00001 /* $Id: iterator.hpp 52869 2012-02-03 20:18:33Z shadowmaster $ */ 00002 /* 00003 Copyright (C) 2011 - 2012 by Mark de Wever <koraq@xs4all.nl> 00004 Part of the Battle for Wesnoth Project http://www.wesnoth.org/ 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY. 00012 00013 See the COPYING file for more details. 00014 */ 00015 00016 /** 00017 * @file 00018 * Contains the base iterator class for the gui2 widgets. 00019 * 00020 * For more information @see @ref gui2_iterator for more information. 00021 */ 00022 00023 #ifndef GUI_WIDGETS_AUXILIARY_ITERATOR_ITERATOR_HPP_INCLUDED 00024 #define GUI_WIDGETS_AUXILIARY_ITERATOR_ITERATOR_HPP_INCLUDED 00025 00026 #include "gui/auxiliary/iterator/policy_order.hpp" 00027 00028 namespace gui2 { 00029 00030 namespace iterator { 00031 00032 /** 00033 * The iterator class. 00034 * 00035 * @see @ref gui2_iterator_iterator for more information. 00036 */ 00037 template<class order> 00038 class titerator 00039 : private order 00040 , private boost::noncopyable 00041 { 00042 public: 00043 00044 /** 00045 * Contstructor. 00046 * 00047 * @param root The widget where to start the iteration. 00048 */ 00049 titerator(twidget& root) 00050 : order(root) 00051 { 00052 } 00053 00054 /** 00055 * Has the iterator reached the end? 00056 * 00057 * @returns The status. 00058 * @retval [true] At the end. 00059 * @retval [false] Not at the end. 00060 */ 00061 bool at_end() const { return order::at_end(); } 00062 00063 /** 00064 * Visit the next widget. 00065 * 00066 * @pre @ref at_end() == false 00067 * 00068 * @throws @ref trange_error upon pre condition violation. 00069 * 00070 * @returns Whether the next widget can be safely 00071 * deferred. 00072 */ 00073 bool next() { return order::next(); } 00074 00075 /** See @ref next. */ 00076 titerator<order>& operator++() 00077 { 00078 order::next(); 00079 return *this; 00080 } 00081 00082 /** 00083 * Returns the current widget. 00084 * 00085 * @returns The current widget. 00086 */ 00087 twidget& operator*() { return order::operator*(); } 00088 00089 /** See @ref operator*. */ 00090 twidget* operator->() 00091 { 00092 return &(operator*()); 00093 } 00094 }; 00095 00096 } // namespace iterator 00097 00098 } // namespace gui2 00099 00100 #endif 00101
| Generated by doxygen 1.7.1 on Fri May 25 2012 01:02:54 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |