rtcprof.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
19 #include <iostream>
20 #include <string>
21 #include <vector>
22 
23 #include <coil/Properties.h>
24 #include <coil/File.h>
25 
26 #include <rtm/Manager.h>
27 
28 
29 int main(int argc, char* argv[])
30 {
31  if (argc != 2)
32  {
33  std::cerr << "usage: " << std::endl;
34  std::cerr << argv[0] << " .so or .DLL" << std::endl;
35  std::cerr << std::endl;
36  return -1;
37  }
38 
39  //
40  // notice: coil::dirname brakes original string
41  //
42  // file name with full path
43  std::string fullname(argv[1]);
44  // directory name
45  std::string dirname(coil::dirname(argv[1]));
46  // basename
47  std::string basename(coil::basename(fullname.c_str()));
48 
49  // making command line option
50  // dummy -o manager.modules.load_path
51  coil::vstring opts;
52  opts.push_back("dummy");
53  opts.push_back("-o");
54  std::string load_path("manager.modules.load_path:");
55  load_path += dirname;
56  opts.push_back(load_path);
57  opts.push_back("-o");
58  opts.push_back("logger.enable:NO");
59  opts.push_back("-o");
60  opts.push_back("manager.corba_servant:NO");
61 
62  // Manager initialization
63  RTC::Manager::init(opts.size(), coil::toArgv(opts));
65 
66 
67  // loaded profile = old profiles - new profiles
68  std::vector<coil::Properties> oldp(mgr.getFactoryProfiles());
69  mgr.load(basename.c_str(), "");
70  std::vector<coil::Properties> newp(mgr.getFactoryProfiles());
71  std::vector<coil::Properties> profs;
72 
73  for (size_t i(0); i < newp.size(); ++i)
74  {
75  bool exists(false);
76  for (size_t j(0); j < oldp.size(); ++j)
77  {
78  if (oldp[j]["implementation_id"] == newp[i]["implementation_id"] &&
79  oldp[j]["type_name"] == newp[i]["type_name"] &&
80  oldp[j]["description"] == newp[i]["description"] &&
81  oldp[j]["version"] == newp[i]["version"])
82  {
83  exists = true;
84  }
85  }
86  if (!exists) { profs.push_back(newp[i]); }
87  }
88 
89  // loaded component profile have to be one
90  if (profs.size() == 0)
91  {
92  std::cerr << "Load failed." << std::endl;
93  return -1;
94  }
95 
96  if (profs.size() > 1)
97  {
98  std::cerr << "One ore more modules loaded." << std::endl;
99  return -1;
100  }
101 
102  coil::vstring keys(profs[0].propertyNames());
103 
104  for (size_t i(0); i < keys.size(); ++i)
105  {
106  std::cout << keys[i] << ": " << profs[0][keys[i]] << std::endl;
107  }
108 
109  return 0;
110 }
int main(int argc, char *argv[])
Definition: rtcprof.cpp:29
Manager class.
Definition: Manager.h:80
static Manager & instance()
Get instance of the manager.
Definition: Manager.cpp:140
RTComponent manager class.
std::vector< std::string > vstring
Definition: stringutil.h:37
def j(str, encoding="cp932")
Definition: RunAtFirst.py:198
static Manager * init(int argc, char **argv)
Initialize manager.
Definition: Manager.cpp:110
char ** toArgv(const vstring &args)
Convert the given string list into the argument list.
Definition: stringutil.cpp:568
const char * basename(const char *path)
Get a file name part than a file pass.
Definition: ace/coil/File.h:33
const char * dirname(const char *path)
Definition: ace/coil/File.h:28


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Jun 6 2019 19:26:00