summaryrefslogtreecommitdiff
path: root/project2/presenter.h
blob: a4c0a00e5ddd6a598e43cd7cabe78ee774a7db36 (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef PRESENTER_H
#define PRESENTER_H

#include <boost/intrusive_ptr.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
#include <glibmm/ustring.h>
#include "view.h"
#include "paramChecker.h"
#include "xmlObjectLoader.h"

class Presenter : public virtual IntrusivePtrBase {
	public:
		Presenter();
		virtual ~Presenter() = 0;

		virtual void declareNamespace(const Glib::ustring & prefix, const Glib::ustring & ns) const = 0;
		virtual void pushSub(const Glib::ustring & name) const;
		virtual void pushSub(const Glib::ustring & name, const Glib::ustring & ns) const = 0;
		virtual void setNamespace(const Glib::ustring & prefix, const Glib::ustring & ns) const = 0;
		virtual void addAttr(const Glib::ustring & name, const VariableType & value) const;
		virtual void addAttr(const Glib::ustring & name, const Glib::ustring & ns, const VariableType & value) const;
		virtual void addField(const Glib::ustring & name, const VariableType & value) const;
		virtual void addField(const Glib::ustring & name, const Glib::ustring & ns, const VariableType & value) const;
		virtual void addText(const VariableType & value) const = 0;
		virtual void popSub() const = 0;
};

class ContentPresenter : public Presenter {
	public:
		ContentPresenter(const Glib::ustring & contentType);
		const Glib::ustring contentType;
};

typedef boost::intrusive_ptr<const Presenter> PresenterCPtr;
typedef boost::intrusive_ptr<Presenter> PresenterPtr;

/// Base class to implement presenter modules
class PresenterLoader : public ComponentLoader {
	public:
		virtual PresenterPtr createFrom(const xmlpp::Element * e) const = 0;
};

/// Helper implemention for specific presenters
template <class PresenterType>
class PresenterLoaderImpl : public PresenterLoader {
	public:
		virtual PresenterPtr createFrom(const xmlpp::Element * e) const
		{
			return new PresenterType(e);
		}
};

#endif