Browse Source

Merge pull request #2072 from treefrogframework/v1_12-psql_mongo

Updated TreeFrog to version 1.12.0 and added setup for MongoDB and PostgreSQL
Nate 9 years ago
parent
commit
04641d2f49
26 changed files with 621 additions and 45 deletions
  1. 50 4
      frameworks/C++/treefrog/benchmark_config.json
  2. 20 18
      frameworks/C++/treefrog/config/application.ini
  3. 3 3
      frameworks/C++/treefrog/config/mongodb.ini
  4. 1 1
      frameworks/C++/treefrog/controllers/controllers.pro
  5. 18 0
      frameworks/C++/treefrog/controllers/fortunecontroller.cpp
  6. 2 1
      frameworks/C++/treefrog/controllers/fortunecontroller.h
  7. 51 1
      frameworks/C++/treefrog/controllers/worldcontroller.cpp
  8. 7 0
      frameworks/C++/treefrog/controllers/worldcontroller.h
  9. 1 1
      frameworks/C++/treefrog/helpers/helpers.pro
  10. 104 0
      frameworks/C++/treefrog/models/mngfortune.cpp
  11. 51 0
      frameworks/C++/treefrog/models/mngfortune.h
  12. 105 0
      frameworks/C++/treefrog/models/mngworld.cpp
  13. 51 0
      frameworks/C++/treefrog/models/mngworld.h
  14. 9 3
      frameworks/C++/treefrog/models/models.pro
  15. 35 0
      frameworks/C++/treefrog/models/mongoobjects/mngfortuneobject.h
  16. 35 0
      frameworks/C++/treefrog/models/mongoobjects/mngworldobject.h
  17. 20 0
      frameworks/C++/treefrog/setup-mongodb.sh
  18. 20 0
      frameworks/C++/treefrog/setup-postgres.sh
  19. 5 4
      frameworks/C++/treefrog/setup-thread.sh
  20. 4 3
      frameworks/C++/treefrog/setup.sh
  21. 1 1
      frameworks/C++/treefrog/views/_src/_src.pro
  22. 1 0
      frameworks/C++/treefrog/views/fortune/.trim_mode
  23. 1 2
      frameworks/C++/treefrog/views/fortune/index.erb
  24. 22 0
      frameworks/C++/treefrog/views/fortune/mindex.erb
  25. 1 0
      frameworks/C++/treefrog/views/world/.trim_mode
  26. 3 3
      toolset/setup/linux/frameworks/treefrog.sh

+ 50 - 4
frameworks/C++/treefrog/benchmark_config.json

