2 // Tizen Web Device API
3 // Copyright (c) 2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
17 #ifndef __TIZEN_TIZEN_FILTER_ITERATOR_H__
18 #define __TIZEN_TIZEN_FILTER_ITERATOR_H__
20 #include "AbstractFilter.h"
21 #include "AttributeFilter.h"
22 #include "AttributeRangeFilter.h"
23 #include "CompositeFilter.h"
30 enum FilterIteratorState {
33 FIS_ATTRIBUTE_RANGE_FILTER,
42 FilterIterator(AbstractFilterPtr filter);
44 FilterIteratorState getState() const;
45 AbstractFilterPtr operator*() const;
46 AbstractFilterPtr getCurrentFilter() const;
49 bool isInsideCompositeFilter() const;
52 * Returns null shared pointer if we are not inside composite filter
54 CompositeFilterPtr getCurrentCompositeFilter() const;
57 * Get index of current sub filter (inside composite filter)
58 * Returns 0 if we are not inside composite filter.
60 int getCurrentCompositeSubFilterIndex() const;
63 * Return true if current sub filter is the last one in current composite filter
64 * Returns false if we are not inside composite filter.
66 bool isLastCompositeSubFilter() const;
73 void goToNext(AbstractFilterPtr next);
74 void goToNextInCurCompositeFilter();
76 AbstractFilterPtr m_root_filter;
77 FilterIteratorState m_current_state;
78 AbstractFilterPtr m_current_filter;
80 struct CompositeIterState {
81 CompositeIterState() :
82 cur_sub_filter_index(0)
86 CompositeIterState(const CompositeIterState& other) :
88 cur_sub_filter_index(other.cur_sub_filter_index)
92 CompositeFilterPtr filter;
93 int cur_sub_filter_index;
96 std::stack<CompositeIterState> m_composite_stack;
102 #endif // __TIZEN_TIZEN_FILTER_ITERATOR_H__