NAP
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | List of all members
ParameterService Class Reference

#include <parameterservice.h>

Public Types

using PresetFileList = std::vector< std::string >
 

Public Member Functions

 ParameterService (ServiceConfiguration *configuration)
 
PresetFileList getPresets (const ParameterGroup &group) const
 
bool loadPreset (ParameterGroup &group, const std::string &presetFile, utility::ErrorState &errorState)
 
bool savePreset (ParameterGroup &group, const std::string &presetFile, utility::ErrorState &errorState)
 
std::string getPresetPath (const std::string &groupID, const std::string &filename) const
 
std::string getGroupPresetDirectory (const std::string &groupID) const
 
- Public Member Functions inherited from Service
UNPREFIXED_MODULE_NAME_INPUTCASE Service (ServiceConfiguration *configuration)
 
virtual void getDependentServices (std::vector< rtti::TypeInfo > &dependencies) override
 
virtual bool init (nap::utility::ErrorState &errorState) override
 
virtual void update (double deltaTime) override
 
virtual void shutdown () override
 
 Service (ServiceConfiguration *configuration)
 
virtual ~Service ()
 
CoregetCore ()
 
const CoregetCore () const
 
std::string getTypeName () const
 
const ModulegetModule () const
 
 Service (Service &)=delete
 
Serviceoperator= (const Service &)=delete
 
 Service (Service &&)=delete
 
Serviceoperator= (Service &&)=delete
 

Public Attributes

nap::Signal presetLoaded
 
nap::Signal fileLoaded
 

Protected Member Functions

virtual void postResourcesLoaded () override
 
- Protected Member Functions inherited from Service
virtual void registerObjectCreators (rtti::Factory &factory)
 
virtual void getDependentServices (std::vector< rtti::TypeInfo > &dependencies)
 
virtual void created ()
 
virtual bool init (utility::ErrorState &error)
 
virtual void preUpdate (double deltaTime)
 
virtual void update (double deltaTime)
 
virtual void postUpdate (double deltaTime)
 
virtual void preShutdown ()
 
virtual void shutdown ()
 
virtual void preResourcesLoaded ()
 
template<typename SERVICE_CONFIG >
SERVICE_CONFIG * getConfiguration ()
 
template<typename SERVICE_CONFIG >
const SERVICE_CONFIG * getConfiguration () const
 
std::string getIniFilePath () const
 
std::string getIniFilePath (const std::string &appendix) const
 

Description

The ParameterService manages the Parameters for a project. It provides support for loading/saving presets of Parameters

Inheritance diagram for ParameterService:
[legend]
Collaboration diagram for ParameterService:
[legend]

Member Typedef Documentation

◆ PresetFileList

using PresetFileList = std::vector<std::string>

Constructor & Destructor Documentation

◆ ParameterService()

ParameterService ( ServiceConfiguration configuration)

Member Function Documentation

◆ getGroupPresetDirectory()

std::string getGroupPresetDirectory ( const std::string &  groupID) const

Get the directory that presets for the specified group are stored in

Parameters
groupIDThe group id
Returns
The directory that presets for the specified group are stored in

◆ getPresetPath()

std::string getPresetPath ( const std::string &  groupID,
const std::string &  filename 
) const

Get the full path to the preset file

Parameters
groupIDThe group id
filenameThe preset file to get the full path of
Returns
Full path to the preset file

◆ getPresets()

PresetFileList getPresets ( const ParameterGroup group) const

Get a list of all available preset files for the specified group.

Returns
The list of presets

◆ loadPreset()

bool loadPreset ( ParameterGroup group,
const std::string &  presetFile,
utility::ErrorState errorState 
)

Load a preset from the specified file. The parameters in the Preset will be automatically applied. The list of available presets files can be retrieved through getPresets()

Parameters
groupthe parameter group.
presetFileThe path to the the preset file to load
errorStateDetailed error information when load fails
Returns
Whether the load of the preset failed or succeeded

◆ postResourcesLoaded()

virtual void postResourcesLoaded ( )
overrideprotectedvirtual

Called when a json file has been (re)loaded. Used to re-apply the presets.

Reimplemented from Service.

◆ savePreset()

bool savePreset ( ParameterGroup group,
const std::string &  presetFile,
utility::ErrorState errorState 
)

Save the current set of parameters/values to the specified file as a preset.

Parameters
groupthe parameter group.
presetFileThe path to save to
errorStateDetailed error information when save fails
Returns
Whether the save of the preset failed or succeeded

Member Data Documentation

◆ fileLoaded

nap::Signal fileLoaded

Signal that is emitted when a file reload occurs

◆ presetLoaded

nap::Signal presetLoaded

Signal that is emitted when a preset is loaded