@@ -2,6 +2,29 @@
   "framework": "treefrog",
   "framework": "treefrog",
   "tests": [{
   "tests": [{
     "default": {
     "default": {
+      "setup_file": "setup-thread",
+      "json_url": "/json/json",
+      "db_url": "/world/random",
+      "query_url": "/world/queries/",
+      "fortune_url": "/fortune/index",
+      "update_url": "/world/updates/",
+      "plaintext_url": "/world/plain",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Fullstack",
+      "database": "MySQL",
+      "framework": "treefrog",
+      "language": "C++",
+      "orm": "Micro",
+      "platform": "Treefrog",
+      "webserver": "None",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "treefrog-thread",
+      "notes": "",
+      "versus": ""
+    },
+    "hybrid": {
       "setup_file": "setup",
       "setup_file": "setup",
       "json_url": "/json/json",
       "json_url": "/json/json",
       "db_url": "/world/random",
       "db_url": "/world/random",
@@ -24,8 +47,8 @@
       "notes": "",
       "notes": "",
       "versus": ""
       "versus": ""
     },
     },
-    "thread": {
-      "setup_file": "setup-thread",
+    "postgres": {
+      "setup_file": "setup-postgres",
       "json_url": "/json/json",
       "json_url": "/json/json",
       "db_url": "/world/random",
       "db_url": "/world/random",
       "query_url": "/world/queries/",
       "query_url": "/world/queries/",
@@ -35,7 +58,7 @@
       "port": 8080,
       "port": 8080,
       "approach": "Realistic",
       "approach": "Realistic",
       "classification": "Fullstack",
       "classification": "Fullstack",
-      "database": "MySQL",
+      "database": "Postgres",
       "framework": "treefrog",
       "framework": "treefrog",
       "language": "C++",
       "language": "C++",
       "orm": "Micro",
       "orm": "Micro",
@@ -43,7 +66,30 @@
       "webserver": "None",
       "webserver": "None",
       "os": "Linux",
       "os": "Linux",
       "database_os": "Linux",
       "database_os": "Linux",
-      "display_name": "treefrog-thread",
+      "display_name": "treefrog-postgres",
+      "notes": "",
+      "versus": ""
+    },
+    "mongodb": {
+      "setup_file": "setup-mongodb",
+      "json_url": "/json/json",
+      "db_url": "/world/mrandom",
+      "query_url": "/world/mqueries/",
+      "fortune_url": "/fortune/mindex",
+      "update_url": "/world/mupdates/",
+      "plaintext_url": "/world/plain",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Fullstack",
+      "database": "MongoDB",
+      "framework": "treefrog",
+      "language": "C++",
+      "orm": "Micro",
+      "platform": "Treefrog",
+      "webserver": "None",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "treefrog-mongo",
       "notes": "",
       "notes": "",
       "versus": ""
       "versus": ""
     }
     }

+ 20 - 18
frameworks/C++/treefrog/config/application.ini

@@ -14,10 +14,6 @@ InternalEncoding=UTF-8
 # specified encoding. See QTextCodec class reference.
 # specified encoding. See QTextCodec class reference.
 HttpOutputEncoding=UTF-8
 HttpOutputEncoding=UTF-8
 
 
-# Sets the charset parameter of 'text/html' in the HTTP Content-Type
-# header to the specified string.
-HtmlContentCharset=UTF-8
-
 # Sets a language/country pair, such as en_US, ja_JP, etc.
 # Sets a language/country pair, such as en_US, ja_JP, etc.
 # If this value is empty, the system's locale is used.
 # If this value is empty, the system's locale is used.
 Locale=
 Locale=
@@ -33,7 +29,7 @@ UploadTemporaryDirectory=tmp
 SqlDatabaseSettingsFiles=database.ini
 SqlDatabaseSettingsFiles=database.ini
 
 
 # Specify the setting file for MongoDB.
 # Specify the setting file for MongoDB.
-MongoDbSettingsFile=
+MongoDbSettingsFile=mongodb.ini
 
 
 # Specify the directory path to store SQL query files
 # Specify the directory path to store SQL query files
 SqlQueriesStoredDirectory=sql/
 SqlQueriesStoredDirectory=sql/
@@ -64,6 +60,25 @@ LimitRequestBody=0
 # forgery never work; otherwise it's enabled.
 # forgery never work; otherwise it's enabled.
 EnableCsrfProtectionModule=false
 EnableCsrfProtectionModule=false
 
 
+# Enables HTTP method override if true. The following are priorities of
+# override.
+#  - Value of query parameter named '_method'
+#  - Value of X-HTTP-Method-Override header
+#  - Value of X-HTTP-Method header
+#  - Value of X-METHOD-OVERRIDE header
+EnableHttpMethodOverride=false
+
+# Sets the timeout in seconds during which a keep-alive HTTP connection
+# will stay open on the server side. The zero value disables keep-alive
+# client connections.
+HttpKeepAliveTimeout=10
+
+# Forces some libraries to be loaded before all others. It means to set
+# the LD_PRELOAD environment variable for the application server, Linux
+# only. The paths to shared objects, jemalloc or TCMalloc, can be
+# specified.
+LDPreload=/usr/lib/x86_64-linux-gnu/libjemalloc.so
+
 ##
 ##
 ## Session section
 ## Session section
 ##
 ##
@@ -112,19 +127,6 @@ MPM.thread.MaxAppServers=10
 # per server process.
 # per server process.
 MPM.thread.MaxThreadsPerAppServer=100
 MPM.thread.MaxThreadsPerAppServer=100
 
 
-##
-## MPM Prefork section
-##
-
-# Maximum number of server processes allowed to start
-MPM.prefork.MaxServers=20
-
-# Minimum number of server processes allowed to start
-MPM.prefork.MinServers=5
-
-# Number of server processes which are kept spare
-MPM.prefork.SpareServers=5
-
 ##
 ##
 ## MPM Hybrid section
 ## MPM Hybrid section
 ##
 ##

+ 3 - 3
frameworks/C++/treefrog/config/mongodb.ini

@@ -3,7 +3,7 @@
 #
 #
 
 
 [dev]
 [dev]
-DatabaseName=mdb
+DatabaseName=hello_world
 HostName=localhost
 HostName=localhost
 Port=
 Port=
 UserName=
 UserName=
@@ -19,8 +19,8 @@ Password=
 ConnectOptions=
 ConnectOptions=
 
 
 [product]
 [product]
-DatabaseName=
-HostName=
+DatabaseName=hello_world
+HostName=localhost
 Port=
 Port=
 UserName=
 UserName=
 Password=
 Password=

+ 1 - 1
frameworks/C++/treefrog/controllers/controllers.pro

@@ -1,7 +1,7 @@
 TARGET = controller
 TARGET = controller
 TEMPLATE = lib
 TEMPLATE = lib
 CONFIG += shared x86_64 c++11
 CONFIG += shared x86_64 c++11
-QT += network sql xml
+QT += network sql xml qml
 QT -= gui
 QT -= gui
 DEFINES += TF_DLL
 DEFINES += TF_DLL
 DESTDIR = ../lib
 DESTDIR = ../lib

+ 18 - 0
frameworks/C++/treefrog/controllers/fortunecontroller.cpp

@@ -1,11 +1,17 @@
 #include "fortunecontroller.h"
 #include "fortunecontroller.h"
 #include "fortune.h"
 #include "fortune.h"
+#include "mngfortune.h"
 
 
 static bool caseSensitiveLessThan(const Fortune &f1, const Fortune &f2)
 static bool caseSensitiveLessThan(const Fortune &f1, const Fortune &f2)
 {
 {
     return f1.message() < f2.message();
     return f1.message() < f2.message();
 }
 }
 
 
+static bool caseSensitiveMngFortuneLessThan(const MngFortune &f1, const MngFortune &f2)
+{
+    return f1.message() < f2.message();
+}
+
 FortuneController::FortuneController(const FortuneController &)
 FortuneController::FortuneController(const FortuneController &)
     : ApplicationController()
     : ApplicationController()
 { }
 { }
@@ -22,6 +28,18 @@ void FortuneController::index()
     render();
     render();
 }
 }
 
 
+void FortuneController::mindex()
+{
+    QList<MngFortune> fortuneList = MngFortune::getAll();
+    MngFortune fortune;
+    fortune.setMessage(QLatin1String("Additional fortune added at request time."));
+    fortuneList << fortune;
+    // Sort
+    qSort(fortuneList.begin(), fortuneList.end(), caseSensitiveMngFortuneLessThan);
+    texport(fortuneList);
+    render("mindex");
+}
+
 void FortuneController::show(const QString &pk)
 void FortuneController::show(const QString &pk)
 {
 {
     Fortune fortune = Fortune::get(pk.toUInt());
     Fortune fortune = Fortune::get(pk.toUInt());

+ 2 - 1
frameworks/C++/treefrog/controllers/fortunecontroller.h

@@ -14,7 +14,8 @@ public:
     bool transactionEnabled() const { return false; }
     bool transactionEnabled() const { return false; }
 
 
 public slots:
 public slots:
-    void index();
+    void index();   // SQL
+    void mindex();  // MongoDB
     void show(const QString &pk);
     void show(const QString &pk);
     void entry();
     void entry();
     void create();
     void create();

+ 51 - 1
frameworks/C++/treefrog/controllers/worldcontroller.cpp

@@ -1,5 +1,6 @@
 #include "worldcontroller.h"
 #include "worldcontroller.h"
 #include "world.h"
 #include "world.h"
+#include "mngworld.h"
 
 
 
 
 WorldController::WorldController(const WorldController &)
 WorldController::WorldController(const WorldController &)
@@ -139,7 +140,7 @@ void WorldController::updates(const QString &num)
         world = World::get(id);
         world = World::get(id);
         world.setRandomNumber( Tf::random(9999) + 1 );
         world.setRandomNumber( Tf::random(9999) + 1 );
         world.update();
         world.update();
-	worlds << world.toVariantMap();
+        worlds << world.toVariantMap();
     }
     }
     renderJson(worlds);
     renderJson(worlds);
 }
 }
