Generated on Mon Aug 25 11:35:44 2008 for Gecode by doxygen 1.5.6

symbol.icc

Go to the documentation of this file.
00001 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
00002 /*
00003  *  Main authors:
00004  *     Guido Tack <tack@gecode.org>
00005  *
00006  *  Contributing authors:
00007  *     Christian Schulte <schulte@gecode.org>
00008  *
00009  *  Copyright:
00010  *     Guido Tack, 2007
00011  *     Christian Schulte, 2007
00012  *
00013  *  Last modified:
00014  *     $Date: 2008-07-11 09:32:27 +0200 (Fri, 11 Jul 2008) $ by $Author: tack $
00015  *     $Revision: 7289 $
00016  *
00017  *  This file is part of Gecode, the generic constraint
00018  *  development environment:
00019  *     http://www.gecode.org
00020  *
00021  *  Permission is hereby granted, free of charge, to any person obtaining
00022  *  a copy of this software and associated documentation files (the
00023  *  "Software"), to deal in the Software without restriction, including
00024  *  without limitation the rights to use, copy, modify, merge, publish,
00025  *  distribute, sublicense, and/or sell copies of the Software, and to
00026  *  permit persons to whom the Software is furnished to do so, subject to
00027  *  the following conditions:
00028  *
00029  *  The above copyright notice and this permission notice shall be
00030  *  included in all copies or substantial portions of the Software.
00031  *
00032  *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00033  *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00034  *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00035  *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
00036  *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
00037  *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00038  *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00039  *
00040  */
00041 
00042 #include <iostream>
00043 
00044 namespace Gecode { namespace Support {
00045   
00049   class GECODE_SUPPORT_EXPORT Symbol {
00050   private:
00051     
00055     class SO {
00056     public:
00058       static char* strdup(const char* s);
00060       unsigned int use_cnt;
00062       bool cancel(void);
00064       void subscribe(void);
00065 
00067       char* s;
00069       bool own;
00070 
00072       SO(const char* s0, bool copy);
00074       void append(SO* s0);
00076       bool eq(const SO* other) const;
00078       bool eq(const char* other) const;
00080       unsigned int size(void) const;
00082       int hash(int m) const;
00084       std::ostream& print(std::ostream& os) const;
00086       static void* operator new(size_t s);
00088       static void  operator delete(void* p);
00089     };
00090 
00092     SO* so;
00093   public:
00095     Symbol(void);
00097     Symbol(const char* s0, bool copy = false);
00099     Symbol(int i);
00101     Symbol(unsigned int i);
00103     Symbol(const Symbol& s0);
00105     const Symbol& operator=(const Symbol& s0);
00107     bool operator==(const Symbol& s0) const;
00109     bool operator==(const char* s0) const;
00111     bool empty(void) const;
00113     Symbol copy(void) const;
00115     Symbol& operator+=(const Symbol& s);
00117     int hash(int m) const;
00119     std::ostream& print(std::ostream& os) const;    
00121     std::string toString(void) const;
00123     GECODE_MSC_VIRTUAL ~Symbol(void);
00124   };
00125   
00126 }}
00127 
00128 forceinline
00129 std::ostream&
00130 operator<<(std::ostream& os, const Gecode::Support::Symbol& x) {
00131   return x.print(os);
00132 }
00133 
00134 // STATISTICS: support-any