1 /* Dia -- an diagram creation/manipulation program
2  * Copyright (C) 1998 Alexander Larsson
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17  */
18 
19 /** \file objects/UML/uml.h  Objects contained  in 'UML - Class' type also and helper functions */
20 
21 #ifndef UML_H
22 #define UML_H
23 
24 #include <glib.h>
25 #include "intl.h"
26 #include "connectionpoint.h"
27 #include "dia_xml.h"
28 
29 typedef struct _UMLAttribute UMLAttribute;
30 typedef struct _UMLOperation UMLOperation;
31 typedef struct _UMLParameter UMLParameter;
32 typedef struct _UMLFormalParameter UMLFormalParameter;
33 
34 /** the visibility (allowed acces) of (to) various UML sub elements */
35 typedef enum _UMLVisibility {
36   UML_PUBLIC, /**< everyone can use it */
37   UML_PRIVATE, /**< only accessible inside the class itself */
38   UML_PROTECTED, /**< the class and its inheritants ca use this */
39   UML_IMPLEMENTATION /**< ?What's this? Means implementation decision */
40 } UMLVisibility;
41 
42 /** In some languages there are different kinds of class inheritances */
43 typedef enum _UMLInheritanceType {
44   UML_ABSTRACT, /**< Pure virtual method: an object of this class cannot be instanciated */
45   UML_POLYMORPHIC, /**< Virtual method : could be reimplemented in derivated classes */
46   UML_LEAF /**< Final method: can't be redefined in subclasses */
47 } UMLInheritanceType;
48 
49 /** describes the data flow between caller and callee */
50 typedef enum _UMLParameterKind {
51   UML_UNDEF_KIND, /**< not defined */
52   UML_IN, /**< by value */
53   UML_OUT, /**< by ref, can be passed in uninitialized */
54   UML_INOUT /**< by ref */
55 } UMLParameterKind;
56 
57 typedef gchar * UMLStereotype;
58 
59 /** \brief A list of UMLAttribute is contained in UMLClass
60  * Some would call them member variables ;)
61  */
62 struct _UMLAttribute {
63   gint internal_id; /**< Arbitrary integer to recognize attributes after
64 		     * the user has shuffled them in the dialog. */
65   gchar *name; /**< the member variables name */
66   gchar *type; /**< the return value */
67   gchar *value; /**< default parameter : Can be NULL => No default value */
68   gchar *comment; /**< comment */
69   UMLVisibility visibility; /**< attributes visibility */
70   int abstract; /**< not sure if this applicable */
71   int class_scope; /**< in C++ : static member */
72 
73   ConnectionPoint* left_connection; /**< left */
74   ConnectionPoint* right_connection; /**< right */
75 };
76 
77 /** \brief A list of UMLOperation is contained in UMLClass
78  * Some would call them member functions ;)
79  */
80 struct _UMLOperation {
81   gint internal_id; /**< Arbitrary integer to recognize operations after
82 		     * the user has shuffled them in the dialog. */
83   gchar *name; /**< the function name */
84   gchar *type; /**< Return type, NULL => No return type */
85   gchar *comment; /**< comment */
86   UMLStereotype stereotype; /**< just some string */
87   UMLVisibility visibility; /**< allowed access */
88   UMLInheritanceType inheritance_type;
89   int query; /**< Do not modify the object, in C++ this is a const function */
90   int class_scope;
91   GList *parameters; /**< List of UMLParameter */
92 
93   ConnectionPoint* left_connection; /**< left */
94   ConnectionPoint* right_connection; /**< right */
95 
96   gboolean needs_wrapping; /** Whether this operation needs wrapping */
97   gint wrap_indent; /** The amount of indentation in chars */
98   GList *wrappos; /** Absolute wrapping positions */
99   real ascent; /** The ascent amount used for line distance in wrapping */
100 };
101 
102 
103 /** \brief A list of UMLParameter is contained in UMLOperation
104  * Some would call them functions parameters ;)
105  */
106 struct _UMLParameter {
107   gchar *name; /**<  name*/
108   gchar *type; /**< return value */
109   gchar *value; /**< Initialization,  can be NULL => No default value */
110   gchar *comment; /**< comment */
111   UMLParameterKind kind; /**< Not currently used */
112 };
113 
114 /** \brief A list of UMLFormalParameter is contained in UMLOperation
115  * Some would call them template parameters ;)
116  */
117 struct _UMLFormalParameter {
118   gchar *name; /**< name */
119   gchar *type; /**< Can be NULL => Type parameter */
120 };
121 
122 /* Characters used to start/end stereotypes: */
123 /** start stereotype symbol(like \xab) for local locale */
124 #define UML_STEREOTYPE_START _("<<")
125 /** end stereotype symbol(like \xbb) for local locale */
126 #define UML_STEREOTYPE_END _(">>")
127 
128 /** calculated the 'formated' representation */
129 extern gchar *uml_get_attribute_string (UMLAttribute *attribute);
130 /** calculated the 'formated' representation */
131 extern gchar *uml_get_operation_string(UMLOperation *operation);
132 /** calculated the 'formated' representation */
133 extern gchar *uml_get_parameter_string(UMLParameter *param);
134 /** calculated the 'formated' representation */
135 extern gchar *uml_get_formalparameter_string(UMLFormalParameter *parameter);
136 extern void uml_attribute_copy_into(UMLAttribute *srcattr, UMLAttribute *destattr);
137 extern UMLAttribute *uml_attribute_copy(UMLAttribute *attr);
138 extern void uml_operation_copy_into(UMLOperation *srcop, UMLOperation *destop);
139 extern UMLOperation *uml_operation_copy(UMLOperation *op);
140 extern UMLFormalParameter *uml_formalparameter_copy(UMLFormalParameter *param);
141 extern void uml_attribute_destroy(UMLAttribute *attribute);
142 extern void uml_operation_destroy(UMLOperation *op);
143 extern void uml_parameter_destroy(UMLParameter *param);
144 extern void uml_formalparameter_destroy(UMLFormalParameter *param);
145 extern UMLAttribute *uml_attribute_new(void);
146 extern UMLOperation *uml_operation_new(void);
147 extern UMLParameter *uml_parameter_new(void);
148 extern UMLFormalParameter *uml_formalparameter_new(void);
149 
150 extern void uml_attribute_ensure_connection_points (UMLAttribute *attr, DiaObject* obj);
151 extern void uml_operation_ensure_connection_points (UMLOperation *oper, DiaObject* obj);
152 
153 extern void uml_attribute_write(AttributeNode attr_node, UMLAttribute *attr);
154 extern void uml_operation_write(AttributeNode attr_node, UMLOperation *op);
155 extern void uml_formalparameter_write(AttributeNode attr_node, UMLFormalParameter *param);
156 
157 #endif /* UML_H */
158 
159