33#include <Ice/Application.h>
34#include <Ice/BuiltinSequences.h>
35#include <Ice/PropertiesF.h>
36#include <IceUtil/Handle.h>
55 struct InitializationData;
58#define xstr(s) stringify(s)
59#define stringify(s) #s
74 class ManagedIceObjectRegistryInterface;
208 template <
class T,
typename... Args>
212 std::unique_lock lock(instanceMutex);
216 throw LocalException(
"Application instance already created");
238 return xstr(ARMARX_VERSION);
247 int run(
int argc,
char* argv[])
override;
255 void setName(
const std::string& name);
262 std::string getName()
const;
269 void interruptCallback(
int signal)
override;
271 void registerDataPathsFromDependencies(std::string dependencies);
278 std::vector<std::string> getArmarXPackageNames();
280 bool isPackageAutoDiscoveryEnabled();
282 static std::string GetArmarXConfigDefaultPath(
bool envVarExpanded =
true);
283 static Ice::StringSeq GetDefaultsPaths();
285 static const std::string& GetProjectName();
286 static const Ice::StringSeq& GetProjectDependencies();
294 void updateIceProperties(
const Ice::PropertyDict& properties)
override;
296 void icePropertiesUpdated(
const std::set<std::string>& changedProperties)
override;
346 const Ice::InitializationData& initData,
347 Ice::Int i)
override;
349 void loadDefaultConfig(
int argc,
char* argv[],
const Ice::InitializationData& initData);
393 void loadLibrariesFromProperties();
403 static std::mutex instanceMutex;
408 std::string applicationName;
417 std::shared_ptr<std::thread> shutdownThread;
419 static std::string ProjectName;
420 static Ice::StringSeq ProjectDependendencies;
423 bool forbidThreadCreation =
false;
424 bool libLoadingEnabled =
false;
426 std::vector<std::string> commandLineArguments;
443 template <
class ComponentT,
class AppT>
492 template <
class ComponentT,
class AppT = armarx::Application>
497 const std::string& configName =
"",
498 const std::string& configDomain =
"ArmarX",
499 bool enableLibLoading =
false)
502 AppT::template createInstance<internal::SimpleSingleComponentApp<ComponentT, AppT>>();
506 sApp->appConfigDomain = configDomain;
507 sApp->appConfigName = configName;
508 app->enableLibLoading(enableLibLoading);
509 app->setName(appName);
510 app->storeCommandLineArguments(argc, argv);
511 return app->main(argc, argv);
535 registry->addObject(comp);
540 template <
class ComponentType>
541 std::vector<ComponentPtr>
547 template <
class ComponentType,
class... ComponentTypes>
548 std::vector<ComponentPtr>
551 std::vector<ComponentPtr> result{comp};
553 result.insert(result.end(), tempResult.begin(), tempResult.end());
557 template <
class... ComponentTypes>
558 std::vector<ComponentPtr>
561 std::vector<ComponentPtr> result;
563 result.insert(result.end(), tempResult.begin(), tempResult.end());
583 template <
class... ComponentTypes>
584 std::tuple<armarx::ApplicationPtr, std::vector<ComponentPtr>>
588 const std::string& configDomain =
"ArmarX")
591 std::vector<ComponentPtr> comps =
595 app->setName(appName);
596 return std::make_tuple(app, comps);
#define ARMARXCORE_IMPORT_EXPORT
The ApplicationNetworkStats class implements the Ice::Instrumentation::CommunicatorObserver interface...
ApplicationPropertyDefinitions(std::string prefix)
Baseclass for all ArmarX applications.
static void HandlerInterrupt(int sig)
handlerInterrupt handles interrupt signals sent to the application (Linux)
void loadDefaultConfig(int argc, char *argv[], const Ice::InitializationData &initData)
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 ...
const std::vector< std::string > & getCommandLineArguments() const
virtual std::string getDomainName()
Retrieve the domain name used for property parsing.
static void HandlerFault(int sig)
handlerFault handles signals sendt to the application such as SIGSEGF or SIGABRT (Linux)
void showHelp(ApplicationOptions::Options &options)
Print help onto the screen or into a file.
ArmarXManagerPtr getArmarXManager()
const ThreadPoolPtr & getThreadPool() const
static ApplicationPtr createInstance(Args &&... args)
Creates the one application instance of type T.
void loadDependentProjectDatapaths()
PropertyDefinitionsPtr createPropertyDefinitions() override
bool getForbidThreadCreation() const
void enableLibLoading(bool enable=true)
static const std::string ArmarXUserConfigDirEnvVar
virtual void setup(const ManagedIceObjectRegistryInterfacePtr ®istry, Ice::PropertiesPtr properties)=0
Setup method to be implemented by user applications.
void storeCommandLineArguments(int argc, char *argv[])
void setForbidThreadCreation(bool value)
Ice::PropertiesPtr parseOptionsMergeProperties(int argc, char *argv[])
Parse options given on the commandline and merge them into the regular properties.
Application()
Application initalizes the Ice::Application base class.
virtual int exec(const ArmarXManagerPtr &armarXManager)
Exec method is the main process of the application.
static std::string GetVersion()
static TPtr create(Ice::PropertiesPtr properties=Ice::createProperties(), const std::string &configName="", const std::string &configDomain="ArmarX")
Factory method for a component.
void setup(const ManagedIceObjectRegistryInterfacePtr ®istry, Ice::PropertiesPtr properties) override
Setup method to be implemented by user applications.
MultipleComponentsApplication(std::vector< ComponentPtr > components)
void setup(const ManagedIceObjectRegistryInterfacePtr ®istry, Ice::PropertiesPtr properties) override
Setup method to be implemented by user applications.
PropertyDefinitionContainer(const std::string &prefix)
std::string prefix
Prefix of the properties such as namespace, domain, component name, etc.
Used by runSimpleComponentApp<ComponentT, AppT>. This class can't be defined in function,...
std::string appConfigName
std::string appConfigDomain
Ice::PropertiesPtr createProperties()
::IceInternal::Handle<::Ice::Properties > PropertiesPtr
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceUtil::Handle< ArmarXManager > ArmarXManagerPtr
IceUtil::Handle< ManagedIceObjectRegistryInterface > ManagedIceObjectRegistryInterfacePtr
::IceUtil::Handle< ApplicationNetworkStats > ApplicationNetworkStatsPtr
std::vector< ComponentPtr > createComponents(ComponentType comp)
std::vector< ComponentPtr > createComponentsUtil(ComponentTypes &&... components)
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).
IceUtil::Handle< Application > ApplicationPtr
std::shared_ptr< ThreadPool > ThreadPoolPtr
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
std::tuple< armarx::ApplicationPtr, std::vector< ComponentPtr > > runMultipleComponentsApp(int argc, char *argv[], std::string appName, const std::string &configDomain="ArmarX")
Convenience function to create an app with multiple components easily.
IceInternal::Handle< Component > ComponentPtr
Component smart pointer type.
Stucture containing the parsed options of the application.