SOIL C++
C++ Unified Device Interface
SOIL::Figure< T, x, y > Class Template Referenceabstract

Intermediate class for Variable and Parameter that derives from Element. More...

#include <Figure.h>

Inheritance diagram for SOIL::Figure< T, x, y >:
SOIL::Element HTTP::Resource

Public Member Functions

 Figure (std::shared_ptr< Element > parent, std::string uuid, std::string name, std::string description, std::string unit, std::string ontology="", Range< T > range=Range< T >(), TIME time=TIME())
 Constructor. More...
 
 ~Figure ()
 Destructor. More...
 
Figure< T, x, y > & operator= (const Container< T, x, y > &value)
 Assignment operator. More...
 
Container< T, x, y > & operator* (void)
 Access Operator. More...
 
bool check_range (const Container< T, x, y > &value) const
 Check range. More...
 
void set_range (Range< T > range)
 Set Range. More...
 
void set_time (TIME time)
 Set Time. More...
 
void set_value (const Container< T, x, y > &value)
 Set Value. More...
 
HTTP::Json wjson (void) override
 HTTP JSON. More...
 
Container< T, x, y > cast (T value)
 Cast to container. More...
 
virtual void update (const Container< T, x, y > &value, TIME time)
 Update. More...
 
- Public Member Functions inherited from SOIL::Element
 Element (std::shared_ptr< Element > parent, std::string uuid, std::string name, std::string description, std::string ontology="")
 Constructor. More...
 
virtual ~Element ()
 Destructor. More...
 
std::vector< std::string > fqid (void)
 FQID. More...
 
std::shared_ptr< Elementoperator[] (std::string fqid)
 Access Operator. More...
 
std::shared_ptr< Elementadd (std::string uuid, std::shared_ptr< Element > child)
 Add Child Element. More...
 
std::shared_ptr< Elementadd (std::string uuid, Element *child)
 Add Child Element. More...
 
bool insert (std::string uuid, std::shared_ptr< Element > child)
 Add Child Element. More...
 
bool insert (std::string uuid, Element *child)
 Add Child Element. More...
 
bool remove (std::string uuid)
 Remove Child element. More...
 
template<typename T >
T * cast (void)
 Get dynamically casted pointer. More...
 
bool is_object (void) const
 Is Object? More...
 
bool is_variable (void) const
 Is Variable? More...
 
bool is_function (void) const
 Is Function? More...
 
bool is_parameter (void) const
 Is Parameter? More...
 
virtual HTTP::Json wjson (void)
 HTTP JSON. More...
 
virtual std::string json (void)
 JSON string. More...
 
HTTP::Response handle (HTTP::Request request, std::smatch match=std::smatch())
 HTTP Handler. More...
 
- Public Member Functions inherited from HTTP::Resource
 Resource ()
 Constructor. More...
 
 ~Resource ()
 Default Destructor. More...
 
virtual Response handle (Request message, std::smatch match=std::smatch())
 HTTP Handler. More...
 
virtual Response handle_get (Request message, std::smatch match=std::smatch())
 HTTP GET Handler. More...
 
virtual Response handle_put (Request message, std::smatch match=std::smatch())
 HTTP PUT Handler. More...
 
virtual Response handle_post (Request message, std::smatch match=std::smatch())
 HTTP POST Handler. More...
 
virtual Response handle_delete (Request message, std::smatch match=std::smatch())
 HTTP DELETE Handler. More...
 
virtual Response handle_patch (Request message, std::smatch match=std::smatch())
 HTTP PATCH Handler. More...
 
virtual Response handle_options (Request message, std::smatch match=std::smatch())
 HTTP OPTIONS Handler. More...
 
virtual Response handle_head (Request message, std::smatch match=std::smatch())
 HTTP HEAD Handler. More...
 
virtual Response handle_exception (Request message, std::exception &exception, std::smatch match=std::smatch())
 HTTP Exception handler. More...
 

Protected Member Functions

