Explorar o código

poco C++ framework added

Robert Ayrapetyan %!s(int64=9) %!d(string=hai) anos
pai
achega
870e00fcb7

+ 1 - 0
.travis.yml

@@ -32,6 +32,7 @@ env:
     - "TESTDIR=C++/ulib"
     - "TESTDIR=C++/wt"
     - "TESTDIR=C++/ffead-cpp"
+    - "TESTDIR=C++/poco"
     - "TESTDIR=Clojure/compojure"
     - "TESTDIR=Clojure/http-kit"
     - "TESTDIR=Clojure/luminus"

+ 78 - 0
frameworks/C++/poco/benchmark.cpp

@@ -0,0 +1,78 @@
+#include <Poco/Net/ServerSocket.h>
+#include <Poco/Net/HTTPServer.h>
+#include <Poco/Net/HTTPRequestHandler.h>
+#include <Poco/Net/HTTPRequestHandlerFactory.h>
+#include <Poco/Net/HTTPResponse.h>
+#include <Poco/Net/HTTPServerRequest.h>
+#include <Poco/Net/HTTPServerResponse.h>
+#include <Poco/Util/ServerApplication.h>
+
+#include <iostream>
+#include <string>
+#include <vector>
+
+#define PLAIN_URL_PATH       "/plaintext"
+#define PLAIN_CONTENT_TYPE   "text/plain"
+#define RES_BODY             "Hello, World!"
+#define SERVER_NAME          "poco"
+
+using namespace Poco::Net;
+using namespace Poco::Util;
+using namespace std;
+
+class MyRequestHandler : public HTTPRequestHandler {
+public:
+    virtual void handleRequest(HTTPServerRequest &req, HTTPServerResponse &resp) {
+        resp.setStatusAndReason(HTTPResponse::HTTP_OK, "OK");
+        resp.setContentType(PLAIN_CONTENT_TYPE);
+        resp.add("Server", SERVER_NAME);
+        resp.sendBuffer(RES_BODY, sizeof(RES_BODY)-1);
+        return;
+    }
+};
+
+class NotFoundRequestHandler : public HTTPRequestHandler {
+public:
+    virtual void handleRequest(HTTPServerRequest &req, HTTPServerResponse &resp) {
+        resp.setStatusAndReason(HTTPResponse::HTTP_NOT_FOUND, "NOT_FOUND");
+        resp.setContentType(PLAIN_CONTENT_TYPE);
+        resp.add("Server", SERVER_NAME);
+        resp.sendBuffer("", 0);
+        return;
+    }
+};
+
+class MyRequestHandlerFactory : public HTTPRequestHandlerFactory {
+public:
+    virtual HTTPRequestHandler* createRequestHandler(const HTTPServerRequest &req) {
+        if (req.getMethod() == "GET" && req.getURI() == PLAIN_URL_PATH)
+            return new MyRequestHandler;
+        else
+            return new NotFoundRequestHandler;
+    }
+};
+
+class MyServerApp : public ServerApplication {
+protected:
+    int main(const vector<string> &args) {
+        HTTPServerParams* hsp = new HTTPServerParams;
+        hsp->setMaxThreads(stoi(args[1]));
+        hsp->setKeepAlive(true);
+        HTTPServer s(new MyRequestHandlerFactory, ServerSocket(stoi(args[0]), 4000), hsp);
+        s.start();
+        waitForTerminationRequest();
+        s.stop();
+        return Application::EXIT_OK;
+    }
+};
+
+int main(int argc, char** argv) {
+    if (argc != 3) {
+        std::cerr << "Usage: " << argv[0] << " port nthreads" << std::endl;
+        return 1;
+    }
+    
+    MyServerApp app;
+    return app.run(argc, argv);
+}
+

+ 24 - 0
frameworks/C++/poco/benchmark_config.json

@@ -0,0 +1,24 @@
+{
+  "framework": "poco",
+  "tests": [{
+    "default": {
+      "setup_file": "setup",
+      "plaintext_url": "/plaintext",
+      "port": 8080,
+      "approach": "Realistic",
+      "classification": "Platform",
+      "database": "none",
+      "framework": "POCO",
+      "language": "C++",
+      "orm": "Raw",
+      "platform": "POCO",
+      "webserver": "poco",
+      "os": "Linux",
+      "database_os": "Linux",
+      "display_name": "POCO",
+      "notes": "",
+      "versus": ""
+    }
+  }]
+}
+

+ 7 - 0
frameworks/C++/poco/setup.sh

@@ -0,0 +1,7 @@
+#!/bin/bash
+
+fw_depends poco
+
+g++-4.8 -O3 -DNDEBUG -std=c++0x -o poco benchmark.cpp -I$POCO_HOME/Foundation/include -I$POCO_HOME/Util/include -I$POCO_HOME/Net/include -L$POCO_HOME/lib/Linux/x86_64 -lPocoNet -lPocoUtil -lPocoFoundation -lPocoXML -lPocoJSON
+./poco 8080 $MAX_THREADS
+

+ 25 - 0
toolset/setup/linux/frameworks/poco.sh

@@ -0,0 +1,25 @@
+#!/bin/bash
+
+RETCODE=$(fw_exists ${IROOT}/poco.installed)
+[ ! "$RETCODE" == 0 ] || { \
+  source $IROOT/poco.installed
+  return 0; }
+
+VERSION=1.6.1
+POCO_HOME=$IROOT/poco_$VERSION
+
+fw_get -o poco_$VERSION.tar.gz http://pocoproject.org/releases/poco-$VERSION/poco-$VERSION-all.tar.gz
+fw_untar poco_$VERSION.tar.gz
+
+cp -R poco-$VERSION-all/ $POCO_HOME
+rm -rf poco-$VERSION-all/
+
+cd $POCO_HOME
+./configure --no-tests --no-samples
+make PageCompiler-libexec XML-libexec JSON-libexec
+
+echo "export POCO_HOME=${POCO_HOME}" > $IROOT/poco.installed
+echo "export LD_LIBRARY_PATH=$POCO_HOME/lib/Linux/x86_64" >> $IROOT/poco.installed 
+
+source $IROOT/poco.installed
+