-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathextradefinition.h
166 lines (126 loc) · 5.88 KB
/
extradefinition.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
#ifndef EXTRADEFINITION_H
#define EXTRADEFINITION_H
// {{SMILE_PUBLIC_HEADER}}
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
// EXTRA DEFINITION
//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
#include "dslobject.h"
#include "intarray.h"
#include "generalclases.h"
#include <vector>
#include <string>
class DSL_network;
class DSL_sfoDefinition;
class DSL_extraDefinition : public DSL_object
{
// holds some extra information for the node. Used for
// customizations that are not easily done anywhere else,
// like some of the ones done for DIAG.
private:
DSL_network *network;
int handle;
DSL_intArray faultStates; // contains a 1 if the state is a fault state
int defaultOutcome; // holds the default outcome for those
// node types that have a default...
std::vector<DSL_documentation> stateDocumentation; // holds the documentation for each state
DSL_stringArray stateDescriptions; // description for each of the states
DSL_idArray faultLabels; // labels indexed by the STATES, not by the faulty states
DSL_stringArray faultNames; // names for the faulty states, again, indexed by all states.
DSL_stringArray stateRepairInfo; // repair (for faults) and state clarity test (for observables)
std::string question;
///////////////////////////////////////////////
///////////////////////////////////////////////
// new node troubleshooting types
public:
enum troubleType {target = 0, observation = 1, auxiliary = 2};
enum showAsType {userDefined = 0, nodeName = 1, stateName = 2, nodeAndStateName = 3, inherit = 4};
private:
troubleType type;
bool ranked;
bool mandatory;
bool setToDefault;
showAsType showAs;
public:
troubleType GetType(void) const {return(type);};
bool IsRanked(void) const {return(ranked);};
bool IsMandatory(void) const {return(mandatory);};
bool IsSetToDefault(void) const {return(setToDefault);};
void SetType(troubleType newType) {type = newType;};
void SetFlags(bool setRanked = false, bool setMandatory = false, bool setSetToDefault = false)
{
ranked = setRanked;
mandatory = setMandatory;
setToDefault = setSetToDefault;
};
void SetShowAs(showAsType asThis) {showAs = asThis;};
showAsType GetShowAs(void) const {return(showAs);};
///////////////////////////////////////////////
///////////////////////////////////////////////
public:
// creation/destruction
DSL_extraDefinition(int myHandle, DSL_network *theNetwork);
DSL_extraDefinition(DSL_extraDefinition &likeThisOne);
virtual ~DSL_extraDefinition() {CleanUp();};
int operator =(DSL_extraDefinition &likeThisOne);
// fast operations
DSL_extraDefinition(DSL_extraDefinition &likeThisOne, bool fast);
int FastCopy(DSL_extraDefinition &likeThisOne);
// member access
DSL_network *Network(void) {return(network);};
int SetNetwork(DSL_network *thisOne);
int Handle(void) {return(handle);};
void SetNetworkAndHandle(DSL_network *network, int handle);
int GetDefaultOutcome(void) {return(defaultOutcome);};
int SetDefaultOutcome(int thisOne);
void SetFaultState(int thisState, int isFault = DSL_TRUE);
int IsFaultState(int thisState);
int SetFaultStates(DSL_intArray &fromHere);
// methods to deal with changes in my definition
int NodeGetsBigger(int thisPosition);
int NodeGetsSmaller(int thisPosition);
int NodeChangedOrderOfStates(DSL_intArray &newOrder);
void CleanUp(int deep = 0);
void CheckReadiness(int deep = 0);
int Clone(DSL_extraDefinition &thisGuy);
int ReCreateFromNetworkStructure(void);
DSL_intArray &GetFaultStates(void) {return(faultStates);};
DSL_documentation &GetDocumentation(int forThisState);
char *GetStateDescription(int forThisState);
char *GetStateRepairInfo(int forThisState);
int SetStateDescription(int forThisState, char *newDescription);
int SetStateRepairInfo(int forThisState, char *newInfo);
DSL_stringArray &GetStateDescriptions(void);
DSL_stringArray &GetFaultNames(void);
const DSL_idArray &GetFaultLabels(void);
DSL_stringArray &GetStateRepairInfos(void);
std::string &GetQuestion(void) {return(question);};
// NOTE: labels must be unique for a given network
// These functions will return an error if an attempt is
// made to enter a duplicate label
int SetLabel(int thisOne, const char *theLabel);
int SetLabels(DSL_idArray &theLabels);
// moved to public interface - we need to check uniqueness
// in node description propery page
int GenerateUniqueLabel(char *prefix, char *buffer);
int IsLabelInUse(char *theLabel, int ignoredNode = DSL_OUT_OF_RANGE);
// tomek feb 27, 2001
// call GetEffectiveFaultName with forceCompose == true
// to get effective name even if node is not target or state is not fault
// this functionality is used by node description page
std::string GetEffectiveFaultName(int state, bool forceCompose = false);
// this override accepts alternate state name passed in szStateName
// parameter. set szStateName to NULL if you want to use real state name.
// this functionality is used by node description page
std::string GetEffectiveFaultName(int state, showAsType format, const char *szStateName, bool forceCompose);
// TCL: definition for serach for opportunities
private:
DSL_sfoDefinition* sfoDef;
public:
DSL_sfoDefinition& SfoDef(void); // instantiate [sfoDef] if it has not been instantiated
bool HasSfoDef(void) const {return (NULL != sfoDef);};
private:
int CreateAndInsertValidLabel(char *prefix, int here);
};
#endif