#ifndef __observerPatterns_object_publish_hpp__
#define __observerPatterns_object_publish_hpp__
#include <unordered_set>
#include "observerPatterns_publish.hpp"
class observerPatterns_object_publish : public observerPatterns_publish
{
private:
observerPatterns_msgPackage _opmp;
std::unordered_set<observerPatterns_subscribe *> _subscribeObjectBucket;
public:
observerPatterns_object_publish();
~observerPatterns_object_publish();
void registerObjectSubscribe(observerPatterns_subscribe *ops);
void removeObjectSubscribe(observerPatterns_subscribe *ops);
void notifyObjectSubscribe();
void setMsgPackage(const observerPatterns_msgPackage &opmp);
};
observerPatterns_object_publish::observerPatterns_object_publish()
{
}
observerPatterns_object_publish::~observerPatterns_object_publish()
{
}
void observerPatterns_object_publish::registerObjectSubscribe(observerPatterns_subscribe *ops)
{
_subscribeObjectBucket.insert(ops);
}
void observerPatterns_object_publish::removeObjectSubscribe(observerPatterns_subscribe *ops)
{
_subscribeObjectBucket.erase(ops);
}
void observerPatterns_object_publish::notifyObjectSubscribe()
{
for (auto &&_sob : _subscribeObjectBucket)
_sob->update(_opmp);
}
void observerPatterns_object_publish::setMsgPackage(const observerPatterns_msgPackage &opmp)
{
_opmp = opmp;
notifyObjectSubscribe();
}
#endif
|