Changeset 604
- Timestamp:
- 10/05/05 14:34:19 (8 years ago)
- Location:
- ossie/trunk/ossie
- Files:
-
- 20 modified
-
include/ossie/ComponentAssemblyParser.h (modified) (2 diffs)
-
include/ossie/ComponentInstantiation.h (modified) (2 diffs)
-
include/ossie/ComponentSupportedInterface.h (modified) (1 diff)
-
include/ossie/Connection.h (modified) (1 diff)
-
include/ossie/DCDParser.h (modified) (2 diffs)
-
include/ossie/FindBy.h (modified) (1 diff)
-
include/ossie/InstantiationProperty.h (modified) (1 diff)
-
include/ossie/Port.h (modified) (1 diff)
-
include/ossie/ProvidesPort.h (modified) (1 diff)
-
include/ossie/UsesPort.h (modified) (1 diff)
-
parser/ComponentAssemblyParser.cpp (modified) (9 diffs)
-
parser/ComponentInstantiation.cpp (modified) (12 diffs)
-
parser/ComponentSupportedInterface.cpp (modified) (13 diffs)
-
parser/Connection.cpp (modified) (10 diffs)
-
parser/DCDParser.cpp (modified) (10 diffs)
-
parser/FindBy.cpp (modified) (13 diffs)
-
parser/InstantiationProperty.cpp (modified) (4 diffs)
-
parser/Port.cpp (modified) (11 diffs)
-
parser/ProvidesPort.cpp (modified) (5 diffs)
-
parser/UsesPort.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ossie/trunk/ossie/include/ossie/ComponentAssemblyParser.h
r540 r604 29 29 30 30 #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 32 32 #pragma warning( disable : 4290 ) // there's an annoying VC7 warning that I wanted to make go away 33 33 #pragma warning( disable : 4251 ) // this is for dll interfaces … … 39 39 class OSSIEPARSER_API ComponentAssemblyParser 40 40 { 41 public: 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 41 52 protected: 42 char* fileName; // the file name for a given DCD or SAD Profile43 char* id; // the id of the root node53 char* fileName; // the file name for a given DCD or SAD Profile 54 char* id; // the id of the root node 44 55 45 char* name; // the name of the root node46 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 destructor52 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; 53 64 54 public: 55 ComponentAssemblyParser(); 56 ComponentAssemblyParser(const char *_profileName); 57 ComponentAssemblyParser(const ComponentAssemblyParser & _copy); 58 virtual ~ComponentAssemblyParser(); 65 private: 66 bool IF; 59 67 60 std::vector <Connection*>* getConnections();61 char *getFileName() const;62 char *getID() const;63 char *getName() const;64 68 }; 65 69 #endif -
ossie/trunk/ossie/include/ossie/ComponentInstantiation.h
r540 r604 29 29 30 30 #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 33 34 #pragma warning( disable : 4251 ) // this is for dll interfaces 34 35 #endif … … 46 47 class OSSIEPARSER_API ComponentInstantiation 47 48 { 49 public: 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 48 60 protected: 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*); 55 67 56 68 private: 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; 72 74 }; 73 75 #endif -
ossie/trunk/ossie/include/ossie/ComponentSupportedInterface.h
r397 r604 32 32 class OSSIEPARSER_API ComponentSupportedInterface 33 33 { 34 public: 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 34 46 protected: 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); 45 57 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();57 58 private: 58 static XMLCh* tmpXMLStr;59 static XMLCh* tmpXMLStr; 59 60 }; 60 61 #endif -
ossie/trunk/ossie/include/ossie/Connection.h
r397 r604 34 34 class OSSIEPARSER_API Connection 35 35 { 36 public: 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 36 51 protected: 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); 53 68 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();68 69 private: 69 static XMLCh* tmpXMLStr;70 static XMLCh* tmpXMLStr; 70 71 }; 71 72 #endif -
ossie/trunk/ossie/include/ossie/DCDParser.h
r397 r604 37 37 class OSSIEPARSER_API DCDParser:public ComponentAssemblyParser 38 38 { 39 public: 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 39 57 protected: 40 58 char* deviceManagerSoftPkg; … … 53 71 void parseDomainManager(DOMElement* _elem); 54 72 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();72 73 private: 73 74 static XMLCh* tmpXMLStr; -
ossie/trunk/ossie/include/ossie/FindBy.h
r397 r604 38 38 { 39 39 private: 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); 53 53 54 static XMLCh* tmpXMLStr;54 static XMLCh* tmpXMLStr; 55 55 56 56 public: 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(); 61 61 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(); 69 69 }; 70 70 #endif -
ossie/trunk/ossie/include/ossie/InstantiationProperty.h
r397 r604 32 32 class OSSIEPARSER_API InstantiationProperty 33 33 { 34 public: 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 34 46 private: 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; 49 49 }; 50 50 #endif -
ossie/trunk/ossie/include/ossie/Port.h
r397 r604 32 32 class OSSIEPARSER_API Port 33 33 { 34 public: 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 34 80 protected: 35 DOMElement* root;36 FindBy* findBy;81 DOMElement* root; 82 FindBy* findBy; 37 83 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; 46 92 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); 99 99 100 100 private: 101 static XMLCh* tmpXMLStr;101 static XMLCh* tmpXMLStr; 102 102 }; 103 103 #endif -
ossie/trunk/ossie/include/ossie/ProvidesPort.h
r397 r604 33 33 { 34 34 private: 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); 39 39 40 static XMLCh* tmpXMLStr;40 static XMLCh* tmpXMLStr; 41 41 42 42 public: 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(); 47 47 48 inline char* getID() const 49 { 50 return identifier; 51 } 48 char* getID() const; 52 49 }; 53 50 #endif -
ossie/trunk/ossie/include/ossie/UsesPort.h
r397 r604 32 32 class OSSIEPARSER_API UsesPort:public Port 33 33 { 34 public: 35 UsesPort(); 36 UsesPort(DOMElement*); 37 UsesPort(const UsesPort&); 38 ~UsesPort(); 39 40 char* getID() const; 41 34 42 private: 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*); 39 46 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; 51 49 }; 52 50 #endif -
ossie/trunk/ossie/parser/ComponentAssemblyParser.cpp
r464 r604 34 34 #include <string.h> // void* memcpy(void* des, void* src, size_t n) 35 35 #endif 36 // it returns the pointer to des36 // it returns the pointer to des 37 37 38 38 /** A definition … … 40 40 * a pointers and assigning it to NULL. 41 41 */ 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 45 46 ComponentAssemblyParser::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 47 fileName(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 */ 62 67 } 63 68 … … 65 70 */ 66 71 ComponentAssemblyParser::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 ()); 72 fileName(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 97 107 } 98 108 … … 101 111 */ 102 112 ComponentAssemblyParser::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 ());113 fileName(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 ()); 122 132 } 123 133 … … 132 142 ComponentAssemblyParser::~ComponentAssemblyParser () 133 143 { 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++) 145 155 // { 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 161 char* 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()); 164 172 } 165 173 … … 168 176 { 169 177 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 200 void 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 */ 221 230 std::vector <Connection*>* ComponentAssemblyParser::getConnections() 222 231 { 223 return &connections;232 return &connections; 224 233 } 225 234 … … 227 236 char* ComponentAssemblyParser::getFileName() const 228 237 { 229 return this->fileName;238 return this->fileName; 230 239 } 231 240 … … 233 242 char* ComponentAssemblyParser::getID() const 234 243 { 235 return this->id;244 return this->id; 236 245 } 237 246 … … 239 248 char* ComponentAssemblyParser::getName() const 240 249 { 241 return this->name;242 } 250 return this->name; 251 } -
ossie/trunk/ossie/parser/ComponentInstantiation.cpp
r397 r604 26 26 27 27 #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; 30 30 31 31 ComponentInstantiation::ComponentInstantiation (): … … 33 33 {} 34 34 35 36 ComponentInstantiation::ComponentInstantiation (DOMElement * _element): 35 ComponentInstantiation::ComponentInstantiation (DOMElement* _element): 37 36 root(_element), instantiationId(NULL), instantiationName(NULL) 38 37 { 39 this->parseElement(); 40 } 41 38 this->parseElement(); 39 } 42 40 43 41 ComponentInstantiation::ComponentInstantiation … … 45 43 root(_compInst.root), instantiationId(NULL), instantiationName(NULL) 46 44 { 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 clean63 {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 55 ComponentInstantiation::~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 } 66 64 } 67 65 … … 69 67 void ComponentInstantiation::parseElement() 70 68 { 71 parseID(root);72 parseName(root);73 parseProperties(root);69 parseID(root); 70 parseName(root); 71 parseProperties(root); 74 72 } 75 73 76 74 void ComponentInstantiation::parseID(DOMElement * _elem) 77 75 { 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); 82 80 } 83 81 … … 85 83 void ComponentInstantiation::parseName(DOMElement * _elem) 86 84 { 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 } 96 94 } 97 95 … … 99 97 void ComponentInstantiation::parseProperties(DOMElement * _elem) 100 98 { 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 } 118 117 } 119 118 … … 121 120 InstantiationProperty* ComponentInstantiation::parseSimpleRef(DOMElement * _elem) 122 121 { 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; 138 137 } 139 138 … … 141 140 char* ComponentInstantiation::getTextNode(DOMElement * _elem) 142 141 { 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 ()); 152 151 } 153 152 … … 155 154 char* ComponentInstantiation::toString() 156 155 { 157 std::vector <InstantiationProperty*>* propertyArray;158 159 char *str = new char[MAX_BUFFER]; // the caller must release this160 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; 186 185 } 187 186 … … 189 188 char* ComponentInstantiation::getID() const 190 189 { 191 return this->instantiationId;190 return this->instantiationId; 192 191 } 193 192 … … 195 194 char* ComponentInstantiation::getName() const 196 195 { 197 return this->instantiationName;196 return this->instantiationName; 198 197 } 199 198 … … 201 200 std::vector <InstantiationProperty*>* ComponentInstantiation::getProperties() 202 201 { 203 return &properties;202 return &properties; 204 203 } 205 204 XMLCh* ComponentInstantiation::tmpXMLStr = NULL; -
ossie/trunk/ossie/parser/ComponentSupportedInterface.cpp
r397 r604 26 26 27 27 #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; 30 30 31 31 /**default constructor … … 48 48 theFindBy(NULL) 49 49 { 50 this->parseElement();50 this->parseElement(); 51 51 } 52 52 … … 61 61 { 62 62 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); 65 65 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); 69 69 70 this->ifComponentInstantiationRef = _csi.ifComponentInstantiationRef;71 this->ifFindBy = _csi.ifFindBy;70 this->ifComponentInstantiationRef = _csi.ifComponentInstantiationRef; 71 this->ifFindBy = _csi.ifFindBy; 72 72 73 if (_csi.theFindBy != NULL) this->theFindBy = new FindBy (_csi.root);73 if (_csi.theFindBy != NULL) this->theFindBy = new FindBy (_csi.root); 74 74 } 75 75 … … 77 77 ComponentSupportedInterface::~ComponentSupportedInterface () 78 78 { 79 mdel(theFindBy);80 sweetd(componentInstantiationRefId);81 sweetd(identifier);79 DELPTR(theFindBy); 80 DELARRAY(componentInstantiationRefId); 81 DELARRAY(identifier); 82 82 } 83 83 … … 85 85 void ComponentSupportedInterface::parseElement() 86 86 { 87 parseID(root);88 parseComponentInstantiationRef(root);87 parseID(root); 88 parseComponentInstantiationRef(root); 89 89 } 90 90 … … 92 92 void ComponentSupportedInterface::parseID (DOMElement * _elem) 93 93 { 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); 97 97 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 } 102 102 } 103 103 … … 105 105 (DOMElement* _elem) 106 106 { 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); 110 110 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); 115 115 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 } 121 121 } 122 122 … … 124 124 char* ComponentSupportedInterface::getTextNode(DOMElement * _elem) 125 125 { 126 DOMNodeList *nodeList = _elem->getChildNodes();126 DOMNodeList *nodeList = _elem->getChildNodes(); 127 127 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 ()); 135 135 } 136 136 … … 138 138 bool ComponentSupportedInterface::isComponentInstantiationRef() 139 139 { 140 return ifComponentInstantiationRef;140 return ifComponentInstantiationRef; 141 141 } 142 142 … … 144 144 bool ComponentSupportedInterface::isFindBy() 145 145 { 146 return ifFindBy;146 return ifFindBy; 147 147 } 148 148 … … 150 150 char* ComponentSupportedInterface::getID() const 151 151 { 152 return identifier;152 return identifier; 153 153 } 154 154 … … 156 156 char* ComponentSupportedInterface::getComponentInstantiationRefId() const 157 157 { 158 return componentInstantiationRefId;158 return componentInstantiationRefId; 159 159 } 160 160 … … 162 162 FindBy* ComponentSupportedInterface::getFindBy() const 163 163 { 164 return theFindBy;164 return theFindBy; 165 165 } 166 166 XMLCh* ComponentSupportedInterface::tmpXMLStr = NULL; -
ossie/trunk/ossie/parser/Connection.cpp
r464 r604 30 30 #endif 31 31 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! --Tuan32 #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 34 34 35 35 Connection::Connection(): … … 48 48 ifComponentSupportedInterface(false), ifFindBy(false) 49 49 { 50 this->parseElement();50 this->parseElement(); 51 51 } 52 52 … … 60 60 ifFindBy(_conn.ifFindBy) 61 61 { 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 ComponentSupportedInterface68 (*(_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); 75 75 } 76 76 77 77 Connection::~Connection() 78 78 { 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); 84 84 } 85 85 … … 88 88 void Connection::parseElement() 89 89 { 90 DOMNodeList *nodeList = element->getChildNodes();91 92 if (nodeList->getLength () < 2)93 {94 //Invalid Profile Exception95 //Invalid XML -Connection must specify a destination component96 }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 Exception129 //Invalid XML connection format130 }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 } 133 133 } 134 134 … … 136 136 void Connection::parseID(DOMElement * _elem) 137 137 { 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); 142 142 } 143 143 … … 146 146 void Connection::parseUsesPort(DOMElement * _elem) 147 147 { 148 tmpXMLStr = XMLString::transcode("usesport");149 DOMNodeList *nodeList = _elem->getElementsByTagName(tmpXMLStr);150 sweetd(tmpXMLStr);151 152 if (nodeList->getLength () == 0) return;153 //Throws exception InvalidProfile154 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; 159 159 } 160 160 … … 163 163 void Connection::parseProvidesPort(DOMElement * _elem) 164 164 { 165 tmpXMLStr = XMLString::transcode("providesport");166 DOMNodeList *nodeList = _elem->getElementsByTagName(tmpXMLStr);167 delete []tmpXMLStr;168 169 if (nodeList->getLength () == 0) return;170 //Throws exception InvalidProfile171 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; 176 176 } 177 177 … … 180 180 void Connection::parseComponentSupportedInterface(DOMElement * _elem) 181 181 { 182 tmpXMLStr = XMLString::transcode("componentsupportedinterface");183 DOMNodeList *nodeList = _elem->getElementsByTagName(tmpXMLStr);184 sweetd(tmpXMLStr);185 186 if (nodeList->getLength () == 0) return;187 //Throws exception InvalidProfile188 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; 192 192 } 193 193 … … 196 196 void Connection::parseFindBy(DOMElement * _elem) 197 197 { 198 sweetd(findBy);199 findBy = new FindBy(_elem);200 ifFindBy = true;198 DELARRAY(findBy); 199 findBy = new FindBy(_elem); 200 ifFindBy = true; 201 201 202 202 //Throws exception InvalidProfile … … 204 204 205 205 206 char* Connection::getID() const207 { 208 return connectionId;209 } 210 211 212 UsesPort* Connection::getUsesPort() const213 { 214 return usesPort;215 } 216 217 218 ProvidesPort* Connection::getProvidesPort() const219 { 220 return providesPort;221 } 222 223 224 ComponentSupportedInterface* Connection::getComponentSupportedInterface() const225 { 226 return componentSupportedInterface;227 } 228 229 230 FindBy* Connection::getFindBy() const231 { 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;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; 251 251 } 252 252 -
ossie/trunk/ossie/parser/DCDParser.cpp
r464 r604 31 31 #endif 32 32 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; 35 35 36 36 /** default constructor … … 127 127 DCDParser::~DCDParser() 128 128 { 129 mdel(domainManagerComponent);130 sweetd(deviceManagerSoftPkg);131 sweetd(domainManagerName);132 sweetd(domainManagerIOR);129 DELPTR(domainManagerComponent); 130 DELARRAY(deviceManagerSoftPkg); 131 DELARRAY(domainManagerName); 132 DELARRAY(domainManagerIOR); 133 133 134 134 /* // This shouldn't cause seg faults. But it does. Need to find out why. -TT … … 143 143 for (unsigned int i=0; deployOnComponents.size(); i++) 144 144 { 145 mdel(deployOnComponents[i]);145 DELPTR(deployOnComponents[i]); 146 146 } 147 147 */ … … 190 190 XMLCh* tmpXMLStr = XMLString::transcode("devicemanagersoftpkg"); 191 191 DOMNodeList* nodeList = _elem->getElementsByTagName(tmpXMLStr); 192 sweetd(tmpXMLStr);192 DELARRAY(tmpXMLStr); 193 193 194 194 DOMElement* tmpElement = (DOMElement*) nodeList->item(0); 195 195 tmpXMLStr = XMLString::transcode("localfile"); 196 196 nodeList = tmpElement->getElementsByTagName(tmpXMLStr); 197 sweetd(tmpXMLStr);197 DELARRAY(tmpXMLStr); 198 198 tmpElement =(DOMElement* ) nodeList->item(0); 199 199 200 200 tmpXMLStr = XMLString::transcode("name"); 201 201 const XMLCh* _tmp = tmpElement->getAttribute(tmpXMLStr); 202 sweetd(tmpXMLStr);202 DELARRAY(tmpXMLStr); 203 203 deviceManagerSoftPkg = XMLString::transcode(_tmp); 204 204 } … … 209 209 XMLCh* tmpXMLStr = XMLString::transcode("componentfile"); 210 210 DOMNodeList* nodeList =_elem->getElementsByTagName(tmpXMLStr); 211 sweetd(tmpXMLStr);211 DELARRAY(tmpXMLStr); 212 212 213 213 DOMNodeList* nodeList2; … … 219 219 tmpXMLStr = XMLString::transcode("localfile"); 220 220 nodeList2 = tmpElement->getElementsByTagName(tmpXMLStr); 221 sweetd(tmpXMLStr);221 DELARRAY(tmpXMLStr); 222 222 tmpElement =(DOMElement* ) nodeList2->item(0); 223 223 tmpXMLStr = XMLString::transcode("name"); 224 224 const XMLCh* _tmp = tmpElement->getAttribute(tmpXMLStr); 225 sweetd(tmpXMLStr);225 DELARRAY(tmpXMLStr); 226 226 localComponents.push_back(XMLString::transcode(_tmp)); 227 227 } … … 233 233 XMLCh* tmpXMLStr = XMLString::transcode("componentplacement"); 234 234 DOMNodeList* nodeList = _elem->getElementsByTagName(tmpXMLStr); 235 sweetd(tmpXMLStr);235 DELARRAY(tmpXMLStr); 236 236 237 237 DOMElement* tmpElement; … … 262 262 tmpXMLStr = XMLString::transcode("domainmanager"); 263 263 DOMNodeList* nodeList = _elem->getElementsByTagName(tmpXMLStr); 264 sweetd(tmpXMLStr);264 DELARRAY(tmpXMLStr); 265 265 266 266 DOMElement* tmpElement =(DOMElement* ) nodeList->item(0); 267 267 tmpXMLStr = XMLString::transcode("namingservice"); 268 268 nodeList = tmpElement->getElementsByTagName(tmpXMLStr); 269 sweetd(tmpXMLStr);269 DELARRAY(tmpXMLStr); 270 270 271 271 if(nodeList->getLength() != 0) … … 275 275 tmpXMLStr = XMLString::transcode("name"); 276 276 const XMLCh* _name = tmpElement->getAttribute(tmpXMLStr); 277 sweetd(tmpXMLStr);277 DELARRAY(tmpXMLStr); 278 278 domainManagerName = XMLString::transcode(_name); 279 279 } … … 282 282 tmpXMLStr = XMLString::transcode("stringifiedobjectref"); 283 283 nodeList = tmpElement->getElementsByTagName(tmpXMLStr); 284 sweetd(tmpXMLStr);284 DELARRAY(tmpXMLStr); 285 285 286 286 if(nodeList->getLength() != 0) -
ossie/trunk/ossie/parser/FindBy.cpp
r397 r604 26 26 27 27 #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; 29 29 30 30 /** default constructor 31 */31 */ 32 32 FindBy::FindBy(): 33 33 root(NULL), … … 52 52 findByDomainFinderName(NULL) 53 53 { 54 this->parseElement();54 this->parseElement(); 55 55 } 56 56 … … 66 66 findByDomainFinderName(NULL) 67 67 { 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; 86 86 } 87 87 88 88 FindBy::~FindBy() 89 89 { 90 mdel(findByDomainFinderName);91 mdel(findByDomainFinderType);92 mdel(findByNamingService);93 mdel(findByStringifiedObjectRef);90 DELPTR(findByDomainFinderName); 91 DELPTR(findByDomainFinderType); 92 DELPTR(findByNamingService); 93 DELPTR(findByStringifiedObjectRef); 94 94 } 95 95 … … 98 98 void FindBy::parseElement() 99 99 { 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 here110 }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 } 113 113 } 114 114 … … 116 116 void FindBy::parseFindByDomainFinder(DOMElement* _elem) 117 117 { 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 } 136 137 } 137 138 138 139 void FindBy::parseFindByNamingService(DOMElement * _elem) 139 140 { 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 } 154 155 } 155 156 … … 157 158 void FindBy::parseFindByStringifiedObjectRef(DOMElement * _elem) 158 159 { 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 } 169 170 } 170 171 … … 172 173 char* FindBy::getTextNode(DOMElement* _node) 173 174 { 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 186 188 char* FindBy::getFindByDomainFinderName() const 187 189 { 188 return findByDomainFinderName;190 return findByDomainFinderName; 189 191 } 190 192 … … 192 194 char* FindBy::getFindByDomainFinderType() const 193 195 { 194 return findByDomainFinderType;196 return findByDomainFinderType; 195 197 } 196 198 … … 198 200 char* FindBy::getFindByNamingServiceName() const 199 201 { 200 return findByNamingService;202 return findByNamingService; 201 203 } 202 204 … … 204 206 char* FindBy::getFindByStringifiedObjectRef() const 205 207 { 206 return findByStringifiedObjectRef;208 return findByStringifiedObjectRef; 207 209 } 208 210 … … 210 212 bool FindBy::isFindByDomainFinder() 211 213 { 212 return ifFindByDomainFinder;214 return ifFindByDomainFinder; 213 215 } 214 216 … … 216 218 bool FindBy::isFindByNamingService() 217 219 { 218 return ifFindByNamingService;220 return ifFindByNamingService; 219 221 } 220 222 … … 222 224 bool FindBy::isFindByStringifiedObjectRef() 223 225 { 224 return ifFindByStringifiedObjectRef;226 return ifFindByStringifiedObjectRef; 225 227 } 226 228 XMLCh* FindBy::tmpXMLStr = NULL; -
ossie/trunk/ossie/parser/InstantiationProperty.cpp
r397 r604 32 32 {} 33 33 34 35 34 InstantiationProperty::InstantiationProperty(const char *_id, const char *_value): 36 35 id(NULL), value(NULL) … … 42 41 strcpy (value, _value); 43 42 } 44 45 43 46 44 InstantiationProperty::InstantiationProperty(const InstantiationProperty & _copy): … … 54 52 } 55 53 56 57 54 InstantiationProperty::~InstantiationProperty() 58 55 { … … 61 58 } 62 59 63 64 60 void InstantiationProperty::setID(const char *_id) 65 61 { 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); 69 65 } 70 66 71 72 void InstantiationProperty::setValue (const char *_value) 67 void InstantiationProperty::setValue(const char *_value) 73 68 { 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); 77 72 } 78 73 79 74 // \note the caller must delete this pointer 75 // \remark why do we have this? java implementation translation? ~tp 80 76 char* InstantiationProperty::toString() 81 77 { -
ossie/trunk/ossie/parser/Port.cpp
r464 r604 33 33 #include "ossie/Port.h" 34 34 35 #define mdel(x) if (x!=NULL) delete x, x=NULL;35 #define DELPTR(x) if (x!=NULL) delete x, x=NULL; 36 36 #define sweetd(x) if (x!=NULL) delete []x, x=NULL; 37 37 … … 48 48 {} 49 49 50 Port::Port (DOMElement * element):50 Port::Port (DOMElement* element): 51 51 root(element), findBy(NULL), 52 52 ifComponentInstantiationRef(false), … … 59 59 deviceUsedByThisComponentRefUsesRefId(NULL) 60 60 { 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 66 Port::Port (const Port &aPort): 67 root(aPort.root), findBy(NULL), 68 ifComponentInstantiationRef(aPort.ifComponentInstantiationRef), 69 ifDeviceThatLoadedThisComponentRef(aPort.ifDeviceThatLoadedThisComponentRef), 70 ifDeviceUsedByThisComponentRef(aPort.ifDeviceUsedByThisComponentRef), 71 ifFindBy(aPort.ifFindBy), 71 72 componentInstantiationRefId(NULL), 72 73 deviceThatLoadedThisComponentRefId(NULL), … … 74 75 deviceUsedByThisComponentRefUsesRefId(NULL) 75 76 { 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); 93 96 } 94 97 … … 96 99 Port::~Port() 97 100 { 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); 104 110 } 105 111 … … 107 113 void Port::parseElement() 108 114 { 109 this->parsePort(this->root);115 parsePort(root); 110 116 } 111 117 … … 114 120 void Port::parsePort (DOMElement * _elem) 115 121 { 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 { 132 138 // string msg = "[Port:parsePort] Invalid XML port"; 133 139 // throw new InvalidProfile( msg ); 134 }135 }136 }137 }140 } 141 } 142 } 143 } 138 144 } 139 145 … … 141 147 void Port::parseComponentInstantiationRef(DOMElement * _elem) 142 148 { 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 } 158 164 } 159 165 … … 161 167 void Port::parseDeviceThatLoadedThisComponentRef (DOMElement * _elem) 162 168 { 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 } 178 184 } 179 185 … … 181 187 void Port::parseFindBy(DOMElement * _elem) 182 188 { 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 } 194 200 } 195 201 … … 197 203 void Port::parseDeviceUsedByThisComponentRef(DOMElement * _elem) 198 204 { 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 } 218 224 } 219 225 -
ossie/trunk/ossie/parser/ProvidesPort.cpp
r397 r604 27 27 #include "ossie/ProvidesPort.h" 28 28 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; 31 31 32 32 ProvidesPort::ProvidesPort():Port(), … … 39 39 identifier(NULL) 40 40 { 41 this->parseElement();41 this->parseElement(); 42 42 } 43 43 … … 46 46 identifier(NULL) 47 47 { 48 this->root=_pp.root;49 this->findBy = new FindBy (_pp.root);48 this->root=_pp.root; 49 this->findBy = new FindBy (_pp.root); 50 50 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; 56 56 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); 59 59 } 60 60 … … 62 62 ProvidesPort::~ProvidesPort() 63 63 { 64 sweetd(identifier); 65 // if (root!=NULL) root->release(), root=NULL; 64 DELARRAY(identifier); 66 65 } 67 66 … … 69 68 void ProvidesPort::parseElement() 70 69 { 71 Port::parseElement();72 parseID(root);70 Port::parseElement(); 71 parseID(root); 73 72 } 74 75 73 76 74 void ProvidesPort::parseID(DOMElement * _elem) 77 75 { 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); 81 79 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)); 84 82 } 85 86 83 87 84 char* ProvidesPort::getTextNode(DOMElement * _node) 88 85 { 89 DOMNodeList *nodeList = _node->getChildNodes ();86 DOMNodeList *nodeList = _node->getChildNodes (); 90 87 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 ()); 98 95 } 99 96 97 char* ProvidesPort::getID() const 98 { 99 return identifier; 100 } 100 101 XMLCh* ProvidesPort::tmpXMLStr = NULL; -
ossie/trunk/ossie/parser/UsesPort.cpp
r397 r604 39 39 identifier(NULL) 40 40 { 41 this->parseElement();41 this->parseElement(); 42 42 } 43 43 44 44 // copy constructor 45 45 UsesPort::UsesPort(const UsesPort & _up): 46 46 Port(_up.root), 47 47 identifier(NULL) 48 48 { 49 this->root = _up.root;50 this->findBy = new FindBy (_up.root);49 this->root = _up.root; 50 this->findBy = new FindBy (_up.root); 51 51 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; 57 57 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); 60 60 } 61 61 … … 63 63 UsesPort::~UsesPort() 64 64 { 65 sweetd(identifier); 66 //if (root!=NULL) root->release(), root=NULL; 65 sweetd(identifier); 67 66 } 68 67 … … 70 69 void UsesPort::parseElement() 71 70 { 72 Port::parseElement(); // call the base class first73 this->parseID(root);71 Port::parseElement(); // call the base class first 72 this->parseID(root); 74 73 } 75 74 … … 77 76 void UsesPort::parseID(DOMElement * _elem) 78 77 { 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); 82 81 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)); 85 84 } 86 85 … … 88 87 char* UsesPort::getTextNode(DOMElement * _node) 89 88 { 90 DOMNodeList* nodeList = _node->getChildNodes();89 DOMNodeList* nodeList = _node->getChildNodes(); 91 90 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 ()); 99 98 } 100 99 100 // \note this should be const char* UsesPort::getID() const 101 char* UsesPort::getID() const 102 { 103 return identifier; 104 } 101 105 XMLCh* UsesPort::tmpXMLStr = NULL;