openDAQ
Open data acquisition platform
InstanceBuilderPtr Class Reference

Builder component of Instance objects. Contains setter methods to configure the Instance parameters, such as Context (Logger, Scheduler, ModuleManager) and RootDevice. Contains a build method that builds the Instance object. More...

Inherits ObjectPtr< IInstanceBuilder >.

Detailed Description

Builder component of Instance objects. Contains setter methods to configure the Instance parameters, such as Context (Logger, Scheduler, ModuleManager) and RootDevice. Contains a build method that builds the Instance object.

The InstanceBuilder provides a fluent interface for setting various configuration options for an Instance object before its creation. It allows customization of the logger, module manager, scheduler and root device. Once configured, calling the build method returns a fully initialized Instance object with the specified settings.

Methods:

The InstanceBuilder provides the following configuration methods:

  • Logger: The custom Logger for the Instance. This logger will be used for logging messages related to the Instance and its components. If a custom logger is set, the Logger sink will be ignored since it is only used with the default Instance logger. If custom logger was not set, builder will generate Instance with default logger.
  • Global log level: The Logger global log level for the Instance. All log messages with a severity level equal to or higher than the specified level will be processed. Default log level is LogLevel::Default
  • Component log level: The Logger level for a specific component of the Instance. Log messages related to that component will be processed according to the specified log level. By default, each component uses the global log level.
  • Logger sink: The logger sink to the default Instance logger. This sink will be responsible for processing log messages, such as writing them to a file or sending them to a remote server. If Logger has been set, configuring of the 'Logger sink' has no effect in building Instance. If logger sinks has not been configure, the Instance uses 'default sinks'.
  • Module manager: The custom ModuleManager for the Instance. When configured, the default module manager path will be ignored. If module manager has not configured, the Instance uses built in manager
  • Module path: The path for the default ModuleManager of the Instance. If a custom module manager has not been set, this path will be used to load modules. Default module path is empty string
  • Scheduler: The custom scheduler for the Instance. If set, the number of worker threads will be ignored. If scheduler has not been configured, the Instance uses default schduler.
  • Scheduler worker num: The number of worker threads in the scheduler of the Instance. if a scheduler has not been set and worker num is 0, which considers as maximum number of concurrent threads.
  • Default root device local ID: The local id of the default client root device. Has no effect if Root device has been congigured.
  • Default root device info: The information of default root device of the Instance such as serial number. Has no effect if Root device has been congigured.
  • Root device: The connection string of a device that replaces the default openDAQ root device (virtual client). When the instance is created a connection to the device with the given connection string will be established, and the device will be placed at the root of the component tree structure. When configured, the Default root device local ID and Default root device info will be ignored.
  • Sink log level: The sink logger level of the default Instance logger. This level is ignored if a custom logger has been configured.
  • Config provider: The config provider is expanding the local options of instance builder from json file or command lines. If value was set before, provider will override this with new one.
  • Module options: Local options dictionary of instance builder has modules key which contains custom values for modules. By default this dictionary is empty, but can be populated from json file, env variables or command line arguments.

Public Member Functions

daq::InstancePtr build () const
 Builds and returns an Instance object using the currently set values of the Builder. More...
 
InstanceBuilderPtr addConfigProvider (const daq::ConfigProviderPtr &configProvider) const
 Populates internal options dictionary with values from set config provider. More...
 
InstanceBuilderPtr setContext (const daq::ContextPtr &context) const
 Sets the Context object of the instance. This overwrites other context related settings such as logger, scheduler and module manager settings. More...
 
daq::ContextPtr getContext () const
 Returns a context object of the instance. More...
 
InstanceBuilderPtr setLogger (const daq::LoggerPtr &logger) const
 Sets the custom Logger for the Instance. This logger will be used for logging messages related to the Instance and its components. When configured, the Logger sink will be ignored, as it is in use only with the default Instance logger. More...
 
daq::LoggerPtr getLogger () const
 Gets the Logger of the Instance. Returns nullptr if custom logger has not been set. More...
 
InstanceBuilderPtr setGlobalLogLevel (daq::LogLevel logLevel) const
 Sets the Logger global log level for the Instance. All log messages with a severity level equal to or higher than the specified level will be processed. More...
 
daq::LogLevel getGlobalLogLevel () const
 Gets the default Logger global level of Instance. More...
 
InstanceBuilderPtr setComponentLogLevel (const daq::StringPtr &component, daq::LogLevel logLevel) const
 Sets The Logger level for a specific component of the Instance. Log messages related to that component will be processed according to the specified log level. More...
 
daq::DictPtr< daq::IString, daq::INumber > getComponentsLogLevel () const
 Gets the dictionary of component names and log level which will be added to logger components. More...
 
