IOSS  2.0
Ioss_PropertyManager.h
Go to the documentation of this file.
1 // Copyright(C) 1999-2020 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 // See packages/seacas/LICENSE for details
6 
7 #ifndef IOSS_Ioss_PropertyManager_h
8 #define IOSS_Ioss_PropertyManager_h
9 
10 #include <Ioss_CodeTypes.h>
11 #include <Ioss_Property.h> // for Property
12 #include <cstddef> // for size_t
13 #include <string> // for string, operator<
14 #include <unordered_map>
15 #include <vector> // for vector
16 
17 namespace Ioss {
18  using PropMapType = std::unordered_map<std::string, Property>;
19  using ValuePair = PropMapType::value_type;
20 
21  /** \brief A collection of Ioss::Property objects
22  */
24  {
25  public:
26  PropertyManager() = default;
27  PropertyManager(const PropertyManager &from);
28  PropertyManager &operator=(const PropertyManager &from) = delete;
30 
31  // Add the specified property to the list.
32  void add(const Property &new_prop);
33 
34  // Assumes: Property 'name' must exist.
35  void erase(const std::string &property_name);
36 
37  // Checks if a property with 'property_name' exists in the database.
38  bool exists(const std::string &property_name) const;
39 
40  Property get(const std::string &property_name) const;
41 
42  // Returns the names of all properties
43  int describe(NameList *names) const;
44 
45  // Returns the names of all properties or origin `origin`
46  int describe(Ioss::Property::Origin origin, NameList *names) const;
47 
48  size_t count() const;
49 
50  private:
52 #if defined(IOSS_THREADSAFE)
53  mutable std::mutex m_;
54 #endif
55  };
56 } // namespace Ioss
57 #endif
Ioss::NameList
std::vector< std::string > NameList
Definition: Ioss_CodeTypes.h:27
Ioss_Property.h
Ioss::PropertyManager::exists
bool exists(const std::string &property_name) const
Checks if a property exists in the database.
Definition: Ioss_PropertyManager.C:51
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:81
Ioss::PropertyManager::get
Property get(const std::string &property_name) const
Get a property object from the property manager.
Definition: Ioss_PropertyManager.C:62
Ioss
The main namespace for the Ioss library.
Definition: Ioad_DatabaseIO.C:40
Ioss::PropertyManager::count
size_t count() const
Definition: Ioss_PropertyManager.C:131
Ioss::PropertyManager::m_properties
PropMapType m_properties
Definition: Ioss_PropertyManager.h:51
Ioss::PropertyManager
A collection of Ioss::Property objects.
Definition: Ioss_PropertyManager.h:24
Ioss::PropertyManager::add
void add(const Property &new_prop)
Add a property to the property manager.
Definition: Ioss_PropertyManager.C:36
Ioss::PropMapType
std::unordered_map< std::string, Property > PropMapType
Definition: Ioss_PropertyManager.h:18
Ioss::PropertyManager::describe
int describe(NameList *names) const
Get the names of all properties in the property manager.
Definition: Ioss_PropertyManager.C:95
Ioss::PropertyManager::operator=
PropertyManager & operator=(const PropertyManager &from)=delete
Ioss::Property::Origin
Origin
Definition: Ioss_Property.h:27
Ioss::PropertyManager::~PropertyManager
~PropertyManager()
Definition: Ioss_PropertyManager.C:22
Ioss::Property
A named value that has a known type.
Definition: Ioss_Property.h:24
Ioss_CodeTypes.h
Ioss::ValuePair
PropMapType::value_type ValuePair
Definition: Ioss_PropertyManager.h:19