File: flowsystem.cc

package info (click to toggle)
arts 1.5.9-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 8,436 kB
  • ctags: 9,848
  • sloc: ansic: 44,670; cpp: 33,776; sh: 10,486; perl: 3,470; makefile: 372; yacc: 347; lex: 160
file content (180 lines) | stat: -rw-r--r-- 4,607 bytes parent folder | download | duplicates (5)
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
    /*

    Copyright (C) 2000 Stefan Westerfeld
                       stefan@space.twc.de

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.
  
    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Library General Public License for more details.
   
    You should have received a copy of the GNU Library General Public License
    along with this library; see the file COPYING.LIB.  If not, write to
    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.

    */

#include "flowsystem.h"
#include "debug.h"

using namespace Arts;

//-------------- ScheduleNode -----------------

ScheduleNode::ScheduleNode(Object_base *object) : _nodeObject(object)
{
	//
}

ScheduleNode::~ScheduleNode()
{
	//
}

Object ScheduleNode::nodeObject()
{
	assert(_nodeObject);
	return Object::_from_base(_nodeObject->_copy());
}

RemoteScheduleNode *ScheduleNode::remoteScheduleNode()
{
	return 0;
}

void *ScheduleNode::cast(const std::string&)
{
	return 0;
}


//----------- RemoteScheduleNode -------------

RemoteScheduleNode::RemoteScheduleNode(Object_stub *stub) : ScheduleNode(stub)
{
	//
}

RemoteScheduleNode *RemoteScheduleNode::remoteScheduleNode()
{
	return this;
}

void RemoteScheduleNode::initStream(const std::string&, void *, long)
{
	// not for stub objects
	assert(false);
}

void RemoteScheduleNode::requireFlow()
{
	// stub objects can't require flow on this server (they don't live here)
	assert(false);
}

void RemoteScheduleNode::virtualize(const std::string&, ScheduleNode *,
		                            const std::string&)
{
	// (de)virtualization of ports is only implemented locally
	assert(false);
}

void RemoteScheduleNode::devirtualize(const std::string&, ScheduleNode *,
		                              const std::string&)
{
	// (de)virtualization of ports is only implemented locally
	assert(false);
}

// interface to modify the node from outside
	
void RemoteScheduleNode::start()
{
	FlowSystem remoteFs = nodeObject()._flowSystem();
	arts_return_if_fail(!remoteFs.isNull());

	remoteFs.startObject(nodeObject());
}

void RemoteScheduleNode::stop()
{
	FlowSystem remoteFs = nodeObject()._flowSystem();
	arts_return_if_fail(!remoteFs.isNull());

	remoteFs.stopObject(nodeObject());
}

void RemoteScheduleNode::connect(const std::string& port,
		                         ScheduleNode *remoteNode,
			                     const std::string& remotePort)
{
	arts_return_if_fail(remoteNode != 0);

	FlowSystem fs = nodeObject()._flowSystem();
	arts_return_if_fail(!fs.isNull());

	AttributeType flags = fs.queryFlags(nodeObject(),port);
	arts_return_if_fail(flags != 0);

	// connectObject must be called as connectObject([sourcePort], [destPort]);

	if(flags & streamOut)	// if our port is an output port, this order
	{
		fs.connectObject(nodeObject(),port,remoteNode->nodeObject(),remotePort);
	}
	else if(flags & streamIn)
	{
		FlowSystem remoteFs = remoteNode->nodeObject()._flowSystem();
		arts_return_if_fail(!remoteFs.isNull());

		remoteFs.connectObject(remoteNode->nodeObject(),
										remotePort,nodeObject(),port);
	} else {
		assert(false);
	}
}

void RemoteScheduleNode::disconnect(const std::string& port,
		                            ScheduleNode *remoteNode,
			                        const std::string& remotePort)
{
	arts_return_if_fail(remoteNode != 0);

	FlowSystem fs = nodeObject()._flowSystem();
	arts_return_if_fail(!fs.isNull());

	AttributeType flags = fs.queryFlags(nodeObject(),port);
	arts_return_if_fail(flags != 0);

	// connectObject must be called as connectObject([sourcePort], [destPort]);

	if(flags & streamOut)	// if our port is an output port, this order
	{
		fs.disconnectObject(nodeObject(),port,remoteNode->nodeObject(),remotePort);
	}
	else if(flags & streamIn)
	{
		FlowSystem remoteFs = remoteNode->nodeObject()._flowSystem();
		arts_return_if_fail(!remoteFs.isNull());

		remoteFs.disconnectObject(remoteNode->nodeObject(),
										remotePort,nodeObject(),port);
	} else {
		assert(false);
	}
}

// constant values
void RemoteScheduleNode::setFloatValue(const std::string& port, float value)
{
	FlowSystem fs = nodeObject()._flowSystem();
	arts_return_if_fail(!fs.isNull());

	fs.setFloatValue(nodeObject(), port, value);
}