Changeset 157 in flair-src for trunk/lib/FlairMeta/src/UavFactory.cpp
- Timestamp:
- Mar 4, 2017, 3:29:18 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairMeta/src/UavFactory.cpp
r122 r157 30 30 31 31 namespace { // anonymous 32 vector<flair::meta::Uav* (*)(string,string, UavMultiplex*)> *vectoroffunctions=NULL;32 vector<flair::meta::Uav* (*)(string,string,string,UavMultiplex*)> *vectoroffunctions=NULL; 33 33 } 34 34 … … 41 41 42 42 43 Uav *CreateUav(string name, string uav_type,43 Uav *CreateUav(string name, string type,string options, 44 44 UavMultiplex *multiplex) { 45 45 … … 48 48 if(vectoroffunctions!=NULL) { 49 49 for(int i=0;i<vectoroffunctions->size();i++) { 50 uav=vectoroffunctions->at(i)(name, uav_type,multiplex);50 uav=vectoroffunctions->at(i)(name,type,options,multiplex); 51 51 if(uav!=NULL) { 52 52 free(vectoroffunctions); … … 57 57 } 58 58 59 if ( uav_type == "hds_x4") {60 getFrameworkManager()->Err("UAV type %s not yet implemented\n", uav_type.c_str());59 if (type == "hds_x4") { 60 getFrameworkManager()->Err("UAV type %s not yet implemented\n", type.c_str()); 61 61 return NULL; 62 } else if ( uav_type == "hds_x8") {63 return new HdsX8(name, multiplex);64 } else if ( uav_type == "xair") {65 return new XAir(name, multiplex);66 } else if ( uav_type == "hds_xufo") {67 getFrameworkManager()->Err("UAV type %s not yet implemented\n", uav_type.c_str());62 } else if (type == "hds_x8") { 63 return new HdsX8(name,options, multiplex); 64 } else if (type == "xair") { 65 return new XAir(name,options, multiplex); 66 } else if (type == "hds_xufo") { 67 getFrameworkManager()->Err("UAV type %s not yet implemented\n", type.c_str()); 68 68 return NULL; 69 } else if ( uav_type.compare(0, 7, "x4_simu") == 0) {69 } else if (type.compare(0, 7, "x4_simu") == 0) { 70 70 int simu_id = 0; 71 if ( uav_type.size() > 7) {72 simu_id = atoi( uav_type.substr(7, uav_type.size() - 7).c_str());71 if (type.size() > 7) { 72 simu_id = atoi(type.substr(7, type.size() - 7).c_str()); 73 73 } 74 return new SimuX4(name, simu_id, multiplex);75 } else if ( uav_type.compare(0, 7, "x8_simu") == 0) {74 return new SimuX4(name, simu_id,options, multiplex); 75 } else if (type.compare(0, 7, "x8_simu") == 0) { 76 76 int simu_id = 0; 77 if ( uav_type.size() > 7) {78 simu_id = atoi( uav_type.substr(7, uav_type.size() - 7).c_str());77 if (type.size() > 7) { 78 simu_id = atoi(type.substr(7, type.size() - 7).c_str()); 79 79 } 80 return new SimuX8(name, simu_id, multiplex);80 return new SimuX8(name, simu_id,options, multiplex); 81 81 } else { 82 getFrameworkManager()->Err("UAV type %s unknown\n", uav_type.c_str());82 getFrameworkManager()->Err("UAV type %s unknown\n", type.c_str()); 83 83 return NULL; 84 84 } 85 85 } 86 86 87 void RegisterUavCreator(flair::meta::Uav*(*func)(string name, string type, 88 UavMultiplex *multiplex)) { 89 if(vectoroffunctions==NULL) vectoroffunctions=(vector<flair::meta::Uav* (*)(string,string,UavMultiplex*)>*)malloc(sizeof(vector<flair::meta::Uav* (*)(string,string,UavMultiplex*)>)); 87 void RegisterUavCreator(flair::meta::Uav*(*func)(string,string,string,UavMultiplex*)) { 88 if(vectoroffunctions==NULL) vectoroffunctions=(vector<flair::meta::Uav* (*)(string,string,string,UavMultiplex*)>*)malloc(sizeof(vector<flair::meta::Uav* (*)(string,string,string,UavMultiplex*)>)); 90 89 91 90 vectoroffunctions->push_back(func);
Note:
See TracChangeset
for help on using the changeset viewer.