PageRenderTime 54ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/src/data/RelationData.h

http://github.com/gregsmirnov/bouml
C Header | 245 lines | 165 code | 49 blank | 31 comment | 1 complexity | c9a6b97713ca5afdccef82010282b721 MD5 | raw file
Possible License(s): GPL-2.0
  1. // *************************************************************************
  2. //
  3. // Copyright 2004-2010 Bruno PAGES .
  4. //
  5. // This file is part of the BOUML Uml Toolkit.
  6. //
  7. // This program is free software; you can redistribute it and/or modify
  8. // it under the terms of the GNU General Public License as published by
  9. // the Free Software Foundation; either version 2 of the License, or
  10. // (at your option) any later version.
  11. //
  12. // This program is distributed in the hope that it will be useful,
  13. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. // GNU General Public License for more details.
  16. //
  17. // You should have received a copy of the GNU General Public License
  18. // along with this program; if not, write to the Free Software
  19. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. //
  21. // e-mail : bouml@free.fr
  22. // home : http://bouml.free.fr
  23. //
  24. // *************************************************************************
  25. #ifndef RELATIONDATA_H
  26. #define RELATIONDATA_H
  27. #include "ClassMemberData.h"
  28. #include "Labeled.h"
  29. #include "AType.h"
  30. class QTextStream;
  31. class BrowserRelation;
  32. class BrowserAttribute;
  33. class BrowserNode;
  34. class BrowserClass;
  35. struct RoleData {
  36. // UML (except some cases to save memory)
  37. MyStr role;
  38. SharedStr multiplicity;
  39. MyStr init_value;
  40. MyStr comment;
  41. MyStr constraint; //
  42. UmlVisibility uml_visibility : 8; // : 4 useless here, : 8 faster than : 4 ?
  43. UmlVisibility cpp_visibility : 8; // : 4 useless here, : 8 faster than : 4
  44. bool isa_class_relation : 1;
  45. bool isa_volatile_relation: 1;
  46. bool isa_const_relation : 1;
  47. bool is_derived : 1;
  48. bool is_derivedunion : 1;
  49. bool is_ordered : 1;
  50. bool is_unique : 1;
  51. bool java_transient : 1; // java
  52. bool idl_truncatable_inheritance : 1; // idl inheritance
  53. // C++
  54. bool cpp_virtual_inheritance : 1;
  55. bool cpp_mutable: 1;
  56. SharedStr cpp_decl;
  57. // Java
  58. SharedStr java_decl;
  59. SharedStr java_annotation;
  60. // Php
  61. SharedStr php_decl;
  62. // Python
  63. SharedStr python_decl;
  64. // Idl
  65. BrowserAttribute * idl_case; // exclusive with idl_explicit_case
  66. SharedStr idl_explicit_case;
  67. SharedStr idl_decl;
  68. };
  69. class RelationData : public ClassMemberData, public Labeled<RelationData> {
  70. Q_OBJECT
  71. friend class RelationDialog;
  72. protected:
  73. static IdDict<RelationData> all;
  74. static QList<RelationData> Unconsistent;
  75. // Uml
  76. bool is_deleted : 8; // 1 useless here, 8 faster than 1 ?
  77. bool is_unconsistent : 8; // 1 useless here, 8 faster than 1 ?
  78. UmlCode type: 8; // < UmlRelations
  79. MyStr name;
  80. RoleData a;
  81. RoleData b;
  82. BrowserRelation * start;
  83. BrowserRelation * end;
  84. BrowserNode * end_removed_from;
  85. AType association; // class association
  86. int original_id; // from project library
  87. virtual void send_uml_def(ToolCom * com, BrowserRelation * rel);
  88. virtual void send_cpp_def(ToolCom * com, BrowserRelation * rel);
  89. virtual void send_java_def(ToolCom * com, BrowserRelation * rel);
  90. virtual void send_php_def(ToolCom * com, BrowserRelation * rel);
  91. virtual void send_python_def(ToolCom * com, BrowserRelation * rel);
  92. virtual void send_idl_def(ToolCom * com, BrowserRelation * rel);
  93. public:
  94. RelationData(UmlCode e, int id = 0);
  95. RelationData(const BrowserRelation * model, BrowserRelation * r);
  96. virtual ~RelationData();
  97. void garbage(BrowserRelation * r);
  98. void copy(RelationData * model);
  99. virtual bool deletedp() const;
  100. virtual void set_deletedp(bool y);
  101. virtual void delete_it();
  102. virtual void undelete(QString & warning, QString & renamed);
  103. bool undelete(QString & warning, QString & renamed,
  104. BrowserRelation * rel, BooL & br_deleted);
  105. BrowserRelation * set_start_end(BrowserRelation * s, BrowserClass * e);
  106. void edit();
  107. bool check_end_visibility();
  108. bool navigable(BrowserRelation *) const;
  109. BrowserClass * get_start_class() const;
  110. BrowserClass * get_end_class() const;
  111. BrowserRelation * get_start() const { return start; }
  112. BrowserRelation * get_end() const { return end; }
  113. void unidir_change_dest(BrowserNode * e);
  114. UmlCode get_type() const { return type; }
  115. void set_type(UmlCode e);
  116. const char * get_name() const { return name; }
  117. QString get_name(BrowserRelation *) const;
  118. void set_name(const QString &);
  119. virtual QString definition(bool full, bool with_kind) const;
  120. virtual bool set_stereotype(const QString &);
  121. virtual bool set_stereotype(const QCString &);
  122. virtual bool set_stereotype(const char *);
  123. virtual bool decldefbody_contain(const QString & s, bool cs, BrowserNode *);
  124. bool is_a(const BrowserRelation * br) const { return br == start; }
  125. const char * get_role_a() const { return a.role; }
  126. const char * get_role_b() const { return b.role; }
  127. bool wrong_role_a_name(const QString &);
  128. bool wrong_role_b_name(const QString &);
  129. AType get_association() const { return association; }
  130. void set_association(const AType & t);
  131. const char * get_multiplicity_a() const { return a.multiplicity; }
  132. const char * get_multiplicity_b() const { return b.multiplicity; }
  133. bool get_isa_class_relation_a() const { return a.isa_class_relation; }
  134. bool get_isa_class_relation_b() const { return b.isa_class_relation; }
  135. bool get_isa_const_relation_a() const { return a.isa_const_relation; }
  136. bool get_isa_const_relation_b() const { return b.isa_const_relation; }
  137. bool get_is_derived_a() const { return a.is_derived; }
  138. bool get_is_derived_b() const { return b.is_derived; }
  139. bool get_is_derivedunion_a() const { return a.is_derivedunion; }
  140. bool get_is_derivedunion_b() const { return b.is_derivedunion; }
  141. bool get_is_ordered_a() const { return a.is_ordered; }
  142. bool get_is_ordered_b() const { return b.is_ordered; }
  143. bool get_is_unique_a() const { return a.is_unique; }
  144. bool get_is_unique_b() const { return b.is_unique; }
  145. UmlVisibility get_uml_visibility_a() const { return a.uml_visibility; }
  146. UmlVisibility get_uml_visibility_b() const { return b.uml_visibility; }
  147. virtual UmlVisibility get_visibility(BrowserNode *);
  148. const char * get_comment_a() const { return a.comment; }
  149. const char * get_comment_b() const { return b.comment; }
  150. void set_comment_a(const char * s) { a.comment = s; }
  151. void set_comment_b(const char * s) { b.comment = s; }
  152. const char * get_constraint_a() const { return a.constraint; }
  153. const char * get_constraint_b() const { return b.constraint; }
  154. void set_constraint_a(const char * s) { a.constraint = s; }
  155. void set_constraint_b(const char * s) { b.constraint = s; }
  156. bool get_cpp_virtual_inheritance() const { return a.cpp_virtual_inheritance; }
  157. UmlVisibility get_cpp_visibility_a() const { return a.cpp_visibility; }
  158. UmlVisibility get_cpp_visibility_b() const { return b.cpp_visibility; }
  159. const char * get_cppdecl_a() const { return a.cpp_decl; }
  160. const char * get_cppdecl_b() const { return b.cpp_decl; }
  161. const char * get_javadecl_a() const { return a.java_decl; }
  162. const char * get_javadecl_b() const { return b.java_decl; }
  163. const char * get_phpdecl_a() const { return a.php_decl; }
  164. const char * get_phpdecl_b() const { return b.php_decl; }
  165. const char * get_pythondecl_a() const { return a.python_decl; }
  166. const char * get_pythondecl_b() const { return b.python_decl; }
  167. const char * get_idldecl_a() const { return a.idl_decl; }
  168. const char * get_idldecl_b() const { return b.idl_decl; }
  169. static const char * get_idlcase(const RoleData & role);
  170. void set_idlcase(RoleData & role, BrowserAttribute * a, const char * e);
  171. bool get_idl_truncatable() const { return a.idl_truncatable_inheritance; }
  172. void select_in_browser(bool prefer_start) const;
  173. void save(QTextStream &, bool ref, QString & warning) const;
  174. static RelationData * read_ref(char * &, bool complete = FALSE,
  175. const char * k = 0);
  176. static RelationData * read(char * &, char * &, BrowserRelation *& unconsistent);
  177. static bool uni_directional(UmlCode);
  178. static const QString & default_name(UmlCode e);
  179. static bool isa_association(UmlCode e);
  180. static bool isa_inherit(UmlCode e);
  181. bool tool_cmd(ToolCom * com, BrowserRelation * rel, const char * args);
  182. static void clear(bool old);
  183. static void update_idmax_for_root();
  184. void prepare_update_lib() const;
  185. void renumber(int phase, BrowserRelation * br);
  186. bool is_writable(const BrowserRelation * br) const;
  187. bool unconsistentp() const { return is_unconsistent; }
  188. void set_unconsistent();
  189. static bool has_unconsistencies();
  190. static void delete_unconsistent();
  191. static void post_load();
  192. protected slots:
  193. void end_deleted();
  194. void on_delete();
  195. };
  196. #endif