summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2014-03-15 13:18:17 +0000
committerrandomdan <randomdan@localhost>2014-03-15 13:18:17 +0000
commit094b3216c8c0c30de004af32e2ad9af12fce4adb (patch)
tree574dbb941b56508e213661ba273e805415714b13
parentBuild ICE modules in parallel (diff)
downloadproject2-094b3216c8c0c30de004af32e2ad9af12fce4adb.tar.bz2
project2-094b3216c8c0c30de004af32e2ad9af12fce4adb.tar.xz
project2-094b3216c8c0c30de004af32e2ad9af12fce4adb.zip
Add a stream presenter, allows output of any source stream
Propergate stream exceptions back to presenters Expose the ICE communicator from iceDataSource
-rw-r--r--project2/cgi/cgiAppEngine.cpp1
-rw-r--r--project2/ice/iceDataSource.h1
-rw-r--r--project2/streams/streamPresenter.cpp72
3 files changed, 74 insertions, 0 deletions
diff --git a/project2/cgi/cgiAppEngine.cpp b/project2/cgi/cgiAppEngine.cpp
index 872f896..234cbeb 100644
--- a/project2/cgi/cgiAppEngine.cpp
+++ b/project2/cgi/cgiAppEngine.cpp
@@ -125,6 +125,7 @@ finalTransformSource(TransformSourcePtr ts)
void
CgiApplicationEngine::process(std::ostream & IO, CgiRequestContext * crc) const
{
+ IO.exceptions(std::ifstream::failbit | std::ifstream::badbit);
bool sessionEmpty = crc->getSession()->Empty();
crc->startTime = boost::date_time::microsec_clock<boost::posix_time::ptime>::universal_time();
bool triedNotFound = false;
diff --git a/project2/ice/iceDataSource.h b/project2/ice/iceDataSource.h
index b145fe5..47af13b 100644
--- a/project2/ice/iceDataSource.h
+++ b/project2/ice/iceDataSource.h
@@ -31,6 +31,7 @@ class IceDataSource : public DataSource {
return Interface::checkedCast(existingProxy->second);
}
+ const Ice::CommunicatorPtr GetCommunicator() const { return ic; }
static void FinaliseLoad();
private:
diff --git a/project2/streams/streamPresenter.cpp b/project2/streams/streamPresenter.cpp
new file mode 100644
index 0000000..3dde21c
--- /dev/null
+++ b/project2/streams/streamPresenter.cpp
@@ -0,0 +1,72 @@
+#include <pch.hpp>
+#include <presenter.h>
+#include <transform.h>
+#include <stream.h>
+
+class StreamPresenter : public Presenter, public WritableContent, public SourceOf<WritableContent> {
+ public:
+ StreamPresenter(ScriptNodePtr e, ObjectSource os, ExecContext * ) :
+ Presenter(os),
+ contentType(e, "contenttype", "application/octet-stream")
+ {
+ e->script->loader.addLoadTarget(e, Storer::into<ElementLoader>(&stream));
+ }
+
+ WritableContent::Class getContentClass() const
+ {
+ return ClassData;
+ }
+
+ Glib::ustring getContentType() const
+ {
+ return contentType(NULL);
+ }
+
+ static size_t write(std::ostream * os, const char * data, size_t len)
+ {
+ os->write(data, len);
+ return len;
+ }
+
+ void writeTo(std::ostream & os, const std::string&, ExecContext * ec) const
+ {
+ if (stream) {
+ stream->runStream(boost::bind(&StreamPresenter::write, &os, _1, _2), ec);
+ }
+ }
+
+ void addNewArray(const Glib::ustring&, bool) const
+ {
+ }
+
+ void finishArray(bool) const
+ {
+ }
+
+ void init(ExecContext*)
+ {
+ }
+
+ void pushSub(const Glib::ustring&, const Glib::ustring&) const
+ {
+ }
+
+ void addText(const VariableType&) const
+ {
+ }
+
+ void popSub() const
+ {
+ }
+
+ operator const WritableContent * () const
+ {
+ return this;
+ }
+
+ private:
+ Variable contentType;
+ StreamPtr stream;
+};
+
+DECLARE_GENERIC_LOADER("stream", PresenterLoader, StreamPresenter)