[opengtl-commits] [629] add a function to find a specific parameter |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/opengtl-commits Archives
]
Revision: 629
Author: cyrille
Date: 2009-03-15 16:19:56 +0100 (Sun, 15 Mar 2009)
Log Message:
-----------
add a function to find a specific parameter
Modified Paths:
--------------
trunk/OpenGTL/OpenShiva/OpenShiva/Metadata.cpp
trunk/OpenGTL/OpenShiva/OpenShiva/Metadata.h
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Metadata.cpp
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Metadata.cpp 2009-03-15 15:12:36 UTC (rev 628)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Metadata.cpp 2009-03-15 15:19:56 UTC (rev 629)
@@ -19,7 +19,10 @@
#include "Metadata.h"
+#include "GTLCore/Macros_p.h"
#include "GTLCore/Value.h"
+#include "GTLCore/Metadata/Group.h"
+#include "GTLCore/Metadata/ParameterEntry.h"
#include "GTLCore/Metadata/ValueEntry.h"
#include "Debug.h"
@@ -84,3 +87,27 @@
return d->parametersList;
}
+const GTLCore::Metadata::ParameterEntry* recursiveFoundParameter(const GTLCore::String& _name, const Group* _group)
+{
+ foreach(const Entry* entry, _group->entries())
+ {
+ if(entry->asParameterEntry())
+ {
+ if(entry->name() == _name)
+ {
+ return entry->asParameterEntry();
+ }
+ } else if(entry->asGroup())
+ {
+ const GTLCore::Metadata::ParameterEntry* pe = recursiveFoundParameter(_name, entry->asGroup());
+ if(pe) return pe;
+ }
+ }
+ return 0;
+}
+
+const GTLCore::Metadata::ParameterEntry* Metadata::parameter(const GTLCore::String& _name) const
+{
+ if(not d->parametersList) return 0;
+ return recursiveFoundParameter( _name, d->parametersList );
+}
Modified: trunk/OpenGTL/OpenShiva/OpenShiva/Metadata.h
===================================================================
--- trunk/OpenGTL/OpenShiva/OpenShiva/Metadata.h 2009-03-15 15:12:36 UTC (rev 628)
+++ trunk/OpenGTL/OpenShiva/OpenShiva/Metadata.h 2009-03-15 15:19:56 UTC (rev 629)
@@ -32,6 +32,7 @@
int version() const;
const GTLCore::Metadata::Group* infos() const;
const GTLCore::Metadata::Group* parameters() const;
+ const GTLCore::Metadata::ParameterEntry* parameter(const GTLCore::String& _name) const;
private:
struct Private;
Private* const d;