1 /* 2 This file is part of dia2code. It generates code from an UML Dia Diagram. 3 Copyright (C) 2014-2014 Vincent Le Garrec 4 5 This program is free software: you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation, either version 3 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 */ 18 19 #ifndef UMLCLASS_HPP 20 #define UMLCLASS_HPP 21 22 #include "config.h" 23 24 #include <list> 25 #include <string> 26 #include <cstring> 27 #include <stdlib.h> 28 #include <libxml/tree.h> 29 30 #include "umlAttribute.hpp" 31 #include "umlOperation.hpp" 32 // No include to avoid circular dependencies. 33 class umlClassNode; 34 class umlPackage; 35 36 struct geometry { 37 float posX; 38 float posY; 39 float width; 40 float height; 41 }; 42 43 void parseGeomPosition (xmlNodePtr attribute, geometry * geom); 44 void parseGeomWidth (xmlNodePtr attribute, geometry * geom); 45 void parseGeomHeight (xmlNodePtr attribute, geometry * geom); 46 47 class umlClass { 48 private : 49 std::string id; 50 std::string name; 51 std::string comment; 52 bool abstract : 1; 53 bool pushed : 1; 54 bool stereotypeTypedef : 1; 55 bool stereotypeEnum : 1; 56 bool stereotypeConst : 1; 57 bool stereotypeStruct : 1; 58 bool stereotypeGetSet : 1; 59 bool stereotypeExtern : 1; 60 bool stereotypeInterface : 1; 61 bool stereotypeDllExport : 1; 62 #ifdef ENABLE_CORBA 63 bool stereotypeCorba : 1; 64 #endif 65 std::list <umlAttribute> attributes; 66 std::list <umlOperation> operations; 67 std::list <const umlClass *> circularLoop; 68 std::list <std::pair <std::string, std::string> > templates; 69 umlPackage *package; 70 geometry geom; 71 72 public : 73 static bool isTypedefStereo (std::string & stereo); 74 static bool isEnumStereo (std::string & stereo); 75 static bool isConstStereo (std::string & stereo); 76 static bool isStructStereo (std::string & stereo); 77 static bool isGetSetStereo (std::string & stereo); 78 static bool isInterfaceStereo (std::string & stereo); 79 static bool isDllExportStereo (std::string & stereo); 80 static bool isCorbaStereo (std::string & stereo); 81 82 umlClass (); 83 84 const std::string & getId () const; 85 const std::string & getName () const; 86 const std::string & getComment () const; 87 bool isAbstract () const; 88 bool isPushed () const; 89 void setPushed (); 90 bool isStereotypeTypedef () const; 91 bool isStereotypeEnum () const; 92 bool isStereotypeConst () const; 93 bool isStereotypeStruct () const; 94 void setStereotypeStruct (bool val); 95 bool isStereotypeGetSet () const; 96 bool isStereotypeCorba () const; 97 bool isStereotypeExtern () const; 98 bool isStereotypeInterface () const; 99 bool isStereotypeDllExport () const; 100 const std::list <umlAttribute> & getAttributes () const; 101 const std::list <umlOperation> & getOperations () const; 102 void addCircularLoop (const umlClass * classe); 103 const std::list <const umlClass *> & getCircularLoop () const; 104 umlPackage * getPackage () const; 105 const std::list <std::pair <std::string, std::string> > & 106 getTemplates () const; 107 108 void makeGetSetMethods (); 109 static bool parseDiagram (char *diafile, 110 std::list <umlClassNode *> & res); 111 void parseClass (xmlNodePtr class_); 112 113 ~umlClass (); 114 }; 115 116 #endif 117 118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 119