Caffa  1.1.0
C++ Application Framework for Embedded Systems with introspection
Public Member Functions | List of all members
caffa::Object Class Reference
Inheritance diagram for caffa::Object:
Inheritance graph
[legend]
Collaboration diagram for caffa::Object:
Collaboration graph
[legend]

Public Member Functions

 Object (bool generateUuid=true)
 
template<typename FieldType >
FieldInitHelper< FieldType > initField (FieldType &field, const std::string &keyword)
 
template<typename MethodType , typename CallbackT >
void initMethod (MethodType &method, const std::string &keyword, const std::vector< std::string > &argumentNames, CallbackT &&callback, MethodHandle::Type type=MethodHandle::Type::READ_WRITE)
 
template<typename MethodType , typename CallbackT >
void initMethodWithDoc (MethodType &method, const std::string &keyword, const std::vector< std::string > &argumentNames, const std::string &documentation, CallbackT &&callback, MethodHandle::Type type=MethodHandle::Type::READ_WRITE)
 
std::string uuid () const override
 
void setUuid (const std::string &uuid) override
 
ObjectHandle::Ptr deepClone (caffa::ObjectFactory *optionalObjectFactory=nullptr) const override
 Deep clone the object using an optional object factory. More...
 
template<typename DerivedClass >
std::shared_ptr< DerivedClass > typedDeepClone (caffa::ObjectFactory *optionalObjectFactory=nullptr) const
 Deep clone and cast to the typed class using an optional object factory. More...
 
bool readFromJsonFile (const std::string &filePath)
 Read the object content from JSON file. More...
 
bool writeToJsonFile (const std::string &filePath) const
 Write the object content to a JSON file. More...
 
- Public Member Functions inherited from caffa::ObjectHandle
virtual std::string classKeyword () const
 
virtual InheritanceStackType classInheritanceStack () const
 
virtual std::string classDocumentation () const
 
std::list< FieldHandle * > fields () const
 
std::list< MethodHandle * > methods () const
 
FieldHandlefindField (const std::string &keyword) const
 
MethodHandlefindMethod (const std::string &keyword) const
 
void addCapability (std::unique_ptr< ObjectCapability > capability)
 
template<typename CapabilityType >
CapabilityType * capability () const
 
virtual void initAfterRead ()
 
void disconnectObserverFromAllSignals (SignalObserver *observer)
 
void accept (Inspector *visitor) const
 
void accept (Editor *visitor)
 
- Public Member Functions inherited from caffa::SignalObserver
std::list< AbstractSignal * > observedSignals () const
 
void addObservedSignal (AbstractSignal *signalToAdd) const
 
void removeObservedSignal (AbstractSignal *signalToRemove) const noexcept
 
- Public Member Functions inherited from caffa::SignalEmitter
void addEmittedSignal (AbstractSignal *signalToAdd) const
 
std::list< AbstractSignal * > emittedSignals () const
 

Additional Inherited Members

- Public Types inherited from caffa::ObjectHandle
using InheritanceStackType = std::vector< std::string >
 
using Ptr = std::shared_ptr< ObjectHandle >
 
using ConstPtr = std::shared_ptr< const ObjectHandle >
 
- Static Public Member Functions inherited from caffa::ObjectHandle
static std::string classKeywordStatic ()
 
static bool matchesClassKeyword (const std::string &classKeyword, const InheritanceStackType &inheritanceStack)
 
static constexpr bool isValidCharacter (char c)
 
static constexpr bool isValidKeyword (const std::string_view &type)
 
- Protected Member Functions inherited from caffa::ObjectHandle
void addField (FieldHandle *field, const std::string &keyword)
 
void addMethod (MethodHandle *method, const std::string &keyword, MethodHandle::Type type)
 

Member Function Documentation

◆ deepClone()

ObjectHandle::Ptr Object::deepClone ( caffa::ObjectFactory optionalObjectFactory = nullptr) const
overridevirtual

Deep clone the object using an optional object factory.

Parameters
optionalObjectFactoryif null the default object factory will be used
Returns
std::shared_ptr<Object>

Implements caffa::ObjectHandle.

◆ initField()

template<typename FieldType >
FieldInitHelper<FieldType> caffa::Object::initField ( FieldType &  field,
const std::string &  keyword 
)
inline

Initialises the field with a keyword and registers it with the class

Parameters
fieldA reference to the field
keywordThe field keyword. Has to be unique within the class.

◆ initMethod()

template<typename MethodType , typename CallbackT >
void caffa::Object::initMethod ( MethodType &  method,
const std::string &  keyword,
const std::vector< std::string > &  argumentNames,
CallbackT &&  callback,
MethodHandle::Type  type = MethodHandle::Type::READ_WRITE 
)
inline

Initialises the method with a keyword and registers it with the class

Parameters
methodA reference to the method
keywordThe method keyword. Has to be unique within the class.
argumentNamesA vector of argument names
callbackThe method that will be called locally
typeWhether it is a READ_WRITE or a READ_ONLY (const) type method

◆ initMethodWithDoc()

template<typename MethodType , typename CallbackT >
void caffa::Object::initMethodWithDoc ( MethodType &  method,
const std::string &  keyword,
const std::vector< std::string > &  argumentNames,
const std::string &  documentation,
CallbackT &&  callback,
MethodHandle::Type  type = MethodHandle::Type::READ_WRITE 
)
inline

Initialises the method with a keyword and registers it with the class

Parameters
methodA reference to the method
keywordThe method keyword. Has to be unique within the class.
argumentNamesA vector of argument names
documentationA documentation string
callbackThe method that will be called locally
typeWhether it is a READ_WRITE or a READ_ONLY (const) type method

◆ readFromJsonFile()

bool Object::readFromJsonFile ( const std::string &  filePath)

Read the object content from JSON file.

Parameters
filePathThe file path to read from
Returns
true if ok, false if not

◆ typedDeepClone()

template<typename DerivedClass >
std::shared_ptr<DerivedClass> caffa::Object::typedDeepClone ( caffa::ObjectFactory optionalObjectFactory = nullptr) const
inline

Deep clone and cast to the typed class using an optional object factory.

Template Parameters
DerivedClass
Parameters
optionalObjectFactoryif null the default object factory will be used
Returns
std::shared_ptr<DerivedClass>

◆ writeToJsonFile()

bool Object::writeToJsonFile ( const std::string &  filePath) const

Write the object content to a JSON file.

Parameters
filePathThe file path to write to
Returns
true if ok, false if not

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