root/ossie/trunk/ossie/parser/UsesPort.cpp @ 604

Revision 604, 2.9 KB (checked in by tuan, 8 years ago)

Fix up format and some Terminate stuffs

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/UsesPort.h"
28
29#define mdel(x) if (x!=NULL) delete x, x=NULL;
30#define sweetd(x) if (x!=NULL) delete []x, x=NULL;
31
32UsesPort::UsesPort():
33Port(),
34identifier(NULL)
35{}
36
37UsesPort::UsesPort(DOMElement * _root):
38Port(_root),
39identifier(NULL)
40{
41    this->parseElement();
42}
43
44// copy constructor
45UsesPort::UsesPort(const UsesPort & _up):
46Port(_up.root),
47identifier(NULL)
48{
49    this->root = _up.root;
50    this->findBy = new FindBy (_up.root);
51
52    this->ifComponentInstantiationRef = _up.ifComponentInstantiationRef;
53    this->ifDeviceThatLoadedThisComponentRef =
54    _up.ifDeviceThatLoadedThisComponentRef;
55    this->ifDeviceUsedByThisComponentRef = _up.ifDeviceUsedByThisComponentRef;
56    this->ifFindBy = _up.ifFindBy;
57
58    this->identifier = new char[strlen (_up.identifier) + 1];
59    strcpy (this->identifier, _up.identifier);
60}
61
62
63UsesPort::~UsesPort()
64{
65    sweetd(identifier);
66}
67
68
69void UsesPort::parseElement()
70{
71    Port::parseElement();       // call the base class first
72    this->parseID(root);
73}
74
75
76void UsesPort::parseID(DOMElement * _elem)
77{
78    tmpXMLStr = XMLString::transcode("usesidentifier");
79    DOMNodeList *nodeList = _elem->getElementsByTagName(tmpXMLStr);
80    XMLString::release(&tmpXMLStr);
81
82    if (nodeList->getLength () != 0)
83    identifier = this->getTextNode((DOMElement *) nodeList->item (0));
84}
85
86
87char* UsesPort::getTextNode(DOMElement * _node)
88{
89    DOMNodeList* nodeList = _node->getChildNodes();
90
91    if (nodeList->getLength () == 0)
92    {
93        char* astr = new char[strlen("Not Specified") +1];
94        strcpy(astr, "Not Specified");
95        return astr;
96    }
97    else return XMLString::transcode(nodeList->item (0)->getNodeValue ());
98}
99
100// \note this should be const char* UsesPort::getID() const
101char* UsesPort::getID() const
102{
103    return identifier;
104}
105XMLCh* UsesPort::tmpXMLStr = NULL;
Note: See TracBrowser for help on using the browser.