Debian Codegraph @

packages/seacas/libraries/ioss/src/Ioss_PropertyManager.h

raw
1 // Copyright(C) 1999-2024 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 #pragma once
8
9 #include "Ioss_CodeTypes.h"
10 #include "Ioss_Property.h" // for Property
11 #include <cstddef> // for size_t
12 #include <stdint.h>
13 #include <string> // for string, operator<
14 #include <vector> // for vector
15
16 #include "ioss_export.h"
17
18 #define USE_ROBIN_MAP
19 #if defined USE_ROBIN_MAP
20 #include <robin_map.h>
21 #else
22 #include <unordered_map>
23 #endif
24
25 namespace Ioss {
26 #if defined USE_ROBIN_MAP
27 using PropMapType = tsl::robin_pg_map<std::string, Property>;
28 #else
29 using PropMapType = std::unordered_map<std::string, Property>;
30 #endif
31 using ValuePair = PropMapType::value_type;
32
33 /** \brief A collection of Ioss::Property objects
34 */
35 class IOSS_EXPORT PropertyManager
36 {
37 public:
38 PropertyManager() = default;
39 PropertyManager(const PropertyManager &from)
40 : m_properties(from.m_properties)
41 { /* Do not make this `=default` since that breaks the thread-safe build */ }
42 PropertyManager &operator=(const PropertyManager &from) = delete;
43
44 // Add the specified property to the list.
45 void add(const Property &new_prop);
46
47 // Assumes: Property 'name' must exist.
48 void erase(const std::string &property_name);
49
50 // Checks if a property with 'property_name' exists in the database.
51 IOSS_NODISCARD bool exists(const std::string &property_name) const;
52
53 IOSS_NODISCARD Property get(const std::string &property_name) const;
54 IOSS_NODISCARD double get_optional(const std::string &property_name,
55 double optional_value) const;
56 IOSS_NODISCARD int64_t get_optional(const std::string &property_name,
57 int64_t optional_value) const;
58 IOSS_NODISCARD int get_optional(const std::string &property_name, int optional_value) const;
59 IOSS_NODISCARD std::string get_optional(const std::string &property_name,
60 const std::string &optional_value) const;
61
62 // Returns the names of all properties
63 int describe(NameList *names) const;
64 IOSS_NODISCARD NameList describe() const;
65
66 // Returns the names of all properties or origin `origin`
67 int describe(Ioss::Property::Origin origin, NameList *names) const;
68 IOSS_NODISCARD NameList describe(Ioss::Property::Origin origin) const;
69
70 IOSS_NODISCARD size_t count() const;
71
72 private:
73 PropMapType m_properties{};
74 #if defined(IOSS_THREADSAFE)
75 mutable std::mutex m_;
76 #endif
77 };
78 } // namespace Ioss