Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00014 #ifndef DURING_ENV_H
00015 #define DURING_ENV_H
00016
00017 #include "during-if.h"
00018 #include "during-seq.h"
00019 #include "during-thread.h"
00020 #include "during-pool.h"
00021 #include "during-ondemand.h"
00022 #include <stdlib.h>
00023
00024 class sc_during_env : public sc_during_if {
00025 public:
00029 sc_during_env() {
00030 const char *c_mode = getenv("SC_DURING_MODE");
00031 if (c_mode == NULL ||
00032 !strcmp(c_mode, ""))
00033 c_mode = "ondemand";
00034 std::string mode = c_mode;
00035 #define MODE(name) if (mode == #name) { \
00036 m_if = new sc_during_ ## name(); \
00037 }
00038 MODE(seq);
00039 MODE(pool);
00040 MODE(thread);
00041 MODE(ondemand);
00042
00043 if (!m_if) {
00044 std::cout << "No such mode \"" << mode << "\", sorry" << std::endl;
00045 abort();
00046 }
00047 }
00048
00049 virtual ~sc_during_env() {
00050 delete m_if; m_if = NULL;
00051 };
00052 virtual mode get_mode() { return m_if->get_mode(); }
00055 using sc_during_if::during;
00056 using sc_during_if::extra_time;
00057 using sc_during_if::catch_up;
00058
00062 void extra_time(const sc_core::sc_time & t) { m_if->extra_time(t); }
00063 void catch_up(const sc_core::sc_time & t) { m_if->catch_up(t); }
00064 void sc_call(const boost::function<void()> & f) {m_if->sc_call(f); }
00065 void during(const sc_core::sc_time & time,
00066 const boost::function<void()> & routine) {
00067 m_if->during(time, routine);
00068 }
00069
00070
00071 private:
00073 sc_during_if *m_if;
00074 };
00075
00076 #endif // DURING_ENV_H