ovtkCAlgorithmScenarioImporter.cpp 27.4 KB
Newer Older
Jozef Legeny's avatar
Jozef Legeny committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#include "ovtkCAlgorithmScenarioImporter.h"

#include <vector>
#include <map>

using namespace OpenViBE;
using namespace OpenViBE::Kernel;
using namespace OpenViBE::Plugins;

using namespace OpenViBEToolkit;

namespace OpenViBEToolkit
{
	namespace
	{
16 17 18 19 20 21 22 23 24
#define _default_and_copy_constructor_1_(c,m1)                      c(void) { } c(const c& r) : m1(r.m1) { }
#define _default_and_copy_constructor_2_(c,m1,m2)                   c(void) { } c(const c& r) : m1(r.m1), m2(r.m2) { }
#define _default_and_copy_constructor_3_(c,m1,m2,m3)                c(void) { } c(const c& r) : m1(r.m1), m2(r.m2), m3(r.m3) { }
#define _default_and_copy_constructor_4_(c,m1,m2,m3,m4)             c(void) { } c(const c& r) : m1(r.m1), m2(r.m2), m3(r.m3), m4(r.m4) { }
#define _default_and_copy_constructor_5_(c,m1,m2,m3,m4,m5)          c(void) { } c(const c& r) : m1(r.m1), m2(r.m2), m3(r.m3), m4(r.m4), m5(r.m5) { }
#define _default_and_copy_constructor_6_(c,m1,m2,m3,m4,m5,m6)       c(void) { } c(const c& r) : m1(r.m1), m2(r.m2), m3(r.m3), m4(r.m4), m5(r.m5), m6(r.m6) { }
#define _default_and_copy_constructor_7_(c,m1,m2,m3,m4,m5,m6,m7)    c(void) { } c(const c& r) : m1(r.m1), m2(r.m2), m3(r.m3), m4(r.m4), m5(r.m5), m6(r.m6), m7(r.m7) { }
#define _default_and_copy_constructor_8_(c,m1,m2,m3,m4,m5,m6,m7,m8) c(void) { } c(const c& r) : m1(r.m1), m2(r.m2), m3(r.m3), m4(r.m4), m5(r.m5), m6(r.m6), m7(r.m7), m8(r.m8) { }
#define _default_and_copy_constructor_9_(c,m1,m2,m3,m4,m5,m6,m7,m8, m9) c(void) { } c(const c& r) : m1(r.m1), m2(r.m2), m3(r.m3), m4(r.m4), m5(r.m5), m6(r.m6), m7(r.m7), m8(r.m8), m9(r.m9) { }
Jozef Legeny's avatar
Jozef Legeny committed
25 26 27 28 29 30 31

