www.cemf.ir
subscriber.hpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 #ifndef __subscriber_hpp__
21 #define __subscriber_hpp__
22 
23 
24 
25 #include <array>
26 
27 #include "List.hpp"
28 #include "message.hpp"
29 #include "timeInfo.hpp"
30 
31 namespace pFlow
32 {
33 
34 class observer;
35 class anyList;
36 
38 {
39 private:
40 
41  // - list of subsribed objectd that recieve updage messages
42  mutable std::array<List<observer*>,message::numEvents()> observerList_;
43 
45 
46 public:
47 
48  subscriber(const word& name)
49  :
50  subName_(name)
51  {}
52 
54  subscriber(const subscriber&);
55 
59 
62 
66 
67  virtual ~subscriber();
68 
69  virtual bool subscribe(message msg, observer* obsevr)const;
70 
71  virtual bool unsubscribe(observer* obsevr)const;
72 
73  bool notify(
74  uint32 iter,
75  real t,
76  real dt,
77  const message msg,
78  const anyList& varList);
79 
80  bool notify(
81  const timeInfo& ti,
82  const message msg,
83  const anyList& varList);
84 
85  const word& subscriberName()const
86  {
87  return subName_;
88  }
89 
90 };
91 
92 } // pFlow
93 
94 
95 
96 #endif // __eventSubscriber_hpp__
pFlow::observer
Definition: observer.hpp:33
pFlow::subscriber::notify
bool notify(uint32 iter, real t, real dt, const message msg, const anyList &varList)
Definition: subscriber.cpp:126
pFlow::message
Definition: message.hpp:33
pFlow::subscriber::unsubscribe
virtual bool unsubscribe(observer *obsevr) const
Definition: subscriber.cpp:107
pFlow::real
float real
Definition: builtinTypes.hpp:45
timeInfo.hpp
message.hpp
pFlow::subscriber::subscriber
subscriber(const word &name)
Definition: subscriber.hpp:48
List.hpp
pFlow::subscriber::observerList_
std::array< List< observer * >, message::numEvents()> observerList_
Definition: subscriber.hpp:42
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::message::numEvents
static constexpr auto numEvents()
Definition: message.hpp:177
pFlow::subscriber::subName_
word subName_
Definition: subscriber.hpp:44
pFlow::subscriber
Definition: subscriber.hpp:37
pFlow::timeInfo
Definition: timeInfo.hpp:28
pFlow
Definition: demGeometry.hpp:27
pFlow::subscriber::subscribe
virtual bool subscribe(message msg, observer *obsevr) const
Definition: subscriber.cpp:85
pFlow::anyList
Definition: anyList.hpp:35
pFlow::subscriber::subscriberName
const word & subscriberName() const
Definition: subscriber.hpp:85
pFlow::subscriber::~subscriber
virtual ~subscriber()
Definition: subscriber.cpp:70
pFlow::subscriber::operator=
subscriber & operator=(const subscriber &)
Copy assignemnt, only assign the name, do not assign the list.
Definition: subscriber.cpp:48