SumAgg.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 namespace iv
4 {
5 
8 template< class Int >
9 class SumAgg
10 {
11 public:
12  SumAgg();
13  SumAgg( Int aggregated, int size );
14 
15  SumAgg< Int > Insert( Int value ) const;
16  SumAgg< Int > Remove( Int value ) const;
17 
18  Int Aggregated() const;
19  int Size() const;
20 
21 private:
22  Int current;
23  int count;
24 };
25 
28 template< class Int >
29 struct StringIO< SumAgg< Int > >
30 {
31  SumAgg< Int > Read( const char * source, Context const * context ) const
32  {
33  return SumAgg< Int >();
34  }
35 
36  std::string Write( SumAgg< Int > const & value, Context const * context ) const
37  {
38  return StringIO< Int >().Write( value.Aggregated(), context ) + std::string( "[sum of" ) + StringIO< int >().Write( value.Size(), context ) + std::string( "]" );
39  }
40 };
41 
42 }
43 
44 #include "SumAgg.inl"