From c0502cfdfbd9fadcac11b1102078345cbda91166 Mon Sep 17 00:00:00 2001 From: Konrad Rosenbaum Date: Sun, 3 Feb 2013 19:38:41 +0100 Subject: [PATCH] allow object sharing between Qt outputs --- doc/index.html | 6 +++--- doc/wolf-comm.html | 6 ++++++ doc/wolf.html | 5 +++++ woc/qt/qtclass.cpp | 2 +- woc/qt/qtout.cpp | 15 +++++++++------ woc/qt/qtout.h | 4 +++- 6 files changed, 27 insertions(+), 11 deletions(-) diff --git a/doc/index.html b/doc/index.html index 993bd58..67774ce 100644 --- a/doc/index.html +++ b/doc/index.html @@ -16,7 +16,7 @@ The following languages are currently supported:
C++/Qt 4.x yes - planned + partial (no tables) PHP 5.x @@ -41,10 +41,10 @@ The following languages are currently supported:

Building PACK

For compiling PACK you need a C++ compiler (eg. GCC) and Qt4.x. -The meta-compiler WOC requires at least Qt 4.4, the Qt binding itself requires at least Qt 4.7. +The meta-compiler WOC and the Qt binding require at least Qt 4.7 or 5.x. For compiling and running generated code it all depends on your target:
- +
C++/QtA C++ compiler and at least Qt 4.7, modules: Core, Network, XML, optionally XMLpatterns
C++/QtA C++ compiler and at least Qt 4.7 or 5.x, modules: Core, Network, XML, optionally XMLpatterns
PHPPHP, at least version 5.2
SOAPany compatible toolkit that can handle WSDL files

diff --git a/doc/wolf-comm.html b/doc/wolf-comm.html index 6b0ca2e..7ec54a6 100644 --- a/doc/wolf-comm.html +++ b/doc/wolf-comm.html @@ -14,12 +14,18 @@ An example class can be seen here: <Base lang="php/client" class="MyBaseClass"/> <Enum name="TicketState" refColumn="ticket:status"/> + <Enum name="StateOfMind"> + <Value name="sad"/> + <Value name="funny"/> + <Value name="dontcare"/> + </Enum> <Property name="ticketid" type="astring" id="yes"/> <Property name="eventid" type="int"/> <Property name="priceid" type="int"/> <Property name="price" type="Price"/> <Property name="status" type="TicketState"/> <Property name="orderid" type="int"/> + <Property name="stateofmind" type="StateOfMind" optional="yes"/> <Abstract lang="php"/> diff --git a/doc/wolf.html b/doc/wolf.html index 1145352..7d60e50 100644 --- a/doc/wolf.html +++ b/doc/wolf.html @@ -60,6 +60,7 @@ Outputs should be declared after the basics have been declared, but before any t

 <QtClientOutput sourceDir="src" subDir="wob" priInclude="wob.pri" transactionBase="WTransaction" validate="no"/>
+<QtServerOutput sourceDir="src" subDir="wob" priInclude="wob.pri" transactionBase="WTransaction" validate="no"/>
 <PHPServerOutput sourceDir="www" subDir="inc/wob" extension=".php" clean="yes" transactionBase="WobTransaction" validate="no"/>
 <HtmlOutput sourceDir="doc" subDir="wob"/>
 <SchemaOutput sourceDir="schema" filename="project.xsd" compound="compound.xsd"/>
@@ -73,6 +74,10 @@ The optional validate attribute lets you decide whether incoming messages should
 
 The QtClientOutput tag tells woc to create a generator for a Qt based client - the priInclude attribute tells woc which name it should give to the QMake include for its generated output. The transactionBase attribute allows to chose an extended class as base class of generated transactions - usually this should not be necessary for Qt client targets.

+The QtServerOutput tag tells woc to create a generator for a Qt based server, the attributes are the same as for the client output.

+ +With both Qt bases outputs you can optionally specify a shareObjects attribute - if present it contains the class prefix for communication objects. If that prefix is different from the one given as classPrefix woc will assume that some other output will create those objects and not create them in this output. This feature is meant for the case in which client and server reside in the same translation unit and share the same objects (transactions and interfaces can unfortunately not be shared).

+ The PHPServerOutput tag tells woc to create a generator for a PHP based server. The "extension" attribute tells woc which file extension to use for the generated files (default is .php). Woc will automatically create a "autoload" (plus extension) file that should be included from the main body of the PHP project to load the automatically generated classes. The transactionBase attribute allows to chose an extended class as base class of generated transactions - it is recommended to overwrite some protected functions in order to be able to get more information inside transactions.

The HtmlOutput tag tells woc where to generate API documentation. This target generates generic high level documentation for all configured tables, classes, and transactions. Use doxygen or a similar tool to generate language target specific documentation.

