Goby v2
Protected Types | Protected Member Functions | List of all members
goby::pb::Application Class Reference

Base class provided for users to generate applications that participate in the Goby publish/subscribe architecture. More...

#include <goby/pb/application.h>

Inheritance diagram for goby::pb::Application:
Inheritance graph
[legend]

Protected Types

typedef goby::common::Colors Colors
 

Protected Member Functions

template<typename ProtoBufMessage >
void subscribe (boost::function< void(const ProtoBufMessage &)> handler=boost::function< void(const ProtoBufMessage &)>(), const std::string &group="")
 Subscribe to a message (of any type derived from google::protobuf::Message) More...
 
template<typename ProtoBufMessage , class C >
void subscribe (void(C::*mem_func)(const ProtoBufMessage &), C *obj, const std::string &group="")
 Subscribe for a type using a class member function as the handler. More...
 
common::ZeroMQServicezeromq_service ()
 Fetchs the newest received message of this type. More...
 
boost::shared_ptr< StaticProtobufPubSubNodeWrapperpubsub_node ()
 
Constructors / Destructor
 Application (google::protobuf::Message *cfg=0)
 
virtual ~Application ()
 
Publish / Subscribe
void publish (const google::protobuf::Message &msg, const std::string &group="")
 
- Protected Member Functions inherited from goby::common::ZeroMQApplicationBase
 ZeroMQApplicationBase (ZeroMQService *service, google::protobuf::Message *cfg=0)
 
virtual void loop ()=0
 
void set_loop_period (boost::posix_time::time_duration p)
 set the interval (with a boost::posix_time::time_duration) between calls to loop. Alternative to set_loop_freq(). More...
 
void set_loop_period (long milliseconds)
 set the interval in milliseconds between calls to loop. Alternative to set_loop_freq(). More...
 
void set_loop_freq (double hertz)
 set the frequency with which loop() is called. Alternative to set_loop_period(). More...
 
boost::posix_time::time_duration loop_period ()
 interval between calls to loop()
 
long loop_freq ()
 frequency of calls to loop() in Hertz
 
boost::posix_time::ptime t_start ()
 

Additional Inherited Members

- Public Member Functions inherited from goby::common::ApplicationBase
 ApplicationBase (google::protobuf::Message *cfg=0)
 
void quit ()
 Requests a clean (return 0) exit.
 
std::string application_name ()
 name of this application (from AppBaseConfig::app_name). E.g. "garmin_gps_g"
 
std::string platform_name ()
 name of this platform (from AppBaseConfig::platform_name). E.g. "AUV-23" or "unicorn"
 
template<typename App , typename Config >
friend int::goby::run (int argc, char *argv[], Config *cfg)
 
const AppBaseConfigbase_cfg ()
 

Detailed Description

Base class provided for users to generate applications that participate in the Goby publish/subscribe architecture.

Definition at line 49 of file application.h.

Constructor & Destructor Documentation

goby::pb::Application::Application ( google::protobuf::Message cfg = 0)
protected
Parameters
cfgpointer to object derived from google::protobuf::Message that defines the configuration for this Application. This constructor will use the Description of cfg to read the command line parameters and configuration file (if given) and use these values to populate cfg. cfg must be a static member of the subclass or global object since member objects will be constructed after the Application constructor is called.

Definition at line 37 of file application.cpp.

Member Function Documentation

template<typename ProtoBufMessage >
void goby::pb::Application::subscribe ( boost::function< void(const ProtoBufMessage &)>  handler = boost::function<void(const ProtoBufMessage&)>(),
const std::string &  group = "" 
)
inlineprotected

Subscribe to a message (of any type derived from google::protobuf::Message)

Parameters
handlerFunction object to be called as soon as possible upon receipt of a message of this type. The signature of handler must match: void handler(const ProtoBufMessage& msg). if handler is omitted, no handler is called and only the newest message buffer is updated upon message receipt (for calls to newest<ProtoBufMessage>())

Definition at line 73 of file application.h.

template<typename ProtoBufMessage , class C >
void goby::pb::Application::subscribe ( void(C::*)(const ProtoBufMessage &)  mem_func,
C *  obj,
const std::string &  group = "" 
)
inlineprotected

Subscribe for a type using a class member function as the handler.

Parameters
mem_funcMember function (method) of class C with a signature of void C::mem_func(const ProtoBufMessage& msg)
objpointer to the object whose member function (mem_func) to call

Definition at line 86 of file application.h.

common::ZeroMQService& goby::pb::Application::zeromq_service ( )
inlineprotected

Fetchs the newest received message of this type.

You must subscribe() for this type before using this method

Definition at line 109 of file application.h.


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