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. More...
 
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. More...
 
const std::vector< std::string > & getCommandLineArguments () const
 
bool getForbidThreadCreation () const
 
std::string getName () const
 Retrieve name of the application. More...
 
const ThreadPoolPtrgetThreadPool () const
 
void icePropertiesUpdated (const std::set< std::string > &changedProperties) override
 This method is called when new Properties are set via setIceProperties(). More...
 
void interruptCallback (int signal) override
 Cleans up connections with IceStorm before terminating the app. More...
 
bool isPackageAutoDiscoveryEnabled ()
 
void registerDataPathsFromDependencies (std::string dependencies)
 
int run (int argc, char *argv[]) override
 Ice::Application replacement for the main function. More...
 
void setForbidThreadCreation (bool value)
 
void setIceProperties (Ice::PropertiesPtr properties) override
 Overrides PropertyUser::setIceProperties() which is called internally. More...
 
void setName (const std::string &name)
 Set name of the application. More...
 
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. More...
 
template<typename PropertyType >
Property< PropertyType > getProperty (const std::string &name)
 Property creation and retrieval. More...
 
template<typename PropertyType >
Property< PropertyType > getProperty (const std::string &name) const
 Hack to allow using getProperty in const-modified methods. More...
 
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< TgetPropertyAsCSV (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. More...
 
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. More...
 
 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. More...
 
static std::string GetArmarXConfigDefaultPath (bool envVarExpanded=true)
 
static Ice::StringSeq GetDefaultsPaths ()
 
static ApplicationPtr getInstance ()
 Retrieve shared pointer to the application object. More...
 
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. More...
 
virtual int exec (const ArmarXManagerPtr &armarXManager)
 Exec method is the main process of the application. More...
 
ArmarXManagerPtr getArmarXManager ()
 
virtual std::string getDomainName ()
 Retrieve the domain name used for property parsing. More...
 
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. More...
 
virtual void setup (const ManagedIceObjectRegistryInterfacePtr &registry, Ice::PropertiesPtr properties)=0
 Setup method to be implemented by user applications. More...
 
void showHelp (ApplicationOptions::Options &options)
 Print help onto the screen or into a file. More...
 

Static Protected Member Functions

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

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));
};
}

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 armarx::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");
}

If you are using the defaults for ApplicationType (armarx::Application) ExampleComponentConfigName (armarx::Component::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.

Definition at line 193 of file Application.h.

Constructor & Destructor Documentation

◆ Application()

Application initalizes the Ice::Application base class.

Definition at line 283 of file Application.cpp.

Member Function Documentation

◆ createInstance()

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

Definition at line 210 of file Application.h.

◆ createPropertyDefinitions()

PropertyDefinitionsPtr createPropertyDefinitions ( )
overrideprotectedvirtual
See also
PropertyUser::createPropertyDefinitions()

Implements PropertyUser.

Reimplemented in ArmarXGuiApp, and SimulatorViewerApp.

Definition at line 877 of file Application.cpp.

+ Here is the call graph for this function:

◆ 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

Definition at line 758 of file Application.cpp.

+ Here is the call graph for this function:

◆ enableLibLoading()

void enableLibLoading ( bool  enable = true)

Definition at line 249 of file Application.cpp.

◆ 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, SimulatorViewerApp, and ScenarioCli.

Definition at line 529 of file Application.cpp.

◆ GetArmarXConfigDefaultPath()

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

Definition at line 689 of file Application.cpp.

+ Here is the caller graph for this function:

◆ getArmarXManager()

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

Definition at line 751 of file Application.cpp.

◆ 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

Definition at line 670 of file Application.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCommandLineArguments()

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

Definition at line 267 of file Application.cpp.

◆ GetDefaultsPaths()

Ice::StringSeq GetDefaultsPaths ( )
static

Definition at line 804 of file Application.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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.

Definition at line 602 of file Application.cpp.

+ Here is the caller graph for this function:

◆ getForbidThreadCreation()

bool getForbidThreadCreation ( ) const

Definition at line 227 of file Application.cpp.

◆ 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

Definition at line 289 of file Application.cpp.

+ Here is the caller graph for this function:

◆ getName()

std::string getName ( ) const

Retrieve name of the application.

Returns
application name

Definition at line 614 of file Application.cpp.

+ Here is the caller graph for this function:

◆ GetProjectDependencies()

const Ice::StringSeq & GetProjectDependencies ( )
static

Definition at line 870 of file Application.cpp.

+ Here is the caller graph for this function:

◆ GetProjectName()

const std::string & GetProjectName ( )
static

Definition at line 863 of file Application.cpp.

+ Here is the caller graph for this function:

◆ getThreadPool()

const ThreadPoolPtr & getThreadPool ( ) const

Definition at line 356 of file Application.cpp.

◆ GetVersion()

static std::string GetVersion ( )
inlinestatic

Definition at line 234 of file Application.h.

+ Here is the caller graph for this function:

◆ HandlerFault()

void HandlerFault ( int  sig)
staticprotected

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

Parameters
sig

Definition at line 109 of file Application.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ HandlerInterrupt()

void HandlerInterrupt ( int  sig)
staticprotected

handlerInterrupt handles interrupt signals sent to the application (Linux)

Parameters
sig

Definition at line 273 of file Application.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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.

Definition at line 332 of file Application.cpp.

◆ interruptCallback()

void interruptCallback ( int  signal)
override

Cleans up connections with IceStorm before terminating the app.

Parameters
signalThe signal send to the application

Definition at line 620 of file Application.cpp.

◆ isPackageAutoDiscoveryEnabled()

bool isPackageAutoDiscoveryEnabled ( )

Definition at line 656 of file Application.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LoadDefaultConfig()

void LoadDefaultConfig ( Ice::PropertiesPtr  properties)
static

Definition at line 832 of file Application.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadDefaultConfig()

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

Definition at line 826 of file Application.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadDependentProjectDatapaths()

void loadDependentProjectDatapaths ( )
protected

Definition at line 884 of file Application.cpp.

+ Here is the call graph for this function:

◆ parseOptionsMergeProperties()

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

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

Definition at line 538 of file Application.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ registerDataPathsFromDependencies()

void registerDataPathsFromDependencies ( std::string  dependencies)

Definition at line 636 of file Application.cpp.

+ Here is the call graph for this function:

◆ run()

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

Ice::Application replacement for the main function.

Definition at line 363 of file Application.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setForbidThreadCreation()

void setForbidThreadCreation ( bool  value)

Definition at line 233 of file Application.cpp.

+ Here is the call graph for this function:

◆ setIceProperties()

void setIceProperties ( Ice::PropertiesPtr  properties)
overridevirtual

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

Additionally it calls Component::updateIceProperties().

Reimplemented from PropertyUser.

Definition at line 306 of file Application.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setInstance()

void setInstance ( ApplicationPtr const &  inst)
static

Definition at line 297 of file Application.cpp.

+ Here is the caller graph for this function:

◆ 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

Definition at line 608 of file Application.cpp.

+ Here is the caller graph for this function:

◆ 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 MultipleComponentsApplication, DummyApplication, ArmarXGuiApp, SimulatorViewerApp, ScenarioCli, and DecoupledSingleComponentApp.

+ Here is the caller graph for this function:

◆ showHelp()

void showHelp ( ApplicationOptions::Options options)
protected

Print help onto the screen or into a file.

Definition at line 570 of file Application.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ storeCommandLineArguments()

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

Definition at line 255 of file Application.cpp.

◆ updateIceProperties()

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

Definition at line 319 of file Application.cpp.

+ Here is the call graph for this function:

Member Data Documentation

◆ ArmarXUserConfigDirEnvVar

const std::string ArmarXUserConfigDirEnvVar = "ARMARX_CONFIG_DIR"
static

Definition at line 296 of file Application.h.


The documentation for this class was generated from the following files:
armarx::Application::setup
virtual void setup(const ManagedIceObjectRegistryInterfacePtr &registry, Ice::PropertiesPtr properties)=0
Setup method to be implemented by user applications.
armarx::ManagedIceObjectRegistryInterfacePtr
IceUtil::Handle< ManagedIceObjectRegistryInterface > ManagedIceObjectRegistryInterfacePtr
Definition: Application.h:83
IceInternal::Handle< ::Ice::Properties >
armarx::Application
Baseclass for all ArmarX applications.
Definition: Application.h:193
main
int main(int argc, char *argv[])
Definition: Admin.cpp:45