summaryrefslogtreecommitdiff
path: root/TAO/CIAO/tools/Config_Handlers/IDREF_Base.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/CIAO/tools/Config_Handlers/IDREF_Base.cpp')
-rw-r--r--TAO/CIAO/tools/Config_Handlers/IDREF_Base.cpp141
1 files changed, 89 insertions, 52 deletions
diff --git a/TAO/CIAO/tools/Config_Handlers/IDREF_Base.cpp b/TAO/CIAO/tools/Config_Handlers/IDREF_Base.cpp
index 88808bb4a6f..7a6201c2906 100644
--- a/TAO/CIAO/tools/Config_Handlers/IDREF_Base.cpp
+++ b/TAO/CIAO/tools/Config_Handlers/IDREF_Base.cpp
@@ -2,6 +2,7 @@
#ifndef IDREF_BASE_CPP
#define IDREF_BASE_CPP
+#include "ciao/CIAO_common.h"
#include "IDREF_Base.h"
#include <iostream>
@@ -10,68 +11,104 @@ ACE_RCSID (DAnCE,
IDREF_Base,
"$Id$")
-
-namespace CIAO
-{
- namespace Config_Handlers
+
+ namespace CIAO
{
- template <typename T>
- void
- IDREF_Base<T>::bind_ref (ACE_CString& id, T value)
- throw (Config_Error)
+ namespace Config_Handlers
{
- int retval =
- idref_map_.bind (id, value);
+ template <typename T>
+ void
+ IDREF_Base<T>::bind_ref (ACE_CString& id, T value)
+ throw (Config_Error)
+ {
+ CIAO_TRACE("IDREF_Base<T>::bind_ref");
- pos_map_.bind (value,id);
+ int retval =
+ idref_map_.bind (id, value);
- if (retval < 0)
- throw Config_Error (id.c_str (),
- "Failed to bind an IDRef. This likely indicates a name clash.");
- }
+ pos_map_.bind (value,id);
- template <typename T>
- void
- IDREF_Base<T>::find_ref (const ACE_CString& id, T& val)
- throw (Config_Error)
- {
- int retval =
- idref_map_.find (id, val);
+ if (retval < 0)
+ throw Config_Error (id.c_str (),
+ "Failed to bind an IDRef. This likely indicates a name clash.");
+ }
- if (retval < 0)
- throw Config_Error (id.c_str (),
- "Unable to look up an IDRef.");
- }
+ template <typename T>
+ void
+ IDREF_Base<T>::bind_next_available (ACE_CString &id)
+ {
+ // Note: For this function to compile and work properly,
+ // T must have the postincrement operator defined.
+ CIAO_TRACE ("IDREF_Base<T>::bind_next_available");
+ // ACE_DEBUG ((LM_DEBUG, "**** Binding %s to %i\n",
+ // id.c_str (),
+ // this->next_));
- template <typename T>
- void
- IDREF_Base<T>::find_ref (const T& value, ACE_CString& id)
- throw (Config_Error)
- {
- int retval =
- pos_map_.find (value, id);
+ int retval = idref_map_.bind (id, this->next_);
- if (retval < 0)
- throw Config_Error ("No location information",
- "Failed a reverse IDRef lookup.");
- }
+ int pos_retval = pos_map_.bind (this->next_, id);
- template <typename T>
- bool
- IDREF_Base<T>::unbind_refs (void)
- {
- int retval =
- idref_map_.unbind_all ();
-
- pos_map_.unbind_all ();
-
- if (retval < 0)
- return false;
-
- return true;
+ ++this->next_;
+
+ if (retval < 0 || pos_retval < 0)
+ throw Config_Error (id.c_str (),
+ "Failed to bind an IDRef. This likely indicates a name clash");
+
+ }
+
+ template <typename T>
+ void
+ IDREF_Base<T>::find_ref (const ACE_CString& id, T& val)
+ throw (Config_Error)
+ {
+ CIAO_TRACE("IDREF_Base<T>::find_ref(C_String, T)");
+
+ int retval =
+ idref_map_.find (id, val);
+
+ if (retval < 0)
+ throw Config_Error (id.c_str (),
+ "Unable to look up an IDRef.");
+ }
+
+ template <typename T>
+ void
+ IDREF_Base<T>::find_ref (const T& value, ACE_CString& id)
+ throw (Config_Error)
+ {
+ CIAO_TRACE("IDREF_Base<T>::find_ref (T, CString)");
+
+ int retval =
+ pos_map_.find (value, id);
+
+ // ACE_DEBUG ((LM_ERROR, "**** Looking up value %i\n",
+ // value));
+
+ if (retval < 0)
+ throw Config_Error ("No location information for reverse IDREF lookup",
+ id.c_str ());
+ }
+
+ template <typename T>
+ bool
+ IDREF_Base<T>::unbind_refs (void)
+ {
+ CIAO_TRACE("IDREF_Base<T>::unbind_refs");
+
+ int retval =
+ idref_map_.unbind_all ();
+
+ pos_map_.unbind_all ();
+
+ this->next_ = 0;
+
+ if (retval < 0)
+ return false;
+
+ return true;
+ }
}
-}
-}
+ }
#endif /* IDREF_BASE_CPP */