summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2010-08-05 23:48:05 +0000
committerrandomdan <randomdan@localhost>2010-08-05 23:48:05 +0000
commit77954b11521564c41a8587be87cff51fe22cde0c (patch)
tree48a565bacfb18a508a75b946327fa161ddaa86d6
parentAdd ProcRows as a direct extension of FileRows (diff)
downloadproject2-77954b11521564c41a8587be87cff51fe22cde0c.tar.bz2
project2-77954b11521564c41a8587be87cff51fe22cde0c.tar.xz
project2-77954b11521564c41a8587be87cff51fe22cde0c.zip
Cache the result of default column compose
Use this cache now lots of things are const refs
-rw-r--r--project2/fileRows.cpp8
-rw-r--r--project2/fileRows.h6
-rw-r--r--project2/iterate.h7
-rw-r--r--project2/perRowValues.h2
-rw-r--r--project2/rawView.cpp6
-rw-r--r--project2/rawView.h2
-rw-r--r--project2/rowBase.h6
-rw-r--r--project2/sqlRows.cpp6
-rw-r--r--project2/sqlRows.h6
-rw-r--r--project2/view.h7
10 files changed, 31 insertions, 25 deletions
diff --git a/project2/fileRows.cpp b/project2/fileRows.cpp
index 239ad6b..855136f 100644
--- a/project2/fileRows.cpp
+++ b/project2/fileRows.cpp
@@ -26,7 +26,7 @@ _FileRows::columnCount() const
return columns.size();
}
-Glib::ustring
+const Glib::ustring &
_FileRows::getColumnName(unsigned int col) const
{
return columns[col];
@@ -93,13 +93,13 @@ _FileRows::execute() const
}
}
-Glib::ustring
+const Glib::ustring &
_FileRows::getCurrentValue(unsigned int col) const
{
return *values[col];
}
-Glib::ustring
+const Glib::ustring &
_FileRows::getCurrentValue(const Glib::ustring & id) const
{
Values::const_iterator v = values.begin();
@@ -108,7 +108,7 @@ _FileRows::getCurrentValue(const Glib::ustring & id) const
return **v;
}
}
- return "";
+ throw PerRowValues::FieldDoesNotExist();
}
void
diff --git a/project2/fileRows.h b/project2/fileRows.h
index 3e8d3c6..335e723 100644
--- a/project2/fileRows.h
+++ b/project2/fileRows.h
@@ -16,9 +16,9 @@ class _FileRows : public RowBase {
void execute() const;
unsigned int columnCount() const;
- Glib::ustring getColumnName(unsigned int col) const;
- Glib::ustring getCurrentValue(const Glib::ustring & id) const;
- Glib::ustring getCurrentValue(unsigned int col) const;
+ const Glib::ustring & getColumnName(unsigned int col) const;
+ const Glib::ustring & getCurrentValue(const Glib::ustring & id) const;
+ const Glib::ustring & getCurrentValue(unsigned int col) const;
typedef std::set<gunichar> CharSet;
const Glib::ustring path;
diff --git a/project2/iterate.h b/project2/iterate.h
index 1f6dfda..53f7050 100644
--- a/project2/iterate.h
+++ b/project2/iterate.h
@@ -20,7 +20,7 @@ class _Iterate : public virtual _SourceObject, public PerRowValues, public _NoOu
virtual ~_Iterate();
virtual void execute() const = 0;
- virtual Glib::ustring getCurrentValue(const Glib::ustring & id) const = 0;
+ virtual const Glib::ustring & getCurrentValue(const Glib::ustring & id) const = 0;
static void AddLoaders(Loaders & l, NoOutputExecutes & vs);
protected:
@@ -33,7 +33,10 @@ class _GenericIterate : public _Iterate, public Driver {
public:
_GenericIterate(const xmlpp::Element * p);
- virtual Glib::ustring getCurrentValue(const Glib::ustring & id) const { return Driver::getCurrentValue(id); }
+ virtual const Glib::ustring & getCurrentValue(const Glib::ustring & id) const
+ {
+ return Driver::getCurrentValue(id);
+ }
virtual void executeChildren() const;
virtual void execute() const;
virtual void rowReady() const;
diff --git a/project2/perRowValues.h b/project2/perRowValues.h
index cee7e07..5b5b9ab 100644
--- a/project2/perRowValues.h
+++ b/project2/perRowValues.h
@@ -21,7 +21,7 @@ class PerRowValues {
PerRowValues();
virtual ~PerRowValues() = 0;
- virtual Glib::ustring getCurrentValue(const Glib::ustring & id) const = 0;
+ virtual const Glib::ustring & getCurrentValue(const Glib::ustring & id) const = 0;
void use(const RowUser * r) const { rowUsers.insert(r); }
static const RowValuesStack & Stack() { return stack; }
diff --git a/project2/rawView.cpp b/project2/rawView.cpp
index 920a900..3fe925a 100644
--- a/project2/rawView.cpp
+++ b/project2/rawView.cpp
@@ -1,4 +1,4 @@
-#include <syslog.h>
+#include <stdexcept>
#include "rawView.h"
#include "xml.h"
#include "xmlObjectLoader.h"
@@ -12,10 +12,10 @@ _RawView::_RawView(const xmlpp::Element * p) :
{
}
-Glib::ustring
+const Glib::ustring &
_RawView::getCurrentValue(const Glib::ustring & id) const
{
- return "";
+ throw std::runtime_error("_RawView::getCurrentValue not implemented");
}
void _RawView::execute(xmlpp::Element * par) const
diff --git a/project2/rawView.h b/project2/rawView.h
index 9d7dd44..8909927 100644
--- a/project2/rawView.h
+++ b/project2/rawView.h
@@ -12,7 +12,7 @@ class _RawView : public _View {
public:
_RawView(const xmlpp::Element * p);
void execute(xmlpp::Element *) const;
- Glib::ustring getCurrentValue(const Glib::ustring & id) const;
+ const Glib::ustring & getCurrentValue(const Glib::ustring & id) const;
private:
const xmlpp::Element * copyRoot;
};
diff --git a/project2/rowBase.h b/project2/rowBase.h
index 337a72e..c9397ef 100644
--- a/project2/rowBase.h
+++ b/project2/rowBase.h
@@ -4,9 +4,9 @@
class RowBase {
public:
virtual unsigned int columnCount() const = 0;
- virtual Glib::ustring getColumnName(unsigned int col) const = 0;
- virtual Glib::ustring getCurrentValue(const Glib::ustring & id) const = 0;
- virtual Glib::ustring getCurrentValue(unsigned int col) const = 0;
+ virtual const Glib::ustring & getColumnName(unsigned int col) const = 0;
+ virtual const Glib::ustring & getCurrentValue(const Glib::ustring & id) const = 0;
+ virtual const Glib::ustring & getCurrentValue(unsigned int col) const = 0;
virtual void rowReady() const = 0;
};
diff --git a/project2/sqlRows.cpp b/project2/sqlRows.cpp
index fc4c91c..ca814f7 100644
--- a/project2/sqlRows.cpp
+++ b/project2/sqlRows.cpp
@@ -21,13 +21,13 @@ _SqlRows::~_SqlRows()
delete query;
}
-Glib::ustring
+const Glib::ustring &
_SqlRows::getCurrentValue(const Glib::ustring & id) const
{
return (*query)[id].compose();
}
-Glib::ustring
+const Glib::ustring &
_SqlRows::getCurrentValue(unsigned int col) const
{
return (*query)[col].compose();
@@ -39,7 +39,7 @@ _SqlRows::columnCount() const
return query->columnCount();
}
-Glib::ustring
+const Glib::ustring &
_SqlRows::getColumnName(unsigned int col) const
{
return (*query)[col].name;
diff --git a/project2/sqlRows.h b/project2/sqlRows.h
index fb64caf..98a20f3 100644
--- a/project2/sqlRows.h
+++ b/project2/sqlRows.h
@@ -19,9 +19,9 @@ class _SqlRows : public IHaveParameters, public RowBase {
void execute() const;
unsigned int columnCount() const;
- Glib::ustring getColumnName(unsigned int col) const;
- Glib::ustring getCurrentValue(const Glib::ustring & id) const;
- Glib::ustring getCurrentValue(unsigned int col) const;
+ const Glib::ustring & getColumnName(unsigned int col) const;
+ const Glib::ustring & getCurrentValue(const Glib::ustring & id) const;
+ const Glib::ustring & getCurrentValue(unsigned int col) const;
const std::string dataSource;
const Glib::ustring sql;
diff --git a/project2/view.h b/project2/view.h
index a5f9453..165ed12 100644
--- a/project2/view.h
+++ b/project2/view.h
@@ -19,7 +19,7 @@ class _View : public virtual _SourceObject, public PerRowValues {
_View(const xmlpp::Element * p);
virtual ~_View();
virtual void execute(xmlpp::Element *) const = 0;
- virtual Glib::ustring getCurrentValue(const Glib::ustring & id) const = 0;
+ virtual const Glib::ustring & getCurrentValue(const Glib::ustring & id) const = 0;
const Glib::ustring recordName;
static void AddLoaders(Loaders & l, Views & vs);
@@ -33,7 +33,10 @@ class _GenericView : public _View, public Driver {
public:
_GenericView(const xmlpp::Element * p);
- virtual Glib::ustring getCurrentValue(const Glib::ustring & id) const { return Driver::getCurrentValue(id); }
+ virtual const Glib::ustring & getCurrentValue(const Glib::ustring & id) const
+ {
+ return Driver::getCurrentValue(id);
+ }
virtual void execute(xmlpp::Element * e) const;
virtual void rowReady() const;
private: