MIRA
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends | List of all members
Framework Class Reference

This class represents the core element of a modular application. More...

#include <fw/Framework.h>

Inheritance diagram for Framework:
Inheritance graph
[legend]

Public Types

typedef ProtecteeMixin
< MetaTypeDatabase
ProtecteeDatabase
 
typedef Base::Type Type
 

Public Member Functions

 Framework (int argc, char **argv, bool startImmediately=false)
 Constructor that takes command line arguments and a flag. More...
 
 Framework (const std::vector< std::string > &args, bool startImmediately=false)
 Constructor that takes command line arguments as a vector and a flag. More...
 
virtual ~Framework ()
 
template<typename Reflector >
void reflect (Reflector &r)
 Reflect method for serialization. More...
 
boost::shared_ptr< PropertyNodegetProperties ()
 
void load (XMLDom &xml)
 Loads the specified XML configuration and applies all registered Loaders on it. More...
 
void load (const std::string &configFile)
 Opens the specified XML configuration file and applies all registered Loaders on it. More...
 
void load ()
 Loads configuration files given on command line if any by calling above load(const std::string& configFile) function. More...
 
void start ()
 Starts the framework and it's remote component (if one was configured or created) and returns immediately. More...
 
bool isStarted () const
 Return true if framework is started. More...
 
Duration getUptime () const
 Return duration since started. More...
 
virtual int exec ()
 Executes the framework and blocks until the framework is terminated, e.g. More...
 
virtual void requestTermination (int exitcode=0)
 Requests the termination of the framework and hence the whole application. More...
 
virtual bool isTerminationRequested () const
 Returns whether the termination of the framework is reqested. More...
 
int getTerminationExitCode () const
 Returns the exit code as specified by requestTermination(), or 0 if requestTermination() was not called. More...
 
int run ()
 Calls the above load() and start() methods according to the command line parameters that were passed in the constructor and finally calls exec(). More...
 
std::string getID () const
 Returns the ID of this framework. More...
 
std::string getGlobalID () const
 Return the fully qualified global id of this framework (includes namespace) More...
 
XMLVariablesMapgetVariables ()
 Returns the list of variables that are registered via command line or config file. More...
 
XMLDomPreprocessorgetXMLDomPreprocessor ()
 
ScopedAccess< ProtecteeDatabasegetMetaDatabase ()
 Return the meta database that contains all known meta information in this framework. More...
 
bool isInExec () const
 
Obtain access to framework components
NameRegistrygetNameRegistry ()
 Returns the reference to the name registry. More...
 
AuthorityManagergetAuthorityManager ()
 Returns the reference to the manager singleton for registered authorities. More...
 
ChannelManagergetChannelManager ()
 Returns the reference to the manager singleton for channels. More...
 
boost::shared_ptr
< FrameworkTransformer
getTransformer ()
 Returns the pointer to the transform framework. More...
 
ConfigurationLoadergetConfigurationLoader ()
 Returns the reference to the configuration file loader. More...
 
boost::shared_ptr< UnitManagergetUnitManager ()
 Returns the reference to the unit manager. More...
 
RPCManagergetRPCManager ()
 Returns the reference to the manager singleton for registered RPC services. More...
 
boost::shared_ptr< ErrorServicegetErrorService ()
 Returns the pointer to the persistent error service. More...
 
boost::shared_ptr< RemoteModulegetRemoteModule ()
 Returns the pointer to the remote module. More...
 

Static Public Member Functions

static Typeinstance ()
 Returns a reference to the singleton instance. More...
 
static bool isDestroyed ()
 Returns true, if the singleton was already destroyed. More...
 

Protected Member Functions

void initialize ()
 
void finalize ()
 
void ctrlCHandler (const IntSignal &sig)
 

Static Protected Member Functions

static void errorHandler (const IntSignal &sig)
 
static bool enterLeaveErrorHandler (bool enter)
 

Protected Attributes

bool mTerminationRequested
 
int mTerminationExitCode
 
bool mIsStarted
 
bool mInExec
 
bool mRemoteDisabled
 
boost::shared_ptr
< Private::FrameworkAuthority > 
mAuthority
 
RootPropertyNode mPropertiesRoot
 
boost::shared_ptr< PropertyNodemProperties
 
NameRegistry mNames
 
boost::shared_ptr< RemoteModulemRemoteModule
 
RPCManager mRPCManager
 
ChannelManager mChannelManager
 
AuthorityManager mAuthorityManager
 
boost::shared_ptr
< FrameworkTransformer
mTransformer
 
boost::shared_ptr< UnitManagermUnitManager
 
ConfigurationLoader mConfigurationLoader
 
boost::shared_ptr< ErrorServicemErrorServiceModule
 
std::string mName
 
XMLDomPreprocessor mXMLPreprocessor
 
XMLDom mConfigDom
 
ProtecteeDatabase mMetaDatabase
 
Time mStartTime
 

Friends

class Private::FrameworkStartup
 

Detailed Description

This class represents the core element of a modular application.

The Framework allows communication between different application parts, so called authorities, via data channels and remote procedure calls. The framework hides implementation details as well as sources, destinations of data and the way of data transmission from the developer of an authority. This allows the user to run the application on his local PC or distributed on PCs in a network without changing a single line of code.

Member Typedef Documentation

typedef Base::Type Type
inherited

Constructor & Destructor Documentation

Framework ( int  argc,
char **  argv,
bool  startImmediately = false 
)

Constructor that takes command line arguments and a flag.

Parameters
argcNumber of command line arguments.
argvThe command line arguments.
startImmediatelyIf true the methods load() and start() are called after construction.
Framework ( const std::vector< std::string > &  args,
bool  startImmediately = false 
)

