Changeset 45 in flair-src for trunk/lib/FlairMeta/src/UavFactory.cpp


Ignore:
Timestamp:
Jul 18, 2016, 4:13:56 PM (5 years ago)
Author:
Sanahuja Guillaume
Message:

added compile info

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/FlairMeta/src/UavFactory.cpp

    r41 r45  
    1818#include "UavFactory.h"
    1919#include "FrameworkManager.h"
    20 //#include "ArDrone2.h"
    2120#include "SimuX4.h"
    2221#include "SimuX8.h"
    2322#include "HdsX8.h"
    2423#include "XAir.h"
     24#include "compile_info.h"
    2525
    2626using namespace std;
     
    3030
    3131namespace { // anonymous
    32      vector<flair::meta::Uav* (*)(FrameworkManager*,string,string,UavMultiplex*)> vectoroffunctions;
     32     vector<flair::meta::Uav* (*)(FrameworkManager*,string,string,UavMultiplex*)> *vectoroffunctions=NULL;
    3333}
     34
     35
     36static void constructor() __attribute__((constructor));
     37
     38void constructor() {
     39  compile_info("FlairMeta");
     40}
     41
    3442
    3543Uav *CreateUav(FrameworkManager *parent, string uav_name, string uav_type,
     
    3745
    3846  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    }
    4257  }
    4358
     
    7287void RegisterUavCreator(flair::meta::Uav*(*func)(FrameworkManager *parent, string uav_name, string uav_type,
    7388               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*)>));
    7590
     91  vectoroffunctions->push_back(func);
    7692}
Note: See TracChangeset for help on using the changeset viewer.