Application Class Referenceabstract

Baseclass for all ArmarX applications. More...

#include <ArmarXCore/core/application/Application.h>

+ Inheritance diagram for Application:

Public Member Functions

 Application ()
 Application initalizes the Ice::Application base class.
 
void enableLibLoading (bool enable=true)
 
std::vector< std::string > getArmarXPackageNames ()
 getDefaultPackageNames returns the value of the ArmarX.DefaultPackages property It splits the string by , and returns the elements as a vector.
 
const std::vector< std::string > & getCommandLineArguments () const
 
bool getForbidThreadCreation () const
 
std::string getName () const
 Retrieve name of the application.
 
const ThreadPoolPtr & getThreadPool () const
 
void icePropertiesUpdated (const std::set< std::string > &changedProperties) override
 This method is called when new Properties are set via setIceProperties().
 
void interruptCallback (int signal) override
 Cleans up connections with IceStorm before terminating the app.
 
bool isPackageAutoDiscoveryEnabled ()
 
void registerDataPathsFromDependencies (std::string dependencies)
 
int run (int argc, char *argv[]) override
 Ice::Application replacement for the main function.
 
void setForbidThreadCreation (bool value)
 
void setIceProperties (Ice::PropertiesPtr properties) override
 Overrides PropertyUser::setIceProperties() which is called internally.
 
void setName (const std::string &name)
 Set name of the application.
 
void storeCommandLineArguments (int argc, char *argv[])
 
void updateIceProperties (const Ice::PropertyDict &properties) override
 
- Public Member Functions inherited from PropertyUser
std::vector< std::string > getComponentProxyNames ()
 
Ice::PropertiesPtr getIceProperties () const
 Returns the set of Ice properties.
 
template<typename PropertyType>
Property< PropertyType > getProperty (const std::string &name)
 Property creation and retrieval.
 
template<typename PropertyType>
Property< PropertyType > getProperty (const std::string &name) const
 Hack to allow using getProperty in const-modified methods.
 
template<class T>
void getProperty (std::atomic< T > &val, const std::string &name) const
 
template<class T>
void getProperty (T &val, const std::string &name) const
 
template<class T>
std::vector< T > getPropertyAsCSV (const std::string &name, const std::string &splitBy=",;", bool trimElements=true, bool removeEmptyElements=true)
 
template<class ContainerT>
void getPropertyAsCSV (ContainerT &val, const std::string &name, const std::string &splitBy=",;", bool trimElements=true, bool removeEmptyElements=true)
 
PropertyDefinitionsPtr getPropertyDefinitions ()
 Returns the component's property definition container.
 
std::vector< std::string > getSubscribedTopicNames ()
 
std::vector< std::string > getTopicProxyNames ()
 
bool hasProperty (const std::string &name)
 
virtual void injectPropertyDefinitions (PropertyDefinitionsPtr &)
 Called after createPropertyDefinitions by Component to inject propertes of ComponentPlugin.
 
 PropertyUser ()
 
bool tryAddProperty (const std::string &propertyName, const std::string &value)
 
virtual void updateIceProperties (const std::map< std::string, std::string > &changes)
 
void updateProperties ()
 
void updateProxies (IceManagerPtr)
 
 ~PropertyUser () override
 

Static Public Member Functions

template<class T, typename... Args>
static ApplicationPtr createInstance (Args &&... args)
 Creates the one application instance of type T.
 
static std::string GetArmarXConfigDefaultPath (bool envVarExpanded=true)
 
static Ice::StringSeq GetDefaultsPaths ()
 
static ApplicationPtr getInstance ()
 Retrieve shared pointer to the application object.
 
static const Ice::StringSeq & GetProjectDependencies ()
 
static const std::string & GetProjectName ()
 
static std::string GetVersion ()
 
static void LoadDefaultConfig (Ice::PropertiesPtr properties)
 
static void setInstance (ApplicationPtr const &inst)
 

