|
orca-robotics INTRODUCTION Overview Download and Install Quick Start Documentation Publications REPOSITORY Interfaces Components Libraries Utilities Software Map DEVELOPER Tutorials Examples Dev Guide Dashboard Wiki login/pass: orca/orca PEOPLE Contributors Users Project Download Mailing lists
|
libs/orcaice/component.h00001 /* 00002 * Orca-Robotics Project: Components for robotics 00003 * http://orca-robotics.sf.net/ 00004 * Copyright (c) 2004-2008 Alex Brooks, Alexei Makarenko, Tobias Kaupp 00005 * 00006 * This copy of Orca is licensed to you under the terms described in 00007 * the LICENSE file included in this distribution. 00008 * 00009 */ 00010 00011 #ifndef ORCAICE_COMPONENT_H 00012 #define ORCAICE_COMPONENT_H 00013 00014 #include <memory> 00015 #include <orcaice/context.h> 00016 #include <hydroutil/uncopyable.h> 00017 #include <gbxsickacfr/gbxiceutilacfr/thread.h> 00018 00019 namespace orcaice 00020 { 00021 00022 namespace detail 00023 { 00024 class HomeImpl; 00025 class StatusImpl; 00026 class TracerImpl; 00027 } 00028 00038 enum ComponentInterfaceFlag { 00040 NoStandardInterfaces = 0x000, 00042 HomeInterface = 0x001, 00044 StatusInterface = 0x010, 00046 TracerInterface = 0x100, 00048 AllStandardInterfaces = HomeInterface | StatusInterface | TracerInterface 00049 }; 00050 00101 class Component : public hydroutil::Uncopyable 00102 { 00103 // these are declared friends so they can call init(), tag(), finalise() 00104 friend class Application; 00105 friend class Service; 00106 00107 public: 00120 Component( const std::string& tag, ComponentInterfaceFlag flag=AllStandardInterfaces ); 00121 virtual ~Component(); 00122 00127 virtual void start()=0; 00128 00132 virtual void stop() {}; 00133 00136 virtual const std::string help( const std::string& executable ) const; 00137 00143 00147 00148 virtual const std::string version() const { return std::string(""); }; 00149 00150 protected: 00151 00161 void activate() { context_.activate(); }; 00162 00169 const Context& context() const { return context_; }; 00170 00171 private: 00172 00173 // One of the container classes (Application or Service) will 00174 // call this function before calling start(). 00175 // This is the reason for them to be friends. 00176 void init( const orca::FQComponentName& name, 00177 const bool isApp, 00178 const Ice::ObjectAdapterPtr& adapter ); 00179 00180 // Cleans up internal resources after stop() was called 00181 // but before complete shutdown. 00182 void finalise(); 00183 00184 // Only Service should need to use this when the IceBox tells it 00185 // what the actual tag is. 00186 void setTag( const std::string& t ) { context_.tag_ = t; }; 00187 00188 // Save init flags (for the period between the constructor and init()) 00189 ComponentInterfaceFlag interfaceFlag_; 00190 00191 std::auto_ptr<detail::HomeImpl> home_; 00192 std::auto_ptr<detail::StatusImpl> status_; 00193 std::auto_ptr<detail::TracerImpl> tracer_; 00194 std::auto_ptr<hydroutil::History> history_; 00195 00196 // This thread allows us to do house-keeping stuff and manage Status. 00197 gbxiceutilacfr::ThreadPtr componentThread_; 00198 00199 // Component's context 00200 Context context_; 00201 }; 00202 00203 } // end namespace 00204 00205 #endif |
Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)
1.4.5