-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from NaturalSelect/master
Refacor project and add interfaces
- Loading branch information
Showing
16 changed files
with
242 additions
and
421 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#pragma once | ||
#ifndef _SHARPEN_IQUORUMMAP_HPP | ||
#define _SHARPEN_IQUORUMMAP_HPP | ||
|
||
#include <cassert> | ||
|
||
#include "IRemoteActorBuilder.hpp" | ||
#include "Broadcaster.hpp" | ||
|
||
namespace sharpen | ||
{ | ||
class IQuorum | ||
{ | ||
private: | ||
using Self = sharpen::IQuorum; | ||
protected: | ||
|
||
virtual sharpen::IRemoteActorBuilder *NviLookup(std::uint64_t actorId) noexcept = 0; | ||
|
||
virtual const sharpen::IRemoteActorBuilder *NviLookup(std::uint64_t actorId) const noexcept = 0; | ||
|
||
virtual void NviRegister(std::uint64_t actorId,std::unique_ptr<sharpen::IRemoteActorBuilder> builder) = 0; | ||
public: | ||
|
||
IQuorum() noexcept = default; | ||
|
||
IQuorum(const Self &other) noexcept = default; | ||
|
||
IQuorum(Self &&other) noexcept = default; | ||
|
||
Self &operator=(const Self &other) noexcept = default; | ||
|
||
Self &operator=(Self &&other) noexcept = default; | ||
|
||
virtual ~IQuorum() noexcept = default; | ||
|
||
inline const Self &Const() const noexcept | ||
{ | ||
return *this; | ||
} | ||
|
||
virtual std::unique_ptr<sharpen::Broadcaster> CreateBroadcaster() const = 0; | ||
|
||
inline sharpen::IRemoteActorBuilder *Lookup(std::uint64_t actorId) | ||
{ | ||
return this->NviLookup(actorId); | ||
} | ||
|
||
inline const sharpen::IRemoteActorBuilder *Lookup(std::uint64_t actorId) const | ||
{ | ||
return this->NviLookup(actorId); | ||
} | ||
|
||
inline sharpen::IRemoteActorBuilder &Get(std::uint64_t actorId) noexcept | ||
{ | ||
sharpen::IRemoteActorBuilder *builder{this->NviLookup(actorId)}; | ||
assert(builder != nullptr); | ||
return *builder; | ||
} | ||
|
||
inline const sharpen::IRemoteActorBuilder &Get(std::uint64_t actorId) const noexcept | ||
{ | ||
const sharpen::IRemoteActorBuilder *builder{this->NviLookup(actorId)}; | ||
assert(builder != nullptr); | ||
return *builder; | ||
} | ||
|
||
inline void Register(std::uint64_t actorId,std::unique_ptr<sharpen::IRemoteActorBuilder> builder) | ||
{ | ||
assert(builder != nullptr); | ||
this->NviRegister(actorId,std::move(builder)); | ||
} | ||
|
||
virtual void Remove(std::uint64_t actorId) noexcept = 0; | ||
|
||
inline bool Exist(std::uint64_t actorId) const noexcept | ||
{ | ||
return this->NviLookup(actorId) != nullptr; | ||
} | ||
}; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.