		typedef struct _SInput
		{
			_default_and_copy_constructor_2_(_SInput, m_oTypeIdentifier, m_sName);
			CIdentifier m_oTypeIdentifier;
			CString m_sName;
		} SInput;
32

Jussi Lindgren's avatar
Jussi Lindgren committed
33 34 35 36 37
		typedef struct _SMessageInput
		{
			_default_and_copy_constructor_1_(_SMessageInput, m_sName);
			CString m_sName;
		} SMessageInput;
38

Jozef Legeny's avatar
Jozef Legeny committed
39 40 41 42 43 44
		typedef struct _SOutput
		{
			_default_and_copy_constructor_2_(_SOutput, m_oTypeIdentifier, m_sName);
			CIdentifier m_oTypeIdentifier;
			CString m_sName;
		} SOutput;
45

Jussi Lindgren's avatar
Jussi Lindgren committed
46 47 48 49 50 51
		typedef struct _SMessageOutput
		{
			_default_and_copy_constructor_1_(_SMessageOutput, m_sName);
			//CIdentifier m_oTypeIdentifier;
			CString m_sName;
		} SMessageOutput;
52

Jozef Legeny's avatar
Jozef Legeny committed
53 54
		typedef struct _SSetting
		{
55 56 57 58 59 60 61
			//_default_and_copy_constructor_4_(_SSetting, m_oTypeIdentifier, m_sName, m_sDefaultValue, m_sValue);
			_SSetting(void) :m_bModifiability(false) { }
			_SSetting(const _SSetting& r) : m_oTypeIdentifier(r.m_oTypeIdentifier),
				m_sName(r.m_sName),
				m_sDefaultValue(r.m_sDefaultValue),
				m_sValue(r.m_sValue),
				m_bModifiability(r.m_bModifiability) { }
Jozef Legeny's avatar
Jozef Legeny committed
62 63 64 65
			CIdentifier m_oTypeIdentifier;
			CString m_sName;
			CString m_sDefaultValue;
			CString m_sValue;
66
			boolean m_bModifiability;
Jozef Legeny's avatar
Jozef Legeny committed
67 68 69 70 71 72 73 74 75
		} SSetting;
		typedef struct _SAttribute
		{
			_default_and_copy_constructor_2_(_SAttribute, m_oIdentifier, m_sValue);
			CIdentifier m_oIdentifier;
			CString m_sValue;
		} SAttribute;
		typedef struct _SBox
		{
Jussi Lindgren's avatar
Jussi Lindgren committed
76
			_default_and_copy_constructor_9_(_SBox, m_oIdentifier, m_oAlgorithmClassIdentifier, m_sName, m_vInput, m_vOutput, m_vSetting, m_vAttribute, m_vMessageInput, m_vMessageOutput);
Jozef Legeny's avatar
Jozef Legeny committed
77 78 79 80 81 82 83
			CIdentifier m_oIdentifier;
			CIdentifier m_oAlgorithmClassIdentifier;
			CString m_sName;
			std::vector<SInput> m_vInput;
			std::vector<SOutput> m_vOutput;
			std::vector<SSetting> m_vSetting;
			std::vector<SAttribute> m_vAttribute;
Jussi Lindgren's avatar
Jussi Lindgren committed
84 85
			std::vector<SMessageInput> m_vMessageInput;
			std::vector<SMessageOutput> m_vMessageOutput;
Jozef Legeny's avatar
Jozef Legeny committed
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
		} SBox;
		typedef struct _SComment
		{
			_default_and_copy_constructor_3_(_SComment, m_oIdentifier, m_sText, m_vAttribute);
			CIdentifier m_oIdentifier;
			CString m_sText;
			std::vector<SAttribute> m_vAttribute;
		} SComment;
		typedef struct _SLinkSource
		{
			_default_and_copy_constructor_2_(_SLinkSource, m_oBoxIdentifier, m_ui32BoxOutputIndex);
			CIdentifier m_oBoxIdentifier;
			uint32 m_ui32BoxOutputIndex;
		} SLinkSource;
		typedef struct _SLinkTarget
		{
			_default_and_copy_constructor_2_(_SLinkTarget, m_oBoxIdentifier, m_ui32BoxInputIndex);
			CIdentifier m_oBoxIdentifier;
			uint32 m_ui32BoxInputIndex;
		} SLinkTarget;
		typedef struct _SLink
		{
			_default_and_copy_constructor_4_(_SLink, m_oIdentifier, m_oLinkSource, m_oLinkTarget, m_vAttribute);
			CIdentifier m_oIdentifier;
			SLinkSource m_oLinkSource;
			SLinkTarget m_oLinkTarget;
			std::vector<SAttribute> m_vAttribute;
		} SLink;
		typedef struct _SVisualisationWidget
		{
			_default_and_copy_constructor_8_(_SVisualisationWidget, m_oIdentifier, m_sName, m_ui32Type, m_oParentIdentifier, m_ui32Index, m_oBoxIdentifier, m_ui32NbChildren, m_vAttribute);
			CIdentifier m_oIdentifier;
			CString m_sName;
			uint32 m_ui32Type;
			CIdentifier m_oParentIdentifier;
			uint32 m_ui32Index;
			CIdentifier m_oBoxIdentifier;
			uint32 m_ui32NbChildren;
			std::vector<SAttribute> m_vAttribute;
		} SVisualisationWidget;
		typedef struct _SScenario
		{
Jussi Lindgren's avatar
Jussi Lindgren committed
128
			_default_and_copy_constructor_6_(_SScenario, m_vBox, m_vComment, m_vLink, m_vMessageLink, m_vAttribute, m_vVisualisationWidget);
Jozef Legeny's avatar
Jozef Legeny committed
129 130 131
			std::vector<SBox> m_vBox;
			std::vector<SComment> m_vComment;
			std::vector<SLink> m_vLink;
Jussi Lindgren's avatar
Jussi Lindgren committed
132
			std::vector<SLink> m_vMessageLink;
Jozef Legeny's avatar
Jozef Legeny committed
133 134 135 136
			std::vector<SAttribute> m_vAttribute;
			std::vector<SVisualisationWidget> m_vVisualisationWidget;
		} SScenario;

137 138 139 140 141 142 143 144 145
#undef _default_and_copy_constructor_1_
#undef _default_and_copy_constructor_2_
#undef _default_and_copy_constructor_3_
#undef _default_and_copy_constructor_4_
#undef _default_and_copy_constructor_5_
#undef _default_and_copy_constructor_6_
#undef _default_and_copy_constructor_7_
#undef _default_and_copy_constructor_8_
#undef _default_and_copy_constructor_9_
Jozef Legeny's avatar
Jozef Legeny committed
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
	};

