1 /***********************************************************************/ 2 /* Open Visualization Data Explorer */ 3 /* (C) Copyright IBM Corp. 1989,1999 */ 4 /* ALL RIGHTS RESERVED */ 5 /* This code licensed under the */ 6 /* "IBM PUBLIC LICENSE - Open Visualization Data Explorer" */ 7 /***********************************************************************/ 8 9 #include <dxconfig.h> 10 #include "../base/defines.h" 11 12 13 14 15 #ifndef _ProcessGroupManager_h 16 #define _ProcessGroupManager_h 17 18 19 #include "GroupManager.h" 20 #include "Dictionary.h" 21 #include "DXStrings.h" 22 23 // 24 // Class name definition: 25 // 26 #define ClassProcessGroupManager "ProcessGroupManager" 27 #define PROCESS_GROUP "process" 28 29 class List; 30 class DXApplication; 31 class Network; 32 33 34 // 35 // The class to hold the group info 36 // 37 class ProcessGroupRecord : public GroupRecord 38 { 39 friend class ProcessGroupManager; 40 41 private: 42 43 char *host; 44 char *newhost; 45 ProcessGroupRecord(Network * network,const char * name)46 ProcessGroupRecord(Network *network, const char *name): GroupRecord (network, name) { 47 this->host = NULL; 48 this->newhost = NULL; 49 }; 50 ~ProcessGroupRecord()51 ~ProcessGroupRecord() { 52 if(this->host) delete this->host; 53 } 54 55 public: changesWhere()56 virtual boolean changesWhere () { return TRUE; } 57 }; 58 59 // 60 // The class to hold the host info 61 // 62 class ProcessHostRecord 63 { 64 friend class ProcessGroupManager; 65 66 private: 67 68 char *args; 69 boolean dirty; 70 ProcessHostRecord(const char * args)71 ProcessHostRecord(const char* args) 72 { 73 if(args) 74 this->args = DuplicateString(args); 75 else 76 this->args = NULL; 77 78 this->dirty = FALSE; 79 }; 80 ~ProcessHostRecord()81 ~ProcessHostRecord() 82 { 83 if (this->args) delete this->args; 84 } 85 }; 86 87 // 88 // ProcessGroupManager class definition: 89 // 90 class ProcessGroupManager : public GroupManager 91 { 92 friend class ProcessGroupAssignDialog; 93 friend class ProcessGroupCreateDialog; 94 95 private: 96 // 97 // Private member data: 98 // 99 100 protected: 101 // 102 // The host-argument dictionary 103 // 104 Dictionary arguments; 105 // 106 // A dictionary of lists of host assignment. 107 // 108 Dictionary *assignment; 109 110 // 111 // Send commands to the executive. 112 // 113 void attachGroup(const char *host, const char *group); 114 void detachGroup(const char *host, const char *group); 115 116 // 117 // Update the assignment dictionary. 118 // Return FALSE if given host does not exist. 119 // 120 boolean addGroupAssignment(const char* host, const char *group); 121 boolean removeGroupAssignment(const char *group); 122 recordAllocator(Network * net,const char * name)123 virtual GroupRecord* recordAllocator (Network *net, const char *name) { 124 return new ProcessGroupRecord (net, name); 125 } 126 127 public: 128 // 129 // Constructor: 130 // 131 ProcessGroupManager(Network *); 132 133 // 134 // Destructor: 135 // 136 ~ProcessGroupManager(); 137 SupportsMacros()138 static boolean SupportsMacros() { return FALSE; } 139 140 enum { 141 ATTACH, 142 DETACH 143 }; 144 145 virtual void clear(); 146 147 // 148 // return the host name assigned to a group. 149 // 150 const char *getGroupHost(const char* name); 151 const char *getGroupHost(int n); 152 const char *getGroupNewHost(const char* name); 153 const char *getGroupNewHost(int n); 154 boolean getGroupHostDirty(const char* name); 155 void clearGroupHostDirty(const char* name); 156 157 // 158 // Assign a host name to a group 159 // Return FALSE if the given group doesn't exist 160 // 161 boolean assignHost(const char *groupname,const char *hostname); 162 boolean assignHost(int n,const char *hostname); 163 164 // 165 // Really change host names when OK is pressed. 166 // 167 void updateHosts(); 168 169 // 170 // clear the temporary storage of host names. 171 // 172 void clearNewHosts(); 173 174 // 175 // Access the host's arguments. 176 // 177 const char *getArgument(const char* host); 178 boolean getArgumentDirty(const char* host); 179 void clearArgumentDirty(const char* host); 180 void assignArgument(const char *host,const char *args); 181 void clearArgument(); 182 183 // 184 // Remove modules from the existing group. 185 // 186 virtual boolean removeGroup(const char *name, Network *net); 187 188 189 // 190 // Create the assignment dictionary. 191 // 192 Dictionary *createAssignment(); 193 194 // 195 // Clear the assignment dictionary. 196 // 197 void clearAssignment(); 198 199 // 200 // Send commands to the executive. 201 // 202 void sendAssignment(int func); 203 204 void updateAssignment(); 205 // 206 // Management of sending assignment. 207 // 208 209 // 210 // Parse/Print the group assignment comment. 211 // 212 virtual boolean parseComment(const char *comment, 213 const char *filename, 214 int lineno, 215 Network *net); 216 virtual boolean printComment(FILE *f); 217 virtual boolean printAssignment(FILE *f); 218 219 220 // 221 // Returns a pointer to the class name. 222 // getClassName()223 const char* getClassName() 224 { 225 return ClassProcessGroupManager; 226 } 227 }; 228 229 230 #endif // _ProcessGroupManager_h 231