]> granicus.if.org Git - icinga2/commitdiff
Move implementation code from thpp files into separate files
authorGunnar Beutner <gunnar@beutner.name>
Sat, 28 Mar 2015 10:04:42 +0000 (11:04 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Sat, 28 Mar 2015 10:08:12 +0000 (11:08 +0100)
fixes #8890

69 files changed:
lib/base/CMakeLists.txt
lib/base/application.cpp
lib/base/dynamicobject.cpp
lib/base/dynamicobject.ti
lib/base/exception.cpp
lib/base/exception.hpp
lib/base/filelogger.cpp
lib/base/logger.cpp
lib/base/streamlogger.cpp
lib/base/sysloglogger.cpp
lib/checker/CMakeLists.txt
lib/checker/checkercomponent.cpp
lib/cli/repositoryutility.cpp
lib/compat/CMakeLists.txt
lib/compat/checkresultreader.cpp
lib/compat/compatlogger.cpp
lib/compat/externalcommandlistener.cpp
lib/compat/statusdatawriter.cpp
lib/db_ido/CMakeLists.txt
lib/db_ido/dbconnection.cpp
lib/db_ido_mysql/CMakeLists.txt
lib/db_ido_mysql/idomysqlconnection.cpp
lib/db_ido_pgsql/CMakeLists.txt
lib/db_ido_pgsql/idopgsqlconnection.cpp
lib/demo/CMakeLists.txt
lib/demo/demo.cpp
lib/hello/CMakeLists.txt
lib/hello/hello.cpp
lib/icinga/CMakeLists.txt
lib/icinga/checkable.cpp
lib/icinga/checkcommand.cpp
lib/icinga/checkresult.cpp
lib/icinga/command.cpp
lib/icinga/comment.cpp
lib/icinga/customvarobject.cpp
lib/icinga/dependency.cpp
lib/icinga/downtime.cpp
lib/icinga/eventcommand.cpp
lib/icinga/host.cpp
lib/icinga/hostgroup.cpp
lib/icinga/icingaapplication.cpp
lib/icinga/icingastatuswriter.cpp
lib/icinga/notification.cpp
lib/icinga/notificationcommand.cpp
lib/icinga/perfdatavalue.cpp
lib/icinga/scheduleddowntime.cpp
lib/icinga/service.cpp
lib/icinga/servicegroup.cpp
lib/icinga/timeperiod.cpp
lib/icinga/user.cpp
lib/icinga/usergroup.cpp
lib/livestatus/CMakeLists.txt
lib/livestatus/livestatuslistener.cpp
lib/notification/CMakeLists.txt
lib/notification/notificationcomponent.cpp
lib/perfdata/CMakeLists.txt
lib/perfdata/gelfwriter.cpp
lib/perfdata/graphitewriter.cpp
lib/perfdata/opentsdbwriter.cpp
lib/perfdata/perfdatawriter.cpp
lib/remote/CMakeLists.txt
lib/remote/apiclient-heartbeat.cpp
lib/remote/apilistener.cpp
lib/remote/endpoint.cpp
lib/remote/zone.cpp
tools/mkclass/CMakeLists.txt
tools/mkclass/classcompiler.cpp
tools/mkclass/classcompiler.hpp
tools/mkclass/mkclass.cpp

index fb7cea75e96a4713467731c226e8c3185926a057..726c490a92b10f8fa01d6aaa0d9af79e9e7e3027 100644 (file)
 # along with this program; if not, write to the Free Software Foundation
 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
-mkclass_target(application.ti application.thpp)
-mkclass_target(dynamicobject.ti dynamicobject.thpp)
-mkclass_target(filelogger.ti filelogger.thpp)
-mkclass_target(logger.ti logger.thpp)
-mkclass_target(streamlogger.ti streamlogger.thpp)
-mkclass_target(sysloglogger.ti sysloglogger.thpp)
+mkclass_target(application.ti application.tcpp application.thpp)
+mkclass_target(dynamicobject.ti dynamicobject.tcpp dynamicobject.thpp)
+mkclass_target(filelogger.ti filelogger.tcpp filelogger.thpp)
+mkclass_target(logger.ti logger.tcpp logger.thpp)
+mkclass_target(streamlogger.ti streamlogger.tcpp streamlogger.thpp)
+mkclass_target(sysloglogger.ti sysloglogger.tcpp sysloglogger.thpp)
 
 set(base_SOURCES
-  application.cpp application-version.cpp application.thpp array.cpp array-script.cpp boolean.cpp boolean-script.cpp console.cpp context.cpp
+  application.cpp application.thpp application-version.cpp array.cpp array-script.cpp boolean.cpp boolean-script.cpp console.cpp context.cpp
   convert.cpp debuginfo.cpp dictionary.cpp dictionary-script.cpp dynamicobject.cpp dynamicobject.thpp dynamictype.cpp
   exception.cpp fifo.cpp filelogger.cpp filelogger.thpp initialize.cpp json.cpp json-script.cpp loader.cpp logger.cpp logger.thpp math-script.cpp
   netstring.cpp networkstream.cpp number.cpp number-script.cpp object.cpp object-script.cpp primitivetype.cpp process.cpp
index bbf2135ded9b16960ec961537e9eeed06de32d16..55d9f8367b12133d9b005f223c048ce38141df39 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "base/application.hpp"
+#include "base/application.tcpp"
 #include "base/stacktrace.hpp"
 #include "base/timer.hpp"
 #include "base/logger.hpp"
index e29e51022e63611a44a359e554c8d3544e66f280..6c5006288661a8fc76ef3bfd6753123f571eda3d 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "base/dynamicobject.hpp"
+#include "base/dynamicobject.tcpp"
 #include "base/dynamictype.hpp"
 #include "base/serializer.hpp"
 #include "base/netstring.hpp"
index df8bdb1543105de9d909d01a6011534dbbde27e2..4351c90cabbae1b1cf4b1bc48b39eea5faf74cfe 100644 (file)
@@ -17,6 +17,8 @@
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
  ******************************************************************************/
 
+#include "base/debuginfo.hpp"
+
 namespace icinga
 {
 
index a68e0da59281d0d13ec139058ae92904d82b400a..a079837e56b101d263283b42824bd30ae1a9901e 100644 (file)
@@ -18,8 +18,8 @@
  ******************************************************************************/
 
 #include "base/exception.hpp"
-#include "base/dynamicobject.hpp"
 #include <boost/thread/tss.hpp>
+#include <boost/foreach.hpp>
 
 #ifdef HAVE_CXXABI_H
 #      include <cxxabi.h>
@@ -154,7 +154,7 @@ String icinga::DiagnosticInformation(const std::exception& ex, bool verbose, Sta
        if (vex) {
                DebugInfo di;
 
-               DynamicObject::Ptr dobj = dynamic_pointer_cast<DynamicObject>(vex->GetObject());
+               DynamicObject::Ptr dobj = vex->GetObject();
                if (dobj)
                        di = dobj->GetDebugInfo();
 
@@ -313,7 +313,7 @@ const char *posix_error::what(void) const throw()
        return m_Message;
 }
 
-ValidationError::ValidationError(const intrusive_ptr<ObjectImpl<DynamicObject> >& object, const std::vector<String>& attributePath, const String& message)
+ValidationError::ValidationError(const DynamicObject::Ptr& object, const std::vector<String>& attributePath, const String& message)
        : m_Object(object), m_AttributePath(attributePath), m_Message(message)
 {
        String path;
@@ -342,7 +342,7 @@ const char *ValidationError::what(void) const throw()
        return m_What.CStr();
 }
 
-intrusive_ptr<ObjectImpl<DynamicObject> > ValidationError::GetObject(void) const
+DynamicObject::Ptr ValidationError::GetObject(void) const
 {
        return m_Object;
 }
index 15f449f123c0574fd266b0e16bed724bfee3b290..daeed9677bd752cb960fca589f88aa8819da8d35 100644 (file)
@@ -27,6 +27,7 @@
 #include "base/utility.hpp"
 #include "base/debuginfo.hpp"
 #include "base/dictionary.hpp"
+#include "base/dynamicobject.hpp"
 #include <sstream>
 #include <boost/exception/errinfo_api_function.hpp>
 #include <boost/exception/errinfo_errno.hpp>
@@ -65,21 +66,18 @@ private:
        bool m_IncompleteExpr;
 };
 
-class DynamicObject;
-template<> class ObjectImpl<DynamicObject>;
-
 /*
  * @ingroup base
  */
 class I2_BASE_API ValidationError : virtual public user_error
 {
 public:
-       ValidationError(const intrusive_ptr<ObjectImpl<DynamicObject> >& object, const std::vector<String>& attributePath, const String& message);
+       ValidationError(const DynamicObject::Ptr& object, const std::vector<String>& attributePath, const String& message);
        ~ValidationError(void) throw();
 
        virtual const char *what(void) const throw();
 
-       intrusive_ptr<ObjectImpl<DynamicObject> > GetObject(void) const;
+       DynamicObject::Ptr GetObject(void) const;
        std::vector<String> GetAttributePath(void) const;
        String GetMessage(void) const;
 
@@ -87,7 +85,7 @@ public:
        Dictionary::Ptr GetDebugHint(void) const;
 
 private:
-       intrusive_ptr<ObjectImpl<DynamicObject> > m_Object;
+       DynamicObject::Ptr m_Object;
        std::vector<String> m_AttributePath;
        String m_Message;
        String m_What;
index b15234f70b332bd72dd13e8d507516f882d2bd33..ab981bb7665c1d276b3968004a741b618d9edb08 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "base/filelogger.hpp"
+#include "base/filelogger.tcpp"
 #include "base/dynamictype.hpp"
 #include "base/statsfunction.hpp"
 #include "base/application.hpp"
index 4c15c5d3d43b27664967d401a46ae244b764c908..4ffe3ef2b923825fe416b3796903b90509c36b00 100644 (file)
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
  ******************************************************************************/
 
+#include "base/logger.hpp"
+#include "base/logger.tcpp"
 #include "base/application.hpp"
 #include "base/streamlogger.hpp"
-#include "base/logger.hpp"
 #include "base/dynamictype.hpp"
 #include "base/utility.hpp"
 #include "base/objectlock.hpp"
index d3b0ca8a94694de921fc02a0393dd4768d341d67..63ac98f6a28663c674443dbd34b1305ffea32b45 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "base/streamlogger.hpp"
+#include "base/streamlogger.tcpp"
 #include "base/utility.hpp"
 #include "base/objectlock.hpp"
 #include "base/console.hpp"
index f806cf6b062f62756b03fd26cf85fb67827f9e11..34cffbcdd2c33aabbe6cfe6b89b7bb92b693c9f7 100644 (file)
@@ -22,6 +22,8 @@
 #include "base/statsfunction.hpp"
 
 #ifndef _WIN32
+#include "base/sysloglogger.tcpp"
+
 using namespace icinga;
 
 REGISTER_TYPE(SyslogLogger);
index d8f422dfb02f3d4ce34ff697beb0432716953f3f..3a7b5a742f3cc2d753e434616ec4df1a542ca296 100644 (file)
@@ -15,7 +15,7 @@
 # along with this program; if not, write to the Free Software Foundation
 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
-mkclass_target(checkercomponent.ti checkercomponent.thpp)
+mkclass_target(checkercomponent.ti checkercomponent.tcpp checkercomponent.thpp)
 
 set(checker_SOURCES
   checkercomponent.cpp checkercomponent.thpp
index 89e5b015b4e49604a40ba61d9df36806e18a8a2e..7bb5eef1cf12bd1f71607ac57f4d8682122fe071 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "checker/checkercomponent.hpp"
+#include "checker/checkercomponent.tcpp"
 #include "icinga/icingaapplication.hpp"
 #include "icinga/cib.hpp"
 #include "icinga/perfdatavalue.hpp"
index d7b0e0ecd655842d24f6435bb96af026e453e90e..d1fa88b3aa193f4bdc093d4246628bf4360704a5 100644 (file)
@@ -31,6 +31,7 @@
 #include "base/objectlock.hpp"
 #include "base/console.hpp"
 #include "base/serializer.hpp"
+#include "base/exception.hpp"
 #include <boost/foreach.hpp>
 #include <boost/algorithm/string/join.hpp>
 #include <boost/algorithm/string/replace.hpp>
index 60a4d9a1e0cde9a55ab105f7f783c48ffeb59fa7..eef148eec37124dcbc4e6ff750054a9816e3e9ed 100644 (file)
 # along with this program; if not, write to the Free Software Foundation
 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
-mkclass_target(checkresultreader.ti checkresultreader.thpp)
-mkclass_target(compatlogger.ti compatlogger.thpp)
-mkclass_target(externalcommandlistener.ti externalcommandlistener.thpp)
-mkclass_target(statusdatawriter.ti statusdatawriter.thpp)
+mkclass_target(checkresultreader.ti checkresultreader.tcpp checkresultreader.thpp)
+mkclass_target(compatlogger.ti compatlogger.tcpp compatlogger.thpp)
+mkclass_target(externalcommandlistener.ti externalcommandlistener.tcpp externalcommandlistener.thpp)
+mkclass_target(statusdatawriter.ti statusdatawriter.tcpp statusdatawriter.thpp)
 
 set(compat_SOURCES
   checkresultreader.cpp checkresultreader.thpp compatlogger.cpp
index ac2b30c15f242e1259366acc25f3797df9d57376..6433d055a7230970311cd5750e28cc3116e46bfb 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "compat/checkresultreader.hpp"
+#include "compat/checkresultreader.tcpp"
 #include "icinga/service.hpp"
 #include "icinga/pluginutility.hpp"
 #include "icinga/icingaapplication.hpp"
index c5cc9b424291c590e01f53e18b426ff445021e3d..90dd2aafeb795c0e887598638d6ffe61ca583ac7 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "compat/compatlogger.hpp"
+#include "compat/compatlogger.tcpp"
 #include "icinga/service.hpp"
 #include "icinga/checkcommand.hpp"
 #include "icinga/eventcommand.hpp"
index 95c6fc6037f2e7ffeac86203c149eb5d7022f895..6c96a4c745a384f47e4a9fb8a13dfb95d76207a6 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "compat/externalcommandlistener.hpp"
+#include "compat/externalcommandlistener.tcpp"
 #include "icinga/externalcommandprocessor.hpp"
 #include "base/dynamictype.hpp"
 #include "base/logger.hpp"
index 699f0b605ed33a24866125cff1eda0f63e694fd3..e5e5f24ba38920edcaa4d043a8ad6c56868a512a 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "compat/statusdatawriter.hpp"
+#include "compat/statusdatawriter.tcpp"
 #include "icinga/icingaapplication.hpp"
 #include "icinga/cib.hpp"
 #include "icinga/hostgroup.hpp"
index 0cec9ea024b927a8e3048a7ae4b63f21bcd9a1c0..9a7baa361d96e4a30e375cc3681818493c321cb2 100644 (file)
 # along with this program; if not, write to the Free Software Foundation
 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
-mkclass_target(dbconnection.ti dbconnection.thpp)
+mkclass_target(dbconnection.ti dbconnection.tcpp dbconnection.thpp)
 
 mkembedconfig_target(db_ido-itl.conf db_ido-itl.cpp)
 
 set(db_ido_SOURCES
-  commanddbobject.cpp dbconnection.cpp dbconnection.thpp dbconnection.thpp
+  commanddbobject.cpp dbconnection.cpp dbconnection.thpp
   db_ido-itl.cpp dbevents.cpp dbobject.cpp dbquery.cpp
   dbreference.cpp dbtype.cpp dbvalue.cpp endpointdbobject.cpp hostdbobject.cpp
   hostgroupdbobject.cpp idochecktask.cpp servicedbobject.cpp
index fe8e011b184a0e93d305a58fedb178932226749c..8c91fe7c853de2e2423048374ec75268ed871a49 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "db_ido/dbconnection.hpp"
+#include "db_ido/dbconnection.tcpp"
 #include "db_ido/dbvalue.hpp"
 #include "icinga/icingaapplication.hpp"
 #include "icinga/host.hpp"
index 61d57232a07bda1e1f2ffb3524304aa8fac76107..d4e2bb92141099c3a35cfa18078001d01125e61e 100644 (file)
@@ -18,7 +18,7 @@
 find_package(MySQL)
 
 if(MYSQL_FOUND)
-  mkclass_target(idomysqlconnection.ti idomysqlconnection.thpp)
+  mkclass_target(idomysqlconnection.ti idomysqlconnection.tcpp idomysqlconnection.thpp)
 
   set(db_ido_mysql_SOURCES
     idomysqlconnection.cpp idomysqlconnection.thpp
index c74d62fa29fc6ce9c391db256f440eca2d82aea5..b6532dcc71d177c8a38d4533df8555f053c83ded 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "icinga/perfdatavalue.hpp"
+#include "icinga/perfdatavalue.tcpp"
 #include "db_ido/dbtype.hpp"
 #include "db_ido/dbvalue.hpp"
 #include "db_ido_mysql/idomysqlconnection.hpp"
index 06da5143dcbb5b0385bbed1c9354d2642bfee5c9..0d7d52a0ce9dc0554d8d544ca33fcc1913b30d6b 100644 (file)
@@ -18,7 +18,7 @@
 find_package(PostgreSQL)
 
 if(PostgreSQL_FOUND)
-  mkclass_target(idopgsqlconnection.ti idopgsqlconnection.thpp)
+  mkclass_target(idopgsqlconnection.ti idopgsqlconnection.tcpp idopgsqlconnection.thpp)
 
   link_directories(${PostgreSQL_LIBRARY_DIRS})
   include_directories(${PostgreSQL_INCLUDE_DIRS})
index dd8884736ade14f78a8bc0752b7d372a93691d1b..ab9333133fe658b205e5f09a7542648a57a4ddc6 100644 (file)
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
  ******************************************************************************/
 
+#include "db_ido_pgsql/idopgsqlconnection.hpp"
+#include "db_ido_pgsql/idopgsqlconnection.tcpp"
 #include "db_ido/dbtype.hpp"
 #include "db_ido/dbvalue.hpp"
-#include "db_ido_pgsql/idopgsqlconnection.hpp"
 #include "icinga/perfdatavalue.hpp"
 #include "base/logger.hpp"
 #include "base/objectlock.hpp"
index 2484d356acd556b8c93a1048d02f31d86147fc55..92fa2bd22eff7782070e758302bda0a33d25dced 100644 (file)
@@ -15,7 +15,7 @@
 # along with this program; if not, write to the Free Software Foundation
 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
-mkclass_target(demo.ti demo.thpp)
+mkclass_target(demo.ti demo.tcpp)
 
 set(demo_SOURCES
   demo.cpp demo.thpp
index 598aacdd867c2aa91d406079c0e72646a6ef0ed4..1b076f6027496fae11fa97fde9abb380b5ec8c94 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "demo/demo.hpp"
+#include "demo/demo.tcpp"
 #include "remote/apilistener.hpp"
 #include "remote/apifunction.hpp"
 #include "base/dynamictype.hpp"
index d9ff7017ad4d60fe335c2b0ca4370cf804072b48..cbfa8746a5496efd3f6898eb62eb31d277fd6abb 100644 (file)
@@ -15,7 +15,7 @@
 # along with this program; if not, write to the Free Software Foundation
 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
-mkclass_target(hello.ti hello.thpp)
+mkclass_target(hello.ti hello.tcpp hello.thpp)
 
 mkembedconfig_target(hello-app.conf hello-app.cpp)
 
index 56da13a2420224a0cd3408d3bdc0e5842a68757c..b273d523cbac3d449b8aa5314d79f8e7772775c6 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "hello/hello.hpp"
+#include "hello/hello.tcpp"
 #include "base/logger.hpp"
 
 using namespace icinga;
index 10648c885730af9337b59c5716c6ef6e80cbb325..65801a1a23c049fb2f91ef5146cd9902a2389d38 100644 (file)
 # along with this program; if not, write to the Free Software Foundation
 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
-mkclass_target(checkable.ti checkable.thpp)
-mkclass_target(checkcommand.ti checkcommand.thpp)
-mkclass_target(checkresult.ti checkresult.thpp)
-mkclass_target(command.ti command.thpp)
-mkclass_target(comment.ti comment.thpp)
-mkclass_target(dependency.ti dependency.thpp)
-mkclass_target(downtime.ti downtime.thpp)
-mkclass_target(eventcommand.ti eventcommand.thpp)
-mkclass_target(hostgroup.ti hostgroup.thpp)
-mkclass_target(host.ti host.thpp)
-mkclass_target(icingaapplication.ti icingaapplication.thpp)
-mkclass_target(customvarobject.ti customvarobject.thpp)
-mkclass_target(icingastatuswriter.ti icingastatuswriter.thpp)
-mkclass_target(notificationcommand.ti notificationcommand.thpp)
-mkclass_target(notification.ti notification.thpp)
-mkclass_target(perfdatavalue.ti perfdatavalue.thpp)
-mkclass_target(scheduleddowntime.ti scheduleddowntime.thpp)
-mkclass_target(servicegroup.ti servicegroup.thpp)
-mkclass_target(service.ti service.thpp)
-mkclass_target(timeperiod.ti timeperiod.thpp)
-mkclass_target(usergroup.ti usergroup.thpp)
-mkclass_target(user.ti user.thpp)
+mkclass_target(checkable.ti checkable.tcpp checkable.thpp)
+mkclass_target(checkcommand.ti checkcommand.tcpp checkcommand.thpp)
+mkclass_target(checkresult.ti checkresult.tcpp checkresult.thpp)
+mkclass_target(command.ti command.tcpp command.thpp)
+mkclass_target(comment.ti comment.tcpp comment.thpp)
+mkclass_target(dependency.ti dependency.tcpp dependency.thpp)
+mkclass_target(downtime.ti downtime.tcpp downtime.thpp)
+mkclass_target(eventcommand.ti eventcommand.tcpp eventcommand.thpp)
+mkclass_target(hostgroup.ti hostgroup.tcpp hostgroup.thpp)
+mkclass_target(host.ti host.tcpp host.thpp)
+mkclass_target(icingaapplication.ti icingaapplication.tcpp icingaapplication.thpp)
+mkclass_target(customvarobject.ti customvarobject.tcpp customvarobject.thpp)
+mkclass_target(icingastatuswriter.ti icingastatuswriter.tcpp icingastatuswriter.thpp)
+mkclass_target(notificationcommand.ti notificationcommand.tcpp notificationcommand.thpp)
+mkclass_target(notification.ti notification.tcpp notification.thpp)
+mkclass_target(perfdatavalue.ti perfdatavalue.tcpp perfdatavalue.thpp)
+mkclass_target(scheduleddowntime.ti scheduleddowntime.tcpp scheduleddowntime.thpp)
+mkclass_target(servicegroup.ti servicegroup.tcpp servicegroup.thpp)
+mkclass_target(service.ti service.tcpp service.thpp)
+mkclass_target(timeperiod.ti timeperiod.tcpp timeperiod.thpp)
+mkclass_target(usergroup.ti usergroup.tcpp usergroup.thpp)
+mkclass_target(user.ti user.tcpp user.thpp)
 
 mkembedconfig_target(icinga-app.conf icinga-app.cpp)
 
@@ -45,11 +45,11 @@ set(icinga_SOURCES
   checkable-flapping.cpp checkcommand.cpp checkcommand.thpp checkresult.cpp checkresult.thpp
   cib.cpp command.cpp command.thpp comment.cpp comment.thpp compatutility.cpp dependency.cpp dependency.thpp
   dependency-apply.cpp downtime.cpp downtime.thpp eventcommand.cpp eventcommand.thpp
-  externalcommandprocessor.cpp host.cpp host.thpp hostgroup.cpp hostgroup.thpp icingaapplication.cpp
-  icingaapplication.thpp customvarobject.cpp customvarobject.thpp icingastatuswriter.cpp icingastatuswriter.thpp
-  legacytimeperiod.cpp macroprocessor.cpp notificationcommand.cpp notificationcommand.thpp notification.cpp
-  notification.thpp notification-apply.cpp objectutils.cpp perfdatavalue.cpp perfdatavalue.thpp pluginutility.cpp scheduleddowntime.cpp
-  scheduleddowntime.thpp scheduleddowntime-apply.cpp service-apply.cpp checkable-check.cpp checkable-comment.cpp
+  externalcommandprocessor.cpp host.cpp host.thpp hostgroup.cpp hostgroup.thpp icingaapplication.cpp icingaapplication.thpp
+  customvarobject.cpp customvarobject.thpp icingastatuswriter.cpp icingastatuswriter.thpp
+  legacytimeperiod.cpp macroprocessor.cpp notificationcommand.cpp notificationcommand.thpp notification.cpp notification.thpp
+  notification-apply.cpp objectutils.cpp perfdatavalue.cpp perfdatavalue.thpp pluginutility.cpp scheduleddowntime.cpp scheduleddowntime.thpp
+  scheduleddowntime-apply.cpp service-apply.cpp checkable-check.cpp checkable-comment.cpp
   service.cpp service.thpp servicegroup.cpp servicegroup.thpp checkable-notification.cpp timeperiod.cpp timeperiod.thpp
   user.cpp user.thpp usergroup.cpp usergroup.thpp icinga-app.cpp
 )
index 27b5c3628537cac82d9a9233b33060c99b154078..75561bed1a205a826c9010f15edf2de84cea12b9 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "icinga/checkable.hpp"
+#include "icinga/checkable.tcpp"
 #include "base/objectlock.hpp"
 #include "base/utility.hpp"
 #include "base/exception.hpp"
index 849a371413c5a5528d80d4dab55fe9d981251390..26e39984ecb90ba61ff5e3a0116fd98bbe3f3588 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "icinga/checkcommand.hpp"
+#include "icinga/checkcommand.tcpp"
 #include "base/dynamictype.hpp"
 
 using namespace icinga;
index c6798b5b7aabe2fb162d7c5e7879c135e1b3c376..d1f2933d9e1ddec751099c78d9e15652655fc47e 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "icinga/checkresult.hpp"
+#include "icinga/checkresult.tcpp"
 
 using namespace icinga;
 
index 0641e1d57460649cbab3e86a1090785819ead6b6..4741467cb7bac558f7131ac3d233f24adb339013 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "icinga/command.hpp"
+#include "icinga/command.tcpp"
 #include "icinga/macroprocessor.hpp"
 #include "base/exception.hpp"
 #include "base/objectlock.hpp"
index d39e6dae2b0524a5ad2f7f100812b312e96a0a29..ce6f8576efb1807777d020d88e937bd2a077a96f 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "icinga/comment.hpp"
+#include "icinga/comment.tcpp"
 #include "base/utility.hpp"
 #include "base/dynamictype.hpp"
 
index 8388cea293a5119b357257c4ad3d0a3541f9dbb4..48facf14ba07172fb33e26bb0c782dff4ae780ba 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "icinga/customvarobject.hpp"
+#include "icinga/customvarobject.tcpp"
 #include "icinga/macroprocessor.hpp"
 #include "base/logger.hpp"
 #include "base/function.hpp"
index d935a8f03db1f0008b059389532cbd00da176016..28de23d02eb4d2b1c85b929b940aa58ce46ea1df 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "icinga/dependency.hpp"
+#include "icinga/dependency.tcpp"
 #include "icinga/service.hpp"
 #include "base/logger.hpp"
 #include "base/exception.hpp"
index ffabab7b5cade4247ec7733798b17cc6022a0c10..8c37a3d03d12873315a90e3967852a88e68974f7 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "icinga/downtime.hpp"
+#include "icinga/downtime.tcpp"
 #include "base/utility.hpp"
 
 using namespace icinga;
index e2714eb83507cdcb2aecc13af503072160657aa7..55c97b246f86e0d33d0c49d3f845bdef42377acc 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "icinga/eventcommand.hpp"
+#include "icinga/eventcommand.tcpp"
 
 using namespace icinga;
 
index 4e7083a20b638b16902ada114911572a7c293df8..db05304714a369d26f46b91e72b48ae646a4e6a0 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "icinga/host.hpp"
+#include "icinga/host.tcpp"
 #include "icinga/service.hpp"
 #include "icinga/hostgroup.hpp"
 #include "icinga/pluginutility.hpp"
index 586ab62278a076dadee8809e357b8d8125ec7cbc..c6e00962829f629f4f11f974b59ec0d561c7d5f6 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "icinga/hostgroup.hpp"
+#include "icinga/hostgroup.tcpp"
 #include "config/objectrule.hpp"
 #include "config/configitem.hpp"
 #include "base/dynamictype.hpp"
index 2a5edc8f7dcc66e0bf159cbfdd8471e738bc311b..d9a3333626ad633fba612dc343c5fc91ccb59d30 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "icinga/icingaapplication.hpp"
+#include "icinga/icingaapplication.tcpp"
 #include "icinga/cib.hpp"
 #include "base/dynamictype.hpp"
 #include "base/logger.hpp"
index 105d6a180717cf83f908b1b2a3c64eaa8f705565..f01ec47545d502b4a1639c3af96bc4e4e0a106e0 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "icinga/icingastatuswriter.hpp"
+#include "icinga/icingastatuswriter.tcpp"
 #include "icinga/cib.hpp"
 #include "base/dynamictype.hpp"
 #include "base/logger.hpp"
index af2732d000f313f460ff1dd104b898297b97a43d..7289df566c6c1332fbb364bbead6f692c4a3f0b7 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "icinga/notification.hpp"
+#include "icinga/notification.tcpp"
 #include "icinga/notificationcommand.hpp"
 #include "icinga/service.hpp"
 #include "base/objectlock.hpp"
index 67076fb3abf8c36a8781b3dfd40eca0b4e0a0da1..fd324b90db0f8f80a31301f920f6de3deb91b32b 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "icinga/notificationcommand.hpp"
+#include "icinga/notificationcommand.tcpp"
 
 using namespace icinga;
 
index b3e0ae1be6f5e7749047cb5bdbcdcaf0d2dabfac..37f7904ecb97960c545720fe56332215a3d8e462 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "icinga/perfdatavalue.hpp"
+#include "icinga/perfdatavalue.tcpp"
 #include "base/convert.hpp"
 #include "base/exception.hpp"
 #include "base/logger.hpp"
index 4deacdd9ad0fb8ddc2dfc4d2a877b4c59d7a050f..c5cb0124721306990e283945e67206b6b852210e 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "icinga/scheduleddowntime.hpp"
+#include "icinga/scheduleddowntime.tcpp"
 #include "icinga/legacytimeperiod.hpp"
 #include "icinga/downtime.hpp"
 #include "icinga/service.hpp"
index b1cc8e36b8ac9fc97426489894bc5acf21710300..f9e7e915e4b78e90e96dd63cf90d00ba3bdfe1a9 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "icinga/service.hpp"
+#include "icinga/service.tcpp"
 #include "icinga/servicegroup.hpp"
 #include "icinga/scheduleddowntime.hpp"
 #include "icinga/pluginutility.hpp"
index ee07360bd7344296f855f50225d53f673a6cb987..5513889dca39425906f2f8bbb39b4fc54c5bd614 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "icinga/servicegroup.hpp"
+#include "icinga/servicegroup.tcpp"
 #include "config/objectrule.hpp"
 #include "config/configitem.hpp"
 #include "base/dynamictype.hpp"
index 07dcbe39916f3d7afbebcd435343ae1a7afe5f7f..8cd0acd52cd9feaa9eeb0a3387e76b6e3f7e1b17 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "icinga/timeperiod.hpp"
+#include "icinga/timeperiod.tcpp"
 #include "icinga/legacytimeperiod.hpp"
 #include "base/dynamictype.hpp"
 #include "base/objectlock.hpp"
index cb68b6cf552bc1d7c296e0105a022b95c5212d35..299d6bf7407e34128d2d0f2ed716ac76f2dcad17 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "icinga/user.hpp"
+#include "icinga/user.tcpp"
 #include "icinga/usergroup.hpp"
 #include "icinga/notification.hpp"
 #include "icinga/usergroup.hpp"
index fbaa545f3946e955ee86767b06389ecb4da59316..82bc4b518668dae1a6487035d6ef5ec5a9092455 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "icinga/usergroup.hpp"
+#include "icinga/usergroup.tcpp"
 #include "config/objectrule.hpp"
 #include "config/configitem.hpp"
 #include "base/dynamictype.hpp"
index fb7033b7287dc14ac54c579f359caa6603b2d5f6..2913c4ffa9409c1d87cb295e16b6d4f150d63e5c 100644 (file)
@@ -15,7 +15,7 @@
 # along with this program; if not, write to the Free Software Foundation
 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
-mkclass_target(livestatuslistener.ti livestatuslistener.thpp)
+mkclass_target(livestatuslistener.ti livestatuslistener.tcpp livestatuslistener.thpp)
 
 set(livestatus_SOURCES
   aggregator.cpp andfilter.cpp attributefilter.cpp
index 800fa271381a45858d1e4ad418ea2bff38430d4f..10a46d4d9046ba1e6d97027389b56d874cd30017 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "livestatus/livestatuslistener.hpp"
+#include "livestatus/livestatuslistener.tcpp"
 #include "icinga/perfdatavalue.hpp"
 #include "base/utility.hpp"
 #include "base/objectlock.hpp"
index dca75ba540be2f40304e4548edd55eaf46e6737e..deaa075456695dfb1942f1114cdef2a211abdbd2 100644 (file)
@@ -15,7 +15,7 @@
 # along with this program; if not, write to the Free Software Foundation
 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
-mkclass_target(notificationcomponent.ti notificationcomponent.thpp)
+mkclass_target(notificationcomponent.ti notificationcomponent.tcpp notificationcomponent.thpp)
 
 set(notification_SOURCES
   notificationcomponent.cpp notificationcomponent.thpp
index 7b65a69cd95a3b88f05714312dae5db35e26e0fc..bc00116945642101a51f02cd3742fd9d101d2be4 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "notification/notificationcomponent.hpp"
+#include "notification/notificationcomponent.tcpp"
 #include "icinga/service.hpp"
 #include "icinga/icingaapplication.hpp"
 #include "base/dynamictype.hpp"
index b6c2cd9185b4dda615566cc18a3e23ddef476947..846aefd6c58595bde35ff99663d9840f894e1091 100644 (file)
 # along with this program; if not, write to the Free Software Foundation
 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
-mkclass_target(gelfwriter.ti gelfwriter.thpp)
-mkclass_target(graphitewriter.ti graphitewriter.thpp)
-mkclass_target(opentsdbwriter.ti opentsdbwriter.thpp)
-mkclass_target(perfdatawriter.ti perfdatawriter.thpp)
+mkclass_target(gelfwriter.ti gelfwriter.tcpp gelfwriter.thpp)
+mkclass_target(graphitewriter.ti graphitewriter.tcpp graphitewriter.thpp)
+mkclass_target(opentsdbwriter.ti opentsdbwriter.tcpp opentsdbwriter.thpp)
+mkclass_target(perfdatawriter.ti perfdatawriter.tcpp perfdatawriter.thpp)
 
 set(perfdata_SOURCES
   gelfwriter.cpp gelfwriter.thpp graphitewriter.cpp graphitewriter.thpp opentsdbwriter.cpp opentsdbwriter.thpp perfdatawriter.cpp perfdatawriter.thpp
index f05af555347c297f649d4401a6ce378e75492e22..1efec3ec6a5c7aca0021e55268e86a4b7a8d6236 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "perfdata/gelfwriter.hpp"
+#include "perfdata/gelfwriter.tcpp"
 #include "icinga/service.hpp"
 #include "icinga/notification.hpp"
 #include "icinga/macroprocessor.hpp"
index 7304e62259645a639ac9ef0270d8409bbf929f6d..ef717116ff462560807131fac4b3d7fd3a1e83f6 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "perfdata/graphitewriter.hpp"
+#include "perfdata/graphitewriter.tcpp"
 #include "icinga/service.hpp"
 #include "icinga/macroprocessor.hpp"
 #include "icinga/icingaapplication.hpp"
index 20248af955b6dacec384ef58be9a5f5cea7318d5..acbd718079aacf6b7414349f51a497cd9b5501b8 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "perfdata/opentsdbwriter.hpp"
+#include "perfdata/opentsdbwriter.tcpp"
 #include "icinga/service.hpp"
 #include "icinga/macroprocessor.hpp"
 #include "icinga/icingaapplication.hpp"
index 368889fcbb3804a9a307456f446a0830df8f7f50..94a5c5090328cf0c4022faaf5abd0d7ef5202eb8 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "perfdata/perfdatawriter.hpp"
+#include "perfdata/perfdatawriter.tcpp"
 #include "icinga/service.hpp"
 #include "icinga/macroprocessor.hpp"
 #include "icinga/icingaapplication.hpp"
index 9965474aaa1883404ebcb5e0fb0283248fcea3c7..e7e96e19074d806eea5990f169430a68d4bfd287 100644 (file)
 # along with this program; if not, write to the Free Software Foundation
 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
-mkclass_target(apilistener.ti apilistener.thpp)
-mkclass_target(endpoint.ti endpoint.thpp)
-mkclass_target(zone.ti zone.thpp)
+mkclass_target(apilistener.ti apilistener.tcpp apilistener.thpp)
+mkclass_target(endpoint.ti endpoint.tcpp endpoint.thpp)
+mkclass_target(zone.ti zone.tcpp zone.thpp)
 
 set(remote_SOURCES
-  apiclient.cpp apiclient-heartbeat.cpp apifunction.cpp apilistener.cpp apilistener-sync.cpp
-  apilistener.thpp authority.cpp endpoint.cpp endpoint.thpp jsonrpc.cpp
+  apiclient.cpp apiclient-heartbeat.cpp apifunction.cpp apilistener.cpp apilistener.thpp apilistener-sync.cpp
+  authority.cpp endpoint.cpp endpoint.thpp jsonrpc.cpp
   messageorigin.cpp zone.cpp zone.thpp
 )
 
index bd7aad9f8ab0974d3a9304b91e46f3ec0273392d..4bd224e1c843298f7a3a9633949dc9aaa427f3b0 100644 (file)
@@ -23,6 +23,7 @@
 #include "base/initialize.hpp"
 #include "base/dynamictype.hpp"
 #include "base/logger.hpp"
+#include "base/utility.hpp"
 #include <boost/foreach.hpp>
 
 using namespace icinga;
index 42042270a211b2da8f22d434c04da4dfadd979c0..de96f97bf885069fd018fae234330fd7d2a2b130 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "remote/apilistener.hpp"
+#include "remote/apilistener.tcpp"
 #include "remote/apiclient.hpp"
 #include "remote/endpoint.hpp"
 #include "remote/jsonrpc.hpp"
index a7a9e7afe6d246a2f749a524cef84064980f6e67..4dca3970b5a02000d2b15eebfb0fb6d01facd6a0 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "remote/endpoint.hpp"
+#include "remote/endpoint.tcpp"
 #include "remote/apilistener.hpp"
 #include "remote/apiclient.hpp"
 #include "remote/zone.hpp"
index 194292cdb1db3805755acc21d389ebc11ba22b88..a5a21a63a4b2b4abee2258aa7b6cd764a718ef14 100644 (file)
@@ -18,6 +18,7 @@
  ******************************************************************************/
 
 #include "remote/zone.hpp"
+#include "remote/zone.tcpp"
 #include "remote/apiclient.hpp"
 #include "base/objectlock.hpp"
 #include <boost/foreach.hpp>
index f49ed9eb358c29d7118692f57517cb56ed2b2624..7f16402dce6778dc037b44f3154508251594ec0d 100644 (file)
@@ -40,15 +40,12 @@ set_target_properties (
   FOLDER Bin
 )
 
-macro(MKCLASS_TARGET ClassInput ClassOutput)
+macro(MKCLASS_TARGET ClassInput ClassImplOutput ClassHeaderOutput)
     add_custom_command(
-        OUTPUT ${ClassOutput}
+        OUTPUT ${ClassImplOutput} ${ClassHeaderOutput}
         COMMAND mkclass
-        ARGS ${ClassInput} > ${CMAKE_CURRENT_BINARY_DIR}/${ClassOutput}.tmp
-        COMMAND ${CMAKE_COMMAND}
-        ARGS -E copy ${CMAKE_CURRENT_BINARY_DIR}/${ClassOutput}.tmp ${CMAKE_CURRENT_BINARY_DIR}/${ClassOutput}
+        ARGS ${ClassInput} ${CMAKE_CURRENT_BINARY_DIR}/${ClassImplOutput} ${CMAKE_CURRENT_BINARY_DIR}/${ClassHeaderOutput}
         WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
         DEPENDS mkclass ${ClassInput}
     )
-    set_property(SOURCE ${ClassOutput} PROPERTY EXCLUDE_UNITY_BUILD)
 endmacro()
index d700cfd523c88e00de84f592c17b73708ff94a0b..1dd24623a85bc9b8feeef39a401b434359653adf 100644 (file)
@@ -34,8 +34,9 @@
 
 using namespace icinga;
 
-ClassCompiler::ClassCompiler(const std::string& path, std::istream *input)
-       : m_Path(path), m_Input(input)
+ClassCompiler::ClassCompiler(const std::string& path, std::istream& input,
+    std::ostream& oimpl, std::ostream& oheader)
+       : m_Path(path), m_Input(input), m_Impl(oimpl), m_Header(oheader)
 {
        InitializeScanner();
 }
@@ -57,36 +58,41 @@ void *ClassCompiler::GetScanner(void)
 
 size_t ClassCompiler::ReadInput(char *buffer, size_t max_size)
 {
-       m_Input->read(buffer, max_size);
-       return static_cast<size_t>(m_Input->gcount());
+       m_Input.read(buffer, max_size);
+       return static_cast<size_t>(m_Input.gcount());
 }
 
 void ClassCompiler::HandleInclude(const std::string& path, const ClassDebugInfo&)
 {
-       std::cout << "#include \"" << path << "\"" << std::endl << std::endl;
+       m_Header << "#include \"" << path << "\"" << std::endl << std::endl;
 }
 
 void ClassCompiler::HandleAngleInclude(const std::string& path, const ClassDebugInfo&)
 {
-       std::cout << "#include <" << path << ">" << std::endl << std::endl;
+       m_Header << "#include <" << path << ">" << std::endl << std::endl;
 }
 
 void ClassCompiler::HandleNamespaceBegin(const std::string& name, const ClassDebugInfo&)
 {
-       std::cout << "namespace " << name << std::endl
-                         << "{" << std::endl << std::endl;
+       m_Header << "namespace " << name << std::endl
+                << "{" << std::endl << std::endl;
+
+       m_Impl << "namespace " << name << std::endl
+              << "{" << std::endl << std::endl;
 }
 
 void ClassCompiler::HandleNamespaceEnd(const ClassDebugInfo&)
 {
        HandleMissingValidators();
 
-       std::cout << "}" << std::endl;
+       m_Header << "}" << std::endl;
+
+       m_Impl << "}" << std::endl;
 }
 
 void ClassCompiler::HandleCode(const std::string& code, const ClassDebugInfo&)
 {
-       std::cout << code << std::endl;
+       m_Header << code << std::endl;
 }
 
 unsigned long ClassCompiler::SDBM(const std::string& str, size_t len = std::string::npos)
@@ -148,77 +154,78 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
 
        /* forward declaration */
        if (klass.Name.find_first_of(':') == std::string::npos)
-               std::cout << "class " << klass.Name << ";" << std::endl << std::endl;
+               m_Header << "class " << klass.Name << ";" << std::endl << std::endl;
 
        /* TypeHelper */
        if (klass.Attributes & TAAbstract) {
-               std::cout << "template<>" << std::endl
-                         << "struct TypeHelper<" << klass.Name << ">" << std::endl
-                         << "{" << std::endl
-                         << "\t" << "static ObjectFactory GetFactory(void)" << std::endl
-                         << "\t" << "{" << std::endl
-                         << "\t\t" << "return NULL;" << std::endl
-                         << "\t" << "}" << std::endl
-                         << "};" << std::endl << std::endl;
+               m_Header << "template<>" << std::endl
+                        << "struct TypeHelper<" << klass.Name << ">" << std::endl
+                        << "{" << std::endl
+                        << "\t" << "static ObjectFactory GetFactory(void)" << std::endl
+                        << "\t" << "{" << std::endl
+                        << "\t\t" << "return NULL;" << std::endl
+                        << "\t" << "}" << std::endl
+                        << "};" << std::endl << std::endl;
        }
 
        /* TypeImpl */
-       std::cout << "template<>" << std::endl
-               << "class TypeImpl<" << klass.Name << ">"
-               << " : public Type";
+       m_Header << "template<>" << std::endl
+                << "class TypeImpl<" << klass.Name << ">"
+                << " : public Type";
        
        if (!klass.TypeBase.empty())
-               std::cout << ", public " + klass.TypeBase;
+               m_Header << ", public " + klass.TypeBase;
 
-       std::cout << std::endl
-               << " {" << std::endl
-               << "public:" << std::endl;
+       m_Header << std::endl
+                << "{" << std::endl
+                << "public:" << std::endl;
 
        /* GetName */
-       std::cout << "\t" << "virtual String GetName(void) const" << std::endl
-                 << "\t" << "{" << std::endl
-                 << "\t\t" << "return \"" << klass.Name << "\";" << std::endl
-                 << "\t" << "}" << std::endl << std::endl;
+       m_Header << "\t" << "virtual String GetName(void) const;" << std::endl;
+
+       m_Impl << "String TypeImpl<" << klass.Name << ">::GetName(void) const" << std::endl
+              << "{" << std::endl
+              << "\t" << "return \"" << klass.Name << "\";" << std::endl
+              << "}" << std::endl << std::endl;
 
        /* GetAttributes */
-       std::cout << "\t" << "virtual int GetAttributes(void) const" << std::endl
-                 << "\t" << "{" << std::endl
-                 << "\t\t" << "return " << klass.Attributes << ";" << std::endl
-                 << "\t" << "}" << std::endl << std::endl;
+       m_Header << "\t" << "virtual int GetAttributes(void) const;" << std::endl;
+
+       m_Impl << "int TypeImpl<" << klass.Name << ">::GetAttributes(void) const" << std::endl
+              << "{" << std::endl
+              << "\t" << "return " << klass.Attributes << ";" << std::endl
+              << "}" << std::endl << std::endl;
 
        /* GetBaseType */
-       std::cout << "\t" << "virtual Type::Ptr GetBaseType(void) const" << std::endl
-               << "\t" << "{" << std::endl;
+       m_Header << "\t" << "virtual Type::Ptr GetBaseType(void) const;" << std::endl;
 
-       std::cout << "\t\t" << "return ";
+       m_Impl << "Type::Ptr TypeImpl<" << klass.Name << ">::GetBaseType(void) const" << std::endl
+              << "{" << std::endl
+              << "\t" << "return ";
 
        if (!klass.Parent.empty())
-               std::cout << "Type::GetByName(\"" << klass.Parent << "\")";
+               m_Impl << "Type::GetByName(\"" << klass.Parent << "\")";
        else
-               std::cout << "Type::Ptr()";
+               m_Impl << "Type::Ptr()";
 
-       std::cout << ";" << std::endl
-                         << "\t" << "}" << std::endl << std::endl;
+       m_Impl << ";" << std::endl
+              << "}" << std::endl << std::endl;
 
        /* GetFieldId */
-       std::cout << "\t" << "virtual int GetFieldId(const String& name) const" << std::endl
-               << "\t" << "{" << std::endl
-               << "\t\t" << "return StaticGetFieldId(name);" << std::endl
-               << "\t" << "}" << std::endl << std::endl;
+       m_Header << "\t" << "virtual int GetFieldId(const String& name) const;" << std::endl;
 
-       /* StaticGetFieldId */
-       std::cout << "\t" << "static int StaticGetFieldId(const String& name)" << std::endl
-               << "\t" << "{" << std::endl;
+       m_Impl << "int TypeImpl<" << klass.Name << ">::GetFieldId(const String& name) const" << std::endl
+              << "{" << std::endl;
 
        if (!klass.Fields.empty()) {
-               std::cout << "\t\t" << "int offset = ";
+               m_Impl << "\t" << "int offset = ";
 
                if (!klass.Parent.empty())
-                       std::cout << "TypeImpl<" << klass.Parent << ">::StaticGetFieldCount()";
+                       m_Impl << klass.Parent << "::TypeInstance->GetFieldCount()";
                else
-                       std::cout << "0";
+                       m_Impl << "0";
 
-               std::cout << ";" << std::endl << std::endl;
+               m_Impl << ";" << std::endl << std::endl;
        }
 
        std::map<int, std::vector<std::pair<int, std::string> > > jumptable;
@@ -243,61 +250,57 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
        } while (collisions >= 5 && hlen < 8);
 
        if (!klass.Fields.empty()) {
-               std::cout << "\t\tswitch (static_cast<int>(Utility::SDBM(name, " << hlen << "))) {" << std::endl;
+               m_Impl << "\tswitch (static_cast<int>(Utility::SDBM(name, " << hlen << "))) {" << std::endl;
 
                std::map<int, std::vector<std::pair<int, std::string> > >::const_iterator itj;
 
                for (itj = jumptable.begin(); itj != jumptable.end(); itj++) {
-                       std::cout << "\t\t\tcase " << itj->first << ":" << std::endl;
+                       m_Impl << "\t\tcase " << itj->first << ":" << std::endl;
 
                        std::vector<std::pair<int, std::string> >::const_iterator itf;
 
                        for (itf = itj->second.begin(); itf != itj->second.end(); itf++) {
-                               std::cout << "\t\t\t\t" << "if (name == \"" << itf->second << "\")" << std::endl
-                                       << "\t\t\t\t\t" << "return offset + " << itf->first << ";" << std::endl;
+                               m_Impl << "\t\t\t" << "if (name == \"" << itf->second << "\")" << std::endl
+                                      << "\t\t\t\t" << "return offset + " << itf->first << ";" << std::endl;
                        }
 
-                       std::cout << std::endl
-                                 << "\t\t\t\tbreak;" << std::endl;
+                       m_Impl << std::endl
+                                << "\t\t\t\tbreak;" << std::endl;
                }
 
-               std::cout << "\t\t}" << std::endl;
+               m_Impl << "\t}" << std::endl;
        }
 
-       std::cout << std::endl
-               << "\t\t" << "return ";
+       m_Impl << std::endl
+              << "\t" << "return ";
 
        if (!klass.Parent.empty())
-               std::cout << "TypeImpl<" << klass.Parent << ">::StaticGetFieldId(name)";
+               m_Impl << klass.Parent << "::TypeInstance->GetFieldId(name)";
        else
-               std::cout << "-1";
+               m_Impl << "-1";
 
-       std::cout << ";" << std::endl
-               << "\t" << "}" << std::endl << std::endl;
+       m_Impl << ";" << std::endl
+              << "}" << std::endl << std::endl;
 
        /* GetFieldInfo */
-       std::cout << "\t" << "virtual Field GetFieldInfo(int id) const" << std::endl
-               << "\t" << "{" << std::endl
-               << "\t\t" << "return StaticGetFieldInfo(id);" << std::endl
-               << "\t" << "}" << std::endl << std::endl;
+       m_Header << "\t" << "virtual Field GetFieldInfo(int id) const;" << std::endl;
 
-       /* StaticGetFieldInfo */
-       std::cout << "\t" << "static Field StaticGetFieldInfo(int id)" << std::endl
-               << "\t" << "{" << std::endl;
+       m_Impl << "Field TypeImpl<" << klass.Name << ">::GetFieldInfo(int id) const" << std::endl
+              << "{" << std::endl;
 
        if (!klass.Parent.empty())
-               std::cout << "\t\t" << "int real_id = id - " << "TypeImpl<" << klass.Parent << ">::StaticGetFieldCount();" << std::endl
-               << "\t\t" << "if (real_id < 0) { return " << "TypeImpl<" << klass.Parent << ">::StaticGetFieldInfo(id); }" << std::endl;
+               m_Impl << "\t" << "int real_id = id - " << klass.Parent << "::TypeInstance->GetFieldCount();" << std::endl
+                      << "\t" << "if (real_id < 0) { return " << klass.Parent << "::TypeInstance->GetFieldInfo(id); }" << std::endl;
 
        if (klass.Fields.size() > 0) {
-               std::cout << "\t\t" << "switch (";
+               m_Impl << "\t" << "switch (";
 
                if (!klass.Parent.empty())
-                       std::cout << "real_id";
+                       m_Impl << "real_id";
                else
-                       std::cout << "id";
+                       m_Impl << "id";
 
-               std::cout << ") {" << std::endl;
+               m_Impl << ") {" << std::endl;
 
                size_t num = 0;
                for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
@@ -324,193 +327,210 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
                        else
                                nameref = "NULL";
 
-                       std::cout << "\t\t\t" << "case " << num << ":" << std::endl
-                               << "\t\t\t\t" << "return Field(" << num << ", \"" << ftype << "\", \"" << it->Name << "\", " << nameref << ", " << it->Attributes << ");" << std::endl;
+                       m_Impl << "\t\t" << "case " << num << ":" << std::endl
+                                << "\t\t\t\t" << "return Field(" << num << ", \"" << ftype << "\", \"" << it->Name << "\", " << nameref << ", " << it->Attributes << ");" << std::endl;
                        num++;
                }
 
-               std::cout << "\t\t\t" << "default:" << std::endl
-                                 << "\t\t";
+               m_Impl << "\t\t" << "default:" << std::endl
+                        << "\t\t";
        }
 
-       std::cout << "\t\t" << "throw std::runtime_error(\"Invalid field ID.\");" << std::endl;
+       m_Impl << "\t" << "throw std::runtime_error(\"Invalid field ID.\");" << std::endl;
 
        if (klass.Fields.size() > 0)
-               std::cout << "\t\t" << "}" << std::endl;
+               m_Impl << "\t" << "}" << std::endl;
 
-       std::cout << "\t" << "}" << std::endl << std::endl;
+       m_Impl << "}" << std::endl << std::endl;
 
        /* GetFieldCount */
-       std::cout << "\t" << "virtual int GetFieldCount(void) const" << std::endl
-               << "\t" << "{" << std::endl
-               << "\t\t" << "return StaticGetFieldCount();" << std::endl
-               << "\t" << "}" << std::endl << std::endl;
+       m_Header << "\t" << "virtual int GetFieldCount(void) const;" << std::endl;
 
-       /* StaticGetFieldCount */
-       std::cout << "\t" << "static int StaticGetFieldCount(void)" << std::endl
-               << "\t" << "{" << std::endl
-               << "\t\t" << "return " << klass.Fields.size();
+       m_Impl << "int TypeImpl<" << klass.Name << ">::GetFieldCount(void) const" << std::endl
+              << "{" << std::endl
+              << "\t" << "return " << klass.Fields.size();
 
        if (!klass.Parent.empty())
-               std::cout << " + " << "TypeImpl<" << klass.Parent << ">::StaticGetFieldCount()";
+               m_Impl << " + " << klass.Parent << "::TypeInstance->GetFieldCount()";
 
-       std::cout << ";" << std::endl
-               << "\t" << "}" << std::endl << std::endl;
+       m_Impl << ";" << std::endl
+              << "}" << std::endl << std::endl;
 
        /* GetFactory */
-       std::cout << "\t" << "virtual ObjectFactory GetFactory(void) const" << std::endl
-                 << "\t" << "{" << std::endl
-                 << "\t\t" << "return TypeHelper<" << klass.Name << ">::GetFactory();" << std::endl
-                 << "\t" << "}" << std::endl << std::endl;
+       m_Header << "\t" << "virtual ObjectFactory GetFactory(void) const;" << std::endl;
+
+       m_Impl << "ObjectFactory TypeImpl<" << klass.Name << ">::GetFactory(void) const" << std::endl
+              << "{" << std::endl
+              << "\t" << "return TypeHelper<" << klass.Name << ">::GetFactory();" << std::endl
+              << "}" << std::endl << std::endl;
 
        /* GetLoadDependencies */
-       std::cout << "\t" << "virtual std::vector<String> GetLoadDependencies(void) const" << std::endl
-                 << "\t" << "{" << std::endl
-                 << "\t\t" << "std::vector<String> deps;" << std::endl;
+       m_Header << "\t" << "virtual std::vector<String> GetLoadDependencies(void) const;" << std::endl;
+
+       m_Impl << "std::vector<String> TypeImpl<" << klass.Name << ">::GetLoadDependencies(void) const" << std::endl
+              << "{" << std::endl
+              << "\t" << "std::vector<String> deps;" << std::endl;
 
        for (std::vector<std::string>::const_iterator itd = klass.LoadDependencies.begin(); itd != klass.LoadDependencies.end(); itd++)
-               std::cout << "\t\t" << "deps.push_back(\"" << *itd << "\");" << std::endl;
+               m_Impl << "\t" << "deps.push_back(\"" << *itd << "\");" << std::endl;
 
-       std::cout << "\t\t" << "return deps;" << std::endl
-                 << "\t" << "}" << std::endl;
+       m_Impl << "\t" << "return deps;" << std::endl
+              << "}" << std::endl;
 
-       std::cout << "};" << std::endl << std::endl;
+       m_Header << "};" << std::endl << std::endl;
 
-       std::cout << std::endl;
+       m_Header << std::endl;
 
        /* ObjectImpl */
-       std::cout << "template<>" << std::endl
-                 << "class ObjectImpl<" << klass.Name << ">"
-                 << " : public " << (klass.Parent.empty() ? "Object" : klass.Parent) << std::endl
-                 << "{" << std::endl
-                 << "public:" << std::endl
-                 << "\t" << "DECLARE_PTR_TYPEDEFS(ObjectImpl<" << klass.Name << ">);" << std::endl << std::endl;
+       m_Header << "template<>" << std::endl
+                << "class ObjectImpl<" << klass.Name << ">"
+                << " : public " << (klass.Parent.empty() ? "Object" : klass.Parent) << std::endl
+                << "{" << std::endl
+                << "public:" << std::endl
+                << "\t" << "DECLARE_PTR_TYPEDEFS(ObjectImpl<" << klass.Name << ">);" << std::endl << std::endl;
 
        /* Validate */
-       std::cout << "\t" << "virtual void Validate(int types, const ValidationUtils& utils)" << std::endl
-               << "\t" << "{" << std::endl;
+       m_Header << "\t" << "virtual void Validate(int types, const ValidationUtils& utils);" << std::endl;
+
+       m_Impl << "void ObjectImpl<" << klass.Name << ">::Validate(int types, const ValidationUtils& utils)" << std::endl
+              << "{" << std::endl;
 
        if (!klass.Parent.empty())
-               std::cout << "\t\t" << klass.Parent << "::Validate(types, utils);" << std::endl << std::endl;
+               m_Impl << "\t" << klass.Parent << "::Validate(types, utils);" << std::endl << std::endl;
 
        for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
-               std::cout << "\t\t" << "if (" << (it->Attributes & (FAEphemeral|FAConfig|FAState)) << " & types)" << std::endl
-                         << "\t\t\t" << "Validate" << it->GetFriendlyName() << "(Get" << it->GetFriendlyName() << "(), utils);" << std::endl;
+               m_Impl << "\t" << "if (" << (it->Attributes & (FAEphemeral|FAConfig|FAState)) << " & types)" << std::endl
+                        << "\t\t" << "Validate" << it->GetFriendlyName() << "(Get" << it->GetFriendlyName() << "(), utils);" << std::endl;
        }
 
-       std::cout << "\t" << "}" << std::endl << std::endl;
+       m_Impl << "}" << std::endl << std::endl;
 
        for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
-               std::cout << "\t" << "inline void SimpleValidate" << it->GetFriendlyName() << "(" << it->Type.GetArgumentType() << " value, const ValidationUtils& utils)" << std::endl
-                         << "\t" << "{" << std::endl;
+               m_Header << "\t" << "void SimpleValidate" << it->GetFriendlyName() << "(" << it->Type.GetArgumentType() << " value, const ValidationUtils& utils);" << std::endl;
+
+               m_Impl << "void ObjectImpl<" << klass.Name << ">::SimpleValidate" << it->GetFriendlyName() << "(" << it->Type.GetArgumentType() << " value, const ValidationUtils& utils)" << std::endl
+                      << "{" << std::endl;
 
                const Field& field = *it;
 
                if ((field.Attributes & (FARequired)) || field.Type.IsName) {
                        if (field.Attributes & FARequired) {
                                if (field.Type.GetRealType().find("::Ptr") != std::string::npos)
-                                       std::cout << "\t\t" << "if (!value)" << std::endl;
+                                       m_Impl << "\t" << "if (!value)" << std::endl;
                                else
-                                       std::cout << "\t\t" << "if (value.IsEmpty())" << std::endl;
+                                       m_Impl << "\t" << "if (value.IsEmpty())" << std::endl;
 
-                               std::cout << "\t\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of(\"" << field.Name << "\"), \"Attribute must not be empty.\"));" << std::endl << std::endl;
+                               m_Impl << "\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_cast<DynamicObject *>(this), boost::assign::list_of(\"" << field.Name << "\"), \"Attribute must not be empty.\"));" << std::endl << std::endl;
                        }
 
                        if (field.Type.IsName) {
-                               std::cout << "\t\t" << "String ref = value;" << std::endl
-                                         << "\t\t" << "if (!ref.IsEmpty() && !utils.ValidateName(\"" << field.Type.TypeName << "\", ref))" << std::endl
-                                         << "\t\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(this, boost::assign::list_of(\"" << field.Name << "\"), \"Object '\" + ref + \"' of type '" << field.Type.TypeName
-                                         << "' does not exist.\"));" << std::endl;
+                               m_Impl << "\t" << "String ref = value;" << std::endl
+                                      << "\t" << "if (!ref.IsEmpty() && !utils.ValidateName(\"" << field.Type.TypeName << "\", ref))" << std::endl
+                                      << "\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_cast<DynamicObject *>(this), boost::assign::list_of(\"" << field.Name << "\"), \"Object '\" + ref + \"' of type '" << field.Type.TypeName
+                                      << "' does not exist.\"));" << std::endl;
                        }
                }
 
-               std::cout << "\t" << "}" << std::endl << std::endl;
+               m_Impl << "}" << std::endl << std::endl;
        }
 
        if (!klass.Fields.empty()) {
                /* constructor */
-               std::cout << "public:" << std::endl
-                         << "\t" << "ObjectImpl<" << klass.Name << ">(void)" << std::endl
-                         << "\t" << "{" << std::endl;
+               m_Header << "public:" << std::endl
+                        << "\t" << "ObjectImpl<" << klass.Name << ">(void);" << std::endl;
+
+               m_Impl << "ObjectImpl<" << klass.Name << ">::ObjectImpl(void)" << std::endl
+                      << "{" << std::endl;
 
                for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
-                       std::cout << "\t\t" << "Set" << it->GetFriendlyName() << "(" << "GetDefault" << it->GetFriendlyName() << "());" << std::endl;
+                       m_Impl << "\t\t" << "Set" << it->GetFriendlyName() << "(" << "GetDefault" << it->GetFriendlyName() << "());" << std::endl;
                }
 
-               std::cout << "\t" << "}" << std::endl << std::endl;
+               m_Impl << "}" << std::endl << std::endl;
+
+               /* destructor */
+               m_Header << "public:" << std::endl
+                        << "\t" << "~ObjectImpl<" << klass.Name << ">(void);" << std::endl;
+
+               m_Impl << "ObjectImpl<" << klass.Name << ">::~ObjectImpl(void)" << std::endl
+                      << "{ }" << std::endl << std::endl;
 
                /* SetField */
-               std::cout << "protected:" << std::endl
-                                 << "\t" << "virtual void SetField(int id, const Value& value)" << std::endl
-                                 << "\t" << "{" << std::endl;
+               m_Header << "protected:" << std::endl
+                        << "\t" << "virtual void SetField(int id, const Value& value);" << std::endl;
+
+               m_Impl << "void ObjectImpl<" << klass.Name << ">::SetField(int id, const Value& value)" << std::endl
+                      << "{" << std::endl;
 
                if (!klass.Parent.empty())
-                       std::cout << "\t\t" << "int real_id = id - TypeImpl<" << klass.Parent << ">::StaticGetFieldCount(); " << std::endl
-                                 << "\t\t" << "if (real_id < 0) { " << klass.Parent << "::SetField(id, value); return; }" << std::endl;
+                       m_Impl << "\t" << "int real_id = id - " << klass.Parent << "::TypeInstance->GetFieldCount(); " << std::endl
+                              << "\t" << "if (real_id < 0) { " << klass.Parent << "::SetField(id, value); return; }" << std::endl;
 
-               std::cout << "\t\t" << "switch (";
+               m_Impl << "\t" << "switch (";
 
                if (!klass.Parent.empty())
-                       std::cout << "real_id";
+                       m_Impl << "real_id";
                else
-                       std::cout << "id";
+                       m_Impl << "id";
 
-               std::cout << ") {" << std::endl;
+               m_Impl << ") {" << std::endl;
 
                size_t num = 0;
                for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
-                       std::cout << "\t\t\t" << "case " << num << ":" << std::endl
-                                         << "\t\t\t\t" << "Set" << it->GetFriendlyName() << "(";
+                       m_Impl << "\t\t" << "case " << num << ":" << std::endl
+                              << "\t\t\t" << "Set" << it->GetFriendlyName() << "(";
                        
                        if (it->Attributes & FAEnum)
-                               std::cout << "static_cast<" << it->Type.GetRealType() << ">(static_cast<int>(";
+                               m_Impl << "static_cast<" << it->Type.GetRealType() << ">(static_cast<int>(";
 
-                       std::cout << "value";
+                       m_Impl << "value";
                        
                        if (it->Attributes & FAEnum)
-                               std::cout << "))";
+                               m_Impl << "))";
                        
-                       std::cout << ");" << std::endl
-                                         << "\t\t\t\t" << "break;" << std::endl;
+                       m_Impl << ");" << std::endl
+                              << "\t\t\t" << "break;" << std::endl;
                        num++;
                }
 
-               std::cout << "\t\t\t" << "default:" << std::endl
-                                 << "\t\t\t\t" << "throw std::runtime_error(\"Invalid field ID.\");" << std::endl
-                                 << "\t\t" << "}" << std::endl;
+               m_Impl << "\t\t" << "default:" << std::endl
+                      << "\t\t\t" << "throw std::runtime_error(\"Invalid field ID.\");" << std::endl
+                      << "\t" << "}" << std::endl;
 
-               std::cout << "\t" << "}" << std::endl << std::endl;
+               m_Impl << "}" << std::endl << std::endl;
 
                /* GetField */
-               std::cout << "protected:" << std::endl
-                                 << "\t" << "virtual Value GetField(int id) const" << std::endl
-                                 << "\t" << "{" << std::endl;
+               m_Header << "protected:" << std::endl
+                        << "\t" << "virtual Value GetField(int id) const;" << std::endl;
+
+               m_Impl << "Value ObjectImpl<" << klass.Name << ">::GetField(int id) const" << std::endl
+                      << "{" << std::endl;
 
                if (!klass.Parent.empty())
-                       std::cout << "\t\t" << "int real_id = id - TypeImpl<" << klass.Parent << ">::StaticGetFieldCount(); " << std::endl
-                                         << "\t\t" << "if (real_id < 0) { return " << klass.Parent << "::GetField(id); }" << std::endl;
+                       m_Impl << "\t" << "int real_id = id - " << klass.Parent << "::TypeInstance->GetFieldCount(); " << std::endl
+                              << "\t" << "if (real_id < 0) { return " << klass.Parent << "::GetField(id); }" << std::endl;
 
-               std::cout << "\t\t" << "switch (";
+               m_Impl << "\t" << "switch (";
 
                if (!klass.Parent.empty())
-                       std::cout << "real_id";
+                       m_Impl << "real_id";
                else
-                       std::cout << "id";
+                       m_Impl << "id";
 
-               std::cout << ") {" << std::endl;
+               m_Impl << ") {" << std::endl;
 
                num = 0;
                for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
-                       std::cout << "\t\t\t" << "case " << num << ":" << std::endl
-                                         << "\t\t\t\t" << "return Get" << it->GetFriendlyName() << "();" << std::endl;
+                       m_Impl << "\t\t" << "case " << num << ":" << std::endl
+                              << "\t\t\t" << "return Get" << it->GetFriendlyName() << "();" << std::endl;
                        num++;
                }
 
-               std::cout << "\t\t\t" << "default:" << std::endl
-                                 << "\t\t\t\t" << "throw std::runtime_error(\"Invalid field ID.\");" << std::endl
-                                 << "\t\t" << "}" << std::endl;
+               m_Impl << "\t\t" << "default:" << std::endl
+                      << "\t\t\t" << "throw std::runtime_error(\"Invalid field ID.\");" << std::endl
+                      << "\t" << "}" << std::endl;
 
-               std::cout << "\t" << "}" << std::endl << std::endl;
+               m_Impl << "}" << std::endl << std::endl;
 
                /* getters */
                for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
@@ -521,21 +541,23 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
                        else
                                prot = "public";
 
-                       std::cout << prot << ":" << std::endl
-                           << "\t" << "virtual " << it->Type.GetRealType() << " Get" << it->GetFriendlyName() << "(void) const";
+                       m_Header << prot << ":" << std::endl
+                                << "\t" << "virtual " << it->Type.GetRealType() << " Get" << it->GetFriendlyName() << "(void) const";
 
                        if (it->PureGetAccessor) {
-                               std::cout << " = 0;" << std::endl;
+                               m_Header << " = 0;" << std::endl;
                        } else {
-                               std::cout << std::endl
-                                         << "\t" << "{" << std::endl;
+                               m_Header << ";" << std::endl;
+
+                               m_Impl << it->Type.GetRealType() << " ObjectImpl<" << klass.Name << ">::Get" << it->GetFriendlyName() << "(void) const" << std::endl
+                                      << "{" << std::endl;
 
                                if (it->GetAccessor.empty() && !(it->Attributes & FANoStorage))
-                                       std::cout << "\t\t" << "return m_" << it->GetFriendlyName() << ";" << std::endl;
+                                       m_Impl << "\t" << "return m_" << it->GetFriendlyName() << ";" << std::endl;
                                else
-                                       std::cout << it->GetAccessor << std::endl;
+                                       m_Impl << it->GetAccessor << std::endl;
 
-                               std::cout << "\t" << "}" << std::endl << std::endl;
+                               m_Impl << "}" << std::endl << std::endl;
                        }
                }
 
@@ -550,20 +572,23 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
                        else
                                prot = "public";
 
-                       std::cout << prot << ":" << std::endl
-                                 << "\t" << "virtual void Set" << it->GetFriendlyName() << "(" << it->Type.GetArgumentType() << " value)" << std::endl;
+                       m_Header << prot << ":" << std::endl
+                                << "\t" << "virtual void Set" << it->GetFriendlyName() << "(" << it->Type.GetArgumentType() << " value)";
 
                        if (it->PureSetAccessor) {
-                               std::cout << " = 0;" << std::endl;
+                               m_Header << " = 0;" << std::endl;
                        } else {
-                               std::cout << "\t" << "{" << std::endl;
+                               m_Header << ";" << std::endl;
+
+                               m_Impl << "void ObjectImpl<" << klass.Name << ">::Set" << it->GetFriendlyName() << "(" << it->Type.GetArgumentType() << " value)" << std::endl
+                                      << "{" << std::endl;
 
                                if (it->SetAccessor.empty() && !(it->Attributes & FANoStorage))
-                                       std::cout << "\t\t" << "m_" << it->GetFriendlyName() << " = value;" << std::endl;
+                                       m_Impl << "\t\t" << "m_" << it->GetFriendlyName() << " = value;" << std::endl;
                                else
-                                       std::cout << it->SetAccessor << std::endl;
+                                       m_Impl << it->SetAccessor << std::endl;
 
-                               std::cout << "\t" << "}" << std::endl << std::endl;
+                               m_Impl << "}" << std::endl << std::endl;
                        }
                }
 
@@ -571,64 +596,64 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
                for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
                        std::string realType = it->Type.GetRealType();
 
-                       std::cout << "private:" << std::endl
-                                         << "\t" << realType << " GetDefault" << it->GetFriendlyName() << "(void) const" << std::endl
-                                         << "\t" << "{" << std::endl;
+                       m_Header << "private:" << std::endl
+                                << "\t" << realType << " GetDefault" << it->GetFriendlyName() << "(void) const;" << std::endl;
+
+                       m_Impl << realType << " ObjectImpl<" << klass.Name << ">::GetDefault" << it->GetFriendlyName() << "(void) const" << std::endl
+                              << "{" << std::endl;
 
                        if (it->DefaultAccessor.empty())
-                               std::cout << "\t\t" << "return " << realType << "();" << std::endl;
+                               m_Impl << "\t" << "return " << realType << "();" << std::endl;
                        else
-                               std::cout << it->DefaultAccessor << std::endl;
+                               m_Impl << it->DefaultAccessor << std::endl;
 
-                       std::cout << "\t" << "}" << std::endl;
+                       m_Impl << "}" << std::endl;
                }
 
                /* validators */
                for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
-                       std::cout << "protected:" << std::endl
-                                 << "\t" << "virtual void Validate" << it->GetFriendlyName() << "(" << it->Type.GetArgumentType() << " value, const ValidationUtils& utils);" << std::endl;
+                       m_Header << "protected:" << std::endl
+                                << "\t" << "virtual void Validate" << it->GetFriendlyName() << "(" << it->Type.GetArgumentType() << " value, const ValidationUtils& utils);" << std::endl;
                }
 
                /* instance variables */
-               std::cout << "private:" << std::endl;
+               m_Header << "private:" << std::endl;
 
                for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
                        if (!(it->Attributes & FANoStorage))
-                               std::cout << "\t" << it->Type.GetRealType() << " m_" << it->GetFriendlyName() << ";" << std::endl;
+                               m_Header << "\t" << it->Type.GetRealType() << " m_" << it->GetFriendlyName() << ";" << std::endl;
                }
        }
 
        if (klass.Name == "DynamicObject")
