ArmNN
 24.08
Observable.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #pragma once
6 
7 #include "IGraphObservable.hpp"
8 #include "Graph.hpp"
9 
10 namespace armnn
11 {
12 
13 template <typename ObservedType>
15 {
16 public:
17  using Iterator = typename std::list<ObservedType>::const_iterator;
18 
19  GraphObservable(Graph& subject, GraphEvent notifyOnEvent)
20  : m_Subject(&subject)
21  {
22  m_NotifyOnEvent = notifyOnEvent;
24  };
25 
26  void Clear() { m_ObservedObjects.clear(); };
27 
28  Iterator begin() { return m_ObservedObjects.begin(); }
29 
30  Iterator end() { return m_ObservedObjects.end(); }
31 
32 protected:
34  {
35  if (m_Subject)
36  {
38  }
39  }
40 
43  std::list<ObservedType> m_ObservedObjects;
44 };
45 
46 class AddedLayerObservable : public GraphObservable<Layer*>
47 {
48 public:
49  explicit AddedLayerObservable(Graph& subject)
51  {};
52 
53  void Update(Layer* graphLayer) override;
54 };
55 
56 class ErasedLayerNamesObservable : public GraphObservable<std::string>
57 {
58 public:
59  explicit ErasedLayerNamesObservable(Graph& subject)
60  : GraphObservable<std::string>(subject, GraphEvent::LayerErased)
61  {};
62 
63  void Update(Layer* graphLayer) override;
64 };
65 
66 } //namespace armnn
67 
armnn::GraphObservable::m_ObservedObjects
std::list< ObservedType > m_ObservedObjects
Definition: Observable.hpp:43
armnn::GraphEvent
GraphEvent
Definition: IGraphObservable.hpp:12
Graph.hpp
IGraphObservable.hpp
armnn::AddedLayerObservable
Definition: Observable.hpp:46
armnn::ErasedLayerNamesObservable::ErasedLayerNamesObservable
ErasedLayerNamesObservable(Graph &subject)
Definition: Observable.hpp:59
armnn::GraphObservable::begin
Iterator begin()
Definition: Observable.hpp:28
armnn::GraphEvent::LayerAdded
@ LayerAdded
armnn::GraphObservable::m_Subject
Graph * m_Subject
Definition: Observable.hpp:42
armnn::AddedLayerObservable::Update
void Update(Layer *graphLayer) override
Definition: Observable.cpp:11
armnn::AddedLayerObservable::AddedLayerObservable
AddedLayerObservable(Graph &subject)
Definition: Observable.hpp:49
armnn::Layer
Definition: Layer.hpp:230
armnn::GraphEvent::LayerErased
@ LayerErased
armnn::ErasedLayerNamesObservable::Update
void Update(Layer *graphLayer) override
Definition: Observable.cpp:16
armnn::GraphObservable::m_NotifyOnEvent
GraphEvent m_NotifyOnEvent
Definition: Observable.hpp:41
armnn::ErasedLayerNamesObservable
Definition: Observable.hpp:56
armnn::GraphObservable::~GraphObservable
~GraphObservable()
Definition: Observable.hpp:33
armnn::GraphObservable::Clear
void Clear()
Definition: Observable.hpp:26
armnn::GraphObservable::end
Iterator end()
Definition: Observable.hpp:30
std
Definition: BackendId.hpp:149
armnn::IGraphObservable
Definition: IGraphObservable.hpp:18
armnn::GraphObservable::GraphObservable
GraphObservable(Graph &subject, GraphEvent notifyOnEvent)
Definition: Observable.hpp:19
armnn
Copyright (c) 2021 ARM Limited and Contributors.
Definition: 01_00_quick_start.dox:6
armnn::GraphObservable< std::string >::Iterator
typename std::list< std::string >::const_iterator Iterator
Definition: Observable.hpp:17
armnn::GraphObservable
Definition: Observable.hpp:14
armnn::Graph::AttachObservable
void AttachObservable(IGraphObservable *const observable, GraphEvent notifyOnEvent)
Definition: Graph.hpp:226
armnn::Graph::DetachObservable
void DetachObservable(IGraphObservable *const observable, GraphEvent notifyOnEvent)
Definition: Graph.hpp:230
armnn::Graph
Definition: Graph.hpp:30