aboutsummaryrefslogtreecommitdiff
path: root/Src/Plugins/Library/ml_devices/gen_deviceprovider/deviceCommandNodeParser.cpp
blob: 8c55b6e232238f0d3086e369a311bf58e736081b (plain) (blame)
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
#include "main.h"
#include "./DeviceCommandNodeParser.h"
#include "../../xml/obj_xml.h"

DeviceCommandNodeParser::DeviceCommandNodeParser()
	: reader(NULL), test(NULL)
{
}

DeviceCommandNodeParser::~DeviceCommandNodeParser()
{
	End();
}


BOOL DeviceCommandNodeParser::Begin(obj_xml *xmlReader, TestSuite *testSuite)
{
	if (NULL != reader || NULL != test)
		return FALSE;

	if (NULL == xmlReader || NULL == testSuite) 
		return FALSE;

	reader = xmlReader;
	reader->AddRef();
		
	test = testSuite;

	reader->xmlreader_registerCallback(L"testprovider\fcommands\fcommand", this);
	
	return TRUE;
}

void DeviceCommandNodeParser::End()
{	
	if (NULL != reader)
	{
		reader->xmlreader_unregisterCallback(this);
		reader->Release();
		reader = NULL;
	}

	if (NULL != test)
		test = NULL;
}


void DeviceCommandNodeParser::Event_XmlStartElement(const wchar_t *xmlpath, const wchar_t *xmltag, ifc_xmlreaderparams *params)
{
	elementParser.Begin(reader, params);
}

void DeviceCommandNodeParser::Event_XmlEndElement(const wchar_t *xmlpath, const wchar_t *xmltag)
{
	ifc_devicecommand *result;
	if (FALSE != elementParser.End(reader, &result))
	{
		if (NULL != test)
			test->AddCommand(result);
		
		result->Release();
	}
}

void DeviceCommandNodeParser::Event_XmlError(int linenum, int errcode, const wchar_t *errstr)
{	
}

#define CBCLASS DeviceCommandNodeParser
START_DISPATCH;
VCB(ONSTARTELEMENT, Event_XmlStartElement)
VCB(ONENDELEMENT, Event_XmlEndElement)
VCB(ONERROR, Event_XmlError)
END_DISPATCH;
#undef CBCLASS