	class CAlgorithmScenarioImporterContext : public IAlgorithmScenarioImporterContext
	{
	public:

		CAlgorithmScenarioImporterContext(IAlgorithmContext& rAlgorithmContext)
			:m_rAlgorithmContext(rAlgorithmContext)
		{
		}

		virtual boolean processStart(const CIdentifier& rIdentifier);
		virtual boolean processIdentifier(const CIdentifier& rIdentifier, const CIdentifier& rValue);
		virtual boolean processString(const CIdentifier& rIdentifier, const CString& rValue);
		virtual boolean processUInteger(const CIdentifier& rIdentifier, const uint64 ui64Value);
		virtual boolean processStop(void);

		_IsDerivedFromClass_Final_(IAlgorithmScenarioImporterContext, OV_UndefinedIdentifier);

	public:

		IAlgorithmContext& m_rAlgorithmContext;
		SScenario m_oSymbolicScenario;
	};
};

boolean CAlgorithmScenarioImporter::process(void)
{
	TParameterHandler < IScenario* > op_pScenario(this->getOutputParameter(OVTK_Algorithm_ScenarioImporter_OutputParameterId_Scenario));
	IScenario* l_pScenario=op_pScenario;
	if(!l_pScenario)
	{
178
		this->getLogManager() << LogLevel_Error << "No scenario to import to\n";
Jozef Legeny's avatar
Jozef Legeny committed
179 180 181 182 183 184 185
		return false;
	}

	TParameterHandler < IMemoryBuffer* > ip_pMemoryBuffer(this->getInputParameter(OVTK_Algorithm_ScenarioImporter_InputParameterId_MemoryBuffer));
	IMemoryBuffer* l_pMemoryBuffer=ip_pMemoryBuffer;
	if(!l_pMemoryBuffer)
	{
186
		this->getLogManager() << LogLevel_Error << "No memory buffer to import scenario from\n";
Jozef Legeny's avatar
Jozef Legeny committed
187 188 189 190 191 192
		return false;
	}

	std::map<CIdentifier, CIdentifier> l_vBoxIdMapping;
	std::map<CIdentifier, CIdentifier> l_vCommentIdMapping;
	std::map<CIdentifier, CIdentifier> l_vLinkIdMapping;
Jussi Lindgren's avatar
Jussi Lindgren committed
193
	std::map<CIdentifier, CIdentifier> l_vMessageLinkIdMapping;
Jozef Legeny's avatar
Jozef Legeny committed
194 195 196 197 198
	std::map<CIdentifier, CIdentifier> l_vVisualisationWidgetIdMapping;

	CAlgorithmScenarioImporterContext l_oContext(this->getAlgorithmContext());
	if(!this->import(l_oContext, *l_pMemoryBuffer))
	{
199
		this->getLogManager() << LogLevel_Error << "Import failed\n";
Jozef Legeny's avatar
Jozef Legeny committed
200 201 202 203 204 205 206 207 208
		return false;
	}

	SScenario& l_rSymbolicScenario=l_oContext.m_oSymbolicScenario;

	// Now build the scenario according to what has been loaded
	std::vector<SBox>::const_iterator b;
	std::vector<SComment>::const_iterator c;
	std::vector<SInput>::const_iterator i;
Jussi Lindgren's avatar
Jussi Lindgren committed
209 210
	std::vector<SMessageInput>::const_iterator mi;
	std::vector<SMessageOutput>::const_iterator mo;
Jozef Legeny's avatar
Jozef Legeny committed
211 212 213
	std::vector<SOutput>::const_iterator o;
	std::vector<SSetting>::const_iterator s;
	std::vector<SLink>::const_iterator l;
Jussi Lindgren's avatar
Jussi Lindgren committed
214
	std::vector<SLink>::const_iterator ml;
Jozef Legeny's avatar
Jozef Legeny committed
215 216 217 218 219 220 221
	std::vector<SVisualisationWidget>::const_iterator v;
	std::vector<SAttribute>::const_iterator a;
	for(b=l_rSymbolicScenario.m_vBox.begin(); b!=l_rSymbolicScenario.m_vBox.end(); b++)
	{
		IBox* l_pBox=NULL;
		CIdentifier l_oNewBoxIdentifier;

222
		l_pScenario->addBox(l_oNewBoxIdentifier, b->m_oIdentifier);
Jozef Legeny's avatar
Jozef Legeny committed
223 224 225 226 227 228 229 230
		l_pBox=l_pScenario->getBoxDetails(l_oNewBoxIdentifier);
		if(l_pBox)
		{
			l_pBox->setName(b->m_sName);

			for(i=b->m_vInput.begin(); i!=b->m_vInput.end(); i++)
			{
				l_pBox->addInput(
231 232
							i->m_sName,
							i->m_oTypeIdentifier);
Jozef Legeny's avatar
Jozef Legeny committed
233
			}
Jussi Lindgren's avatar
Jussi Lindgren committed
234 235 236 237
			//
			for(mi=b->m_vMessageInput.begin(); mi!=b->m_vMessageInput.end(); mi++)
			{
				l_pBox->addMessageInput(
238
							mi->m_sName);
Jussi Lindgren's avatar
Jussi Lindgren committed
239 240 241 242
			}
			for(mo=b->m_vMessageOutput.begin(); mo!=b->m_vMessageOutput.end(); mo++)
			{
				l_pBox->addMessageOutput(
243
							mo->m_sName);
Jussi Lindgren's avatar
Jussi Lindgren committed
244 245
			}
			//
Jozef Legeny's avatar
Jozef Legeny committed
246 247 248
			for(o=b->m_vOutput.begin(); o!=b->m_vOutput.end(); o++)
			{
				l_pBox->addOutput(
249 250
							o->m_sName,
							o->m_oTypeIdentifier);
Jozef Legeny's avatar
Jozef Legeny committed
251 252 253 254
			}
			for(s=b->m_vSetting.begin(); s!=b->m_vSetting.end(); s++)
			{
				l_pBox->addSetting(
255 256 257 258 259
							s->m_sName,
							s->m_oTypeIdentifier,
							s->m_sDefaultValue,
							-1,
							s->m_bModifiability);
Jozef Legeny's avatar
Jozef Legeny committed
260
				l_pBox->setSettingValue(
261 262
							l_pBox->getSettingCount()-1,
							s->m_sValue);
Jozef Legeny's avatar
Jozef Legeny committed
263 264 265 266
			}
			for(a=b->m_vAttribute.begin(); a!=b->m_vAttribute.end(); a++)
			{
				l_pBox->addAttribute(
267 268
							a->m_oIdentifier,
							a->m_sValue);
Jozef Legeny's avatar
Jozef Legeny committed
269 270 271 272 273 274 275 276 277 278 279 280 281
			}

			// it is important to set box algorithm at
			// last so the box listener is never called
			l_pBox->setAlgorithmClassIdentifier(b->m_oAlgorithmClassIdentifier);
		}
		l_vBoxIdMapping[b->m_oIdentifier]=l_oNewBoxIdentifier;
	}
	for(c=l_rSymbolicScenario.m_vComment.begin(); c!=l_rSymbolicScenario.m_vComment.end(); c++)
	{
		IComment* l_pComment=NULL;
		CIdentifier l_oNewCommentIdentifier;

282
		l_pScenario->addComment(l_oNewCommentIdentifier, c->m_oIdentifier);
Jozef Legeny's avatar
Jozef Legeny committed
283 284 285 286 287 288 289 290
		l_pComment=l_pScenario->getCommentDetails(l_oNewCommentIdentifier);
		if(l_pComment)
		{
			l_pComment->setText(c->m_sText);

			for(a=c->m_vAttribute.begin(); a!=c->m_vAttribute.end(); a++)
			{
				l_pComment->addAttribute(
291 292
							a->m_oIdentifier,
							a->m_sValue);
Jozef Legeny's avatar
Jozef Legeny committed
293 294 295 296 297 298 299 300 301 302
			}
		}
		l_vCommentIdMapping[c->m_oIdentifier]=l_oNewCommentIdentifier;
	}
	for(l=l_rSymbolicScenario.m_vLink.begin(); l!=l_rSymbolicScenario.m_vLink.end(); l++)
	{
		ILink* l_pLink=NULL;
		CIdentifier l_oNewLinkIdentifier;

		l_pScenario->connect(
303
			l_oNewLinkIdentifier,
Jozef Legeny's avatar
Jozef Legeny committed
304 305 306 307
			l_vBoxIdMapping[l->m_oLinkSource.m_oBoxIdentifier],
			l->m_oLinkSource.m_ui32BoxOutputIndex,
			l_vBoxIdMapping[l->m_oLinkTarget.m_oBoxIdentifier],
			l->m_oLinkTarget.m_ui32BoxInputIndex,
308
			l->m_oIdentifier);
Jozef Legeny's avatar
Jozef Legeny committed
309 310 311 312 313 314
		l_pLink=l_pScenario->getLinkDetails(l_oNewLinkIdentifier);
		if(l_pLink)
		{
			for(a=l->m_vAttribute.begin(); a!=l->m_vAttribute.end(); a++)
			{
				l_pLink->addAttribute(
315 316
							a->m_oIdentifier,
							a->m_sValue);
Jozef Legeny's avatar
Jozef Legeny committed
317 318 319 320
			}
			l_vLinkIdMapping[l->m_oIdentifier]=l_oNewLinkIdentifier;
		}
	}
321

Jussi Lindgren's avatar
Jussi Lindgren committed
322 323 324 325 326 327
	for(ml=l_rSymbolicScenario.m_vMessageLink.begin(); ml!=l_rSymbolicScenario.m_vMessageLink.end(); ml++)
	{
		ILink* l_pLink=NULL;
		CIdentifier l_oNewLinkIdentifier;

		l_pScenario->connectMessage(
328
			l_oNewLinkIdentifier,
Jussi Lindgren's avatar
Jussi Lindgren committed
329 330 331 332
			l_vBoxIdMapping[ml->m_oLinkSource.m_oBoxIdentifier],
			ml->m_oLinkSource.m_ui32BoxOutputIndex,
			l_vBoxIdMapping[ml->m_oLinkTarget.m_oBoxIdentifier],
			ml->m_oLinkTarget.m_ui32BoxInputIndex,
333
			ml->m_oIdentifier);
Jussi Lindgren's avatar
Jussi Lindgren committed
334 335 336 337 338 339
		l_pLink=l_pScenario->getMessageLinkDetails(l_oNewLinkIdentifier);
		if(l_pLink)
		{
			for(a=ml->m_vAttribute.begin(); a!=ml->m_vAttribute.end(); a++)
			{
				l_pLink->addAttribute(
340 341
							a->m_oIdentifier,
							a->m_sValue);
Jussi Lindgren's avatar
Jussi Lindgren committed
342 343 344 345
			}
			l_vMessageLinkIdMapping[ml->m_oIdentifier]=l_oNewLinkIdentifier;
		}
	}
346

Jozef Legeny's avatar
Jozef Legeny committed
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363
	for(v=l_rSymbolicScenario.m_vVisualisationWidget.begin(); v!=l_rSymbolicScenario.m_vVisualisationWidget.end(); v++)
	{
		IVisualisationWidget* l_pVisualisationWidget=NULL;
		CIdentifier l_oNewVisualisationWidgetIdentifier;
		CString l_sWidgetName = v->m_sName;
		if(EVisualisationWidgetType(v->m_ui32Type) == EVisualisationWidget_VisualisationBox)
		{
			l_sWidgetName = l_pScenario->getBoxDetails(l_vBoxIdMapping[v->m_oBoxIdentifier])->getName();
		}

		l_pScenario->getVisualisationTreeDetails().addVisualisationWidget(
			l_oNewVisualisationWidgetIdentifier,
			l_sWidgetName,
			EVisualisationWidgetType(v->m_ui32Type),
			l_vVisualisationWidgetIdMapping[v->m_oParentIdentifier],
			v->m_ui32Index,
			l_vBoxIdMapping[v->m_oBoxIdentifier],
364 365
			v->m_ui32NbChildren,
			v->m_oIdentifier);
Jozef Legeny's avatar
Jozef Legeny committed
366 367 368 369 370 371
		l_pVisualisationWidget=l_pScenario->getVisualisationTreeDetails().getVisualisationWidget(l_oNewVisualisationWidgetIdentifier);
		if(l_pVisualisationWidget)
		{
			for(a=v->m_vAttribute.begin(); a!=v->m_vAttribute.end(); a++)
			{
				l_pVisualisationWidget->addAttribute(
372 373
							a->m_oIdentifier,
							a->m_sValue);
Jozef Legeny's avatar
Jozef Legeny committed
374 375 376 377 378 379 380
			}
		}
		l_vVisualisationWidgetIdMapping[v->m_oIdentifier]=l_oNewVisualisationWidgetIdentifier;
	}
	for(a=l_rSymbolicScenario.m_vAttribute.begin(); a!=l_rSymbolicScenario.m_vAttribute.end(); a++)
	{
		l_pScenario->addAttribute(
381 382
					a->m_oIdentifier,
					a->m_sValue);
Jozef Legeny's avatar
Jozef Legeny committed
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401
	}

	return true;
}

