48 #ifndef _MIRA_FRAMEWORK_H_ 49 #define _MIRA_FRAMEWORK_H_ 51 #include <serialization/adapters/std/list> 52 #include <serialization/adapters/std/map> 53 #include <serialization/adapters/boost/shared_ptr.hpp> 74 #define MIRA_FW mira::Framework::instance() 84 class FrameworkTransformer;
100 class FrameworkStartup
103 FrameworkStartup(
int argc,
char** argv);
104 FrameworkStartup(
const std::vector<std::string>& args);
109 ProgramOptions mOptions;
110 typedef std::vector<std::string> CommandLineStrings;
111 CommandLineStrings mCommandLineVariables;
112 CommandLineStrings mCommandLineKnownFrameworks;
117 class FrameworkAuthority :
public Authority
120 FrameworkAuthority(Framework* framework,
const ResourceName& ns,
122 : Authority(ns, name, flags), mFramework(framework)
126 boost::shared_ptr<PropertyNode> getProperties();
129 Framework* mFramework;
162 Framework(
int argc,
char** argv,
bool startImmediately =
false);
169 Framework(
const std::vector<std::string>& args,
bool startImmediately =
false);
174 template<
typename Reflector>
180 r.property(
"RemoteModule",
mRemoteModule,
"The remote module", boost::shared_ptr<RemoteModule>());
182 r.method(
"getUptime", &
Framework::getUptime,
this,
"Get the time since the framework was started");
185 "Terminate framework (and thus, the process). Use with care!",
186 "exitcode",
"the exitcode returned by the process", 0u);
188 r.interface(
"IVariableRegistry");
192 r.interface(
"ILibraryRegistry");
193 r.method(
"getLibraries",
196 r.method(
"getLoadedLibraries",
199 for (
auto it = reg.begin(); it != reg.end(); ) {
200 if (it->second.mIsLoaded)
207 "Query only loaded libraries");
209 r.interface(
"IConfigurationLoader");
210 r.method(
"loadConfig",
211 boost::function<
void(
const XMLDom&)>(
212 [&](
const XMLDom& xml) { this->
load(const_cast<XMLDom&>(xml)); } ),
213 "Load a configuration",
214 "xml",
"XML document",
XMLDom());
216 r.interface(
"IThreadMonitor");
217 r.method(
"getThreadInformation",
220 "Query thread information");
245 void load(
const std::string& configFile);
439 #include <fw/impl/Authority.hpp> 440 #include <fw/impl/ConcreteChannel.hpp> virtual int exec()
Executes the framework and blocks until the framework is terminated, e.g.
Authority class that is used to access the functionality of the framework.
XMLDom mConfigDom
Definition: Framework.h:429
void reflect(Reflector &r)
Reflect method for serialization.
Definition: Framework.h:175
A STL conform wrapper for libxml2 to read XML files as DOM.
Definition: XMLDom.h:74
std::string mName
Definition: Framework.h:426
boost::shared_ptr< ErrorService > getErrorService()
Returns the pointer to the persistent error service.
Definition: Framework.h:341
Manager class for all framework channels.
std::string getGlobalID() const
Return the fully qualified global id of this framework (includes namespace)
Definition: Framework.h:359
Normally authorities must have a unique name.
Definition: Authority.h:104
Manager class for all authorities in a framework.
ConfigurationLoader & getConfigurationLoader()
Returns the reference to the configuration file loader.
Definition: Framework.h:332
static Type & instance()
Returns a reference to the singleton instance.
Definition: Singleton.h:508
bool mInExec
Definition: Framework.h:397
boost::shared_ptr< FrameworkTransformer > getTransformer()
Returns the pointer to the transform framework.
Definition: Framework.h:329
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
A thread monitor, which collects information about the resources of all running threads of the curren...
std::vector< BasicThreadInfo > BasicThreadInfoVector
Vector of serializable thread info.
Definition: ThreadMonitor.h:236
friend class Private::FrameworkStartup
Definition: Framework.h:383
Stores aliases for namespaces and allows to resolve local names to global fully qualified names...
Definition: NameRegistry.h:66
Preprocessor for XML dom documents.
Grants thread-safe access to an object (the Protectee) that should be protected from concurrent acces...
Definition: ScopedAccess.h:119
boost::shared_ptr< ErrorService > mErrorServiceModule
Definition: Framework.h:425
int mTerminationExitCode
Definition: Framework.h:395
Framework(int argc, char **argv, bool startImmediately=false)
Constructor that takes command line arguments and a flag.
static void errorHandler(const IntSignal &sig)
ConfigurationLoader mConfigurationLoader
Definition: Framework.h:423
Structure used in signal handlers to pass the signal and callstack.
Definition: SignalHandler.h:67
static bool enterLeaveErrorHandler(bool enter)
uint8 VersionType
Definition: ReflectorInterface.h:72
std::string getID() const
Returns the ID of this framework.
Definition: Framework.h:353
bool mTerminationRequested
Definition: Framework.h:394
int run()
Calls the above load() and start() methods according to the command line parameters that were passed ...
Wrapper class for boost::posix_time::ptime for adding more functionality to it.
Definition: Time.h:418
RootPropertyNode mPropertiesRoot
Definition: Framework.h:404
Configuration loader for loading XML application configuration files.
bool isInExec() const
Definition: Framework.h:379
Duration getUptime() const
Return duration since started.
Definition: Framework.h:270
std::map< std::string, LibraryInfo > Register
Definition: LibraryRegistry.h:154
Registry for shared libraries.
AuthorityManager mAuthorityManager
Definition: Framework.h:418
bool isStarted() const
Return true if framework is started.
Definition: Framework.h:262
bool mRemoteDisabled
Definition: Framework.h:398
ProtecteeMixin< MetaTypeDatabase > ProtecteeDatabase
Definition: Framework.h:369
ChannelManager mChannelManager
Definition: Framework.h:416
Resolving names of channels and authorities in namespaces.
boost::shared_ptr< RemoteModule > mRemoteModule
Definition: Framework.h:409
bool mIsStarted
Definition: Framework.h:396
A singleton class that can be freely configured using policies that control the creation, instantiation, lifetime and thread-safety.
Use this class to represent time durations.
Definition: Time.h:106
void ctrlCHandler(const IntSignal &sig)
This class represents the core element of a modular application.
Definition: Framework.h:150
A special node that acts only as (empty) root node for a property tree.
Definition: PropertyNode.h:448
std::map< std::string, XMLVariableValue > XMLVariablesMap
Definition: XMLDomPreprocessor.h:92
ProtecteeDatabase mMetaDatabase
Definition: Framework.h:430
ScopedAccess< ProtecteeDatabase > getMetaDatabase()
Return the meta database that contains all known meta information in this framework.
Definition: Framework.h:374
RPCManager & getRPCManager()
Returns the reference to the manager singleton for registered RPC services.
Definition: Framework.h:338
virtual void requestTermination(int exitcode=0)
Requests the termination of the framework and hence the whole application.
boost::shared_ptr< UnitManager > mUnitManager
Definition: Framework.h:421
Provided for convenience.
Definition: Singleton.h:544
static Time now()
Returns the current utc based time.
Definition: Time.h:481
XMLVariablesMap variables
Definition: XMLDomPreprocessor.h:121
boost::shared_ptr< PropertyNode > getProperties()
Definition: Framework.h:225
boost::shared_ptr< FrameworkTransformer > mTransformer
Definition: Framework.h:419
boost::shared_ptr< Private::FrameworkAuthority > mAuthority
Definition: Framework.h:402
Framework channel classes.
NameRegistry & getNameRegistry()
Returns the reference to the name registry.
Definition: Framework.h:320
AuthorityManager & getAuthorityManager()
Returns the reference to the manager singleton for registered authorities.
Definition: Framework.h:323
virtual bool isTerminationRequested() const
Returns whether the termination of the framework is reqested.
ChannelManager & getChannelManager()
Returns the reference to the manager singleton for channels.
Definition: Framework.h:326
XMLDomPreprocessor & getXMLDomPreprocessor()
Definition: Framework.h:367
Central instance that stores all created Authorities.
Definition: AuthorityManager.h:130
Preprocesses XML documents and resolves all special tags like , <if>, <warning> and so on...
Definition: XMLDomPreprocessor.h:109
Time mStartTime
Definition: Framework.h:432
boost::shared_ptr< RemoteModule > getRemoteModule()
Returns the pointer to the remote module.
Definition: Framework.h:344
Class for accessing command line parameters.
Contains internal RPCManager class.
XMLVariablesMap & getVariables()
Returns the list of variables that are registered via command line or config file.
Definition: Framework.h:365
void start()
Starts the framework and it's remote component (if one was configured or created) and returns immedia...
NameRegistry mNames
Definition: Framework.h:408
boost::shared_ptr< UnitManager > getUnitManager()
Returns the reference to the unit manager.
Definition: Framework.h:335
void load()
Loads configuration files given on command line if any by calling above load(const std::string& confi...
An exception that occurred whenever a channel does not exist.
Definition: ChannelManager.h:75
Grants thread-safe access to an object that should be protected from concurrent access.
int getTerminationExitCode() const
Returns the exit code as specified by requestTermination(), or 0 if requestTermination() was not call...
XMLDomPreprocessor mXMLPreprocessor
Definition: Framework.h:428
boost::shared_ptr< PropertyNode > mProperties
Definition: Framework.h:405
This class is for internal use only.
Definition: RPCManager.h:96
Class for loading, parsing, modifying and interpreting application configuration files.
Definition: Loader.h:179
static Register getRegister()
Get access to library register.
Definition: LibraryRegistry.h:180
RPCManager mRPCManager
Definition: Framework.h:415
Contains non-intrusive reflects for XMLDom documents.