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

 

         

orcaice::Component Class Reference

Base class for all Components using libOrcaIce. More...

#include <component.h>

Inherits hydroutil::Uncopyable.

Inherited by bicycle::Component, disparity::Component, laserview::Component, orcaview2d::Component, orcaview3d::Component, probe::Component, registryview::Component, robot2d::Component, teleop::Component, TestComponent, TestComponent, TestComponent, TestComponent, TestComponent, TestComponent, TestComponent, TestComponent, TestComponent, TestComponent, TestComponent, TestComponent, TestComponent, TestComponent, TestComponent, TestComponent, TestComponent, TestComponent, TestComponent, TestComponent, and tracermon::Component.

List of all members.

Public Member Functions

 Component (const std::string &tag, ComponentInterfaceFlag flag=AllStandardInterfaces, ComponentAdapterActivationPolicy adapterPolicy=AdapterAutoActivation)
virtual void start ()=0
virtual void stop ()
virtual const std::string help (const std::string &executable) const
virtual const std::string version () const

Protected Member Functions

void activate ()
const Contextcontext () const

Detailed Description

Base class for all Components using libOrcaIce.

Deriving from this makes it easy to use code as either a stand-alone application (using orcaice::Application) or as a service in an IceBox (using orcaice::Service). Two functions must be implemented: start and stop.

Most of the state of the component is summarized in its Component::context. The information is read-only because it is set prior to the component's initialization.

Component Initialisation

Component initialisation code can be put in two places:

1. Component Constructor

  • In the constructor, none of the orcaice machinery is initialised. This means that no remote calls can be made (the communicator isn't initialised yet), and the tracer isn't available yet.
  • Any code that should be executed before any remote calls are made belongs in the Component constructor.

2. Component::start()

  • start() is called after all resources in Context are initialised.
    • Home and Status interfaces are initialized from a separate thread and it may take multiple attempts to do this.
  • This is the place to launch threads from and get out.
    • Don't do anything that might loop forever in here, otherwise it won't be possible to bring the component down cleanly.
Component Destruction

Clean-up code belongs in one of two places:

1. Component::stop()

  • The context and communicator are still available at this point

2. Component Destructor

  • The context and communicator are no longer available
Author:
Alex Brooks, Alexei Makarenko
See also:
Application, Service, Context
Tracer, Status

Constructor & Destructor Documentation

orcaice::Component::Component ( const std::string &  tag,
ComponentInterfaceFlag  flag = AllStandardInterfaces,
ComponentAdapterActivationPolicy  adapterPolicy = AdapterAutoActivation 
)

Takes the text tag with which to identify it in the config files. The flag specifies what standard interfaces to initialize. It is also possible to configure standard interfaces with the following configuration parameters.

Orca.Component.EnableTracer
Orca.Component.EnableStatus
Orca.Component.EnableHome

Inside this contructor the component context is not initialized yet and cannot be used.


Member Function Documentation

void orcaice::Component::activate (  )  [inline, protected]

Activates the component's adapter. Activation makes provided interfaces accessible from the outside world. It also tries to register the adapter with the IceGrid Registry. If the registry is unreachable, the adapter is not fully activated.

An Orca configuration property Orca.Component.RequireRegistry determines what happens if the Registry is not available. If RequireRegistry=1 (default) and the registry is unreachable, an orcaice::NetworkException is thrown. In this case it is safe to call activate again later, hoping that the regisry will become reachable. If RequireRegistry=0 no exception is thrown.

References orcaice::Context::activate().

const Context& orcaice::Component::context (  )  const [inline, protected]

Component's "context", which contains component's naming and networking information. It can be used directly or passed to threads and classes. For example:

    //!context().tracer().info("Everything is OK");
    //!MainLoop myloop( context() );
    //! 
const std::string orcaice::Component::help ( const std::string &  executable  )  const [virtual]

This function is called by Application when the executable is called with --help command line option.

References hydroutil::basename().

virtual void orcaice::Component::start (  )  [pure virtual]

This function is called by the component's container (Application or Service). It should return immediately, possibly after launching a thread. GUI components are an exception to this rule, they may run in the calling thread provided that the Ctrl-C handler was not installed (see Application, Service).

virtual void orcaice::Component::stop (  )  [inline, virtual]

This function is called by the component's container (Application or Service) when the component is ordered to stop execution. Default implementation does nothing.

virtual const std::string orcaice::Component::version (  )  const [inline, virtual]

This function is called by Application on startup (including when the executable is ! called with --version command line option). Standard Orca components return an ! empty string. Component from external project may reimplement this function to supply ! the project version, which is probably different from the Orca version. ! Example:

virtual const std::string version() const { return std::string(PROJECT_VERSION); };

! Note that PROJECT_VERSION is defined automatically for all projects.


The documentation for this class was generated from the following files:
 

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


Generated for Orca Robotics by  doxygen 1.4.5