boolean CAlgorithmScenarioImporterContext::processStart(const CIdentifier& rIdentifier)
{
	if(false) { }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_OpenViBEScenario)                         { }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_VisualisationTree)                        { }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_VisualisationWidget)                      { m_oSymbolicScenario.m_vVisualisationWidget.push_back(SVisualisationWidget()); }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_VisualisationWidget_Attributes)           {  }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_VisualisationWidget_Attribute)            { m_oSymbolicScenario.m_vVisualisationWidget.back().m_vAttribute.push_back(SAttribute()); }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Attributes)                      { }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Attribute)                       { m_oSymbolicScenario.m_vAttribute.push_back(SAttribute()); }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box_Attributes)                           { }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box_Attribute)                            { m_oSymbolicScenario.m_vBox.back().m_vAttribute.push_back(SAttribute()); }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Link_Attributes)                          { }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Link_Attribute)                           { m_oSymbolicScenario.m_vLink.back().m_vAttribute.push_back(SAttribute()); }
Jussi Lindgren's avatar
Jussi Lindgren committed
402 403
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_MessageLink_Attributes)                   { }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_MessageLink_Attribute)                    { m_oSymbolicScenario.m_vMessageLink.back().m_vAttribute.push_back(SAttribute()); }//Message
Jozef Legeny's avatar
Jozef Legeny committed
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_VisualisationWidget_Attributes)           { }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_VisualisationWidget_Attribute)            { m_oSymbolicScenario.m_vVisualisationWidget.back().m_vAttribute.push_back(SAttribute()); }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Boxes)                                    { }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box)                                      { m_oSymbolicScenario.m_vBox.push_back(SBox()); }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Comments)                                 { }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Comment)                                  { m_oSymbolicScenario.m_vComment.push_back(SComment()); }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Comment_Attributes)                       { }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Comment_Attribute)                        { m_oSymbolicScenario.m_vComment.back().m_vAttribute.push_back(SAttribute());}
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Links)                                    { }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Link)                                     { m_oSymbolicScenario.m_vLink.push_back(SLink()); }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Link_Source)                              { }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Link_Target)                              { }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box_Inputs)                               { }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box_Input)                                { m_oSymbolicScenario.m_vBox.back().m_vInput.push_back(SInput()); }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box_Outputs)                              { }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box_Output)                               { m_oSymbolicScenario.m_vBox.back().m_vOutput.push_back(SOutput()); }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box_Settings)                             { }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box_Setting)                              { m_oSymbolicScenario.m_vBox.back().m_vSetting.push_back(SSetting()); }
Jussi Lindgren's avatar
Jussi Lindgren committed
422 423 424 425 426 427 428 429 430 431
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box_MessageInputs)                               { }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box_MessageInput)                                { m_oSymbolicScenario.m_vBox.back().m_vMessageInput.push_back(SMessageInput()); }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box_MessageOutputs)                              { }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box_MessageOutput)                               { m_oSymbolicScenario.m_vBox.back().m_vMessageOutput.push_back(SMessageOutput()); }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_MessageLinks)                                    { }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_MessageLink)                                     { m_oSymbolicScenario.m_vMessageLink.push_back(SLink()); }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_MessageLink_Source)                              { }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_MessageLink_Target)                              { }
	//
	else m_rAlgorithmContext.getLogManager() << LogLevel_Warning << "(start) Unexpected node identifier " << rIdentifier << "\n";
