Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions

ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER > Class Template Reference

Defines a map implementation. More...

#include <Map_T.h>

Inheritance diagram for ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >:
Inheritance graph
[legend]
Collaboration diagram for ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >:
Collaboration graph
[legend]

List of all members.

Public Types

typedef ACE_Pair< KEY, VALUE > expanded_value
typedef
ACE_Active_Map_Manager_Iterator_Adapter
< ACE_Reference_Pair< const
KEY, VALUE >, expanded_value
iterator_impl
typedef
ACE_Active_Map_Manager_Reverse_Iterator_Adapter
< ACE_Reference_Pair< const
KEY, VALUE >, expanded_value
reverse_iterator_impl
typedef ACE_Active_Map_Manager
< expanded_value
implementation

Public Member Functions

 ACE_Active_Map_Manager_Adapter (ACE_Allocator *alloc=0)
 Initialize with the ACE_DEFAULT_MAP_SIZE.
 ACE_Active_Map_Manager_Adapter (size_t size, ACE_Allocator *alloc=0)
virtual ~ACE_Active_Map_Manager_Adapter (void)
 Close down and release dynamically allocated resources.
virtual int open (size_t length=ACE_DEFAULT_MAP_SIZE, ACE_Allocator *alloc=0)
 Initialize a <Map> with size length.
virtual int close (void)
 Close down a <Map> and release dynamically allocated resources.
virtual int bind (const KEY &key, const VALUE &value)
virtual int bind_modify_key (const VALUE &value, KEY &key)
virtual int create_key (KEY &key)
virtual int bind_create_key (const VALUE &value, KEY &key)
virtual int bind_create_key (const VALUE &value)
virtual int recover_key (const KEY &modified_key, KEY &original_key)
virtual int rebind (const KEY &key, const VALUE &value)
virtual int rebind (const KEY &key, const VALUE &value, VALUE &old_value)
virtual int rebind (const KEY &key, const VALUE &value, KEY &old_key, VALUE &old_value)
virtual int trybind (const KEY &key, VALUE &value)
virtual int find (const KEY &key, VALUE &value)
 Locate value associated with key.
virtual int find (const KEY &key)
 Is key in the map?
virtual int unbind (const KEY &key)
 Remove key from the map.
virtual int unbind (const KEY &key, VALUE &value)
virtual size_t current_size (void) const
 Return the current size of the map.
virtual size_t total_size (void) const
 Return the total size of the map.
virtual void dump (void) const
 Dump the state of an object.
ACE_Active_Map_Manager
< ACE_Pair< KEY, VALUE > > & 
impl (void)
 Accessor to implementation object.
KEY_ADAPTER & key_adapter (void)
 Accessor to key adapter.

Protected Member Functions

virtual int find (const KEY &key, expanded_value *&internal_value)
 Find helper.
virtual int unbind (const KEY &key, expanded_value *&internal_value)
 Unbind helper.
virtual ACE_Iterator_Impl
< ACE_Reference_Pair< const
KEY, VALUE > > * 
begin_impl (void)
 Return forward iterator.
virtual ACE_Iterator_Impl
< ACE_Reference_Pair< const
KEY, VALUE > > * 
end_impl (void)
virtual
ACE_Reverse_Iterator_Impl
< ACE_Reference_Pair< const
KEY, VALUE > > * 
rbegin_impl (void)
 Return reverse iterator.
virtual
ACE_Reverse_Iterator_Impl
< ACE_Reference_Pair< const
KEY, VALUE > > * 
rend_impl (void)

Protected Attributes

ACE_Active_Map_Manager
< ACE_Pair< KEY, VALUE > > 
implementation_
 All implementation details are forwarded to this class.
KEY_ADAPTER key_adapter_
 Adapts between the user key and the Active_Map_Manager_Key.

Private Member Functions

void operator= (const ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER > &)
 ACE_Active_Map_Manager_Adapter (const ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER > &)

Detailed Description

template<class KEY, class VALUE, class KEY_ADAPTER>
class ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >

Defines a map implementation.

Implementation to be provided by <ACE_Active_Map_Manager>.

Definition at line 828 of file Map_T.h.


Member Typedef Documentation

