Alps  2.0.2
Public Member Functions | Private Attributes | List of all members
AlpsEncoded Class Reference

#include <AlpsEncoded.h>

Public Member Functions

void setPosition (const int pos)
 
void setRepresentation (char *&buf)
 
void make_fit (const int addSize)
 Reallocate the size of encoded if necessary so that at least addsize_ number of additional bytes will fit into the encoded. More...
 
void clear ()
 Completely clear the encoded. More...
 
template<class T >
AlpsEncodedwriteRep (const T &value)
 Write a single object of type T in repsentation_ . More...
 
template<class T >
AlpsEncodedreadRep (T &value)
 Read a single object of type T from repsentation_ . More...
 
template<class T >
AlpsEncodedwriteRep (const T *const values, const int length)
 Write a C style array of objects of type T in repsentation_. More...
 
template<class T >
AlpsEncodedreadRep (T *&values, int &length, bool needAllocateMemory=true)
 Read an array of objects of type T from repsentation_, where T must be a built-in type (ar at least something that can be copied with memcpy). More...
 
AlpsEncodedwriteRep (std::string &value)
 Read a std::string in repsentation_ . More...
 
AlpsEncodedreadRep (std::string &value)
 Read a std::string from repsentation_ . More...
 
template<class T >
AlpsEncodedwriteRep (const std::vector< T > &vec)
 Write a std::vector into repsentation_ . More...
 
template<class T >
AlpsEncodedreadRep (std::vector< T > &vec)
 Read a std::vector from repsentation_ . More...
 
Constructors and destructor
 AlpsEncoded ()
 The default constructor creates a buffer of size 16 Kbytes with no message in it. More...
 
 AlpsEncoded (int t)
 Useful constructor. More...
 
 AlpsEncoded (int t, int s, char *&r)
 Useful constructor. More...
 
 ~AlpsEncoded ()
 Destructor. More...
 
Query methods
int type () const
 
int size () const
 
const char * representation () const
 

Private Member Functions

 AlpsEncoded (const AlpsEncoded &)
 Disable copy constructor and assignment operator. More...
 
AlpsEncodedoperator= (const AlpsEncoded &)
 

Private Attributes

size_t pos_
 The next read/write position in the representation. More...
 
size_t maxSize_
 The amount of memory allocated for the representation. More...
 
int type_
 Represent the type of the object. More...
 
int size_
 The size of the packed representation. More...
 
char * representation_
 The encoded/compressed representation of the object. More...
 

Detailed Description

AlpsEncoded

AlpsEncoded is a class for any kind object that is needed to get communicated over the network, ie. (AlpsSolution, AlpsTreeNode, AlpsSubTree, AlpsModel). Objects of this type will be sent/received over the network.

Relationship to #AlpsKnowledge

AlpsKnowledge is a base class for the types that are needed to get comminucated. You can consider AlpsEncoded as the same information in another shape that is suitable to sent/receive over the network.

This data structure is to contain the packed form of an encodable knowledge. It servers two purposes:

Definition at line 64 of file AlpsEncoded.h.

Constructor & Destructor Documentation

◆ AlpsEncoded() [1/4]

AlpsEncoded::AlpsEncoded ( const AlpsEncoded )
private

Disable copy constructor and assignment operator.

◆ AlpsEncoded() [2/4]

AlpsEncoded::AlpsEncoded ( )
inline

The default constructor creates a buffer of size 16 Kbytes with no message in it.

Definition at line 103 of file AlpsEncoded.h.

◆ AlpsEncoded() [3/4]

AlpsEncoded::AlpsEncoded ( int  t)
inline

Useful constructor.

Definition at line 113 of file AlpsEncoded.h.

◆ AlpsEncoded() [4/4]

AlpsEncoded::AlpsEncoded ( int  t,
int  s,
char *&  r 
)
inline

Useful constructor.

Take over ownership of r.

Definition at line 123 of file AlpsEncoded.h.

◆ ~AlpsEncoded()

AlpsEncoded::~AlpsEncoded ( )
inline

Destructor.

Definition at line 133 of file AlpsEncoded.h.

Member Function Documentation

◆ operator=()

AlpsEncoded& AlpsEncoded::operator= ( const AlpsEncoded )
private

◆ type()

int AlpsEncoded::type ( ) const
inline

