IOSS 2.0
Loading...
Searching...
No Matches
Ioss_PropertyManager.h
Go to the documentation of this file.
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
25namespace Ioss {
26#if defined USE_ROBIN_MAP
28#else
29 using PropMapType = std::unordered_map<std::string, Property>;
30#endif
32
33 /** \brief A collection of Ioss::Property objects
34 */
35 class IOSS_EXPORT PropertyManager
36 {
37 public:
38 PropertyManager() = default;
40 : m_properties(from.m_properties)
41 { /* Do not make this `=default` since that breaks the thread-safe build */ }
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
#define IOSS_NODISCARD
Definition Ioss_CodeTypes.h:54
A collection of Ioss::Property objects.
Definition Ioss_PropertyManager.h:36
PropertyManager(const PropertyManager &from)
Definition Ioss_PropertyManager.h:39
PropertyManager & operator=(const PropertyManager &from)=delete
A named value that has a known type.
Definition Ioss_Property.h:27
Origin
Definition Ioss_Property.h:30
Definition robin_map.h:90
typename ht::value_type value_type
Definition robin_map.h:126
The main namespace for the Ioss library.
Definition Ioad_DatabaseIO.C:40
PropMapType::value_type ValuePair
Definition Ioss_PropertyManager.h:31
std::vector< std::string > NameList
Definition Ioss_CodeTypes.h:23