Diffstat (limited to 'noncore/settings/networksettings2/networksettings2/netnode.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/networksettings2/networksettings2/netnode.h | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.h b/noncore/settings/networksettings2/networksettings2/netnode.h index f4a5e30..9681c6e 100644 --- a/noncore/settings/networksettings2/networksettings2/netnode.h +++ b/noncore/settings/networksettings2/networksettings2/netnode.h | |||
@@ -86,38 +86,44 @@ public: | |||
86 | 86 | ||
87 | // create a blank instance of a net node | 87 | // create a blank instance of a net node |
88 | virtual ANetNodeInstance * createInstance( void ) = 0; | 88 | virtual ANetNodeInstance * createInstance( void ) = 0; |
89 | 89 | ||
90 | // return feature this NetNode provides | 90 | // return feature this NetNode provides |
91 | virtual const char * provides( void ) = 0; | 91 | virtual const char * provides( void ) = 0; |
92 | virtual const char ** needs( void ) = 0; | 92 | virtual const char ** needs( void ) = 0; |
93 | 93 | ||
94 | // generate files specific for this node (if any) | 94 | // generate files specific for this node (if any) |
95 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ) = 0; | 95 | virtual bool generateProperFilesFor( ANetNodeInstance * NNI ) = 0; |
96 | // return TRUE if this node has data to be inserted in systemfile | 96 | // return TRUE if this node has data to be inserted in systemfile |
97 | // with name S | 97 | // with name S |
98 | virtual bool hasDataFor( const QString & S, bool DeviceSpecific ) = 0; | 98 | virtual bool hasDataFor( const QString & S ) = 0; |
99 | // generate data specific for a profile and for the system file S | ||
100 | // called only IF data was needed | ||
101 | virtual bool generateDataForCommonFile( | ||
102 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ) = 0; | ||
103 | // generate data specific for the device for the system file S | 99 | // generate data specific for the device for the system file S |
104 | // called only IF data was needed | 100 | // called only IF data was needed |
105 | virtual bool generateDeviceDataForCommonFile( | 101 | virtual bool generateDeviceDataForCommonFile( |
106 | SystemFile & SF, long DevNr, ANetNodeInstance * NNI ) = 0; | 102 | SystemFile & SF, long DevNr ) = 0; |
107 | 103 | ||
108 | // does this Node provide a Connection | 104 | // does this Node provide a Connection |
109 | bool isToplevel( void ) | 105 | bool isToplevel( void ) |
110 | { return strcmp( provides(), "fullsetup") == 0 ; } | 106 | { return strcmp( provides(), "fullsetup") == 0 ; } |
111 | 107 | ||
108 | // generate NIC name based on instance nr | ||
109 | // only relevant if node instances are devices | ||
110 | virtual QString genNic( long ) | ||
111 | { return QString(""); } | ||
112 | |||
113 | // max number of instances for this node type | ||
114 | // only relevant if node instances are devices | ||
115 | virtual long instanceCount( void ) | ||
116 | { return 1; } | ||
117 | |||
112 | // compiled references to 'needed' NetNodes -> needs list | 118 | // compiled references to 'needed' NetNodes -> needs list |
113 | void setAlternatives( NetNodeList * Alt ) | 119 | void setAlternatives( NetNodeList * Alt ) |
114 | { Alternatives = Alt; } | 120 | { Alternatives = Alt; } |
115 | NetNodeList & alternatives( void ) | 121 | NetNodeList & alternatives( void ) |
116 | { return *Alternatives; } | 122 | { return *Alternatives; } |
117 | 123 | ||
118 | protected : | 124 | protected : |
119 | 125 | ||
120 | NetNodeList * Alternatives; | 126 | NetNodeList * Alternatives; |
121 | 127 | ||
122 | private : | 128 | private : |
123 | }; | 129 | }; |
@@ -145,25 +151,25 @@ public: | |||
145 | // return data was modified | 151 | // return data was modified |
146 | void setModified( bool M ) | 152 | void setModified( bool M ) |
147 | { IsModified = M; } | 153 | { IsModified = M; } |
148 | bool isModified( void ) | 154 | bool isModified( void ) |
149 | { return IsModified; } | 155 | { return IsModified; } |
150 | 156 | ||
151 | // get data from GUI and store in node | 157 | // get data from GUI and store in node |
152 | virtual void commit( void ) = 0; | 158 | virtual void commit( void ) = 0; |
153 | 159 | ||
154 | // get next node | 160 | // get next node |
155 | ANetNodeInstance * nextNode(); | 161 | ANetNodeInstance * nextNode(); |
156 | // return NetNode this is an instance of | 162 | // return NetNode this is an instance of |
157 | ANetNode * netNode( void ) | 163 | ANetNode * nodeClass( void ) |
158 | { return NodeType; } | 164 | { return NodeType; } |
159 | 165 | ||
160 | // intialize am instance of a net node | 166 | // intialize am instance of a net node |
161 | void initialize( void ); | 167 | void initialize( void ); |
162 | 168 | ||
163 | // set the value of an attribute | 169 | // set the value of an attribute |
164 | void setAttribute( QString & Attr, QString & Value ) ; | 170 | void setAttribute( QString & Attr, QString & Value ) ; |
165 | void saveAttributes( QTextStream & TS ) ; | 171 | void saveAttributes( QTextStream & TS ) ; |
166 | 172 | ||
167 | // return true if node isntance is NEW and not loaded | 173 | // return true if node isntance is NEW and not loaded |
168 | void setNew( bool IsN ) | 174 | void setNew( bool IsN ) |
169 | { IsNew = IsN; } | 175 | { IsNew = IsN; } |
@@ -185,24 +191,33 @@ public: | |||
185 | const QString pixmapName( void ) | 191 | const QString pixmapName( void ) |
186 | { return NodeType->pixmapName(); } | 192 | { return NodeType->pixmapName(); } |
187 | 193 | ||
188 | const char * provides( void ) | 194 | const char * provides( void ) |
189 | { return NodeType->provides(); } | 195 | { return NodeType->provides(); } |
190 | 196 | ||
191 | const char ** needs( void ) | 197 | const char ** needs( void ) |
192 | { return NodeType->needs(); } | 198 | { return NodeType->needs(); } |
193 | 199 | ||
194 | // returns node specific data -> only useful for 'buddy' | 200 | // returns node specific data -> only useful for 'buddy' |
195 | virtual void * data( void ) = 0; | 201 | virtual void * data( void ) = 0; |
196 | 202 | ||
203 | // return TRUE if this node has data to be inserted in systemfile | ||
204 | // with name S | ||
205 | virtual bool hasDataFor( const QString & S ) = 0; | ||
206 | |||
207 | // generate data specific for a profile and for the system file S | ||
208 | // called only IF data was needed | ||
209 | virtual bool generateDataForCommonFile( | ||
210 | SystemFile & SF, long DevNr ) = 0; | ||
211 | |||
197 | protected : | 212 | protected : |
198 | 213 | ||
199 | virtual void setSpecificAttribute( QString & , QString & ) = 0; | 214 | virtual void setSpecificAttribute( QString & , QString & ) = 0; |
200 | virtual void saveSpecificAttribute( QTextStream & ) = 0; | 215 | virtual void saveSpecificAttribute( QTextStream & ) = 0; |
201 | 216 | ||
202 | ANetNode * NodeType; | 217 | ANetNode * NodeType; |
203 | // connection to which this node belongs to | 218 | // connection to which this node belongs to |
204 | NodeCollection * Connection; | 219 | NodeCollection * Connection; |
205 | QString NodeName; | 220 | QString NodeName; |
206 | QString Description; | 221 | QString Description; |
207 | bool IsModified; | 222 | bool IsModified; |
208 | bool IsNew; | 223 | bool IsNew; |
@@ -211,31 +226,31 @@ protected : | |||
211 | }; | 226 | }; |
212 | 227 | ||
213 | class RuntimeInfo : public QObject { | 228 | class RuntimeInfo : public QObject { |
214 | 229 | ||
215 | Q_OBJECT | 230 | Q_OBJECT |
216 | 231 | ||
217 | public : | 232 | public : |
218 | 233 | ||
219 | RuntimeInfo( ANetNodeInstance * TheNNI ) | 234 | RuntimeInfo( ANetNodeInstance * TheNNI ) |
220 | { NNI = TheNNI; } | 235 | { NNI = TheNNI; } |
221 | 236 | ||
222 | // downcast implemented by specify runtime classes | 237 | // downcast implemented by specify runtime classes |
223 | AsDevice * asDevice( void ) | 238 | virtual AsDevice * asDevice( void ) |
224 | { return 0; } | 239 | { return 0; } |
225 | AsConnection * asConnection( void ) | 240 | virtual AsConnection * asConnection( void ) |
226 | { return 0; } | 241 | { return 0; } |
227 | AsLine * asLine( void ) | 242 | virtual AsLine * asLine( void ) |
228 | { return 0; } | 243 | { return 0; } |
229 | AsFullSetup * asFullSetup( void ) | 244 | virtual AsFullSetup * asFullSetup( void ) |
230 | { return 0; } | 245 | { return 0; } |
231 | 246 | ||
232 | // does this node handles this interface e.g.eth0 | 247 | // does this node handles this interface e.g.eth0 |
233 | // recurse deeper if this node cannot answer that question | 248 | // recurse deeper if this node cannot answer that question |
234 | virtual bool handlesInterface( const QString & ) | 249 | virtual bool handlesInterface( const QString & ) |
235 | { return 0; } | 250 | { return 0; } |
236 | virtual InterfaceInfo * assignedInterface( void ); | 251 | virtual InterfaceInfo * assignedInterface( void ); |
237 | virtual AsDevice * device( void ); | 252 | virtual AsDevice * device( void ); |
238 | 253 | ||
239 | ANetNodeInstance * netNode() | 254 | ANetNodeInstance * netNode() |
240 | { return NNI; } | 255 | { return NNI; } |
241 | NodeCollection * connection() | 256 | NodeCollection * connection() |
@@ -379,31 +394,28 @@ public: | |||
379 | { return QString(""); } | 394 | { return QString(""); } |
380 | const QString nodeName() | 395 | const QString nodeName() |
381 | { return QString("Fake node" ); } | 396 | { return QString("Fake node" ); } |
382 | const QString nodeDescription() | 397 | const QString nodeDescription() |
383 | { return QString("Fake node" ); } | 398 | { return QString("Fake node" ); } |
384 | ANetNodeInstance * createInstance( void ); | 399 | ANetNodeInstance * createInstance( void ); |
385 | const char * provides( void ) | 400 | const char * provides( void ) |
386 | { return ""; } | 401 | { return ""; } |
387 | virtual const char ** needs( void ) | 402 | virtual const char ** needs( void ) |
388 | { return 0; } | 403 | { return 0; } |
389 | virtual bool generateProperFilesFor( ANetNodeInstance * ) | 404 | virtual bool generateProperFilesFor( ANetNodeInstance * ) |
390 | { return 0; } | 405 | { return 0; } |
391 | virtual bool hasDataFor( const QString &, bool DS ) | 406 | virtual bool hasDataFor( const QString & ) |
392 | { return 0; } | 407 | { return 0; } |
393 | virtual bool generateDataForCommonFile( | ||
394 | SystemFile & , long , ANetNodeInstance * ) | ||
395 | {return 1; } | ||
396 | virtual bool generateDeviceDataForCommonFile( | 408 | virtual bool generateDeviceDataForCommonFile( |
397 | SystemFile & , long , ANetNodeInstance * ) | 409 | SystemFile & , long ) |
398 | {return 1; } | 410 | {return 1; } |
399 | 411 | ||
400 | private : | 412 | private : |
401 | 413 | ||
402 | }; | 414 | }; |
403 | 415 | ||
404 | class FakeNetNodeInstance : public ANetNodeInstance { | 416 | class FakeNetNodeInstance : public ANetNodeInstance { |
405 | 417 | ||
406 | public: | 418 | public: |
407 | 419 | ||
408 | FakeNetNodeInstance( ANetNode * NN ) : | 420 | FakeNetNodeInstance( ANetNode * NN ) : |
409 | ANetNodeInstance( NN ), ValAttrPairs() { } | 421 | ANetNodeInstance( NN ), ValAttrPairs() { } |
@@ -425,23 +437,29 @@ public: | |||
425 | // get next node | 437 | // get next node |
426 | ANetNodeInstance * nextNode() | 438 | ANetNodeInstance * nextNode() |
427 | { return 0; } | 439 | { return 0; } |
428 | // return NetNode this is an instance of | 440 | // return NetNode this is an instance of |
429 | 441 | ||
430 | // intialize am instance of a net node | 442 | // intialize am instance of a net node |
431 | void initialize( void ){} | 443 | void initialize( void ){} |
432 | 444 | ||
433 | // returns node specific data -> only useful for 'buddy' | 445 | // returns node specific data -> only useful for 'buddy' |
434 | virtual void * data( void ) | 446 | virtual void * data( void ) |
435 | { return 0; } | 447 | { return 0; } |
436 | 448 | ||
449 | virtual bool hasDataFor( const QString & ) | ||
450 | { return 0; } | ||
451 | |||
452 | virtual bool generateDataForCommonFile( SystemFile & , long ) | ||
453 | { return 1; } | ||
454 | |||
437 | protected : | 455 | protected : |
438 | 456 | ||
439 | virtual void setSpecificAttribute( QString & , QString & ); | 457 | virtual void setSpecificAttribute( QString & , QString & ); |
440 | virtual void saveSpecificAttribute( QTextStream & ); | 458 | virtual void saveSpecificAttribute( QTextStream & ); |
441 | 459 | ||
442 | QDict<QString> ValAttrPairs; | 460 | QDict<QString> ValAttrPairs; |
443 | }; | 461 | }; |
444 | 462 | ||
445 | extern FakeNetNode * FakeNode; | 463 | extern FakeNetNode * FakeNode; |
446 | 464 | ||
447 | #endif | 465 | #endif |