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

SourceForge.net Logo
Project
Download
Mailing lists

 

         

libs/orcaice/component.h

00001 /*
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 <orcaice/context.h>
00015 #include <hydroutil/uncopyable.h>
00016 #include <gbxsickacfr/gbxiceutilacfr/safethread.h>
00017 
00018 namespace orcaice
00019 {
00020 
00021 class Status;
00022 
00032 enum ComponentInterfaceFlag {
00034     NoStandardInterfaces    = 0x000,
00036     HomeInterface           = 0x001,
00038     StatusInterface         = 0x010,
00040     TracerInterface         = 0x100,
00042     AllStandardInterfaces   = NoStandardInterfaces | HomeInterface | StatusInterface | TracerInterface
00043 };
00044 
00095 class Component : public hydroutil::Uncopyable
00096 {
00097 // these are declared friends so they can call init(), tag(), finalise()
00098 friend class Application;
00099 friend class Service;
00100 // this one needs to call activate().
00101 friend class Context;
00102 
00103 public:
00108 
00115 
00116     Component( const std::string& tag, ComponentInterfaceFlag flag=AllStandardInterfaces );
00117     virtual ~Component();
00118 
00123     virtual void start()=0;
00124 
00127     virtual void stop()=0;
00128 
00131     virtual const std::string help( const std::string& executable ) const;
00132 
00138 
00142 
00143     virtual const std::string version() const { return std::string(""); };
00144 
00145 protected:
00146 
00156     void activate();
00157 
00164     const Context& context() const { return context_; };
00165 
00167     ComponentInterfaceFlag interfaceFlag() const { return interfaceFlag_; };
00168 
00169 private:
00170 
00171     // One of the container classes (Application or Service) will
00172     // call this function before calling start().
00173     // This is the reason for them to be friends.
00174     void init( const orca::FQComponentName& name,
00175                const bool isApp,
00176                const Ice::ObjectAdapterPtr& adapter );
00177 
00178     // Cleans up resources prior to stop() being called.
00179     void finalise();
00180 
00181     // Only Service should need to use this when the IceBox tells it
00182     // what the actual tag is.
00183     void setTag( const std::string& t ) { context_.tag_ = t; };
00184 
00185     // initialize component services
00186     orcaice::Home*   initHome();
00187     gbxsickacfr::gbxutilacfr::Tracer* initTracer();
00188     gbxsickacfr::gbxutilacfr::Status* initStatus();
00189     hydroutil::History* initHistory();
00190     void getNetworkProperties();
00191 
00192     // Component's context
00193     Context context_;
00194 
00195     // Save init flags
00196     ComponentInterfaceFlag interfaceFlag_;
00197 
00198     // keep the smart pointer so it's not destroyed with the adapter
00199     // (I think we only need to do it with tracer)
00200     Ice::ObjectPtr tracerObj_;
00201     Ice::ObjectPtr statusObj_;
00202     // alexm: why is this one different?
00203     Ice::ObjectPrx homePrx_;
00204 
00205     // This thread allows us to do house-keeping stuff and manage Status.
00206     gbxsickacfr::gbxiceutilacfr::ThreadPtr componentThread_;
00207 };
00208 
00209 } // end namespace
00210 
00211 #endif
 

Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)


Generated for Orca Robotics by  doxygen 1.4.5