| Line |
Branch |
Exec |
Source |
| 1 |
|
|
/*************************************** |
| 2 |
|
|
Auteur : Pierre Aubert |
| 3 |
|
|
Mail : pierre.aubert@lapp.in2p3.fr |
| 4 |
|
|
Licence : CeCILL-C |
| 5 |
|
|
****************************************/ |
| 6 |
|
|
|
| 7 |
|
|
|
| 8 |
|
|
|
| 9 |
|
|
#ifndef __PCOMPOSETYPE_H__ |
| 10 |
|
|
#define __PCOMPOSETYPE_H__ |
| 11 |
|
|
|
| 12 |
|
|
#include <string> |
| 13 |
|
|
#include <vector> |
| 14 |
|
|
#include "phoenix_ptype.h" |
| 15 |
|
|
|
| 16 |
|
|
#include "data_all.h" |
| 17 |
|
|
|
| 18 |
|
|
///@brief Content of a mock event with variable (push / pull) |
| 19 |
|
|
class PComposeType{ |
| 20 |
|
|
public: |
| 21 |
|
|
PComposeType(); |
| 22 |
|
|
PComposeType(const PComposeType & other); |
| 23 |
|
|
virtual ~PComposeType(); |
| 24 |
|
|
PComposeType & operator = (const PComposeType & other); |
| 25 |
|
|
void setType(const PType & type); |
| 26 |
|
|
void setVecType(const std::vector<PComposeType> & vecType); |
| 27 |
|
|
const PType & getType() const; |
| 28 |
|
|
PType & getType(); |
| 29 |
|
|
const std::vector<PComposeType> & getVecType() const; |
| 30 |
|
|
std::vector<PComposeType> & getVecType(); |
| 31 |
|
|
|
| 32 |
|
|
///Load the current PComposeType with a stream |
| 33 |
|
|
/** @param[out] ds : stream to be used |
| 34 |
|
|
* @return true on success, false otherwise |
| 35 |
|
|
*/ |
| 36 |
|
|
template<typename Stream, DataStreamMode::DataStreamMode Mode> |
| 37 |
|
68 |
bool readWriteStream(Stream & ds){ |
| 38 |
|
68 |
bool b(true); |
| 39 |
|
68 |
b &= DataStream<Stream, Mode, PType >::data_stream(ds, p_type); |
| 40 |
|
68 |
b &= DataStream<Stream, Mode, std::vector<PComposeType> >::data_stream(ds, p_vecType); |
| 41 |
|
68 |
return b; |
| 42 |
|
|
} |
| 43 |
|
|
|
| 44 |
|
|
protected: |
| 45 |
|
|
void copyPComposeType(const PComposeType & other); |
| 46 |
|
|
private: |
| 47 |
|
|
void initialisationPComposeType(); |
| 48 |
|
|
///Type of the current data |
| 49 |
|
|
PType p_type; |
| 50 |
|
|
///Vector of sub type |
| 51 |
|
|
std::vector<PComposeType> p_vecType; |
| 52 |
|
|
}; |
| 53 |
|
|
|
| 54 |
|
|
///@brief Generic PComposeType serialisation/deserialisation, load/save and size function |
| 55 |
|
|
template<typename Stream, DataStreamMode::DataStreamMode Mode> |
| 56 |
|
|
struct DataStream<Stream, Mode, PComposeType>{ |
| 57 |
|
|
///Generic function to load/save/serialise/deserialise PComposeType |
| 58 |
|
|
/** @param data : PComposeType to be used |
| 59 |
|
|
* @return true on success, false otherwise |
| 60 |
|
|
*/ |
| 61 |
|
68 |
static bool data_stream(Stream & ds, PComposeType & data){ |
| 62 |
|
68 |
return data.readWriteStream<Stream, Mode>(ds); |
| 63 |
|
|
} |
| 64 |
|
|
}; |
| 65 |
|
|
|
| 66 |
|
|
|
| 67 |
|
|
|
| 68 |
|
|
///@brief Variable with name and type |
| 69 |
|
|
class PComposeVar{ |
| 70 |
|
|
public: |
| 71 |
|
|
PComposeVar(); |
| 72 |
|
|
PComposeVar(const PComposeVar & other); |
| 73 |
|
|
virtual ~PComposeVar(); |
| 74 |
|
|
PComposeVar & operator = (const PComposeVar & other); |
| 75 |
|
|
void setType(const PComposeType & type); |
| 76 |
|
|
void setName(const std::string & name); |
| 77 |
|
|
void setValue(const std::vector<char> & value); |
| 78 |
|
|
const PComposeType & getType() const; |
| 79 |
|
|
PComposeType & getType(); |
| 80 |
|
|
const std::string & getName() const; |
| 81 |
|
|
std::string & getName(); |
| 82 |
|
|
const std::vector<char> & getValue() const; |
| 83 |
|
|
std::vector<char> & getValue(); |
| 84 |
|
|
|
| 85 |
|
|
///Load the current PComposeVar with a stream |
| 86 |
|
|
/** @param[out] ds : stream to be used |
| 87 |
|
|
* @return true on success, false otherwise |
| 88 |
|
|
*/ |
| 89 |
|
|
template<typename Stream, DataStreamMode::DataStreamMode Mode> |
| 90 |
|
|
bool readWriteStream(Stream & ds){ |
| 91 |
|
|
bool b(true); |
| 92 |
|
|
b &= DataStream<Stream, Mode, PComposeType >::data_stream(ds, p_type); |
| 93 |
|
|
b &= DataStream<Stream, Mode, std::string >::data_stream(ds, p_name); |
| 94 |
|
|
b &= DataStream<Stream, Mode, std::vector<char> >::data_stream(ds, p_value); |
| 95 |
|
|
return b; |
| 96 |
|
|
} |
| 97 |
|
|
|
| 98 |
|
|
protected: |
| 99 |
|
|
void copyPComposeVar(const PComposeVar & other); |
| 100 |
|
|
private: |
| 101 |
|
|
void initialisationPComposeVar(); |
| 102 |
|
|
///Type of the variable |
| 103 |
|
|
PComposeType p_type; |
| 104 |
|
|
///Name of the variable |
| 105 |
|
|
std::string p_name; |
| 106 |
|
|
///Value of the variable |
| 107 |
|
|
std::vector<char> p_value; |
| 108 |
|
|
}; |
| 109 |
|
|
|
| 110 |
|
|
///@brief Generic PComposeVar serialisation/deserialisation, load/save and size function |
| 111 |
|
|
template<typename Stream, DataStreamMode::DataStreamMode Mode> |
| 112 |
|
|
struct DataStream<Stream, Mode, PComposeVar>{ |
| 113 |
|
|
///Generic function to load/save/serialise/deserialise PComposeVar |
| 114 |
|
|
/** @param data : PComposeVar to be used |
| 115 |
|
|
* @return true on success, false otherwise |
| 116 |
|
|
*/ |
| 117 |
|
|
static bool data_stream(Stream & ds, PComposeVar & data){ |
| 118 |
|
|
return data.readWriteStream<Stream, Mode>(ds); |
| 119 |
|
|
} |
| 120 |
|
|
}; |
| 121 |
|
|
|
| 122 |
|
|
|
| 123 |
|
|
|
| 124 |
|
|
///@brief Function prototype |
| 125 |
|
|
class PFunctionPrototype{ |
| 126 |
|
|
public: |
| 127 |
|
|
PFunctionPrototype(); |
| 128 |
|
|
PFunctionPrototype(const PFunctionPrototype & other); |
| 129 |
|
|
virtual ~PFunctionPrototype(); |
| 130 |
|
|
PFunctionPrototype & operator = (const PFunctionPrototype & other); |
| 131 |
|
|
void setName(const std::string & name); |
| 132 |
|
|
void setVecReturnType(const std::vector<PComposeType> & vecReturnType); |
| 133 |
|
|
void setVecParam(const std::vector<PComposeType> & vecParam); |
| 134 |
|
|
const std::string & getName() const; |
| 135 |
|
|
std::string & getName(); |
| 136 |
|
|
const std::vector<PComposeType> & getVecReturnType() const; |
| 137 |
|
|
std::vector<PComposeType> & getVecReturnType(); |
| 138 |
|
|
const std::vector<PComposeType> & getVecParam() const; |
| 139 |
|
|
std::vector<PComposeType> & getVecParam(); |
| 140 |
|
|
|
| 141 |
|
|
///Load the current PFunctionPrototype with a stream |
| 142 |
|
|
/** @param[out] ds : stream to be used |
| 143 |
|
|
* @return true on success, false otherwise |
| 144 |
|
|
*/ |
| 145 |
|
|
template<typename Stream, DataStreamMode::DataStreamMode Mode> |
| 146 |
|
10 |
bool readWriteStream(Stream & ds){ |
| 147 |
|
10 |
bool b(true); |
| 148 |
|
10 |
b &= DataStream<Stream, Mode, std::string >::data_stream(ds, p_name); |
| 149 |
|
10 |
b &= DataStream<Stream, Mode, std::vector<PComposeType> >::data_stream(ds, p_vecReturnType); |
| 150 |
|
10 |
b &= DataStream<Stream, Mode, std::vector<PComposeType> >::data_stream(ds, p_vecParam); |
| 151 |
|
10 |
return b; |
| 152 |
|
|
} |
| 153 |
|
|
|
| 154 |
|
|
protected: |
| 155 |
|
|
void copyPFunctionPrototype(const PFunctionPrototype & other); |
| 156 |
|
|
private: |
| 157 |
|
|
void initialisationPFunctionPrototype(); |
| 158 |
|
|
///Name of the function |
| 159 |
|
|
std::string p_name; |
| 160 |
|
|
///Vector of return type of the function |
| 161 |
|
|
std::vector<PComposeType> p_vecReturnType; |
| 162 |
|
|
///Vector of parameters of the function |
| 163 |
|
|
std::vector<PComposeType> p_vecParam; |
| 164 |
|
|
}; |
| 165 |
|
|
|
| 166 |
|
|
///@brief Generic PFunctionPrototype serialisation/deserialisation, load/save and size function |
| 167 |
|
|
template<typename Stream, DataStreamMode::DataStreamMode Mode> |
| 168 |
|
|
struct DataStream<Stream, Mode, PFunctionPrototype>{ |
| 169 |
|
|
///Generic function to load/save/serialise/deserialise PFunctionPrototype |
| 170 |
|
|
/** @param data : PFunctionPrototype to be used |
| 171 |
|
|
* @return true on success, false otherwise |
| 172 |
|
|
*/ |
| 173 |
|
5 |
static bool data_stream(Stream & ds, PFunctionPrototype & data){ |
| 174 |
|
5 |
return data.readWriteStream<Stream, Mode>(ds); |
| 175 |
|
|
} |
| 176 |
|
|
}; |
| 177 |
|
|
|
| 178 |
|
|
|
| 179 |
|
|
|
| 180 |
|
|
///@brief Function call |
| 181 |
|
|
class PFunctionCall{ |
| 182 |
|
|
public: |
| 183 |
|
|
PFunctionCall(); |
| 184 |
|
|
PFunctionCall(const PFunctionCall & other); |
| 185 |
|
|
virtual ~PFunctionCall(); |
| 186 |
|
|
PFunctionCall & operator = (const PFunctionCall & other); |
| 187 |
|
|
void setPrototype(const PFunctionPrototype & prototype); |
| 188 |
|
|
void setVecParam(const std::vector<std::vector<char> > & vecParam); |
| 189 |
|
|
void setVecResult(const std::vector<std::vector<char> > & vecResult); |
| 190 |
|
|
const PFunctionPrototype & getPrototype() const; |
| 191 |
|
|
PFunctionPrototype & getPrototype(); |
| 192 |
|
|
const std::vector<std::vector<char> > & getVecParam() const; |
| 193 |
|
|
std::vector<std::vector<char> > & getVecParam(); |
| 194 |
|
|
const std::vector<std::vector<char> > & getVecResult() const; |
| 195 |
|
|
std::vector<std::vector<char> > & getVecResult(); |
| 196 |
|
|
|
| 197 |
|
|
///Load the current PFunctionCall with a stream |
| 198 |
|
|
/** @param[out] ds : stream to be used |
| 199 |
|
|
* @return true on success, false otherwise |
| 200 |
|
|
*/ |
| 201 |
|
|
template<typename Stream, DataStreamMode::DataStreamMode Mode> |
| 202 |
|
|
bool readWriteStream(Stream & ds){ |
| 203 |
|
|
bool b(true); |
| 204 |
|
|
b &= DataStream<Stream, Mode, PFunctionPrototype >::data_stream(ds, p_prototype); |
| 205 |
|
|
b &= DataStream<Stream, Mode, std::vector<std::vector<char> > >::data_stream(ds, p_vecParam); |
| 206 |
|
|
b &= DataStream<Stream, Mode, std::vector<std::vector<char> > >::data_stream(ds, p_vecResult); |
| 207 |
|
|
return b; |
| 208 |
|
|
} |
| 209 |
|
|
|
| 210 |
|
|
protected: |
| 211 |
|
|
void copyPFunctionCall(const PFunctionCall & other); |
| 212 |
|
|
private: |
| 213 |
|
|
void initialisationPFunctionCall(); |
| 214 |
|
|
///Prototype of the function to be called |
| 215 |
|
|
PFunctionPrototype p_prototype; |
| 216 |
|
|
///Vector of serialised parameters to be used to call the function |
| 217 |
|
|
std::vector<std::vector<char> > p_vecParam; |
| 218 |
|
|
///Vector of serialised results after the funtion call |
| 219 |
|
|
std::vector<std::vector<char> > p_vecResult; |
| 220 |
|
|
}; |
| 221 |
|
|
|
| 222 |
|
|
///@brief Generic PFunctionCall serialisation/deserialisation, load/save and size function |
| 223 |
|
|
template<typename Stream, DataStreamMode::DataStreamMode Mode> |
| 224 |
|
|
struct DataStream<Stream, Mode, PFunctionCall>{ |
| 225 |
|
|
///Generic function to load/save/serialise/deserialise PFunctionCall |
| 226 |
|
|
/** @param data : PFunctionCall to be used |
| 227 |
|
|
* @return true on success, false otherwise |
| 228 |
|
|
*/ |
| 229 |
|
|
static bool data_stream(Stream & ds, PFunctionCall & data){ |
| 230 |
|
|
return data.readWriteStream<Stream, Mode>(ds); |
| 231 |
|
|
} |
| 232 |
|
|
}; |
| 233 |
|
|
|
| 234 |
|
|
|
| 235 |
|
|
|
| 236 |
|
|
|
| 237 |
|
|
|
| 238 |
|
|
#endif |
| 239 |
|
|
|
| 240 |
|
|
|