Static Public Attributes

static const std::string ArmarXUserConfigDirEnvVar = "ARMARX_CONFIG_DIR"
 

Protected Member Functions

PropertyDefinitionsPtr createPropertyDefinitions () override
 
int doMain (int argc, char *argv[], const Ice::InitializationData &initData, Ice::Int i) override
 Ice::Application::doMain() is called by Ice::Application::main() and does setup of Ice::Communicator before calling the virtual Ice::Application::run() method.
 
virtual int exec (const ArmarXManagerPtr &armarXManager)
 Exec method is the main process of the application.
 
ArmarXManagerPtr getArmarXManager ()
 
virtual std::string getDomainName ()
 Retrieve the domain name used for property parsing.
 
void loadDefaultConfig (int argc, char *argv[], const Ice::InitializationData &initData)
 
void loadDependentProjectDatapaths ()
 
Ice::PropertiesPtr parseOptionsMergeProperties (int argc, char *argv[])
 Parse options given on the commandline and merge them into the regular properties.
 
virtual void setup (const ManagedIceObjectRegistryInterfacePtr &registry, Ice::PropertiesPtr properties)=0
 Setup method to be implemented by user applications.
 
void showHelp (ApplicationOptions::Options &options)
 Print help onto the screen or into a file.
 

Static Protected Member Functions

static void HandlerFault (int sig)
 handlerFault handles signals sendt to the application such as SIGSEGF or SIGABRT (Linux)
 
static void HandlerInterrupt (int sig)
 handlerInterrupt handles interrupt signals sent to the application (Linux)
 

Detailed Description

Baseclass for all ArmarX applications.

  • helper class for ArmarX main programs
  • creates an instance of ArmarXManager
  • generates properties from commandline parameters
  • provides help and automatic generation of properties

Implements the run method from the Ice::Application interface which is called by the automatically generated main.cpp. In order to start writing an ArmarX application, inherit from armarx::Application and implement the setup method to setup and add the required ManagedIceObjects.

class ExampleApp :
virtual public armarx::Application
{
Ice::PropertiesPtr properties)
{
registry->addObject(Component::create<Example>(properties));
};
}
Baseclass for all ArmarX applications.
Definition Application.h:194
virtual void setup(const ManagedIceObjectRegistryInterfacePtr &registry, Ice::PropertiesPtr properties)=0
Setup method to be implemented by user applications.
static TPtr create(Ice::PropertiesPtr properties=Ice::createProperties(), const std::string &configName="", const std::string &configDomain="ArmarX")
Factory method for a component.
Definition Component.h:116
::IceInternal::Handle<::Ice::Properties > PropertiesPtr
Definition PropertyDefinition.h:50
IceUtil::Handle< ManagedIceObjectRegistryInterface > ManagedIceObjectRegistryInterfacePtr
Definition Application.h:83

The application automatically loads a default config file (usually ~/.armarx/default.cfg), which is needed to connect to IceGrid etc. This function is also available as a static version: LoadDefaultConfig()

If you only want to use one component (as above), you can use runSimpleComponentApp. In this case, your main function would look like this:

int main(int argc, char* argv[])
{
return armarx::runSimpleComponentApp<ExampleComponent, ApplicationType>(argc, argv, "ExampleAppName", "ExampleComponentConfigName", "ExampleComponentDomain");
}
int main()
Definition UnscentedKalmanFilterTest.cpp:175
int runSimpleComponentApp(int argc, char *argv[], std::string appName, const std::string &configName="", const std::string &configDomain="ArmarX", bool enableLibLoading=false)
Creates and runs an application (of AppT) for the given component (ComponentT).
Definition Application.h:494

If you are using the defaults for ApplicationType (Application) ExampleComponentConfigName (getDefaultName()) and ExampleComponentDomain ("ArmarX"), your main function looks like this:

int main(int argc, char* argv[])
{
return armarx::runSimpleComponentApp<ExampleComponent>(argc, argv, "ExampleAppName");
}

Application specific configuration files can be passed to the application by using the Ice.Config commandline parameter. The used configuration file format is those of regular Ice configuration files.

Each entry in Ice configuration files is prefixed with a "DomainName" which is "ArmarX" by default. This "DomainName" can be changed by overriding armarx::Application::getDomainName() to return a different string.

Sometimes it is not possible to pass configuration files via the Ice.Config parameter (e.g. when using IceGrid XML deployment files where this paramter is overriden by IceGrid). In this case, the commandline parameter ArmarX.Config can be used. All files specified in this parameter will be merged into the standard properties available inside the armarx::Application.

Special properties:

  • ArmarX.Config
  • ArmarX.NetworkStats: set to "1" to enable logging of network statistics (use armarx::ProfilerObserver to collect the data)
  • ArmarX.DependenciesConfig
  • ArmarX.ProjectDatapath
  • ArmarX.ProjectName
  • ArmarX.ProjectDependencies
  • <DomainName>.DisableLogging
  • <DomainName>.Verbosity
  • <DomainName>.DataPath

Internally, an armarx::Application contains an armarx::ArmarXManger which is responsible for managing they lifecycle of all components inside an application.

Constructor & Destructor Documentation

◆ Application()

Application initalizes the Ice::Application base class.

Member Function Documentation

◆ createInstance()

template<class T, typename... Args>
static ApplicationPtr createInstance ( Args &&... args)
inlinestatic

Creates the one application instance of type T.

T is usually the type of a sublass as defined in a specific component. This method is called from the automatically generated main.cpp.

Returns
shared pointer to the application

◆ createPropertyDefinitions()

PropertyDefinitionsPtr createPropertyDefinitions ( )
overrideprotectedvirtual

◆ doMain()

int doMain ( int argc,
char * argv[],
const Ice::InitializationData & initData,
Ice::Int i )
overrideprotected

Ice::Application::doMain() is called by Ice::Application::main() and does setup of Ice::Communicator before calling the virtual Ice::Application::run() method.

Parameters
argc
argv
initData
Returns

◆ enableLibLoading()

void enableLibLoading ( bool enable = true)

◆ exec()

int exec ( const ArmarXManagerPtr & armarXManager)
protectedvirtual

Exec method is the main process of the application.

The default implementation only calls

armarXManager->waitForShutdown();

If you need to do something in the main process (e.g. processing QT guis) overwrite this method.

Returns
program exit status

Reimplemented in ArmarXGuiApp, ScenarioCli, and SimulatorViewerApp.

◆ GetArmarXConfigDefaultPath()

std::string GetArmarXConfigDefaultPath ( bool envVarExpanded = true)
static

◆ getArmarXManager()

ArmarXManagerPtr getArmarXManager ( )
protected
Returns
an instance of armarx::ArmarXManagerPtr

◆ getArmarXPackageNames()

std::vector< std::string > getArmarXPackageNames ( )

getDefaultPackageNames returns the value of the ArmarX.DefaultPackages property It splits the string by , and returns the elements as a vector.

Returns

◆ getCommandLineArguments()

const std::vector< std::string > & getCommandLineArguments ( ) const

◆ GetDefaultsPaths()

Ice::StringSeq GetDefaultsPaths ( )
static

◆ getDomainName()

std::string getDomainName ( )
protectedvirtual

Retrieve the domain name used for property parsing.

Overwrite this in your subclass in order to use another domain name then "ArmarX". The domain name is the first part of the property identifier where each part is separated via a "." (e.g. ArmarX.some.property).

Returns
domain name. Defaults to "ArmarX".

Reimplemented in MemoryXApplication, and VisionXApplication.

◆ getForbidThreadCreation()

bool getForbidThreadCreation ( ) const

◆ getInstance()

ApplicationPtr getInstance ( )
static

