IOSS 2.0
Loading...
Searching...
No Matches
Ioss_FieldManager.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_Field.h" // for Field, Field::RoleType
11#include <cstddef> // for size_t
12#include <string> // for string
13#include <vector> // for vector
14
15#include "ioss_export.h"
16
17#define USE_ROBIN_MAP
18#if defined USE_ROBIN_MAP
19#include <robin_map.h>
20#else
21#include <unordered_map>
22#endif
23
24namespace Ioss {
25#if defined USE_ROBIN_MAP
27#else
28 using FieldMapType = std::unordered_map<std::string, Field>;
29#endif
31
32 /** \brief A collection of Ioss::Field objects.
33 */
34 class IOSS_EXPORT FieldManager
35 {
36 public:
37 FieldManager() = default;
39 : fields(other.fields)
40 { /* Do not make this `=default` since that breaks the thread-safe build */ }
41
43
44 // If a field with the same 'name' exists, an exception will be thrown.
45 // Add the specified field to the list.
46 void add(const Field &new_field);
47
48 // Remove all fields of type `role`
49 void erase(Field::RoleType role);
50
51 // Assumes: Field 'name' must exist.
52 void erase(const std::string &field_name);
53
54 // Checks if a field with 'field_name' exists in the database.
55 IOSS_NODISCARD bool exists(const std::string &field_name) const;
56
57 IOSS_NODISCARD Field get(const std::string &field_name) const;
58 IOSS_NODISCARD const Field &getref(const std::string &field_name) const;
59
60 // Returns the names of all fields
61 int describe(NameList *names) const;
62 IOSS_NODISCARD NameList describe() const;
63
64 // Returns the names of all fields with the specified 'RoleType'
65 int describe(Field::RoleType role, NameList *names) const;
66 IOSS_NODISCARD NameList describe(Field::RoleType role) const;
67
68 IOSS_NODISCARD size_t count() const;
69
70 private:
72#if defined(IOSS_THREADSAFE)
73 mutable std::mutex m_;
74#endif
75 };
76} // namespace Ioss
#define IOSS_NODISCARD
Definition Ioss_CodeTypes.h:55
A collection of Ioss::Field objects.
Definition Ioss_FieldManager.h:35
FieldManager()=default
FieldManager(const FieldManager &other)
Definition Ioss_FieldManager.h:38
FieldManager & operator=(const FieldManager &)=delete
FieldMapType fields
Definition Ioss_FieldManager.h:71
Holds metadata for bulk data associated with a GroupingEntity.
Definition Ioss_Field.h:25
RoleType
Definition Ioss_Field.h:69
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
Ioss::NameList NameList
Definition Ioss_ChangeSetFactory.h:25
FieldMapType::value_type FieldValuePair
Definition Ioss_FieldManager.h:30