summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/networksettings2/netnode.h
Side-by-side diff
Diffstat (limited to 'noncore/settings/networksettings2/networksettings2/netnode.h') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings2/networksettings2/netnode.h268
1 files changed, 189 insertions, 79 deletions
diff --git a/noncore/settings/networksettings2/networksettings2/netnode.h b/noncore/settings/networksettings2/networksettings2/netnode.h
index ca35c27..d3d7b34 100644
--- a/noncore/settings/networksettings2/networksettings2/netnode.h
+++ b/noncore/settings/networksettings2/networksettings2/netnode.h
@@ -7,2 +7,3 @@
#include <qpixmap.h>
+#include <qstringlist.h>
#include <qobject.h>
@@ -79,28 +80,54 @@ public:
- // pixmap needed for this NetNode
- virtual const QString pixmapName() = 0;
+ //
+ //
+ // standard methods with sensible default
+ //
+ //
- // description for this NetNode
- virtual const QString nodeDescription() = 0;
+ inline int done( void )
+ { return Done; }
+ inline void setDone( int D )
+ { Done = D; }
- // create a blank instance of a net node
- virtual ANetNodeInstance * createInstance( void ) = 0;
+ // does this Node provide a Connection
+ inline bool isToplevel( void )
+ { return strcmp( provides(), "fullsetup") == 0 ; }
- // return feature this NetNode provides
- virtual const char * provides( void ) = 0;
- virtual const char ** needs( void ) = 0;
+ // set the value of an attribute
+ void setAttribute( QString & Attr, QString & Value ) ;
+ void saveAttributes( QTextStream & TS ) ;
- // generate files specific for this node (if any)
- virtual bool generateProperFilesFor( ANetNodeInstance * NNI ) = 0;
- // return TRUE if this node has data to be inserted in systemfile
- // with name S
- virtual bool hasDataFor( const QString & S ) = 0;
- // generate data specific for the device for the system file S
- // called only IF data was needed
- virtual bool generateDeviceDataForCommonFile(
- SystemFile & SF, long DevNr ) = 0;
+ // compiled references to 'needed' NetNodes -> needs list
+ inline void setAlternatives( NetNodeList * Alt )
+ { Alternatives = Alt; }
+ inline NetNodeList & alternatives( void )
+ { return *Alternatives; }
+
+ //
+ //
+ // Virtual methods with sensible default
+ //
+ //
+
+ // do instances of this noce class have data for this file
+ virtual bool hasDataForFile( const QString & )
+ { return 0; }
+
+ // generate instance independent stuff
+ // 0 : data output, 1 no data, 2 error
+ virtual short generateFile( const QString & ,
+ const QString & ,
+ QTextStream & ,
+ long )
+ { return 1; }
+
+ // generate instance dependent but profile common stuff
+ // 0 : data output, 1 no data, 2 error
+ virtual short generateFile( const QString & ,
+ const QString & ,
+ QTextStream & ,
+ ANetNodeInstance * ,
+ long )
+ { return 1; }
- // does this Node provide a Connection
- bool isToplevel( void )
- { return strcmp( provides(), "fullsetup") == 0 ; }
@@ -116,11 +143,24 @@ public:
- // set the value of an attribute
- void setAttribute( QString & Attr, QString & Value ) ;
- void saveAttributes( QTextStream & TS ) ;
+ // return list of files that are specific for this node class
+ virtual QStringList * properFiles( void )
+ { return 0; }
- // compiled references to 'needed' NetNodes -> needs list
- void setAlternatives( NetNodeList * Alt )
- { Alternatives = Alt; }
- NetNodeList & alternatives( void )
- { return *Alternatives; }
+ //
+ //
+ // pure virtual methods with sensible default
+ //
+ //
+
+ // pixmap needed for this NetNode
+ virtual const QString pixmapName() = 0;
+
+ // description for this NetNode
+ virtual const QString nodeDescription() = 0;
+
+ // create a blank instance of a net node
+ virtual ANetNodeInstance * createInstance( void ) = 0;
+
+ // return feature this NetNode provides
+ virtual const char * provides( void ) = 0;
+ virtual const char ** needs( void ) = 0;
@@ -134,2 +174,3 @@ private :
virtual void saveSpecificAttribute( QTextStream & ) = 0;
+ int Done;
@@ -145,23 +186,13 @@ public:
- virtual RuntimeInfo * runtime( void ) = 0;
-
- void setConnection( NodeCollection * NC )
- { Connection = NC; }
- NodeCollection * connection( void )
- { return Connection; }
-
- // create edit widget under parent
- virtual QWidget * edit( QWidget * parent ) = 0;
- // is given data acceptable
- virtual QString acceptable( void ) = 0;
+ inline int done( void )
+ { return Done; }
+ inline void setDone( int D )
+ { Done = D; }
// return data was modified
- void setModified( bool M )
+ inline void setModified( bool M )
{ IsModified = M; }
- bool isModified( void )
+ inline bool isModified( void )
{ return IsModified; }
- // get data from GUI and store in node
- virtual void commit( void ) = 0;
-
// get next node
@@ -180,5 +211,5 @@ public:
// return true if node isntance is NEW and not loaded
- void setNew( bool IsN )
+ inline void setNew( bool IsN )
{ IsNew = IsN; }
- bool isNew( void )
+ inline bool isNew( void )
{ return IsNew; }
@@ -186,5 +217,5 @@ public:
// return description for this instance
- QString & description( void )
+ inline QString & description( void )
{ return Description; }
- void setDescription( const QString & S )
+ inline void setDescription( const QString & S )
{ Description = S; }
@@ -192,22 +223,78 @@ public:
// pixmap for this instance -> from NetNode
- const QString pixmapName( void )
+ inline const QString pixmapName( void )
{ return NodeType->pixmapName(); }
- const char * provides( void )
+ inline const char * provides( void )
{ return NodeType->provides(); }
- const char ** needs( void )
+ inline const char ** needs( void )
{ return NodeType->needs(); }
- // returns node specific data -> only useful for 'buddy'
- virtual void * data( void ) = 0;
+ inline void setConnection( NodeCollection * NC )
+ { Connection = NC; }
+ inline NodeCollection * connection( void )
+ { return Connection; }
+
+ //
+ //
+ // Virtual methods with sensible defaults
+ //
+ //
- // return TRUE if this node has data to be inserted in systemfile
- // with name S
- virtual bool hasDataFor( const QString & S ) = 0;
- // generate data specific for a profile and for the system file S
- // called only IF data was needed
- virtual bool generateDataForCommonFile(
- SystemFile & SF, long DevNr ) = 0;
+
+ // open proper file identified by S
+ virtual QFile * openFile( const QString & )
+ { return 0; }
+
+ // check if this node (or sub nodes) have data for this file
+ virtual bool hasDataForFile( const QString & S )
+ { return nodeClass()->hasDataForFile( S ); }
+
+ // generate code specific for this node but embedded
+ // in the section of the parent
+ // this is called within the code of the parent
+ virtual short generateFileEmbedded( const QString & ID,
+ const QString & Path,
+ QTextStream & TS,
+ long DevNr )
+ { ANetNodeInstance * NNI = nextNode();
+ return (NNI) ? NNI->generateFileEmbedded( ID, Path, TS, DevNr ) : 1;
+ }
+
+ // generate code specific for this node
+ // (or find the first node that does)
+ virtual short generateFile( const QString & ID,
+ const QString & Path,
+ QTextStream & TS,
+ long DevNr )
+ { ANetNodeInstance * NNI = nextNode();
+ return (NNI) ? NNI->generateFile( ID, Path, TS, DevNr ) : 1;
+ }
+
+ // return true if this node instance is triggered by this trigger
+ // could be delegated to deeper instances
+ virtual bool triggeredBy( const QString & )
+ { return 0; }
+
+ //
+ //
+ // Pure virtual functions
+ //
+ //
+
+ // return runtime information for this node
+ virtual RuntimeInfo * runtime( void ) = 0;
+
+ // create edit widget under parent
+ virtual QWidget * edit( QWidget * parent ) = 0;
+
+ // is given data acceptable
+ virtual QString acceptable( void ) = 0;
+
+ // get data from GUI and store in node
+ virtual void commit( void ) = 0;
+
+ // returns node specific data -> only useful for 'buddy'
+ virtual void * data( void ) = 0;
@@ -224,2 +311,3 @@ protected :
bool IsNew;
+ int Done;
@@ -284,16 +372,21 @@ public :
- int number( void )
+ inline int done( void )
+ { return Done; }
+ inline void setDone( int D )
+ { Done = D; }
+
+ inline int number( void )
{ return Number; }
- void setNumber( int i )
+ inline void setNumber( int i )
{ Number = i; }
- bool isNew( void )
+ inline bool isNew( void )
{ return IsNew; }
- void setNew( bool N )
+ inline void setNew( bool N )
{ IsNew = N ; }
- bool isModified( void )
+ inline bool isModified( void )
{ return IsModified; }
- void setModified( bool N )
+ inline void setModified( bool N )
{ IsModified = N ; }
- bool handlesInterface( const QString & S ) {
+ inline bool handlesInterface( const QString & S ) {
return getToplevel()->runtime()->handlesInterface( S );
@@ -301,3 +394,3 @@ public :
- InterfaceInfo * assignedInterface( void ) {
+ inline InterfaceInfo * assignedInterface( void ) {
return getToplevel()->runtime()->assignedInterface();
@@ -305,3 +398,3 @@ public :
- AsDevice * device() {
+ inline AsDevice * device() {
return getToplevel()->runtime()->device();
@@ -311,3 +404,3 @@ public :
- State_t state( bool Update = 0 )
+ inline State_t state( bool Update = 0 )
{ Log(( "%s state %d(=%d?)\n", Name.latin1(), CurrentState,
@@ -327,11 +420,11 @@ public :
QPixmap statePixmap( State_t S );
- QPixmap statePixmap( bool Update = 0 )
+ inline QPixmap statePixmap( bool Update = 0 )
{ return statePixmap( state(Update) ); }
QString stateName( State_t );
- QString stateName( bool Update = 0 )
+ inline QString stateName( bool Update = 0 )
{ return stateName( state(Update) ); }
- bool setState( Action_t A, bool Force =0 )
+ inline bool setState( Action_t A, bool Force =0 )
{ return getToplevel()->runtime()->setState( this, A, Force ); }
- bool canSetState( Action_t A )
+ inline bool canSetState( Action_t A )
{ return getToplevel()->runtime()->canSetState( CurrentState, A ); }
@@ -350,3 +443,3 @@ public :
- const QString & name()
+ inline const QString & name()
{ return Name; }
@@ -355,10 +448,26 @@ public :
- void setName( const QString & N)
+ inline void setName( const QString & N)
{ Name = N; }
- State_t currentState( void )
+ inline State_t currentState( void )
{ return CurrentState; }
- void setCurrentState( State_t S )
+ inline void setCurrentState( State_t S )
{ CurrentState = S; }
+ // return TRUE if this node can have data to be inserted in
+ // file identified by S
+ bool hasDataForFile( const QString & S );
+ ANetNodeInstance * firstWithDataForFile( const QString & S );
+
+ // generate items for this file -> toplevel call
+ short generateFile( const QString & FID, // identification of file
+ const QString & FName, // effective filename of file
+ QTextStream & TS, // stream to file
+ long DN // device number
+ )
+ { return getToplevel()->generateFile( FID, FName, TS, DN ); }
+
+ bool triggeredBy( const QString & Trigger )
+ { return getToplevel()->triggeredBy( Trigger ); }
+
private :
@@ -380,2 +489,3 @@ private :
bool IsModified;
+ int Done;