virtual void read (void)=0
 Read callback. More...
 
virtual void write (void)=0
 Write callback. More...
 
- Protected Member Functions inherited from HTTP::Resource
void apply_headers (Response &response)
 Apply headers. More...
 

Protected Attributes

TIME time
 Data Timestamp. More...
 
std::string unit
 Unit. More...
 
Container< T, x, y > value
 Value. More...
 
Range< T > range
 Range. More...
 
- Protected Attributes inherited from HTTP::Resource
std::vector< web::http::method > allowed_methods
 Allowed methods. More...
 
std::string content_type
 Content type. More...
 
std::string allowed_origins
 Allowed Origins. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from HTTP::Resource
static web::json::value request_info (Request message, std::smatch match=std::smatch())
 Request Info. More...
 
- Public Attributes inherited from SOIL::Element
std::map< std::string, std::shared_ptr< Element > > children
 Children Map. More...
 
std::shared_ptr< Elementparent
 Parent Pointer. More...
 
std::shared_ptr< Elementself
 Self Pointer. More...
 
std::string uuid
 Local UUID. More...
 
std::string name
 Name. More...
 
std::string description
 Description. More...
 
std::string ontology
 Ontology identifier. More...
 
std::recursive_mutex mutex
 Element Mutex. More...
 

Detailed Description

template<typename T, int x = -1, int y = -1>
class SOIL::Figure< T, x, y >

Intermediate class for Variable and Parameter that derives from Element as both share many properties. This class should not be instantianted directly and is abstract. The underlying data management completely relies on the templated Container class, henace many templates are passed on.

Template Parameters
TType of the data.
xFirst dimension of the data. -1 means unused, 0 means arbitray size. Cannot be -1 if y is not -1.
ySecond dimension of the data. -1 means unused, 0 means arbitray size. Must be -1 for x to be -1.

Definition at line 48 of file Figure.h.

Constructor & Destructor Documentation

◆ Figure()

template<typename T , int x, int y>
SOIL::Figure< T, x, y >::Figure ( std::shared_ptr< Element parent,
std::string  uuid,
std::string  name,
std::string  description,
std::string  unit,
std::string  ontology = "",
Range< T >  range = Range<T>(),
SOIL::TIME  time = TIME() 
)

Standard constructor intialiazing the values which should be called from the constructor of deriving classes.

Parameters
[in]parentShared pointer to parent object.
[in]uuidLocally Unique identifier
[in]nameHuman-readable name
[in]descriptionHuman-readable description
[in]unitUNECE unit code, e.g. MTR
[in]ontologyOntology reference, is set to null if an empty string is passed
range[in] Allowed range for the variable values, defaults to an empty object, i.e. allowing all values
time[in] Timestamp for the initial value, defaults to unset

Definition at line 218 of file Figure.h.

◆ ~Figure()

template<typename T , int x, int y>
SOIL::Figure< T, x, y >::~Figure

Default destructor, without custom effort.

Definition at line 223 of file Figure.h.

Member Function Documentation

◆ cast()

template<typename T , int x, int y>
SOIL::Container< T, x, y > SOIL::Figure< T, x, y >::cast ( value)

Takes a value and returns the corresponding container

Parameters
[in]valueValue to containerize
Returns
Container version
Todo:
This function seems error prone in the multidimensional case.

Definition at line 248 of file Figure.h.

◆ check_range()

template<typename T , int x, int y>
bool SOIL::Figure< T, x, y >::check_range ( const Container< T, x, y > &  value) const

Check if value expressed as container object matches the range specified for this Figure. This may be useful prior to assignment to avoid exceptions.

Parameters
[in]valueValue to check
Returns
True if the value(s) is (are) in range, false else.

Definition at line 278 of file Figure.h.

◆ operator*()

template<typename T , int x, int y>
SOIL::Container< T, x, y > & SOIL::Figure< T, x, y >::operator* ( void  )

Access Operator returning the container of the value.

Returns
Value container.