@@ -156,5 +157,54 @@ void WorldController::remove(const QString &pk)
 }
 }
 
 
 
 
+
+/*
+  MongoDB
+ */
+void WorldController::mqueries()
+{
+    mqueries("1");
+}
+
+void WorldController::mqueries(const QString &num)
+{
+    QVariantList worlds;
+    int d = qMin(qMax(num.toInt(), 1), 500);
+
+    for (int i = 0; i < d; ++i) {
+        QString id = QString::number(Tf::random(9999) + 1);
+        worlds << MngWorld::get(id).toVariantMap();
+    }
+    renderJson(worlds);
+}
+
+void WorldController::mrandom()
+{
+    int id = Tf::random(9999) + 1;
+    World world = World::get(id);
+    renderJson(world.toVariantMap());
+}
+
+void WorldController::mupdates()
+{
+    mupdates("1");
+}
+
+void WorldController::mupdates(const QString &num)
+{
+    QVariantList worlds;
+    int d = qMin(qMax(num.toInt(), 1), 500);
+    MngWorld world;
+
+    for (int i = 0; i < d; ++i) {
+        QString id = QString::number(Tf::random(9999) + 1);
+        world = MngWorld::get(id);
+        world.setRandomNumber( Tf::random(9999) + 1 );
+        world.update();
+        worlds << world.toVariantMap();
+    }
+    renderJson(worlds);
+}
+
 // Don't remove below this line
 // Don't remove below this line
 T_REGISTER_CONTROLLER(worldcontroller)
 T_REGISTER_CONTROLLER(worldcontroller)

