root/ossieparser/trunk/ComponentPlacement.cpp @ 10

Revision 10, 2.0 KB (checked in by balister, 9 years ago)

Initial import

Line 
1#include "ComponentPlacement.h"
2
3ComponentPlacement::ComponentPlacement() { SPDFile = NULL; }
4
5// TODO: implement exception handling //
6ComponentPlacement::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
24ComponentPlacement::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
37ComponentPlacement::~ComponentPlacement()
38{
39}
40
41void ComponentPlacement::parseElement() { this->parseFileRef( root ); }
42
43// TODO: implement exception handling //
44void 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
61ComponentInstantiation* 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 //
74void ComponentPlacement::extractFileRef( DOMElement* _elem ){}//throws SCA.CF.InvalidProfile
75
76char* ComponentPlacement::getSPDFile() const { return SPDFile; }
77
78std::vector<ComponentInstantiation*>* ComponentPlacement::getInstantiations() { return &instantiations; }
79
Note: See TracBrowser for help on using the browser.