Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members

# CIAO::Object_Set< T, T_var > Class Template Reference

A helper template class for maintaining and managing a set of object reference. More...

`#include <Object_Set_T.h>`

Inheritance diagram for CIAO::Object_Set< T, T_var >:

[legend]
Collaboration diagram for CIAO::Object_Set< T, T_var >:

[legend]
List of all members.

## Public Methods

| Object_Set (CORBA::ULong init_capacity=10, CORBA::ULong step=10)
| ~Object_Set (void)
| Default destructor.
CORBA::Long | add (T *objref)
CORBA::Long | remove (T *objref)
| Removing an object from the set. Return -1 if error occurred.
T_var & | at (CORBA::ULong index)
CORBA::ULong | copy (CORBA::ULong size, T **buffer)
int | object_in_set (T *objref)
CORBA::ULong | size (void) const
| Query the current size the set contains.
CORBA::ULong | capacity (void) const
| Query the current capacity the set.
void | release (void)

## Protected Methods

void | grow (void)
| Grow the internal array holding the object references.

## Protected Attributes

T_var * | buffer_
CORBA::ULong | capacity_
| Maximun capacity of this->buffer_;.
CORBA::ULong | size_
| Current size in the set.
CORBA::ULong | step_

## Detailed Description

### template<class T, class T_var>
class CIAO::Object_Set< T, T_var >

A helper template class for maintaining and managing a set of object reference.

This class provides a naive implementation of an object reference set. It is naive because it simply keeps object references in an objref_var array without checking for duplication. More importantly, it takes O(n) to to look for an object reference and return it. What we really need is a thread-safe hash_set<> like class here. Since this is mostly used only during setup/assemble time for a CIAO application, i.e., not on critical path, this class serves as a place holder for later, more efficient implementation.

## Constructor & Destructor Documentation

template<class T, class T_var>
CIAO::Object_Set< T, T_var >::Object_Set | ( | CORBA::ULong | init_capacity = 10,
|  | CORBA::ULong | step = 10
| ) |

| Default contructor that also allows initializing the initial capacity of the set and the increment step.

template<class T, class T_var>
CIAO::Object_Set< T, T_var >::~Object_Set | ( | void |  | ) |

| Default destructor.

## Member Function Documentation

template<class T, class T_var>
CORBA::Long CIAO::Object_Set< T, T_var >::add | ( | T * | objref | ) |

| Adding a new object reference to the set. Return -1 if error occurred.

template<class T, class T_var>
ACE_INLINE T_var & CIAO::Object_Set< T, T_var >::at | ( | CORBA::ULong | index | ) |

| Access the underlying T_var array directly. This is added to get around a bug in TAO's sequence of object C++ mapping.

template<class T, class T_var>
ACE_INLINE CORBA::ULong CIAO::Object_Set< T, T_var >::capacity | ( | void |  | ) | const

| Query the current capacity the set.

template<class T, class T_var>
CORBA::ULong CIAO::Object_Set< T, T_var >::copy | ( | CORBA::ULong | size,
|  | T ** | buffer
| ) |

Get a copy of the object reference set into the incoming array `buffer` with capacity of `size`. `buffer` is usually allocated using a sequence's `allocbuf` method. Notice that caller is responsible to release the object references in buffer.

Return values:

  actual | number of objrefs copied into `buffer`.

template<class T, class T_var>
void CIAO::Object_Set< T, T_var >::grow | ( | void |  | ) | `[protected]`

| Grow the internal array holding the object references.

template<class T, class T_var>
int CIAO::Object_Set< T, T_var >::object_in_set | ( | T * | objref | ) |

| Check if an object is in the set. Return 0 if false.

template<class T, class T_var>
void CIAO::Object_Set< T, T_var >::release | ( | void |  | ) |

| Release all object references.

template<class T, class T_var>
CORBA::Long CIAO::Object_Set< T, T_var >::remove | ( | T * | objref | ) |

| Removing an object from the set. Return -1 if error occurred.

template<class T, class T_var>
ACE_INLINE CORBA::ULong CIAO::Object_Set< T, T_var >::size | ( | void |  | ) | const

| Query the current size the set contains.

## Member Data Documentation

template<class T, class T_var>
T_var* CIAO::Object_Set< T, T_var >::buffer_`[protected]`

| Pointer to the dynamically allocated buffer that holds the object references.

template<class T, class T_var>
CORBA::ULong CIAO::Object_Set< T, T_var >::capacity_`[protected]`

| Maximun capacity of this->buffer_;.

template<class T, class T_var>
CORBA::ULong CIAO::Object_Set< T, T_var >::size_`[protected]`

| Current size in the set.

template<class T, class T_var>
CORBA::ULong CIAO::Object_Set< T, T_var >::step_`[protected]`

| How many more slots to add each time we expand the capacity of this set.

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

- Object_Set_T.h
- Object_Set_T.cpp
- Object_Set_T.inl