All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MetadataManager.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2001-2013 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file terralib/metadata/MetadataManager.cpp
22  */
23 
24 // TerraLib
25 #include "../common/Exception.h"
26 #include "../common/Translator.h"
27 #include "Config.h"
28 #include "MetadataAnnotation.h"
29 #include "MetadataManager.h"
30 
31 // STL
32 #include <cassert>
33 
34 
36 
38 {
39 }
40 
41 void
43 {
44  assert(a);
45 
46  std::map<std::string,MetadataAnnotation*>::const_iterator it = m_metadata.find(a->getAnnotationtId());
47 
48  if (it != m_metadata.end())
49  throw te::common::Exception(TR_METADATA("A metadata annotation with this id already exists in the manager."));
50 
51  m_metadata.insert(std::make_pair(a->getAnnotationtId(),a));
52 }
53 
54 void
56 {
57  assert(a);
58 
59  std::map<std::string,MetadataAnnotation*>::iterator it = m_metadata.find(a->getAnnotationtId());
60 
61  if (it == m_metadata.end())
62  throw te::common::Exception(TR_METADATA("A metadata annotation with this id already exists in the manager."));
63 
64  m_metadata.erase(it);
65 
66 }
67 
69 te::md::MetadataManager::find(const std::string& aid) const
70 {
71  assert(!aid.empty());
72 
73  std::map<std::string,MetadataAnnotation*>::const_iterator it = m_metadata.find(aid);
74 
75  if (it == m_metadata.end())
76  return 0;
77 
78  return it->second;
79 }
80 
81 const std::map<std::string,te::md::MetadataAnnotation*>&
83 {
84  return m_metadata;
85 }
86 
87 
88 bool
90 {
91  return m_metadata.empty();
92 }
93 
94 void
96 {
97  m_metadata.clear();
98 }
99 
100 const std::map<std::string,te::md::MetadataAnnotation*>::const_iterator
102 {
103  return m_metadata.begin();
104 }
105 
106 const std::map<std::string,te::md::MetadataAnnotation*>::const_iterator
108 {
109  return m_metadata.end();
110 }
111 
112 
113 
114 
const std::map< std::string, MetadataAnnotation * >::const_iterator getEndIterator() const
Returns an end iterator pointing to the annotations managed.
const std::map< std::string, MetadataAnnotation * >::const_iterator getBeginIterator() const
Returns a begin iterator to the annotations managed.
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
Definition: Exception.h:58
#define TR_METADATA(message)
It marks a string in order to get translated. This is a special mark used in the Plugin module of Ter...
Definition: Config.h:59
void clear()
Removes all the annotation from the manager.
void insert(MetadataAnnotation *a)
Inserts a new metadata annotation to the manager.
const MetadataAnnotation * find(const std::string &aid) const
Searches for an annotation, given its identification.
void erase(MetadataAnnotation *a)
Removes the annotation from the manager and frees its resources.
MetadataManager()
It initializes the Singleton.
A class o relate a metadata annotation to a TerraLib element (or entity).
~MetadataManager()
Destructor.
const std::string & getAnnotationtId() const
Gets the annotation identifier.
Configuration flags for the Metadata support of TerraLib.
bool isEmpty() const
Check wheter the manager is empty.
const std::map< std::string, MetadataAnnotation * > & getAnnotations() const
Gives access to the set of metadata annotations.