summaryrefslogtreecommitdiff
path: root/project2/common/columns.h
blob: d3e2c9720efe69c3acf2c6f2af99801eebbbef25 (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
#ifndef COLUMNS_H
#define COLUMNS_H

#include "variables.h"
#include <boost/multi_index_container.hpp>
#include <boost/multi_index/member.hpp>
#include <boost/multi_index/ordered_index.hpp>

class Column : public IntrusivePtrBase {
	public:
		Column(unsigned int idx, ScriptNodePtr p);
		Column(unsigned int i, const Glib::ustring & n, const Variable & v = Variable(Null()));
		virtual ~Column() = default;

		static Column * make(unsigned int idx, ScriptNodePtr p);

		const unsigned int idx;
		const Glib::ustring name;
		const std::string key;
		const Variable defValue;
};

struct byColIdx {};
struct byColName {};
typedef boost::intrusive_ptr<Column> ColumnPtr;
typedef boost::multi_index::multi_index_container<ColumnPtr,
				boost::multi_index::indexed_by<
				boost::multi_index::ordered_unique<
				boost::multi_index::tag<byColName>, BOOST_MULTI_INDEX_MEMBER(Column, const std::string, key)>,
				boost::multi_index::ordered_unique<
				boost::multi_index::tag<byColIdx>,  BOOST_MULTI_INDEX_MEMBER(Column, const unsigned int, idx)>
				> > Columns;

#endif