PhoenixSwarm  3.5.0
Library to ease communication between daemons
Loading...
Searching...
No Matches
phoenix_createData_impl.h
Go to the documentation of this file.
1/***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5****************************************/
6
7#ifndef __PHOENIX_CREATEDATA_IMPL_H__
8#define __PHOENIX_CREATEDATA_IMPL_H__
9
10#include "phoenix_type_stream.h"
11#include "phoenix_assert.h"
12
13#include "phoenix_createData.h"
14
16
19template<typename T>
20Data phoenix_createData(const T & value){
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}
28
30
33template<typename T>
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}
41
42
43#endif
44
Basic Data exchanged in the swarm.
void setType(const PString &type)
Sets the type of the Data.
const PString & getType() const
Gets the type of the Data.
const DataStreamMsg & getValue() const
Gets the value of the Data.
T phoenix_getValueFromData(const Data &data)
Get the value in the Data.
Data phoenix_createData(const T &value)
Create a Data from a value.