| 1 | /******************************************************************************* |
|---|
| 2 | |
|---|
| 3 | Copyright 2004, 2007 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 CRCs SCA Reference Implementation(SCARI) |
|---|
| 23 | see: http://www.crc.ca/en/html/rmsc/home/sdr/projects/scari |
|---|
| 24 | |
|---|
| 25 | *********************************************************************************/ |
|---|
| 26 | #include <iostream> |
|---|
| 27 | #include <string> |
|---|
| 28 | |
|---|
| 29 | #include "ossie/DCDComponentPlacement.h" |
|---|
| 30 | |
|---|
| 31 | #include "tinyxml.h" |
|---|
| 32 | |
|---|
| 33 | // the ifDeployOn initialization has been set from FALSE to true |
|---|
| 34 | DCDComponentPlacement::DCDComponentPlacement(TiXmlElement *elem) : ComponentPlacement(elem), ifDeployOn(false), ifCompositePartOf(false), ifDomainManager(false) |
|---|
| 35 | { |
|---|
| 36 | DEBUG(4, DCDComponentPlacement, "In constructor."); |
|---|
| 37 | |
|---|
| 38 | parseDeployOnDevice(elem); |
|---|
| 39 | parseCompositePartOfDevice(elem); |
|---|
| 40 | parseDPDFileName(elem); |
|---|
| 41 | parseInstantiations(elem); |
|---|
| 42 | |
|---|
| 43 | DEBUG(4, DCDComponentPlacement, "Leaving constructor."); |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | DCDComponentPlacement::~DCDComponentPlacement() |
|---|
| 49 | { |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | void DCDComponentPlacement::parseDeployOnDevice(TiXmlElement *elem) |
|---|
| 54 | { |
|---|
| 55 | DEBUG(4, DCDComponentPlacement, "In parseDeployOnDevice."); |
|---|
| 56 | |
|---|
| 57 | TiXmlElement *deploy = elem->FirstChildElement("deployondevice"); |
|---|
| 58 | |
|---|
| 59 | if(deploy) { |
|---|
| 60 | ifDeployOn = true; |
|---|
| 61 | deployOnDeviceID = deploy->Attribute("refid"); |
|---|
| 62 | } else { |
|---|
| 63 | DEBUG(4, DCDComponentPlacement, "deployondevice NOT found") |
|---|
| 64 | } |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | void DCDComponentPlacement::parseCompositePartOfDevice(TiXmlElement *elem) |
|---|
| 69 | { |
|---|
| 70 | DEBUG(4, DCDComponentPlacement, "In parseCompositePartOfDevice."); |
|---|
| 71 | |
|---|
| 72 | TiXmlElement *composite = elem->FirstChildElement("compositepartofdevice"); |
|---|
| 73 | |
|---|
| 74 | if (composite) { |
|---|
| 75 | ifCompositePartOf = true; |
|---|
| 76 | compositePartOfDeviceID = composite->Attribute("refid"); |
|---|
| 77 | } |
|---|
| 78 | } |
|---|
| 79 | |
|---|
| 80 | |
|---|
| 81 | void DCDComponentPlacement::parseDPDFileName(TiXmlElement *elem) |
|---|
| 82 | { |
|---|
| 83 | DEBUG(4, DCDComponentPlacement, "In DPDFileName."); |
|---|
| 84 | |
|---|
| 85 | TiXmlElement *DPD = elem->FirstChildElement("devicepkgfile"); |
|---|
| 86 | |
|---|
| 87 | if (DPD) { |
|---|
| 88 | TiXmlElement *local = DPD->FirstChildElement("localfile"); |
|---|
| 89 | DPDFile = local->Attribute("name"); |
|---|
| 90 | } |
|---|
| 91 | else |
|---|
| 92 | { |
|---|
| 93 | DEBUG(4, DCDComponentPlacement, "devicepkgfile tag not found, DPD not referenced"); |
|---|
| 94 | } |
|---|
| 95 | } |
|---|
| 96 | |
|---|
| 97 | |
|---|
| 98 | void DCDComponentPlacement::parseInstantiations(TiXmlElement *elem) |
|---|
| 99 | { |
|---|
| 100 | DEBUG(4, DCDComponentPlacement, "In parseInstantiations."); |
|---|
| 101 | |
|---|
| 102 | TiXmlElement *instance = elem->FirstChildElement("componentinstantiation"); |
|---|
| 103 | |
|---|
| 104 | std::vector <ComponentInstantiation* > _instantiations; |
|---|
| 105 | |
|---|
| 106 | for (; instance; instance = instance->NextSiblingElement()) { |
|---|
| 107 | |
|---|
| 108 | _instantiations.push_back((ComponentInstantiation* ) new DCDComponentInstantiation(instance)); |
|---|
| 109 | _instantiationId = _instantiations.back()->getID(); |
|---|
| 110 | _usageName = _instantiations.back()->getUsageName(); |
|---|
| 111 | } |
|---|
| 112 | } |
|---|
| 113 | |
|---|
| 114 | |
|---|
| 115 | const char* DCDComponentPlacement::getDMDFile() |
|---|
| 116 | { |
|---|
| 117 | return DMDFile.c_str(); |
|---|
| 118 | } |
|---|
| 119 | |
|---|
| 120 | |
|---|
| 121 | const char* DCDComponentPlacement::getDeployOnDeviceID() |
|---|
| 122 | { |
|---|
| 123 | return deployOnDeviceID.c_str(); |
|---|
| 124 | } |
|---|
| 125 | |
|---|
| 126 | |
|---|
| 127 | const char* DCDComponentPlacement::getCompositePartOfDeviceID() |
|---|
| 128 | { |
|---|
| 129 | return compositePartOfDeviceID.c_str(); |
|---|
| 130 | } |
|---|
| 131 | |
|---|
| 132 | std::string DCDComponentPlacement::getDPDFile() |
|---|
| 133 | { |
|---|
| 134 | return DPDFile.c_str(); |
|---|
| 135 | } |
|---|
| 136 | |
|---|
| 137 | |
|---|
| 138 | bool DCDComponentPlacement::isDeployOn() |
|---|
| 139 | { |
|---|
| 140 | return ifDeployOn; |
|---|
| 141 | } |
|---|
| 142 | |
|---|
| 143 | |
|---|
| 144 | bool DCDComponentPlacement::isCompositePartOf() |
|---|
| 145 | { |
|---|
| 146 | return ifCompositePartOf; |
|---|
| 147 | } |
|---|
| 148 | |
|---|
| 149 | |
|---|
| 150 | bool DCDComponentPlacement::isDomainManager() |
|---|
| 151 | { |
|---|
| 152 | return ifDomainManager; |
|---|
| 153 | } |
|---|
| 154 | |
|---|
| 155 | |
|---|
| 156 | const char *DCDComponentPlacement::getFileRefId() |
|---|
| 157 | { |
|---|
| 158 | return _fileRefId.c_str(); |
|---|
| 159 | } |
|---|
| 160 | |
|---|
| 161 | const char *DCDComponentPlacement::getInstantiationId() |
|---|
| 162 | { |
|---|
| 163 | return _instantiationId.c_str(); |
|---|
| 164 | } |
|---|
| 165 | |
|---|
| 166 | const char *DCDComponentPlacement::getUsageName() |
|---|
| 167 | { |
|---|
| 168 | return _usageName.c_str(); |
|---|
| 169 | } |
|---|