-               std::cout << "\t" << "friend class ConfigItem;" << std::endl;
+               m_Header << "\t" << "friend class ConfigItem;" << std::endl;
 
        if (!klass.TypeBase.empty())
-               std::cout << "\t" << "friend class " << klass.TypeBase << ";" << std::endl;
+               m_Header << "\t" << "friend class " << klass.TypeBase << ";" << std::endl;
 
-       std::cout << "};" << std::endl << std::endl;
+       m_Header << "};" << std::endl << std::endl;
 
        for (it = klass.Fields.begin(); it != klass.Fields.end(); it++) {
                m_MissingValidators[std::make_pair(klass.Name, it->GetFriendlyName())] = *it;
        }
 }
 
-enum ValidatorType
-{
-       ValidatorField,
-       ValidatorArray,
-       ValidatorDictionary
-};
-
-static void CodeGenValidator(const std::string& name, const std::string& klass, const std::vector<Rule>& rules, const std::string& field, const FieldType& fieldType, ValidatorType validatorType)
+void ClassCompiler::CodeGenValidator(const std::string& name, const std::string& klass, const std::vector<Rule>& rules, const std::string& field, const FieldType& fieldType, ValidatorType validatorType)
 {
-       std::cout << "inline void TIValidate" << name << "(const intrusive_ptr<ObjectImpl<" << klass << "> >& object, ";
+       m_Header << "void TIValidate" << name << "(const intrusive_ptr<ObjectImpl<" << klass << "> >& object, ";
+       m_Impl << "void TIValidate" << name << "(const intrusive_ptr<ObjectImpl<" << klass << "> >& object, ";
 
-       if (validatorType != ValidatorField)
-               std::cout << "const String& key, ";
+       if (validatorType != ValidatorField) {
+               m_Header << "const String& key, ";
+               m_Impl << "const String& key, ";
+       }
 
        bool static_known_attribute = false;
 
-       std::cout << fieldType.GetArgumentType() << " value, std::vector<String>& location, const ValidationUtils& utils)" << std::endl
-                 << "{" << std::endl;
+       m_Header << fieldType.GetArgumentType() << " value, std::vector<String>& location, const ValidationUtils& utils);" << std::endl;
+
+       m_Impl << fieldType.GetArgumentType() << " value, std::vector<String>& location, const ValidationUtils& utils)" << std::endl
+              << "{" << std::endl;
 
        if (validatorType == ValidatorField) {
                static_known_attribute = true;
@@ -646,21 +671,21 @@ static void CodeGenValidator(const std::string& name, const std::string& klass,
 
                if (fieldType.GetRealType() != "int" && fieldType.GetRealType() != "double") {
                        if (fieldType.GetRealType() == "Value" || fieldType.GetRealType() == "String")
-                               std::cout << "\t" << "if (value.IsEmpty())" << std::endl;
+                               m_Impl << "\t" << "if (value.IsEmpty())" << std::endl;
                        else
-                               std::cout << "\t" << "if (!value)" << std::endl;
+                               m_Impl << "\t" << "if (!value)" << std::endl;
 
                        if (required)
-                               std::cout << "BOOST_THROW_EXCEPTION(ValidationError(this, location, \"This attribute must not be empty.\"));" << std::endl;
+                               m_Impl << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_cast<DynamicObject *>(this), location, \"This attribute must not be empty.\"));" << std::endl;
                        else
-                               std::cout << "\t\t" << "return;" << std::endl;
+                               m_Impl << "\t\t" << "return;" << std::endl;
 
-                       std::cout << std::endl;
+                       m_Impl << std::endl;
                }
        }
 
        if (!static_known_attribute)
-               std::cout << "\t" << "bool known_attribute = false;" << std::endl;
+               m_Impl << "\t" << "bool known_attribute = false;" << std::endl;
 
        bool type_check = false;
 
@@ -673,50 +698,50 @@ static void CodeGenValidator(const std::string& name, const std::string& klass,
                if (validatorType == ValidatorField && rule.Pattern != field)
                        continue;
 
-               std::cout << "\t" << "do {" << std::endl;
+               m_Impl << "\t" << "do {" << std::endl;
 
                if (validatorType != ValidatorField) {
                        if (rule.Pattern != "*") {
                                if (rule.Pattern.find_first_of("*?") != std::string::npos)
-                                       std::cout << "\t\t" << "if (!Utility::Match(\"" << rule.Pattern << "\", key))" << std::endl;
+                                       m_Impl << "\t\t" << "if (!Utility::Match(\"" << rule.Pattern << "\", key))" << std::endl;
                                else
-                                       std::cout << "\t\t" << "if (key != \"" << rule.Pattern << "\")" << std::endl;
+                                       m_Impl << "\t\t" << "if (key != \"" << rule.Pattern << "\")" << std::endl;
 
-                               std::cout << "\t\t\t" << "break;" << std::endl;
+                               m_Impl << "\t\t\t" << "break;" << std::endl;
                        } else
                                static_known_attribute = true;
 
                        if (!static_known_attribute)
-                               std::cout << "\t\t" << "known_attribute = true;" << std::endl;
+                               m_Impl << "\t\t" << "known_attribute = true;" << std::endl;
                }
 
                if (rule.IsName) {
-                       std::cout << "\t\t" << "if (value.IsScalar()) {" << std::endl
-                                 << "\t\t\t" << "if (utils.ValidateName(\"" << rule.Type << "\", value))" << std::endl
-                                 << "\t\t\t\t" << "return;" << std::endl
-                                 << "\t\t\t" << "else" << std::endl
-                                 << "\t\t\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(object, location, \"Object '\" + value + \"' of type '" << rule.Type << "' does not exist.\"));" << std::endl
-                                 << "\t\t" << "}" << std::endl;
+                       m_Impl << "\t\t" << "if (value.IsScalar()) {" << std::endl
+                              << "\t\t\t" << "if (utils.ValidateName(\"" << rule.Type << "\", value))" << std::endl
+                              << "\t\t\t\t" << "return;" << std::endl
+                              << "\t\t\t" << "else" << std::endl
+                              << "\t\t\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_pointer_cast<DynamicObject>(object), location, \"Object '\" + value + \"' of type '" << rule.Type << "' does not exist.\"));" << std::endl
+                              << "\t\t" << "}" << std::endl;
                }
 
                if (fieldType.GetRealType() == "Value") {
                        if (rule.Type == "String")
-                               std::cout << "\t\t" << "if (value.IsScalar())" << std::endl
-                                         << "\t\t\t" << "return;" << std::endl;
+                               m_Impl << "\t\t" << "if (value.IsScalar())" << std::endl
+                                      << "\t\t\t" << "return;" << std::endl;
                        else if (rule.Type == "Number") {
-                               std::cout << "\t\t" << "try {" << std::endl
-                                         << "\t\t\t" << "Convert::ToDouble(value);" << std::endl
-                                         << "\t\t\t" << "return;" << std::endl
-                                         << "\t\t" << "} catch (...) { }" << std::endl;
+                               m_Impl << "\t\t" << "try {" << std::endl
+                                      << "\t\t\t" << "Convert::ToDouble(value);" << std::endl
+                                      << "\t\t\t" << "return;" << std::endl
+                                      << "\t\t" << "} catch (...) { }" << std::endl;
                        }
                }
 
                if (rule.Type == "Dictionary" || rule.Type == "Array" || rule.Type == "Function") {
                        if (fieldType.GetRealType() == "Value") {
-                               std::cout << "\t\t" << "if (value.IsObjectType<" << rule.Type << ">()) {" << std::endl;
+                               m_Impl << "\t\t" << "if (value.IsObjectType<" << rule.Type << ">()) {" << std::endl;
                                type_check = true;
                        } else if (fieldType.GetRealType() != rule.Type + "::Ptr") {
-                               std::cout << "\t\t" << "if (dynamic_pointer_cast<" << rule.Type << ">(value)) {" << std::endl;
+                               m_Impl << "\t\t" << "if (dynamic_pointer_cast<" << rule.Type << ">(value)) {" << std::endl;
                                type_check = true;
                        }
 
@@ -725,29 +750,29 @@ static void CodeGenValidator(const std::string& name, const std::string& klass,
 
                                if (rule.Type == "Dictionary") {
                                        if (type_check)
-                                               std::cout << "\t\t\t" << "Dictionary::Ptr dict = value;" << std::endl;
+                                               m_Impl << "\t\t\t" << "Dictionary::Ptr dict = value;" << std::endl;
                                        else
-                                               std::cout << "\t\t" << "const Dictionary::Ptr& dict = value;" << std::endl;
+                                               m_Impl << "\t\t" << "const Dictionary::Ptr& dict = value;" << std::endl;
 
-                                       std::cout << (type_check ? "\t" : "") << "\t\t" << "ObjectLock olock(dict);" << std::endl
-                                                 << (type_check ? "\t" : "") << "\t\t" << "BOOST_FOREACH(const Dictionary::Pair& kv, dict) {" << std::endl
-                                                 << (type_check ? "\t" : "") << "\t\t\t" << "const String& akey = kv.first;" << std::endl
-                                                 << (type_check ? "\t" : "") << "\t\t\t" << "const Value& avalue = kv.second;" << std::endl;
+                                       m_Impl << (type_check ? "\t" : "") << "\t\t" << "ObjectLock olock(dict);" << std::endl
+                                              << (type_check ? "\t" : "") << "\t\t" << "BOOST_FOREACH(const Dictionary::Pair& kv, dict) {" << std::endl
+                                              << (type_check ? "\t" : "") << "\t\t\t" << "const String& akey = kv.first;" << std::endl
+                                              << (type_check ? "\t" : "") << "\t\t\t" << "const Value& avalue = kv.second;" << std::endl;
                                        indent = true;
                                } else if (rule.Type == "Array") {
                                        if (type_check)
-                                               std::cout << "\t\t\t" << "Array::Ptr arr = value;" << std::endl;
+                                               m_Impl << "\t\t\t" << "Array::Ptr arr = value;" << std::endl;
                                        else
-                                               std::cout << "\t\t" << "const Array::Ptr& arr = value;" << std::endl;
+                                               m_Impl << "\t\t" << "const Array::Ptr& arr = value;" << std::endl;
 
-                                       std::cout << (type_check ? "\t" : "") << "\t\t" << "Array::SizeType anum = 0;" << std::endl
-                                                 << (type_check ? "\t" : "") << "\t\t" << "ObjectLock olock(arr);" << std::endl
-                                                 << (type_check ? "\t" : "") << "\t\t" << "BOOST_FOREACH(const Value& avalue, arr) {" << std::endl
-                                                 << (type_check ? "\t" : "") << "\t\t\t" << "String akey = Convert::ToString(anum);" << std::endl;
+                                       m_Impl << (type_check ? "\t" : "") << "\t\t" << "Array::SizeType anum = 0;" << std::endl
+                                              << (type_check ? "\t" : "") << "\t\t" << "ObjectLock olock(arr);" << std::endl
+                                              << (type_check ? "\t" : "") << "\t\t" << "BOOST_FOREACH(const Value& avalue, arr) {" << std::endl
+                                              << (type_check ? "\t" : "") << "\t\t\t" << "String akey = Convert::ToString(anum);" << std::endl;
                                        indent = true;
                                } else {
-                                       std::cout << (type_check ? "\t" : "") << "\t\t" << "String akey = \"\";" << std::endl
-                                                 << (type_check ? "\t" : "") << "\t\t" << "const Value& avalue = value;" << std::endl;
+                                       m_Impl << (type_check ? "\t" : "") << "\t\t" << "String akey = \"\";" << std::endl
+                                              << (type_check ? "\t" : "") << "\t\t" << "const Value& avalue = value;" << std::endl;
                                }
 
                                std::string subvalidator_prefix;
@@ -757,14 +782,14 @@ static void CodeGenValidator(const std::string& name, const std::string& klass,
                                else
                                        subvalidator_prefix = name;
 
-                               std::cout << (type_check ? "\t" : "") << (indent ? "\t" : "") << "\t\t" << "location.push_back(akey);" << std::endl
-                                         << (type_check ? "\t" : "") << (indent ? "\t" : "") << "\t\t" << "TIValidate" << subvalidator_prefix << "_" << i << "(object, akey, avalue, location, utils);" << std::endl;
+                               m_Impl << (type_check ? "\t" : "") << (indent ? "\t" : "") << "\t\t" << "location.push_back(akey);" << std::endl
+                                      << (type_check ? "\t" : "") << (indent ? "\t" : "") << "\t\t" << "TIValidate" << subvalidator_prefix << "_" << i << "(object, akey, avalue, location, utils);" << std::endl;
 
                                if (rule.Type == "Array")
-                                       std::cout << (type_check ? "\t" : "") << "\t\t\t" << "anum++;" << std::endl;
+                                       m_Impl << (type_check ? "\t" : "") << "\t\t\t" << "anum++;" << std::endl;
 
                                if (rule.Type == "Dictionary" || rule.Type == "Array")
-                                       std::cout << (type_check ? "\t" : "") << "\t\t" << "}" << std::endl;
+                                       m_Impl << (type_check ? "\t" : "") << "\t\t" << "}" << std::endl;
 
                                for (std::vector<Rule>::size_type i = 0; i < rule.Rules.size(); i++) {
                                        const Rule& srule = rule.Rules[i];
@@ -773,8 +798,8 @@ static void CodeGenValidator(const std::string& name, const std::string& klass,
                                                continue;
 
                                        if (rule.Type == "Dictionary") {
-                                               std::cout << (type_check ? "\t" : "") << "\t\t" << "if (dict.Get(\"" << srule.Pattern << "\").IsEmpty())" << std::endl
-                                                         << (type_check ? "\t" : "") << "\t\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(this, location, \"Required dictionary item '" << srule.Pattern << "' is not set.\"));" << std::endl;
+                                               m_Impl << (type_check ? "\t" : "") << "\t\t" << "if (dict.Get(\"" << srule.Pattern << "\").IsEmpty())" << std::endl
+                                                      << (type_check ? "\t" : "") << "\t\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_cast<DynamicObject *>(this), location, \"Required dictionary item '" << srule.Pattern << "' is not set.\"));" << std::endl;
                                        } else if (rule.Type == "Array") {
                                                int index = -1;
                                                std::stringstream idxbuf;
@@ -786,43 +811,43 @@ static void CodeGenValidator(const std::string& name, const std::string& klass,
                                                        std::exit(1);
                                                }
 
-                                               std::cout << (type_check ? "\t" : "") << "\t\t" << "if (arr.GetLength() < " << (index + 1) << ")" << std::endl
-                                                         << (type_check ? "\t" : "") << "\t\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(this, location, \"Required index '" << index << "' is not set.\"));" << std::endl;
+                                               m_Impl << (type_check ? "\t" : "") << "\t\t" << "if (arr.GetLength() < " << (index + 1) << ")" << std::endl
+                                                      << (type_check ? "\t" : "") << "\t\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_cast<DynamicObject *>(this), location, \"Required index '" << index << "' is not set.\"));" << std::endl;
                                        }
                                }
 
-                               std::cout << (type_check ? "\t" : "") << (indent ? "\t" : "") << "\t\t" << "location.pop_back();" << std::endl;
+                               m_Impl << (type_check ? "\t" : "") << (indent ? "\t" : "") << "\t\t" << "location.pop_back();" << std::endl;
                        }
 
-                       std::cout << (type_check ? "\t" : "") << "\t\t" << "return;" << std::endl;
+                       m_Impl << (type_check ? "\t" : "") << "\t\t" << "return;" << std::endl;
 
                        if (fieldType.GetRealType() == "Value" || fieldType.GetRealType() != rule.Type + "::Ptr")
-                               std::cout << "\t\t" << "}" << std::endl;
+                               m_Impl << "\t\t" << "}" << std::endl;
                }
 
-               std::cout << "\t" << "} while (0);" << std::endl << std::endl;
+               m_Impl << "\t" << "} while (0);" << std::endl << std::endl;
        }
 
        if (type_check || validatorType != ValidatorField) {
                if (!static_known_attribute)
-                       std::cout << "\t" << "if (!known_attribute)" << std::endl
-                                 << "\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(object, location, \"Invalid attribute: \" + key));" << std::endl
-                                 << "\t" << "else" << std::endl;
+                       m_Impl << "\t" << "if (!known_attribute)" << std::endl
+                              << "\t\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_pointer_cast<DynamicObject>(object), location, \"Invalid attribute: \" + key));" << std::endl
+                              << "\t" << "else" << std::endl;
 
-               std::cout << (!static_known_attribute ? "\t" : "") << "\t" << "BOOST_THROW_EXCEPTION(ValidationError(object, boost::assign::list_of(";
+               m_Impl << (!static_known_attribute ? "\t" : "") << "\t" << "BOOST_THROW_EXCEPTION(ValidationError(dynamic_pointer_cast<DynamicObject>(object), boost::assign::list_of(";
 
                if (validatorType == ValidatorField)
-                       std::cout << "\"" << field << "\"";
+                       m_Impl << "\"" << field << "\"";
                else
-                       std::cout << "key";
+                       m_Impl << "key";
 
-               std::cout << "), \"Invalid type.\"));" << std::endl;
+               m_Impl << "), \"Invalid type.\"));" << std::endl;
        }
 
-       std::cout << "}" << std::endl << std::endl;
+       m_Impl << "}" << std::endl << std::endl;
 }
 
-static void CodeGenValidatorSubrules(const std::string& name, const std::string& klass, const std::vector<Rule>& rules)
+void ClassCompiler::CodeGenValidatorSubrules(const std::string& name, const std::string& klass, const std::vector<Rule>& rules)
 {
        for (std::vector<Rule>::size_type i = 0; i < rules.size(); i++) {
                const Rule& rule = rules[i];
@@ -863,13 +888,13 @@ void ClassCompiler::HandleValidator(const Validator& validator, const ClassDebug
                CodeGenValidator(it->first.first + it->first.second, it->first.first, validator.Rules, it->second.Name, it->second.Type, ValidatorField);
 
        for (std::map<std::pair<std::string, std::string>, Field>::const_iterator it = m_MissingValidators.begin(); it != m_MissingValidators.end(); it++) {
-               std::cout << "inline void ObjectImpl<" << it->first.first << ">::Validate" << it->first.second << "(" << it->second.Type.GetArgumentType() << " value, const ValidationUtils& utils)" << std::endl
-                         << "{" << std::endl
-                         << "\t" << "SimpleValidate" << it->first.second << "(value, utils);" << std::endl
-                         << "\t" << "std::vector<String> location;" << std::endl
-                         << "\t" << "location.push_back(\"" << it->second.Name << "\");" << std::endl
-                         << "\t" << "TIValidate" << it->first.first << it->first.second << "(this, value, location, utils);" << std::endl
-                         << "}" << std::endl << std::endl;
+               m_Impl << "void ObjectImpl<" << it->first.first << ">::Validate" << it->first.second << "(" << it->second.Type.GetArgumentType() << " value, const ValidationUtils& utils)" << std::endl
+                      << "{" << std::endl
+                      << "\t" << "SimpleValidate" << it->first.second << "(value, utils);" << std::endl
+                      << "\t" << "std::vector<String> location;" << std::endl
+                      << "\t" << "location.push_back(\"" << it->second.Name << "\");" << std::endl
+                      << "\t" << "TIValidate" << it->first.first << it->first.second << "(this, value, location, utils);" << std::endl
+                      << "}" << std::endl << std::endl;
        }
 
        m_MissingValidators.clear();
@@ -878,24 +903,67 @@ void ClassCompiler::HandleValidator(const Validator& validator, const ClassDebug
 void ClassCompiler::HandleMissingValidators(void)
 {
        for (std::map<std::pair<std::string, std::string>, Field>::const_iterator it = m_MissingValidators.begin(); it != m_MissingValidators.end(); it++) {
-               std::cout << "inline void ObjectImpl<" << it->first.first << ">::Validate" << it->first.second << "(" << it->second.Type.GetArgumentType() << " value, const ValidationUtils& utils)" << std::endl
-                         << "{" << std::endl
-                         << "\t" << "SimpleValidate" << it->first.second << "(value, utils);" << std::endl
-                         << "}" << std::endl << std::endl;
+               m_Impl << "void ObjectImpl<" << it->first.first << ">::Validate" << it->first.second << "(" << it->second.Type.GetArgumentType() << " value, const ValidationUtils& utils)" << std::endl
+                      << "{" << std::endl
+                      << "\t" << "SimpleValidate" << it->first.second << "(value, utils);" << std::endl
+                      << "}" << std::endl << std::endl;
        }
 
        m_MissingValidators.clear();
 }
 
-void ClassCompiler::CompileFile(const std::string& path)
+void ClassCompiler::CompileFile(const std::string& inputpath,
+    const std::string& implpath, const std::string& headerpath)
 {
-       std::ifstream stream;
-       stream.open(path.c_str(), std::ifstream::in);
+       std::ifstream input;
+       input.open(inputpath.c_str(), std::ifstream::in);
+
+       if (!input) {
+               std::cerr << "Could not open input file: " << inputpath << std::endl;
+               std::exit(EXIT_FAILURE);
+       }
+
+       std::string tmpheaderpath = headerpath + ".tmp";
+       std::ofstream oheader;
+       oheader.open(tmpheaderpath.c_str(), std::ofstream::out);
+
+       if (!oheader) {
+               std::cerr << "Could not open header file: " << tmpheaderpath << std::endl;
+               std::exit(EXIT_FAILURE);
+       }
+
+       std::string tmpimplpath = implpath + ".tmp";
+       std::ofstream oimpl;
+       oimpl.open(tmpimplpath.c_str(), std::ofstream::out);
+
+       if (!oimpl) {
+               std::cerr << "Could not open implementation file: " << tmpimplpath << std::endl;
+               std::exit(EXIT_FAILURE);
+       }
+
+       CompileStream(inputpath, input, oimpl, oheader);
 
-       if (!stream)
-               throw std::invalid_argument("Could not open config file: " + path);
+       input.close();
+       oimpl.close();
+       oheader.close();
 
-       return CompileStream(path, &stream);
+#ifdef _WIN32
+       _unlink(headerpath.c_str());
+#endif /* _WIN32 */
+
+       if (rename(tmpheaderpath.c_str(), headerpath.c_str()) < 0) {
+               std::cerr << "Could not rename header file: " << tmpheaderpath << " -> " << headerpath << std::endl;
+               std::exit(EXIT_FAILURE);
+       }
+
+#ifdef _WIN32
+       _unlink(implpath.c_str());
+#endif /* _WIN32 */
+
+       if (rename(tmpimplpath.c_str(), implpath.c_str()) < 0) {
+               std::cerr << "Could not rename implementation file: " << tmpimplpath << " -> " << implpath << std::endl;
+               std::exit(EXIT_FAILURE);
+       }
 }
 
 std::string ClassCompiler::BaseName(const std::string& path)
@@ -921,7 +989,7 @@ std::string ClassCompiler::FileNameToGuardName(const std::string& fname)
 {
        std::string result = fname;
 
-       for (int i = 0; i < result.size(); i++) {
+       for (std::string::size_type i = 0; i < result.size(); i++) {
                result[i] = toupper(result[i]);
 
                if (result[i] == '.')
@@ -931,39 +999,41 @@ std::string ClassCompiler::FileNameToGuardName(const std::string& fname)
        return result;
 }
 
-void ClassCompiler::CompileStream(const std::string& path, std::istream *stream)
+void ClassCompiler::CompileStream(const std::string& path, std::istream& input,
+    std::ostream& oimpl, std::ostream& oheader)
 {
-       stream->exceptions(std::istream::badbit);
+       input.exceptions(std::istream::badbit);
 
        std::string guard_name = FileNameToGuardName(BaseName(path));
 
-       std::cout << "#ifndef " << guard_name << std::endl
-                         << "#define " << guard_name << std::endl << std::endl;
-
-       std::cout << "#include \"base/object.hpp\"" << std::endl
-                         << "#include \"base/type.hpp\"" << std::endl
-                         << "#include \"base/debug.hpp\"" << std::endl
-                         << "#include \"base/value.hpp\"" << std::endl
-                         << "#include \"base/array.hpp\"" << std::endl
-                         << "#include \"base/dictionary.hpp\"" << std::endl
-                         << "#include \"base/convert.hpp\"" << std::endl
-                         << "#include \"base/exception.hpp\"" << std::endl
-                         << "#include \"base/objectlock.hpp\"" << std::endl
-                         << "#include \"base/utility.hpp\"" << std::endl << std::endl
-                         << "#include <boost/foreach.hpp>" << std::endl
-                         << "#include <boost/assign/list_of.hpp>" << std::endl
-                         << "#ifdef _MSC_VER" << std::endl
-                         << "#pragma warning( push )" << std::endl
-                         << "#pragma warning( disable : 4244 )" << std::endl
-                         << "#pragma warning( disable : 4800 )" << std::endl
-                         << "#endif /* _MSC_VER */" << std::endl << std::endl;
-
-       ClassCompiler ctx(path, stream);
+       oheader << "#ifndef " << guard_name << std::endl
+               << "#define " << guard_name << std::endl << std::endl;
+
+       oheader << "#include \"base/object.hpp\"" << std::endl
+               << "#include \"base/type.hpp\"" << std::endl
+               << "#include \"base/value.hpp\"" << std::endl
+               << "#include \"base/array.hpp\"" << std::endl
+               << "#include \"base/dictionary.hpp\"" << std::endl << std::endl;
+
+       oimpl << "#include \"base/exception.hpp\"" << std::endl
+             << "#include \"base/objectlock.hpp\"" << std::endl
+             << "#include \"base/utility.hpp\"" << std::endl
+             << "#include \"base/convert.hpp\"" << std::endl
+             << "#include <boost/foreach.hpp>" << std::endl
+             << "#include <boost/assign/list_of.hpp>" << std::endl
+             << "#ifdef _MSC_VER" << std::endl
+             << "#pragma warning( push )" << std::endl
+             << "#pragma warning( disable : 4244 )" << std::endl
+             << "#pragma warning( disable : 4800 )" << std::endl
+             << "#endif /* _MSC_VER */" << std::endl << std::endl;
+
+
+       ClassCompiler ctx(path, input, oimpl, oheader);
        ctx.Compile();
 
-       std::cout << "#ifdef _MSC_VER" << std::endl
-                         << "#pragma warning ( pop )" << std::endl
-                         << "#endif /* _MSC_VER */" << std::endl;
+       oheader << "#endif /* " << guard_name << " */" << std::endl;
 
-       std::cout << "#endif /* " << guard_name << " */" << std::endl;
+       oimpl << "#ifdef _MSC_VER" << std::endl
+               << "#pragma warning ( pop )" << std::endl
+               << "#endif /* _MSC_VER */" << std::endl;
 }
index 697f32f490287d2f5a80e7e1493b588eec9a1095..96b48b57da414cd9fb8cd8f6c6319b9986b499dc 100644 (file)
@@ -171,6 +171,13 @@ struct Rule
        std::vector<Rule> Rules;
 };
 
+enum ValidatorType
+{
+       ValidatorField,
+       ValidatorArray,
+       ValidatorDictionary
+};
+
 struct Validator
 {
        std::string Name;
@@ -180,7 +187,7 @@ struct Validator
 class ClassCompiler
 {
 public:
-       ClassCompiler(const std::string& path, std::istream *input);
+       ClassCompiler(const std::string& path, std::istream& input, std::ostream& oimpl, std::ostream& oheader);
        ~ClassCompiler(void);
 
        void Compile(void);
@@ -203,14 +210,21 @@ public:
        void HandleCode(const std::string& code, const ClassDebugInfo& locp);
        void HandleMissingValidators(void);
 
-       static void CompileFile(const std::string& path);
-       static void CompileStream(const std::string& path, std::istream *stream);
+       void CodeGenValidator(const std::string& name, const std::string& klass, const std::vector<Rule>& rules, const std::string& field, const FieldType& fieldType, ValidatorType validatorType);
+       void CodeGenValidatorSubrules(const std::string& name, const std::string& klass, const std::vector<Rule>& rules);
+
+       static void CompileFile(const std::string& inputpath, const std::string& implpath,
+           const std::string& headerpath);
+       static void CompileStream(const std::string& path, std::istream& input,
+           std::ostream& oimpl, std::ostream& oheader);
 
        static void OptimizeStructLayout(std::vector<Field>& fields);
 
 private:
        std::string m_Path;
-       std::istream *m_Input;
+       std::istream& m_Input;
+       std::ostream& m_Impl;
+       std::ostream& m_Header;
        void *m_Scanner;
 
        std::map<std::pair<std::string, std::string>, Field> m_MissingValidators;
index db5ddee41a64397b5b17c7bd07c7d1bbe8124a9f..655773db07131abedbbed0b810b6077ed91e82f8 100644 (file)
@@ -24,10 +24,10 @@ using namespace icinga;
 
 int main(int argc, char **argv)
 {
-       if (argc < 2) {
-               std::cerr << "Syntax: " << argv[0] << " <file>" << std::endl;
+       if (argc < 4) {
+               std::cerr << "Syntax: " << argv[0] << " <input> <output-impl> <output-header>" << std::endl;
                return 1;
        }
 
-       ClassCompiler::CompileFile(argv[1]);
+       ClassCompiler::CompileFile(argv[1], argv[2], argv[3]);
 }