summaryrefslogtreecommitdiff
path: root/project2/basics/aggregates/distinct.cpp
blob: ebac934281413822b95fc14c7d924b84f29fd1c1 (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
#include <aggregate.h>
#include <boost/foreach.hpp>

class Distinct : public SetAggregate {
	public:
		Distinct(ScriptNodePtr s) :
			SetAggregate(s)
		{
		}
		void reset() const
		{
			result.clear();
		}
		void pushValue(const VariableType & v) const
		{
			result.insert(v);
		}
		void onResultValues(const SetAggregate::UseAgg & u) const
		{
			BOOST_FOREACH(const VariableType & v, result) {
				u(v);
			}
		}
	private:
		mutable std::set<VariableType> result;
};

DECLARE_LOADER("distinct", Distinct);