template<class KEY, class VALUE, class KEY_ADAPTER>
typedef ACE_Pair<KEY, VALUE> ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::expanded_value

Definition at line 834 of file Map_T.h.

template<class KEY, class VALUE, class KEY_ADAPTER>
typedef ACE_Active_Map_Manager<expanded_value> ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::implementation

Definition at line 840 of file Map_T.h.

template<class KEY, class VALUE, class KEY_ADAPTER>
typedef ACE_Active_Map_Manager_Iterator_Adapter<ACE_Reference_Pair<const KEY, VALUE>, expanded_value> ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::iterator_impl

Definition at line 836 of file Map_T.h.

template<class KEY, class VALUE, class KEY_ADAPTER>
typedef ACE_Active_Map_Manager_Reverse_Iterator_Adapter<ACE_Reference_Pair<const KEY, VALUE>, expanded_value> ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::reverse_iterator_impl

Definition at line 838 of file Map_T.h.


Constructor & Destructor Documentation

template<class KEY , class VALUE , class KEY_ADAPTER >
ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::ACE_Active_Map_Manager_Adapter ( ACE_Allocator alloc = 0  )  [inline]

Initialize with the ACE_DEFAULT_MAP_SIZE.

Definition at line 290 of file Map_T.inl.

  : implementation_ (alloc)
{
}

template<class KEY , class VALUE , class KEY_ADAPTER >
ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::ACE_Active_Map_Manager_Adapter ( size_t  size,
ACE_Allocator alloc = 0 
) [inline]

Initialize with size entries. The size parameter is ignored by maps for which an initialize size does not make sense.

Definition at line 296 of file Map_T.inl.

  : implementation_ (size,
                     alloc)
{
}

template<class KEY , class VALUE , class KEY_ADAPTER >
ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::~ACE_Active_Map_Manager_Adapter ( void   )  [virtual]

Close down and release dynamically allocated resources.

Definition at line 406 of file Map_T.cpp.

{
}

template<class KEY, class VALUE, class KEY_ADAPTER>
ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::ACE_Active_Map_Manager_Adapter ( const ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER > &   )  [private]

Member Function Documentation

template<class KEY , class VALUE , class KEY_ADAPTER >
ACE_Iterator_Impl< ACE_Reference_Pair< const KEY, VALUE > > * ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::begin_impl ( void   )  [protected, virtual]

Return forward iterator.

Implements ACE_Map< KEY, VALUE >.

Definition at line 716 of file Map_T.cpp.

template<class KEY , class VALUE , class KEY_ADAPTER >
int ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::bind ( const KEY &  key,
const VALUE &  value 
) [virtual]

Add key / value pair to the map. If key is already in the map then no changes are made and 1 is returned. Returns 0 on a successful addition. This function fails for maps that do not allow user specified keys. key is an "in" parameter.

Implements ACE_Map< KEY, VALUE >.

Definition at line 425 of file Map_T.cpp.

template<class KEY , class VALUE , class KEY_ADAPTER >
int ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::bind_create_key ( const VALUE &  value,
KEY &  key 
) [virtual]

Add value to the map, and the corresponding key produced by the Map is returned through key which is an "out" parameter. For maps that do not naturally produce keys, the map adapters will use the KEY_GENERATOR class to produce a key. However, the users are responsible for not jeopardizing this key production scheme by using user specified keys with keys produced by the key generator.

Implements ACE_Map< KEY, VALUE >.

Definition at line 471 of file Map_T.cpp.

{
  // Reserve a slot and create an active key.
  expanded_value *internal_value = 0;
  ACE_Active_Map_Manager_Key active_key;
  int result = this->implementation_.bind (active_key,
                                           internal_value);
  if (result == 0)
    {
      // Encode the active key into key part of <expanded_value>.
      result = this->key_adapter_.encode (internal_value->first (),
                                          active_key,
                                          internal_value->first ());
      if (result == 0)
        {
          // Copy user value into <expanded_value>.
          internal_value->second (value);
          // Copy new, modified key to the user key.
          key = internal_value->first ();
        }
      else
        {
          // In case of errors, unbind from map.
          this->implementation_.unbind (active_key);
        }
    }

  return result;
}

template<class KEY , class VALUE , class KEY_ADAPTER >
int ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::bind_create_key ( const VALUE &  value  )  [virtual]

