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

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

up ugv

  • Property svn:eol-style set to native
File size: 1.7 KB
RevLine 
[377]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"
[378]21#include "SumoUgv.h"
[377]22
23
24using namespace std;
25using namespace flair::core;
26using namespace flair::meta;
27
28namespace { // anonymous
29 vector<flair::meta::Ugv* (*)(string,string,string)> *vectoroffunctions=NULL;
30}
31
32
33Ugv *CreateUgv(string name, string type,string options) {
34
35 Ugv *ugv;
36
37 if(vectoroffunctions!=NULL) {
38 for(int i=0;i<vectoroffunctions->size();i++) {
39 ugv=vectoroffunctions->at(i)(name,type,options);
40 if(ugv!=NULL) {
41 free(vectoroffunctions);
42 vectoroffunctions=NULL;
43 return ugv;
44 }
45 }
46 }
47
48#ifdef CORE2_64
49 if (type.compare(0, 8, "ugv_simu") == 0) {
50 int simu_id = 0;
51 if (type.size() > 8) {
52 simu_id = atoi(type.substr(8, type.size() - 8).c_str());
53 }
54 return new SimuUgv(name, simu_id);
[378]55 } else if (type.compare(0, 4, "sumo") == 0) {
56 return new SumoUgv(name);
57 } else {
[377]58 getFrameworkManager()->Err("UGV type %s unknown\n", type.c_str());
59 return NULL;
60 }
61#endif
62}
63
64void RegisterUgvCreator(flair::meta::Ugv*(*func)(string,string,string)) {
65 if(vectoroffunctions==NULL) vectoroffunctions=(vector<flair::meta::Ugv* (*)(string,string,string)>*)malloc(sizeof(vector<flair::meta::Ugv* (*)(string,string,string)>));
66
67 vectoroffunctions->push_back(func);
68}
Note: See TracBrowser for help on using the repository browser.