PACK WOC  $VERSION$
processor.h
Go to the documentation of this file.
1 // Copyright (C) 2009-2011 by Konrad Rosenbaum <konrad@silmor.de>
2 // protected under the GNU GPL version 3 or at your option any newer.
3 // See COPYING.GPL file that comes with this distribution.
4 //
5 
6 #ifndef WOC_PROCESSOR_H
7 #define WOC_PROCESSOR_H
8 
9 #include <QList>
10 #include <QMap>
11 #include <QObject>
12 #include <QPair>
13 #include <QStringList>
14 
15 class QDomElement;
16 
17 QList<QDomElement>elementsByTagName(const QDomElement&,QString);
18 
19 inline bool str2bool(QString s)
20 {
21  bool b;
22  int i=s.toInt(&b,0);
23  if(b)return i?true:false;
24  s=s.toLower();
25  if(s=="yes"||s=="y"||s=="on"||s=="true"||s=="t")return true;
26  return false;
27 }
28 
29 #include "procclass.h"
30 #include "proctable.h"
31 #include "proctrans.h"
32 
33 
35 class WocOutput:public QObject
36 {
37  Q_OBJECT
38  public:
40  WocOutput();
42  virtual ~WocOutput();
43 
44  protected slots:
46  virtual void newClass(const WocClass&)=0;
48  virtual void newTable(const WocTable&)=0;
50  virtual void newTransaction(const WocTransaction&)=0;
52  virtual void finalize()=0;
53  signals:
54  void errorFound();
55 };
56 
58 class WocProcessor:public QObject
59 {
60  Q_OBJECT
61  public:
62  WocProcessor();
63 
65  bool processFile(QString);
67  void finalize();
68 
70  static WocProcessor* instance(){return inst;}
71 
73  QString baseDir()const{return m_baseDir;}
75  QString wobDir()const{return m_wobDir;}
77  QString projectName()const{return m_projname;}
79  QString verComm()const{return m_verComm;}
81  QString verNeedComm()const{return m_verNeedComm;}
83  QString verHR()const{return m_verHR;}
85  QMap<QString,QString> versionInfo()const{return m_verInfo;}
87  QString dbInst()const{return m_dbInst;}
89  QString dbSchema()const{return m_dbSchema;}
91  QString dbVersion()const{return m_dbVer;}
93  QString dbConfigTable()const{return m_dbConfigTable;}
95  QString dbConfigKeyColumn()const{return m_dbConfigKey;}
97  QString dbConfigValueColumn()const{return m_dbConfigVal;}
99  QString dbVersionRow()const{return m_dbVersionRow;}
100 
102  QString xmlProjectNamespace()const{return m_xmlNS;}
104  QString xmlPackNamespace()const{return m_xmlPackNS;}
106  QString xmlSoap12Namespace()const{return m_xmlSoap12NS;}
108  QString xmlSchemaNamespace()const{return m_xmlSchemaNS;}
110  QString xmlXmlNamespace()const{return m_xmlXmlNS;}
111 
122  };
125 
127  enum AuthMode {
136  };
138  AuthMode authMode()const{return m_auth;}
139 
141  bool hasTable(QString)const;
143  WocTable table(QString)const;
144 
146  bool hasClass(QString)const;
147 
149  QStringList transactionNames()const;
151  QStringList classNames()const;
153  QStringList tableNames()const;
154 
156  QStringList docStrings()const{return m_docstrings;}
157 
159  QStringList privilegeNames()const;
160 
162  bool dbUpdatingDefault()const{return m_dbUpd;}
163  signals:
164  void sfinalize();
165  void newClass(const WocClass&);
166  void newTable(const WocTable&);
167  void newTransaction(const WocTransaction&);
168  public slots:
169  void errorFound();
170  private:
173  QMap<QString,QString>m_verInfo;
174  QStringList m_verSys;
177  QStringList m_docstrings;
181 
182  QList<WocTable> m_tables;
183  QList<WocClass> m_classes;
184  QList<WocTransaction> m_transactions;
185 
187 
189  bool callSvn();
191  bool callGit();
193  bool callNoVer();
194 
196  void parseNamespaces();
197 
199  AuthMode str2AuthMode(QString);
200 };
201 
202 
203 #endif
void newClass(const WocClass &)
QString m_verComm
Definition: processor.h:171
QStringList tableNames() const
returns a list of table names
Definition: processor.cpp:593
no authentication
Definition: processor.h:129
AuthMode authMode() const
returns the authentication mode
Definition: processor.h:138
WocOutput()
the constructor should set up and initialize the environment of the generator
Definition: processor.cpp:646
QString m_dbSchema
Definition: processor.h:175
QString xmlSoap12Namespace() const
returns the XML namespace for SOAP 1.2 elements
Definition: processor.h:106
QString m_dbConfigKey
Definition: processor.h:175
QString xmlPackNamespace() const
returns the XML namespace for Wob base elements
Definition: processor.h:104
QString dbConfigKeyColumn() const
returns the config key column
Definition: processor.h:95
bool dbUpdatingDefault() const
returns the default for the database "updating" attribute
Definition: processor.h:162
encode as standard WOB transactions
Definition: processor.h:115
bool callGit()
helper: calls GIT and parses its output
Definition: processor.cpp:411
stores the internal representation of a database table and its abstraction class
Definition: proctable.h:19
base class of all output generators
Definition: processor.h:35
void parseNamespaces()
helper: looks up some schema files and finds the corresponding namespaces
Definition: processor.cpp:625
QString m_dbVersionRow
Definition: processor.h:175
MessageEncoding messageEncoding() const
returns the message encoding mode
Definition: processor.h:124
encode as SOAP 1.2
Definition: processor.h:117
QString m_svnExe
Definition: processor.h:172
bool callNoVer()
helper: fallback for version control check
Definition: processor.cpp:534
session ID authentication
Definition: processor.h:131
QString m_dbVer
Definition: processor.h:175
QString m_verTarget
Definition: processor.h:172
void sfinalize()
virtual void newTransaction(const WocTransaction &)=0
called whenever the parser finds a new transaction; the parser guarantees that all referenced types e...
QString verHR() const
returns a human readable version string
Definition: processor.h:83
QString m_verNeedComm
Definition: processor.h:171
MessageEncoding m_encmode
Definition: processor.h:179
bool str2bool(QString s)
Definition: processor.h:19
QString m_wobDir
Definition: processor.h:171
QString dbSchema() const
returns the variable name that will contain the database schema object
Definition: processor.h:89
QString m_dbConfigVal
Definition: processor.h:175
virtual void newTable(const WocTable &)=0
called whenever the parser finds a new table in the XML input; the parser guarantees that tables it d...
AuthMode str2AuthMode(QString)
helper: converts Project/auth attribute to enum
Definition: processor.cpp:633
QString m_verHR
Definition: processor.h:171
QString m_xmlSchemaNS
Definition: processor.h:176
QString m_gitExe
Definition: processor.h:172
WocTable table(QString) const
returns the requested table
Definition: processor.cpp:558
QString wobDir() const
returns the directory where WOLFs are found, should normally not be used outside this class ...
Definition: processor.h:75
QString verComm() const
returns the current communication protocol version
Definition: processor.h:79
AuthMode m_auth
Definition: processor.h:180
QMap< QString, QString > versionInfo() const
returns version information about the project
Definition: processor.h:85
AuthMode
describes the authentication mode of the project
Definition: processor.h:127
static WocProcessor * inst
Definition: processor.h:186
QString m_xmlPackNS
Definition: processor.h:176
virtual ~WocOutput()
currently there is no guarantee that the destructor is ever called.
Definition: processor.cpp:655
encode according to the current SOAP standard
Definition: processor.h:119
static WocProcessor * instance()
returns the instance of the processor (if it exists yet)
Definition: processor.h:70
bool m_error
Definition: processor.h:178
QMap< QString, QString > m_verInfo
Definition: processor.h:173
central processing singleton
Definition: processor.h:58
virtual void newClass(const WocClass &)=0
called whenever the parser finds a new class in the XML input; some references might not exist yet ...
bool callSvn()
helper: calls SVN and parses its output
Definition: processor.cpp:254
basic user/password authentication
Definition: processor.h:133
QString m_xmlNS
Definition: processor.h:176
QString m_projname
Definition: processor.h:171
QString m_xmlXmlNS
Definition: processor.h:176
QString dbConfigValueColumn() const
returns the config value column
Definition: processor.h:97
QString dbVersionRow() const
returns the row containing the DB version in the config table
Definition: processor.h:99
QString projectName() const
returns the project name (default="WobProject")
Definition: processor.h:77
void errorFound()
QStringList classNames() const
returns a list of class names
Definition: processor.cpp:585
QStringList m_docstrings
Definition: processor.h:177
QStringList transactionNames() const
returns a list of transaction names
Definition: processor.cpp:577
QString dbVersion() const
returns the database schema version
Definition: processor.h:91
QString dbInst() const
returns the variable name that will contain the database driver instance
Definition: processor.h:87
QString m_baseDir
Definition: processor.h:171
internal representation of a transaction
Definition: proctrans.h:16
void errorFound()
Definition: processor.cpp:572
QString xmlXmlNamespace() const
returns the XML namespace for XML base elements
Definition: processor.h:110
bool m_dbUpd
Definition: processor.h:178
QList< WocTable > m_tables
Definition: processor.h:182
QString verNeedComm() const
returns the communication protocol version that is at least needed to be compatible ...
Definition: processor.h:81
QString m_dbInst
Definition: processor.h:175
QStringList docStrings() const
returns global docu
Definition: processor.h:156
bool hasClass(QString) const
returns whether a class exists
Definition: processor.cpp:565
void newTransaction(const WocTransaction &)
QList< QDomElement > elementsByTagName(const QDomElement &, QString)
Definition: processor.cpp:27
void finalize()
called from main loop to finalize its work
Definition: processor.cpp:546
QStringList privilegeNames() const
returns the qualified names of all privileges
Definition: processor.cpp:601
helper value: used in some parts of the code to simply query the processor for the encoding...
Definition: processor.h:121
QList< WocClass > m_classes
Definition: processor.h:183
QStringList m_verSys
Definition: processor.h:174
QString m_dbConfigTable
Definition: processor.h:175
void newTable(const WocTable &)
QString m_xmlSoap12NS
Definition: processor.h:176
bool processFile(QString)
called from main loop to parse a file
Definition: processor.cpp:65
MessageEncoding
describes the way message are encoded in transport
Definition: processor.h:113
virtual void finalize()=0
called when the parsing is complete: it should clean up the generators environment; it may not be cal...
WocProcessor()
Definition: processor.cpp:43
QString baseDir() const
returns the base directory of the project (all other pathes are relative to it)
Definition: processor.h:73
QString xmlSchemaNamespace() const
returns the XML namespace for Schema itself
Definition: processor.h:108
QString dbConfigTable() const
returns the config table name
Definition: processor.h:93
bool hasTable(QString) const
returns whether a table exists
Definition: processor.cpp:551
QList< WocTransaction > m_transactions
Definition: processor.h:184
stores a communication class including serialization and deserialization information ...
Definition: procclass.h:26
QString xmlProjectNamespace() const
returns the XML namespace of the project
Definition: processor.h:102
helper value: unknown authentication type, signifies an error condition
Definition: processor.h:135