source: flair-src/trunk/lib/FlairMeta/src/UavFactory.cpp@ 466

Last change on this file since 466 was 268, checked in by Sanahuja Guillaume, 6 years ago

add defines for architectures to speed up compile time

File size: 2.7 KB
RevLine 
[10]1// %flair:license{
[15]2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
[10]4// %flair:license}
[7]5// created: 2016/02/05
6// filename: UavFactory.cpp
7//
8// author: Guillaume Sanahuja
9// Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11// version: $Id: $
12//
13// purpose: construct a Uav based on the type name
14//
15//
16/*********************************************************************/
17
18#include "UavFactory.h"
19#include "FrameworkManager.h"
20#include "SimuX4.h"
21#include "SimuX8.h"
22#include "HdsX8.h"
23#include "XAir.h"
[45]24#include "compile_info.h"
[7]25
26using namespace std;
27using namespace flair::core;
28using namespace flair::filter;
29using namespace flair::meta;
30
[41]31namespace { // anonymous
[157]32 vector<flair::meta::Uav* (*)(string,string,string,UavMultiplex*)> *vectoroffunctions=NULL;
[41]33}
34
[45]35
36static void constructor() __attribute__((constructor));
37
38void constructor() {
39 compile_info("FlairMeta");
40}
41
42
[157]43Uav *CreateUav(string name, string type,string options,
[15]44 UavMultiplex *multiplex) {
[41]45
46 Uav *uav;
[45]47
48 if(vectoroffunctions!=NULL) {
49 for(int i=0;i<vectoroffunctions->size();i++) {
[157]50 uav=vectoroffunctions->at(i)(name,type,options,multiplex);
[45]51 if(uav!=NULL) {
52 free(vectoroffunctions);
53 vectoroffunctions=NULL;
54 return uav;
55 }
56 }
[41]57 }
58
[268]59#ifdef ARMV7A
[157]60 if (type == "hds_x4") {
61 getFrameworkManager()->Err("UAV type %s not yet implemented\n", type.c_str());
[15]62 return NULL;
[157]63 } else if (type == "hds_x8") {
64 return new HdsX8(name,options, multiplex);
65 } else if (type == "xair") {
66 return new XAir(name,options, multiplex);
67 } else if (type == "hds_xufo") {
68 getFrameworkManager()->Err("UAV type %s not yet implemented\n", type.c_str());
[15]69 return NULL;
[268]70 } else {
71 getFrameworkManager()->Err("UAV type %s unknown\n", type.c_str());
72 return NULL;
73 }
74#endif
75#ifdef CORE2_64
76 if (type.compare(0, 7, "x4_simu") == 0) {
[15]77 int simu_id = 0;
[157]78 if (type.size() > 7) {
79 simu_id = atoi(type.substr(7, type.size() - 7).c_str());
[7]80 }
[157]81 return new SimuX4(name, simu_id,options, multiplex);
82 } else if (type.compare(0, 7, "x8_simu") == 0) {
[15]83 int simu_id = 0;
[157]84 if (type.size() > 7) {
85 simu_id = atoi(type.substr(7, type.size() - 7).c_str());
[15]86 }
[157]87 return new SimuX8(name, simu_id,options, multiplex);
[15]88 } else {
[157]89 getFrameworkManager()->Err("UAV type %s unknown\n", type.c_str());
[15]90 return NULL;
91 }
[268]92#endif
[7]93}
[41]94
[157]95void RegisterUavCreator(flair::meta::Uav*(*func)(string,string,string,UavMultiplex*)) {
96 if(vectoroffunctions==NULL) vectoroffunctions=(vector<flair::meta::Uav* (*)(string,string,string,UavMultiplex*)>*)malloc(sizeof(vector<flair::meta::Uav* (*)(string,string,string,UavMultiplex*)>));
[41]97
[45]98 vectoroffunctions->push_back(func);
[41]99}
Note: See TracBrowser for help on using the repository browser.