summaryrefslogtreecommitdiff
path: root/project2/common/cache.h
blob: 0806c6f70e7438a319e5132f07abb0d84bf50d19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef CACHE_H
#define CACHE_H

#include "sourceObject.h"
#include "presenter.h"
#include "iHaveParameters.h"
#include "rowSet.h"

class RowSet;
class RowState;
typedef boost::intrusive_ptr<const RowSet> RowSetCPtr;

class Cache : public IHaveParameters, public SourceObject {
	public:
		Cache(ScriptNodePtr p);

		bool checkAndExecute(ExecContext *, const Glib::ustring &, const Glib::ustring &, const IHaveParameters *, const RowProcessorCallback &);
		virtual RowSetPresenterPtr openFor(ExecContext *, const Glib::ustring &, const Glib::ustring &, const IHaveParameters *) = 0;
		virtual void save(ExecContext *, const Glib::ustring &, const Glib::ustring &, const IHaveParameters *) = 0;
		virtual void discard(ExecContext *, const Glib::ustring &, const Glib::ustring &, const IHaveParameters *) = 0;

	protected:
		virtual RowSetCPtr getCachedRowSet(ExecContext *, const Glib::ustring &, const Glib::ustring &, const IHaveParameters *) const = 0;
		typedef boost::function<void (const std::string &, const VariableType &)> KeyApplier;
		void applyKeys(ExecContext * ec, const KeyApplier & f, const IHaveParameters * ps) const;
		const bool inherit;
};
typedef boost::intrusive_ptr<Cache> CachePtr;

#endif