Add value to the map. The user does not care about the corresponding key produced by the Map. For maps that do not naturally produce keys, the map adapters will use the KEY_GENERATOR class to produce a key. However, the users are responsible for not jeopardizing this key production scheme by using user specified keys with keys produced by the key generator.

Implements ACE_Map< KEY, VALUE >.

Definition at line 503 of file Map_T.cpp.

{
  // Reserve a slot and create an active key.
  expanded_value *internal_value = 0;
  ACE_Active_Map_Manager_Key active_key;
  int result = this->implementation_.bind (active_key,
                                           internal_value);
  if (result == 0)
    {
      // Encode the active key into key part of <expanded_value>.
      result = this->key_adapter_.encode (internal_value->first (),
                                          active_key,
                                          internal_value->first ());
      if (result == 0)
        {
          // Copy user value into <expanded_value>.
          internal_value->second (value);
        }
      else
        {
          // In case of errors, unbind from map.
          this->implementation_.unbind (active_key);
        }
    }

  return result;
}

template<class KEY , class VALUE , class KEY_ADAPTER >
int ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::bind_modify_key ( const VALUE &  value,
KEY &  key 
) [virtual]

Add key / value pair to the map. key is an "inout" parameter and maybe modified/extended by the map to add additional information. To recover original key, call the <recover_key> method.

Implements ACE_Map< KEY, VALUE >.

Definition at line 432 of file Map_T.cpp.

{
  // Reserve a slot and create an active key.
  expanded_value *internal_value = 0;
  ACE_Active_Map_Manager_Key active_key;
  int result = this->implementation_.bind (active_key,
                                           internal_value);
  if (result == 0)
    {
      // Encode the active key and the existing user key into key part
      // of <expanded_value>.
      result = this->key_adapter_.encode (key,
                                          active_key,
                                          internal_value->first ());
      if (result == 0)
        {
          // Copy user value into <expanded_value>.
          internal_value->second (value);
          // Copy new, modified key back to the user key.
          key = internal_value->first ();
        }
      else
        {
          // In case of errors, unbind from map.
          this->implementation_.unbind (active_key);
        }
    }

  return result;
}

template<class KEY , class VALUE , class KEY_ADAPTER >
int ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::close ( void   )  [virtual]

Close down a <Map> and release dynamically allocated resources.

Implements ACE_Map< KEY, VALUE >.

Definition at line 419 of file Map_T.cpp.

{
  return this->implementation_.close ();
}

template<class KEY , class VALUE , class KEY_ADAPTER >
int ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::create_key ( KEY &  key  )  [virtual]

Produce a key and return it through key which is an "out" parameter. For maps that do not naturally produce keys, the map adapters will use the KEY_GENERATOR class to produce a key. However, the users are responsible for not jeopardizing this key production scheme by using user specified keys with keys produced by the key generator.

Implements ACE_Map< KEY, VALUE >.

Definition at line 465 of file Map_T.cpp.

template<class KEY , class VALUE , class KEY_ADAPTER >
size_t ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::current_size ( void   )  const [virtual]

Return the current size of the map.

Implements ACE_Map< KEY, VALUE >.

Definition at line 696 of file Map_T.cpp.

{
  return this->implementation_.current_size ();
}

template<class KEY , class VALUE , class KEY_ADAPTER >
void ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::dump ( void   )  const [virtual]

Dump the state of an object.

Implements ACE_Map< KEY, VALUE >.

Definition at line 708 of file Map_T.cpp.

{
#if defined (ACE_HAS_DUMP)
  this->implementation_.dump ();
#endif /* ACE_HAS_DUMP */
}

template<class KEY , class VALUE , class KEY_ADAPTER >
ACE_Iterator_Impl< ACE_Reference_Pair< const KEY, VALUE > > * ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::end_impl ( void   )  [protected, virtual]

Implements ACE_Map< KEY, VALUE >.

Definition at line 726 of file Map_T.cpp.

template<class KEY , class VALUE , class KEY_ADAPTER >
int ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::find ( const KEY &  key,
expanded_value *&  internal_value 
) [protected, virtual]

Find helper.

Definition at line 542 of file Map_T.cpp.