+ 7 - 0
frameworks/C++/treefrog/controllers/worldcontroller.h

@@ -28,6 +28,13 @@ public slots:
     void updates();
     void updates();
     void remove(const QString &pk);
     void remove(const QString &pk);
 
 
+    // MongoDB
+    void mqueries();
+    void mqueries(const QString &num);
+    void mrandom();
+    void mupdates(const QString &num);
+    void mupdates();
+
 private:
 private:
     void renderEntry(const QVariantMap &world = QVariantMap());
     void renderEntry(const QVariantMap &world = QVariantMap());
     void renderEdit(const QVariantMap &world = QVariantMap());
     void renderEdit(const QVariantMap &world = QVariantMap());

+ 1 - 1
frameworks/C++/treefrog/helpers/helpers.pro

@@ -2,7 +2,7 @@ TARGET = helper
 TEMPLATE = lib
 TEMPLATE = lib
 CONFIG += shared x86_64 c++11
 CONFIG += shared x86_64 c++11
 QT  -= gui
 QT  -= gui
-QT  += 
+QT  += qml
 DEFINES += TF_DLL
 DEFINES += TF_DLL
 DESTDIR = ../lib
 DESTDIR = ../lib
 DEPENDPATH +=
 DEPENDPATH +=

+ 104 - 0
frameworks/C++/treefrog/models/mngfortune.cpp

@@ -0,0 +1,104 @@
+#include <TreeFrogModel>
+#include "mngfortune.h"
+#include "mngfortuneobject.h"
+
+MngFortune::MngFortune()
+    : TAbstractModel(), d(new MngFortuneObject)
+{
+    d->id = 0;
+}
+
+MngFortune::MngFortune(const MngFortune &other)
+    : TAbstractModel(), d(new MngFortuneObject(*other.d))
+{ }
+
+MngFortune::MngFortune(const MngFortuneObject &object)
+    : TAbstractModel(), d(new MngFortuneObject(object))
+{ }
+
+MngFortune::~MngFortune()
+{
+    // If the reference count becomes 0,
+    // the shared data object 'MngFortuneObject' is deleted.
+}
+
+int MngFortune::id() const
+{
+    return d->id;
+}
+
+QString MngFortune::message() const
+{
+    return d->message;
+}
+
+void MngFortune::setMessage(const QString &message)
+{
+    d->message = message;
+}
+
+MngFortune &MngFortune::operator=(const MngFortune &other)
+{
+    d = other.d;  // increments the reference count of the data
+    return *this;
+}
+
+MngFortune MngFortune::create(const QString &message)
+{
+    MngFortuneObject obj;
+    obj.message = message;
+    if (!obj.create()) {
+        return MngFortune();
+    }
+    return MngFortune(obj);
+}
+
+MngFortune MngFortune::create(const QVariantMap &values)
+{
+    MngFortune model;
+    model.setProperties(values);
+    if (!model.d->create()) {
+        model.d->clear();
+    }
+    return model;
+}
+
+MngFortune MngFortune::get(const QString &id)
+{
+    TMongoODMapper<MngFortuneObject> mapper;
+    return MngFortune(mapper.findByObjectId(id));
+}
+
+int MngFortune::count()
+{
+    TMongoODMapper<MngFortuneObject> mapper;
+    return mapper.findCount();
+}
+
+QList<MngFortune> MngFortune::getAll()
+{
+    return tfGetModelListByMongoCriteria<MngFortune, MngFortuneObject>(TCriteria());
+}
+
+QJsonArray MngFortune::getAllJson()
+{
+    QJsonArray array;
+    TMongoODMapper<MngFortuneObject> mapper;
+
+    if (mapper.find()) {
+        while (mapper.next()) {
+            array.append(QJsonValue(QJsonObject::fromVariantMap(MngFortune(mapper.value()).toVariantMap())));
+        }
+    }
+    return array;
+}
+
+TModelObject *MngFortune::modelData()
+{
+    return d.data();
+}
+
+const TModelObject *MngFortune::modelData() const
+{
+    return d.data();
+}

