Changeset 604

Show
Ignore:
Timestamp:
10/05/05 14:34:19 (8 years ago)
Author:
tuan
Message:

Fix up format and some Terminate stuffs

Location:
ossie/trunk/ossie
Files:
20 modified

Legend:

Unmodified
Added
Removed
  • ossie/trunk/ossie/include/ossie/ComponentAssemblyParser.h

    r540 r604  
    2929 
    3030#ifdef MS_dotNET 
    31 #pragma warning( disable : 4275 ) // this could be something but i'm not sure    
     31#pragma warning( disable : 4275 ) // this could be something but i'm not sure 
    3232#pragma warning( disable : 4290 ) // there's an annoying VC7 warning that I wanted to make go away 
    3333#pragma warning( disable : 4251 ) // this is for dll interfaces 
     
    3939class OSSIEPARSER_API ComponentAssemblyParser 
    4040{ 
     41public: 
     42    ComponentAssemblyParser(); 
     43    ComponentAssemblyParser(const char*); 
     44    ComponentAssemblyParser(const ComponentAssemblyParser&); 
     45    virtual ~ComponentAssemblyParser(); 
     46 
     47    std::vector <Connection*>* getConnections(); 
     48    char* getFileName() const; 
     49    char* getID() const; 
     50    char* getName() const; 
     51 
    4152protected: 
    42         char* fileName;                           // the file name for a given DCD or SAD Profile 
    43         char* id;                                 // the id of the root node 
     53    char* fileName;                           // the file name for a given DCD or SAD Profile 
     54    char* id;                                 // the id of the root node 
    4455 
    45         char* name;                               // the name of the root node 
    46         XERCES_CPP_NAMESPACE::DOMDocument* doc; 
    47         std::vector <Connection*> connections; 
    48         void parseIdAndName(DOMElement* _root); 
    49         void parseConnections(DOMElement* _root); 
    50         char* getTextNode(DOMElement* _root); 
    51         //Just keeping a reference so we can delete it at the destructor 
    52         XercesDOMParser* parser; 
     56    char* name;                               // the name of the root node 
     57    XERCES_CPP_NAMESPACE::DOMDocument* doc; 
     58    std::vector <Connection*> connections; 
     59    void parseIdAndName(DOMElement* _root); 
     60    void parseConnections(DOMElement* _root); 
     61    char* getTextNode(DOMElement* _root); 
     62    //Just keeping a reference so we can delete it at the destructor 
     63    XercesDOMParser* parser; 
    5364 
    54 public: 
    55         ComponentAssemblyParser(); 
    56         ComponentAssemblyParser(const char *_profileName); 
    57         ComponentAssemblyParser(const ComponentAssemblyParser & _copy); 
    58         virtual ~ComponentAssemblyParser(); 
     65private: 
     66    bool IF; 
    5967 
    60         std::vector <Connection*>* getConnections(); 
    61         char *getFileName() const; 
    62         char *getID() const; 
    63         char *getName() const; 
    6468}; 
    6569#endif 
  • ossie/trunk/ossie/include/ossie/ComponentInstantiation.h

    r540 r604  
    2929 
    3030#ifdef MS_dotNET 
    31 #pragma warning( disable : 4275 ) // this could be something but i'm not sure    
    32 #pragma warning( disable : 4290 ) // there's an annoying VC7 warning that I wanted to make go away 
     31#pragma warning( disable : 4275 ) // this could be something but i'm not sure 
     32#pragma warning( disable : 4290 ) // there's an annoying VC7 warning that 
     33                                  // I wanted to make go away 
    3334#pragma warning( disable : 4251 ) // this is for dll interfaces 
    3435#endif 
     
    4647class OSSIEPARSER_API ComponentInstantiation 
    4748{ 
     49public: 
     50    ComponentInstantiation(); 
     51    ComponentInstantiation(DOMElement*); 
     52    ComponentInstantiation(const ComponentInstantiation &); 
     53    virtual ~ComponentInstantiation(); 
     54 
     55    char* getID() const; 
     56    char* getName() const; 
     57    char* toString(); 
     58    std::vector <InstantiationProperty*>* getProperties(); 
     59 
    4860protected: 
    49         DOMElement* root; 
    50         void parseElement(); 
    51         void parseID(DOMElement * _elem); 
    52         void parseName(DOMElement * _elem); 
    53         void parseProperties(DOMElement * _elem); 
    54         InstantiationProperty* parseSimpleRef(DOMElement * _elem); 
     61    DOMElement* root; 
     62    void parseElement(); 
     63    void parseID(DOMElement*); 
     64    void parseName(DOMElement*); 
     65    void parseProperties(DOMElement*); 
     66    InstantiationProperty* parseSimpleRef(DOMElement*); 
    5567 
    5668private: 
    57         char* instantiationId; 
    58         char* instantiationName; 
    59         std::vector <InstantiationProperty*> properties; 
    60         char* getTextNode(DOMElement * _elem); 
    61         static XMLCh* tmpXMLStr; 
    62 public: 
    63         ComponentInstantiation(); 
    64         ComponentInstantiation(DOMElement * _element); 
    65         ComponentInstantiation(const ComponentInstantiation & _compInst); 
    66         virtual ~ComponentInstantiation(); 
    67  
    68         char* getID() const; 
    69         char* getName() const; 
    70         char* toString(); 
    71         std::vector <InstantiationProperty*>* getProperties(); 
     69    char* instantiationId; 
     70    char* instantiationName; 
     71    std::vector <InstantiationProperty*> properties; 
     72    char* getTextNode(DOMElement*); 
     73    static XMLCh* tmpXMLStr; 
    7274}; 
    7375#endif 
  • ossie/trunk/ossie/include/ossie/ComponentSupportedInterface.h

    r397 r604  
    3232class OSSIEPARSER_API ComponentSupportedInterface 
    3333{ 
     34public: 
     35    ComponentSupportedInterface(); 
     36    ComponentSupportedInterface(DOMElement * _element); 
     37    ComponentSupportedInterface(const ComponentSupportedInterface & _csi); 
     38    ~ComponentSupportedInterface(); 
     39 
     40    char* getComponentInstantiationRefId() const; 
     41    char* getID() const; 
     42    FindBy* getFindBy() const; 
     43    bool isComponentInstantiationRef(); 
     44    bool isFindBy(); 
     45 
    3446protected: 
    35         DOMElement* root; 
    36         char* identifier; 
    37         char* componentInstantiationRefId; 
    38         bool ifComponentInstantiationRef; 
    39         bool ifFindBy; 
    40         FindBy* theFindBy; 
    41         void parseElement(); 
    42         void parseID(DOMElement * elem); 
    43         void parseComponentInstantiationRef(DOMElement * elem); 
    44         char* getTextNode(DOMElement * elem); 
     47    DOMElement* root; 
     48    char* identifier; 
     49    char* componentInstantiationRefId; 
     50    bool ifComponentInstantiationRef; 
     51    bool ifFindBy; 
     52    FindBy* theFindBy; 
     53    void parseElement(); 
     54    void parseID(DOMElement * elem); 
     55    void parseComponentInstantiationRef(DOMElement * elem); 
     56    char* getTextNode(DOMElement * elem); 
    4557 
    46 public: 
    47         ComponentSupportedInterface(); 
    48         ComponentSupportedInterface(DOMElement * _element); 
    49         ComponentSupportedInterface(const ComponentSupportedInterface & _csi); 
    50         ~ComponentSupportedInterface(); 
    51  
    52         char* getComponentInstantiationRefId() const; 
    53         char* getID() const; 
    54         FindBy* getFindBy() const; 
    55         bool isComponentInstantiationRef(); 
    56         bool isFindBy(); 
    5758private: 
    58         static XMLCh* tmpXMLStr; 
     59    static XMLCh* tmpXMLStr; 
    5960}; 
    6061#endif 
  • ossie/trunk/ossie/include/ossie/Connection.h

    r397 r604  
    3434class OSSIEPARSER_API Connection 
    3535{ 
     36public: 
     37    Connection(); 
     38    Connection(DOMElement* root); 
     39    Connection(const Connection & _conn); 
     40    ~Connection(); 
     41 
     42     char*getID() const; 
     43     FindBy* getFindBy() const; 
     44     UsesPort* getUsesPort() const; 
     45     ProvidesPort* getProvidesPort() const; 
     46     ComponentSupportedInterface*getComponentSupportedInterface() const; 
     47     bool isComponentSupportedInterface(); 
     48     bool isFindBy(); 
     49     bool isProvidesPort(); 
     50 
    3651protected: 
    37         DOMElement* element; 
    38         char* connectionId; 
    39         FindBy* findBy; 
    40         UsesPort* usesPort; 
    41         ProvidesPort* providesPort; 
    42         ComponentSupportedInterface* componentSupportedInterface; 
    43         bool ifUsesPort; 
    44         bool ifProvidesPort; 
    45         bool ifComponentSupportedInterface; 
    46         bool ifFindBy; 
    47         void parseElement(); 
    48         void parseID(DOMElement* elem); 
    49         void parseFindBy(DOMElement* elem); 
    50         void parseUsesPort(DOMElement* elem); 
    51         void parseProvidesPort(DOMElement* elem); 
    52         void parseComponentSupportedInterface(DOMElement* elem); 
     52    DOMElement* element; 
     53    char* connectionId; 
     54    FindBy* findBy; 
     55    UsesPort* usesPort; 
     56    ProvidesPort* providesPort; 
     57    ComponentSupportedInterface* componentSupportedInterface; 
     58    bool ifUsesPort; 
     59    bool ifProvidesPort; 
     60    bool ifComponentSupportedInterface; 
     61    bool ifFindBy; 
     62    void parseElement(); 
     63    void parseID(DOMElement* elem); 
     64    void parseFindBy(DOMElement* elem); 
     65    void parseUsesPort(DOMElement* elem); 
     66    void parseProvidesPort(DOMElement* elem); 
     67    void parseComponentSupportedInterface(DOMElement* elem); 
    5368 
    54 public: 
    55         Connection(); 
    56         Connection(DOMElement* root); 
    57         Connection(const Connection & _conn); 
    58         ~Connection(); 
    59  
    60          char*getID() const; 
    61          FindBy* getFindBy() const; 
    62          UsesPort* getUsesPort() const; 
    63          ProvidesPort* getProvidesPort() const; 
    64          ComponentSupportedInterface*getComponentSupportedInterface() const; 
    65          bool isComponentSupportedInterface(); 
    66          bool isFindBy(); 
    67          bool isProvidesPort(); 
    6869private: 
    69         static XMLCh* tmpXMLStr; 
     70    static XMLCh* tmpXMLStr; 
    7071}; 
    7172#endif 
  • ossie/trunk/ossie/include/ossie/DCDParser.h

    r397 r604  
    3737class OSSIEPARSER_API DCDParser:public ComponentAssemblyParser 
    3838{ 
     39public: 
     40        DCDParser(); 
     41        DCDParser(const char* _DCDFile); 
     42        DCDParser(const DCDParser & _dcdP); 
     43        virtual ~DCDParser(); 
     44 
     45        char* getDCDFilename() const; 
     46        char* getDeviceManagerSoftPkg() const; 
     47        char* getDomainManagerName() const; 
     48        char* getDomainManagerIOR() const; 
     49         
     50        DCDComponentPlacement* getDomainManagerComponent() const; 
     51 
     52        std::vector <char*>* getLocalComponents(); 
     53        std::vector <DCDComponentPlacement*>* getDeployOnComponents(); 
     54 
     55    char* toString(); 
     56 
    3957protected: 
    4058        char* deviceManagerSoftPkg; 
     
    5371        void parseDomainManager(DOMElement*  _elem); 
    5472 
    55 public: 
    56         DCDParser(); 
    57         DCDParser(const char* _DCDFile); 
    58         DCDParser(const DCDParser & _dcdP); 
    59         virtual ~DCDParser(); 
    60  
    61         char* getDCDFilename() const; 
    62         char* getDeviceManagerSoftPkg() const; 
    63         char* getDomainManagerName() const; 
    64         char* getDomainManagerIOR() const; 
    65          
    66         DCDComponentPlacement* getDomainManagerComponent() const; 
    67  
    68         std::vector <char*>* getLocalComponents(); 
    69         std::vector <DCDComponentPlacement*>* getDeployOnComponents(); 
    70  
    71         char* toString(); 
    7273private: 
    7374        static XMLCh* tmpXMLStr; 
  • ossie/trunk/ossie/include/ossie/FindBy.h

    r397 r604  
    3838{ 
    3939private: 
    40         DOMElement* root; 
    41         bool ifFindByNamingService; 
    42         bool ifFindByStringifiedObjectRef; 
    43         bool ifFindByDomainFinder; 
    44         char* findByNamingService; 
    45         char* findByStringifiedObjectRef; 
    46         char* findByDomainFinderType; 
    47         char* findByDomainFinderName; 
    48         void parseElement(); 
    49         void parseFindByDomainFinder(DOMElement * elem); 
    50         void parseFindByNamingService(DOMElement * elem); 
    51         void parseFindByStringifiedObjectRef(DOMElement * elem); 
    52         char* getTextNode(DOMElement * elem); 
     40    DOMElement* root; 
     41    bool ifFindByNamingService; 
     42    bool ifFindByStringifiedObjectRef; 
     43    bool ifFindByDomainFinder; 
     44    char* findByNamingService; 
     45    char* findByStringifiedObjectRef; 
     46    char* findByDomainFinderType; 
     47    char* findByDomainFinderName; 
     48    void parseElement(); 
     49    void parseFindByDomainFinder(DOMElement * elem); 
     50    void parseFindByNamingService(DOMElement * elem); 
     51    void parseFindByStringifiedObjectRef(DOMElement * elem); 
     52    char* getTextNode(DOMElement * elem); 
    5353 
    54         static XMLCh* tmpXMLStr; 
     54    static XMLCh* tmpXMLStr; 
    5555 
    5656public: 
    57         FindBy(); 
    58         FindBy(DOMElement * element); 
    59         FindBy(const FindBy & _fb); 
    60         ~FindBy(); 
     57    FindBy(); 
     58    FindBy(DOMElement * element); 
     59    FindBy(const FindBy & _fb); 
     60    ~FindBy(); 
    6161 
    62         char* getFindByDomainFinderName() const; 
    63         char* getFindByDomainFinderType() const; 
    64         char* getFindByNamingServiceName() const; 
    65         char* getFindByStringifiedObjectRef() const; 
    66         bool isFindByDomainFinder(); 
    67         bool isFindByNamingService(); 
    68         bool isFindByStringifiedObjectRef(); 
     62    char* getFindByDomainFinderName() const; 
     63    char* getFindByDomainFinderType() const; 
     64    char* getFindByNamingServiceName() const; 
     65    char* getFindByStringifiedObjectRef() const; 
     66    bool isFindByDomainFinder(); 
     67    bool isFindByNamingService(); 
     68    bool isFindByStringifiedObjectRef(); 
    6969}; 
    7070#endif 
  • ossie/trunk/ossie/include/ossie/InstantiationProperty.h

    r397 r604  
    3232class OSSIEPARSER_API InstantiationProperty 
    3333{ 
     34public: 
     35    InstantiationProperty(); 
     36    InstantiationProperty(const char*, const char*); 
     37    InstantiationProperty(const InstantiationProperty&); 
     38    ~InstantiationProperty(); 
     39 
     40    void setID(const char*); 
     41    void setValue(const char*); 
     42    char* toString(); 
     43    char* getID() const; 
     44    char* getValue() const; 
     45 
    3446private: 
    35         char* id; 
    36         char* value; 
    37  
    38 public: 
    39         InstantiationProperty(); 
    40         InstantiationProperty(const char *_id, const char *_value); 
    41         InstantiationProperty(const InstantiationProperty & _copy); 
    42         ~InstantiationProperty(); 
    43  
    44         void setID(const char *_id); 
    45         void setValue(const char *_value); 
    46         char* toString(); 
    47         char* getID() const; 
    48         char* getValue() const; 
     47    char* id; 
     48    char* value; 
    4949}; 
    5050#endif 
  • ossie/trunk/ossie/include/ossie/Port.h

    r397 r604  
    3232class OSSIEPARSER_API Port 
    3333{ 
     34public: 
     35    Port(); 
     36    Port(DOMElement*); 
     37    Port(const Port&); 
     38    virtual ~Port(); 
     39 
     40    char* getComponentInstantiationRefID() const 
     41    { 
     42        return componentInstantiationRefId; 
     43    } 
     44 
     45    char* getDeviceThatLoadedThisComponentRef() const 
     46    { 
     47        return deviceThatLoadedThisComponentRefId; 
     48    } 
     49 
     50    char* getDeviceUsedByThisComponentRefID() const 
     51    { 
     52        return deviceUsedByThisComponentRefId; 
     53    } 
     54 
     55    char* getDeviceUsedByThisComponentRefUsesRefID() const 
     56    { 
     57        return deviceUsedByThisComponentRefUsesRefId; 
     58    } 
     59 
     60    FindBy* getFindBy() const 
     61    { 
     62        return findBy; 
     63    } 
     64 
     65    bool isComponentInstantiationRef() const 
     66    { 
     67        return ifComponentInstantiationRef; 
     68    } 
     69 
     70    bool isDeviceThatLoadedThisComponentRef() const 
     71    { 
     72        return ifDeviceThatLoadedThisComponentRef; 
     73    } 
     74 
     75    bool isDeviceUsedByThisComponentRef() const 
     76    { 
     77        return ifDeviceUsedByThisComponentRef; 
     78    } 
     79 
    3480protected: 
    35         DOMElement* root; 
    36         FindBy* findBy; 
     81    DOMElement* root; 
     82    FindBy* findBy; 
    3783 
    38         bool ifComponentInstantiationRef; 
    39         bool ifDeviceThatLoadedThisComponentRef; 
    40         bool ifDeviceUsedByThisComponentRef; 
    41         bool ifFindBy; 
    42         char* componentInstantiationRefId; 
    43         char* deviceThatLoadedThisComponentRefId; 
    44         char* deviceUsedByThisComponentRefId; 
    45         char* deviceUsedByThisComponentRefUsesRefId; 
     84    bool ifComponentInstantiationRef; 
     85    bool ifDeviceThatLoadedThisComponentRef; 
     86    bool ifDeviceUsedByThisComponentRef; 
     87    bool ifFindBy; 
     88    char* componentInstantiationRefId; 
     89    char* deviceThatLoadedThisComponentRefId; 
     90    char* deviceUsedByThisComponentRefId; 
     91    char* deviceUsedByThisComponentRefUsesRefId; 
    4692 
    47         void parseElement(); 
    48         void parsePort(DOMElement * elem); 
    49         void parseFindBy(DOMElement * elem); 
    50         void parseComponentInstantiationRef(DOMElement * elem); 
    51         void parseDeviceUsedByThisComponentRef(DOMElement * elem); 
    52         void parseDeviceThatLoadedThisComponentRef(DOMElement * elem); 
    53  
    54 public: 
    55         Port(); 
    56         Port(DOMElement* element); 
    57         Port(const Port & _port); 
    58         virtual ~Port(); 
    59  
    60         char* getComponentInstantiationRefID() const 
    61         { 
    62                 return componentInstantiationRefId; 
    63         } 
    64  
    65         char* getDeviceThatLoadedThisComponentRef() const 
    66         { 
    67                 return deviceThatLoadedThisComponentRefId; 
    68         } 
    69  
    70         char* getDeviceUsedByThisComponentRefID() const 
    71         { 
    72                 return deviceUsedByThisComponentRefId; 
    73         } 
    74  
    75         char* getDeviceUsedByThisComponentRefUsesRefID() const 
    76         { 
    77                 return deviceUsedByThisComponentRefUsesRefId; 
    78         } 
    79  
    80         FindBy* getFindBy() const 
    81         { 
    82                 return findBy; 
    83         } 
    84  
    85         bool isComponentInstantiationRef() const 
    86         { 
    87                 return ifComponentInstantiationRef; 
    88         } 
    89  
    90         bool isDeviceThatLoadedThisComponentRef() const 
    91         { 
    92                 return ifDeviceThatLoadedThisComponentRef; 
    93         } 
    94  
    95         bool isDeviceUsedByThisComponentRef() const 
    96         { 
    97                 return ifDeviceUsedByThisComponentRef; 
    98         } 
     93    void parseElement(); 
     94    void parsePort(DOMElement * elem); 
     95    void parseFindBy(DOMElement * elem); 
     96    void parseComponentInstantiationRef(DOMElement * elem); 
     97    void parseDeviceUsedByThisComponentRef(DOMElement * elem); 
     98    void parseDeviceThatLoadedThisComponentRef(DOMElement * elem); 
    9999 
    100100private: 
    101         static XMLCh*   tmpXMLStr; 
     101    static XMLCh*       tmpXMLStr; 
    102102}; 
    103103#endif 
  • ossie/trunk/ossie/include/ossie/ProvidesPort.h

    r397 r604  
    3333{ 
    3434private: 
    35         char* identifier; 
    36         void parseElement(); 
    37         void parseID(DOMElement * _elem); 
    38         char* getTextNode(DOMElement * _node); 
     35    char* identifier; 
     36    void parseElement(); 
     37    void parseID(DOMElement * _elem); 
     38    char* getTextNode(DOMElement * _node); 
    3939 
    40         static XMLCh* tmpXMLStr; 
     40    static XMLCh* tmpXMLStr; 
    4141 
    4242public: 
    43         ProvidesPort(); 
    44         ProvidesPort(DOMElement * element); 
    45         ProvidesPort(const ProvidesPort & _pp); 
    46         ~ProvidesPort(); 
     43    ProvidesPort(); 
     44    ProvidesPort(DOMElement * element); 
     45    ProvidesPort(const ProvidesPort & _pp); 
     46    ~ProvidesPort(); 
    4747 
    48         inline char* getID() const 
    49         { 
    50                 return identifier; 
    51         } 
     48    char* getID() const; 
    5249}; 
    5350#endif 
  • ossie/trunk/ossie/include/ossie/UsesPort.h

    r397 r604  
    3232class OSSIEPARSER_API UsesPort:public Port 
    3333{ 
     34public: 
     35    UsesPort(); 
     36    UsesPort(DOMElement*); 
     37    UsesPort(const UsesPort&); 
     38    ~UsesPort(); 
     39 
     40    char* getID() const; 
     41     
    3442private: 
    35         char* identifier; 
    36         void parseElement(); 
    37         void parseID(DOMElement * _elem); 
    38         char* getTextNode(DOMElement * _node); 
     43    void parseElement(); 
     44    void parseID(DOMElement*); 
     45    char* getTextNode(DOMElement*); 
    3946 
    40         static XMLCh* tmpXMLStr; 
    41 public: 
    42         UsesPort(); 
    43         UsesPort(DOMElement * _root); 
    44         UsesPort(const UsesPort & _up); 
    45         ~UsesPort(); 
    46  
    47         char *getID () const 
    48         { 
    49             return identifier; 
    50         } 
     47    static XMLCh* tmpXMLStr; 
     48    char* identifier; 
    5149}; 
    5250#endif 
  • ossie/trunk/ossie/parser/ComponentAssemblyParser.cpp

    r464 r604  
    3434#include <string.h>     // void* memcpy(void* des, void* src, size_t n) 
    3535#endif 
    36         // it returns the pointer to des 
     36    // it returns the pointer to des 
    3737 
    3838/** A definition 
     
    4040* a pointers and assigning it to NULL. 
    4141*/ 
    42 #define mdel(x) if (x!=NULL) delete x, x=NULL; 
    43 #define sweetd(x) if (x!=NULL) delete []x, x=NULL; 
    44  
     42#define DELPTR(x) if (x!=NULL) delete x, x=NULL; 
     43#define DELARRAY(x) if (x!=NULL) delete []x, x=NULL; 
     44 
     45// this default constructor should never be called ~tp 
    4546ComponentAssemblyParser::ComponentAssemblyParser (): 
    46 fileName(NULL), id(NULL), name(NULL), doc(NULL), parser(NULL) 
    47 { 
    48         // Initialize the XML4C2 system 
    49         try 
    50         { 
    51         XMLPlatformUtils::Initialize ();         
    52         } catch (const XMLException & toCatch) 
    53         { 
    54         // printf ("Error during Xerces-c Initialization.\nException message:"); 
    55         // printf ("%s\n", toCatch.getMessage ()); 
    56         cerr<< "Error during Xerces-c Initialization."<<endl 
    57         <<"Exception message:" 
    58         << toCatch.getMessage ()<<endl; 
    59         return; 
    60         } 
    61  
     47fileName(NULL), id(NULL), name(NULL), doc(NULL), parser(NULL), IF(false) 
     48{ 
     49// Initialize the XML4C2 system 
     50 /* 
     51    try 
     52    { 
     53        XMLPlatformUtils::Initialize (); 
     54    } 
     55    catch (const XMLException & toCatch) 
     56    { 
     57        // printf ("Error during Xerces-c Initialization.\nException message:"); 
     58        // printf ("%s\n", toCatch.getMessage ()); 
     59        cerr<< "Error during Xerces-c Initialization."<<endl 
     60        <<"Exception message:" 
     61        << toCatch.getMessage ()<<endl; 
     62        return; 
     63    } 
     64 
     65    XMLPlatformUtils::Terminate(); 
     66*/ 
    6267} 
    6368 
     
    6570*/ 
    6671ComponentAssemblyParser::ComponentAssemblyParser(const char *_profileName): 
    67 fileName(NULL), id(NULL), name(NULL), doc(NULL), parser(NULL) 
    68 { 
    69         // Initialize the XML4C2 system 
    70         try 
    71         { 
    72         XMLPlatformUtils::Initialize ();         
    73         } catch (const XMLException & toCatch) 
    74         { 
    75         cerr<< "Error during Xerces-c Initialization."<<endl 
    76         <<"Exception message:" 
    77         << toCatch.getMessage ()<<endl; 
    78         return; 
    79         } 
    80  
    81         //note: strlen and strcpy are POSIX compliant 
    82         this->fileName = new char[strlen (_profileName) + 1]; 
    83         strcpy(this->fileName, _profileName); 
    84  
    85         string tstr=".";                // C++ string 
    86         tstr.append(_profileName); 
    87  
    88         parser = new XercesDOMParser(); 
    89         parser->parse (tstr.c_str()); 
    90          
    91         // getDocument returns a pointer to the root document 
    92         // this pointer is owned by the parser 
    93         // So dont delete "doc" 
    94         doc = parser->getDocument(); 
    95         parseIdAndName (doc->getDocumentElement ()); 
    96         parseConnections (doc->getDocumentElement ()); 
     72fileName(NULL), id(NULL), name(NULL), doc(NULL), parser(NULL), IF(false) 
     73{ 
     74    // Initialize the XML4C2 system 
     75    try 
     76    { 
     77        XMLPlatformUtils::Initialize(); 
     78    } 
     79    catch (const XMLException & toCatch) 
     80    { 
     81        cerr<< "Error during Xerces-c Initialization."<<endl 
     82        <<"Exception message:" 
     83        << toCatch.getMessage ()<<endl; 
     84        return; 
     85    } 
     86 
     87    IF=true; 
     88    //note: strlen and strcpy are POSIX compliant 
     89    this->fileName = new char[strlen (_profileName) + 1]; 
     90    strcpy(this->fileName, _profileName); 
     91 
     92    string tstr=".";            // C++ string 
     93    tstr.append(_profileName); 
     94 
     95    parser = new XercesDOMParser(); 
     96    parser->parse (tstr.c_str()); 
     97     
     98    // getDocument returns a pointer to the root document 
     99    // this pointer is owned by the parser 
     100    // So dont delete "doc" 
     101    doc = parser->getDocument(); 
     102    parseIdAndName (doc->getDocumentElement ()); 
     103    parseConnections (doc->getDocumentElement ()); 
     104 
     105//    doc->release();  // parser cleans itself 
     106//    XMLPlatformUtils::Terminate();  // now it is safe to call Terminate 
    97107} 
    98108 
     
    101111*/ 
    102112ComponentAssemblyParser::ComponentAssemblyParser (const ComponentAssemblyParser & _copy): 
    103 fileName(NULL), id(NULL), name(NULL), doc(NULL), parser(NULL) 
    104 { 
    105         fileName = new char[strlen (_copy.fileName) + 1]; 
    106         strcpy(fileName, _copy.fileName); 
    107  
    108         name = new char[strlen (_copy.name) + 1]; 
    109         strcpy (name, _copy.name); 
    110  
    111         id = new char[strlen (_copy.id) + 1]; 
    112         strcpy (id, _copy.id); 
    113  
    114         string tstr="."; 
    115         tstr.append(fileName); 
    116  
    117         parser = new XercesDOMParser; 
    118         parser->parse(tstr.c_str()); 
    119         doc = parser->getDocument (); 
    120         parseIdAndName (doc->getDocumentElement ()); 
    121         parseConnections (doc->getDocumentElement ()); 
     113fileName(NULL), id(NULL), name(NULL), doc(NULL), parser(NULL), IF(false) 
     114{ 
     115    fileName = new char[strlen (_copy.fileName) + 1]; 
     116    strcpy(fileName, _copy.fileName); 
     117 
     118    name = new char[strlen (_copy.name) + 1]; 
     119    strcpy (name, _copy.name); 
     120 
     121    id = new char[strlen (_copy.id) + 1]; 
     122    strcpy (id, _copy.id); 
     123 
     124    string tstr="."; 
     125    tstr.append(fileName); 
     126 
     127    parser = new XercesDOMParser; 
     128    parser->parse(tstr.c_str()); 
     129    doc = parser->getDocument(); 
     130    parseIdAndName (doc->getDocumentElement ()); 
     131    parseConnections (doc->getDocumentElement ()); 
    122132} 
    123133 
     
    132142ComponentAssemblyParser::~ComponentAssemblyParser () 
    133143{ 
    134         sweetd(fileName); 
    135         sweetd(id); 
    136         sweetd(name); 
    137  
    138 //      if (doc!=NULL) doc->release();  // seg fault! 
    139         //doc = NULL; 
    140         //parser->resetDocumentPool(); 
    141  
    142         if (parser!=NULL) mdel(parser); 
    143  
    144 //      for (unsigned int i=0; i < connections.size(); i++)     // Application_impl.cpp in ossiecf uses these connections :-( 
     144    DELARRAY(fileName); 
     145    DELARRAY(id); 
     146    DELARRAY(name); 
     147    if (IF)     // Initialization Flag 
     148    { 
     149        doc->release();  // parser cleans itself 
     150        XMLPlatformUtils::Terminate();  // now it is safe to call Terminate 
     151    } 
     152 
     153// Application_impl.cpp in ossiecf uses these connections :-( 
     154//      for (unsigned int i=0; i < connections.size(); i++) 
    145155//      { 
    146 //              mdel(connections[i]); 
    147 //      } 
    148  
    149         XMLPlatformUtils::Terminate(); 
    150 } 
    151  
    152  
    153 char* ComponentAssemblyParser::getTextNode(DOMElement * _root) 
    154 { 
    155         DOMNodeList *nodeList = _root->getChildNodes(); 
    156  
    157         if (nodeList->getLength() == 0) 
    158         { 
    159                 char* astr = new char[strlen("Not Specified") +1]; 
    160                 strcpy(astr,"Not Specified"); 
    161                 return astr; 
    162         } 
    163         else return XMLString::transcode(nodeList->item(0)->getNodeValue()); 
     156//              DELPTR(connections[i]); 
     157//    } 
     158} 
     159 
     160 
     161char* ComponentAssemblyParser::getTextNode(DOMElement* _root) 
     162{ 
     163    DOMNodeList* nodeList = _root->getChildNodes(); 
     164 
     165    if (nodeList->getLength() == 0) 
     166    { 
     167        char* astr = new char[strlen("Not Specified") +1]; 
     168        strcpy(astr,"Not Specified"); 
     169        return astr; 
     170    } 
     171    else return XMLString::transcode(nodeList->item(0)->getNodeValue()); 
    164172} 
    165173 
     
    168176{ 
    169177 
    170         XMLCh* tmpXMLStr; 
    171  
    172         tmpXMLStr = XMLString::transcode("name"); 
    173         const XMLCh *_name = _root->getAttribute(tmpXMLStr); 
    174         XMLString::release(&tmpXMLStr); 
    175  
    176         tmpXMLStr = XMLString::transcode("id"); 
    177         const XMLCh *_id = _root->getAttribute(tmpXMLStr); 
    178         XMLString::release(&tmpXMLStr); 
    179  
    180         // \note XMLString::transcode() returns a pointer to 
    181         // a buffer of chars and expects the caller to clean 
    182         // it up 
    183  
    184         // So we check the pointers before we allocate any 
    185         // new memory to avoid dangling pointer 
    186         /// \todo Have someone explain this me me, PJB 
    187         if (name!=NULL) delete []name; name = XMLString::transcode (_name); 
    188         if (id!=NULL) delete []id; id = XMLString::transcode (_id); 
    189 } 
    190  
    191  
    192 void ComponentAssemblyParser::parseConnections (DOMElement * _root) 
    193 { 
    194         XMLCh* tmpXMLStr; 
    195  
    196         tmpXMLStr = XMLString::transcode("connections"); 
    197         DOMNodeList* _connections = _root->getElementsByTagName(tmpXMLStr); 
    198         XMLString::release(&tmpXMLStr); 
    199 //      delete []tmpXMLStr, tmpXMLStr = NULL; 
    200          
    201         // \remarks Dont do this because it is...leaky! 
    202         // DOMNodeList *_connections = 
    203         // _root->getElementsByTagName (XMLString::transcode ("connections")); 
    204  
    205         if( _connections->getLength() > 0) 
    206         { 
    207         DOMElement *_connection = (DOMElement* ) _connections->item (0); 
    208  
    209         tmpXMLStr = XMLString::transcode("connectinterface"); 
    210         DOMNodeList *_connectionsList = _connection->getElementsByTagName(tmpXMLStr); 
    211         XMLString::release(&tmpXMLStr); 
    212  
    213         for (unsigned int i = 0; i < _connectionsList->getLength (); i++) 
    214         this->connections.push_back(new Connection ((DOMElement *) 
    215         _connectionsList->item (i))); 
    216         } 
    217 } 
    218  
    219 /** Returns a pointer to a list of Connection 
    220         */ 
     178    XMLCh* tmpXMLStr; 
     179 
     180    tmpXMLStr = XMLString::transcode("name"); 
     181    const XMLCh* _name = _root->getAttribute(tmpXMLStr); 
     182    XMLString::release(&tmpXMLStr); 
     183 
     184    tmpXMLStr = XMLString::transcode("id"); 
     185    const XMLCh* _id = _root->getAttribute(tmpXMLStr); 
     186    XMLString::release(&tmpXMLStr); 
     187 
     188    // \note XMLString::transcode() returns a pointer to 
     189    // a buffer of chars and expects the caller to clean 
     190    // it up 
     191 
     192    // So we check the pointers before we allocate any 
     193    // new memory to avoid mem leak 
     194    /// \todo Have someone explain this me, PJB 
     195    if (name!=NULL) delete []name; name = XMLString::transcode (_name); 
     196    if (id!=NULL) delete []id; id = XMLString::transcode (_id); 
     197} 
     198 
     199 
     200void ComponentAssemblyParser::parseConnections(DOMElement * _root) 
     201{ 
     202    XMLCh* tmpXMLStr; 
     203 
     204    tmpXMLStr = XMLString::transcode("connections"); 
     205    DOMNodeList* _connections = _root->getElementsByTagName(tmpXMLStr); 
     206    XMLString::release(&tmpXMLStr); 
     207     
     208    // \remarks Dont do this because it is...leaky! 
     209    // DOMNodeList *_connections = 
     210    // _root->getElementsByTagName (XMLString::transcode ("connections")); 
     211 
     212    if( _connections->getLength() > 0) 
     213    { 
     214        DOMElement* _connection = (DOMElement* ) _connections->item (0); 
     215 
     216        tmpXMLStr = XMLString::transcode("connectinterface"); 
     217        DOMNodeList *_connectionsList = _connection->getElementsByTagName(tmpXMLStr); 
     218        XMLString::release(&tmpXMLStr); 
     219 
     220        for (unsigned int i = 0; i < _connectionsList->getLength (); i++) 
     221        this->connections.push_back(new Connection ((DOMElement *) 
     222        _connectionsList->item (i))); 
     223    } 
     224} 
     225 
     226/** 
     227 * @return a pointer to a list of Connection 
     228 * i hate this! ~tp 
     229*/ 
    221230std::vector <Connection*>* ComponentAssemblyParser::getConnections() 
    222231{ 
    223         return &connections; 
     232    return &connections; 
    224233} 
    225234 
     
    227236char* ComponentAssemblyParser::getFileName() const 
    228237{ 
    229         return this->fileName; 
     238    return this->fileName; 
    230239} 
    231240 
     
    233242char* ComponentAssemblyParser::getID() const 
    234243{ 
    235         return this->id; 
     244    return this->id; 
    236245} 
    237246 
     
    239248char* ComponentAssemblyParser::getName() const 
    240249{ 
    241         return this->name; 
    242 } 
     250    return this->name; 
     251} 
  • ossie/trunk/ossie/parser/ComponentInstantiation.cpp

    r397 r604  
    2626 
    2727#include "ossie/ComponentInstantiation.h" 
    28 #define mdel(x) if (x!=NULL) delete x, x=NULL; 
    29 #define sweetd(x) if (x!=NULL) delete []x, x=NULL; 
     28#define DELPTR(x) if (x!=NULL) delete x, x=NULL; 
     29#define DELARRAY(x) if (x!=NULL) delete []x, x=NULL; 
    3030 
    3131ComponentInstantiation::ComponentInstantiation (): 
     
    3333{} 
    3434 
    35  
    36 ComponentInstantiation::ComponentInstantiation (DOMElement * _element): 
     35ComponentInstantiation::ComponentInstantiation (DOMElement* _element): 
    3736root(_element), instantiationId(NULL), instantiationName(NULL) 
    3837{ 
    39         this->parseElement(); 
    40 } 
    41  
     38    this->parseElement(); 
     39} 
    4240 
    4341ComponentInstantiation::ComponentInstantiation 
     
    4543root(_compInst.root), instantiationId(NULL), instantiationName(NULL) 
    4644{ 
    47         this->instantiationId = new char[strlen (_compInst.instantiationId) + 1]; 
    48         strcpy (instantiationId, _compInst.instantiationId); 
    49  
    50         this->instantiationName = new char[strlen (_compInst.instantiationName) + 1]; 
    51         strcpy (instantiationName, _compInst.instantiationName); 
    52  
    53         for (unsigned int i = 0; i < _compInst.properties.size (); i++) 
    54         this->properties.push_back (_compInst.properties[i]); 
    55 } 
    56  
    57 ComponentInstantiation::~ComponentInstantiation () 
    58 { 
    59         sweetd(instantiationId); 
    60         sweetd(instantiationName); 
    61  
    62         for (unsigned int i=0; i< properties.size(); i++)       // deep clean 
    63         { 
    64                 mdel(properties[i]); 
    65         } 
     45    this->instantiationId = new char[strlen (_compInst.instantiationId) + 1]; 
     46    strcpy (instantiationId, _compInst.instantiationId); 
     47 
     48    this->instantiationName = new char[strlen (_compInst.instantiationName) + 1]; 
     49    strcpy (instantiationName, _compInst.instantiationName); 
     50 
     51    for (unsigned int i = 0; i < _compInst.properties.size (); i++) 
     52    this->properties.push_back (_compInst.properties[i]); 
     53} 
     54 
     55ComponentInstantiation::~ComponentInstantiation() 
     56{ 
     57    DELARRAY(instantiationId); 
     58    DELARRAY(instantiationName); 
     59 
     60    for (unsigned int i=0; i< properties.size(); i++)   // deep clean 
     61    { 
     62        DELPTR(properties[i]); 
     63    } 
    6664} 
    6765 
     
    6967void ComponentInstantiation::parseElement() 
    7068{ 
    71         parseID(root); 
    72         parseName(root); 
    73         parseProperties(root); 
     69    parseID(root); 
     70    parseName(root); 
     71    parseProperties(root); 
    7472} 
    7573 
    7674void ComponentInstantiation::parseID(DOMElement * _elem) 
    7775{ 
    78         tmpXMLStr = XMLString::transcode("id"); 
    79         const XMLCh *_id = _elem->getAttribute(tmpXMLStr); 
    80         sweetd(tmpXMLStr); 
    81         this->instantiationId = XMLString::transcode(_id); 
     76    tmpXMLStr = XMLString::transcode("id"); 
     77    const XMLCh *_id = _elem->getAttribute(tmpXMLStr); 
     78    XMLString::release(&tmpXMLStr); 
     79    this->instantiationId = XMLString::transcode(_id); 
    8280} 
    8381 
     
    8583void ComponentInstantiation::parseName(DOMElement * _elem) 
    8684{ 
    87         tmpXMLStr = XMLString::transcode("usagename"); 
    88         DOMNodeList* nodeList = _elem->getElementsByTagName(tmpXMLStr); 
    89         sweetd(tmpXMLStr); 
    90  
    91         if (nodeList->getLength() != 0) 
    92         { 
    93                 DOMElement* elem = (DOMElement*) nodeList->item(0); 
    94                 this->instantiationName = getTextNode(elem); 
    95         } 
     85    tmpXMLStr = XMLString::transcode("usagename"); 
     86    DOMNodeList* nodeList = _elem->getElementsByTagName(tmpXMLStr); 
     87    XMLString::release(&tmpXMLStr); 
     88 
     89    if (nodeList->getLength() != 0) 
     90    { 
     91        DOMElement* elem = (DOMElement*) nodeList->item(0); 
     92        this->instantiationName = getTextNode(elem); 
     93    } 
    9694} 
    9795 
     
    9997void ComponentInstantiation::parseProperties(DOMElement * _elem) 
    10098{ 
    101         tmpXMLStr = XMLString::transcode("componentproperties"); 
    102         DOMNodeList* nodeList =  _elem->getElementsByTagName(tmpXMLStr); 
    103         sweetd(tmpXMLStr); 
    104  
    105         if (nodeList->getLength() != 0) 
    106         { 
    107                 DOMElement *elem = (DOMElement *) nodeList->item (0); 
    108                 tmpXMLStr = XMLString::transcode("simpleref"); 
    109                 nodeList = elem->getElementsByTagName(tmpXMLStr); 
    110                 sweetd(tmpXMLStr); 
    111  
    112                 for (unsigned int i = 0; i < nodeList->getLength (); i++) 
    113                 { 
    114                         InstantiationProperty *_tmp = parseSimpleRef ((DOMElement *) nodeList->item (i)); 
    115                         properties.push_back (_tmp); 
    116                 } 
    117         } 
     99    tmpXMLStr = XMLString::transcode("componentproperties"); 
     100    DOMNodeList* nodeList =  _elem->getElementsByTagName(tmpXMLStr); 
     101    XMLString::release(&tmpXMLStr); 
     102 
     103    if (nodeList->getLength() != 0) 
     104    { 
     105        DOMElement *elem = (DOMElement *) nodeList->item (0); 
     106        tmpXMLStr = XMLString::transcode("simpleref"); 
     107        nodeList = elem->getElementsByTagName(tmpXMLStr); 
     108        XMLString::release(&tmpXMLStr); 
     109 
     110        InstantiationProperty *_tmp; 
     111        for (unsigned int i = 0; i < nodeList->getLength (); i++) 
     112        { 
     113                _tmp = parseSimpleRef ((DOMElement *) nodeList->item (i)); 
     114                properties.push_back(_tmp); 
     115        } 
     116    } 
    118117} 
    119118 
     
    121120InstantiationProperty* ComponentInstantiation::parseSimpleRef(DOMElement * _elem) 
    122121{ 
    123         tmpXMLStr = XMLString::transcode("refid"); 
    124         const XMLCh *_propId = _elem->getAttribute(tmpXMLStr); 
    125         sweetd(tmpXMLStr); 
    126         tmpXMLStr = XMLString::transcode("value"); 
    127         const XMLCh *_propVal = _elem->getAttribute(tmpXMLStr); 
    128         sweetd(tmpXMLStr); 
    129  
    130         char* tmpStr1 = XMLString::transcode(_propId); 
    131         char* tmpStr2 = XMLString::transcode(_propVal); 
    132         InstantiationProperty* property = new InstantiationProperty(tmpStr1,tmpStr2); 
    133  
    134         delete []tmpStr1; 
    135         delete []tmpStr2; 
    136  
    137         return property; 
     122    tmpXMLStr = XMLString::transcode("refid"); 
     123    const XMLCh *_propId = _elem->getAttribute(tmpXMLStr); 
     124    XMLString::release(&tmpXMLStr); 
     125    tmpXMLStr = XMLString::transcode("value"); 
     126    const XMLCh *_propVal =     _elem->getAttribute(tmpXMLStr); 
     127    XMLString::release(&tmpXMLStr); 
     128 
     129    char* tmpStr1 = XMLString::transcode(_propId); 
     130    char* tmpStr2 = XMLString::transcode(_propVal); 
     131    InstantiationProperty* property = new InstantiationProperty(tmpStr1,tmpStr2); 
     132 
     133    delete []tmpStr1; 
     134    delete []tmpStr2; 
     135 
     136    return property; 
    138137} 
    139138 
     
    141140char* ComponentInstantiation::getTextNode(DOMElement * _elem) 
    142141{ 
    143         DOMNodeList *nodeList = _elem->getChildNodes (); 
    144  
    145         if (nodeList->getLength () == 0) 
    146         { 
    147                 char* astr = new char[strlen("Not Specified") +1]; 
    148                 strcpy(astr,"Not Specified"); 
    149                 return astr; 
    150         } 
    151         else return XMLString::transcode (nodeList->item (0)->getNodeValue ()); 
     142    DOMNodeList *nodeList = _elem->getChildNodes (); 
     143 
     144    if (nodeList->getLength () == 0) 
     145    { 
     146        char* astr = new char[strlen("Not Specified") +1]; 
     147        strcpy(astr,"Not Specified"); 
     148        return astr; 
     149    } 
     150    else return XMLString::transcode (nodeList->item (0)->getNodeValue ()); 
    152151} 
    153152 
     
    155154char* ComponentInstantiation::toString() 
    156155{ 
    157         std::vector <InstantiationProperty*>* propertyArray; 
    158  
    159         char *str = new char[MAX_BUFFER];       // the caller must release this 
    160  
    161         strcpy (str, "\n        ID="); 
    162         str = strcat (str, getID ()); 
    163         str = strcat (str, "\n  Name="); 
    164         str = strcat (str, getName ()); 
    165  
    166         propertyArray = getProperties (); 
    167  
    168         if (propertyArray->size () > 0) 
    169         { 
    170                 str = strcat (str, "\n     Propert"); 
    171  
    172                 if (propertyArray->size () == 1) str = strcat (str, "y"); 
    173                 else str = strcat (str, "ies"); 
    174  
    175                 for (unsigned int i = 0; i < propertyArray->size (); i++) 
    176                 { 
    177                         str = strcat (str, "\n       ["); 
    178                         str = strcat (str, (char *) i); 
    179                         str = strcat (str, "]"); 
    180                         str = strcat (str, (*propertyArray)[i]->getID ()); 
    181                 } 
    182         } 
    183         else str = strcat (str, "\n     There are no properties"); 
    184  
    185         return str; 
     156    std::vector <InstantiationProperty*>* propertyArray; 
     157 
     158    char *str = new char[MAX_BUFFER];   // the caller must release this 
     159 
     160    strcpy (str, "\n    ID="); 
     161    str = strcat (str, getID ()); 
     162    str = strcat (str, "\n      Name="); 
     163    str = strcat (str, getName ()); 
     164 
     165    propertyArray = getProperties (); 
     166 
     167    if (propertyArray->size () > 0) 
     168    { 
     169        str = strcat (str, "\n     Propert"); 
     170 
     171        if (propertyArray->size () == 1) str = strcat (str, "y"); 
     172        else str = strcat (str, "ies"); 
     173 
     174        for (unsigned int i = 0; i < propertyArray->size (); i++) 
     175        { 
     176                str = strcat (str, "\n       ["); 
     177                str = strcat (str, (char *) i); 
     178                str = strcat (str, "]"); 
     179                str = strcat (str, (*propertyArray)[i]->getID ()); 
     180        } 
     181    } 
     182    else str = strcat (str, "\n     There are no properties"); 
     183 
     184    return str; 
    186185} 
    187186 
     
    189188char* ComponentInstantiation::getID() const 
    190189{ 
    191         return this->instantiationId; 
     190    return this->instantiationId; 
    192191} 
    193192 
     
    195194char* ComponentInstantiation::getName() const 
    196195{ 
    197         return this->instantiationName; 
     196    return this->instantiationName; 
    198197} 
    199198 
     
    201200std::vector <InstantiationProperty*>* ComponentInstantiation::getProperties() 
    202201{ 
    203         return &properties; 
     202    return &properties; 
    204203} 
    205204XMLCh* ComponentInstantiation::tmpXMLStr = NULL; 
  • ossie/trunk/ossie/parser/ComponentSupportedInterface.cpp

    r397 r604  
    2626 
    2727#include "ossie/ComponentSupportedInterface.h" 
    28 #define mdel(x) if (x!=NULL) delete x, x=NULL; 
    29 #define sweetd(x) if (x!=NULL) delete []x, x=NULL; 
     28#define DELPTR(x) if (x!=NULL) delete x, x=NULL; 
     29#define DELARRAY(x) if (x!=NULL) delete []x, x=NULL; 
    3030 
    3131/**default constructor 
     
    4848theFindBy(NULL) 
    4949{ 
    50         this->parseElement(); 
     50    this->parseElement(); 
    5151} 
    5252 
     
    6161{ 
    6262 
    63         this->identifier = new char[strlen (_csi.identifier) + 1]; 
    64         strcpy (identifier, _csi.identifier); 
     63    this->identifier = new char[strlen (_csi.identifier) + 1]; 
     64    strcpy (identifier, _csi.identifier); 
    6565 
    66         this->componentInstantiationRefId = 
    67         new char[strlen (_csi.componentInstantiationRefId) + 1]; 
    68         strcpy (componentInstantiationRefId, _csi.componentInstantiationRefId); 
     66    this->componentInstantiationRefId = 
     67    new char[strlen (_csi.componentInstantiationRefId) + 1]; 
     68    strcpy (componentInstantiationRefId, _csi.componentInstantiationRefId); 
    6969 
    70         this->ifComponentInstantiationRef = _csi.ifComponentInstantiationRef; 
    71         this->ifFindBy = _csi.ifFindBy; 
     70    this->ifComponentInstantiationRef = _csi.ifComponentInstantiationRef; 
     71    this->ifFindBy = _csi.ifFindBy; 
    7272 
    73         if (_csi.theFindBy != NULL) this->theFindBy = new FindBy (_csi.root); 
     73    if (_csi.theFindBy != NULL) this->theFindBy = new FindBy (_csi.root); 
    7474} 
    7575 
     
    7777ComponentSupportedInterface::~ComponentSupportedInterface () 
    7878{ 
    79         mdel(theFindBy); 
    80         sweetd(componentInstantiationRefId); 
    81         sweetd(identifier); 
     79    DELPTR(theFindBy); 
     80    DELARRAY(componentInstantiationRefId); 
     81    DELARRAY(identifier); 
    8282} 
    8383 
     
    8585void ComponentSupportedInterface::parseElement() 
    8686{ 
    87         parseID(root); 
    88         parseComponentInstantiationRef(root); 
     87    parseID(root); 
     88    parseComponentInstantiationRef(root); 
    8989} 
    9090 
     
    9292void ComponentSupportedInterface::parseID (DOMElement * _elem) 
    9393{ 
    94         tmpXMLStr = XMLString::transcode ("supportedidentifier");  
    95         DOMNodeList *nodeList = _elem->getElementsByTagName(tmpXMLStr); 
    96         sweetd(tmpXMLStr); 
     94    tmpXMLStr = XMLString::transcode("supportedidentifier"); 
     95    DOMNodeList *nodeList = _elem->getElementsByTagName(tmpXMLStr); 
     96    XMLString::release(&tmpXMLStr); 
    9797 
    98         if (nodeList->getLength() != 0) 
    99         { 
    100                 identifier = getTextNode((DOMElement *) nodeList->item (0)); 
    101         } 
     98    if (nodeList->getLength() != 0) 
     99    { 
     100        identifier = getTextNode((DOMElement *) nodeList->item (0)); 
     101    } 
    102102} 
    103103 
     
    105105(DOMElement* _elem) 
    106106{ 
    107         tmpXMLStr = XMLString::transcode ("componentinstantiationref");  
    108         DOMNodeList *nodeList =_elem->getElementsByTagName(tmpXMLStr); 
    109         sweetd(tmpXMLStr); 
     107    tmpXMLStr = XMLString::transcode ("componentinstantiationref");  
     108    DOMNodeList *nodeList =_elem->getElementsByTagName(tmpXMLStr); 
     109    XMLString::release(&tmpXMLStr); 
    110110 
    111         if (nodeList->getLength () != 0) 
    112         { 
    113                 ifComponentInstantiationRef = true; 
    114                 DOMElement *_tmpElement = (DOMElement *) nodeList->item (0); 
     111    if (nodeList->getLength () != 0) 
     112    { 
     113        ifComponentInstantiationRef = true; 
     114        DOMElement *_tmpElement = (DOMElement *) nodeList->item (0); 
    115115 
    116                 tmpXMLStr = XMLString::transcode("refid"); 
    117                 const XMLCh *_tmp =_tmpElement->getAttribute(tmpXMLStr); 
    118                 sweetd(tmpXMLStr); 
    119                 componentInstantiationRefId = XMLString::transcode (_tmp); 
    120         } 
     116        tmpXMLStr = XMLString::transcode("refid"); 
     117        const XMLCh *_tmp =_tmpElement->getAttribute(tmpXMLStr); 
     118        XMLString::release(&tmpXMLStr); 
     119        componentInstantiationRefId = XMLString::transcode (_tmp); 
     120    } 
    121121} 
    122122 
     
    124124char* ComponentSupportedInterface::getTextNode(DOMElement * _elem) 
    125125{ 
    126         DOMNodeList *nodeList = _elem->getChildNodes(); 
     126    DOMNodeList *nodeList = _elem->getChildNodes(); 
    127127 
    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 ()); 
     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 ()); 
    135135} 
    136136 
     
    138138bool ComponentSupportedInterface::isComponentInstantiationRef() 
    139139{ 
    140         return ifComponentInstantiationRef; 
     140    return ifComponentInstantiationRef; 
    141141} 
    142142 
     
    144144bool ComponentSupportedInterface::isFindBy() 
    145145{ 
    146         return ifFindBy; 
     146    return ifFindBy; 
    147147} 
    148148 
     
    150150char* ComponentSupportedInterface::getID() const 
    151151{ 
    152         return identifier; 
     152    return identifier; 
    153153} 
    154154 
     
    156156char* ComponentSupportedInterface::getComponentInstantiationRefId() const 
    157157{ 
    158         return componentInstantiationRefId; 
     158    return componentInstantiationRefId; 
    159159} 
    160160 
     
    162162FindBy* ComponentSupportedInterface::getFindBy() const 
    163163{ 
    164         return theFindBy; 
     164    return theFindBy; 
    165165} 
    166166XMLCh* ComponentSupportedInterface::tmpXMLStr = NULL; 
  • ossie/trunk/ossie/parser/Connection.cpp

    r464 r604  
    3030#endif 
    3131 
    32 #define mdel(x) if (x!=NULL) delete x, x=NULL; 
    33 #define sweetd(x) if (x!=NULL) delete []x, x=NULL;      // this is sweet! --Tuan 
     32#define DELPTR(x) if (x!=NULL) delete x, x=NULL; 
     33#define DELARRAY(x) if (x!=NULL) delete []x, x=NULL;    // this is sweet! --Tuan 
    3434 
    3535Connection::Connection(): 
     
    4848ifComponentSupportedInterface(false), ifFindBy(false) 
    4949{ 
    50         this->parseElement(); 
     50    this->parseElement(); 
    5151} 
    5252 
     
    6060ifFindBy(_conn.ifFindBy) 
    6161{ 
    62         if (_conn.usesPort != NULL) 
    63         this->usesPort = new UsesPort (*(_conn.usesPort)); 
    64         if (_conn.providesPort != NULL) 
    65         this->providesPort = new ProvidesPort (*(_conn.providesPort)); 
    66         if (_conn.componentSupportedInterface != NULL) 
    67         this->componentSupportedInterface = new ComponentSupportedInterface 
    68         (*(_conn.componentSupportedInterface)); 
    69  
    70         if (_conn.findBy != NULL) 
    71         this->findBy = new FindBy (*(_conn.findBy)); 
    72  
    73         this->connectionId = new char[strlen (_conn.connectionId) + 1]; 
    74         strcpy (connectionId, _conn.connectionId); 
     62    if (_conn.usesPort != NULL) 
     63    this->usesPort = new UsesPort (*(_conn.usesPort)); 
     64    if (_conn.providesPort != NULL) 
     65    this->providesPort = new ProvidesPort (*(_conn.providesPort)); 
     66    if (_conn.componentSupportedInterface != NULL) 
     67    this->componentSupportedInterface = new ComponentSupportedInterface 
     68    (*(_conn.componentSupportedInterface)); 
     69 
     70    if (_conn.findBy != NULL) 
     71    this->findBy = new FindBy (*(_conn.findBy)); 
     72 
     73    this->connectionId = new char[strlen (_conn.connectionId) + 1]; 
     74    strcpy (connectionId, _conn.connectionId); 
    7575} 
    7676 
    7777Connection::~Connection() 
    7878{ 
    79         sweetd(connectionId); 
    80         mdel(findBy); 
    81         mdel(usesPort); 
    82         mdel(providesPort); 
    83         mdel(componentSupportedInterface); 
     79    DELARRAY(connectionId); 
     80    DELPTR(findBy); 
     81    DELPTR(usesPort); 
     82    DELPTR(providesPort); 
     83    DELPTR(componentSupportedInterface); 
    8484} 
    8585 
     
    8888void Connection::parseElement() 
    8989{ 
    90         DOMNodeList *nodeList = element->getChildNodes(); 
    91  
    92         if (nodeList->getLength () < 2) 
    93         { 
    94                 //Invalid Profile Exception 
    95                 //Invalid XML -Connection must specify a destination component 
    96         } 
    97  
    98         parseID(element); 
    99         parseUsesPort(element); 
    100         parseProvidesPort(element); 
    101  
    102         if (!isProvidesPort()) 
    103         { 
    104                 parseComponentSupportedInterface(element); 
    105  
    106                 if (!isComponentSupportedInterface()) 
    107                 { 
    108                         DOMElement* _tmpElement = NULL; 
    109                         for (unsigned int i = 0; i < nodeList->getLength(); i++) 
    110                         { 
    111                                 _tmpElement = (DOMElement *) nodeList->item (i); 
    112  
    113                                 const XMLCh* _tagname = _tmpElement->getTagName(); 
    114                                 char* _name = XMLString::transcode(_tagname); 
    115  
    116                                 if (strcmp (_name, "findby") == 0) 
    117                                 { 
    118                                         delete []_name; 
    119                                         break; 
    120                                 } 
    121                                 delete []_name,_name=NULL; 
    122                         } 
    123  
    124                         parseFindBy (_tmpElement); 
    125  
    126                         if (!isFindBy()) 
    127                         { 
    128                                 //Invalid Profile Exception 
    129                                 //Invalid XML connection format 
    130                         } 
    131                 } 
    132         } 
     90    DOMNodeList *nodeList = element->getChildNodes(); 
     91 
     92    if (nodeList->getLength () < 2) 
     93    { 
     94        //Invalid Profile Exception 
     95        //Invalid XML -Connection must specify a destination component 
     96    } 
     97 
     98    parseID(element); 
     99    parseUsesPort(element); 
     100    parseProvidesPort(element); 
     101 
     102    if (!isProvidesPort()) 
     103    { 
     104        parseComponentSupportedInterface(element); 
     105 
     106        if (!isComponentSupportedInterface()) 
     107        { 
     108                DOMElement* _tmpElement = NULL; 
     109                for (unsigned int i = 0; i < nodeList->getLength(); i++) 
     110                { 
     111                        _tmpElement = (DOMElement *) nodeList->item (i); 
     112 
     113                        const XMLCh* _tagname = _tmpElement->getTagName(); 
     114                        char* _name = XMLString::transcode(_tagname); 
     115 
     116                        if (strcmp (_name, "findby") == 0) 
     117                        { 
     118                                delete []_name; 
     119                                break; 
     120                        } 
     121                        delete []_name,_name=NULL; 
     122                } 
     123 
     124                parseFindBy (_tmpElement); 
     125 
     126                if (!isFindBy()) 
     127                { 
     128                        //Invalid Profile Exception 
     129                        //Invalid XML connection format 
     130                } 
     131        } 
     132    } 
    133133} 
    134134 
     
    136136void Connection::parseID(DOMElement * _elem) 
    137137{ 
    138         tmpXMLStr = XMLString::transcode("id"); 
    139         const XMLCh* _tmp = _elem->getAttribute(tmpXMLStr); 
    140         sweetd(tmpXMLStr); 
    141         connectionId = XMLString::transcode (_tmp); 
     138    tmpXMLStr = XMLString::transcode("id"); 
     139    const XMLCh* _tmp = _elem->getAttribute(tmpXMLStr); 
     140    XMLString::release(&tmpXMLStr); 
     141    connectionId = XMLString::transcode (_tmp); 
    142142} 
    143143 
     
    146146void Connection::parseUsesPort(DOMElement * _elem) 
    147147{ 
    148         tmpXMLStr = XMLString::transcode("usesport"); 
    149         DOMNodeList *nodeList = _elem->getElementsByTagName(tmpXMLStr); 
    150         sweetd(tmpXMLStr); 
    151  
    152         if (nodeList->getLength () == 0) return; 
    153         //Throws exception InvalidProfile 
    154  
    155         DOMElement *_tmpElement = (DOMElement *) nodeList->item (0); 
    156         sweetd(usesPort); 
    157         usesPort = new UsesPort (_tmpElement); 
    158         ifUsesPort = true; 
     148    tmpXMLStr = XMLString::transcode("usesport"); 
     149    DOMNodeList *nodeList = _elem->getElementsByTagName(tmpXMLStr); 
     150    XMLString::release(&tmpXMLStr); 
     151 
     152    if (nodeList->getLength () == 0) return; 
     153    //Throws exception InvalidProfile 
     154 
     155    DOMElement *_tmpElement = (DOMElement *) nodeList->item (0); 
     156    DELARRAY(usesPort); 
     157    usesPort = new UsesPort (_tmpElement); 
     158    ifUsesPort = true; 
    159159} 
    160160 
     
    163163void Connection::parseProvidesPort(DOMElement * _elem) 
    164164{ 
    165         tmpXMLStr = XMLString::transcode("providesport"); 
    166         DOMNodeList *nodeList = _elem->getElementsByTagName(tmpXMLStr); 
    167         delete []tmpXMLStr; 
    168  
    169         if (nodeList->getLength () == 0) return; 
    170         //Throws exception InvalidProfile 
    171  
    172         DOMElement* _tmpElement = (DOMElement *) nodeList->item (0); 
    173         sweetd(providesPort); 
    174         providesPort = new ProvidesPort (_tmpElement); 
    175         ifProvidesPort = true; 
     165    tmpXMLStr = XMLString::transcode("providesport"); 
     166    DOMNodeList *nodeList = _elem->getElementsByTagName(tmpXMLStr); 
     167    XMLString::release(&tmpXMLStr); 
     168 
     169    if (nodeList->getLength () == 0) return; 
     170    //Throws exception InvalidProfile 
     171 
     172    DOMElement* _tmpElement = (DOMElement *) nodeList->item (0); 
     173    DELARRAY(providesPort); 
     174    providesPort = new ProvidesPort (_tmpElement); 
     175    ifProvidesPort = true; 
    176176} 
    177177 
     
    180180void Connection::parseComponentSupportedInterface(DOMElement * _elem) 
    181181{ 
    182         tmpXMLStr = XMLString::transcode("componentsupportedinterface"); 
    183         DOMNodeList *nodeList = _elem->getElementsByTagName(tmpXMLStr); 
    184         sweetd(tmpXMLStr); 
    185  
    186         if (nodeList->getLength () == 0) return; 
    187         //Throws exception InvalidProfile 
    188  
    189         DOMElement *_tmpElement = (DOMElement *) nodeList->item (0); 
    190         componentSupportedInterface = new ComponentSupportedInterface (_tmpElement); 
    191         ifComponentSupportedInterface = true; 
     182    tmpXMLStr = XMLString::transcode("componentsupportedinterface"); 
     183    DOMNodeList *nodeList = _elem->getElementsByTagName(tmpXMLStr); 
     184    XMLString::release(&tmpXMLStr); 
     185 
     186    if (nodeList->getLength () == 0) return; 
     187    //Throws exception InvalidProfile 
     188 
     189    DOMElement *_tmpElement = (DOMElement *) nodeList->item (0); 
     190    componentSupportedInterface = new ComponentSupportedInterface (_tmpElement); 
     191    ifComponentSupportedInterface = true; 
    192192} 
    193193 
     
    196196void Connection::parseFindBy(DOMElement * _elem) 
    197197{ 
    198         sweetd(findBy); 
    199         findBy = new FindBy(_elem); 
    200         ifFindBy = true; 
     198    DELARRAY(findBy); 
     199    findBy = new FindBy(_elem); 
     200    ifFindBy = true; 
    201201 
    202202//Throws exception InvalidProfile 
     
    204204 
    205205 
    206  char* Connection::getID() const 
    207 { 
    208         return connectionId; 
    209 } 
    210  
    211  
    212  UsesPort* Connection::getUsesPort() const 
    213 { 
    214         return usesPort; 
    215 } 
    216  
    217  
    218  ProvidesPort* Connection::getProvidesPort() const 
    219 { 
    220         return providesPort; 
    221 } 
    222  
    223  
    224  ComponentSupportedInterface* Connection::getComponentSupportedInterface() const 
    225 { 
    226         return componentSupportedInterface; 
    227 } 
    228  
    229  
    230  FindBy* Connection::getFindBy() const 
    231 { 
    232         return findBy; 
    233 } 
    234  
    235  
    236  bool Connection::isProvidesPort() 
    237 { 
    238         return ifProvidesPort; 
    239 } 
    240  
    241  
    242  bool Connection::isComponentSupportedInterface() 
    243 { 
    244         return ifComponentSupportedInterface; 
    245 } 
    246  
    247  
    248  bool Connection::isFindBy() 
    249 { 
    250         return ifFindBy; 
     206char* Connection::getID() const 
     207{ 
     208    return connectionId; 
     209} 
     210 
     211 
     212UsesPort* Connection::getUsesPort() const 
     213{ 
     214    return usesPort; 
     215} 
     216 
     217 
     218ProvidesPort* Connection::getProvidesPort() const 
     219{ 
     220    return providesPort; 
     221} 
     222 
     223 
     224ComponentSupportedInterface* Connection::getComponentSupportedInterface() const 
     225{ 
     226    return componentSupportedInterface; 
     227} 
     228 
     229 
     230FindBy* Connection::getFindBy() const 
     231{ 
     232    return findBy; 
     233} 
     234 
     235 
     236bool Connection::isProvidesPort() 
     237{ 
     238    return ifProvidesPort; 
     239} 
     240 
     241 
     242bool Connection::isComponentSupportedInterface() 
     243{ 
     244    return ifComponentSupportedInterface; 
     245} 
     246 
     247 
     248bool Connection::isFindBy() 
     249{ 
     250    return ifFindBy; 
    251251} 
    252252 
  • ossie/trunk/ossie/parser/DCDParser.cpp

    r464 r604  
    3131#endif 
    3232 
    33 #define mdel(x) if(x!=NULL) delete x, x=NULL; 
    34 #define sweetd(x) if(x!=NULL) delete []x, x=NULL; 
     33#define DELPTR(x) if(x!=NULL) delete x, x=NULL; 
     34#define DELARRAY(x) if(x!=NULL) delete []x, x=NULL; 
    3535 
    3636/** default constructor 
     
    127127DCDParser::~DCDParser() 
    128128{ 
    129         mdel(domainManagerComponent); 
    130         sweetd(deviceManagerSoftPkg); 
    131         sweetd(domainManagerName); 
    132         sweetd(domainManagerIOR); 
     129        DELPTR(domainManagerComponent); 
     130        DELARRAY(deviceManagerSoftPkg); 
     131        DELARRAY(domainManagerName); 
     132        DELARRAY(domainManagerIOR); 
    133133 
    134134/*      // This shouldn't cause seg faults. But it does. Need to find out why. -TT 
     
    143143        for (unsigned int i=0; deployOnComponents.size(); i++) 
    144144        { 
    145                 mdel(deployOnComponents[i]); 
     145                DELPTR(deployOnComponents[i]); 
    146146        } 
    147147*/ 
     
    190190        XMLCh* tmpXMLStr = XMLString::transcode("devicemanagersoftpkg"); 
    191191        DOMNodeList* nodeList = _elem->getElementsByTagName(tmpXMLStr); 
    192         sweetd(tmpXMLStr); 
     192        DELARRAY(tmpXMLStr); 
    193193 
    194194        DOMElement* tmpElement = (DOMElement*) nodeList->item(0); 
    195195        tmpXMLStr = XMLString::transcode("localfile"); 
    196196        nodeList = tmpElement->getElementsByTagName(tmpXMLStr); 
    197         sweetd(tmpXMLStr); 
     197        DELARRAY(tmpXMLStr); 
    198198        tmpElement =(DOMElement* ) nodeList->item(0); 
    199199 
    200200        tmpXMLStr = XMLString::transcode("name"); 
    201201        const XMLCh* _tmp = tmpElement->getAttribute(tmpXMLStr); 
    202         sweetd(tmpXMLStr); 
     202        DELARRAY(tmpXMLStr); 
    203203        deviceManagerSoftPkg = XMLString::transcode(_tmp); 
    204204} 
     
    209209        XMLCh* tmpXMLStr = XMLString::transcode("componentfile"); 
    210210        DOMNodeList* nodeList =_elem->getElementsByTagName(tmpXMLStr); 
    211         sweetd(tmpXMLStr); 
     211        DELARRAY(tmpXMLStr); 
    212212 
    213213        DOMNodeList* nodeList2; 
     
    219219                tmpXMLStr = XMLString::transcode("localfile"); 
    220220                nodeList2 = tmpElement->getElementsByTagName(tmpXMLStr); 
    221                 sweetd(tmpXMLStr); 
     221                DELARRAY(tmpXMLStr); 
    222222                tmpElement =(DOMElement* ) nodeList2->item(0); 
    223223                tmpXMLStr = XMLString::transcode("name"); 
    224224                const XMLCh* _tmp = tmpElement->getAttribute(tmpXMLStr); 
    225                 sweetd(tmpXMLStr); 
     225                DELARRAY(tmpXMLStr); 
    226226                localComponents.push_back(XMLString::transcode(_tmp)); 
    227227        } 
     
    233233        XMLCh* tmpXMLStr = XMLString::transcode("componentplacement");  
    234234        DOMNodeList* nodeList = _elem->getElementsByTagName(tmpXMLStr); 
    235         sweetd(tmpXMLStr); 
     235        DELARRAY(tmpXMLStr); 
    236236         
    237237        DOMElement* tmpElement; 
     
    262262        tmpXMLStr = XMLString::transcode("domainmanager"); 
    263263        DOMNodeList* nodeList = _elem->getElementsByTagName(tmpXMLStr); 
    264         sweetd(tmpXMLStr); 
     264        DELARRAY(tmpXMLStr); 
    265265         
    266266        DOMElement* tmpElement =(DOMElement* ) nodeList->item(0); 
    267267        tmpXMLStr = XMLString::transcode("namingservice"); 
    268268        nodeList = tmpElement->getElementsByTagName(tmpXMLStr); 
    269         sweetd(tmpXMLStr); 
     269        DELARRAY(tmpXMLStr); 
    270270 
    271271        if(nodeList->getLength() != 0) 
     
    275275                tmpXMLStr = XMLString::transcode("name"); 
    276276                const XMLCh* _name = tmpElement->getAttribute(tmpXMLStr); 
    277                 sweetd(tmpXMLStr); 
     277                DELARRAY(tmpXMLStr); 
    278278                domainManagerName = XMLString::transcode(_name); 
    279279        } 
     
    282282                tmpXMLStr = XMLString::transcode("stringifiedobjectref"); 
    283283                nodeList = tmpElement->getElementsByTagName(tmpXMLStr); 
    284                 sweetd(tmpXMLStr); 
     284                DELARRAY(tmpXMLStr); 
    285285 
    286286                if(nodeList->getLength() != 0) 
  • ossie/trunk/ossie/parser/FindBy.cpp

    r397 r604  
    2626 
    2727#include "ossie/FindBy.h" 
    28 #define mdel(x) if (x!=NULL) delete []x, x=NULL; 
     28#define DELPTR(x) if (x!=NULL) delete []x, x=NULL; 
    2929 
    3030/** default constructor 
    31         */ 
     31    */ 
    3232FindBy::FindBy(): 
    3333root(NULL), 
     
    5252findByDomainFinderName(NULL)     
    5353{ 
    54         this->parseElement(); 
     54    this->parseElement(); 
    5555} 
    5656 
     
    6666findByDomainFinderName(NULL)     
    6767{ 
    68         this->findByNamingService = new char[strlen (_fb.findByNamingService) + 1]; 
    69         strcpy (this->findByNamingService, _fb.findByNamingService); 
    70  
    71         this->findByStringifiedObjectRef = 
    72         new char[strlen (_fb.findByStringifiedObjectRef) + 1]; 
    73         strcpy (this->findByStringifiedObjectRef, _fb.findByStringifiedObjectRef); 
    74  
    75         this->findByDomainFinderType = 
    76         new char[strlen (_fb.findByDomainFinderType) + 1]; 
    77         strcpy (this->findByDomainFinderType, _fb.findByDomainFinderType); 
    78  
    79         this->findByDomainFinderName = 
    80         new char[strlen (_fb.findByDomainFinderName) + 1]; 
    81         strcpy (this->findByDomainFinderName, _fb.findByDomainFinderName); 
    82  
    83         this->ifFindByNamingService = _fb.ifFindByNamingService; 
    84         this->ifFindByStringifiedObjectRef = _fb.ifFindByStringifiedObjectRef; 
    85         this->ifFindByDomainFinder = _fb.ifFindByDomainFinder; 
     68    this->findByNamingService = new char[strlen (_fb.findByNamingService) + 1]; 
     69    strcpy (this->findByNamingService, _fb.findByNamingService); 
     70 
     71    this->findByStringifiedObjectRef = 
     72    new char[strlen (_fb.findByStringifiedObjectRef) + 1]; 
     73    strcpy (this->findByStringifiedObjectRef, _fb.findByStringifiedObjectRef); 
     74 
     75    this->findByDomainFinderType = 
     76    new char[strlen (_fb.findByDomainFinderType) + 1]; 
     77    strcpy (this->findByDomainFinderType, _fb.findByDomainFinderType); 
     78 
     79    this->findByDomainFinderName = 
     80    new char[strlen (_fb.findByDomainFinderName) + 1]; 
     81    strcpy (this->findByDomainFinderName, _fb.findByDomainFinderName); 
     82 
     83    this->ifFindByNamingService = _fb.ifFindByNamingService; 
     84    this->ifFindByStringifiedObjectRef = _fb.ifFindByStringifiedObjectRef; 
     85    this->ifFindByDomainFinder = _fb.ifFindByDomainFinder; 
    8686} 
    8787 
    8888FindBy::~FindBy() 
    8989{ 
    90         mdel(findByDomainFinderName); 
    91         mdel(findByDomainFinderType); 
    92         mdel(findByNamingService); 
    93         mdel(findByStringifiedObjectRef); 
     90    DELPTR(findByDomainFinderName); 
     91    DELPTR(findByDomainFinderType); 
     92    DELPTR(findByNamingService); 
     93    DELPTR(findByStringifiedObjectRef); 
    9494} 
    9595 
     
    9898void FindBy::parseElement() 
    9999{ 
    100         this->parseFindByNamingService(root); 
    101         if (!this->isFindByNamingService()) 
    102         { 
    103                 this->parseFindByStringifiedObjectRef (root); 
    104                 if (!this->isFindByStringifiedObjectRef()) 
    105                 { 
    106                         this->parseFindByDomainFinder (root); 
    107                         if (!this->isFindByDomainFinder ()) 
    108                         { 
    109                                 //throw an InvalidProfile here 
    110                         } 
    111                 } 
    112         } 
     100    this->parseFindByNamingService(root); 
     101    if (!this->isFindByNamingService()) 
     102    { 
     103        this->parseFindByStringifiedObjectRef (root); 
     104        if (!this->isFindByStringifiedObjectRef()) 
     105        { 
     106                this->parseFindByDomainFinder (root); 
     107                if (!this->isFindByDomainFinder ()) 
     108                { 
     109                        //throw an InvalidProfile here 
     110                } 
     111        } 
     112    } 
    113113} 
    114114 
     
    116116void FindBy::parseFindByDomainFinder(DOMElement* _elem) 
    117117{ 
    118         tmpXMLStr = XMLString::transcode("domainfinder"); 
    119         DOMNodeList* nodeList = _elem->getElementsByTagName(tmpXMLStr); 
    120         mdel(tmpXMLStr); 
    121  
    122         if (nodeList->getLength() != 0) 
    123         { 
    124                 ifFindByDomainFinder = true; 
    125                 DOMElement *elem = (DOMElement* ) nodeList->item (0); 
    126                 tmpXMLStr = XMLString::transcode("type"); 
    127                 const XMLCh *finderType = elem->getAttribute(tmpXMLStr); 
    128                 mdel(tmpXMLStr); 
    129                 findByDomainFinderType = XMLString::transcode(finderType); 
    130          
    131                 tmpXMLStr = XMLString::transcode("name"); 
    132                 const XMLCh *finderName = elem->getAttribute(tmpXMLStr); 
    133                 mdel(tmpXMLStr); 
    134                 findByDomainFinderName = XMLString::transcode(finderName); 
    135         } 
     118    tmpXMLStr = XMLString::transcode("domainfinder"); 
     119    DOMNodeList* nodeList = _elem->getElementsByTagName(tmpXMLStr); 
     120    XMLString::release(&tmpXMLStr); 
     121    //DELPTR(tmpXMLStr);  // it is more portable with XMLString::release() -TP 
     122 
     123    if (nodeList->getLength() != 0) 
     124    { 
     125        ifFindByDomainFinder = true; 
     126        DOMElement *elem = (DOMElement* ) nodeList->item (0); 
     127        tmpXMLStr = XMLString::transcode("type"); 
     128        const XMLCh *finderType = elem->getAttribute(tmpXMLStr); 
     129        XMLString::release(&tmpXMLStr); 
     130        findByDomainFinderType = XMLString::transcode(finderType); 
     131     
     132        tmpXMLStr = XMLString::transcode("name"); 
     133        const XMLCh *finderName = elem->getAttribute(tmpXMLStr); 
     134        XMLString::release(&tmpXMLStr); 
     135        findByDomainFinderName = XMLString::transcode(finderName); 
     136    } 
    136137} 
    137138 
    138139void FindBy::parseFindByNamingService(DOMElement * _elem) 
    139140{ 
    140         tmpXMLStr = XMLString::transcode("namingservice"); 
    141         DOMNodeList *nodeList = _elem->getElementsByTagName(tmpXMLStr); 
    142         mdel(tmpXMLStr); 
    143  
    144         if (nodeList->getLength() != 0) 
    145         { 
    146                 ifFindByNamingService = true; 
    147                 DOMElement *elem = (DOMElement *) nodeList->item (0); 
    148          
    149                 tmpXMLStr = XMLString::transcode("name"); 
    150                 const XMLCh *svcName = elem->getAttribute(tmpXMLStr); 
    151                 mdel(tmpXMLStr); 
    152                 findByNamingService = XMLString::transcode(svcName); 
    153         } 
     141    tmpXMLStr = XMLString::transcode("namingservice"); 
     142    DOMNodeList *nodeList = _elem->getElementsByTagName(tmpXMLStr); 
     143    XMLString::release(&tmpXMLStr); 
     144 
     145    if (nodeList->getLength() != 0) 
     146    { 
     147        ifFindByNamingService = true; 
     148        DOMElement *elem = (DOMElement *) nodeList->item (0); 
     149     
     150        tmpXMLStr = XMLString::transcode("name"); 
     151        const XMLCh *svcName = elem->getAttribute(tmpXMLStr); 
     152        XMLString::release(&tmpXMLStr); 
     153        findByNamingService = XMLString::transcode(svcName); 
     154    } 
    154155} 
    155156 
     
    157158void FindBy::parseFindByStringifiedObjectRef(DOMElement * _elem) 
    158159{ 
    159         tmpXMLStr = XMLString::transcode("stringifiedobjectref"); 
    160         DOMNodeList *nodeList = _elem->getElementsByTagName(tmpXMLStr); 
    161         mdel(tmpXMLStr); 
    162  
    163         if (nodeList->getLength () != 0) 
    164         { 
    165                 ifFindByStringifiedObjectRef = true; 
    166                 findByStringifiedObjectRef = 
    167                 getTextNode((DOMElement *) nodeList->item (0)); 
    168         } 
     160    tmpXMLStr = XMLString::transcode("stringifiedobjectref"); 
     161    DOMNodeList *nodeList = _elem->getElementsByTagName(tmpXMLStr); 
     162    XMLString::release(&tmpXMLStr); 
     163 
     164    if (nodeList->getLength () != 0) 
     165    { 
     166        ifFindByStringifiedObjectRef = true; 
     167        findByStringifiedObjectRef = 
     168        getTextNode((DOMElement *) nodeList->item (0)); 
     169    } 
    169170} 
    170171 
     
    172173char* FindBy::getTextNode(DOMElement* _node) 
    173174{ 
    174         DOMNodeList *nodeList = _node->getChildNodes (); 
    175  
    176         if (nodeList->getLength () == 0) 
    177         { 
    178                 char* astr = new char[strlen("Not Specified") +1]; 
    179                 strcpy(astr,"Not Specified"); 
    180                 return astr; 
    181         } 
    182         else return XMLString::transcode( nodeList->item (0)->getNodeValue() ); 
    183 } 
    184  
    185  
     175    DOMNodeList *nodeList = _node->getChildNodes (); 
     176 
     177    // returned char* must be "deletable" -TP 
     178    if (nodeList->getLength () == 0) 
     179    { 
     180        char* astr = new char[strlen("Not Specified") +1]; 
     181        strcpy(astr,"Not Specified"); 
     182        return astr; 
     183    } 
     184    else return XMLString::transcode( nodeList->item (0)->getNodeValue() ); 
     185} 
     186 
     187// \note the returned char* is const ~TP 
    186188char* FindBy::getFindByDomainFinderName() const 
    187189{ 
    188         return findByDomainFinderName; 
     190    return findByDomainFinderName; 
    189191} 
    190192 
     
    192194char* FindBy::getFindByDomainFinderType() const 
    193195{ 
    194         return findByDomainFinderType; 
     196    return findByDomainFinderType; 
    195197} 
    196198 
     
    198200char* FindBy::getFindByNamingServiceName() const 
    199201{ 
    200         return findByNamingService; 
     202    return findByNamingService; 
    201203} 
    202204 
     
    204206char* FindBy::getFindByStringifiedObjectRef() const 
    205207{ 
    206         return findByStringifiedObjectRef; 
     208    return findByStringifiedObjectRef; 
    207209} 
    208210 
     
    210212bool FindBy::isFindByDomainFinder() 
    211213{ 
    212         return ifFindByDomainFinder; 
     214    return ifFindByDomainFinder; 
    213215} 
    214216 
     
    216218bool FindBy::isFindByNamingService() 
    217219{ 
    218         return ifFindByNamingService; 
     220    return ifFindByNamingService; 
    219221} 
    220222 
     
    222224bool FindBy::isFindByStringifiedObjectRef() 
    223225{ 
    224         return ifFindByStringifiedObjectRef; 
     226    return ifFindByStringifiedObjectRef; 
    225227} 
    226228XMLCh* FindBy::tmpXMLStr = NULL; 
  • ossie/trunk/ossie/parser/InstantiationProperty.cpp

    r397 r604  
    3232{} 
    3333 
    34  
    3534InstantiationProperty::InstantiationProperty(const char *_id, const char *_value): 
    3635id(NULL), value(NULL) 
     
    4241    strcpy (value, _value); 
    4342} 
    44  
    4543 
    4644InstantiationProperty::InstantiationProperty(const InstantiationProperty & _copy): 
     
    5452} 
    5553 
    56  
    5754InstantiationProperty::~InstantiationProperty() 
    5855{ 
     
    6158} 
    6259 
    63  
    6460void InstantiationProperty::setID(const char *_id) 
    6561{ 
    66         if (id != NULL) delete []id; 
    67         id = new char[strlen(_id) + 1]; 
    68         strcpy(id, _id); 
     62    if (id != NULL) delete []id; 
     63    id = new char[strlen(_id) + 1]; 
     64    strcpy(id, _id); 
    6965} 
    7066 
    71  
    72 void InstantiationProperty::setValue (const char *_value) 
     67void InstantiationProperty::setValue(const char *_value) 
    7368{ 
    74         if (value != NULL) delete []value; 
    75         value = new char[strlen(_value) + 1]; 
    76         strcpy(value, _value); 
     69    if (value != NULL) delete []value; 
     70    value = new char[strlen(_value) + 1]; 
     71    strcpy(value, _value); 
    7772} 
    7873 
    79  
     74// \note the caller must delete this pointer 
     75// \remark why do we have this? java implementation translation? ~tp 
    8076char* InstantiationProperty::toString() 
    8177{ 
  • ossie/trunk/ossie/parser/Port.cpp

    r464 r604  
    3333#include "ossie/Port.h" 
    3434 
    35 #define mdel(x) if (x!=NULL) delete x, x=NULL; 
     35#define DELPTR(x) if (x!=NULL) delete x, x=NULL; 
    3636#define sweetd(x) if (x!=NULL) delete []x, x=NULL; 
    3737 
     
    4848{} 
    4949 
    50 Port::Port (DOMElement * element): 
     50Port::Port (DOMElement* element): 
    5151root(element), findBy(NULL), 
    5252ifComponentInstantiationRef(false), 
     
    5959deviceUsedByThisComponentRefUsesRefId(NULL) 
    6060{ 
    61         this->parseElement(); 
    62 } 
    63  
    64  
    65 Port::Port (const Port & _port): 
    66 root(_port.root), findBy(NULL), 
    67 ifComponentInstantiationRef(_port.ifComponentInstantiationRef), 
    68 ifDeviceThatLoadedThisComponentRef(_port.ifDeviceThatLoadedThisComponentRef), 
    69 ifDeviceUsedByThisComponentRef(_port.ifDeviceUsedByThisComponentRef), 
    70 ifFindBy(_port.ifFindBy), 
     61    this->parseElement(); 
     62} 
     63 
     64// copy constructor 
     65// deep copy 
     66Port::Port (const Port &aPort): 
     67root(aPort.root), findBy(NULL), 
     68ifComponentInstantiationRef(aPort.ifComponentInstantiationRef), 
     69ifDeviceThatLoadedThisComponentRef(aPort.ifDeviceThatLoadedThisComponentRef), 
     70ifDeviceUsedByThisComponentRef(aPort.ifDeviceUsedByThisComponentRef), 
     71ifFindBy(aPort.ifFindBy), 
    7172componentInstantiationRefId(NULL), 
    7273deviceThatLoadedThisComponentRefId(NULL), 
     
    7475deviceUsedByThisComponentRefUsesRefId(NULL) 
    7576{ 
    76         this->findBy = new FindBy (_port.root); 
    77  
    78         this->componentInstantiationRefId = 
    79         new char[strlen (_port.componentInstantiationRefId) + 1]; 
    80         strcpy(this->componentInstantiationRefId, _port.componentInstantiationRefId); 
    81  
    82         this->deviceThatLoadedThisComponentRefId = 
    83         new char[strlen (_port.deviceThatLoadedThisComponentRefId) + 1]; 
    84         strcpy (this->deviceThatLoadedThisComponentRefId, _port.deviceThatLoadedThisComponentRefId); 
    85  
    86         this->deviceUsedByThisComponentRefId = 
    87         new char[strlen (_port.deviceUsedByThisComponentRefId) + 1]; 
    88         strcpy (this->deviceUsedByThisComponentRefId, _port.deviceUsedByThisComponentRefId); 
    89  
    90         this->deviceUsedByThisComponentRefUsesRefId = 
    91         new char[strlen (_port.deviceUsedByThisComponentRefUsesRefId) + 1]; 
    92         strcpy (this->deviceUsedByThisComponentRefUsesRefId, _port.deviceUsedByThisComponentRefUsesRefId); 
     77    this->findBy = new FindBy (aPort.root); 
     78 
     79    this->componentInstantiationRefId = 
     80    new char[strlen (aPort.componentInstantiationRefId) + 1]; 
     81    strcpy(this->componentInstantiationRefId, aPort.componentInstantiationRefId); 
     82 
     83    this->deviceThatLoadedThisComponentRefId = 
     84    new char[strlen (aPort.deviceThatLoadedThisComponentRefId) + 1]; 
     85    strcpy (this->deviceThatLoadedThisComponentRefId, 
     86            aPort.deviceThatLoadedThisComponentRefId); 
     87 
     88    this->deviceUsedByThisComponentRefId = 
     89    new char[strlen (aPort.deviceUsedByThisComponentRefId) + 1]; 
     90    strcpy (this->deviceUsedByThisComponentRefId, aPort.deviceUsedByThisComponentRefId); 
     91 
     92    this->deviceUsedByThisComponentRefUsesRefId = 
     93    new char[strlen (aPort.deviceUsedByThisComponentRefUsesRefId) + 1]; 
     94    strcpy (this->deviceUsedByThisComponentRefUsesRefId, 
     95            aPort.deviceUsedByThisComponentRefUsesRefId); 
    9396} 
    9497 
     
    9699Port::~Port() 
    97100{ 
    98         root->release();        // it is safer to let the parser or whoever passes the DOMElement calls release() --Tuan 
    99         mdel(findBy); 
    100         sweetd(componentInstantiationRefId); 
    101         sweetd(deviceThatLoadedThisComponentRefId); 
    102         sweetd(deviceUsedByThisComponentRefId); 
    103         sweetd(deviceUsedByThisComponentRefUsesRefId); 
     101//    it is safer to let the parser 
     102// or whoever passes the DOMElement calls release() --Tuan 
     103//    root->release(); 
     104     
     105    DELPTR(findBy); 
     106    sweetd(componentInstantiationRefId); 
     107    sweetd(deviceThatLoadedThisComponentRefId); 
     108    sweetd(deviceUsedByThisComponentRefId); 
     109    sweetd(deviceUsedByThisComponentRefUsesRefId); 
    104110} 
    105111 
     
    107113void Port::parseElement() 
    108114{ 
    109     this->parsePort(this->root); 
     115    parsePort(root); 
    110116} 
    111117 
     
    114120void Port::parsePort (DOMElement * _elem) 
    115121{ 
    116         this->parseComponentInstantiationRef (_elem); 
    117  
    118         if (!this->ifComponentInstantiationRef) 
    119         { 
    120                 this->parseDeviceThatLoadedThisComponentRef (_elem); 
    121  
    122                 if (!this->ifDeviceThatLoadedThisComponentRef) 
    123                 { 
    124                         this->parseDeviceUsedByThisComponentRef (_elem); 
    125  
    126                         if (!this->ifDeviceUsedByThisComponentRef) 
    127                         { 
    128                                 this->parseFindBy (_elem); 
    129  
    130                                 if (!this->ifFindBy) 
    131                                 { 
     122    this->parseComponentInstantiationRef (_elem); 
     123 
     124    if (!this->ifComponentInstantiationRef) 
     125    { 
     126        this->parseDeviceThatLoadedThisComponentRef (_elem); 
     127 
     128        if (!this->ifDeviceThatLoadedThisComponentRef) 
     129        { 
     130                this->parseDeviceUsedByThisComponentRef (_elem); 
     131 
     132                if (!this->ifDeviceUsedByThisComponentRef) 
     133                { 
     134                        this->parseFindBy (_elem); 
     135 
     136                        if (!this->ifFindBy) 
     137                        { 
    132138//                                      string msg = "[Port:parsePort] Invalid XML port"; 
    133139//                                      throw new InvalidProfile( msg ); 
    134                                 } 
    135                         } 
    136                 } 
    137         } 
     140                        } 
     141                } 
     142        } 
     143    } 
    138144} 
    139145 
     
    141147void Port::parseComponentInstantiationRef(DOMElement * _elem) 
    142148{ 
    143         tmpXMLStr = XMLString::transcode("componentinstantiationref"); 
    144         DOMNodeList* nodeList = _elem->getElementsByTagName(tmpXMLStr); 
    145         sweetd(tmpXMLStr); 
    146  
    147         if (nodeList->getLength() != 0) 
    148         { 
    149                 DOMElement *elem = (DOMElement *) nodeList->item(0); 
    150  
    151                 tmpXMLStr = XMLString::transcode("refid"); 
    152                 const XMLCh *refId = elem->getAttribute(tmpXMLStr); 
    153                 sweetd(tmpXMLStr); 
    154  
    155                 this->componentInstantiationRefId = XMLString::transcode(refId); 
    156                 this->ifComponentInstantiationRef = true; 
    157         } 
     149    tmpXMLStr = XMLString::transcode("componentinstantiationref"); 
     150    DOMNodeList* nodeList = _elem->getElementsByTagName(tmpXMLStr); 
     151    XMLString::release(&tmpXMLStr); 
     152 
     153    if (nodeList->getLength() != 0) 
     154    { 
     155        DOMElement *elem = (DOMElement *) nodeList->item(0); 
     156 
     157        tmpXMLStr = XMLString::transcode("refid"); 
     158        const XMLCh *refId = elem->getAttribute(tmpXMLStr); 
     159        XMLString::release(&tmpXMLStr); 
     160 
     161        this->componentInstantiationRefId = XMLString::transcode(refId); 
     162        this->ifComponentInstantiationRef = true; 
     163    } 
    158164} 
    159165 
     
    161167void Port::parseDeviceThatLoadedThisComponentRef (DOMElement * _elem) 
    162168{ 
    163         tmpXMLStr = XMLString::transcode("devicethatloadedthiscomponentref"); 
    164         DOMNodeList* nodeList = _elem->getElementsByTagName(tmpXMLStr); 
    165         sweetd(tmpXMLStr); 
    166  
    167         if (nodeList->getLength () != 0) 
    168         { 
    169                 DOMElement *elem = (DOMElement*) nodeList->item (0); 
    170  
    171                 tmpXMLStr = XMLString::transcode("refid"); 
    172                 const XMLCh* refId = elem->getAttribute(tmpXMLStr); 
    173                 sweetd(tmpXMLStr); 
    174  
    175                 this->deviceThatLoadedThisComponentRefId = XMLString::transcode(refId); 
    176                 this->ifDeviceThatLoadedThisComponentRef = true; 
    177         } 
     169    tmpXMLStr = XMLString::transcode("devicethatloadedthiscomponentref"); 
     170    DOMNodeList* nodeList = _elem->getElementsByTagName(tmpXMLStr); 
     171    XMLString::release(&tmpXMLStr); 
     172 
     173    if (nodeList->getLength () != 0) 
     174    { 
     175        DOMElement *elem = (DOMElement*) nodeList->item (0); 
     176 
     177        tmpXMLStr = XMLString::transcode("refid"); 
     178        const XMLCh* refId = elem->getAttribute(tmpXMLStr); 
     179        XMLString::release(&tmpXMLStr); 
     180 
     181        this->deviceThatLoadedThisComponentRefId = XMLString::transcode(refId); 
     182        this->ifDeviceThatLoadedThisComponentRef = true; 
     183    } 
    178184} 
    179185 
     
    181187void Port::parseFindBy(DOMElement * _elem) 
    182188{ 
    183         tmpXMLStr = XMLString::transcode("findby"); 
    184         DOMNodeList *nodeList = _elem->getElementsByTagName(tmpXMLStr); 
    185         sweetd(tmpXMLStr); 
    186  
    187         if (nodeList->getLength () != 0) 
    188         { 
    189                 DOMElement *elem = (DOMElement *) nodeList->item (0); 
    190  
    191                 this->findBy = new FindBy(elem); 
    192                 this->ifFindBy = true; 
    193         } 
     189    tmpXMLStr = XMLString::transcode("findby"); 
     190    DOMNodeList *nodeList = _elem->getElementsByTagName(tmpXMLStr); 
     191    XMLString::release(&tmpXMLStr); 
     192 
     193    if (nodeList->getLength () != 0) 
     194    { 
     195        DOMElement *elem = (DOMElement *) nodeList->item (0); 
     196 
     197        this->findBy = new FindBy(elem); 
     198        this->ifFindBy = true; 
     199    } 
    194200} 
    195201 
     
    197203void Port::parseDeviceUsedByThisComponentRef(DOMElement * _elem) 
    198204{ 
    199         tmpXMLStr = XMLString::transcode("deviceusedbythiscomponentref"); 
    200         DOMNodeList *nodeList = _elem->getElementsByTagName(tmpXMLStr); 
    201         sweetd(tmpXMLStr); 
    202  
    203         if (nodeList->getLength() != 0) 
    204         { 
    205                 DOMElement* elem = (DOMElement*) nodeList->item(0); 
    206  
    207                 tmpXMLStr = XMLString::transcode("refid"); 
    208                 const XMLCh *refId = elem->getAttribute (XMLString::transcode ("refid")); 
    209                 sweetd(tmpXMLStr); 
    210                 tmpXMLStr = XMLString::transcode("usesrefid"); 
    211                 const XMLCh *refUsesId = elem->getAttribute (XMLString::transcode ("usesrefid")); 
    212                 sweetd(tmpXMLStr); 
    213  
    214                 this->deviceUsedByThisComponentRefId = XMLString::transcode(refId); 
    215                 this->deviceUsedByThisComponentRefUsesRefId =XMLString::transcode(refUsesId); 
    216                 this->ifDeviceUsedByThisComponentRef = true; 
    217         } 
     205    tmpXMLStr = XMLString::transcode("deviceusedbythiscomponentref"); 
     206    DOMNodeList *nodeList = _elem->getElementsByTagName(tmpXMLStr); 
     207    XMLString::release(&tmpXMLStr); 
     208 
     209    if (nodeList->getLength() != 0) 
     210    { 
     211        DOMElement* elem = (DOMElement*) nodeList->item(0); 
     212 
     213        tmpXMLStr = XMLString::transcode("refid"); 
     214        const XMLCh *refId = elem->getAttribute(tmpXMLStr); 
     215        XMLString::release(&tmpXMLStr); 
     216        tmpXMLStr = XMLString::transcode("usesrefid"); 
     217        const XMLCh *refUsesId = elem->getAttribute(tmpXMLStr); 
     218        XMLString::release(&tmpXMLStr); 
     219 
     220        this->deviceUsedByThisComponentRefId = XMLString::transcode(refId); 
     221        this->deviceUsedByThisComponentRefUsesRefId =XMLString::transcode(refUsesId); 
     222        this->ifDeviceUsedByThisComponentRef = true; 
     223    } 
    218224} 
    219225 
  • ossie/trunk/ossie/parser/ProvidesPort.cpp

    r397 r604  
    2727#include "ossie/ProvidesPort.h" 
    2828 
    29 #define mdel(x) if (x!=NULL) delete x, x=NULL; 
    30 #define sweetd(x) if (x!=NULL) delete []x, x=NULL; 
     29#define DELPTR(x) if (x!=NULL) delete x, x=NULL; 
     30#define DELARRAY(x) if (x!=NULL) delete []x, x=NULL; 
    3131 
    3232ProvidesPort::ProvidesPort():Port(), 
     
    3939identifier(NULL) 
    4040{ 
    41         this->parseElement(); 
     41    this->parseElement(); 
    4242} 
    4343 
     
    4646identifier(NULL) 
    4747{ 
    48         this->root=_pp.root; 
    49         this->findBy = new FindBy (_pp.root); 
     48    this->root=_pp.root; 
     49    this->findBy = new FindBy (_pp.root); 
    5050 
    51         this->ifComponentInstantiationRef = _pp.ifComponentInstantiationRef; 
    52         this->ifDeviceThatLoadedThisComponentRef = 
    53         _pp.ifDeviceThatLoadedThisComponentRef; 
    54         this->ifDeviceUsedByThisComponentRef = _pp.ifDeviceUsedByThisComponentRef; 
    55         this->ifFindBy = _pp.ifFindBy; 
     51    this->ifComponentInstantiationRef = _pp.ifComponentInstantiationRef; 
     52    this->ifDeviceThatLoadedThisComponentRef = 
     53    _pp.ifDeviceThatLoadedThisComponentRef; 
     54    this->ifDeviceUsedByThisComponentRef = _pp.ifDeviceUsedByThisComponentRef; 
     55    this->ifFindBy = _pp.ifFindBy; 
    5656 
    57         this->identifier = new char[strlen (_pp.identifier) + 1]; 
    58         strcpy (identifier, _pp.identifier); 
     57    this->identifier = new char[strlen (_pp.identifier) + 1]; 
     58    strcpy (identifier, _pp.identifier); 
    5959} 
    6060 
     
    6262ProvidesPort::~ProvidesPort() 
    6363{ 
    64         sweetd(identifier); 
    65 //      if (root!=NULL) root->release(), root=NULL; 
     64    DELARRAY(identifier); 
    6665} 
    6766 
     
    6968void ProvidesPort::parseElement() 
    7069{ 
    71         Port::parseElement(); 
    72         parseID(root); 
     70    Port::parseElement(); 
     71    parseID(root); 
    7372} 
    74  
    7573 
    7674void ProvidesPort::parseID(DOMElement * _elem) 
    7775{ 
    78         tmpXMLStr = XMLString::transcode("providesidentifier"); 
    79         DOMNodeList *nodeList = _elem->getElementsByTagName(tmpXMLStr); 
    80         sweetd(tmpXMLStr); 
     76    tmpXMLStr = XMLString::transcode("providesidentifier"); 
     77    DOMNodeList *nodeList = _elem->getElementsByTagName(tmpXMLStr); 
     78    XMLString::release(&tmpXMLStr); 
    8179 
    82         if (nodeList->getLength () != 0) 
    83         identifier = this->getTextNode ((DOMElement *) nodeList->item (0)); 
     80    if (nodeList->getLength () != 0) 
     81    identifier = this->getTextNode ((DOMElement *) nodeList->item (0)); 
    8482} 
    85  
    8683 
    8784char* ProvidesPort::getTextNode(DOMElement * _node) 
    8885{ 
    89         DOMNodeList *nodeList = _node->getChildNodes (); 
     86    DOMNodeList *nodeList = _node->getChildNodes (); 
    9087 
    91         if (nodeList->getLength () == 0) 
    92         { 
    93                 char* astr = new char[strlen("Not Specified") +1];      // dont worry, the compiler will optimize const string 
    94                 strcpy(astr, "Not Specified"); 
    95                 return astr; 
    96         } 
    97         else return XMLString::transcode (nodeList->item (0)->getNodeValue ()); 
     88    if (nodeList->getLength () == 0) 
     89    { 
     90        char* astr = new char[strlen("Not Specified") +1]; 
     91        strcpy(astr, "Not Specified"); 
     92        return astr; 
     93    } 
     94    else return XMLString::transcode (nodeList->item (0)->getNodeValue ()); 
    9895} 
    9996 
     97char* ProvidesPort::getID() const 
     98{ 
     99    return identifier; 
     100} 
    100101XMLCh* ProvidesPort::tmpXMLStr = NULL; 
  • ossie/trunk/ossie/parser/UsesPort.cpp

    r397 r604  
    3939identifier(NULL) 
    4040{ 
    41         this->parseElement(); 
     41    this->parseElement(); 
    4242} 
    4343 
    44  
     44// copy constructor 
    4545UsesPort::UsesPort(const UsesPort & _up): 
    4646Port(_up.root), 
    4747identifier(NULL) 
    4848{ 
    49         this->root = _up.root; 
    50         this->findBy = new FindBy (_up.root); 
     49    this->root = _up.root; 
     50    this->findBy = new FindBy (_up.root); 
    5151 
    52         this->ifComponentInstantiationRef = _up.ifComponentInstantiationRef; 
    53         this->ifDeviceThatLoadedThisComponentRef = 
    54         _up.ifDeviceThatLoadedThisComponentRef; 
    55         this->ifDeviceUsedByThisComponentRef = _up.ifDeviceUsedByThisComponentRef; 
    56         this->ifFindBy = _up.ifFindBy; 
     52    this->ifComponentInstantiationRef = _up.ifComponentInstantiationRef; 
     53    this->ifDeviceThatLoadedThisComponentRef = 
     54    _up.ifDeviceThatLoadedThisComponentRef; 
     55    this->ifDeviceUsedByThisComponentRef = _up.ifDeviceUsedByThisComponentRef; 
     56    this->ifFindBy = _up.ifFindBy; 
    5757 
    58         this->identifier = new char[strlen (_up.identifier) + 1]; 
    59         strcpy (this->identifier, _up.identifier); 
     58    this->identifier = new char[strlen (_up.identifier) + 1]; 
     59    strcpy (this->identifier, _up.identifier); 
    6060} 
    6161 
     
    6363UsesPort::~UsesPort() 
    6464{ 
    65         sweetd(identifier); 
    66         //if (root!=NULL) root->release(), root=NULL; 
     65    sweetd(identifier); 
    6766} 
    6867 
     
    7069void UsesPort::parseElement() 
    7170{ 
    72         Port::parseElement();   // call the base class first 
    73         this->parseID(root); 
     71    Port::parseElement();       // call the base class first 
     72    this->parseID(root); 
    7473} 
    7574 
     
    7776void UsesPort::parseID(DOMElement * _elem) 
    7877{ 
    79         tmpXMLStr = XMLString::transcode("usesidentifier"); 
    80         DOMNodeList *nodeList = _elem->getElementsByTagName(tmpXMLStr); 
    81         sweetd(tmpXMLStr); 
     78    tmpXMLStr = XMLString::transcode("usesidentifier"); 
     79    DOMNodeList *nodeList = _elem->getElementsByTagName(tmpXMLStr); 
     80    XMLString::release(&tmpXMLStr); 
    8281 
    83         if (nodeList->getLength () != 0) 
    84         identifier = this->getTextNode((DOMElement *) nodeList->item (0)); 
     82    if (nodeList->getLength () != 0) 
     83    identifier = this->getTextNode((DOMElement *) nodeList->item (0)); 
    8584} 
    8685 
     
    8887char* UsesPort::getTextNode(DOMElement * _node) 
    8988{ 
    90         DOMNodeList* nodeList = _node->getChildNodes(); 
     89    DOMNodeList* nodeList = _node->getChildNodes(); 
    9190 
    92         if (nodeList->getLength () == 0) 
    93         { 
    94                 char* astr = new char[strlen("Not Specified") +1];      // dont worry, the compiler will optimize const string 
    95                 strcpy(astr, "Not Specified"); 
    96                 return astr; 
    97         } 
    98         else return XMLString::transcode(nodeList->item (0)->getNodeValue ()); 
     91    if (nodeList->getLength () == 0) 
     92    { 
     93        char* astr = new char[strlen("Not Specified") +1]; 
     94        strcpy(astr, "Not Specified"); 
     95        return astr; 
     96    } 
     97    else return XMLString::transcode(nodeList->item (0)->getNodeValue ()); 
    9998} 
    10099 
     100// \note this should be const char* UsesPort::getID() const 
     101char* UsesPort::getID() const 
     102{ 
     103    return identifier; 
     104} 
    101105XMLCh* UsesPort::tmpXMLStr = NULL;