InstanceBuilderPtr addLoggerSink (const daq::LoggerSinkPtr &sink) const
 Adds the logger sink of the default Instance logger. If Logger has been set, configuring of the Logger sink has no effect in building Instance. More...
 
InstanceBuilderPtr setSinkLogLevel (const daq::LoggerSinkPtr &sink, daq::LogLevel logLevel) const
 Sets the sink logger level of the default Instance logger. If Logger has been set, configuring of the Logger sink has no effect in building Instance. More...
 
daq::ListPtr< daq::ILoggerSink > getLoggerSinks () const
 Gets the list of logger sinks for the default Instance logger. More...
 
InstanceBuilderPtr setModulePath (const daq::StringPtr &path) const
 Sets the path for the default ModuleManager of the Instance. If Module manager has been set, configuring of Module path has no effect in building Instance. More...
 
daq::StringPtr getModulePath () const
 Gets the path for the default ModuleManager of Instance. More...
 
InstanceBuilderPtr addModulePath (const daq::StringPtr &path) const
 Add the path for the default ModuleManager of the Instance. If Module manager has been set, configuring of Module path has no effect in building Instance. More...
 
daq::ListPtr< daq::IString > getModulePathsList () const
 Get the list of paths for the default ModuleManager of the Instance. If Module manager has been set, configuring of Module path has no effect in building Instance. More...
 
InstanceBuilderPtr setModuleManager (const daq::ModuleManagerPtr &moduleManager) const
 Sets The custom ModuleManager for the Instance. More...
 
daq::ModuleManagerPtr getModuleManager () const
 Gets the custom ModuleManager of Instance. More...
 
InstanceBuilderPtr setAuthenticationProvider (const daq::AuthenticationProviderPtr &authenticationProvider) const
 Sets the AuthenticationProvider for the Instance. More...
 
daq::AuthenticationProviderPtr getAuthenticationProvider () const
 Gets the AuthenticationProvider of Instance. More...
 
InstanceBuilderPtr setSchedulerWorkerNum (daq::SizeT numWorkers) const
 Sets the number of worker threads in the scheduler of the Instance. If Scheduler has been set, configuring of Scheduler worker num has no effect in building Instance. More...
 
daq::SizeT getSchedulerWorkerNum () const
 Gets the amount of worker threads in the scheduler of Instance. More...
 
InstanceBuilderPtr setScheduler (const daq::SchedulerPtr &scheduler) const
 Sets the custom scheduler of Instance. More...
 
daq::SchedulerPtr getScheduler () const
 Gets the custom scheduler of Instance. More...
 
InstanceBuilderPtr setDefaultRootDeviceLocalId (const daq::StringPtr &localId) const
 Sets the local id for default device. Has no effect if Root device has been congigured. More...
 
daq::StringPtr getDefaultRootDeviceLocalId () const
 Gets the default root device local id. More...
 
InstanceBuilderPtr setRootDevice (const daq::StringPtr &connectionString, const daq::PropertyObjectPtr &config=nullptr) const
 Sets the connection string for a device that replaces the default openDAQ root device. When the instance is created, a connection to the device with the given connection string will be established, and the device will be placed at the root of the component tree structure. More...
 
daq::StringPtr getRootDevice () const
 Gets the connection string for the default root device of Instance. More...
 
daq::PropertyObjectPtr getRootDeviceConfig () const
 Gets the configuration property object for the default root device of Instance. More...
 
InstanceBuilderPtr setDefaultRootDeviceInfo (const daq::DeviceInfoPtr &deviceInfo) const
 Sets the default device info of Instance. If device info has been set, method getInfo of Instance will return set device info if Root Device has not been set. More...
 
daq::DeviceInfoPtr getDefaultRootDeviceInfo () const
 Gets the default device info of Instance. More...
 
daq::DictPtr< daq::IString, daq::IBaseObject > getOptions () const
 Gets the dictionary of instance options. More...
 
InstanceBuilderPtr enableStandardProviders (daq::Bool flag) const
 Allows enabling or disabling standard configuration providers, including JsonConfigProvider, based on the specified flag. More...
 
daq::ListPtr< daq::IString > getDiscoveryServers () const
 Gets the dictionary of discovery servers. More...
 
InstanceBuilderPtr addDiscoveryServer (const daq::StringPtr &serverName) const
 Adds a discovery server to the context. More...
 

Member Function Documentation

◆ addConfigProvider()

InstanceBuilderPtr addConfigProvider ( const daq::ConfigProviderPtr &  configProvider) const
inline

Populates internal options dictionary with values from set config provider.

Parameters
configProviderThe configuration provider

◆ addDiscoveryServer()

InstanceBuilderPtr addDiscoveryServer ( const daq::StringPtr &  serverName) const
inline

Adds a discovery server to the context.

