message event update for points and boundaries

This commit is contained in:
Hamidreza Norouzi 2024-03-22 09:01:07 -07:00
parent c3821d03c0
commit f27fbdd82c
3 changed files with 52 additions and 10 deletions

View File

@ -21,6 +21,7 @@ Licence:
#define __message_hpp__
#include <bitset>
#include <array>
#include "types.hpp"
#include "iOstream.hpp"
@ -35,22 +36,40 @@ public:
enum EVENT : size_t
{
DEFAULT = 0,
CAP_CHANGED = 1,
SIZE_CHANGED = 2,
ITEM_DELETE = 3,
ITEM_INSERT = 4,
RANGE_CHANGED = 5,
ITEM_REARRANGE = 6,
ITEM_TRANSFER = 7,
RESET_COUNTERS = 8
CAP_CHANGED = 1, // internal points capacity changed
SIZE_CHANGED = 2, // internal points size changed
ITEM_DELETE = 3, // internal points item deleted
ITEM_INSERT = 4, // internal points item inserted
RANGE_CHANGED = 5, // internal points range changed
ITEM_REARRANGE = 6, // internal points item rearrange
BNDR_REARRANGE = 7, // boundary indices rearrange
BNDR_TRANSFER = 8, // boundary indices transfered
BNDR_RESET = 9, // boundary indices reset entirely
BNDR_DELETE = 10 // boundary indices deleted
};
protected:
private:
static constexpr size_t numberOfEvents_ = 9;
static constexpr size_t numberOfEvents_ = 11;
std::bitset<numberOfEvents_> events_{0x0000};
static
inline const std::array<word,numberOfEvents_> eventNames_
{
"",
"capacity",
"size",
"deletedIndices",
"insertedIndices",
"range",
"rearrangedIndices",
"rearrangedIndices",
"transferredIndices",
"",
"deletedIndices"
};
public:
@ -141,6 +160,12 @@ public:
message msg;
return msg;
}
static
const word& eventName(size_t event)
{
return eventNames_[event];
}
};

View File

@ -48,6 +48,21 @@ pFlow::observer::~observer()
invalidateSubscriber();
}
pFlow::observer &pFlow::observer::addEvent(message::EVENT event)
{
if( !message_.equivalentTo(event) )
{
message_.add(event);
if(!subscriber_->subscribe(message(event),this))
{
fatalErrorInFunction<<
"error when subcribing event from observer "<<endl;
fatalExit;
}
}
return *this;
}
void pFlow::observer::addToSubscriber
(
const subscriber* subscrbr,

View File

@ -64,6 +64,8 @@ public:
void subscribe(
const subscriber* subscrbr,
message msg);
observer& addEvent(message::EVENT event);
inline
bool subscribed()const