Jozef Legeny's avatar
Jozef Legeny committed
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455

	return true;
}

boolean CAlgorithmScenarioImporterContext::processIdentifier(const CIdentifier& rIdentifier, const CIdentifier& rValue)
{
	if(false) { }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_VisualisationWidget_Attribute_Identifier) { m_oSymbolicScenario.m_vVisualisationWidget.back().m_vAttribute.back().m_oIdentifier=rValue; }

	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_VisualisationWidget_Identifier)           { m_oSymbolicScenario.m_vVisualisationWidget.back().m_oIdentifier=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_VisualisationWidget_BoxIdentifier)        { m_oSymbolicScenario.m_vVisualisationWidget.back().m_oBoxIdentifier=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_VisualisationWidget_ParentIdentifier)     { m_oSymbolicScenario.m_vVisualisationWidget.back().m_oParentIdentifier=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box_Attribute_Identifier)                 { m_oSymbolicScenario.m_vBox.back().m_vAttribute.back().m_oIdentifier=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box_Identifier)                           { m_oSymbolicScenario.m_vBox.back().m_oIdentifier=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box_AlgorithmClassIdentifier)             { m_oSymbolicScenario.m_vBox.back().m_oAlgorithmClassIdentifier=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box_Input_TypeIdentifier)                 { m_oSymbolicScenario.m_vBox.back().m_vInput.back().m_oTypeIdentifier=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box_Output_TypeIdentifier)                { m_oSymbolicScenario.m_vBox.back().m_vOutput.back().m_oTypeIdentifier=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box_Setting_TypeIdentifier)               { m_oSymbolicScenario.m_vBox.back().m_vSetting.back().m_oTypeIdentifier=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Comment_Identifier)                       { m_oSymbolicScenario.m_vComment.back().m_oIdentifier=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Comment_Attribute_Identifier)             { m_oSymbolicScenario.m_vComment.back().m_vAttribute.back().m_oIdentifier=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Link_Attribute_Identifier)                { m_oSymbolicScenario.m_vLink.back().m_vAttribute.back().m_oIdentifier=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Link_Identifier)                          { m_oSymbolicScenario.m_vLink.back().m_oIdentifier=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Link_Source_BoxIdentifier)                { m_oSymbolicScenario.m_vLink.back().m_oLinkSource.m_oBoxIdentifier=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Link_Target_BoxIdentifier)                { m_oSymbolicScenario.m_vLink.back().m_oLinkTarget.m_oBoxIdentifier=rValue; }
