- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# AlpsEncoded Class Reference

This data structure is to contain the packed form of an encodable knowledge. More...

`#include <AlpsEncoded.h>`

List of all members.

## 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.
void | clear ()
| Completely clear the encoded.
template<class T>
AlpsEncoded & | writeRep (const T &value)
| Write a single object of type `T` in `repsentation_` .
template<class T>
AlpsEncoded & | readRep (T &value)
| Read a single object of type `T` from `repsentation_` .
template<class T>
AlpsEncoded & | writeRep (const T *const values, const int length)
| Write a C style array of objects of type `T` in `repsentation_`.
template<class T>
AlpsEncoded & | readRep (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).
AlpsEncoded & | writeRep (std::string &value)
| Read a `std::string` in `repsentation_` .
AlpsEncoded & | readRep (std::string &value)
| Read a `std::string` from `repsentation_` .
template<class T>
AlpsEncoded & | writeRep (const std::vector< T > &vec)
| Write a `std::vector` into `repsentation_` .
template<class T>
AlpsEncoded & | readRep (std::vector< T > &vec)
| Read a `std::vector` from `repsentation_` .
Constructors and destructor
| AlpsEncoded ()
| The default constructor creates a buffer of size 16 Kbytes with no message in it.
| AlpsEncoded (int t)
| Useful constructor.
| AlpsEncoded (int t, int s, char *&r)
| Useful constructor.
| ~AlpsEncoded ()
| Destructor.
Query methods
int | type () const
int | size () const
const char * | representation () const
## Private Member Functions
| AlpsEncoded (const AlpsEncoded &)
| Disable copy constructor and assignment operator.
AlpsEncoded & | operator= (const AlpsEncoded &)
| Disable copy constructor and assignment operator.
## Private Attributes
size_t | pos_
| The next read/write position in the representation.
size_t | maxSize_
| The amount of memory allocated for the representation.
int | type_
| Represent the type of the object.
int | size_
| The size of the packed representation.
char * | representation_
| The encoded/compressed representation of the object.

## Detailed Description

This data structure is to contain the packed form of an encodable knowledge.

It servers two purposes:

- used as a buffer when passing messages
- allow Alps to manipulate the user derived knowledge

Definition at line 25 of file AlpsEncoded.h.

## Constructor & Destructor Documentation

AlpsEncoded::AlpsEncoded | ( | const AlpsEncoded & |  | ) | `[private]`

Disable copy constructor and assignment operator.

AlpsEncoded::AlpsEncoded | ( |  | ) | `[inline]`

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

Definition at line 65 of file AlpsEncoded.h.

AlpsEncoded::AlpsEncoded | ( | int | t | ) | `[inline]`

Useful constructor.

Definition at line 75 of file AlpsEncoded.h.

AlpsEncoded::AlpsEncoded | ( | int | t,
|  | int | s,
|  | char *& | r |
| ) |  |  | `[inline]`

Useful constructor.

Take over ownership of r.

Definition at line 85 of file AlpsEncoded.h.

AlpsEncoded::~AlpsEncoded | ( |  | ) | `[inline]`

Destructor.

Definition at line 95 of file AlpsEncoded.h.

References representation_.

## Member Function Documentation

AlpsEncoded& AlpsEncoded::operator= | ( | const AlpsEncoded & |  | ) | `[private]`

Disable copy constructor and assignment operator.

int AlpsEncoded::type | ( |  | ) | const`[inline]`

Definition at line 105 of file AlpsEncoded.h.

References type_.

int AlpsEncoded::size | ( |  | ) | const`[inline]`

Definition at line 106 of file AlpsEncoded.h.

References size_.

Referenced by setPosition(), and writeRep().

const char* AlpsEncoded::representation | ( |  | ) | const`[inline]`

Definition at line 107 of file AlpsEncoded.h.

References representation_.

void AlpsEncoded::setPosition | ( | const int | pos | ) | `[inline]`

Definition at line 110 of file AlpsEncoded.h.

References pos_, and size().

void AlpsEncoded::setRepresentation | ( | char *& | buf | ) | `[inline]`

Definition at line 120 of file AlpsEncoded.h.

References maxSize_, and representation_.

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 130 of file AlpsEncoded.h.

References maxSize_, representation_, and size_.

Referenced by writeRep().

void AlpsEncoded::clear | ( |  | ) | `[inline]`

Completely clear the encoded.

Delete and zero out `type_, size_, pos_`.

Definition at line 146 of file AlpsEncoded.h.

References pos_, representation_, size_, and type_.

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 163 of file AlpsEncoded.h.

References make_fit(), representation_, and size_.

Referenced by AlpsParams::pack(), KnapParams::pack(), and AbcParams::pack().

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 173 of file AlpsEncoded.h.

References pos_, representation_, and size_.

Referenced by readRep(), AlpsParams::unpack(), KnapParams::unpack(), and AbcParams::unpack().

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 189 of file AlpsEncoded.h.

References make_fit(), representation_, and size_.

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 214 of file AlpsEncoded.h.

References pos_, representation_, and size_.

AlpsEncoded& AlpsEncoded::writeRep | ( | std::string & | value | ) | `[inline]`

Read a `std::string` in `repsentation_` .

Definition at line 279 of file AlpsEncoded.h.

References make_fit(), representation_, and size_.

AlpsEncoded& AlpsEncoded::readRep | ( | std::string & | value | ) | `[inline]`

Read a `std::string` from `repsentation_` .

Definition at line 293 of file AlpsEncoded.h.

References pos_, readRep(), and representation_.

template<class T>

AlpsEncoded& AlpsEncoded::writeRep | ( | const std::vector< T > & | vec | ) | `[inline]`

Write a `std::vector` into `repsentation_` .

Definition at line 302 of file AlpsEncoded.h.

References make_fit(), representation_, size(), and size_.

template<class T>

AlpsEncoded& AlpsEncoded::readRep | ( | std::vector< T > & | vec | ) | `[inline]`

Read a `std::vector` from `repsentation_` .

Definition at line 316 of file AlpsEncoded.h.

References pos_, representation_, and size_.

## Member Data Documentation

size_t AlpsEncoded::pos_`[private]`

The next read/write position in the representation.

Definition at line 38 of file AlpsEncoded.h.

Referenced by clear(), readRep(), and setPosition().

size_t AlpsEncoded::maxSize_`[private]`

The amount of memory allocated for the representation.

Definition at line 41 of file AlpsEncoded.h.

Referenced by make_fit(), and setRepresentation().

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 49 of file AlpsEncoded.h.

Referenced by clear(), and type().

int AlpsEncoded::size_`[private]`

The size of the packed representation.

Definition at line 52 of file AlpsEncoded.h.

Referenced by clear(), make_fit(), readRep(), size(), and writeRep().

char* AlpsEncoded::representation_`[private]`

The encoded/compressed representation of the object.

Definition at line 56 of file AlpsEncoded.h.

Referenced by clear(), make_fit(), readRep(), representation(), setRepresentation(), writeRep(), and ~AlpsEncoded().

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

- /home/coin/SVN-release/Alps-1.3.0/Alps/src/AlpsEncoded.h