Generated on Tue Dec 16 13:34:02 2008 for ell-3.0.0 by doxygen 1.5.1

src/ell/State.hh

Go to the documentation of this file.
00001 #ifndef STATE_H_
00002 #define STATE_H_
00003 
00004 #include <memory>
00005 #include <string>
00006 #include <limits.h>
00007 #include <biu/VirtualList.hh>
00008 #include <biu/Alphabet.hh>
00009 
00021 namespace ell
00022 {
00023     
00026     typedef biu::Alphabet::CSequence CSequence; 
00037     class State
00038     {
00039     public:
00040         // TYPEDEFs
00041     
00044         typedef biu::VirtualList<State> NeighborList;
00045         
00047         typedef std::auto_ptr<NeighborList> NeighborListPtr;
00048 
00049         State()
00050         {}
00051         
00052         virtual ~State()
00053         {}
00054         
00060         virtual const std::string& getID( void ) const = 0;
00061         
00062         virtual bool            operator== (const State& state2) const = 0;
00063         virtual bool            operator!= (const State& state2) const = 0;
00064         
00080         virtual bool            operator< (const State& state2) const;
00081 
00094         static
00095         bool less(const State* s1, const State* s2);
00096         
00098         virtual double      getEnergy() const = 0;
00099         
00104         virtual unsigned int    getMinimalDistance(const State& state2) const = 0;
00105         
00113         virtual State*  clone( State* toFill = NULL) const = 0;
00114         
00117         virtual State* fromString(const std::string& stringRep) const = 0;
00118         
00122         virtual std::string toString() const = 0;
00123 
00129         virtual std::string& toString( std::string & toFill ) const = 0;
00130 
00131         // neighborhood
00135         virtual NeighborListPtr getNeighborList() const = 0;
00136 
00141         virtual NeighborListPtr getRandomNeighborList() const = 0;
00142 
00146         virtual State* getRandomNeighbor(State* inPlaceNeigh = NULL) const = 0;
00147         
00149         
00153         virtual CSequence compress(void) const = 0;
00154         
00160         virtual CSequence& compress(CSequence& toFill) const = 0;
00161         
00170         virtual State* uncompress(const CSequence& cseq, State* toFill ) const = 0;
00171         
00177         virtual State* uncompress(const CSequence& cseq) = 0;
00178         
00179     };
00180 
00181 }
00182 
00183 #include <biu/assertbiu.hh>
00184 
00185 namespace ell {
00186 
00187     inline
00188     bool
00189     State::
00190 	operator< (const State& state2) const
00191     {
00192           // check if same object
00193         if (this == &state2)
00194             return false;
00195           // check if 
00196           // - smaller energy or
00197           // - equal energy and smaller string representation
00198         return ( this->getEnergy() < state2.getEnergy() )
00199                 || ( this->getEnergy() == state2.getEnergy()
00200                     && this->toString().compare(state2.toString()) < 0 );
00201     }
00202     
00203     inline
00204     bool
00205     State::
00206 	less(const State* s1, const State* s2)
00207     {
00208         assertbiu( s1 != NULL, "no state s1 given (NULL)");
00209         assertbiu( s2 != NULL, "no state s2 given (NULL)");
00210         
00211         return s1->operator <( *s2 );
00212     }
00213 }
00214 
00215 
00216 
00217 #endif /*STATE_H_*/