PhoenixSwarm  3.5.0
Library to ease communication between daemons
Loading...
Searching...
No Matches
phoenix_createData_impl.h File Reference
#include "phoenix_type_stream.h"
#include "phoenix_assert.h"
#include "phoenix_createData.h"
+ Include dependency graph for phoenix_createData_impl.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<typename T>
Data phoenix_createData (const T &value)
 Create a Data from a value.
 
template<typename T>
phoenix_getValueFromData (const Data &data)
 Get the value in the Data.
 

Function Documentation

◆ phoenix_createData()

template<typename T>
Data phoenix_createData ( const T & value)

Create a Data from a value.

Parameters
value: value to set the Data
Returns
corresponding Data

Definition at line 20 of file phoenix_createData_impl.h.

20 {
21 Data param;
22 param.setType(phoenix_getTypeToStr<T>());
23 param.getValue().resize(data_size(value));
24 DataStreamIter iter = (DataStreamIter)param.getValue().data();
25 phoenix_assert(data_message_save(iter, value));
26 return param;
27}
Basic Data exchanged in the swarm.
void setType(const PString &type)
Sets the type of the Data.
const DataStreamMsg & getValue() const
Gets the value of the Data.

References Data::getValue(), and Data::setType().

Referenced by phoenix_function_call(), and Daemon< _TBackend >::sendValue().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ phoenix_getValueFromData()

template<typename T>
T phoenix_getValueFromData ( const Data & data)

Get the value in the Data.

Parameters
data: data to be used
Returns
corresponding value of the data

Definition at line 34 of file phoenix_createData_impl.h.

34 {
35 phoenix_assert(data.getType() == phoenix_getTypeToStr<T>());
36 DataStreamIter resIter = (DataStreamIter)data.getValue().data();
37 T resValue;
38 phoenix_assert(data_message_load(resIter, resValue));
39 return resValue;
40}
const PString & getType() const
Gets the type of the Data.

References Data::getType(), and Data::getValue().

Referenced by DataFunctionCall< _Data >::call(), and DataFunctionClassCall< _Class, _Data >::call().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: