Goby3  3.1.5a
2024.05.23
goby::middleware::SingleThreadApplication< Config, InterProcessPortal > Class Template Reference

Implements an Application for a two layer middleware setup ([ intervehicle [ interprocess ] ]) based around InterVehicleForwarder without any interthread communications layer. This class isn't used directly by user applications, for that use a specific implementation, e.g. zeromq::SingleThreadApplication. More...

#include <goby/middleware/application/single_thread.h>

Inheritance diagram for goby::middleware::SingleThreadApplication< Config, InterProcessPortal >:
goby::middleware::Application< Config > goby::middleware::Thread< Config, InterVehicleForwarder< InterProcessPortal<> > > goby::middleware::coroner::Application< Derived > goby::middleware::terminate::Application< SingleThreadApplication< Config, InterProcessPortal > >

Public Member Functions

 SingleThreadApplication (double loop_freq_hertz=0)
 Construct the application calling loop() at the given frequency (double overload) More...
 
 SingleThreadApplication (boost::units::quantity< boost::units::si::frequency > loop_freq)
 Construct the application calling loop() at the given frequency (boost::units overload) More...
 
virtual ~SingleThreadApplication ()
 
- Public Member Functions inherited from goby::middleware::Application< Config >
 Application ()
 
virtual ~Application ()
 
- Public Member Functions inherited from goby::middleware::Thread< Config, InterVehicleForwarder< InterProcessPortal<> > >
 Thread (const Config &cfg, InterVehicleForwarder< InterProcessPortal<> > *transporter, int index)
 Construct a thread with a given configuration, underlying transporter, and index (for multiple instantiations), but without any loop() frequency. More...
 
 Thread (const Config &cfg, InterVehicleForwarder< InterProcessPortal<> > *transporter, double loop_freq_hertz=0, int index=-1)
 Construct a thread with all possible metadata (using double to specify frequency in Hertz) More...
 
 Thread (const Config &cfg, InterVehicleForwarder< InterProcessPortal<> > *transporter, boost::units::quantity< boost::units::si::frequency > loop_freq, int index=-1)
 Construct a thread with all possible metadata (using boost::units to specify frequency) More...
 
virtual ~Thread ()
 
void run (std::atomic< bool > &alive)
 Run the thread until the boolean reference passed is set false. This call blocks, and should be run in a std::thread by the caller. More...
 
int index () const
 
std::type_index type_index ()
 
void set_type_index (std::type_index type_i)
 
std::string name ()
 
void set_name (const std::string &name)
 
int uid ()
 
void set_uid (int uid)
 

Protected Member Functions

InterProcessPortal & interprocess ()
 
InterVehicleForwarder< InterProcessPortal<> > & intervehicle ()
 
virtual void health (goby::middleware::protobuf::ThreadHealth &health) override
 Called when HealthRequest is made by goby_coroner. More...
 
virtual void post_initialize () override
 Assume all required subscriptions are done in the Constructor or in initialize(). If this isn't the case, this method can be overridden. More...
 
- Protected Member Functions inherited from goby::middleware::Application< Config >
virtual void pre_initialize ()
 Called just before initialize. More...
 
virtual void initialize ()
 Perform any initialize tasks that couldn't be done in the constructor. More...
 
virtual void pre_finalize ()
 Called just before finalize. More...
 
virtual void finalize ()
 Perform any final cleanup actions just before the destructor is called. More...
 
virtual void post_finalize ()
 Called just after finalize. More...
 
void quit (int return_value=0)
 Requests a clean exit. More...
 
const Config & app_cfg ()
 Accesses configuration object passed at launch. More...
 
const util::UTMGeodesygeodesy ()
 Accesses the geodetic conversion tool if lat_origin and lon_origin were provided. More...
 
bool has_geodesy ()
 Returns if the geodesy tool is configured with a datum. More...
 
std::string app_name ()
 
void configure_geodesy (goby::util::UTMGeodesy::LatLonPoint datum)
 
- Protected Member Functions inherited from goby::middleware::Thread< Config, InterVehicleForwarder< InterProcessPortal<> > >
 Thread (const Config &cfg, boost::units::quantity< boost::units::si::frequency > loop_freq, int index=-1)
 
void set_transporter (InterVehicleForwarder< InterProcessPortal<> > *transporter)
 
virtual void loop ()
 
double loop_frequency_hertz () const
 
decltype(loop_frequency_) loop_frequency () const
 
double loop_max_frequency () const
 
void run_once ()
 
InterVehicleForwarder< InterProcessPortal<> > & transporter () const
 
const Config & cfg () const
 
virtual void initialize ()
 
virtual void finalize ()
 
void thread_health (goby::middleware::protobuf::ThreadHealth &health)
 
void thread_quit ()
 
bool alive ()
 
- Protected Member Functions inherited from goby::middleware::coroner::Application< Derived >
void subscribe_coroner ()
 
- Protected Member Functions inherited from goby::middleware::terminate::Application< SingleThreadApplication< Config, InterProcessPortal > >
void subscribe_terminate (bool do_quit=true)
 

