-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dca): add DCA direct component access
Signed-off-by: pingkai <pingkai010@gmail.com>
- Loading branch information
1 parent
e85595f
commit 2e948b8
Showing
2 changed files
with
46 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// | ||
// Created by moqi on 2020/6/24. | ||
// | ||
|
||
#ifndef CICADAMEDIA_IDCA_H | ||
#define CICADAMEDIA_IDCA_H | ||
#include <string> | ||
// direct component access | ||
namespace Cicada { | ||
class IDCAObserver { | ||
public: | ||
virtual void onEvent(int level, const std::string &content) = 0; | ||
}; | ||
class IDCA { | ||
public: | ||
void setDCAObserver(IDCAObserver *observer) | ||
{ | ||
mObserver = observer; | ||
} | ||
virtual int invoke(int cmd, const std::string &content) = 0; | ||
virtual ~IDCA() = default; | ||
|
||
protected: | ||
void sendEvent(int level, const std::string &content) | ||
{ | ||
if (mObserver) { | ||
mObserver->onEvent(level, content); | ||
} | ||
}; | ||
|
||
private: | ||
IDCAObserver *mObserver{nullptr}; | ||
}; | ||
}// namespace Cicada | ||
#endif//CICADAMEDIA_IDCA_H |
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