• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

sst/core/activity.h

00001 // Copyright 2009-2010 Sandia Corporation. Under the terms
00002 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S.
00003 // Government retains certain rights in this software.
00004 // 
00005 // Copyright (c) 2009-2010, Sandia Corporation
00006 // All rights reserved.
00007 // 
00008 // This file is part of the SST software package. For license
00009 // information, see the LICENSE file in the top level directory of the
00010 // distribution.
00011 
00012 
00013 #ifndef SST_ACTIVITY_H
00014 #define SST_ACTIVITY_H
00015 
00016 #include <sst/core/sst_types.h>
00017 
00018 namespace SST {
00019 
00020 class Activity {
00021 public:
00022   Activity() {}
00023     virtual ~Activity() {}
00024 
00025     virtual void execute(void) = 0;
00026     
00027     // Comparator class to use with STL container classes.
00028     class less_time_priority {
00029     public:
00030         inline bool operator()(const Activity* lhs, const Activity* rhs) {
00031             if (lhs->delivery_time == rhs->delivery_time ) return lhs->priority < rhs->priority;
00032             else return lhs->delivery_time < rhs->delivery_time;
00033         }
00034 
00035         inline bool operator()(const Activity& lhs, const Activity& rhs) {
00036             if (lhs.delivery_time == rhs.delivery_time ) return lhs.priority < rhs.priority;
00037             else return lhs.delivery_time < rhs.delivery_time;
00038         }
00039     };
00040     
00041     // Comparator class to use with STL container classes.
00042     class less_time {
00043     public:
00044         inline bool operator()(const Activity* lhs, const Activity* rhs) {
00045             return lhs->delivery_time < rhs->delivery_time;
00046         }
00047 
00048         inline bool operator()(const Activity& lhs, const Activity& rhs) {
00049             return lhs.delivery_time < rhs.delivery_time;
00050         }
00051     };
00052     
00053     void setDeliveryTime(SimTime_t time) {
00054         delivery_time = time;
00055     }
00056 
00057     inline SimTime_t getDeliveryTime() const {
00058         return delivery_time;
00059     }
00060 
00061     inline int getPriority() const {
00062         return priority;
00063     }
00064 
00065 protected:
00066     void setPriority(int priority) {
00067         this->priority = priority;
00068     }
00069 
00070 private:
00071     SimTime_t delivery_time;
00072     int       priority;
00073 
00074     friend class boost::serialization::access;
00075     template<class Archive>
00076     void
00077     serialize(Archive & ar, const unsigned int version )
00078     {
00079         ar & BOOST_SERIALIZATION_NVP(delivery_time);
00080         ar & BOOST_SERIALIZATION_NVP(priority);
00081     }
00082 };
00083 
00084 }
00085 
00086 BOOST_CLASS_EXPORT_KEY(SST::Activity)
00087 
00088 #endif // SST_ACTIVITY_H

Generated on Fri Oct 22 2010 11:02:13 for SST by  doxygen 1.7.1