Changeset 45 in flair-src for trunk/lib/FlairMeta/src/UavFactory.cpp
- Timestamp:
- 07/18/16 16:13:56 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairMeta/src/UavFactory.cpp
r41 r45 18 18 #include "UavFactory.h" 19 19 #include "FrameworkManager.h" 20 //#include "ArDrone2.h"21 20 #include "SimuX4.h" 22 21 #include "SimuX8.h" 23 22 #include "HdsX8.h" 24 23 #include "XAir.h" 24 #include "compile_info.h" 25 25 26 26 using namespace std; … … 30 30 31 31 namespace { // anonymous 32 vector<flair::meta::Uav* (*)(FrameworkManager*,string,string,UavMultiplex*)> vectoroffunctions;32 vector<flair::meta::Uav* (*)(FrameworkManager*,string,string,UavMultiplex*)> *vectoroffunctions=NULL; 33 33 } 34 35 36 static void constructor() __attribute__((constructor)); 37 38 void constructor() { 39 compile_info("FlairMeta"); 40 } 41 34 42 35 43 Uav *CreateUav(FrameworkManager *parent, string uav_name, string uav_type, … … 37 45 38 46 Uav *uav; 39 for(int i=0;i<vectoroffunctions.size();i++) { 40 uav=vectoroffunctions.at(i)(parent, uav_name, uav_type,multiplex); 41 if(uav!=NULL) return uav; 47 48 if(vectoroffunctions!=NULL) { 49 for(int i=0;i<vectoroffunctions->size();i++) { 50 uav=vectoroffunctions->at(i)(parent, uav_name, uav_type,multiplex); 51 if(uav!=NULL) { 52 free(vectoroffunctions); 53 vectoroffunctions=NULL; 54 return uav; 55 } 56 } 42 57 } 43 58 … … 72 87 void RegisterUavCreator(flair::meta::Uav*(*func)(FrameworkManager *parent, string uav_name, string uav_type, 73 88 UavMultiplex *multiplex)) { 74 vectoroffunctions.push_back(func);89 if(vectoroffunctions==NULL) vectoroffunctions=(vector<flair::meta::Uav* (*)(FrameworkManager*,string,string,UavMultiplex*)>*)malloc(sizeof(vector<flair::meta::Uav* (*)(FrameworkManager*,string,string,UavMultiplex*)>)); 75 90 91 vectoroffunctions->push_back(func); 76 92 }
Note:
See TracChangeset
for help on using the changeset viewer.