| 1 | #include "ComponentPlacement.h"
|
|---|
| 2 |
|
|---|
| 3 | ComponentPlacement::ComponentPlacement() { SPDFile = NULL; }
|
|---|
| 4 |
|
|---|
| 5 | // TODO: implement exception handling //
|
|---|
| 6 | ComponentPlacement::ComponentPlacement( DOMElement* _element, DOMDocument* _doc )
|
|---|
| 7 | {
|
|---|
| 8 | if( (_element != NULL) )
|
|---|
| 9 | {
|
|---|
| 10 | char* _tmp = XMLString::transcode( _element->getNodeName() );
|
|---|
| 11 |
|
|---|
| 12 | if( strcmp( _tmp, "componentplacement" ) != 0 )
|
|---|
| 13 | {
|
|---|
| 14 | //Invalid Profile
|
|---|
| 15 | }
|
|---|
| 16 | }
|
|---|
| 17 |
|
|---|
| 18 | this->doc = _doc;
|
|---|
| 19 | this->root = _element;
|
|---|
| 20 | SPDFile = NULL;
|
|---|
| 21 | this->parseElement();
|
|---|
| 22 | }
|
|---|
| 23 |
|
|---|
| 24 | ComponentPlacement::ComponentPlacement( const ComponentPlacement& _CP )
|
|---|
| 25 | {
|
|---|
| 26 | this->doc = _CP.doc;
|
|---|
| 27 |
|
|---|
| 28 | this->root= _CP.root;
|
|---|
| 29 |
|
|---|
| 30 | this->SPDFile = new char[ strlen( _CP.SPDFile ) + 1 ];
|
|---|
| 31 | strcpy( SPDFile, _CP.SPDFile );
|
|---|
| 32 |
|
|---|
| 33 | for(int i = 0; i< _CP.instantiations.size(); i++)
|
|---|
| 34 | this->instantiations.push_back( _CP.instantiations[i] );
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 | ComponentPlacement::~ComponentPlacement()
|
|---|
| 38 | {
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | void ComponentPlacement::parseElement() { this->parseFileRef( root ); }
|
|---|
| 42 |
|
|---|
| 43 | // TODO: implement exception handling //
|
|---|
| 44 | void ComponentPlacement::parseFileRef( DOMElement* _elem )
|
|---|
| 45 | {
|
|---|
| 46 |
|
|---|
| 47 | DOMNodeList* nodeList = _elem->getElementsByTagName( XMLString::transcode( "componentfileref" ) );
|
|---|
| 48 | DOMElement* elem = (DOMElement*)nodeList->item( 0 );
|
|---|
| 49 |
|
|---|
| 50 | const XMLCh* refId = elem->getAttribute( XMLString::transcode( "refid" ) );
|
|---|
| 51 |
|
|---|
| 52 | elem = doc->getElementById( refId );
|
|---|
| 53 |
|
|---|
| 54 | if (elem==NULL)
|
|---|
| 55 | {
|
|---|
| 56 | //Inavlid Profile
|
|---|
| 57 | } else
|
|---|
| 58 | extractFileRef(elem);
|
|---|
| 59 | }
|
|---|
| 60 |
|
|---|
| 61 | ComponentInstantiation* ComponentPlacement::getInstantiationById( const char* _id )
|
|---|
| 62 | {
|
|---|
| 63 | for(int i = 0; i < instantiations.size(); i++)
|
|---|
| 64 | {
|
|---|
| 65 | if( strcmp( instantiations[i]->getID(), _id ) == 0 )
|
|---|
| 66 | return instantiations[i];
|
|---|
| 67 | }
|
|---|
| 68 |
|
|---|
| 69 | return NULL;
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 | // TODO: implement extractFileRef //
|
|---|
| 73 | // TODO: implement exception handling //
|
|---|
| 74 | void ComponentPlacement::extractFileRef( DOMElement* _elem ){}//throws SCA.CF.InvalidProfile
|
|---|
| 75 |
|
|---|
| 76 | char* ComponentPlacement::getSPDFile() const { return SPDFile; }
|
|---|
| 77 |
|
|---|
| 78 | std::vector<ComponentInstantiation*>* ComponentPlacement::getInstantiations() { return &instantiations; }
|
|---|
| 79 |
|
|---|