ApplicationInstance Class Reference

Class containing data about the instance of an application. More...

#include <ArmarXCore/util/ScenarioManagerCommon/data_structure/ApplicationInstance.h>

+ Inheritance diagram for ApplicationInstance:

Public Member Functions

void addProperty (std::string name, std::string value)
 Adds a new property with the specified name and value to this ApplicationInstance.
 
bool adoptPidIfUnset (int newPid)
 Sets the pid to newPid, but only if no pid is currently known (i.e.
 
 ApplicationInstance (Application application, std::string instanceName, std::string configPath, ScenarioPtr scenarioName, std::string node, bool enabled)
 Constructor that sets the base data of this ApplicationInstance.
 
 ApplicationInstance (std::string executableName, std::string executablePath, std::string instanceName, std::string configPath, std::string packageName, ScenarioPtr scenarioName, std::string node, bool enabled)
 Constructor that sets the base data of this ApplicationInstance.
 
bool compareAndResetPid (int expectedPid)
 Sets the pid to -1, but only if it is still expectedPid.
 
void copyFrom (ApplicationInstance &other)
 copyFrom Copy the other instance configuration to this one.
 
void deleteConfig ()
 
std::string getConfigDomain () const
 
std::string getConfigPath ()
 
std::string getEffectiveNodeName () const
 
bool getEnabled ()
 
std::string getInstanceName ()
 
std::string getNodeName () const
 
Intent getPendingIntent () const
 The intent this application is currently moving towards, or None when idle.
 
int getPid ()
 
ScenarioPtr getScenario ()
 
std::string getStatus ()
 Returns the status.
 
bool isConfigWritable ()
 
bool isReadOnly () const
 
void linkFrom (ApplicationInstance &other)
 linkFrom Link this instance configuration from the other instance.
 
void load (bool firstLoad=false)
 Loades the IceProperties from the configPath Firstload determins if properties that equal their default value get uncommented.
 
void makeLocal ()
 Make a local copy of this instance if it is linked and nothing otherwise.
 
void modifyProperty (std::string name, std::string value)
 Changes the value of the specified property.
 
void resetConfigPath ()
 resetConfigPath.
 
void save ()
 Saves the IceProperties to the configPath.
 
void setConfigDomain (const std::string &value)
 
void setConfigPath (std::string configPath)
 Sets the config path of this ApplicationInstance.
 
void setEnabled (bool enabled)
 
void setInstanceName (std::string newName)
 Sets the name of this ApplicationInstance.
 
void setNodeName (std::string nodeName)
 
void setPendingIntent (Intent intent)
 
void setPid (int pid)
 Sets the pid of this ApplicationInstance.
 
bool setStatus (const std::string &status)
 Sets the status of this ApplicationInstance.
 
- Public Member Functions inherited from Application
 Application (Application &app)
 Copy constructor.
 
 Application (std::string name, std::string executablePath, std::string packageName)
 Constructor that sets the name and the path to the executable of the application.
 
std::string getExecutableAbsPath ()
 
std::string getExecutableName ()
 
bool getFound ()
 
std::string getName ()
 
std::string getPackageName ()
 
std::string getPathToExecutable ()
 
armarx::PropertyDefinitionsPtr getProperties ()
 
bool isDefaultProperty (std::string name)
 
bool isDefaultPropertyEnabled (std::string name)
 
void setDefaultPropertyEnabled (std::string name, bool enabled)
 
void setIsDefaultProperty (std::string name, bool defaultValue)
 
void setProperties (armarx::PropertyDefinitionsPtr properties)
 Sets the properties of this application.
 
void updateFound ()
 Checks whether the executable exists and caches the result for getFound().
 

Additional Inherited Members

- Protected Attributes inherited from Application
PropertyEnabledMap defaultMap
 
PropertyEnabledMap enabledMap
 
armarx::PropertyDefinitionsPtr properties
 
std::mutex propertiesMutex
 Guards properties, enabledMap and defaultMap.
 

Detailed Description

Class containing data about the instance of an application.

Provides methods to get and set the data. It is only representative and doesn't actually synchronize with the configuration files.

Constructor & Destructor Documentation

◆ ApplicationInstance() [1/2]

ApplicationInstance ( std::string executableName,
std::string executablePath,
std::string instanceName,
std::string configPath,
std::string packageName,
ScenarioPtr scenarioName,
std::string node,
bool enabled )

Constructor that sets the base data of this ApplicationInstance.

Parameters
executableNameThe name of the Application
executablePathThe path of the Executable
instanceNamea name that distinguishes this instance from other instances
configPathpath to the config file of this instance

◆ ApplicationInstance() [2/2]

ApplicationInstance ( Application application,
std::string instanceName,
std::string configPath,
ScenarioPtr scenarioName,
std::string node,
bool enabled )

Constructor that sets the base data of this ApplicationInstance.

Parameters
applicationThe application this class instantiates.
instanceNamea name that distinguishes this instance from other instances
configPathpath to the config file of this instance

Member Function Documentation

◆ addProperty()

void addProperty ( std::string name,
std::string value )

Adds a new property with the specified name and value to this ApplicationInstance.

Parameters
namename of the new property
valuevalue of the new property

◆ adoptPidIfUnset()

bool adoptPidIfUnset ( int newPid)

Sets the pid to newPid, but only if no pid is currently known (i.e.

it is -1). Used when adopting a pid cached on disk, so that a concurrently started process wins.

Returns
whether the pid was set.

◆ compareAndResetPid()

bool compareAndResetPid ( int expectedPid)

Sets the pid to -1, but only if it is still expectedPid.

The status poller and the starter/stopper threads all inspect and update the pid concurrently. Whoever observes that a process has died must clear only the pid it actually probed - an unconditional reset can wipe the pid a concurrent start has just stored, which would leave a running application marked as stopped indefinitely.

Returns
whether the pid was reset.

◆ copyFrom()

void copyFrom ( ApplicationInstance & other)

copyFrom Copy the other instance configuration to this one.

Parameters
otherthe instance to copy

◆ deleteConfig()

void deleteConfig ( )

◆ getConfigDomain()

std::string getConfigDomain ( ) const

◆ getConfigPath()

std::string getConfigPath ( )
Returns
config path of this ApplicationInstance

◆ getEffectiveNodeName()

std::string getEffectiveNodeName ( ) const

◆ getEnabled()

bool getEnabled ( )

◆ getInstanceName()

std::string getInstanceName ( )
Returns
name of this ApplicationInstance

◆ getNodeName()

std::string getNodeName ( ) const

◆ getPendingIntent()

Data_Structure::Intent getPendingIntent ( ) const

The intent this application is currently moving towards, or None when idle.

Written by the ApplicationLifecycle that owns the application, so it is up to date as soon as a request has been made rather than only after the next status poll. The GUI uses it both to show the application as "Waiting" and to grey out the button of the operation that is under way.

◆ getPid()

int getPid ( )
Returns
pid of this ApplicationInstance

◆ getScenario()

Data_Structure::ScenarioPtr getScenario ( )

◆ getStatus()

std::string getStatus ( )

Returns the status.

Doesn't update automatically, is not necessarily synchronized with the actual status of the process. Use the Executor to get the actual status of this application.

Returns
status of this ApplicationInstance
See also
Executor

◆ isConfigWritable()

bool isConfigWritable ( )

◆ isReadOnly()

bool isReadOnly ( ) const

◆ linkFrom()

void linkFrom ( ApplicationInstance & other)

linkFrom Link this instance configuration from the other instance.

Parameters
otherthe source instance

◆ load()

void load ( bool firstLoad = false)

Loades the IceProperties from the configPath Firstload determins if properties that equal their default value get uncommented.

◆ makeLocal()

void makeLocal ( )

Make a local copy of this instance if it is linked and nothing otherwise.

◆ modifyProperty()

void modifyProperty ( std::string name,
std::string value )

Changes the value of the specified property.

Parameters
namename of the property whose value is to be changed
valuenew value of the property

◆ resetConfigPath()

void resetConfigPath ( )

resetConfigPath.

should be called when the instanceName is changed/ deletes the old cfg file and resets the local config Path to where the file should be you should call save after this

◆ save()

void save ( )

Saves the IceProperties to the configPath.

◆ setConfigDomain()

void setConfigDomain ( const std::string & value)

◆ setConfigPath()

void setConfigPath ( std::string configPath)

Sets the config path of this ApplicationInstance.

Parameters
newconfig path

◆ setEnabled()

void setEnabled ( bool enabled)

◆ setInstanceName()

void setInstanceName ( std::string newName)

Sets the name of this ApplicationInstance.

Parameters
newname

◆ setNodeName()

void setNodeName ( std::string nodeName)

◆ setPendingIntent()

void setPendingIntent ( Intent intent)

◆ setPid()

void setPid ( int pid)

Sets the pid of this ApplicationInstance.

This pid gets used by the Executor to stop this application, therefore it is not suggested to set this to random values. Set this to -1, if no pid is known.

Parameters
pidnew pid

◆ setStatus()

bool setStatus ( const std::string & status)

Sets the status of this ApplicationInstance.

Parameters
newstatus. Should be either "running" or "stopped" for Scenario statuses to work properly.
Returns
tree if status changed.

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