-
Notifications
You must be signed in to change notification settings - Fork 0
/
CProcessorDirector.cpp
55 lines (47 loc) · 1.13 KB
/
CProcessorDirector.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "CProcessorDirector.h"
using namespace std;
CProcessorDirector::CProcessorDirector()
{
}
CProcessorDirector::~CProcessorDirector()
{
}
void CProcessorDirector::AddProcessor(std::string name, LogProcessor * pProcessor)
{
if (processors.find(name) == processors.end())
return;
processors[name]->addListener(pProcessor);
}
void CProcessorDirector::SetReader(std::string name, StatusReader * pReader, int szData)
{
if (szData <= 0)
throw runtime_error("zero data size");
if (processors.find(name) == processors.end())
{
CProcess* pCP = new CProcess();
pReader->Initialize();
pCP->setReader(pReader, szData);
processors.insert(make_pair(name, pCP));
}
else
{
processors[name]->setReader(pReader, szData);
}
}
bool CProcessorDirector::Activate(std::string name)
{
if (processors.find(name) != processors.end())
{
return processors[name]->Process();
}
return false;
}
void CProcessorDirector::Release()
{
for (auto iter = processors.begin(); iter != processors.end(); ++iter)
{
iter->second->Release();
delete (iter->second);
}
processors.clear();
}