PTLib Version 2.12.9

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

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Macros
contain.h File Reference
`#include <ptlib/object.h>`
`#include <ptlib/critsec.h>`
`#include <ptlib/array.h>`
`#include <ptlib/lists.h>`
`#include <ptlib/dict.h>`
`#include <ptlib/pstring.h>`
Include dependency graph for contain.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Classes
class | PContainerReference
class | PContainer
| Abstract class to embody the base functionality of a `container`. More...
class | PCollection
| A collection is a container that collects together descendents of the `PObject` class. More...

## Macros
#define | PCONTAINERINFO(cls, par)
| Macro to declare funtions required in a container. More...

## Macro Definition Documentation

#define PCONTAINERINFO | ( |  | cls,
|  |  | par
| ) |  |

Value:
PCLASSINFO(cls, par) \
public: \
cls(const cls & c) : par(c) { CopyContents(c); } \
cls & operator=(const cls & c) \
{ AssignContents(c); return *this; } \
virtual ~cls() { Destruct(); } \
virtual PBoolean MakeUnique() \
{ if(par::MakeUnique())return true; CloneContents(this);return false; } \
protected: \
cls(int dummy, const cls * c) : par(dummy, c) { CloneContents(c); } \
virtual void DestroyContents(); \
void CloneContents(const cls * c); \
void CopyContents(const cls & c); \
virtual void AssignContents(const PContainer & c) \
{ par::AssignContents(c); CopyContents((const cls &)c); }

Macro to declare funtions required in a container.

This macro is used to declare all the functions that should be implemented for a working container class. It will also define some inline code for some standard function behaviour.

This may be used when multiple inheritance requires a special class declaration. Normally, the `PCONTAINERINFO` macro would be used, which includes this macro in it.

The default implementation for contructors, destructor, the assignment operator and the MakeUnique() function is as follows:

            cls(const cls & c)
              : par(c)
            {
              CopyContents(c);
            }

            cls & operator=(const cls & c)
            {
              par::operator=(c);
              return *this;
            }

            cls(int dummy, const cls * c)
              : par(dummy, c)
            {
              CloneContents(c);
            }

            virtual ~cls()
            {
              Destruct();
            }

            PBoolean MakeUnique()
            {
              if (par::MakeUnique())
                return true;
              CloneContents(c);
              return false;
            }

Then the `DestroyContents()`, `CloneContents()` and `CopyContents()` functions are declared and must be implemented by the programmer. See the `PContainer` class for more information on these functions.