456

Jussi Lindgren's avatar
Jussi Lindgren committed
457 458 459 460
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_MessageLink_Attribute_Identifier)                { m_oSymbolicScenario.m_vMessageLink.back().m_vAttribute.back().m_oIdentifier=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_MessageLink_Identifier)                          { m_oSymbolicScenario.m_vMessageLink.back().m_oIdentifier=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_MessageLink_Source_BoxIdentifier)                { m_oSymbolicScenario.m_vMessageLink.back().m_oLinkSource.m_oBoxIdentifier=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_MessageLink_Target_BoxIdentifier)                { m_oSymbolicScenario.m_vMessageLink.back().m_oLinkTarget.m_oBoxIdentifier=rValue; }
461

Jussi Lindgren's avatar
Jussi Lindgren committed
462 463
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Attribute_Identifier)            { m_oSymbolicScenario.m_vAttribute.back().m_oIdentifier=rValue; }
	else m_rAlgorithmContext.getLogManager() << LogLevel_Warning << "(id) Unexpected node identifier " << rIdentifier << "\n";
Jozef Legeny's avatar
Jozef Legeny committed
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479

	return true;
}

boolean CAlgorithmScenarioImporterContext::processString(const CIdentifier& rIdentifier, const CString& rValue)
{
	if(false) { }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_VisualisationWidget_Attribute_Value)      { m_oSymbolicScenario.m_vVisualisationWidget.back().m_vAttribute.back().m_sValue=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_VisualisationWidget_Name)                 { m_oSymbolicScenario.m_vVisualisationWidget.back().m_sName=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box_Attribute_Value)                      { m_oSymbolicScenario.m_vBox.back().m_vAttribute.back().m_sValue=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box_Name)                                 { m_oSymbolicScenario.m_vBox.back().m_sName=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box_Input_Name)                           { m_oSymbolicScenario.m_vBox.back().m_vInput.back().m_sName=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box_Output_Name)                          { m_oSymbolicScenario.m_vBox.back().m_vOutput.back().m_sName=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box_Setting_Name)                         { m_oSymbolicScenario.m_vBox.back().m_vSetting.back().m_sName=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box_Setting_DefaultValue)                 { m_oSymbolicScenario.m_vBox.back().m_vSetting.back().m_sDefaultValue=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box_Setting_Value)                        { m_oSymbolicScenario.m_vBox.back().m_vSetting.back().m_sValue=rValue; }
