File: Wait.cpp

package info (click to toggle)
eris 1.2.1-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,360 kB
  • ctags: 1,348
  • sloc: sh: 8,289; cpp: 7,576; perl: 287; ansic: 172; makefile: 143
file content (89 lines) | stat: -rw-r--r-- 2,060 bytes parent folder | download
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#ifdef HAVE_CONFIG_H
	#include "config.h"
#endif

#include <Eris/Wait.h>

#include <Eris/atlas_utils.h>
#include <Eris/Utils.h>
#include <Eris/Connection.h>
#include <Eris/SignalDispatcher.h>

#include <Atlas/Objects/Root.h>

#include <sigc++/object_slot.h>

#include <cassert>

namespace Eris {

WaitForBase::WaitForBase(const Atlas::Message::Element &m, Connection *conn) :
		_pending(false),
		_msg(m),
		_conn(conn)
{ 
	conn->addWait(this);
}
	
void WaitForBase::fire()
{
	assert(!_pending);
	_pending = true;
	
	std::string summary(objectSummary( Atlas::atlas_cast<Atlas::Objects::Root>(_msg) ));
	//Log("firing WaitFor %p, content is %s", this, summary.c_str());
	_conn->postForDispatch(_msg);
}
	
//////////////////////////////////////////////////////////////////////////////////////////
	
WaitForDispatch::WaitForDispatch(const Atlas::Message::Element &msg,  
	const std::string &ppath,
	Dispatcher *dsp,
	Connection *conn) :
	WaitForBase(msg, conn),
	_parentPath(ppath),
	_dsp(dsp)
{
	Dispatcher *pr = conn->getDispatcherByPath(ppath);
	pr->addSubdispatch( dsp );
	dsp->addSubdispatch(new SignalDispatcher0("sig", SigC::slot(*this, &WaitForBase::fire)));
}

WaitForDispatch::WaitForDispatch(const Atlas::Objects::Root &obj,  
	const std::string &ppath,
	Dispatcher *dsp,
	Connection *conn) :
	WaitForBase(obj.asObject(), conn),
	_parentPath(ppath),
	_dsp(dsp)
{
	Dispatcher *pr = conn->getDispatcherByPath(ppath);
	assert(pr);
	pr->addSubdispatch( dsp );
	dsp->addSubdispatch(new SignalDispatcher0("sig", SigC::slot(*this, &WaitForBase::fire)));
}


WaitForDispatch::~WaitForDispatch()
{
	Dispatcher *pr = _conn->getDispatcherByPath(_parentPath);
	pr->rmvSubdispatch( _dsp );
}

//////////////////////////////////////////////////////////////////////////////////////

WaitForSignal::WaitForSignal(SigC::Signal0<void> &sig, const Atlas::Message::Element &msg,
	Connection *conn) :
	WaitForBase(msg, conn)
{
	//Eris::Log("Created WaitForSignal %p", this);
	sig.connect(SigC::slot(*this, &WaitForBase::fire));
}

WaitForSignal::~WaitForSignal()
{
	;
}

}