rtcprof.cpp
Go to the documentation of this file.
00001 // -*- C++ -*-
00019 #include <iostream>
00020 #include <string>
00021 #include <vector>
00022 
00023 #include <coil/Properties.h>
00024 #include <coil/File.h>
00025 
00026 #include <rtm/Manager.h>
00027 
00028 
00029 int main(int argc, char* argv[])
00030 {
00031   if (argc != 2)
00032     {
00033       std::cerr << "usage: " << std::endl;
00034       std::cerr << argv[0] << " .so or .DLL" << std::endl;
00035       std::cerr << std::endl;
00036       return -1;
00037     }
00038 
00039   //
00040   // notice: coil::dirname brakes original string
00041   // 
00042   // file name with full path
00043   std::string fullname(argv[1]);
00044   // directory name
00045   std::string dirname(coil::dirname(argv[1]));
00046   // basename
00047   std::string basename(coil::basename(fullname.c_str()));
00048 
00049   // making command line option
00050   //   dummy -o manager.modules.load_path
00051   coil::vstring opts;
00052   opts.push_back("dummy");
00053   opts.push_back("-o");
00054   std::string load_path("manager.modules.load_path:");
00055   load_path += dirname;
00056   opts.push_back(load_path);
00057   opts.push_back("-o");
00058   opts.push_back("logger.enable:NO");
00059   opts.push_back("-o");
00060   opts.push_back("manager.corba_servant:NO");
00061 
00062   // Manager initialization
00063   RTC::Manager::init(opts.size(), coil::toArgv(opts));
00064   RTC::Manager& mgr(RTC::Manager::instance());
00065 
00066 
00067   // loaded profile = old profiles - new profiles
00068   std::vector<coil::Properties> oldp(mgr.getFactoryProfiles());
00069   mgr.load(basename.c_str(), "");
00070   std::vector<coil::Properties> newp(mgr.getFactoryProfiles());
00071   std::vector<coil::Properties> profs;
00072 
00073   for (size_t i(0); i < newp.size(); ++i)
00074     {
00075       bool exists(false);
00076       for (size_t j(0); j < oldp.size(); ++j)
00077         {
00078           if (oldp[j]["implementation_id"] == newp[i]["implementation_id"] &&
00079               oldp[j]["type_name"]         == newp[i]["type_name"] &&
00080               oldp[j]["description"]       == newp[i]["description"] &&
00081               oldp[j]["version"]           == newp[i]["version"])
00082             {
00083               exists = true;
00084             }
00085         }
00086       if (!exists) { profs.push_back(newp[i]); }
00087     }
00088 
00089   // loaded component profile have to be one
00090   if (profs.size() == 0)
00091     {
00092       std::cerr << "Load failed." << std::endl;
00093       return -1;
00094     }
00095 
00096   if (profs.size() > 1)
00097     {
00098       std::cerr << "One ore more modules loaded." << std::endl;
00099       return -1;
00100     }
00101 
00102   coil::vstring keys(profs[0].propertyNames());
00103 
00104   for (size_t i(0); i < keys.size(); ++i)
00105     {
00106       std::cout << keys[i] << ": " << profs[0][keys[i]] << std::endl;
00107     }
00108 
00109   return 0;
00110 }


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Sat Jun 8 2019 18:49:06