//============================================================================== // // DInc - the (auto) increment class in OFC // // Copyright (C) 2003 Dick van Oudheusden // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public // License as published by the Free Software Foundation; either // version 2 of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // // You should have received a copy of the GNU General Public // License along with this program; if not, write to the Free // Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // //============================================================================== // // $Date: 2003/10/07 18:10:40 $ $Revision: 1.1 $ // //============================================================================== #include "DInc.h" #include /// /// #include "ofc/config.h" /// /// /// // The inc class is used to test collections. It stores an integer, that /// // is automaticly increased when a new instance is created. The integer can be /// // printed and returned. /// /// @interface DInc : Object /// { /// @private /// int _number; // the test number /// } /// @implementation DInc static int _counter = 1; //// Constructors // // Initialise to the next test object // // @return the object // - (DInc *) init { [self init :_counter++]; return self; } // // Initialise to a fixed test object // // @param number the fixed number // // @return the object // - (DInc *) init :(int) number { [super init]; _number = number; return self; } //// Main methods // // Return the number in the test object // // @return the number // - (int) number { return _number; } // // Print the contents of the test object (followed by a ,) // // @return the object // - (DInc *) print { fprintf(stdout, "%d,", _number); return self; } // // Print the contents of the test object (followed by a \n) // // @return the object // - (DInc *) println { fprintf(stdout, "%d\n", _number); return self; } //// Class methods // // Reset the test object counter to 1 // + (void) reset { _counter = 1; } @end /*==========================================================================*/