VR-Forces Development_Version Class Documentation
Home
Modules
Namespaces
Classes
Files
Examples
Behavior Models
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
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/DtSubjectAnnouncer.h
>
13
#include <
vrvCore/DtSubjectBinder.h
>
14
15
#include <
vrvUtil/templateUtil.h
>
16
17
#include <boost/signal.hpp>
18
#include <boost/bind.hpp>
19
20
namespace
makVrv
21
{
22
27
template
<
class
T>
28
class
DtSubjectObserver
:
public
virtual
DtSubjectBinder
29
{
30
31
public
:
32
37
DtSubjectObserver
();
38
39
virtual
~DtSubjectObserver
();
40
41
virtual
void
slot_activate
(T* subject) = 0;
42
43
virtual
void
slot_deactivate
(T* subject) = 0;
44
45
protected
:
46
47
virtual
void
connect
(
DtDe
& de);
48
49
50
};
51
52
template
<
class
T>
53
DtSubjectObserver<T>::DtSubjectObserver
()
54
{
56
BindFunction
functor =
boost::bind
(&
DtSubjectObserver<T>::connect
,
this
, _1);
57
58
myBindFunctionList.push_back(functor);
59
}
60
61
template
<
class
T>
62
DtSubjectObserver<T>::~DtSubjectObserver
()
63
{
64
65
}
66
67
template
<
class
T>
68
void
DtSubjectObserver<T>::connect
(
DtDe
& de )
69
{
73
DtSubjectAnnouncer<T>
* announcer =
DtSubjectAnnouncer<T>::findInstance
(de);
74
75
if
(announcer)
76
{
78
announcer->
signal_activate
.connect(
79
boost::bind
(&
DtSubjectObserver<T>::slot_activate
,
this
, _1));
80
82
// w/ each activated subject instance.
83
typename
std::list<T*>::iterator curIter = announcer->
activatedList
().begin();
84
typename
std::list<T*>::iterator endIter = announcer->
activatedList
().end();
85
for
(;curIter != endIter; ++curIter)
86
{
87
this->slot_activate(*curIter);
88
}
89
}
90
}
91
92
EXPORT_TEMPLATE_TYPEDEF
(
DtSubjectObserver<DtDe>
,
DtDeObserver
)
93
EXPORT_TEMPLATE_TYPEDEF
(
DtSubjectObserver
<
DtDisplay
>, DtDisplayObserver)
94
EXPORT_TEMPLATE_TYPEDEF
(
DtSubjectObserver
<
DtDeCommunicator
>,
DtDeCommunicatorObserver
)
95
}
Document ID: Generated on Mon Jul 4 01:00:18 EDT 2016 from SVN revision 166489
Copyright © 2005-2015 VT MÄK. All Rights Reserved (
www.mak.com
)