00001
00011
00012 #include <map>
00013
00014 #include <vector>
00015
00016
00017 #include "dependencies.h"
00018
00019 namespace ace {
00020
00021
00022
00023 typedef std::map<std::string, dependency_index_t> string_to_dependency_t;
00024
00025
00026 typedef std::vector<std::string> dependency_to_string_t;
00027
00028
00029 namespace dependency {
00030 dependency_index_t head = 0;
00031 dependency_index_t undef = 0;
00032 }
00033
00034
00035 const dependency_index_t number_of_dependencies = 118;
00036
00037
00038
00039
00040 const char* dependency_to_cstring_tab[number_of_dependencies] = {
00041 "Adv", "Adv_Ap", "Adv_Co", "Adv_Pa",
00042 "AdvAtr", "AdvAtr_Ap", "AdvAtr_Co", "AdvAtr_Pa",
00043 "Apos", "Apos_Ap", "Apos_Co", "Apos_Pa",
00044 "Atr", "Atr_Ap", "Atr_Co", "Atr_Pa",
00045 "AtrAdv", "AtrAdv_Ap", "AtrAdv_Co", "AtrAdv_Pa",
00046 "AtrAtr", "AtrAtr_Ap", "AtrAtr_Co", "AtrAtr_Pa",
00047 "AtrObj", "AtrObj_Ap", "AtrObj_Co", "AtrObj_Pa",
00048 "Atv", "Atv_Ap", "Atv_Co", "Atv_Pa",
00049 "AtvV", "AtvV_Ap", "AtvV_Co", "AtvV_Pa",
00050 "Aux", "Aux_Ap", "Aux_Co", "Aux_Pa",
00051 "AuxC", "AuxC_Ap", "AuxC_Co", "AuxC_Pa",
00052 "AuxG", "AuxG_Ap", "AuxG_Co", "AuxG_Pa",
00053 "AuxK", "AuxK_Ap", "AuxK_Co", "AuxK_Pa",
00054 "AuxO", "AuxO_Ap", "AuxO_Co", "AuxO_Pa",
00055 "AuxP", "AuxP_Ap", "AuxP_Co", "AuxP_Pa",
00056 "AuxR", "AuxR_Ap", "AuxR_Co", "AuxR_Pa",
00057 "AuxS", "AuxS_Ap", "AuxS_Co", "AuxS_Pa",
00058 "AuxT", "AuxT_Ap", "AuxT_Co", "AuxT_Pa",
00059 "AuxV", "AuxV_Ap", "AuxV_Co", "AuxV_Pa",
00060 "AuxX", "AuxX_Ap", "AuxX_Co", "AuxX_Pa",
00061 "AuxY", "AuxY_Ap", "AuxY_Co", "AuxY_Pa",
00062 "AuxZ", "AuxZ_Ap", "AuxZ_Co", "AuxZ_Pa",
00063 "Coord", "Coord_Ap", "Coord_Co", "Coord_Pa",
00064 "ExD", "ExD_Ap", "ExD_Co", "ExD_Pa",
00065 "Head",
00066 "Obj", "Obj_Ap", "Obj_Co", "Obj_Pa",
00067 "ObjAtr", "ObjAtr_Ap", "ObjAtr_Co", "ObjAtr_Pa",
00068 "Pnom", "Pnom_Ap", "Pnom_Co", "Pnom_Pa",
00069 "Pred", "Pred_Ap", "Pred_Co", "Pred_Pa",
00070 "Sb", "Sb_Ap", "Sb_Co", "Sb_Pa",
00071 "Undef"
00072 };
00073
00076 string_to_dependency_t _init_str2dep(void) {
00077
00078 string_to_dependency_t str2dep;
00079
00080
00081 for ( unsigned i = 0; i < number_of_dependencies; ++i ) {
00082 std::string str = std::string(dependency_to_cstring_tab[i]);
00083 str2dep.insert(string_to_dependency_t::value_type(str, static_cast<dependency_index_t>(i)));
00084 if ( str == std::string("Head") ) {
00085
00086 dependency::head = static_cast<dependency_index_t>(i);
00087 }
00088 if ( str == std::string("Undef") ) {
00089
00090 dependency::undef = static_cast<dependency_index_t>(i);
00091 }
00092 }
00093
00094 return str2dep;
00095 }
00096
00097
00098
00099 dependency_index_t string2dependency(std::string& str) {
00100 static string_to_dependency_t str2dep = _init_str2dep();
00101
00102 string_to_dependency_t::iterator founded = str2dep.find(str);
00103 return (founded == str2dep.end()) ? dependency::undef : founded->second;
00104 }
00105
00106
00107
00108 const char * dependency2cstring(dependency_index_t dependency_index) {
00109 return dependency_to_cstring_tab[dependency_index];
00110 }
00111
00112 }