source: flair-src/trunk/lib/FlairMeta/src/UgvFactory.cpp@ 377

Last change on this file since 377 was 377, checked in by Sanahuja Guillaume, 2 years ago

ugv update

  • Property svn:eol-style set to native
File size: 1.9 KB
Line 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
5// created: 2020/12/16
6// filename: UgvFactory.cpp
7//
8// author: Guillaume Sanahuja
9// Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11// version: $Id: $
12//
13// purpose: construct a Ugv based on the type name
14//
15//
16/*********************************************************************/
17
18#include "UgvFactory.h"
19#include "FrameworkManager.h"
20#include "SimuUgv.h"
21
22
23using namespace std;
24using namespace flair::core;
25using namespace flair::meta;
26
27namespace { // anonymous
28 vector<flair::meta::Ugv* (*)(string,string,string)> *vectoroffunctions=NULL;
29}
30
31
32Ugv *CreateUgv(string name, string type,string options) {
33
34 Ugv *ugv;
35
36 if(vectoroffunctions!=NULL) {
37 for(int i=0;i<vectoroffunctions->size();i++) {
38 ugv=vectoroffunctions->at(i)(name,type,options);
39 if(ugv!=NULL) {
40 free(vectoroffunctions);
41 vectoroffunctions=NULL;
42 return ugv;
43 }
44 }
45 }
46
47#ifdef CORE2_64
48 if (type.compare(0, 8, "ugv_simu") == 0) {
49 int simu_id = 0;
50 if (type.size() > 8) {
51 simu_id = atoi(type.substr(8, type.size() - 8).c_str());
52 }
53 return new SimuUgv(name, simu_id);
54 }/* else if (type.compare(0, 7, "x8_simu") == 0) {
55 int simu_id = 0;
56 if (type.size() > 7) {
57 simu_id = atoi(type.substr(7, type.size() - 7).c_str());
58 }
59 return new SimuX8(name, simu_id,options, multiplex);
60 }*/ else {
61 getFrameworkManager()->Err("UGV type %s unknown\n", type.c_str());
62 return NULL;
63 }
64#endif
65}
66
67void RegisterUgvCreator(flair::meta::Ugv*(*func)(string,string,string)) {
68 if(vectoroffunctions==NULL) vectoroffunctions=(vector<flair::meta::Ugv* (*)(string,string,string)>*)malloc(sizeof(vector<flair::meta::Ugv* (*)(string,string,string)>));
69
70 vectoroffunctions->push_back(func);
71}
Note: See TracBrowser for help on using the repository browser.