From 05b49fd2deaaed7857e0b1cfdfb051b75ecef095 Mon Sep 17 00:00:00 2001 From: randomdan Date: Wed, 30 Nov 2011 15:36:51 +0000 Subject: Add the singleton view for accessing non-rowView data --- project2/common/Jamfile.jam | 13 +---------- project2/common/rowView.cpp | 2 +- project2/common/singleton.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 13 deletions(-) create mode 100644 project2/common/singleton.cpp 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(node)) { - viewColumns.insert(Parameters::value_type(elem->get_name(), Variable(elem, boost::optional()))); + viewColumns.insert(Columns::value_type(elem->get_name(), Variable(elem, boost::optional()))); } } 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 +#include +#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(node)) { + viewColumns.insert(Columns::value_type(elem->get_name(), Variable(elem, boost::optional()))); + } + } + LoaderBase loader(true); + loader.supportedStorers.insert(Storer::into(&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 Columns; + Columns viewColumns; + + typedef ANONSTORAGEOF(View) SubViews; + SubViews subViews; + mutable const MultiRowSetPresenter * presenter; +}; +DECLARE_LOADER("singleton", Singleton); + -- cgit v1.2.3