00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef SST_CORE_STOPACTION_H
00013 #define SST_CORE_STOPACTION_H
00014
00015 #include <sst/core/serialization.h>
00016
00017 #include <iostream>
00018
00019 #include <sst/core/action.h>
00020
00021 namespace SST {
00022
00023
00024
00025
00026 class StopAction : public Action
00027 {
00028 private:
00029
00030 std::string message;
00031 bool print_message;
00032
00033 public:
00034 StopAction() {
00035 setPriority(STOPACTIONPRIORITY);
00036 print_message = false;
00037 }
00038
00039
00040
00041 StopAction(std::string msg) {
00042 setPriority(STOPACTIONPRIORITY);
00043 print_message = true;
00044 message = msg;
00045 }
00046
00047 void execute() {
00048 if ( print_message ) {
00049 std::cout << message << std::endl;
00050 }
00051 endSimulation();
00052 }
00053
00054 void print(const std::string &header, Output &out) const {
00055 out.output("%s StopAction to be delivered at %" PRIu64 "\n", header.c_str(), getDeliveryTime());
00056 }
00057
00058 private:
00059 friend class boost::serialization::access;
00060 template<class Archive>
00061 void
00062 serialize(Archive & ar, const unsigned int version )
00063 {
00064 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Action);
00065 ar & BOOST_SERIALIZATION_NVP(message);
00066 ar & BOOST_SERIALIZATION_NVP(print_message);
00067 }
00068 };
00069
00070 }
00071
00072 #endif //SST_CORE_STOPACTION_H