INTRODUCTION
Overview
Download and Install
Quick Start
Documentation
Publications

NONFRAMEWORK CODE
Driver Interfaces
Drivers
Libraries
Utilities

FRAMEWORK CODE
Interfaces
Components
Libraries
Utilities

Full Software Listings

DEVELOPER
Tutorials
Examples
Dev Guide
Dashboard

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-2009 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 
00039 {
00041     NoStandardInterfaces    = 0x000,
00043     HomeInterface           = 0x001,
00045     StatusInterface         = 0x010,
00047     TracerInterface         = 0x100,
00049     AllStandardInterfaces   = HomeInterface | StatusInterface | TracerInterface
00050 };
00051 
00055 enum ComponentAdapterActivationPolicy
00056 {
00058     AdapterManualActivation=0,
00061     AdapterAutoActivation
00062 };
00063 
00114 class Component : public hydroutil::Uncopyable
00115 {
00116 // these are declared friends so they can call init(), tag(), finalise()
00117 friend class Application;
00118 friend class Service;
00119 
00120 public:
00133     Component( const std::string& tag, 
00134                ComponentInterfaceFlag flag=AllStandardInterfaces,
00135                ComponentAdapterActivationPolicy adapterPolicy=AdapterAutoActivation );
00136     virtual ~Component();
00137 
00142     virtual void start()=0;
00143 
00147     virtual void stop() {};
00148 
00151     virtual const std::string help( const std::string& executable ) const;
00152 
00158 
00162 
00163     virtual const std::string version() const { return std::string(""); };
00164 
00165 protected:
00166 
00176     void activate() { context_.activate(); };
00177 
00184     const Context& context() const { return context_; };
00185 
00186 private:
00187 
00188     // One of the container classes (Application or Service) will
00189     // call this function before calling start().
00190     // This is the reason for them to be friends.
00191     void init( const orca::FQComponentName& name,
00192                const bool isApp,
00193                const Ice::ObjectAdapterPtr& adapter );
00194 
00195     // Cleans up internal resources after stop() was called
00196     // but before complete shutdown.
00197     void finalise();
00198 
00199     // Only Service should need to use this when the IceBox tells it
00200     // what the actual tag is.
00201     void setTag( const std::string& t ) { context_.tag_ = t; };
00202 
00203     // Save init flags (for the period between the constructor and init())
00204     ComponentInterfaceFlag interfaceFlag_;
00205     ComponentAdapterActivationPolicy adapterPolicy_;
00206 
00207     std::auto_ptr<detail::HomeImpl> home_;
00208     std::auto_ptr<detail::StatusImpl> status_;
00209     std::auto_ptr<detail::TracerImpl> tracer_;
00210     std::auto_ptr<hydroutil::History> history_;
00211 
00212     // This thread allows us to do house-keeping stuff and manage Status.
00213     gbxiceutilacfr::ThreadPtr componentThread_;
00214 
00215     // Component's context
00216     Context context_;
00217 };
00218 
00219 } // end namespace
00220 
00221 #endif
 

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


Generated for Orca Robotics by  doxygen 1.4.5