{
  // Ask the <key_adapter_> to recover the active key.
  ACE_Active_Map_Manager_Key active_key;
  int result = this->key_adapter_.decode (key,
                                          active_key);
  if (result == 0)
    {
      // Find recovered active key in map.
      result = this->implementation_.find (active_key,
                                           internal_value);
    }

  return result;
}

template<class KEY , class VALUE , class KEY_ADAPTER >
int ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::find ( const KEY &  key,
VALUE &  value 
) [virtual]

Locate value associated with key.

Implements ACE_Map< KEY, VALUE >.

Definition at line 560 of file Map_T.cpp.

{
  expanded_value *internal_value = 0;
  int result = this->find (key,
                           internal_value);

  if (result == 0)
    {
      // Copy value.
      value = internal_value->second ();
    }

  return result;
}

template<class KEY , class VALUE , class KEY_ADAPTER >
int ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::find ( const KEY &  key  )  [virtual]

Is key in the map?

Implements ACE_Map< KEY, VALUE >.

Definition at line 577 of file Map_T.cpp.

{
  expanded_value *internal_value = 0;
  return this->find (key,
                     internal_value);
}

template<class KEY , class VALUE , class KEY_ADAPTER >
ACE_Active_Map_Manager< ACE_Pair< KEY, VALUE > > & ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::impl ( void   )  [inline]

Accessor to implementation object.

Definition at line 304 of file Map_T.inl.

{
  return this->implementation_;
}

template<class KEY , class VALUE , class KEY_ADAPTER >
KEY_ADAPTER & ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::key_adapter ( void   )  [inline]

Accessor to key adapter.

Definition at line 310 of file Map_T.inl.

{
  return this->key_adapter_;
}

template<class KEY , class VALUE , class KEY_ADAPTER >
int ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::open ( size_t  length = ACE_DEFAULT_MAP_SIZE,
ACE_Allocator alloc = 0 
) [virtual]

Initialize a <Map> with size length.

Implements ACE_Map< KEY, VALUE >.

Definition at line 411 of file Map_T.cpp.

{
  return this->implementation_.open (length,
                                     alloc);
}

template<class KEY, class VALUE, class KEY_ADAPTER>
void ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::operator= ( const ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER > &   )  [private]
template<class KEY , class VALUE , class KEY_ADAPTER >
ACE_Reverse_Iterator_Impl< ACE_Reference_Pair< const KEY, VALUE > > * ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::rbegin_impl ( void   )  [protected, virtual]

Return reverse iterator.

Implements ACE_Map< KEY, VALUE >.

Definition at line 736 of file Map_T.cpp.

template<class KEY , class VALUE , class KEY_ADAPTER >
int ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::rebind ( const KEY &  key,
const VALUE &  value,
KEY &  old_key,
VALUE &  old_value 
) [virtual]

Reassociate key with value, storing the old key and value into the "out" parameters old_key and old_value. The function fails if key is not in the map for maps that do not allow user specified keys. However, for maps that allow user specified keys, if the key is not in the map, a new key / value association is created.

Implements ACE_Map< KEY, VALUE >.

Definition at line 623 of file Map_T.cpp.

{
  expanded_value *internal_value = 0;
  int result = this->find (key,
                           internal_value);

  if (result == 0)
    {
      // Copy old key and value.
      old_key = internal_value->first ();
      old_value = internal_value->second ();

      // Reset to new value.
      internal_value->second (value);
    }

  return result;
}

template<class KEY , class VALUE , class KEY_ADAPTER >
int ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::rebind ( const KEY &  key,
const VALUE &  value 
) [virtual]

Reassociate key with value. The function fails if key is not in the map for maps that do not allow user specified keys. However, for maps that allow user specified keys, if the key is not in the map, a new key / value association is created.

Implements ACE_Map< KEY, VALUE >.

Definition at line 585 of file Map_T.cpp.

{
  expanded_value *internal_value = 0;
  int result = this->find (key,
                           internal_value);

  if (result == 0)
    {
      // Reset value.
      internal_value->second (value);
    }

  return result;
}

template<class KEY , class VALUE , class KEY_ADAPTER >
int ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::rebind ( const KEY &  key,
const VALUE &  value,
VALUE &  old_value 
) [virtual]