480
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box_Setting_Modifiability)				  { m_oSymbolicScenario.m_vBox.back().m_vSetting.back().m_bModifiability=(rValue==CString("true"))?true:false; }
Jozef Legeny's avatar
Jozef Legeny committed
481 482 483
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Comment_Text)                             { m_oSymbolicScenario.m_vComment.back().m_sText=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Comment_Attribute_Value)                  { m_oSymbolicScenario.m_vComment.back().m_vAttribute.back().m_sValue=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Link_Attribute_Value)                     { m_oSymbolicScenario.m_vLink.back().m_vAttribute.back().m_sValue=rValue; }
Jussi Lindgren's avatar
Jussi Lindgren committed
484
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_MessageLink_Attribute_Value)              { m_oSymbolicScenario.m_vMessageLink.back().m_vAttribute.back().m_sValue=rValue; }
485

Jussi Lindgren's avatar
Jussi Lindgren committed
486 487 488
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Scenario_Attribute_Value)                 { m_oSymbolicScenario.m_vAttribute.back().m_sValue=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box_MessageInput_Name)                    { m_oSymbolicScenario.m_vBox.back().m_vMessageInput.back().m_sName=rValue; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Box_MessageOutput_Name)                   { m_oSymbolicScenario.m_vBox.back().m_vMessageOutput.back().m_sName=rValue; }
489