Constructor that takes command line arguments as a vector and a flag.

Parameters
argsThe command line arguments.
startImmediatelyIf true the methods load() and start() are called after construction.
virtual ~Framework ( )
virtual

Member Function Documentation

void reflect ( Reflector &  r)
inline

Reflect method for serialization.

boost::shared_ptr<PropertyNode> getProperties ( )
inline
void load ( XMLDom xml)

Loads the specified XML configuration and applies all registered Loaders on it.

This will load libraries, instantiate and configure units, etc. This method will do nothing if the xml document is empty.

void load ( const std::string &  configFile)

Opens the specified XML configuration file and applies all registered Loaders on it.

This will load libraries, instantiate and configure units, etc. This method will do nothing if configFile is empty.

void load ( )

Loads configuration files given on command line if any by calling above load(const std::string& configFile) function.

void start ( )

Starts the framework and it's remote component (if one was configured or created) and returns immediately.

bool isStarted ( ) const
inline

Return true if framework is started.

Duration getUptime ( ) const
inline

Return duration since started.

virtual int exec ( )
virtual

Executes the framework and blocks until the framework is terminated, e.g.

by pressing Ctrl+C. Returns the exit code as specified by requestTermination().

Reimplemented in FrameworkWithGui.

virtual void requestTermination ( int  exitcode = 0)
virtual

Requests the termination of the framework and hence the whole application.

Is called e.g. when user presses Ctrl+C. You can optionally specify an exit code that will be returned as exit code by exec(). Furthermore, this code is returned by the mira executables (mira, miragui, miracenter, etc.).

Reimplemented in FrameworkWithGui.

virtual bool isTerminationRequested ( ) const
virtual

Returns whether the termination of the framework is reqested.

int getTerminationExitCode ( ) const

Returns the exit code as specified by requestTermination(), or 0 if requestTermination() was not called.

See Also
isTerminationRequested().
int run ( )

Calls the above load() and start() methods according to the command line parameters that were passed in the constructor and finally calls exec().

Hence, this method will launch a fully operating framework and blocks until the framework is terminated, e.g. by pressing Ctrl+C. Returns the exit code as specified by requestTermination(), or 0 if no error or exception has occurred, otherwise -1.

NameRegistry& getNameRegistry ( )
inline

Returns the reference to the name registry.

AuthorityManager& getAuthorityManager ( )
inline

Returns the reference to the manager singleton for registered authorities.

ChannelManager& getChannelManager ( )
inline

Returns the reference to the manager singleton for channels.

boost::shared_ptr<FrameworkTransformer> getTransformer ( )
inline

Returns the pointer to the transform framework.

ConfigurationLoader& getConfigurationLoader ( )
inline

Returns the reference to the configuration file loader.

boost::shared_ptr<UnitManager> getUnitManager ( )
inline

Returns the reference to the unit manager.

RPCManager& getRPCManager ( )
inline

Returns the reference to the manager singleton for registered RPC services.

boost::shared_ptr<ErrorService> getErrorService ( )
inline

Returns the pointer to the persistent error service.

boost::shared_ptr<RemoteModule> getRemoteModule ( )
inline

Returns the pointer to the remote module.

std::string getID ( ) const
inline

Returns the ID of this framework.

The ID can be specified via command line. If no ID is specified an UUID based one will be generated.

std::string getGlobalID ( ) const
inline

Return the fully qualified global id of this framework (includes namespace)

Returns
Global ID
XMLVariablesMap& getVariables ( )
inline

Returns the list of variables that are registered via command line or config file.

XMLDomPreprocessor& getXMLDomPreprocessor ( )
inline
ScopedAccess<ProtecteeDatabase> getMetaDatabase ( )
inline

Return the meta database that contains all known meta information in this framework.

bool isInExec ( ) const
inline
void initialize ( )
protected
void finalize ( )
protected
void ctrlCHandler ( const IntSignal sig)
protected
static void errorHandler ( const IntSignal sig)
staticprotected
static bool enterLeaveErrorHandler ( bool  enter)
staticprotected
static Type& instance ( )
inlinestaticinherited

Returns a reference to the singleton instance.

Exceptions
XLogicalIf the singleton was already destroyed (dead reference) or not yet created (when using ExplicitInstantiation).
static bool isDestroyed ( )
inlinestaticinherited

Returns true, if the singleton was already destroyed.

Trying to access it will result in an exception.

Friends And Related Function Documentation

friend class Private::FrameworkStartup
friend

Member Data Documentation

bool mTerminationRequested
protected
int mTerminationExitCode
protected
bool mIsStarted
protected
bool mInExec
protected
bool mRemoteDisabled
protected
boost::shared_ptr<Private::FrameworkAuthority> mAuthority
protected
RootPropertyNode mPropertiesRoot
protected
boost::shared_ptr<PropertyNode> mProperties
protected
NameRegistry mNames
protected
boost::shared_ptr<RemoteModule> mRemoteModule
protected
RPCManager mRPCManager
protected
ChannelManager mChannelManager
protected
AuthorityManager mAuthorityManager
protected
boost::shared_ptr<FrameworkTransformer> mTransformer
protected
boost::shared_ptr<UnitManager> mUnitManager
protected
ConfigurationLoader mConfigurationLoader
protected
boost::shared_ptr<ErrorService> mErrorServiceModule
protected
std::string mName
protected
XMLDomPreprocessor mXMLPreprocessor
protected
XMLDom mConfigDom
protected
ProtecteeDatabase mMetaDatabase
protected
Time mStartTime
protected

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