From c74021ed3c3026da77ad539affc48ca75108075f Mon Sep 17 00:00:00 2001 From: a7458969 <290198252@qq.com> Date: Thu, 21 May 2020 17:32:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=AD=E4=BB=8B=E8=80=85?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- general/CMakeLists.txt | 2 +- general/src/pattern/adapter.hpp | 51 ++++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/general/CMakeLists.txt b/general/CMakeLists.txt index 4e79081..d4c5c16 100644 --- a/general/CMakeLists.txt +++ b/general/CMakeLists.txt @@ -34,7 +34,7 @@ aux_source_directory(src DIRSRCS) aux_source_directory(src/pattern PaternSrc) -add_library(General OBJECT ${DIRSRCS} ${PaternSrc} src/pattern/signleton.hpp src/pattern/Observer.hpp src/pattern/stratergy.hpp src/pattern/adapter.hpp src/encrypt/base64.cpp src/encrypt/base64.h src/encrypt/aes.cpp src/encrypt/aes.h src/encrypt/rsa.cpp +add_library(General OBJECT ${DIRSRCS} ${PaternSrc} src/pattern/signleton.hpp src/pattern/Observer.hpp src/pattern/stratergy.hpp "src/ b-+/adapter.hpp" src/encrypt/base64.cpp src/encrypt/base64.h src/encrypt/aes.cpp src/encrypt/aes.h src/encrypt/rsa.cpp src/math/BigInt.hpp src/net/TcpClient.cpp src/net/TcpClient.h src/net/PackageReceiver.cpp src/net/PackageReceiver.h src/function/btree.cpp src/function/btree.h src/algorithm/sorter.hpp) set(COPYITEM inc) diff --git a/general/src/pattern/adapter.hpp b/general/src/pattern/adapter.hpp index f55f8c6..46a43aa 100644 --- a/general/src/pattern/adapter.hpp +++ b/general/src/pattern/adapter.hpp @@ -4,6 +4,8 @@ #ifndef GENERAL_ADAPTER_H #define GENERAL_ADAPTER_H +#include +#include template class Adapter{ T mAdapter; @@ -31,10 +33,57 @@ template class ResponsabilityChan{ public: int AddNext(ResponsabilityChan *p){ - + } private: ResponsabilityChan *mHead; ResponsabilityChan *mTail; }; +class Mediator; + +template +class MediatorColleague{ +public: + MediatorColleague(std::string name,Mediator *p){ + mName = name; + mMediater = p; + } + std::string GetName(){ + return mName; + }; + int SetMediater(Mediator* p){ + mMediater = p; + + } + virtual int Send(std::string colleage,T* data){ + + } +private: + MediatorColleague(){ + + } + std::string mName; + Mediator *mMediater; +}; + +class Mediator{ +public: + virtual int Register(MediatorColleague *p){ // 注册 + if (nullptr == p){ + return -1; + } + if(mColleague.find(p->GetName()) != mColleague.end()){ + return -1; + } + mColleague[p->GetName()] = p; + p->SetMediater(this); + return -1; + } + virtual int Relay(MediatorColleague *p){ //转发 + return -1; + } +private: + std::map mColleague; +}; + #endif //GENERAL_ADAPTER_H