| 1 |
|
/*========================================================================= |
| 2 |
|
|
| 3 |
|
Program: Insight Segmentation & Registration Toolkit |
| 4 |
|
Module: $RCSfile: itkMetaDataDictionary.h.html,v $ |
| 5 |
|
Language: C++ |
| 6 |
|
Date: $Date: 2006/01/17 19:15:42 $ |
| 7 |
|
Version: $Revision: 1.4 $ |
| 8 |
|
|
| 9 |
|
Copyright (c) Insight Software Consortium. All rights reserved. |
| 10 |
|
See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details. |
| 11 |
|
|
| 12 |
|
This software is distributed WITHOUT ANY WARRANTY; without even |
| 13 |
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
| 14 |
|
PURPOSE. See the above copyright notices for more information. |
| 15 |
|
|
| 16 |
|
=========================================================================*/ |
| 17 |
|
#ifndef __itkMetaDataDictionary_h |
| 18 |
|
#define __itkMetaDataDictionary_h |
| 19 |
|
|
| 20 |
|
#include "itkMetaDataObjectBase.h" |
| 21 |
|
#include <vector> |
| 22 |
|
#include <map> |
| 23 |
|
#include <string> |
| 24 |
|
|
| 25 |
|
namespace itk |
| 26 |
|
{ |
| 27 |
|
|
| 28 |
|
/** |
| 29 |
|
* \author Hans J. Johnson |
| 30 |
|
* The MetaDataDictionary, along with the MetaDataObject derived template |
| 31 |
|
* classes, is designed to provide a mechanism for storing a collection of |
| 32 |
|
* arbitrary data types. The main motivation for such a collection is to |
| 33 |
|
* associate arbitrary data elements with itk DataObjects. |
| 34 |
|
*/ |
| 35 |
|
class ITKCommon_EXPORT MetaDataDictionary |
| 36 |
MCM |
{ |
| 37 |
|
public: |
| 38 |
|
typedef MetaDataDictionary Self; |
| 39 |
|
/** |
| 40 |
|
* Defines the default behavior for printing out this element |
| 41 |
|
* \param os An output stream |
| 42 |
|
*/ |
| 43 |
|
virtual void Print(std::ostream& os) const; |
| 44 |
|
|
| 45 |
|
// Declare the datastructure that will be used to hold the |
| 46 |
|
// dictionary. |
| 47 |
|
class MetaDataDictionaryMapType |
| 48 |
IND |
****: public std::map<std::string, MetaDataObjectBase::Pointer> |
| 49 |
IND |
******{ |
| 50 |
IND |
******}; |
| 51 |
|
|
| 52 |
|
typedef MetaDataDictionaryMapType::iterator Iterator; |
| 53 |
|
typedef MetaDataDictionaryMapType::const_iterator ConstIterator; |
| 54 |
|
|
| 55 |
|
// Constructor |
| 56 |
|
MetaDataDictionary(); |
| 57 |
|
// Copy Constructor |
| 58 |
|
MetaDataDictionary(const MetaDataDictionary&); |
| 59 |
|
// operator = |
| 60 |
|
void operator=(const MetaDataDictionary&); |
| 61 |
|
|
| 62 |
|
// Destructor |
| 63 |
|
virtual ~MetaDataDictionary(); |
| 64 |
|
|
| 65 |
|
/** Returns a vector of keys to the key/value entries in the |
| 66 |
IND |
****dictionary. Iterate through the dictionary using these keys. |
| 67 |
IND |
*****/ |
| 68 |
|
std::vector<std::string> GetKeys() const; |
| 69 |
|
|
| 70 |
|
// Implement map's api. On some Micorsoft compilers, stl containers |
| 71 |
|
// cannot be exported. This causes problems when building DLL's. |
| 72 |
|
// Here we inherit privately from std::map and provide a simple |
| 73 |
|
// API. The implementation will be in the DLL. |
| 74 |
|
MetaDataObjectBase::Pointer &operator [](const std::string &); |
| 75 |
|
const MetaDataObjectBase * operator [](const std::string &) const; |
| 76 |
|
bool HasKey (const std::string &); |
| 77 |
|
|
| 78 |
|
|
| 79 |
|
/** \warning the following functions SHOULD NOT be used with |
| 80 |
|
* the visual studio 6 compiler since iterator outside of the dll |
| 81 |
|
* context cannot be dereferenced safely */ |
| 82 |
|
|
| 83 |
|
/** Returns an iterator to the beginning of the map */ |
| 84 |
|
Iterator Begin(); |
| 85 |
|
ConstIterator Begin() const; |
| 86 |
|
|
| 87 |
|
/** Returns an iterator to the end of the map */ |
| 88 |
|
Iterator End(); |
| 89 |
|
ConstIterator End() const; |
| 90 |
|
|
| 91 |
|
/** Returns an iterator matching the string key */ |
| 92 |
|
Iterator Find(const std::string & key); |
| 93 |
|
ConstIterator Find(const std::string & key) const; |
| 94 |
|
|
| 95 |
|
private: |
| 96 |
|
MetaDataDictionaryMapType *m_Dictionary; |
| 97 |
|
}; |
| 98 |
|
|
| 99 |
|
} |
| 100 |
|
#endif // __itkMetaDataDictionary_h |
| 101 |
|
|
| 102 |
EOF |
|