openDAQ
Open data acquisition platform
IInstanceBuilder Struct Referenceabstract

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

+ Inheritance diagram for IInstanceBuilder:
+ Collaboration diagram for 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

virtual ErrCode INTERFACE_FUNC build (IInstance **instance)=0
 Builds and returns an Instance object using the currently set values of the Builder. More...
 
virtual ErrCode INTERFACE_FUNC addConfigProvider (IConfigProvider *configProvider)=0
 Populates internal options dictionary with values from set config provider. More...
 
virtual ErrCode INTERFACE_FUNC setContext (IContext *context)=0
 Sets the Context object of the instance. This overwrites other context related settings such as logger, scheduler and module manager settings. More...
 
virtual ErrCode INTERFACE_FUNC getContext (IContext **context)=0
 Returns a context object of the instance. More...
 
virtual ErrCode INTERFACE_FUNC setLogger (ILogger *logger)=0
 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...
 
virtual ErrCode INTERFACE_FUNC getLogger (ILogger **logger)=0
 Gets the Logger of the Instance. Returns nullptr if custom logger has not been set. More...
 
virtual ErrCode INTERFACE_FUNC setGlobalLogLevel (LogLevel logLevel)=0
 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...
 
virtual ErrCode INTERFACE_FUNC getGlobalLogLevel (LogLevel *logLevel)=0
 Gets the default Logger global level of Instance. More...
 
virtual ErrCode INTERFACE_FUNC setComponentLogLevel (IString *component, LogLevel logLevel)=0
 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...
 
virtual ErrCode INTERFACE_FUNC getComponentsLogLevel (IDict **components)=0
 Gets the dictionary of component names and log level which will be added to logger components. More...
 
virtual ErrCode INTERFACE_FUNC addLoggerSink (ILoggerSink *sink)=0
 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...
 
virtual ErrCode INTERFACE_FUNC setSinkLogLevel (ILoggerSink *sink, LogLevel logLevel)=0
 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...
 
virtual ErrCode INTERFACE_FUNC getLoggerSinks (IList **sinks)=0
 Gets the list of logger sinks for the default Instance logger. More...
 
virtual ErrCode INTERFACE_FUNC setModulePath (IString *path)=0
 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...
 
virtual ErrCode INTERFACE_FUNC getModulePath (IString **path)=0
 Gets the path for the default ModuleManager of Instance. More...
 
virtual ErrCode INTERFACE_FUNC addModulePath (IString *path)=0
 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...
 
virtual ErrCode INTERFACE_FUNC getModulePathsList (IList **paths)=0
 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...
 
virtual ErrCode INTERFACE_FUNC setModuleManager (IModuleManager *moduleManager)=0
 Sets The custom ModuleManager for the Instance. More...
 
virtual ErrCode INTERFACE_FUNC getModuleManager (IModuleManager **moduleManager)=0
 Gets the custom ModuleManager of Instance. More...
 
virtual ErrCode INTERFACE_FUNC setAuthenticationProvider (IAuthenticationProvider *authenticationProvider)=0
 Sets the AuthenticationProvider for the Instance. More...
 
virtual ErrCode INTERFACE_FUNC getAuthenticationProvider (IAuthenticationProvider **authenticationProvider)=0
 Gets the AuthenticationProvider of Instance. More...
 
virtual ErrCode INTERFACE_FUNC setSchedulerWorkerNum (SizeT numWorkers)=0
 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...
 
virtual ErrCode INTERFACE_FUNC getSchedulerWorkerNum (SizeT *numWorkers)=0
 Gets the amount of worker threads in the scheduler of Instance. More...
 
virtual ErrCode INTERFACE_FUNC setScheduler (IScheduler *scheduler)=0
 Sets the custom scheduler of Instance. More...
 
virtual ErrCode INTERFACE_FUNC getScheduler (IScheduler **scheduler)=0
 Gets the custom scheduler of Instance. More...
 
virtual ErrCode INTERFACE_FUNC setDefaultRootDeviceLocalId (IString *localId)=0
 Sets the local id for default device. Has no effect if Root device has been congigured. More...
 
virtual ErrCode INTERFACE_FUNC getDefaultRootDeviceLocalId (IString **localId)=0
 Gets the default root device local id. More...
 
virtual ErrCode INTERFACE_FUNC setRootDevice (IString *connectionString, IPropertyObject *config=nullptr)=0
 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...
 
virtual ErrCode INTERFACE_FUNC getRootDevice (IString **connectionString)=0
 Gets the connection string for the default root device of Instance. More...
 
virtual ErrCode INTERFACE_FUNC getRootDeviceConfig (IPropertyObject **config)=0
 Gets the configuration property object for the default root device of Instance. More...
 
virtual ErrCode INTERFACE_FUNC setDefaultRootDeviceInfo (IDeviceInfo *deviceInfo)=0
 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...
 
