roller.cpp

Go to the documentation of this file.
00001 #ifndef ROLLER_IMPLEMENTATION_FILE
00002 #define ROLLER_IMPLEMENTATION_FILE
00003 
00004 /*****************************************************************************\
00005 *                                                                             *
00006 *  Name   : roller                                                            *
00007 *  Author : Chris Koeritz                                                     *
00008 *                                                                             *
00009 *******************************************************************************
00010 * Copyright (c) 1996-$now By Author.  This program is free software; you can  *
00011 * redistribute it and/or modify it under the terms of the GNU General Public  *
00012 * License as published by the Free Software Foundation; either version 2 of   *
00013 * the License or (at your option) any later version.  This is online at:      *
00014 *     http://www.fsf.org/copyleft/gpl.html                                    *
00015 * Please send any updates to: fred@gruntose.com                               *
00016 \*****************************************************************************/
00017 
00018 #include "roller.h"
00019 
00020 #ifndef ROLLER_CLASS_IMPLEMENTATION
00021 #define ROLLER_CLASS_IMPLEMENTATION
00022 
00023 template <class contents>
00024 roller<contents>::roller(contents start, contents end)
00025 : _current_id(start), _start_of_range(start), _end_of_range(end) {}
00026 
00027 template <class contents>
00028 void roller<contents>::set_current(contents new_current)
00029 {
00030   _current_id = new_current;
00031   if (_current_id >= _end_of_range) _current_id = _start_of_range;
00032 }
00033 
00034 template <class contents> roller<contents>::~roller() {}
00035 
00036 template <class contents> contents roller<contents>::current() const
00037 { return _current_id; }
00038 
00039 template <class contents> contents roller<contents>::next_id()
00040 {
00041   contents to_return = _current_id;
00042   if (to_return == _end_of_range) {
00043     // somehow the id to return is at the end of the range.  this probably
00044     // means the end of range condition wasn't detected last time due to an
00045     // error in the parameters or the operation of == or ++ in the templated
00046     // class.
00047     _current_id = _start_of_range;
00048     to_return = _current_id;
00049   }
00050   _current_id++;  // next id.
00051   if (_current_id == _end_of_range) _current_id = _start_of_range;
00052     // reset the current position when hits the end of the range.
00053   return to_return;
00054 }
00055 
00056 #endif
00057 
00058 
00059 #endif //ROLLER_IMPLEMENTATION_FILE
00060 

Generated on Fri Nov 21 04:29:50 2008 for HOOPLE Libraries by  doxygen 1.5.1