VR-Vantage API Documentation
Home
Modules
Namespaces
Classes
Files
Examples
Tutorials
File List
File Members
include
vrvCore
DtSubjectObserver.h
Go to the documentation of this file.
1
/******************************************************************************
2
** Copyright (c) 2010 MAK Technologies, Inc.
3
** All rights reserved.
4
******************************************************************************/
5
9
10
#pragma once
11
12
#include <
vrvCore/vrvCore.h
>
13
#include <
vrvCore/DtDe.h
>
14
#include <
vrvCore/DtSubjectAnnouncer.h
>
15
#include <
vrvCore/DtSubjectBinder.h
>
16
17
#include <
vrvUtil/templateUtil.h
>
18
19
#include <boost/signal.hpp>
20
#include <boost/bind.hpp>
21
22
namespace
makVrv
23
{
24
29
template
<
class
T>
30
class
DtSubjectObserver
:
public
virtual
DtSubjectBinder
31
{
32
33
public
:
34
39
DtSubjectObserver
();
40
41
virtual
~DtSubjectObserver
();
42
43
virtual
void
slot_activate
(
T
* subject) = 0;
44
45
virtual
void
slot_deactivate
(
T
* subject) = 0;
46
47
protected
:
48
49
virtual
void
connect
(
DtDe
& de);
50
51
52
};
53
54
template
<
class
T>
55
DtSubjectObserver<T>::DtSubjectObserver
()
56
{
58
BindFunction
functor = boost::bind(&
DtSubjectObserver<T>::connect
,
this
, _1);
59
60
myBindFunctionList.push_back(functor);
61
}
62
63
template
<
class
T>
64
DtSubjectObserver<T>::~DtSubjectObserver
()
65
{
66
67
}
68
69
template
<
class
T>
70
void
DtSubjectObserver<T>::connect
(
DtDe
& de )
71
{
75
DtSubjectAnnouncer<T>
* announcer =
DtSubjectAnnouncer<T>::findInstance
(de);
76
77
if
(announcer)
78
{
80
announcer->
signal_activate
.connect(
81
boost::bind(&
DtSubjectObserver<T>::slot_activate
,
this
, _1));
82
84
// w/ each activated subject instance.
85
typename
std::list<T*>::iterator curIter = announcer->
activatedList
().begin();
86
typename
std::list<T*>::iterator endIter = announcer->
activatedList
().end();
87
for
(;curIter != endIter; ++curIter)
88
{
89
this->slot_activate(*curIter);
90
}
91
}
92
}
93
94
EXPORT_TEMPLATE_TYPEDEF
(
DtSubjectObserver<DtDe>
,
DtDeObserver
)
95
EXPORT_TEMPLATE_TYPEDEF
(
DtSubjectObserver
<
DtDisplay
>, DtDisplayObserver)
96
EXPORT_TEMPLATE_TYPEDEF
(
DtSubjectObserver
<
DtDeCommunicator
>,
DtDeCommunicatorObserver
)
97
}
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (
www.mak.com
)