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