+ 51 - 0
frameworks/C++/treefrog/models/mngfortune.h

@@ -0,0 +1,51 @@
+#ifndef MNGFORTUNE_H
+#define MNGFORTUNE_H
+
+#include <QStringList>
+#include <QDateTime>
+#include <QVariant>
+#include <QSharedDataPointer>
+#include <TGlobal>
+#include <TAbstractModel>
+
+class TModelObject;
+class MngFortuneObject;
+class QJsonArray;
+
+
+class T_MODEL_EXPORT MngFortune : public TAbstractModel
+{
+public:
+    MngFortune();
+    MngFortune(const MngFortune &other);
+    MngFortune(const MngFortuneObject &object);
+    ~MngFortune();
+
+    int id() const;
+    QString message() const;
+    void setMessage(const QString &message);
+    MngFortune &operator=(const MngFortune &other);
+
+    bool create() { return TAbstractModel::create(); }
+    bool update() { return TAbstractModel::update(); }
+    bool save()   { return TAbstractModel::save(); }
+    bool remove() { return TAbstractModel::remove(); }
+
+    static MngFortune create(const QString &message);
+    static MngFortune create(const QVariantMap &values);
+    static MngFortune get(const QString &id);
+    static int count();
+    static QList<MngFortune> getAll();
+    static QJsonArray getAllJson();
+
+private:
+    QSharedDataPointer<MngFortuneObject> d;
+
+    TModelObject *modelData();
+    const TModelObject *modelData() const;
+};
+
+Q_DECLARE_METATYPE(MngFortune)
+Q_DECLARE_METATYPE(QList<MngFortune>)
+
+#endif // MNGFORTUNE_H

+ 105 - 0
frameworks/C++/treefrog/models/mngworld.cpp

@@ -0,0 +1,105 @@
+#include <TreeFrogModel>
+#include "mngworld.h"
+#include "mngworldobject.h"
+
+MngWorld::MngWorld()
+    : TAbstractModel(), d(new MngWorldObject)
+{
+    d->id = 0;
+    d->randomNumber = 0;
+}
+
+MngWorld::MngWorld(const MngWorld &other)
+    : TAbstractModel(), d(new MngWorldObject(*other.d))
+{ }
+
+MngWorld::MngWorld(const MngWorldObject &object)
+    : TAbstractModel(), d(new MngWorldObject(object))
+{ }
+
+MngWorld::~MngWorld()
+{
+    // If the reference count becomes 0,
+    // the shared data object 'MngWorldObject' is deleted.
+}
+
+int MngWorld::id() const
+{
+    return d->id;
+}
+
+int MngWorld::randomNumber() const
+{
+    return d->randomNumber;
+}
+
+void MngWorld::setRandomNumber(int randomNumber)
+{
+    d->randomNumber = randomNumber;
+}
+
+MngWorld &MngWorld::operator=(const MngWorld &other)
+{
+    d = other.d;  // increments the reference count of the data
+    return *this;
+}
+
+MngWorld MngWorld::create(int randomNumber)
+{
+    MngWorldObject obj;
+    obj.randomNumber = randomNumber;
+    if (!obj.create()) {
+        return MngWorld();
+    }
+    return MngWorld(obj);
+}
+
+MngWorld MngWorld::create(const QVariantMap &values)
+{
+    MngWorld model;
+    model.setProperties(values);
+    if (!model.d->create()) {
+        model.d->clear();
+    }
+    return model;
+}
+
+MngWorld MngWorld::get(const QString &id)
+{
+    TMongoODMapper<MngWorldObject> mapper;
+    return MngWorld(mapper.findByObjectId(id));
+}
+
+int MngWorld::count()
+{
+    TMongoODMapper<MngWorldObject> mapper;
+    return mapper.findCount();
+}
+
+QList<MngWorld> MngWorld::getAll()
+{
+    return tfGetModelListByMongoCriteria<MngWorld, MngWorldObject>(TCriteria());
+}
+
+QJsonArray MngWorld::getAllJson()
+{
+    QJsonArray array;
+    TMongoODMapper<MngWorldObject> mapper;
+
+    if (mapper.find()) {
+        while (mapper.next()) {
+            array.append(QJsonValue(QJsonObject::fromVariantMap(MngWorld(mapper.value()).toVariantMap())));
+        }
+    }
+    return array;
+}
+
+TModelObject *MngWorld::modelData()
+{
+    return d.data();
+}
+
+const TModelObject *MngWorld::modelData() const
+{
+    return d.data();
+}

+ 51 - 0
frameworks/C++/treefrog/models/mngworld.h

