root/ossie/trunk/ossie/parser/ComponentSupportedInterface.cpp @ 397

Revision 397, 4.4 KB (checked in by balister, 8 years ago)

Move includes to include/ossie and fixes so library still compiles

Line 
1/*******************************************************************************
2
3Copyright 2004, Virginia Polytechnic Institute and State University
4
5This file is part of the OSSIE Parser.
6
7OSSIE Parser is free software; you can redistribute it and/or modify
8it under the terms of the Lesser GNU General Public License as published by
9the Free Software Foundation; either version 2.1 of the License, or
10(at your option) any later version.
11
12OSSIE Parser is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15Lesser GNU General Public License for more details.
16
17You should have received a copy of the Lesser GNU General Public License
18along with OSSIE Parser; if not, write to the Free Software
19Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
21Even though all code is original, the architecture of the OSSIE Parser is based
22on the architecture of the CRC's SCA Reference Implementation (SCARI)
23see: http://www.crc.ca/en/html/rmsc/home/sdr/projects/scari
24
25*********************************************************************************/
26
27#include "ossie/ComponentSupportedInterface.h"
28#define mdel(x) if (x!=NULL) delete x, x=NULL;
29#define sweetd(x) if (x!=NULL) delete []x, x=NULL;
30
31/**default constructor
32*/
33ComponentSupportedInterface::ComponentSupportedInterface():
34root(NULL), identifier(NULL),
35componentInstantiationRefId(NULL),
36ifComponentInstantiationRef(false),
37ifFindBy(false),
38theFindBy(NULL)
39{}
40
41/** default constructor
42*/
43ComponentSupportedInterface::ComponentSupportedInterface(DOMElement*_element):
44root(_element), identifier(NULL),
45componentInstantiationRefId(NULL),
46ifComponentInstantiationRef(false),
47ifFindBy(false),
48theFindBy(NULL)
49{
50        this->parseElement();
51}
52
53
54ComponentSupportedInterface::
55ComponentSupportedInterface(const ComponentSupportedInterface & _csi):
56root(_csi.root), identifier(NULL),
57componentInstantiationRefId(NULL),
58ifComponentInstantiationRef(false),
59ifFindBy(false),
60theFindBy(NULL)
61{
62
63        this->identifier = new char[strlen (_csi.identifier) + 1];
64        strcpy (identifier, _csi.identifier);
65
66        this->componentInstantiationRefId =
67        new char[strlen (_csi.componentInstantiationRefId) + 1];
68        strcpy (componentInstantiationRefId, _csi.componentInstantiationRefId);
69
70        this->ifComponentInstantiationRef = _csi.ifComponentInstantiationRef;
71        this->ifFindBy = _csi.ifFindBy;
72
73        if (_csi.theFindBy != NULL) this->theFindBy = new FindBy (_csi.root);
74}
75
76
77ComponentSupportedInterface::~ComponentSupportedInterface ()
78{
79        mdel(theFindBy);
80        sweetd(componentInstantiationRefId);
81        sweetd(identifier);
82}
83
84
85void ComponentSupportedInterface::parseElement()
86{
87        parseID(root);
88        parseComponentInstantiationRef(root);
89}
90
91
92void ComponentSupportedInterface::parseID (DOMElement * _elem)
93{
94        tmpXMLStr = XMLString::transcode ("supportedidentifier");
95        DOMNodeList *nodeList = _elem->getElementsByTagName(tmpXMLStr);
96        sweetd(tmpXMLStr);
97
98        if (nodeList->getLength() != 0)
99        {
100                identifier = getTextNode((DOMElement *) nodeList->item (0));
101        }
102}
103
104void ComponentSupportedInterface::parseComponentInstantiationRef
105(DOMElement* _elem)
106{
107        tmpXMLStr = XMLString::transcode ("componentinstantiationref");
108        DOMNodeList *nodeList =_elem->getElementsByTagName(tmpXMLStr);
109        sweetd(tmpXMLStr);
110
111        if (nodeList->getLength () != 0)
112        {
113                ifComponentInstantiationRef = true;
114                DOMElement *_tmpElement = (DOMElement *) nodeList->item (0);
115
116                tmpXMLStr = XMLString::transcode("refid");
117                const XMLCh *_tmp =_tmpElement->getAttribute(tmpXMLStr);
118                sweetd(tmpXMLStr);
119                componentInstantiationRefId = XMLString::transcode (_tmp);
120        }
121}
122
123
124char* ComponentSupportedInterface::getTextNode(DOMElement * _elem)
125{
126        DOMNodeList *nodeList = _elem->getChildNodes();
127
128        if (nodeList->getLength () == 0)
129        {
130                char* astr = new char[strlen("Not Specified") +1];
131                strcpy(astr,"Not Specified");
132                return astr;
133        }
134        else return XMLString::transcode(nodeList->item (0)->getNodeValue ());
135}
136
137
138bool ComponentSupportedInterface::isComponentInstantiationRef()
139{
140        return ifComponentInstantiationRef;
141}
142
143
144bool ComponentSupportedInterface::isFindBy()
145{
146        return ifFindBy;
147}
148
149
150char* ComponentSupportedInterface::getID() const
151{
152        return identifier;
153}
154
155
156char* ComponentSupportedInterface::getComponentInstantiationRefId() const
157{
158        return componentInstantiationRefId;
159}
160
161
162FindBy* ComponentSupportedInterface::getFindBy() const
163{
164        return theFindBy;
165}
166XMLCh* ComponentSupportedInterface::tmpXMLStr = NULL;
Note: See TracBrowser for help on using the browser.