Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 #include <telekyb_base/TeleKyb.hpp>
00009 #include <telekyb_base/Options/RawOptionsContainer.hpp>
00010 #include <telekyb_base/Options/CommonOptions.hpp>
00011 #include <telekyb_base/ROS/ROSOptionController.hpp>
00012 #include <telekyb_base/ROS/ROSModule.hpp>
00013 
00014 #include <telekyb_base/Base/BaseSingleton.hpp>
00015 
00016 #include <ros/init.h>
00017 #include <ros/console.h>
00018 
00019 
00020 #include <boost/lexical_cast.hpp>
00021 
00022 namespace TELEKYB_NAMESPACE {
00023 
00024 bool TeleKyb::initialized = false;
00025 
00026 void TeleKyb::init(int argc, char* argv[], const std::string& name, uint32_t options)
00027 {
00028         
00029         ros::init(argc, argv, name, options);
00030 
00031         
00032         
00033         
00034 
00035         
00036         telekyb::RawOptionsContainer::parseCommandLine(argc, argv, true);
00037         
00038         CommonOptions& co = CommonOptions::Instance();
00039         
00040         co.setNodeName(name);
00041 
00042         
00043         if (!co.tConfigFile->isOnInitialValue()) {
00044                 telekyb::RawOptionsContainer::parseFile(co.tConfigFile->getValue(), false);
00045         }
00046 
00047         
00048         co.updateFromRawOptions(true);
00049 
00050         
00051 
00052         
00053         if (co.tPrintOptions->getValue()) {
00054                 BaseOption::printOptions = true;
00055                 co.printOptions();
00056         }
00057 
00058 
00060         
00061         if (ROSModule::HasInstance()) {
00062                 ROS_FATAL("Trying to create Singleton ROSModule, but it already exits!");
00063                 
00064                 ros::shutdown();
00065         }
00066 
00067         
00068         ROSModule::Instance();
00069 
00070 
00071         
00072         ROSOptionController::Instance();
00073 
00074         
00075         initialized = true;
00076 }
00077 
00078 bool TeleKyb::isInitialized()
00079 {
00080         
00081         return initialized;
00082 }
00083 
00084 void TeleKyb::shutdown()
00085 {
00086         
00087         
00088 
00089         
00090         CommonOptions::ShutDownInstance();
00091         ROSModule::ShutDownInstance();
00092 
00093         ROSOptionController::ShutDownInstance();
00094 
00095         
00096         BaseSingleton::deleteAllSingletons();
00097 
00098         initialized = false;
00099 }
00100 
00101 }