cStringPool Class Reference

For saving memory on the storage of (largely) constant strings that occur in many instances during runtime: module names, gate names, property names, keys and values, etc. More...

#include <cstringpool.h>

List of all members.

Public Member Functions

const char * get (const char *s)
const char * peek (const char *s) const
void release (const char *s)
void dump () const

Detailed Description

For saving memory on the storage of (largely) constant strings that occur in many instances during runtime: module names, gate names, property names, keys and values, etc.

These strings can be stored in a cStringPool as one shared instance. Strings in the cStringPool are reference counted. (See Flyweight GoF pattern.)


Member Function Documentation

const char* cStringPool::get ( const char *  s  ) 

Returns pointer to the pooled copy of the given string, and increments its reference count.

get() and release() must occur in pairs. Passing NULL is OK.

const char* cStringPool::peek ( const char *  s  )  const

Returns pointer to the pooled copy of the given string, or NULL.

Reference count is not incremented. Passing NULL is OK.

void cStringPool::release ( const char *  s  ) 

The parameter must a pointer returned by get().

It decrements the reference count and frees the pooled string if it reaches zero. Passing NULL is OK.


The documentation for this class was generated from the following file:
Generated on Tue Dec 2 11:16:30 2014 for OMNeT++ Simulation Library by  doxygen 1.6.3