virtual ErrCode INTERFACE_FUNC getDefaultRootDeviceInfo (IDeviceInfo **deviceInfo)=0
 Gets the default device info of Instance. More...
 
virtual ErrCode INTERFACE_FUNC getOptions (IDict **options)=0
 Gets the dictionary of instance options. More...
 
virtual ErrCode INTERFACE_FUNC enableStandardProviders (Bool flag)=0
 Allows enabling or disabling standard configuration providers, including JsonConfigProvider, based on the specified flag. More...
 
virtual ErrCode INTERFACE_FUNC getDiscoveryServers (IList **serverNames)=0
 Gets the dictionary of discovery servers. More...
 
virtual ErrCode INTERFACE_FUNC addDiscoveryServer (IString *serverName)=0
 Adds a discovery server to the context. More...
 
- Public Member Functions inherited from IBaseObject
virtual ErrCode INTERFACE_FUNC borrowInterface (const IntfID &intfID, void **obj) const =0
 Returns another interface which is supported by the object without incrementing the reference count. More...
 
virtual ErrCode INTERFACE_FUNC dispose ()=0
 Disposes all references held by the object. More...
 
virtual ErrCode INTERFACE_FUNC getHashCode (SizeT *hashCode)=0
 Returns hash code of the object. More...
 
virtual ErrCode INTERFACE_FUNC equals (IBaseObject *other, Bool *equal) const =0
 Compares object to another object for equality. More...
 
virtual ErrCode INTERFACE_FUNC toString (CharPtr *str)=0
 Returns a string representation of the object. More...
 
- Public Member Functions inherited from IUnknown
virtual ErrCode INTERFACE_FUNC queryInterface (const IntfID &intfID, void **obj)=0
 Returns another interface which is supported by the object and increments the reference count. More...
 
virtual int INTERFACE_FUNC addRef ()=0
 Increments the reference count for an interface on an object. More...
 
virtual int INTERFACE_FUNC releaseRef ()=0
 Decrements the reference count for an interface on an object. More...
 

Member Function Documentation

◆ addConfigProvider()

virtual ErrCode INTERFACE_FUNC addConfigProvider ( IConfigProvider configProvider)
pure virtual

Populates internal options dictionary with values from set config provider.

Parameters
configProviderThe configuration provider

◆ addDiscoveryServer()

virtual ErrCode INTERFACE_FUNC addDiscoveryServer ( IString serverName)
pure virtual

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()

virtual ErrCode INTERFACE_FUNC addLoggerSink ( ILoggerSink sink)
pure virtual

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()

virtual ErrCode INTERFACE_FUNC addModulePath ( IString path)
pure virtual

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()

virtual ErrCode INTERFACE_FUNC build ( IInstance **  instance)
pure virtual

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

Parameters
[out]instanceThe built Instance.

◆ enableStandardProviders()

virtual ErrCode INTERFACE_FUNC enableStandardProviders ( Bool  flag)
pure virtual

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()

virtual ErrCode INTERFACE_FUNC getAuthenticationProvider ( IAuthenticationProvider **  authenticationProvider)
pure virtual

Gets the AuthenticationProvider of Instance.

Parameters
[out]authenticationProviderThe AuthenticationProvider of Instance.

◆ getComponentsLogLevel()

virtual ErrCode INTERFACE_FUNC getComponentsLogLevel ( IDict **  components)
pure virtual

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

Parameters
[out]componentsThe dictionary of component names and log level

◆ getContext()

virtual ErrCode INTERFACE_FUNC getContext ( IContext **  context)
pure virtual

Returns a context object of the instance.

Parameters
[out]contextThe Context object of the instance.

◆ getDefaultRootDeviceInfo()

virtual ErrCode INTERFACE_FUNC getDefaultRootDeviceInfo ( IDeviceInfo **  deviceInfo)
pure virtual

Gets the default device info of Instance.

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

◆ getDefaultRootDeviceLocalId()

virtual ErrCode INTERFACE_FUNC getDefaultRootDeviceLocalId ( IString **  localId)
pure virtual

Gets the default root device local id.

Parameters
[out]localIdThe default root device local id. Returns empty string id default root device local is has not been set.

◆ getDiscoveryServers()

virtual ErrCode INTERFACE_FUNC getDiscoveryServers ( IList **  serverNames)
pure virtual

Gets the dictionary of discovery servers.

Parameters
[out]serverNamesThe dictionary of discovery server names

◆ getGlobalLogLevel()

virtual ErrCode INTERFACE_FUNC getGlobalLogLevel ( LogLevel logLevel)
pure virtual

Gets the default Logger global level of Instance.

Parameters
[out]logLevelThe Logger global level of Instance. Returns LogLevel::Default, If global log level has not been set

