IOSS 2.0

Ioss_PropertyManager.h
Go to the documentation of this file.
1 // Copyright(C) 1999-2017 National Technology & Engineering Solutions
2 // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
3 // NTESS, the U.S. Government retains certain rights in this software.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // * Redistributions in binary form must reproduce the above
13 // copyright notice, this list of conditions and the following
14 // disclaimer in the documentation and/or other materials provided
15 // with the distribution.
16 //
17 // * Neither the name of NTESS nor the names of its
18 // contributors may be used to endorse or promote products derived
19 // from this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33 #ifndef IOSS_Ioss_PropertyManager_h
34 #define IOSS_Ioss_PropertyManager_h
35
36 #include <Ioss_CodeTypes.h>
37 #include <Ioss_Property.h> // for Property
38 #include <cstddef> // for size_t
39 #include <string> // for string, operator<
40 #include <unordered_map>
41 #include <vector> // for vector
42
43 namespace Ioss {
44 using PropMapType = std::unordered_map<std::string, Property>;
45 using ValuePair = PropMapType::value_type;
46
47 /** \brief A collection of Ioss::Property objects
48 */
49 class PropertyManager
50 {
51 public:
52 PropertyManager() = default;
53 PropertyManager(const PropertyManager &from);
54 PropertyManager &operator=(const PropertyManager &from) = delete;
55 ~PropertyManager();
56
57 // Add the specified property to the list.
58 void add(const Property &new_prop);
59
60 // Assumes: Property 'name' must exist.
61 void erase(const std::string &property_name);
62
63 // Checks if a property with 'property_name' exists in the database.
64 bool exists(const std::string &property_name) const;
65
66 Property get(const std::string &property_name) const;
67
68 // Returns the names of all properties
69 int describe(NameList *names) const;
70
71 size_t count() const;
72
73 private:
74 PropMapType properties;
75 #if defined(IOSS_THREADSAFE)
76 mutable std::mutex m_;
77 #endif
78 };
79 } // namespace Ioss
80 #endif
Ioss::NameList
std::vector< std::string > NameList
Definition: Ioss_CodeTypes.h:44
Ioss_CodeTypes.h
Ioss::Property
A named value that has a known type.
Definition: Ioss_Property.h:47
Ioss::PropertyManager::describe
int describe(NameList *names) const
Get the names of all properties in the property manager.
Definition: Ioss_PropertyManager.C:121
Ioss::PropertyManager::~PropertyManager
~PropertyManager()
Definition: Ioss_PropertyManager.C:48
Ioss_Property.h
Ioss
The main namespace for the Ioss library.
Definition: Iocgns_DatabaseIO.h:50
Ioss::PropertyManager::exists
bool exists(const std::string &property_name) const
Checks if a property exists in the database.
Definition: Ioss_PropertyManager.C:77
Ioss::PropertyManager::PropertyManager
PropertyManager()=default
Ioss::PropertyManager::erase
void erase(const std::string &property_name)
Remove a property from the property manager.
Definition: Ioss_PropertyManager.C:107
Ioss::PropertyManager::add
void add(const Property &new_prop)
Add a property to the property manager.
Definition: Ioss_PropertyManager.C:62
Ioss::PropertyManager::count
size_t count() const
Definition: Ioss_PropertyManager.C:137
Ioss::ValuePair
PropMapType::value_type ValuePair
Definition: Ioss_PropertyManager.h:45
Ioss::PropertyManager::operator=
PropertyManager & operator=(const PropertyManager &from)=delete
Ioss::PropertyManager::properties
PropMapType properties
Definition: Ioss_PropertyManager.h:74
Ioss::PropertyManager
A collection of Ioss::Property objects.
Definition: Ioss_PropertyManager.h:49
Ioss::PropMapType
std::unordered_map< std::string, Property > PropMapType
Definition: Ioss_PropertyManager.h:44