File: TimerPython.i

package info (click to toggle)
robotraconteur 1.2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 101,380 kB
  • sloc: cpp: 1,149,268; cs: 87,653; java: 58,127; python: 26,897; ansic: 356; sh: 152; makefile: 90; xml: 51
file content (43 lines) | stat: -rw-r--r-- 1,416 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
namespace RobotRaconteur
{

%feature(shadow) WallTimer::WallTimer(const boost::posix_time::time_duration& period, bool oneshot, const boost::shared_ptr<RobotRaconteur::RobotRaconteurNode>& node, RobotRaconteur::AsyncTimerEventReturnDirector* handler, int32_t id)
%{
	def __init__(self,*args):
		#This is a shadowed function

		from .RobotRaconteurPythonUtil import AsyncTimerEventReturnDirectorImpl

		if (not hasattr(args[1], '__call__')): raise Exception("Handler must be callable")
		director=AsyncTimerEventReturnDirectorImpl(args[1])

		oneshot=False

		if (len(args) > 2):
			oneshot=args[2]

		if (len(args) > 3):
			node=args[3]
		else:
			node=RobotRaconteurNode.s

		this = _RobotRaconteurPython.new_WallTimer(args[0],oneshot,node,director,0)
		director.__disown__()
		try: self.this.append(this)
		except: self.this = this
%}

}

%include "Timer.i"

// cSpell: ignore sphandler

%extend RobotRaconteur::WallTimer
{
	WallTimer(const boost::posix_time::time_duration& period, bool oneshot, const boost::shared_ptr<RobotRaconteur::RobotRaconteurNode>& node, RobotRaconteur::AsyncTimerEventReturnDirector* handler, int32_t id )
	{
		boost::shared_ptr<AsyncTimerEventReturnDirector> sphandler(handler,boost::bind(&ReleaseDirector<AsyncTimerEventReturnDirector>,RR_BOOST_PLACEHOLDERS(_1),id));
		return new WallTimer(period,boost::bind(&TimerHandlerFunc,RR_BOOST_PLACEHOLDERS(_1),sphandler),oneshot,node);
	}
}