◆ getLogger()

virtual ErrCode INTERFACE_FUNC getLogger ( ILogger **  logger)
pure virtual

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

Parameters
[out]loggerThe Logger of Instance

◆ getLoggerSinks()

virtual ErrCode INTERFACE_FUNC getLoggerSinks ( IList **  sinks)
pure virtual

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

Parameters
[out]sinksThe list of logger sinks of the default Instance logger

◆ getModuleManager()

virtual ErrCode INTERFACE_FUNC getModuleManager ( IModuleManager **  moduleManager)
pure virtual

Gets the custom ModuleManager of Instance.

Parameters
[out]moduleManagerThe ModuleManager of Instance. Returns nullptr, if custom ModuleManager has not been set

◆ getModulePath()

virtual ErrCode INTERFACE_FUNC getModulePath ( IString **  path)
pure virtual

Gets the path for the default ModuleManager of Instance.

Parameters
[out]pathThe path for the default ModuleManager of Instance. Returns empty string, If module path has not been set

◆ getModulePathsList()

virtual ErrCode INTERFACE_FUNC getModulePathsList ( IList **  paths)
pure virtual

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.

Parameters
pathsThe paths for the default ModuleManager of Instance

◆ getOptions()

virtual ErrCode INTERFACE_FUNC getOptions ( IDict **  options)
pure virtual

Gets the dictionary of instance options.

Parameters
[out]optionsThe dictionary of instance options

◆ getRootDevice()

virtual ErrCode INTERFACE_FUNC getRootDevice ( IString **  connectionString)
pure virtual

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

Parameters
[out]connectionStringThe connection string for the root device of Instance. Returns nullptr, if root device connection string has not been set.

◆ getRootDeviceConfig()

virtual ErrCode INTERFACE_FUNC getRootDeviceConfig ( IPropertyObject **  config)
pure virtual

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

Parameters
[out]configThe configuraton property object for the root device of Instance. Returns nullptr, for the default configuration property object.

◆ getScheduler()

virtual ErrCode INTERFACE_FUNC getScheduler ( IScheduler **  scheduler)
pure virtual

Gets the custom scheduler of Instance.

Parameters
[out]schedulerThe custom scheduler of Instance. Returns nullptr, if custom Scheduler has not been set.

◆ getSchedulerWorkerNum()

virtual ErrCode INTERFACE_FUNC getSchedulerWorkerNum ( SizeT *  numWorkers)
pure virtual

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

Parameters
[out]numWorkersThe amount of worker threads in the scheduler of Instance. Returns 0, if worker num has not been set

◆ setAuthenticationProvider()

virtual ErrCode INTERFACE_FUNC setAuthenticationProvider ( IAuthenticationProvider authenticationProvider)
pure virtual

Sets the AuthenticationProvider for the Instance.

Parameters
authenticationProviderThe AuthenticationProvider for the Instance

◆ setComponentLogLevel()

virtual ErrCode INTERFACE_FUNC setComponentLogLevel ( IString component,
LogLevel  logLevel 
)
pure virtual

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()

virtual ErrCode INTERFACE_FUNC setContext ( IContext context)
pure virtual

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()

virtual ErrCode INTERFACE_FUNC setDefaultRootDeviceInfo ( IDeviceInfo deviceInfo)
pure virtual

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()

virtual ErrCode INTERFACE_FUNC setDefaultRootDeviceLocalId ( IString localId)
pure virtual

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

Parameters
localIdThe default root device local id

◆ setGlobalLogLevel()

virtual ErrCode INTERFACE_FUNC setGlobalLogLevel ( LogLevel  logLevel)
pure virtual

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()

virtual ErrCode INTERFACE_FUNC setLogger ( ILogger logger)
pure virtual

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()

virtual ErrCode INTERFACE_FUNC setModuleManager ( IModuleManager moduleManager)
pure virtual

Sets The custom ModuleManager for the Instance.

Parameters
moduleManagerThe custom ModuleManager of Instance

◆ setModulePath()

virtual ErrCode INTERFACE_FUNC setModulePath ( IString path)
pure virtual

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()

virtual ErrCode INTERFACE_FUNC setRootDevice ( IString connectionString,
IPropertyObject config = nullptr 
)
pure virtual

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()

virtual ErrCode INTERFACE_FUNC setScheduler ( IScheduler scheduler)
pure virtual

Sets the custom scheduler of Instance.

Parameters
schedulerThe custom scheduler of Instance

◆ setSchedulerWorkerNum()

virtual ErrCode INTERFACE_FUNC setSchedulerWorkerNum ( SizeT  numWorkers)
pure virtual

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()

virtual ErrCode INTERFACE_FUNC setSinkLogLevel ( ILoggerSink sink,
LogLevel  logLevel 
)
pure virtual

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