-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsubmodel.h
193 lines (168 loc) · 7.9 KB
/
submodel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#ifndef SUBMODEL_H
#define SUBMODEL_H
// {{SMILE_PUBLIC_HEADER}}
// ==================================================
// This file implements the class [DSL_submodelHandler].
//
// The visual information of each submodel is
// grouped in the class [DSL_submodel]. This is a
// "dummy" class thas does almost nothing.
//
// The [DSL_submodelHandler] class handles creation and
// destruction of submodels and provides all kinds of
// information regarding interrelationships between
// submodels and individual nodes.
//
// The [DSL_submodelHandler] class is implemented as a
// list (using an array) that links each child with
// its parent. The list is just an array indexed by
// submodel identifier.
// ===================================================
// Origination:
// Author : Daniel Garcia
// Date : 17 July, 1997
//
// Revision Trail: yeah, right...
#include "network.h"
class DSL_node;
class DSL_intArray;
// check this values later
#define DSL_NO_PARENT -8888 // only possible with main submodel
#define DSL_EMPTY_SLOT -8889
#define DSL_SUBMODEL_MASK 0x4000 // all but 15th bit set to 0
////////////////////////////////////////////////////
// class DSL_submodel
////////////////////////////////////////////////////
class DSL_submodel : public DSL_object
{
public:
DSL_header header; // id, comment, etc
DSL_screenInfo info; // submodel as icon
DSL_rectangle windowpos; // submodel as window
int bkcolor; // submodel as window (background color)
DSL_textBoxList theComments; // comments on screen;
public:
DSL_submodel(void) {bkcolor = DSL_UNDEFINED_INT; CheckReadiness();};
DSL_submodel(DSL_submodel &likeThisOne);
int operator =(DSL_submodel &likeThisOne);
int CopyAppearance(DSL_submodel &likeThisOne);
};
////////////////////////////////////////////////////
// class DSL_submodelEntry
////////////////////////////////////////////////////
class DSL_submodelEntry
{
public:
DSL_submodel *submodel;
int parent;
public:
DSL_submodelEntry(void) {submodel = NULL; parent = DSL_EMPTY_SLOT;};
int IsEmpty(void) {return(parent == DSL_EMPTY_SLOT);};
int IsMainSubmodel(void) {return(parent == DSL_NO_PARENT);};
};
////////////////////////////////////////////////////
// class DSL_submodel
////////////////////////////////////////////////////
#define DSL_MAIN_SUBMODEL (DSL_SUBMODEL_MASK) // 0 is the main submodel
// From now on, [Handler] always make reference to a submodel [Handler]
// (i.e., an integer that uniquely identifies each submodel
class DSL_submodelHandler : public DSL_object
{
protected:
int maxSubmodels;
DSL_submodelEntry *submodels;
DSL_network *network; // the network I belong to
int delta;
DSL_screenInfo defaultNodeValues; // default info for node
DSL_screenInfo defaultSubmodelValues; // default info for submodel
public:
DSL_submodelHandler(void);
~DSL_submodelHandler() {CleanUp();};
int operator =(const DSL_submodelHandler &likeThisOne);
void SetNetwork(DSL_network *theNetwork) {network = theNetwork; CheckReadiness();};
int Initialize(void);
int IsThisIdentifierInUse(const char *theId);
int Flush(void);
int CreateSubmodel(int theParent, char *thisId);
int DeleteSubmodel(int theSubmodel);
int Ok(int index) {OI(index); return(iOk(index));};
int GetParent(int ofThisSubmodel);
DSL_submodel *GetSubmodel(int handler);
int GetFirstSubmodel(void);
int GetNextSubmodel(int ofThisSubmodel);
int GetSelectedSubmodels(DSL_intArray &here);
int FindSubmodel(char *withThisID);
int MoveSubmodel(int thisSubmodel, int intoThisSubmodel);
int GetSubmodelsOfManyNodes(DSL_intArray &theNodes, DSL_intArray &here);
void IdentifyArcs(int obj1, int obj2, dsl_arcType layer, DSL_intArray &parents, DSL_intArray &children);
int IsMainSubmodel(int handle) {return(handle == DSL_MAIN_SUBMODEL);};
int PartialOrdering(DSL_intArray &here);
int GetNumberOfSubmodels(void);
DSL_screenInfo &GetNodeDefaultValues() { return defaultNodeValues; }
DSL_screenInfo &GetSubmodelDefaultValues() { return defaultSubmodelValues; }
// INTERFACE FUNCTIONS (MAKE TRANSLATION IN/OUT)
int GetIncludedSubmodels(int inThisSubmodel, DSL_intArray &here);
int GetIncludedNodes(int inThisSubmodel, DSL_intArray &here);
int GetDeepIncludedSubmodels(int inThisSubmodel, DSL_intArray &here);
int GetDeepIncludedNodes(int inThisSubmodel, DSL_intArray &here);
int GetParentSubmodels(int ofThisGuy, DSL_intArray &here, dsl_arcType layer);
int GetChildSubmodels(int ofThisGuy, DSL_intArray &here, dsl_arcType layer);
int GetParentNodes(int ofThisGuy, DSL_intArray &here, dsl_arcType layer);
int GetChildNodes(int ofThisGuy, DSL_intArray &here, dsl_arcType layer);
int GetOutsideParentNodes(int ofThisGuy, DSL_intArray &here, dsl_arcType layer);
int GetOutsideChildNodes(int ofThisGuy, DSL_intArray &here, dsl_arcType layer);
void CleanUp(int deep = 0);
void CheckReadiness(int deep = 0);
int ReCreate(DSL_network *theNetwork);
protected:
int iOk(int index) {return(index>=0 && index<maxSubmodels && !submodels[index].IsEmpty());};
int IsEmpty(int thisSlot) {return(submodels[thisSlot].IsEmpty());};
int IsSubmodel(int index) {return(index & DSL_SUBMODEL_MASK);};
int FindEmptySlot(void);
int Grow(void);
int IsIncluded(int thisSubmodel, int intoThisSubmodel);
int CreateMainSubmodel(void);
int CreateUniqueSubmodelIdentifier(char *here, int tryThis);
int GetNodeSubmodel(int thisNode);
int IO(int &aSubmodel) {return(aSubmodel |= DSL_SUBMODEL_MASK);};
int OI(int &aSubmodel) {return(aSubmodel &= ~DSL_SUBMODEL_MASK);};
// INTERNAL FUNCTIONS
int iCreateSubmodel(int theParent, char *thisId);
int iDeleteSubmodel(int theSubmodel);
int iGetParent(int ofThisSubmodel);
DSL_submodel *iGetSubmodel(int handler);
int iGetFirstSubmodel(void);
int iGetNextSubmodel(int ofThisSubmodel);
int iGetSelectedSubmodels(DSL_intArray &here);
int iFindSubmodel(char *withThisID);
int iMoveSubmodel(int thisSubmodel, int intoThisSubmodel);
int iGetSubmodelsOfManyNodes(DSL_intArray &theNodes, DSL_intArray &here);
int FillMainSubmodelDefaultValues(void);
int iFillDefaultValues(int intoThisSubmodel, int fromThisSubmodel);
///////// RELATIONSHIPS
int iGetIncludedSubmodels(int inThisSubmodel, DSL_intArray &here);
int iGetIncludedNodes(int inThisSubmodel, DSL_intArray &here);
int iGetDeepIncludedSubmodels(int inThisSubmodel, DSL_intArray &here);
int iGetDeepIncludedNodes(int inThisSubmodel, DSL_intArray &here);
// parent submodels
int iGetParentSubmodelsOfNode(int theNode, DSL_intArray &here, dsl_arcType layer/* = dsl_normalArc*/);
int iGetParentSubmodelsOfSubmodel(int theSubmodel, DSL_intArray &here);
// child submodels
int iGetChildSubmodelsOfNode(int theNode, DSL_intArray &here, dsl_arcType layer);
int iGetChildSubmodelsOfSubmodel(int theSubmodel, DSL_intArray &here, dsl_arcType layer);
// parent nodes
int iGetParentNodesOfNode(int theNode, DSL_intArray &here, dsl_arcType layer);
int iGetParentNodesOfSubmodel(int theSubmodel, DSL_intArray &here);
// child nodes
int iGetChildNodesOfNode(int theNode, DSL_intArray &here, dsl_arcType layer);
int iGetChildNodesOfSubmodel(int theSubmodel, DSL_intArray &here);
// outside parent nodes
int iGetOutsideParentNodesOfNode(int theNode, DSL_intArray &here, dsl_arcType layer);
int iGetOutsideParentNodesOfSubmodel(int theSubmodel, DSL_intArray &here, dsl_arcType layer);
// outside child nodes
int iGetOutsideChildNodesOfNode(int theNode, DSL_intArray &here, dsl_arcType layer);
int iGetOutsideChildNodesOfSubmodel(int theSubmodel, DSL_intArray &here, dsl_arcType layer);
};
// STILL NOT CLEAR. SPECIFY MORE.
// int DSL_Copy_Submodel(DSL_network *netwp, int submodel_ID);
#endif