Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

/home/pauldt/projects/IDEA/IDEA-ALL/IDEA-DEV/Modules/PLASMA/PlanServer/Includes/PlasmaTokenImpl.hh

Go to the documentation of this file.
00001 // -*- Mode: C++ -*-
00002 //      CVS: $Id: PlasmaTokenImpl.hh,v 1.18 2005/11/15 18:26:51 rijsman Exp $
00003 //      Tag: $name$
00004 //     Info: $CVSROOT/IDEA-DEV/COPYRIGHT
00005 
00006 #ifndef PLASMA_TOKEN_IMPLEMENTATION_HEADER
00007 #define PLASMA_TOKEN_IMPLEMENTATION_HEADER
00008 
00009 #include "PslTokenImpl.hh"
00010 
00011 #include "Token.hh"
00012 #include "TokenVariable.hh"
00013 
00014 namespace IDEA
00015 {
00016   class PslConstraint;
00017   class PslPredicate;
00018   class PslTimeline;
00019 
00027   class PlasmaTokenImpl:
00028     public PslTokenImpl
00029   {
00030   public:
00031     PlasmaTokenImpl( const PslDatabase* database,
00032                      const PslTimeline* timeline,
00033                      const PslPredicate* predicate,
00034                      int externalTokenId, 
00035                      const TokenLocation& source,
00036                      const std::string& comRelayName,
00037                      const EUROPA::TokenId& tokenId );
00038 
00043     PlasmaTokenImpl( const PslDatabase* database,
00044                      const PslPredicate* predicate,
00045                      int externalTokenId, 
00046                      const TokenLocation& source,
00047                      const std::string& comRelayName,
00048                      const EUROPA::TokenId& tokenId );
00049 
00050     ~PlasmaTokenImpl();
00051 
00052     void finalize();
00053     void commit();
00054     bool isCommitted() const;
00055     bool canBeCommitted() const;
00056     Time getEarliestEndTime() const;
00057     Time getEarliestStartTime() const;
00058     int getId() const;
00059     Time getMaximumDuration() const;
00060     Time getMinimumDuration() const;
00061     Time getLatestEndTime() const;
00062     Time getLatestStartTime() const;
00063 
00064     bool endsAtStart( const PslToken* token ) const;
00065 
00066     void setSuccessor( const PslToken* token ) const;
00067 
00068     const EUROPA::TokenId getTokenId() const;
00069 
00070     void print( std::ostream& os ) const;
00071 
00072     void setEarliestEndTime( const Time& value );
00073     void setLatestEndTime( const Time& value );
00074     void setLatestStartTime( const Time& value );
00075     void setEarliestStartTime( const Time& value );
00076     void resetSuccessorSelectorParameters( const std::vector<int>& authorities );
00077     bool endsNoEarlierThanEnd(const PslToken * token) const;
00078   private:
00079     const PslTimeline* retrieveTimelineAllocation() const;
00084     void resetSuccessorSelectorParameter( const std::vector<int>& authorities, int index );
00085 
00086     const PslVariable* createEndVariable();
00087     
00088     const PslVariable* createStartVariable();
00089     
00090     void createParameters( const PslToken* token );
00091 
00092     EUROPA::TokenId m_TokenId;
00093   };
00094 
00098   struct earliestStarTimeToken:
00099     public std::binary_function< EUROPA::TokenId, EUROPA::TokenId, bool>
00100   {
00101     bool operator()( EUROPA::TokenId& lhs, EUROPA::TokenId& rhs ) const
00102     {
00103       if( !lhs.isValid() || !rhs.isValid() )
00104         return false;
00105       
00106       double lhs_est = lhs->getStart()->derivedDomain().getLowerBound();
00107       double rhs_est = rhs->getStart()->derivedDomain().getLowerBound();
00108 
00109       if( lhs_est < rhs_est )
00110         return true;
00111 
00112       double lhs_lst = lhs->getStart()->derivedDomain().getUpperBound();
00113       double rhs_lst = rhs->getStart()->derivedDomain().getUpperBound();
00114 
00115       if( lhs_est == rhs_est && lhs_lst <  rhs_lst  )
00116         return true;
00117 
00118       double lhs_eet = lhs->getEnd()->derivedDomain().getLowerBound();
00119       double rhs_eet = rhs->getEnd()->derivedDomain().getLowerBound();
00120 
00121       if( lhs_est == rhs_est && lhs_lst ==  rhs_lst &&  lhs_eet < rhs_eet )
00122         return true;
00123 
00124       double lhs_let = lhs->getEnd()->derivedDomain().getUpperBound();
00125       double rhs_let = rhs->getEnd()->derivedDomain().getUpperBound();
00126 
00127       if( lhs_est == rhs_est && lhs_lst ==  rhs_lst &&  lhs_eet == rhs_eet && lhs_let < rhs_let )
00128         return true;
00129 
00130       return false;
00131     }
00132   };
00133 
00134 }
00135 
00136 #endif //PLASMA_TOKEN_IMPLEMENTATION_HEADER
00137 

Contact information
© IDEA
Generated on Fri Feb 3 17:09:42 2006 for IDEA.