|
| Codec (const Type type, const bool scramble=true) |
|
const Variable * | attach (const char *name, std::string &value) noexcept(false) |
|
const Variable * | attach (const char *name, const char *&value) noexcept(false) |
|
const Variable * | attach (const char *name, int &value) noexcept(false) |
|
const Variable * | attach (const char *name, S64 &value) noexcept(false) |
|
const Variable * | attach (const char *name, bool &value) noexcept(false) |
|
const Variable * | attach (const char *name, DataBlock &value) noexcept(false) |
|
const Variable * | attach (const char *name, float &value) noexcept(false) |
|
const Variable * | attach (const char *name, double &value) noexcept(false) |
|
const Variable * | attach (const char *name, Second &value) noexcept(false) |
|
const Variable * | attach (const char *name, Millisecond &value) noexcept(false) |
|
const Variable * | attach (const char *name, Microsecond &value) noexcept(false) |
|
| CompatCodec (const Type type, const bool scramble=true) |
|
virtual | ~CompatCodec () |
|
Type | getType () const |
|
const Variable * | attach (const char *name, const short int id, std::string &value) noexcept(false) |
|
const Variable * | attach (const char *name, const short int id, const char *&value) noexcept(false) |
|
const Variable * | attach (const char *name, const short int id, int &value) noexcept(false) |
|
const Variable * | attach (const char *name, const short int id, S64 &value) noexcept(false) |
|
const Variable * | attach (const char *name, const short int id, bool &value) noexcept(false) |
|
const Variable * | attach (const char *name, const short int id, DataBlock &value) noexcept(false) |
|
const Variable * | attach (const char *name, const short int id, float &value) noexcept(false) |
|
const Variable * | attach (const char *name, const short int id, double &value) noexcept(false) |
|
const Variable * | attach (const char *name, const short int id, Second &value) noexcept(false) |
|
const Variable * | attach (const char *name, const short int id, Millisecond &value) noexcept(false) |
|
const Variable * | attach (const char *name, const short int id, Microsecond &value) noexcept(false) |
|
const Variable * | attach (const char *name, const short int id, comm::CompatCodec &value) noexcept(false) |
|
const Variable & | find (const short int id) const noexcept(false) |
|
void | setNull (const short int id, const bool isNull=true) noexcept(false) |
|
void | setNull (const Variable *variable, const bool isNull=true) |
|
bool | isNull (const short int id) const noexcept(false) |
|
iterator | begin () |
|
const_iterator | begin () const |
|
iterator | end () |
|
const_iterator | end () const |
|
int | size () const |
|
virtual const DataBlock & | code () noexcept(false) |
|
virtual void | decode (const DataBlock &dataBlock) noexcept(false) |
|
| Message () |
|
virtual | ~Message () |
|
const DataBlock & | getBody () const |
|
Message * | setBody (const DataBlock &body) noexcept(false) |
|
Message * | setBody (const char *buffer, const int size) noexcept(false) |
|
virtual Message * | setBody (const xml::Node *node) noexcept(false) |
|
void | clearBody () |
|
| DataBlock (const bool deepCopy=false) |
|
| DataBlock (const char *buffer, const int size, const bool deepCopy=false) noexcept(false) |
|
| DataBlock (const DataBlock &other) noexcept(false) |
|
virtual | ~DataBlock () |
|
int | getMaxSize () const |
|
int | getSize () const |
|
const char * | getData () const |
|
bool | isEmpty () const |
|
bool | deepCopy () const |
|
void | setSize (const int size) noexcept(false) |
|
DataBlock & | operator+= (const char c) noexcept(false) |
|
DataBlock & | operator+= (const DataBlock &right) noexcept(false) |
|
DataBlock & | operator+= (const std::string &str) noexcept(false) |
|
const char | operator[] (const int pos) const noexcept(false) |
|
char & | operator[] (const int pos) noexcept(false) |
|
void | append (const char *data, const int len) noexcept(false) |
|
void | append (const DataBlock &other) noexcept(false) |
|
void | assign (const DataBlock &right) noexcept(false) |
|
void | assign (const char *buffer, const int size) noexcept(false) |
|
DataBlock & | operator= (const DataBlock &right) noexcept(false) |
|
DataBlock & | operator= (const char c) noexcept(false) |
|
DataBlock & | operator= (const std::string &str) noexcept(false) |
|
void | allocate (const int nbytes) noexcept(false) |
|
void | clear () noexcept(false) |
|
void | remove (const int pos, const int nbytes) noexcept(false) |
|
void | remove (const int nbytes) noexcept(false) |
|
std::string | asString (const int characterByLine=24) const |
|
Codificador/Decodificador compatible para transporte de datos
Esta clase ofrece una forma muy eficaz para codificar estructuras de datos complejas y pretende sustituir los tipicos aplanadores y desaplanadores ya que permite que cualquier proceso defina facilmente la forma de transferir cierta informacion sobre un bloque de memoria y viceversa.
Vamos a ver un ejemplo de uso. Primero vamos a definir la clase MensajeDemo:
#include <anna.comm.Codec.h>
class MensajeDemo :
public Codec {
public:
MensajeDemo () :
Codec (type),
a_dataBlock (true)
{
attach (
"Bloque datos", a_dataBlock);
}
const int obtenerEntero () const { return a_entero; }
const std::string& obtenerCadena () const { return a_cadena; }
const DataBlock& obtenerDataBlock ()
const {
return a_dataBlock; }
void establecerEntero (const int entero) { a_entero = entero; }
void establecerCadena (const std::string& cadena) { a_cadena = cadena; }
void establecerCadena (const char* cadena) { a_cadena = cadena; }
void establecerDataBlock (
const DataBlock& dataBlock) { a_dataBlock = dataBlock; }
private:
int a_entero;
std::string a_cadena;
};
La clase que use esta clase para enviar un mensaje debe establecer los valores de cada uno de los datos mediante los modificadores definidos y luego invocar al metodo code que transferiria el contenido de las variables asociadas a este mensaje a un bloque de memoria, que normalmente seriausado como mensaje.
Por otra parte la clase que recibe el mensaje invocar�al metodo decode que transfiere el contenido del bloque de memoria a cada una de las variables asociadas al mensaje. Posteriormente, podremos acceder al contenido de cada una de las variables asociadas al mensaje atraves de los accesores definidos para el caso.
Estos codificadores nos dan la posibilidad de definir variables opcionales, de forma que una determinada variable puede no ser transferida al bloque de memoria, y por tanto puede no ser recibida en el otro extremo. Ver el metodo isNull y setNull para mas informacion.
- Warning
- Esta clase no establece proteccion ante accesos concurrentes