Parameters
serverNameThe discovery server to add

openDAQ supports the "mdns" server by default, but must be added to the instance builder to be enabled.

◆ addLoggerSink()

InstanceBuilderPtr addLoggerSink ( const daq::LoggerSinkPtr &  sink) const
inline

Adds the logger sink of the default Instance logger. If Logger has been set, configuring of the Logger sink has no effect in building Instance.

Parameters
sinkThe logger sink of the default Instance logger

◆ addModulePath()

InstanceBuilderPtr addModulePath ( const daq::StringPtr &  path) const
inline

Add the path for the default ModuleManager of the Instance. If Module manager has been set, configuring of Module path has no effect in building Instance.

Parameters
pathThe path for the default ModuleManager of Instance

◆ build()

daq::InstancePtr build ( ) const
inline

Builds and returns an Instance object using the currently set values of the Builder.

Returns
The built Instance.

◆ enableStandardProviders()

InstanceBuilderPtr enableStandardProviders ( daq::Bool  flag) const
inline

Allows enabling or disabling standard configuration providers, including JsonConfigProvider, based on the specified flag.

Parameters
flagBoolean flag indicating whether to enable (true) or disable (false) standard config providers.

◆ getAuthenticationProvider()

daq::AuthenticationProviderPtr getAuthenticationProvider ( ) const
inline

Gets the AuthenticationProvider of Instance.

Returns
The AuthenticationProvider of Instance.

◆ getComponentsLogLevel()

daq::DictPtr<daq::IString, daq::INumber> getComponentsLogLevel ( ) const
inline

Gets the dictionary of component names and log level which will be added to logger components.

Returns
The dictionary of component names and log level

◆ getContext()

daq::ContextPtr getContext ( ) const
inline

Returns a context object of the instance.

Returns
The Context object of the instance.

◆ getDefaultRootDeviceInfo()

daq::DeviceInfoPtr getDefaultRootDeviceInfo ( ) const
inline

Gets the default device info of Instance.

Returns
The default device info of Instance. Returns nullptr, if default device info has not been set.

◆ getDefaultRootDeviceLocalId()

daq::StringPtr getDefaultRootDeviceLocalId ( ) const
inline

Gets the default root device local id.

Returns
The default root device local id. Returns empty string id default root device local is has not been set.

◆ getDiscoveryServers()

daq::ListPtr<daq::IString> getDiscoveryServers ( ) const
inline

Gets the dictionary of discovery servers.

Returns
The dictionary of discovery server names

◆ getGlobalLogLevel()

daq::LogLevel getGlobalLogLevel ( ) const
inline

Gets the default Logger global level of Instance.

Returns
The Logger global level of Instance. Returns LogLevel::Default, If global log level has not been set

◆ getLogger()

daq::LoggerPtr getLogger ( ) const
inline

Gets the Logger of the Instance. Returns nullptr if custom logger has not been set.

Returns
The Logger of Instance

◆ getLoggerSinks()

daq::ListPtr<daq::ILoggerSink> getLoggerSinks ( ) const
inline

Gets the list of logger sinks for the default Instance logger.

Returns
The list of logger sinks of the default Instance logger

◆ getModuleManager()

daq::ModuleManagerPtr getModuleManager ( ) const
inline

Gets the custom ModuleManager of Instance.

Returns
The ModuleManager of Instance. Returns nullptr, if custom ModuleManager has not been set

◆ getModulePath()

daq::StringPtr getModulePath ( ) const
inline

Gets the path for the default ModuleManager of Instance.

Returns
The path for the default ModuleManager of Instance. Returns empty string, If module path has not been set

◆ getModulePathsList()

daq::ListPtr<daq::IString> getModulePathsList ( ) const
inline

Get the list of paths for the default ModuleManager of the Instance. If Module manager has been set, configuring of Module path has no effect in building Instance.

Returns
The paths for the default ModuleManager of Instance

◆ getOptions()

daq::DictPtr<daq::IString, daq::IBaseObject> getOptions ( ) const
inline

Gets the dictionary of instance options.

Returns
The dictionary of instance options

◆ getRootDevice()

daq::StringPtr getRootDevice ( ) const
inline

Gets the connection string for the default root device of Instance.

Returns
The connection string for the root device of Instance. Returns nullptr, if root device connection string has not been set.

◆ getRootDeviceConfig()

daq::PropertyObjectPtr getRootDeviceConfig ( ) const
inline

Gets the configuration property object for the default root device of Instance.

Returns
The configuraton property object for the root device of Instance. Returns nullptr, for the default * configuration property object.

◆ getScheduler()

daq::SchedulerPtr getScheduler ( ) const
inline

Gets the custom scheduler of Instance.

Returns
The custom scheduler of Instance. Returns nullptr, if custom Scheduler has not been set.

◆ getSchedulerWorkerNum()

daq::SizeT getSchedulerWorkerNum ( ) const
inline

Gets the amount of worker threads in the scheduler of Instance.

Returns
The amount of worker threads in the scheduler of Instance. Returns 0, if worker num has not been set

◆ setAuthenticationProvider()

InstanceBuilderPtr setAuthenticationProvider ( const daq::AuthenticationProviderPtr &  authenticationProvider) const
inline

Sets the AuthenticationProvider for the Instance.

Parameters
authenticationProviderThe AuthenticationProvider for the Instance

◆ setComponentLogLevel()

InstanceBuilderPtr setComponentLogLevel ( const daq::StringPtr &  component,
daq::LogLevel  logLevel 
) const
inline

Sets The Logger level for a specific component of the Instance. Log messages related to that component will be processed according to the specified log level.

Parameters
componentThe name of Instance component
logLevelThe log level of Instance component

◆ setContext()

InstanceBuilderPtr setContext ( const daq::ContextPtr &  context) const
inline

Sets the Context object of the instance. This overwrites other context related settings such as logger, scheduler and module manager settings.

Parameters
contextThe Context object for instance.

◆ setDefaultRootDeviceInfo()

InstanceBuilderPtr setDefaultRootDeviceInfo ( const daq::DeviceInfoPtr &  deviceInfo) const
inline

Sets the default device info of Instance. If device info has been set, method getInfo of Instance will return set device info if Root Device has not been set.

Parameters
deviceInfoThe device info of the default device of Instance

◆ setDefaultRootDeviceLocalId()

InstanceBuilderPtr setDefaultRootDeviceLocalId ( const daq::StringPtr &  localId) const
inline

Sets the local id for default device. Has no effect if Root device has been congigured.

Parameters
localIdThe default root device local id

◆ setGlobalLogLevel()

InstanceBuilderPtr setGlobalLogLevel ( daq::LogLevel  logLevel) const
inline

Sets the Logger global log level for the Instance. All log messages with a severity level equal to or higher than the specified level will be processed.

Parameters
logLevelThe Logger global level of Instance

◆ setLogger()

InstanceBuilderPtr setLogger ( const daq::LoggerPtr &  logger) const
inline

Sets the custom Logger for the Instance. This logger will be used for logging messages related to the Instance and its components. When configured, the Logger sink will be ignored, as it is in use only with the default Instance logger.

Parameters
loggerThe custom Logger of Instance

◆ setModuleManager()

InstanceBuilderPtr setModuleManager ( const daq::ModuleManagerPtr &  moduleManager) const
inline

Sets The custom ModuleManager for the Instance.

Parameters
moduleManagerThe custom ModuleManager of Instance

◆ setModulePath()

InstanceBuilderPtr setModulePath ( const daq::StringPtr &  path) const
inline

Sets the path for the default ModuleManager of the Instance. If Module manager has been set, configuring of Module path has no effect in building Instance.

Parameters
pathThe path for the default ModuleManager of Instance

◆ setRootDevice()

InstanceBuilderPtr setRootDevice ( const daq::StringPtr &  connectionString,
const daq::PropertyObjectPtr &  config = nullptr 
) const
inline

Sets the connection string for a device that replaces the default openDAQ root device. When the instance is created, a connection to the device with the given connection string will be established, and the device will be placed at the root of the component tree structure.

Parameters
connectionStringThe connection string for the root device of the Instance.
configA config object to configure a client device. This object can contain properties like max sample rate, port to use for 3rd party communication, number of channels to generate, or other device specific settings. In case of nullptr, a default configuration is used.

◆ setScheduler()

InstanceBuilderPtr setScheduler ( const daq::SchedulerPtr &  scheduler) const
inline

Sets the custom scheduler of Instance.

Parameters
schedulerThe custom scheduler of Instance

◆ setSchedulerWorkerNum()

InstanceBuilderPtr setSchedulerWorkerNum ( daq::SizeT  numWorkers) const
inline

Sets the number of worker threads in the scheduler of the Instance. If Scheduler has been set, configuring of Scheduler worker num has no effect in building Instance.

Parameters
numWorkersThe amount of worker threads in the scheduler of Instance. If is 0, then the amount of workers is the maximum number of concurrent threads supported by the implementation.

◆ setSinkLogLevel()

InstanceBuilderPtr setSinkLogLevel ( const daq::LoggerSinkPtr &  sink,
daq::LogLevel  logLevel 
) const
inline

Sets the sink logger level of the default Instance logger. If Logger has been set, configuring of the Logger sink has no effect in building Instance.

Parameters
sinkThe sink logger of the default Instance logger
logLevelThe sink logger level of the default Instance logger