summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2011-11-30 15:36:51 +0000
committerrandomdan <randomdan@localhost>2011-11-30 15:36:51 +0000
commit9cc3a10f1c16957c0cb9690b5d3501eb1dbb9348 (patch)
treee731d90ec335e40a8aa0ee9aad56307c06caeab6
parentAllow specifying different loader classes when setting up script parsers (all... (diff)
downloadproject2-9cc3a10f1c16957c0cb9690b5d3501eb1dbb9348.tar.bz2
project2-9cc3a10f1c16957c0cb9690b5d3501eb1dbb9348.tar.xz
project2-9cc3a10f1c16957c0cb9690b5d3501eb1dbb9348.zip
Add the singleton view for accessing non-rowView data
-rw-r--r--project2/common/Jamfile.jam13
-rw-r--r--project2/common/rowView.cpp2
-rw-r--r--project2/common/singleton.cpp50
3 files changed, 52 insertions, 13 deletions
diff --git a/project2/common/Jamfile.jam b/project2/common/Jamfile.jam
index 5bb0507..f08a2ff 100644
--- a/project2/common/Jamfile.jam
+++ b/project2/common/Jamfile.jam
@@ -13,18 +13,7 @@ cpp-pch pch : pch.hpp :
;
lib p2common :
pch
- appEngine.cpp dataSource.cpp environment.cpp fileStarGlibIoChannel.cpp iHaveParameters.cpp library.cpp iHaveSubTasks.cpp
- iterate.cpp paramChecker.cpp presenter.cpp logger.cpp if.cpp xmlScriptParser.cpp viewHost.cpp
- sourceObject.cpp task.cpp variables.cpp variableConvert.cpp view.cpp xmlObjectLoader.cpp exceptions.cpp cache.cpp
- sessionContainer.cpp sessionClearTask.cpp session.cpp sessionSetTask.cpp commonObjects.cpp taskHost.cpp checkHost.cpp
- rowView.cpp rowSet.cpp rowProcessor.cpp config.cpp fileStrmVarWriter.cpp noOutputExecute.cpp columns.cpp scopeObject.cpp
- transform.cpp definedColumns.cpp structExceptHandling.cpp validDateCheck.cpp memoryCache.cpp
- variables-modconfig.cpp
- variables-modlocalparam.cpp
- variables-modlookup.cpp
- variables-modparam.cpp
- variables-modsession.cpp
- variables-moduri.cpp
+ [ glob *.cpp ]
[ glob functions/*.cpp ]
../../libmisc/buffer.cpp
../../libmisc/misc.cpp
diff --git a/project2/common/rowView.cpp b/project2/common/rowView.cpp
index 6b0bbed..5e01061 100644
--- a/project2/common/rowView.cpp
+++ b/project2/common/rowView.cpp
@@ -19,7 +19,7 @@ RowView::RowView(const xmlpp::Element * p) :
{
BOOST_FOREACH(xmlpp::Node * node, p->find("columns/*")) {
if (const xmlpp::Element * elem = dynamic_cast<const xmlpp::Element *>(node)) {
- viewColumns.insert(Parameters::value_type(elem->get_name(), Variable(elem, boost::optional<Glib::ustring>())));
+ viewColumns.insert(Columns::value_type(elem->get_name(), Variable(elem, boost::optional<Glib::ustring>())));
}
}
LoaderBase loader(true);
diff --git a/project2/common/singleton.cpp b/project2/common/singleton.cpp
new file mode 100644
index 0000000..eb78a48
--- /dev/null
+++ b/project2/common/singleton.cpp
@@ -0,0 +1,50 @@
+#include <pch.hpp>
+#include <libxml++/nodes/element.h>
+#include "view.h"
+#include "iHaveParameters.h"
+#include "presenter.h"
+#include "scopeObject.h"
+
+class Singleton : public View {
+ public:
+ Singleton(const xmlpp::Element * p) :
+ SourceObject(p),
+ View(p),
+ rootName(p, "rootname") {
+ BOOST_FOREACH(xmlpp::Node * node, p->find("columns/*")) {
+ if (const xmlpp::Element * elem = dynamic_cast<const xmlpp::Element *>(node)) {
+ viewColumns.insert(Columns::value_type(elem->get_name(), Variable(elem, boost::optional<Glib::ustring>())));
+ }
+ }
+ LoaderBase loader(true);
+ loader.supportedStorers.insert(Storer::into<ElementLoader>(&subViews));
+ loader.collectAll(p, true, IgnoreUnsupported);
+ }
+ void execute(const MultiRowSetPresenter * p) const
+ {
+ presenter = p;
+ presenter->addNewRowSet(rootName());
+ ScopeObject pres(boost::bind(&MultiRowSetPresenter::finishRowSet, p));
+ BOOST_FOREACH(const Columns::value_type & col, viewColumns) {
+ p->addNamedValue(col.first, col.second);
+ }
+ }
+
+ const Variable rootName;
+ private:
+ void executeChildren() const
+ {
+ BOOST_FOREACH(const SubViews::value_type & sq, subViews) {
+ sq->execute(presenter);
+ }
+ }
+
+ typedef std::map<Glib::ustring, Variable> Columns;
+ Columns viewColumns;
+
+ typedef ANONSTORAGEOF(View) SubViews;
+ SubViews subViews;
+ mutable const MultiRowSetPresenter * presenter;
+};
+DECLARE_LOADER("singleton", Singleton);
+