Definition at line 271 of file Figure.h.

◆ operator=()

template<typename T , int x, int y>
SOIL::Figure< T, x, y > & SOIL::Figure< T, x, y >::operator= ( const Container< T, x, y > &  value)

Assigns the value provided as container on the right hand side to the figure.

Exceptions
std::range_errorThrows an exception if the value to assign is outside the allowed range.
Parameters
[in]valueValue to assign
Returns
Reference to the current Figure

Definition at line 259 of file Figure.h.

◆ read()

template<typename T , int x, int y>
void SOIL::Figure< T, x, y >::read ( void  )
protectedpure virtual

Read callback that can be implemented by deriving classes to perform custom build logic on read actions, e.g. update the value from an external storage. Declared virtual to make sure the derived method is called first.

Implemented in SOIL::Parameter< T, x, y >, and SOIL::Variable< T, x, y >.

Definition at line 254 of file Figure.h.

◆ set_range()

template<typename T , int x, int y>
void SOIL::Figure< T, x, y >::set_range ( Range< T >  range)

Set the range property of this figure.

Parameters
[in]rangeRange to set

Definition at line 284 of file Figure.h.

◆ set_time()

template<typename T , int x, int y>
void SOIL::Figure< T, x, y >::set_time ( TIME  time)

Set the time property of this figure.

Parameters
[in]timeTime to set

Definition at line 291 of file Figure.h.

◆ set_value()

template<typename T , int x, int y>
void SOIL::Figure< T, x, y >::set_value ( const Container< T, x, y > &  value)

Assigns the value provided as container. This is currently equivalent to the assignment operator.

Exceptions
std::range_errorThrows an exception if the value to assign is outside the allowed range.
Parameters
[in]valueValue to assign

Definition at line 298 of file Figure.h.

◆ update()

template<typename T , int x, int y>
void SOIL::Figure< T, x, y >::update ( const Container< T, x, y > &  value,
TIME  time 
)
virtual

Update the figure setting a new value and timestamp. This is common scenario when dealing with measurement data.

Parameters
[in]valueValue to set
[in]timeTimestamp to assign

Definition at line 308 of file Figure.h.

◆ wjson()

template<typename T , int x, int y>
HTTP::Json SOIL::Figure< T, x, y >::wjson ( void  )
overridevirtual

Get a HTTP JSON object corresponding to the current state of the Figure. This function provides a partial representation of the SOIL-conformant JSON representation of Variable and Parameter and may be called from their wjson() methods.

Returns
JSON object

Reimplemented from SOIL::Element.

Definition at line 229 of file Figure.h.

◆ write()

template<typename T , int x = -1, int y = -1>
virtual void SOIL::Figure< T, x, y >::write ( void  )
protectedpure virtual

Write callback that can be implemented by deriving classes to perform custom build logic on write actions, e.g.set a value to an external system. Declared virtual to make sure the derived method is called first.

Implemented in SOIL::Parameter< T, x, y >, and SOIL::Variable< T, x, y >.

Member Data Documentation

◆ range

template<typename T , int x = -1, int y = -1>
Range<T> SOIL::Figure< T, x, y >::range
protected

Allowed range for the figure, expressed using the therefore designed Range class.

Definition at line 77 of file Figure.h.

◆ time

template<typename T , int x = -1, int y = -1>
TIME SOIL::Figure< T, x, y >::time
protected

Timestamp of the data, i.e. the time which should be considered as physically related to the value.

Definition at line 56 of file Figure.h.

◆ unit

template<typename T , int x = -1, int y = -1>
std::string SOIL::Figure< T, x, y >::unit
protected

Unit of the stored value, expressed as UNECE code (e.g. MTR).

Definition at line 63 of file Figure.h.

◆ value

template<typename T , int x = -1, int y = -1>
Container<T, x, y> SOIL::Figure< T, x, y >::value
protected

Actual value that is currently held by the figure, which is represented as conatiner.

Definition at line 70 of file Figure.h.


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