Bug 82 (Add convenience API to retrieve default values)
authorGustavo J. A. M. Carneiro <gjc@inescporto.pt>
Mon, 08 Oct 2007 17:49:18 +0100
changeset 1701 5e9bd24a8716
parent 1700 2f03a3b8a225
child 1702 0fbe74581141
child 1772 dd278e20e52e
child 1840 f5bb4b608832
Bug 82 (Add convenience API to retrieve default values)
src/core/default-value.h
--- a/src/core/default-value.h	Mon Oct 08 17:44:17 2007 +0100
+++ b/src/core/default-value.h	Mon Oct 08 17:49:18 2007 +0100
@@ -97,6 +97,21 @@
   static Iterator End (void);
   static void Remove (const std::string &name);
   static void Add (DefaultValueBase *defaultValue);
+
+  template <typename T>
+  static const T* Get (const std::string &name)
+  {
+    for (Iterator iter = Begin (); iter != End (); iter++)
+      {
+        const DefaultValueBase *value = *iter;
+        if (value->GetName () == name)
+          {
+            return dynamic_cast<const T*> (value);
+          }
+      }
+    return NULL;
+  }
+
  private:
   typedef std::list<DefaultValueBase *> List;
   static List *GetList (void);