@@ -0,0 +1,51 @@
+#ifndef MNGWORLD_H
+#define MNGWORLD_H
+
+#include <QStringList>
+#include <QDateTime>
+#include <QVariant>
+#include <QSharedDataPointer>
+#include <TGlobal>
+#include <TAbstractModel>
+
+class TModelObject;
+class MngWorldObject;
+class QJsonArray;
+
+
+class T_MODEL_EXPORT MngWorld : public TAbstractModel
+{
+public:
+    MngWorld();
+    MngWorld(const MngWorld &other);
+    MngWorld(const MngWorldObject &object);
+    ~MngWorld();
+
+    int id() const;
+    int randomNumber() const;
+    void setRandomNumber(int randomNumber);
+    MngWorld &operator=(const MngWorld &other);
+
+    bool create() { return TAbstractModel::create(); }
+    bool update() { return TAbstractModel::update(); }
+    bool save()   { return TAbstractModel::save(); }
+    bool remove() { return TAbstractModel::remove(); }
+
+    static MngWorld create(int randomNumber);
+    static MngWorld create(const QVariantMap &values);
+    static MngWorld get(const QString &id);
+    static int count();
+    static QList<MngWorld> getAll();
+    static QJsonArray getAllJson();
+
+private:
+    QSharedDataPointer<MngWorldObject> d;
+
+    TModelObject *modelData();
+    const TModelObject *modelData() const;
+};
+
+Q_DECLARE_METATYPE(MngWorld)
+Q_DECLARE_METATYPE(QList<MngWorld>)
+
+#endif // MNGWORLD_H

+ 9 - 3
frameworks/C++/treefrog/models/models.pro

@@ -1,12 +1,12 @@
 TARGET = model
 TARGET = model
 TEMPLATE = lib
 TEMPLATE = lib
 CONFIG += shared x86_64 c++11
 CONFIG += shared x86_64 c++11
-QT += sql
+QT += sql qml
 QT -= gui
 QT -= gui
 DEFINES += TF_DLL
 DEFINES += TF_DLL
 DESTDIR = ../lib
 DESTDIR = ../lib
-INCLUDEPATH += ../helpers sqlobjects
-DEPENDPATH  += ../helpers sqlobjects
+INCLUDEPATH += ../helpers sqlobjects mongoobjects
+DEPENDPATH  += ../helpers sqlobjects mongoobjects
 LIBS += -L../lib -lhelper
 LIBS += -L../lib -lhelper
 
 
 include(../appbase.pri)
 include(../appbase.pri)
@@ -17,3 +17,9 @@ SOURCES += fortune.cpp
 HEADERS += sqlobjects/worldobject.h
 HEADERS += sqlobjects/worldobject.h
 HEADERS += world.h
 HEADERS += world.h
 SOURCES += world.cpp
 SOURCES += world.cpp
+HEADERS += mongoobjects/mngworldobject.h
+HEADERS += mngworld.h
+SOURCES += mngworld.cpp
+HEADERS += mongoobjects/mngfortuneobject.h
+HEADERS += mngfortune.h
+SOURCES += mngfortune.cpp

+ 35 - 0
frameworks/C++/treefrog/models/mongoobjects/mngfortuneobject.h

@@ -0,0 +1,35 @@
+#ifndef MNGFORTUNEOBJECT_H
+#define MNGFORTUNEOBJECT_H
+
+#include <TMongoObject>
+#include <QSharedData>
+
+
+class T_MODEL_EXPORT MngFortuneObject : public TMongoObject, public QSharedData
+{
+public:
+    QString _id;
+    int id;
+    QString message;
+
+    enum PropertyIndex {
+        _Id = 0,
+        Id,
+        Message,
+    };
+
+    virtual QString collectionName() const { return "fortune"; }
+    virtual QString objectId() const { return _id; }
+    virtual QString &objectId() { return _id; }
+
+private:
+    Q_OBJECT
+    Q_PROPERTY(QString _id READ get_id WRITE set_id)
+    T_DEFINE_PROPERTY(QString, _id)
+    Q_PROPERTY(int id READ getid WRITE setid)
+    T_DEFINE_PROPERTY(int, id)
+    Q_PROPERTY(QString message READ getmessage WRITE setmessage)
+    T_DEFINE_PROPERTY(QString, message)
+};
+
+#endif // MNGFORTUNEOBJECT_H

+ 35 - 0
frameworks/C++/treefrog/models/mongoobjects/mngworldobject.h