Reassociate key with value, storing the old value into the "out" parameter old_value. The function fails if key is not in the map for maps that do not allow user specified keys. However, for maps that allow user specified keys, if the key is not in the map, a new key / value association is created.

Implements ACE_Map< KEY, VALUE >.

Definition at line 602 of file Map_T.cpp.

{
  expanded_value *internal_value = 0;
  int result = this->find (key,
                           internal_value);

  if (result == 0)
    {
      // Copy old value.
      old_value = internal_value->second ();

      // Reset to new value.
      internal_value->second (value);
    }

  return result;
}

template<class KEY , class VALUE , class KEY_ADAPTER >
int ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::recover_key ( const KEY &  modified_key,
KEY &  original_key 
) [virtual]

Recovers the original key potentially modified by the map during <bind_modify_key>.

Implements ACE_Map< KEY, VALUE >.

Definition at line 532 of file Map_T.cpp.

{
  // Ask the <key_adapter_> to help out with recovering the original
  // user key, since it was the one that encode it in the first place.
  return this->key_adapter_.decode (modified_key,
                                    original_key);
}

template<class KEY , class VALUE , class KEY_ADAPTER >
ACE_Reverse_Iterator_Impl< ACE_Reference_Pair< const KEY, VALUE > > * ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::rend_impl ( void   )  [protected, virtual]

Implements ACE_Map< KEY, VALUE >.

Definition at line 746 of file Map_T.cpp.

template<class KEY , class VALUE , class KEY_ADAPTER >
size_t ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::total_size ( void   )  const [virtual]

Return the total size of the map.

Implements ACE_Map< KEY, VALUE >.

Definition at line 702 of file Map_T.cpp.

{
  return this->implementation_.total_size ();
}

template<class KEY , class VALUE , class KEY_ADAPTER >
int ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::trybind ( const KEY &  key,
VALUE &  value 
) [virtual]

Associate key with value if and only if key is not in the map. If key is already in the map, then the value parameter is overwritten with the existing value in the map. Returns 0 if a new key / value association is created. Returns 1 if an attempt is made to bind an existing entry. This function fails for maps that do not allow user specified keys.

Implements ACE_Map< KEY, VALUE >.

Definition at line 646 of file Map_T.cpp.

template<class KEY , class VALUE , class KEY_ADAPTER >
int ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::unbind ( const KEY &  key,
VALUE &  value 
) [virtual]

Remove key from the map, and return the value associated with key.

Implements ACE_Map< KEY, VALUE >.

Definition at line 679 of file Map_T.cpp.

{
  expanded_value *internal_value = 0;
  int result = this->unbind (key,
                             internal_value);

  if (result == 0)
    {
      // Copy value.
      value = internal_value->second ();
    }

  return result;
}

template<class KEY , class VALUE , class KEY_ADAPTER >
int ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::unbind ( const KEY &  key  )  [virtual]

Remove key from the map.

Implements ACE_Map< KEY, VALUE >.

Definition at line 671 of file Map_T.cpp.

{
  expanded_value *internal_value = 0;
  return this->unbind (key,
                       internal_value);
}

template<class KEY , class VALUE , class KEY_ADAPTER >
int ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::unbind ( const KEY &  key,
expanded_value *&  internal_value 
) [protected, virtual]

Unbind helper.

Definition at line 653 of file Map_T.cpp.

{
  // Ask the <key_adapter_> to recover the active key.
  ACE_Active_Map_Manager_Key active_key;
  int result = this->key_adapter_.decode (key,
                                          active_key);
  if (result == 0)
    {
      // Unbind recovered active key from map.
      result = this->implementation_.unbind (active_key,
                                             internal_value);
    }

  return result;
}


Member Data Documentation

template<class KEY, class VALUE, class KEY_ADAPTER>
ACE_Active_Map_Manager<ACE_Pair<KEY, VALUE> > ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::implementation_ [protected]

All implementation details are forwarded to this class.

Definition at line 1002 of file Map_T.h.

template<class KEY, class VALUE, class KEY_ADAPTER>
KEY_ADAPTER ACE_Active_Map_Manager_Adapter< KEY, VALUE, KEY_ADAPTER >::key_adapter_ [protected]

Adapts between the user key and the Active_Map_Manager_Key.

Definition at line 1005 of file Map_T.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines