IOSS  2.0
Ioss_FieldManager.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_FieldManager_h
8 #define IOSS_Ioss_FieldManager_h
9 
10 #include <Ioss_CodeTypes.h>
11 #include <Ioss_Field.h> // for Field, Field::RoleType
12 #include <Ioss_Utils.h> // for Utils
13 #include <cstddef> // for size_t
14 #include <functional> // for binary_function
15 #include <string> // for string
16 #include <unordered_map>
17 #include <vector> // for vector
18 
19 namespace Ioss {
20  using FieldMapType = std::unordered_map<std::string, Field>;
21  using FieldValuePair = FieldMapType::value_type;
22 
23  /** \brief A collection of Ioss::Field objects.
24  */
26  {
27  public:
28  FieldManager() = default;
29  FieldManager(const FieldManager &other) : fields(other.fields) {}
30 
31  FieldManager &operator=(const FieldManager &) = delete;
32  ~FieldManager() = default;
33 
34  // Assumes: Field with the same 'name' does not exist.
35  // Add the specified field to the list.
36  void add(const Field &new_field);
37 
38  // Assumes: Field 'name' must exist.
39  void erase(const std::string &field_name);
40 
41  // Checks if a field with 'field_name' exists in the database.
42  bool exists(const std::string &field_name) const;
43 
44  Field get(const std::string &field_name) const;
45  const Field &getref(const std::string &field_name) const;
46 
47  // Returns the names of all fields
48  int describe(NameList *names) const;
49 
50  // Returns the names of all fields with the specified 'RoleType'
51  int describe(Field::RoleType role, NameList *names) const;
52 
53  size_t count() const;
54 
55  private:
57 #if defined(IOSS_THREADSAFE)
58  mutable std::mutex m_;
59 #endif
60  };
61 } // namespace Ioss
62 #endif
Ioss::NameList
std::vector< std::string > NameList
Definition: Ioss_CodeTypes.h:27
Ioss::Field
Holds metadata for bulk data associated with a GroupingEntity.
Definition: Ioss_Field.h:22
Ioss::FieldManager::getref
const Field & getref(const std::string &field_name) const
Get a reference to a field from the field manager.
Definition: Ioss_FieldManager.C:65
Ioss::FieldManager::exists
bool exists(const std::string &field_name) const
Checks if a field with a given name exists in the field manager.
Definition: Ioss_FieldManager.C:37
Ioss::FieldManager::FieldManager
FieldManager(const FieldManager &other)
Definition: Ioss_FieldManager.h:29
Ioss::FieldManager::add
void add(const Field &new_field)
Add a field to the field manager.
Definition: Ioss_FieldManager.C:22
Ioss::FieldManager
A collection of Ioss::Field objects.
Definition: Ioss_FieldManager.h:26
Ioss::FieldValuePair
FieldMapType::value_type FieldValuePair
Definition: Ioss_FieldManager.h:21
Ioss
The main namespace for the Ioss library.
Definition: Ioad_DatabaseIO.C:40
Ioss::FieldManager::fields
FieldMapType fields
Definition: Ioss_FieldManager.h:56
Ioss::FieldMapType
std::unordered_map< std::string, Field > FieldMapType
Definition: Ioss_FieldManager.h:20
Ioss::FieldManager::operator=
FieldManager & operator=(const FieldManager &)=delete
Ioss::FieldManager::~FieldManager
~FieldManager()=default
Ioss_Utils.h
Ioss_Field.h
Ioss::FieldManager::describe
int describe(NameList *names) const
Get the names of all fields in the field manager.
Definition: Ioss_FieldManager.C:97
Ioss::FieldManager::get
Field get(const std::string &field_name) const
Get a field from the field manager.
Definition: Ioss_FieldManager.C:50
Ioss::FieldManager::erase
void erase(const std::string &field_name)
Remove a field from the field manager.
Definition: Ioss_FieldManager.C:80
Ioss::Field::RoleType
RoleType
Definition: Ioss_Field.h:49
Ioss_CodeTypes.h
Ioss::FieldManager::count
size_t count() const
Get the number of fields in the field manager.
Definition: Ioss_FieldManager.C:138
Ioss::FieldManager::FieldManager
FieldManager()=default