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/Core/GoalLoader/Includes/PlanReader.hh

Go to the documentation of this file.
00001 // -*- Mode: C++ -*-
00002 //      CVS: $Id: PlanReader.hh,v 1.9 2005/08/23 20:26:22 rijsman Exp $
00003 //      Tag: $name$
00004 //     Info: $CVSROOT/Copyright.txt
00005 
00006 #ifndef PLAN_READER_HH
00007 #define PLAN_READER_HH 
00008 
00009 #include <map>
00010 #include <vector>
00011 #include <string>
00012 #include <iostream>
00013 #include "TimeBasics.hh"
00014 namespace IDEA 
00015 {
00021   struct BranchPoint
00022   {
00026     BranchPoint(int key, int from, int to): 
00027       tokenKey(key), 
00028       contextFrom(from), 
00029       contextTo(to) {}
00030 
00031     int tokenKey;
00032     int contextFrom;
00033     int contextTo;
00034   };
00035 
00041   struct TimeBranch:
00042     public BranchPoint
00043   {
00047     TimeBranch(int key, int from, int to, long time) : 
00048       BranchPoint(key, from, to),
00049       deadLine(time) {}
00050     long deadLine;
00051   };
00052 
00058   struct EnergyBranch:
00059     public BranchPoint
00060   {
00064     EnergyBranch(): 
00065       BranchPoint(0,0,0) {}
00066     double energyLeft;
00067   };
00068 
00069   struct TrackingBranch: 
00070     public BranchPoint
00071   {
00075     TrackingBranch(int key, int from, int to, bool flag, std::string target): 
00076       BranchPoint(key, from, to), 
00077       isTracking(flag), 
00078       targetName(target) {}
00079 
00080     bool isTracking;
00081     std::string targetName;
00082   };
00083 
00084   std::ostream& IDEA::operator << (std::ostream& os, 
00085                                    IDEA::BranchPoint const * branch);
00086 
00087   std::ostream& IDEA::operator << (std::ostream& os, 
00088                                    IDEA::TimeBranch const * branch);
00089 
00090   std::ostream& IDEA::operator << (std::ostream& os, 
00091                                    IDEA::TrackingBranch const * branch);
00092 
00099   class PlanReader
00100   {
00101   public:
00103     class IValue
00104     {
00105     public:
00106       virtual ~IValue() {}
00107     };
00110     template <class Type>
00111     class Value : public IValue
00112     {
00113     public:
00114       Value(Type value) {m_val = value;}
00115       const Type & get() const {return m_val;}
00116     private:
00117       Type m_val;
00118     };
00122     typedef std::map<std::string, IValue*> ArgumentToValue;
00123 
00127     struct TokenData
00128     {
00129       int key;
00130       Time earlyStart;
00131       Time earlyEnd;
00132       Time lateStart;
00133       Time lateEnd;
00134       std::string predicateName;
00135       ArgumentToValue arguments;
00136     };
00137 
00141     typedef std::vector<TokenData> TokenToArgValues;
00142 
00146     typedef std::map<std::string, TokenToArgValues> TimelineToTokens;
00147 
00151     struct ObjectData
00152     {
00153       std::string objectName;
00154       std::string className;
00155       TimelineToTokens timelines;
00156     };
00157 
00161     typedef std::map<std::string, ObjectData> ObjectToTimelines;
00162 
00166     struct EndsBeforeStartConstraint
00167     {
00168       int predecessor;
00169       int successor;
00170       long min;
00171       long max;
00172     };
00173 
00177     typedef std::vector<EndsBeforeStartConstraint> EndStartConstraints;
00178 
00182     struct Plan
00183     {
00184       ObjectToTimelines planObjects;
00185       EndStartConstraints constraints;
00186     };
00187 
00188     typedef std::map<int, Plan> ContextToPlanBranch;
00189 
00194     typedef std::map<int, IDEA::BranchPoint*> BranchPoints;
00198     virtual bool getBranchPoint(int tokenKey, BranchPoint *& branchPoint) = 0;
00199 
00203     virtual int readPlan( const std::string& fileName) = 0;
00207     virtual ObjectToTimelines const & getPlanObjects(int context = 0) = 0;
00211     virtual EndStartConstraints const & getPlanConstraints(int context = 0) = 0;
00215     virtual int getInfinity() {return INT_MAX;};
00219     virtual int getNegativeInfinity() { return -INT_MAX;}
00220   };
00221 
00222   std::ostream& operator << (std::ostream& os, 
00223                              PlanReader::TokenData const & token);
00224   std::ostream& 
00225   operator << (std::ostream& os, 
00226                PlanReader::EndsBeforeStartConstraint const & constraint);
00227   /*
00228   std::ostream& operator << (std::ostream& os, 
00229                              PlanReader::Value const & value);
00230   */
00231   std::ostream& operator << (std::ostream& os, 
00232                              PlanReader::ObjectToTimelines const & planBranch);
00233 } //namespace IDEA 
00234 
00235 #endif //PLAN_READER_HH 

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