Jussi Lindgren's avatar
Jussi Lindgren committed
490
	else m_rAlgorithmContext.getLogManager() << LogLevel_Warning << "(string) Unexpected node identifier " << rIdentifier << "\n";
Jozef Legeny's avatar
Jozef Legeny committed
491 492 493 494 495 496 497 498 499 500 501 502

	return true;
}

boolean CAlgorithmScenarioImporterContext::processUInteger(const CIdentifier& rIdentifier, const uint64 ui64Value)
{
	if(false) { }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_VisualisationWidget_Type)                 { m_oSymbolicScenario.m_vVisualisationWidget.back().m_ui32Type=(uint32)ui64Value; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_VisualisationWidget_Index)                { m_oSymbolicScenario.m_vVisualisationWidget.back().m_ui32Index=(uint32)ui64Value; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_VisualisationWidget_NumChildren)          { m_oSymbolicScenario.m_vVisualisationWidget.back().m_ui32NbChildren=(uint32)ui64Value; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Link_Source_BoxOutputIndex)               { m_oSymbolicScenario.m_vLink.back().m_oLinkSource.m_ui32BoxOutputIndex=(uint32)ui64Value; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_Link_Target_BoxInputIndex)                { m_oSymbolicScenario.m_vLink.back().m_oLinkTarget.m_ui32BoxInputIndex=(uint32)ui64Value; }
Jussi Lindgren's avatar
Jussi Lindgren committed
503 504 505
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_MessageLink_Source_BoxOutputIndex)        { m_oSymbolicScenario.m_vMessageLink.back().m_oLinkSource.m_ui32BoxOutputIndex=(uint32)ui64Value; }
	else if(rIdentifier==OVTK_Algorithm_ScenarioExporter_NodeId_MessageLink_Target_BoxInputIndex)         { m_oSymbolicScenario.m_vMessageLink.back().m_oLinkTarget.m_ui32BoxInputIndex=(uint32)ui64Value; }
	else m_rAlgorithmContext.getLogManager() << LogLevel_Warning << "(uint) Unexpected node identifier " << rIdentifier << "\n";
Jozef Legeny's avatar
Jozef Legeny committed
506 507 508 509 510 511 512 513

	return true;
}

boolean CAlgorithmScenarioImporterContext::processStop(void)
{
	return true;
}