IOSS 2.0
Loading...
Searching...
No Matches
Ioss_DynamicTopologyNotifier.h
Go to the documentation of this file.
1// Copyright(C) 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
11
12#include "Ioss_CodeTypes.h"
13#include "Ioss_DBUsage.h"
14#include "Ioss_DatabaseIO.h" // for DatabaseIO
15#include "Ioss_ParallelUtils.h" // for ParallelUtils
16#include "Ioss_PropertyManager.h" // for PropertyManager
17#include "Ioss_Utils.h"
18#include "ioss_export.h"
19
20#include <cstddef> // for size_t, nullptr
21#include <cstdint> // for int64_t
22#include <iomanip>
23#include <sstream>
24#include <string> // for string, operator<
25
26namespace Ioss {
27
28 class IOSS_EXPORT DynamicTopologyNotifier
29 {
30 public:
31 explicit DynamicTopologyNotifier(const std::string &model_name) : m_modelName(model_name) {}
32
33 virtual ~DynamicTopologyNotifier() = default;
34
35 std::string name() const { return m_modelName; }
36
37 const std::vector<std::shared_ptr<DynamicTopologyObserver>> &get_observers() const
38 {
39 return m_observers;
40 }
41
42 std::vector<std::shared_ptr<DynamicTopologyObserver>> &get_observers() { return m_observers; }
43
44 void register_observer(std::shared_ptr<DynamicTopologyObserver> observer);
45
46 void unregister_observer(std::shared_ptr<DynamicTopologyObserver> observer);
47
48 void reset_topology_modification();
49
50 void set_topology_modification(unsigned int type);
51
52 template <typename ObserverType> bool has_observer_type() const
53 {
54 bool found = false;
55
56 for (const std::shared_ptr<DynamicTopologyObserver> &observer : m_observers) {
57 if (dynamic_cast<const ObserverType *>(observer.get()) != nullptr) {
58 found = true;
59 break;
60 }
61 }
62 return found;
63 }
64
65 template <typename ObserverType>
66 std::vector<std::shared_ptr<ObserverType>> get_observer_type() const
67 {
68 std::vector<std::shared_ptr<ObserverType>> typed_observers;
69
70 for (const std::shared_ptr<DynamicTopologyObserver> &observer : m_observers) {
71 ObserverType *typed_observer = dynamic_cast<ObserverType *>(observer.get());
72 if (typed_observer != nullptr) {
73 typed_observers.push_back(std::dynamic_pointer_cast<ObserverType>(observer));
74 }
75 }
76
77 return typed_observers;
78 }
79
80 private:
81 const std::string m_modelName;
82 std::vector<std::shared_ptr<DynamicTopologyObserver>> m_observers;
83 };
84
85} // namespace Ioss
Definition Ioss_DynamicTopologyNotifier.h:29
std::vector< std::shared_ptr< DynamicTopologyObserver > > m_observers
Definition Ioss_DynamicTopologyNotifier.h:82
const std::string m_modelName
Definition Ioss_DynamicTopologyNotifier.h:81
std::vector< std::shared_ptr< ObserverType > > get_observer_type() const
Definition Ioss_DynamicTopologyNotifier.h:66
std::string name() const
Definition Ioss_DynamicTopologyNotifier.h:35
DynamicTopologyNotifier(const std::string &model_name)
Definition Ioss_DynamicTopologyNotifier.h:31
std::vector< std::shared_ptr< DynamicTopologyObserver > > & get_observers()
Definition Ioss_DynamicTopologyNotifier.h:42
bool has_observer_type() const
Definition Ioss_DynamicTopologyNotifier.h:52
const std::vector< std::shared_ptr< DynamicTopologyObserver > > & get_observers() const
Definition Ioss_DynamicTopologyNotifier.h:37
virtual ~DynamicTopologyNotifier()=default
The main namespace for the Ioss library.
Definition Ioad_DatabaseIO.C:40