Definition at line 143 of file AlpsEncoded.h.

◆ size()

int AlpsEncoded::size ( ) const
inline

Definition at line 144 of file AlpsEncoded.h.

◆ representation()

const char* AlpsEncoded::representation ( ) const
inline

Definition at line 145 of file AlpsEncoded.h.

◆ setPosition()

void AlpsEncoded::setPosition ( const int  pos)
inline

Definition at line 148 of file AlpsEncoded.h.

◆ setRepresentation()

void AlpsEncoded::setRepresentation ( char *&  buf)
inline

Definition at line 158 of file AlpsEncoded.h.

◆ make_fit()

void AlpsEncoded::make_fit ( const int  addSize)
inline

Reallocate the size of encoded if necessary so that at least addsize_ number of additional bytes will fit into the encoded.

Definition at line 168 of file AlpsEncoded.h.

◆ clear()

void AlpsEncoded::clear ( )
inline

Completely clear the encoded.

Delete and zero out type_, size_, pos_.

Definition at line 184 of file AlpsEncoded.h.

◆ writeRep() [1/4]

template<class T >
AlpsEncoded& AlpsEncoded::writeRep ( const T &  value)
inline

Write a single object of type T in repsentation_ .

Copies sizeof(T) bytes from the address of the object.

Definition at line 201 of file AlpsEncoded.h.

◆ readRep() [1/4]

template<class T >
AlpsEncoded& AlpsEncoded::readRep ( T &  value)
inline

Read a single object of type T from repsentation_ .

Copies sizeof(T) bytes to the address of the object.

Definition at line 211 of file AlpsEncoded.h.

◆ writeRep() [2/4]

template<class T >
AlpsEncoded& AlpsEncoded::writeRep ( const T *const  values,
const int  length 
)
inline

Write a C style array of objects of type T in repsentation_.

First write the length, then write the content of the array

Definition at line 227 of file AlpsEncoded.h.

◆ readRep() [2/4]

template<class T >
AlpsEncoded& AlpsEncoded::readRep ( T *&  values,
int &  length,
bool  needAllocateMemory = true 
)
inline

Read an array of objects of type T from repsentation_, where T must be a built-in type (ar at least something that can be copied with memcpy).

If the third argument is true then memory is allocated for the array and the array pointer and the length of the array are returned in the arguments.

If the third argument is false then the arriving array's length is compared to length and an exception is thrown if they are not the same. Also, the array passed as the first argument will be filled with the arriving array.

Definition at line 254 of file AlpsEncoded.h.

◆ writeRep() [3/4]

AlpsEncoded& AlpsEncoded::writeRep ( std::string &  value)
inline

Read a std::string in repsentation_ .

Definition at line 319 of file AlpsEncoded.h.

◆ readRep() [3/4]

AlpsEncoded& AlpsEncoded::readRep ( std::string &  value)
inline

Read a std::string from repsentation_ .

Definition at line 333 of file AlpsEncoded.h.

◆ writeRep() [4/4]

template<class T >
AlpsEncoded& AlpsEncoded::writeRep ( const std::vector< T > &  vec)
inline

Write a std::vector into repsentation_ .

Definition at line 342 of file AlpsEncoded.h.

◆ readRep() [4/4]

template<class T >
AlpsEncoded& AlpsEncoded::readRep ( std::vector< T > &  vec)
inline

Read a std::vector from repsentation_ .

Definition at line 356 of file AlpsEncoded.h.

Member Data Documentation

◆ pos_

size_t AlpsEncoded::pos_
private

The next read/write position in the representation.

Definition at line 76 of file AlpsEncoded.h.

◆ maxSize_

size_t AlpsEncoded::maxSize_
private

The amount of memory allocated for the representation.

Definition at line 79 of file AlpsEncoded.h.

◆ type_

int AlpsEncoded::type_
private

Represent the type of the object.

We might use RTTI to point this into the static data of the executable :-) Can only be initialized during constructing. User take care of memory.

Definition at line 87 of file AlpsEncoded.h.

◆ size_

int AlpsEncoded::size_
private

The size of the packed representation.

Definition at line 90 of file AlpsEncoded.h.

◆ representation_

char* AlpsEncoded::representation_
private

The encoded/compressed representation of the object.

Definition at line 94 of file AlpsEncoded.h.


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