summaryrefslogtreecommitdiff
path: root/CIAO/DAnCE/NodeManager/NAM_Map.cpp
blob: f3aebb307a2ee0887d79d98ce709785566eb725f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// $Id$
#include "NAM_Map.h"
#include "ciao/CIAO_Config.h"
#include "ciao/CIAO_common.h"

namespace CIAO
{
  NAM_Map::NAM_Map (void)
    : map_ (CIAO_DEFAULT_MAP_SIZE)
  {
  }

  bool
  NAM_Map::is_available (const ACE_CString &str) const
  {
    if (this->map_.find (str) == 0)
      return true;

    return false;
  }

  bool
  NAM_Map::insert_nam (const ACE_CString &str,
                       const PortableServer::ObjectId &oid)
  {
    return (this->map_.bind (str, oid) == 0);
  }

  ::PortableServer::ObjectId
  NAM_Map::get_nam (const ACE_CString &str)
  {
    MAP::ENTRY *entry = 0;

    if (this->map_.find (str, entry) != 0)
      return ::PortableServer::ObjectId ();

    return entry->int_id_.in ();
  }

  bool
  NAM_Map::remove_nam (const PortableServer::ObjectId &oid)
  {
    for (Iterator i = this->map_.begin ();
         i != this->map_.end ();
         ++i)
      {
        if ((*i).int_id_.in() == oid)
          return this->map_.unbind ((*i).ext_id_) == 0;
      }
    return false;
  }
}