-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathAdviseSink.cpp
55 lines (43 loc) · 1.55 KB
/
AdviseSink.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
////////////////////////////////////////////////////////////////////////////////
//! \file AdviseSink.cpp
//! \brief The AdviseSink class definition.
//! \author Chris Oldwood
#include "Common.hpp"
#include "AdviseSink.hpp"
#include <NCL/DDELink.hpp>
#include <NCL/DDEData.hpp>
#include <WCL/StringIO.hpp>
#include <Core/StringUtils.hpp>
#include "ValueFormatter.hpp"
#include <NCL/DDEConv.hpp>
////////////////////////////////////////////////////////////////////////////////
//! Constructor.
AdviseSink::AdviseSink(tostream& out, const ValueFormatter& formatter, CEvent& abortEvent)
: m_out(out)
, m_formatter(formatter)
, m_abortEvent(abortEvent)
{
}
////////////////////////////////////////////////////////////////////////////////
//! Destructor.
AdviseSink::~AdviseSink()
{
}
////////////////////////////////////////////////////////////////////////////////
//! Handle a link being updated.
void AdviseSink::OnAdvise(CDDELink* link, const CDDEData* value)
{
tstring server = link->Conversation()->Service().c_str();
tstring topic = link->Conversation()->Topic().c_str();
tstring item = link->Item().c_str();
TextFormat stringFormat = (link->Format() != CF_UNICODETEXT) ? ANSI_TEXT : UNICODE_TEXT;
tstring stringValue = value->GetString(stringFormat).c_str();
m_out << m_formatter.format(server, topic, item, stringValue) << std::endl;
m_out.flush();
}
////////////////////////////////////////////////////////////////////////////////
//! Handle the conversation closing.
void AdviseSink::OnDisconnect(CDDECltConv* /*conv*/)
{
m_abortEvent.Signal();
}