diff --git a/woc/qt/qtclass.cpp b/woc/qt/qtclass.cpp index 288fcd4..74ee73b 100644 --- a/woc/qt/qtclass.cpp +++ b/woc/qt/qtclass.cpp @@ -29,7 +29,7 @@ void WocQtClass::finalize() void WocQtClass::newClass(const WocClass&cls) { - QString cn=m_parent->namePrefix()+"O"+cls.name(); + QString cn=m_parent->sharedPrefix()+"O"+cls.name(); QString cna=cn; if(cls.isAbstract(m_parent->languageSpec()))cna+="Abstract"; m_parent->addFile(cna); diff --git a/woc/qt/qtout.cpp b/woc/qt/qtout.cpp index 8eb38ce..f36cdcd 100644 --- a/woc/qt/qtout.cpp +++ b/woc/qt/qtout.cpp @@ -20,11 +20,12 @@ WocQtOut::WocQtOut(QDomElement&el) { qclass=0;qtable=0;qtrans=0; - qDebug("Info: creating Qt Client Output Generator."); + qDebug("Info: creating %s Generator.",el.tagName().toLatin1().data()); m_basedir=WocProcessor::instance()->baseDir()+"/"+el.attribute("sourceDir","."); m_subdir=el.attribute("subDir","qtwob"); m_clean=str2bool(el.attribute("clean","0")); m_prefix=el.attribute("classPrefix","Wob"); + m_cprefix=el.attribute("shareObjects",m_prefix); m_transbase=el.attribute("transactionBase","WTransaction"); m_genscript=str2bool(el.attribute("scriptable","0")); //get/create directory @@ -198,7 +199,7 @@ QString WocQtOut::qttype(const WocClass&cls,QString p,bool dolist) if(cls.propertyIsInt(p))r+="qint64";else if(cls.propertyIsBool(p))r+="bool";else if(cls.propertyIsBlob(p))r+="QByteArray";else - if(cls.propertyIsObject(p))r+=m_prefix+"O"+cls.propertyPlainType(p); + if(cls.propertyIsObject(p))r+=m_cprefix+"O"+cls.propertyPlainType(p); else r+=cls.propertyPlainType(p); r+=">"; return r; @@ -223,7 +224,7 @@ QString WocQtOut::qttype(const WocTransaction&trn,QString v,InOut io) if(tp==""){ qDebug("Warning: the final type of property %s is empty!",v.toLatin1().data()); r+="void"; - }else r+=m_prefix+"O"+tp.split("/",QString::SkipEmptyParts).at(0); + }else r+=m_cprefix+"O"+tp.split("/",QString::SkipEmptyParts).at(0); r+=e;r+=" "; return r; } @@ -236,14 +237,15 @@ QString WocQtOut::qtobjtype(const WocTransaction&trn,QString v,InOut io) if(tp=="astring" || tp=="string" || tp=="int" || tp=="int32" || tp=="int64" || tp=="bool" || tp=="blob") return ""; else - return m_prefix+"O"+tp; + return m_cprefix+"O"+tp; } WocQtClientOut::WocQtClientOut(QDomElement&el) :WocQtOut(el) { m_lang="qt/client"; - qclass=new WocQtClass(this); + if(namePrefix()==sharedPrefix()) + qclass=new WocQtClass(this); qtrans=new WocQtClientTransaction(this); } @@ -251,7 +253,8 @@ WocQtServerOut::WocQtServerOut(QDomElement& el) :WocQtOut(el) { m_lang="qt/server"; - qclass=new WocQtClass(this); + if(namePrefix()==sharedPrefix()) + qclass=new WocQtClass(this); qtrans=new WocQtServerTransaction(this); qtable=new WocQtTable(this); } diff --git a/woc/qt/qtout.h b/woc/qt/qtout.h index 5519950..4a674fb 100644 --- a/woc/qt/qtout.h +++ b/woc/qt/qtout.h @@ -103,6 +103,8 @@ class WocQtOut:public WocOutput ///returns the class name prefix configured for this output inline QString namePrefix()const{return m_prefix;} + ///returns the class name prefix for shared or unshared classes + inline QString sharedPrefix()const{return m_cprefix;} ///returns the language output spec inline QString languageSpec()const{return m_lang;} ///returns the base directory of the project @@ -121,7 +123,7 @@ class WocQtOut:public WocOutput void initVersionH(); private: - QString m_basedir,m_subdir,m_prefix,m_transbase,m_postiface,m_scriptcode; + QString m_basedir,m_subdir,m_prefix,m_cprefix,m_transbase,m_postiface,m_scriptcode; bool m_clean,m_genscript; MFile m_pri,m_iface,m_ifacecpp,m_hdr; QString m_iface_prefix,m_iface_class; -- 1.7.2.5