00001 #pragma once 00002 #ifndef OPENGM_MACROS 00003 #define OPENGM_MACROS 00004 00005 #include <string> 00006 00007 #include "opengm/opengm.hxx" 00008 00009 #define STRING_TO_ENUM_1( CLASS_OF_ENUM,NAME_STRING,PARAM_NAME,ENTRY_1,ENUM_OUT) \ 00010 if (NAME_STRING==std::string( #ENTRY_1)) ENUM_OUT=CLASS_OF_ENUM::ENTRY_1 \ 00011 else (throw RuntimeError(std::string("Wrong value for parameter")+std::string(#PARAM_NAME))) 00012 00013 #define STRING_TO_ENUM_2( CLASS_OF_ENUM,NAME_STRING,PARAM_NAME,ENTRY_1,ENTYR_2,ENUM_OUT) \ 00014 if (NAME_STRING==std::string( #ENTRY_1)) ENUM_OUT=CLASS_OF_ENUM::ENTRY_1 \ 00015 else if (NAME_STRING==std::string( #ENTRY_2)) ENUM_OUT=CLASS_OF_ENUM::ENTRY_2 \ 00016 else (throw RuntimeError(std::string("Wrong value for parameter")+std::string(#PARAM_NAME))) 00017 00018 #define STRING_TO_ENUM_3( CLASS_OF_ENUM,NAME_STRING,PARAM_NAME,ENTRY_1,ENTYR_2,ENTYR_3,ENUM_OUT) \ 00019 if (NAME_STRING==std::string( #ENTRY_1)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_1;} \ 00020 else if (NAME_STRING==std::string( #ENTRY_2)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_2;} \ 00021 else if (NAME_STRING==std::string( #ENTRY_3)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_3;} \ 00022 else {throw RuntimeError(std::string("unsupported value for parameter ")+std::string(#PARAM_NAME));} 00023 00024 #define STRING_TO_ENUM_4( CLASS_OF_ENUM,NAME_STRING,PARAM_NAME,ENTRY_1,ENTYR_2,ENTYR_3,ENTYR_4,ENUM_OUT) \ 00025 if (NAME_STRING==std::string( #ENTRY_1)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_1;} \ 00026 else if (NAME_STRING==std::string( #ENTRY_2)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_2;} \ 00027 else if (NAME_STRING==std::string( #ENTRY_3)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_3;} \ 00028 else if (NAME_STRING==std::string( #ENTRY_4)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_4;} \ 00029 else {throw RuntimeError(std::string("unsupported value for parameter ")+std::string(#PARAM_NAME));} 00030 00031 #define STRING_TO_ENUM_5( CLASS_OF_ENUM,NAME_STRING,PARAM_NAME,ENTRY_1,ENTYR_2,ENTYR_3,ENTYR_4,ENTYR_5,ENUM_OUT) \ 00032 if (NAME_STRING==std::string( #ENTRY_1)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_1;} \ 00033 else if (NAME_STRING==std::string( #ENTRY_2)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_2;} \ 00034 else if (NAME_STRING==std::string( #ENTRY_3)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_3;} \ 00035 else if (NAME_STRING==std::string( #ENTRY_4)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_4;} \ 00036 else if (NAME_STRING==std::string( #ENTRY_5)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_5;} \ 00037 else {throw RuntimeError(std::string("unsupported value for parameter ")+std::string(#PARAM_NAME));} 00038 00039 #define STRING_TO_ENUM_6( CLASS_OF_ENUM,NAME_STRING,PARAM_NAME,ENTRY_1,ENTYR_2,ENTYR_3,ENTYR_4,ENTYR_5,ENTYR_6,ENUM_OUT) \ 00040 if (NAME_STRING==std::string( #ENTRY_1)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_1;} \ 00041 else if (NAME_STRING==std::string( #ENTRY_2)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_2;} \ 00042 else if (NAME_STRING==std::string( #ENTRY_3)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_3;} \ 00043 else if (NAME_STRING==std::string( #ENTRY_4)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_4;} \ 00044 else if (NAME_STRING==std::string( #ENTRY_5)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_5;} \ 00045 else if (NAME_STRING==std::string( #ENTRY_6)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_6;} \ 00046 else {throw RuntimeError(std::string("unsupported value for parameter ")+std::string(#PARAM_NAME));} 00047 00048 #define STRING_TO_ENUM_7( CLASS_OF_ENUM,NAME_STRING,PARAM_NAME,ENTRY_1,ENTYR_2,ENTYR_3,ENTYR_4,ENTYR_5,ENTYR_6,ENTYR_7,ENUM_OUT) \ 00049 if (NAME_STRING==std::string( #ENTRY_1)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_1;} \ 00050 else if (NAME_STRING==std::string( #ENTRY_2)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_2;} \ 00051 else if (NAME_STRING==std::string( #ENTRY_3)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_3;} \ 00052 else if (NAME_STRING==std::string( #ENTRY_4)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_4;} \ 00053 else if (NAME_STRING==std::string( #ENTRY_5)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_5;} \ 00054 else if (NAME_STRING==std::string( #ENTRY_6)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_6;} \ 00055 else if (NAME_STRING==std::string( #ENTRY_7)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_7;} \ 00056 else {throw RuntimeError(std::string("unsupported value for parameter ")+std::string(#PARAM_NAME));} 00057 00058 #define STRING_TO_ENUM_8( CLASS_OF_ENUM,NAME_STRING,PARAM_NAME,ENTRY_1,ENTYR_2,ENTYR_3,ENTYR_4,ENTYR_5,ENTYR_6,ENTYR_7,ENTYR_8,ENUM_OUT) \ 00059 if (NAME_STRING==std::string( #ENTRY_1)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_1;} \ 00060 else if (NAME_STRING==std::string( #ENTRY_2)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_2;} \ 00061 else if (NAME_STRING==std::string( #ENTRY_3)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_3;} \ 00062 else if (NAME_STRING==std::string( #ENTRY_4)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_4;} \ 00063 else if (NAME_STRING==std::string( #ENTRY_5)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_5;} \ 00064 else if (NAME_STRING==std::string( #ENTRY_6)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_6;} \ 00065 else if (NAME_STRING==std::string( #ENTRY_7)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_7;} \ 00066 else if (NAME_STRING==std::string( #ENTRY_8)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_8;} \ 00067 else {throw RuntimeError(std::string("unsupported value for parameter ")+std::string(#PARAM_NAME));} 00068 00069 #define STRING_TO_ENUM_9( CLASS_OF_ENUM,NAME_STRING,PARAM_NAME,ENTRY_1,ENTYR_2,ENTYR_3,ENTYR_4,ENTYR_5,ENTYR_6,ENTYR_7,ENTYR_8,ENTYR_9,ENUM_OUT) \ 00070 if (NAME_STRING==std::string( #ENTRY_1)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_1;} \ 00071 else if (NAME_STRING==std::string( #ENTRY_2)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_2;} \ 00072 else if (NAME_STRING==std::string( #ENTRY_3)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_3;} \ 00073 else if (NAME_STRING==std::string( #ENTRY_4)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_4;} \ 00074 else if (NAME_STRING==std::string( #ENTRY_5)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_5;} \ 00075 else if (NAME_STRING==std::string( #ENTRY_6)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_6;} \ 00076 else if (NAME_STRING==std::string( #ENTRY_7)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_7;} \ 00077 else if (NAME_STRING==std::string( #ENTRY_8)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_8;} \ 00078 else if (NAME_STRING==std::string( #ENTRY_9)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_9;} \ 00079 else {throw RuntimeError(std::string("unsupported value for parameter ")+std::string(#PARAM_NAME));} 00080 00081 #define STRING_TO_ENUM_10( CLASS_OF_ENUM,NAME_STRING,PARAM_NAME,ENTRY_1,ENTYR_2,ENTYR_3,ENTYR_4,ENTYR_5,ENTYR_6,ENTYR_7,ENTYR_8,ENTYR_9,ENTYR_10,ENUM_OUT) \ 00082 if (NAME_STRING==std::string( #ENTRY_1)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_1;} \ 00083 else if (NAME_STRING==std::string( #ENTRY_2)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_2;} \ 00084 else if (NAME_STRING==std::string( #ENTRY_3)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_3;} \ 00085 else if (NAME_STRING==std::string( #ENTRY_4)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_4;} \ 00086 else if (NAME_STRING==std::string( #ENTRY_5)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_5;} \ 00087 else if (NAME_STRING==std::string( #ENTRY_6)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_6;} \ 00088 else if (NAME_STRING==std::string( #ENTRY_7)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_7;} \ 00089 else if (NAME_STRING==std::string( #ENTRY_8)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_8;} \ 00090 else if (NAME_STRING==std::string( #ENTRY_9)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_9;} \ 00091 else if (NAME_STRING==std::string( #ENTRY_10)) {ENUM_OUT=CLASS_OF_ENUM::ENTRY_10;} \ 00092 else {throw RuntimeError(std::string("unsupported value for parameter ")+std::string(#PARAM_NAME));} 00093 00094 #endif // #ifndef OPENGM_MACROS