| 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(/*true*/false), ifCompositePartOf(false), ifDomainManager(false) |
|---|
| 35 | { |
|---|
| 36 | DEBUG(4, DCDComponentPlacement, "In constructor."); |
|---|
| 37 | // DEBUG(4, DCDComponentPlacement, "WARNING: ifDeployOn is initalized to TRUE"); |
|---|
| 38 | |
|---|
| 39 | parseDeployOnDevice(elem); |
|---|
| 40 | parseCompositePartOfDevice(elem); |
|---|
| 41 | parseDPDFileName(elem); |
|---|
| 42 | parseInstantiations(elem); |
|---|
| 43 | |
|---|
| 44 | DEBUG(4, DCDComponentPlacement, "Leaving constructor."); |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | |
|---|
| 49 | DCDComponentPlacement::~DCDComponentPlacement() |
|---|
| 50 | { |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | void DCDComponentPlacement::parseDeployOnDevice(TiXmlElement *elem) |
|---|
| 55 | { |
|---|
| 56 | DEBUG(4, DCDComponentPlacement, "In parseDeployOnDevice."); |
|---|
| 57 | |
|---|
| 58 | TiXmlElement *deploy = elem->FirstChildElement("deployondevice"); |
|---|
| 59 | |
|---|
| 60 | if(deploy) { |
|---|
| 61 | deployOnDeviceID = deploy->Attribute("refid"); |
|---|
| 62 | } |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | void DCDComponentPlacement::parseCompositePartOfDevice(TiXmlElement *elem) |
|---|
| 67 | { |
|---|
| 68 | DEBUG(4, DCDComponentPlacement, "In parseCompositePartOfDevice."); |
|---|
| 69 | |
|---|
| 70 | TiXmlElement *composite = elem->FirstChildElement("compositepartofdevice"); |
|---|
| 71 | |
|---|
| 72 | if (composite) { |
|---|
| 73 | compositePartOfDeviceID = composite->Attribute("refid"); |
|---|
| 74 | } |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | void DCDComponentPlacement::parseDPDFileName(TiXmlElement *elem) |
|---|
| 79 | { |
|---|
| 80 | DEBUG(4, DCDComponentPlacement, "In DPDFileName."); |
|---|
| 81 | |
|---|
| 82 | TiXmlElement *DPD = elem->FirstChildElement("devicepkgfile"); |
|---|
| 83 | |
|---|
| 84 | if (DPD) { |
|---|
| 85 | TiXmlElement *local = DPD->FirstChildElement("localfile"); |
|---|
| 86 | DPDFile = local->Attribute("name"); |
|---|
| 87 | } |
|---|
| 88 | else |
|---|
| 89 | { |
|---|
| 90 | DEBUG(4, DCDComponentPlacement, "devicepkgfile tag not found, DPD not referenced"); |
|---|
| 91 | } |
|---|
| 92 | } |
|---|
| 93 | |
|---|
| 94 | |
|---|
| 95 | void DCDComponentPlacement::parseInstantiations(TiXmlElement *elem) |
|---|
| 96 | { |
|---|
| 97 | DEBUG(4, DCDComponentPlacement, "In parseInstantiations."); |
|---|
| 98 | |
|---|
| 99 | TiXmlElement *instance = elem->FirstChildElement("componentinstantiation"); |
|---|
| 100 | |
|---|
| 101 | std::vector <ComponentInstantiation* > _instantiations; |
|---|
| 102 | |
|---|
| 103 | for (; instance; instance = instance->NextSiblingElement()) { |
|---|
| 104 | |
|---|
| 105 | _instantiations.push_back((ComponentInstantiation* ) new DCDComponentInstantiation(instance)); |
|---|
| 106 | _instantiationId = _instantiations.back()->getID(); |
|---|
| 107 | _usageName = _instantiations.back()->getUsageName(); |
|---|
| 108 | } |
|---|
| 109 | } |
|---|
| 110 | |
|---|
| 111 | |
|---|
| 112 | const char* DCDComponentPlacement::getDMDFile() |
|---|
| 113 | { |
|---|
| 114 | return DMDFile.c_str(); |
|---|
| 115 | } |
|---|
| 116 | |
|---|
| 117 | |
|---|
| 118 | const char* DCDComponentPlacement::getDeployOnDeviceID() |
|---|
| 119 | { |
|---|
| 120 | return deployOnDeviceID.c_str(); |
|---|
| 121 | } |
|---|
| 122 | |
|---|
| 123 | |
|---|
| 124 | const char* DCDComponentPlacement::getCompositePartOfDeviceID() |
|---|
| 125 | { |
|---|
| 126 | return compositePartOfDeviceID.c_str(); |
|---|
| 127 | } |
|---|
| 128 | |
|---|
| 129 | std::string DCDComponentPlacement::getDPDFile() |
|---|
| 130 | { |
|---|
| 131 | return DPDFile.c_str(); |
|---|
| 132 | } |
|---|
| 133 | |
|---|
| 134 | |
|---|
| 135 | bool DCDComponentPlacement::isDeployOn() |
|---|
| 136 | { |
|---|
| 137 | return ifDeployOn; |
|---|
| 138 | } |
|---|
| 139 | |
|---|
| 140 | |
|---|
| 141 | bool DCDComponentPlacement::isCompositePartOf() |
|---|
| 142 | { |
|---|
| 143 | return ifCompositePartOf; |
|---|
| 144 | } |
|---|
| 145 | |
|---|
| 146 | |
|---|
| 147 | bool DCDComponentPlacement::isDomainManager() |
|---|
| 148 | { |
|---|
| 149 | return ifDomainManager; |
|---|
| 150 | } |
|---|
| 151 | |
|---|
| 152 | |
|---|
| 153 | const char *DCDComponentPlacement::getFileRefId() |
|---|
| 154 | { |
|---|
| 155 | return _fileRefId.c_str(); |
|---|
| 156 | } |
|---|
| 157 | |
|---|
| 158 | const char *DCDComponentPlacement::getInstantiationId() |
|---|
| 159 | { |
|---|
| 160 | return _instantiationId.c_str(); |
|---|
| 161 | } |
|---|
| 162 | |
|---|
| 163 | const char *DCDComponentPlacement::getUsageName() |
|---|
| 164 | { |
|---|
| 165 | return _usageName.c_str(); |
|---|
| 166 | } |
|---|