Friends

class coroner::Application< SingleThreadApplication< Config, InterProcessPortal > >
 
class terminate::Application< SingleThreadApplication< Config, InterProcessPortal > >
 

Additional Inherited Members

- Public Types inherited from goby::middleware::Application< Config >
using ConfigType = Config
 
- Public Types inherited from goby::middleware::Thread< Config, InterVehicleForwarder< InterProcessPortal<> > >
using Transporter = InterVehicleForwarder< InterProcessPortal<> >
 
- Static Public Attributes inherited from goby::middleware::Thread< Config, InterVehicleForwarder< InterProcessPortal<> > >
static constexpr goby::middleware::Group shutdown_group_
 
static constexpr goby::middleware::Group joinable_group_
 

Detailed Description

template<class Config, template< class=NullTransporter > class InterProcessPortal>
class goby::middleware::SingleThreadApplication< Config, InterProcessPortal >

Implements an Application for a two layer middleware setup ([ intervehicle [ interprocess ] ]) based around InterVehicleForwarder without any interthread communications layer. This class isn't used directly by user applications, for that use a specific implementation, e.g. zeromq::SingleThreadApplication.

Template Parameters
ConfigConfiguration type
InterProcessPortalthe interprocess portal type to use (e.g. zeromq::InterProcessPortal)

Definition at line 50 of file single_thread.h.

Constructor & Destructor Documentation

◆ SingleThreadApplication() [1/2]

template<class Config , template< class=NullTransporter > class InterProcessPortal>
goby::middleware::SingleThreadApplication< Config, InterProcessPortal >::SingleThreadApplication ( double  loop_freq_hertz = 0)
inline

Construct the application calling loop() at the given frequency (double overload)

Parameters
loop_freq_hertzThe frequency at which to attempt to call loop(), assuming the main thread isn't blocked handling transporter callbacks (e.g. subscribe callbacks). Zero or negative indicates loop() will never be called.

Definition at line 69 of file single_thread.h.

◆ SingleThreadApplication() [2/2]

template<class Config , template< class=NullTransporter > class InterProcessPortal>
goby::middleware::SingleThreadApplication< Config, InterProcessPortal >::SingleThreadApplication ( boost::units::quantity< boost::units::si::frequency >  loop_freq)
inline

Construct the application calling loop() at the given frequency (boost::units overload)

Parameters
loop_freqThe frequency at which to attempt to call loop(), assuming the main thread isn't blocked handling transporter callbacks (e.g. subscribe callbacks). Zero or negative indicates loop() will never be called.

Definition at line 77 of file single_thread.h.

◆ ~SingleThreadApplication()

template<class Config , template< class=NullTransporter > class InterProcessPortal>
virtual goby::middleware::SingleThreadApplication< Config, InterProcessPortal >::~SingleThreadApplication ( )
inlinevirtual

Definition at line 99 of file single_thread.h.

Member Function Documentation

◆ health()

template<class Config , template< class=NullTransporter > class InterProcessPortal>
virtual void goby::middleware::SingleThreadApplication< Config, InterProcessPortal >::health ( goby::middleware::protobuf::ThreadHealth health)
inlineoverrideprotectedvirtual

Called when HealthRequest is made by goby_coroner.

Override to implement thread specific health response

Reimplemented from goby::middleware::Thread< Config, InterVehicleForwarder< InterProcessPortal<> > >.

Definition at line 105 of file single_thread.h.

◆ interprocess()

template<class Config , template< class=NullTransporter > class InterProcessPortal>
InterProcessPortal& goby::middleware::SingleThreadApplication< Config, InterProcessPortal >::interprocess ( )
inlineprotected

Definition at line 102 of file single_thread.h.

◆ intervehicle()

template<class Config , template< class=NullTransporter > class InterProcessPortal>
InterVehicleForwarder<InterProcessPortal<> >& goby::middleware::SingleThreadApplication< Config, InterProcessPortal >::intervehicle ( )
inlineprotected

Definition at line 103 of file single_thread.h.

◆ post_initialize()

template<class Config , template< class=NullTransporter > class InterProcessPortal>
virtual void goby::middleware::SingleThreadApplication< Config, InterProcessPortal >::post_initialize ( )
inlineoverrideprotectedvirtual

Assume all required subscriptions are done in the Constructor or in initialize(). If this isn't the case, this method can be overridden.

Reimplemented from goby::middleware::Application< Config >.

Definition at line 112 of file single_thread.h.

Friends And Related Function Documentation

◆ coroner::Application< SingleThreadApplication< Config, InterProcessPortal > >

template<class Config , template< class=NullTransporter > class InterProcessPortal>
friend class coroner::Application< SingleThreadApplication< Config, InterProcessPortal > >
friend

Definition at line 62 of file single_thread.h.

◆ terminate::Application< SingleThreadApplication< Config, InterProcessPortal > >

template<class Config , template< class=NullTransporter > class InterProcessPortal>
friend class terminate::Application< SingleThreadApplication< Config, InterProcessPortal > >
friend

Definition at line 63 of file single_thread.h.


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