Retrieve shared pointer to the application object.

Use this in order to access is called from the automatically generated main.cpp.

Returns
shared pointer to the application

◆ getName()

std::string getName ( ) const

Retrieve name of the application.

Returns
application name

◆ GetProjectDependencies()

const Ice::StringSeq & GetProjectDependencies ( )
static

◆ GetProjectName()

const std::string & GetProjectName ( )
static

◆ getThreadPool()

const ThreadPoolPtr & getThreadPool ( ) const

◆ GetVersion()

static std::string GetVersion ( )
inlinestatic

◆ HandlerFault()

void HandlerFault ( int sig)
staticprotected

handlerFault handles signals sendt to the application such as SIGSEGF or SIGABRT (Linux)

Parameters
sig

◆ HandlerInterrupt()

void HandlerInterrupt ( int sig)
staticprotected

handlerInterrupt handles interrupt signals sent to the application (Linux)

Parameters
sig

◆ icePropertiesUpdated()

void icePropertiesUpdated ( const std::set< std::string > & changedProperties)
overridevirtual

This method is called when new Properties are set via setIceProperties().

Each class deriving from PropertyUser can overwrite this method in order to react to changed properties.

Reimplemented from PropertyUser.

◆ interruptCallback()

void interruptCallback ( int signal)
override

Cleans up connections with IceStorm before terminating the app.

Parameters
signalThe signal send to the application

◆ isPackageAutoDiscoveryEnabled()

bool isPackageAutoDiscoveryEnabled ( )

◆ LoadDefaultConfig()

void LoadDefaultConfig ( Ice::PropertiesPtr properties)
static

◆ loadDefaultConfig()

void loadDefaultConfig ( int argc,
char * argv[],
const Ice::InitializationData & initData )
protected

◆ loadDependentProjectDatapaths()

void loadDependentProjectDatapaths ( )
protected

◆ parseOptionsMergeProperties()

Ice::PropertiesPtr parseOptionsMergeProperties ( int argc,
char * argv[] )
protected

Parse options given on the commandline and merge them into the regular properties.

◆ registerDataPathsFromDependencies()

void registerDataPathsFromDependencies ( std::string dependencies)

◆ run()

int run ( int argc,
char * argv[] )
override

Ice::Application replacement for the main function.

◆ setForbidThreadCreation()

void setForbidThreadCreation ( bool value)

◆ setIceProperties()

void setIceProperties ( Ice::PropertiesPtr properties)
overridevirtual

Overrides PropertyUser::setIceProperties() which is called internally.

Additionally it calls Component::updateIceProperties().

Reimplemented from PropertyUser.

◆ setInstance()

void setInstance ( ApplicationPtr const & inst)
static

◆ setName()

void setName ( const std::string & name)

Set name of the application.

Called from main.cpp. This method has an effect only if it is called before Application::main()

Parameters
applicationname

◆ setup()

virtual void setup ( const ManagedIceObjectRegistryInterfacePtr & registry,
Ice::PropertiesPtr properties )
protectedpure virtual

Setup method to be implemented by user applications.

Use this method to add all required ManagedIceObject to the application

See also
void ManagedIceObjectRegistryInterfacePtr::addObject(ManagedIceObjectPtr object)

Implemented in ArmarXGuiApp, DecoupledSingleComponentApp, DummyApplication, MultipleComponentsApplication, ScenarioCli, and SimulatorViewerApp.

◆ showHelp()

void showHelp ( ApplicationOptions::Options & options)
protected

Print help onto the screen or into a file.

◆ storeCommandLineArguments()

void storeCommandLineArguments ( int argc,
char * argv[] )

◆ updateIceProperties()

void updateIceProperties ( const Ice::PropertyDict & properties)
override

Member Data Documentation

◆ ArmarXUserConfigDirEnvVar

const std::string ArmarXUserConfigDirEnvVar = "ARMARX_CONFIG_DIR"
static

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