From 3a41b51160ca87a8718185663e1e70967b320566 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Mon, 8 Oct 2007 17:49:18 +0100 Subject: [PATCH] Bug 82 (Add convenience API to retrieve default values) --- src/core/default-value.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/core/default-value.h b/src/core/default-value.h index b43f013be..8d252ab45 100644 --- a/src/core/default-value.h +++ b/src/core/default-value.h @@ -97,6 +97,21 @@ class DefaultValueList static Iterator End (void); static void Remove (const std::string &name); static void Add (DefaultValueBase *defaultValue); + + template + 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 (value); + } + } + return NULL; + } + private: typedef std::list List; static List *GetList (void);