@@ -0,0 +1,35 @@
+#ifndef MNGWORLDOBJECT_H
+#define MNGWORLDOBJECT_H
+
+#include <TMongoObject>
+#include <QSharedData>
+
+
+class T_MODEL_EXPORT MngWorldObject : public TMongoObject, public QSharedData
+{
+public:
+    QString _id;
+    int id;
+    int randomNumber;
+
+    enum PropertyIndex {
+        _Id = 0,
+        Id,
+        RandomNumber,
+    };
+
+    virtual QString collectionName() const { return "world"; }
+    virtual QString objectId() const { return _id; }
+    virtual QString &objectId() { return _id; }
+
+private:
+    Q_OBJECT
+    Q_PROPERTY(QString _id READ get_id WRITE set_id)
+    T_DEFINE_PROPERTY(QString, _id)
+    Q_PROPERTY(int id READ getid WRITE setid)
+    T_DEFINE_PROPERTY(int, id)
+    Q_PROPERTY(int randomNumber READ getrandomNumber WRITE setrandomNumber)
+    T_DEFINE_PROPERTY(int, randomNumber)
+};
+
+#endif // MNGWORLDOBJECT_H

+ 20 - 0
frameworks/C++/treefrog/setup-mongodb.sh

@@ -0,0 +1,20 @@
+#!/bin/bash
+
+sed -i 's|HostName=.*|HostName='"$DBHOST"'|g' config/database.ini
+sed -i 's|HostName=.*|HostName='"$DBHOST"'|g' config/mongodb.ini
+sed -i 's|DriverType=.*|DriverType=QMYSQL|g' config/database.ini
+sed -i 's|MultiProcessingModule=.*|MultiProcessingModule=thread|g' config/application.ini
+
+fw_depends treefrog
+
+# 1. Generate Makefile
+qmake -r CONFIG+=release
+
+# 2. Compile applicaton
+make
+
+# 3. Clean log files
+rm -f log/*.log
+
+# 4. Start TreeFrog
+treefrog -d $TROOT

+ 20 - 0
frameworks/C++/treefrog/setup-postgres.sh

@@ -0,0 +1,20 @@
+#!/bin/bash
+
+sed -i 's|HostName=.*|HostName='"$DBHOST"'|g' config/database.ini
+sed -i 's|HostName=.*|HostName='"$DBHOST"'|g' config/mongodb.ini
+sed -i 's|DriverType=.*|DriverType=QPSQL|g' config/database.ini
+sed -i 's|MultiProcessingModule=.*|MultiProcessingModule=thread|g' config/application.ini
+
+fw_depends treefrog
+
+# 1. Generate Makefile
+qmake -r CONFIG+=release
+
+# 2. Compile applicaton
+make
+
+# 3. Clean log files
+rm -f log/*.log
+
+# 4. Start TreeFrog
+treefrog -d $TROOT

+ 5 - 4
frameworks/C++/treefrog/setup-thread.sh

@@ -1,7 +1,9 @@
 #!/bin/bash
 #!/bin/bash
 
 
 sed -i 's|HostName=.*|HostName='"$DBHOST"'|g' config/database.ini
 sed -i 's|HostName=.*|HostName='"$DBHOST"'|g' config/database.ini
-sed -i "s|MultiProcessingModule=.*|MultiProcessingModule=thread|g" config/application.ini
+sed -i 's|HostName=.*|HostName='"$DBHOST"'|g' config/mongodb.ini
+sed -i 's|DriverType=.*|DriverType=QMYSQL|g' config/database.ini
+sed -i 's|MultiProcessingModule=.*|MultiProcessingModule=thread|g' config/application.ini
 
 
 fw_depends treefrog
 fw_depends treefrog
 
 
@@ -9,11 +11,10 @@ fw_depends treefrog
 qmake -r CONFIG+=release
 qmake -r CONFIG+=release
 
 
 # 2. Compile applicaton
 # 2. Compile applicaton
-make clean
-make -j8
+make
 
 
 # 3. Clean log files
 # 3. Clean log files
 rm -f log/*.log
 rm -f log/*.log
 
 
 # 4. Start TreeFrog
 # 4. Start TreeFrog
-treefrog -d $TROOT &
+treefrog -d $TROOT

+ 4 - 3
frameworks/C++/treefrog/setup.sh

@@ -1,7 +1,9 @@
 #!/bin/bash
 #!/bin/bash
 
 
 sed -i 's|HostName=.*|HostName='"$DBHOST"'|g' config/database.ini
 sed -i 's|HostName=.*|HostName='"$DBHOST"'|g' config/database.ini
-sed -i "s|MultiProcessingModule=.*|MultiProcessingModule=hybrid|g" config/application.ini
+sed -i 's|HostName=.*|HostName='"$DBHOST"'|g' config/mongodb.ini
+sed -i 's|DriverType=.*|DriverType=QMYSQL|g' config/database.ini
+sed -i 's|MultiProcessingModule=.*|MultiProcessingModule=hybrid|g' config/application.ini
 
 
 fw_depends treefrog
 fw_depends treefrog
 
 
@@ -9,8 +11,7 @@ fw_depends treefrog
 qmake -r CONFIG+=release
 qmake -r CONFIG+=release
 
 
 # 2. Compile applicaton
 # 2. Compile applicaton
-make clean
-make -j8
+make
 
 
 # 3. Clean log files
 # 3. Clean log files
 rm -f log/*.log
 rm -f log/*.log

+ 1 - 1
frameworks/C++/treefrog/views/_src/_src.pro

@@ -1,7 +1,7 @@
 TARGET = view
 TARGET = view
 TEMPLATE = lib
 TEMPLATE = lib
 CONFIG += shared x86_64 c++11
 CONFIG += shared x86_64 c++11
-QT += network xml
+QT += network xml qml
 QT -= gui
 QT -= gui
 DEFINES += TF_DLL
 DEFINES += TF_DLL
 INCLUDEPATH += ../../helpers ../../models
 INCLUDEPATH += ../../helpers ../../models

+ 1 - 0
frameworks/C++/treefrog/views/fortune/.trim_mode

@@ -0,0 +1 @@
+2

+ 1 - 2
frameworks/C++/treefrog/views/fortune/index.erb

@@ -11,8 +11,7 @@
 <th>message</th>
 <th>message</th>
 </tr>
 </tr>
 <% tfetch(QList<Fortune>, fortuneList); %>
 <% tfetch(QList<Fortune>, fortuneList); %>
-<% for (QListIterator<Fortune> it(fortuneList); it.hasNext(); ) {
-     const Fortune &i = it.next(); %>
+<% for (auto &i : fortuneList) { %>
 <tr>
 <tr>
 <td><%= i.id() %></td>
 <td><%= i.id() %></td>
 <td><%= i.message() %></td>
 <td><%= i.message() %></td>

+ 22 - 0
frameworks/C++/treefrog/views/fortune/mindex.erb

@@ -0,0 +1,22 @@
+<!DOCTYPE HTML>
+<%#include "mngfortune.h" %>
+<html>
+<head>
+<title>Fortunes</title>
+</head>
+<body>
+<table>
+<tr>
+<th>id</th>
+<th>message</th>
+</tr>
+<% tfetch(QList<MngFortune>, fortuneList); %>
+<% for (auto &i : fortuneList) { %>
+<tr>
+<td><%= i.id() %></td>
+<td><%= i.message() %></td>
+</tr>
+<% } %>
+</table>
+</body>
+</html>

+ 1 - 0
frameworks/C++/treefrog/views/world/.trim_mode

@@ -0,0 +1 @@
+2

+ 3 - 3
toolset/setup/linux/frameworks/treefrog.sh

@@ -1,14 +1,14 @@
 #!/bin/bash
 #!/bin/bash
 
 
-TFVER=treefrog-1.10.0
+TFVER=treefrog-1.12.0
 RETCODE=$(fw_exists ${IROOT}/treefrog.installed)
 RETCODE=$(fw_exists ${IROOT}/treefrog.installed)
 [ ! "$RETCODE" == 0 ] || { \
 [ ! "$RETCODE" == 0 ] || { \
   source $IROOT/treefrog.installed
   source $IROOT/treefrog.installed
   return 0; }
   return 0; }
 
 
 sudo add-apt-repository --yes ppa:ubuntu-sdk-team/ppa
 sudo add-apt-repository --yes ppa:ubuntu-sdk-team/ppa
-sudo apt-get update
-sudo apt-get install -y qt5-qmake qt5-default qtbase5-dev qtbase5-dev-tools libqt5sql5 libqt5sql5-mysql libqt5sql5-psql g++ 
+sudo apt-get update -qq
+sudo apt-get install -y qt5-qmake qt5-default qtbase5-dev qtbase5-dev-tools libqt5sql5 libqt5sql5-mysql libqt5sql5-psql libqt5qml5 libqt5xml5 qtdeclarative5-dev g++ libjemalloc-dev gcc
 sudo add-apt-repository --remove --yes ppa:ubuntu-sdk-team/ppa
 sudo add-apt-repository --remove --yes ppa:ubuntu-sdk-team/ppa
 
 
 fw_get -O http://downloads.sourceforge.net/project/treefrog/src/$TFVER.tar.gz
 fw_get -O http://downloads.sourceforge.net/project/treefrog/src/$TFVER.tar.gz