BWAPI
|
00001 // Copyright (c) 2005 Stanford University (USA). 00002 // All rights reserved. 00003 // 00004 // This file is part of CGAL (www.cgal.org); you can redistribute it and/or 00005 // modify it under the terms of the GNU Lesser General Public License as 00006 // published by the Free Software Foundation; version 2.1 of the License. 00007 // See the file LICENSE.LGPL distributed with CGAL. 00008 // 00009 // Licensees holding a valid commercial license may use this file in 00010 // accordance with the commercial license agreement provided with the software. 00011 // 00012 // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00013 // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00014 // 00015 // $URL: svn+ssh://scm.gforge.inria.fr/svn/cgal/branches/CGAL-3.5-branch/Kinetic_data_structures/include/CGAL/Tools/Label.h $ 00016 // $Id: Label.h 39077 2007-06-13 23:19:20Z drussel $ 00017 // 00018 // 00019 // Author(s) : Daniel Russel <drussel@alumni.princeton.edu> 00020 00021 #ifndef CGAL_LABEL_H_ 00022 #define CGAL_LABEL_H_ 00023 #include <CGAL/basic.h> 00024 #include <iostream> 00025 #include <sstream> 00026 00027 CGAL_BEGIN_NAMESPACE 00028 00030 00035 template <class A_Type> 00036 class Label 00037 { 00038 protected: 00039 typedef Label<A_Type> This; 00040 int id_; 00041 00042 public: 00044 explicit Label(int i):id_(i){} 00046 Label():id_(-1) { 00047 if(0) print(); // make sure it is compiled 00048 } 00050 00051 CGAL_GETNR(This, successor, return This(id_+1)); 00052 00053 CGAL_IS(valid, return id_ >=0); 00054 00055 CGAL_GETNR(unsigned int, index, CGAL_assertion(is_valid()); return id_); 00056 00057 CGAL_COMPARISONS1(id_); 00058 00059 std::ostream& write(std::ostream &out) const 00060 { 00061 if (id_ == -1) out << "(N)"; 00062 else out << "(" << id_ << ")"; 00063 return out; 00064 } 00065 void print() const 00066 { 00067 write(std::cout); 00068 } 00070 std::string string() const 00071 { 00072 std::ostringstream os; 00073 write(os); 00074 return os.str(); 00075 } 00076 }; 00077 00078 CGAL_OUTPUT1(Label); 00079 00080 00081 CGAL_END_NAMESPACE 00082 #endif