diff options
Diffstat (limited to 'project2/common/aggregates/count.cpp')
-rw-r--r-- | project2/common/aggregates/count.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/project2/common/aggregates/count.cpp b/project2/common/aggregates/count.cpp new file mode 100644 index 0000000..9bdb47c --- /dev/null +++ b/project2/common/aggregates/count.cpp @@ -0,0 +1,28 @@ +#include "../aggregate.h" + +class Count : public ValueAggregate { + public: + Count(ScriptNodePtr s) : + ValueAggregate(s), + c(0) + { + } + void reset() const + { + c = 0; + } + void pushValue(const VariableType &) const + { + c += 1; + } + VariableType resultValue() const + { + return c; + } + private: + mutable int c; +}; + +DECLARE_LOADER("count", Count); + + |