lintel 0.2.0
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
lintel::PropertyService Class Reference

#include <PropertyService.h>

Inheritance diagram for lintel::PropertyService:
lintel::PersistableBean

Public Member Functions

 PropertyService (const std::vector< std::shared_ptr< PropertyRepository > > &propertyRepositories, std::vector< std::shared_ptr< AbstractServiceInterface > > abstractServices)
 
virtual ~PropertyService ()=default
 
void onAwake () override
 
void getOrCreate (const std::vector< std::shared_ptr< PropertyBase > > &propertiesVec)
 
template<class T >
std::shared_ptr< Property< T > > getOrCreate (const std::string &name, const std::string &instanceName, const std::string &className, const std::string &processName, const std::string &description, bool runtimeChange, const T &defaultValue=T())
 
std::shared_ptr< PropertyBase > & get (const std::string &name, const std::string &instanceName, const std::string &className, const std::string &processName)
 
std::vector< std::shared_ptr< PropertyBase > > allOf ()
 
std::vector< std::shared_ptr< PropertyBase > > allOf (const std::string &processName)
 
std::vector< std::shared_ptr< PropertyBase > > allOf (const std::string &processName, const std::string &className)
 
std::vector< std::shared_ptr< PropertyBase > > allOf (const std::string &processName, const std::string &className, const std::string &instanceName)
 
template<class T >
void changeValueOf (const std::shared_ptr< PropertyBase > &property, const T &value)
 
void changeStringValueOf (const std::shared_ptr< PropertyBase > &property, const std::string &value)
 
void setPropertyChangeBus (const std::shared_ptr< IEventBus > &bus, const std::string &subscriberName)
 
std::size_t applyChangeNotifications ()
 
std::map< PropertyRepositoryType, std::shared_ptr< PropertyRepository > > buildMap (const std::vector< std::shared_ptr< PropertyRepository > > &vector)
 

Static Public Attributes

static constexpr std::string_view PROPERTY_CHANGES_TOPIC = "property_changes"
 
static constexpr std::string_view PROPERTY_CHANGES_TYPE = "property_change"
 

Detailed Description

Central service for managing, querying and persisting properties

Constructor & Destructor Documentation

◆ PropertyService()

lintel::PropertyService::PropertyService ( const std::vector< std::shared_ptr< PropertyRepository > > &  propertyRepositories,
std::vector< std::shared_ptr< AbstractServiceInterface > >  abstractServices 
)
Parameters
propertyRepositorieslist of all property repositories
abstractServiceslist of services to notify on property changes

◆ ~PropertyService()

virtual lintel::PropertyService::~PropertyService ( )
virtualdefault

Member Function Documentation

◆ allOf() [1/4]

std::vector< std::shared_ptr< PropertyBase > > lintel::PropertyService::allOf ( )
Returns
all properties

◆ allOf() [2/4]

std::vector< std::shared_ptr< PropertyBase > > lintel::PropertyService::allOf ( const std::string &  processName)
Returns
properties matching the given process name

◆ allOf() [3/4]

std::vector< std::shared_ptr< PropertyBase > > lintel::PropertyService::allOf ( const std::string &  processName,
const std::string &  className 
)
Returns
properties matching process name and class name

◆ allOf() [4/4]

std::vector< std::shared_ptr< PropertyBase > > lintel::PropertyService::allOf ( const std::string &  processName,
const std::string &  className,
const std::string &  instanceName 
)
Returns
properties matching process, class, and instance name

◆ applyChangeNotifications()

std::size_t lintel::PropertyService::applyChangeNotifications ( )

Drain pending change notifications and apply them to local properties.

Returns
the number of applied changes

◆ buildMap()

std::map< PropertyRepositoryType, std::shared_ptr< PropertyRepository > > lintel::PropertyService::buildMap ( const std::vector< std::shared_ptr< PropertyRepository > > &  vector)

Build repository type-to-instance map

◆ changeStringValueOf()

void lintel::PropertyService::changeStringValueOf ( const std::shared_ptr< PropertyBase > &  property,
const std::string &  value 
)

Change the value of a property from string representation

◆ changeValueOf()

template<class T >
void lintel::PropertyService::changeValueOf ( const std::shared_ptr< PropertyBase > &  property,
const T &  value 
)

Change the value of a property at runtime

Exceptions
PropertyNoRuntimeChangeSupportedif property does not allow it

◆ get()

std::shared_ptr< PropertyBase > & lintel::PropertyService::get ( const std::string &  name,
const std::string &  instanceName,
const std::string &  className,
const std::string &  processName 
)

Get a property by its coordinates

Exceptions
PropertyNotFoundExceptionif not found

◆ getOrCreate() [1/2]

template<class T >
std::shared_ptr< Property< T > > lintel::PropertyService::getOrCreate ( const std::string &  name,
const std::string &  instanceName,
const std::string &  className,
const std::string &  processName,
const std::string &  description,
bool  runtimeChange,
const T &  defaultValue = T() 
)

Get or create a typed property

Template Parameters
Tproperty value type
Parameters
nameproperty name
instanceNameinstance name
classNameclass name
processNameprocess name
descriptionproperty description
runtimeChangewhether runtime changes are supported
defaultValuedefault value if property does not exist
Returns
the property

◆ getOrCreate() [2/2]

void lintel::PropertyService::getOrCreate ( const std::vector< std::shared_ptr< PropertyBase > > &  propertiesVec)
inline

Match properties from vector against existing map

◆ onAwake()

void lintel::PropertyService::onAwake ( )
overridevirtual

Called when the bean should reload or refresh its state from persistent storage.

Implements lintel::PersistableBean.

◆ setPropertyChangeBus()

void lintel::PropertyService::setPropertyChangeBus ( const std::shared_ptr< IEventBus > &  bus,
const std::string &  subscriberName 
)

Connect the change notification bus and subscribe for property changes.

Parameters
busthe event bus view used for notifications
subscriberNamea name unique to this process

Member Data Documentation

◆ PROPERTY_CHANGES_TOPIC

constexpr std::string_view lintel::PropertyService::PROPERTY_CHANGES_TOPIC = "property_changes"
staticconstexpr

Event bus topic carrying property change notifications.

◆ PROPERTY_CHANGES_TYPE

constexpr std::string_view lintel::PropertyService::PROPERTY_CHANGES_TYPE = "property_change"
staticconstexpr

Event type of property change notifications.


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