dbus-cxx logo
accumulators.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2009,2010 by Rick L. Vinyard, Jr. *
3  * rvinyard@cs.nmsu.edu *
4  * *
5  * This file is part of the dbus-cxx library. *
6  * *
7  * The dbus-cxx library is free software; you can redistribute it and/or *
8  * modify it under the terms of the GNU General Public License *
9  * version 3 as published by the Free Software Foundation. *
10  * *
11  * The dbus-cxx library is distributed in the hope that it will be *
12  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty *
13  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with this software. If not see <http://www.gnu.org/licenses/>. *
18  ***************************************************************************/
19 #include <dbus-cxx/enums.h>
20 
21 #ifndef DBUSCXX_ACCUMULATORS_H
22 #define DBUSCXX_ACCUMULATORS_H
23 
24 namespace DBus
25 {
32 
38  typedef bool result_type;
39 
40  template <typename T_iterator>
41  result_type operator()( T_iterator first, T_iterator last ) const {
42  bool result = true;
43  while ( first != last ) {
44  result = result and( *first );
45  }
46  return result;
47  }
48  };
49 
55  typedef bool result_type;
56 
57  template <typename T_iterator>
58  result_type operator()( T_iterator first, T_iterator last ) const {
59  while ( first != last ) {
60  if ( *first ) return true;
61  ++first;
62  }
63  return false;
64  }
65  };
66 
78 
79  template <typename T_iterator>
80  result_type operator()( T_iterator first, T_iterator last ) const {
81  HandlerResult retval = NOT_HANDLED;
82  while ( first != last ) {
83  switch ( *first )
84  {
85  case HANDLED:
86  return HANDLED;
88  retval = HANDLER_NEEDS_MEMORY;
89  // no break because we'll slide through to the next case
90  case NOT_HANDLED:
91  ++first;
92  }
93  }
94  return retval;
95  }
96  };
97 
109 
110  template <typename T_iterator>
111  result_type operator()( T_iterator first, T_iterator last ) const {
112  FilterResult retval = DONT_FILTER;
113  while ( first != last ) {
114  switch ( *first )
115  {
116  case FILTER:
117  return FILTER;
118  case FILTER_NEEDS_MEMORY:
119  retval = FILTER_NEEDS_MEMORY;
120  // no break because we'll slide through to the next case
121  case DONT_FILTER:
122  ++first;
123  }
124  }
125  return retval;
126  }
127  };
128 
134  typedef bool result_type;
135 
136  template <typename T_iterator>
137  result_type operator()( T_iterator first, T_iterator last ) const {
138  bool result = false;
139  while ( first != last ) {
140  result = result or( *first );
141  ++first;
142  }
143  return result;
144  }
145  };
146 
148 
149 }
150 
151 #endif
This accumulator will try each slot and stop when the first slot returns HANDLED. ...
Definition: accumulators.h:76
bool result_type
Definition: accumulators.h:134
bool result_type
Definition: accumulators.h:55
HandlerResult
Definition: enums.h:87
Definition: enums.h:98
FilterResult
Definition: enums.h:94
Definition: accumulators.h:24
This accumulator will try each slot and stop when the first slot returns FILTER.
Definition: accumulators.h:107
Definition: enums.h:90
This accumulator starts with a presumption of false and checks to see if any result returned true...
Definition: accumulators.h:133
result_type operator()(T_iterator first, T_iterator last) const
Definition: accumulators.h:41
This accumulator starts with a presumption of true and checks to see if any result returned false...
Definition: accumulators.h:37
Definition: enums.h:96
This accumulator will interrupt on the first slot that returns true.
Definition: accumulators.h:54
result_type operator()(T_iterator first, T_iterator last) const
Definition: accumulators.h:58
Definition: enums.h:97
FilterResult result_type
Definition: accumulators.h:108
result_type operator()(T_iterator first, T_iterator last) const
Definition: accumulators.h:111
HandlerResult result_type
Definition: accumulators.h:77
bool result_type
Definition: accumulators.h:38
result_type operator()(T_iterator first, T_iterator last) const
Definition: accumulators.h:80
Definition: enums.h:89
result_type operator()(T_iterator first, T_iterator last) const
Definition: accumulators.h:137
Definition: enums.h:91

Generated on Sun Mar 19 2017 14:54:26 for dbus-cxx by doxygen 1.8.8