rtcsh.cpp
Go to the documentation of this file.
00001 // -*- C++ -*-
00019 #include <iostream>
00020 #include <boost/regex.hpp>
00021 #include <boost/tokenizer.hpp>
00022 #include <vector>
00023 #include <string>
00024 #include <rtm/RtcNaming.h>
00025 #include <rtm/RtcConfig.h>
00026 #include <rtm/RtcManager.h>
00027 
00028 using namespace RTM;
00029 using namespace std;
00030 
00031 
00032 int main(int argc, char** argv)
00033 {
00034   RtcConfig config(argc, argv);
00035   RtcNaming naming;
00036   CORBA::ORB_var orb;
00037 
00038   char** _argv = config.getOrbInitArgv();
00039   int    _argc = config.getOrbInitArgc();
00040 
00041   try {
00042         orb = CORBA::ORB_init(_argc, _argv);
00043         cout << "ORB init done" << endl;
00044   }
00045   catch (...) {
00046         cout << "error cought" << endl;
00047   }
00048   
00049   naming.initNaming(orb);
00050   cout << "Naming init done" << endl;
00051 
00052   string mgrname(".*/.*/Manager.*");
00053   vector<CORBA::Object_ptr> vObj;
00054   naming.findManager(mgrname, vObj);
00055 
00056   cout << "Number of objects:" << vObj.size() << endl;
00057 
00058   if (vObj.size() == 0) {
00059         cout << "Manager could not find." << endl;
00060         return -1;
00061   }
00062 
00063   CORBA::Object_ptr obj = *(vObj.end()-1);
00064   if (CORBA::is_nil(obj)) {
00065         cout << "manager not found" << endl;
00066         return 0;
00067   }
00068 
00069   RTM::RTCManager_var mgr = RTM::RTCManager::_narrow(obj);
00070   if (CORBA::is_nil(mgr)) {
00071         cout << "manager not found" << endl;
00072         return 0;
00073   }
00074  
00075   char* retval;
00076 
00077   string cmd;
00078   while (1) {
00079         cout << ">> ";
00080         getline(cin, cmd);
00081 
00082         //      retval = NULL;
00083         if (cmd.size() > 0 && !CORBA::is_nil(mgr)) {
00084           bool ret = mgr->command(cmd.c_str(), retval);
00085 
00086           if (ret == true) {
00087                 //              cout << "Success: " <<  endl;
00088                 cout << "Success: " << retval <<  endl;
00089                 //              CORBA::string_free(retval);
00090           } else {
00091                 cout << "Error" << endl;
00092           }
00093         }
00094   }
00095   return 0;
00096 }


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