SST/macro
event_handler.h
Go to the documentation of this file.
1 /*
2  * This file is part of SST/macroscale:
3  * The macroscale architecture simulator from the SST suite.
4  * Copyright (c) 2009 Sandia Corporation.
5  * This software is distributed under the BSD License.
6  * Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
7  * the U.S. Government retains certain rights in this software.
8  * For more information, see the LICENSE file in the top
9  * SST/macroscale directory.
10  */
11 
12 #ifndef SSTMAC_COMMON_EVENTHANDLER_H_INCLUDED
13 #define SSTMAC_COMMON_EVENTHANDLER_H_INCLUDED
14 
18 
19 namespace sstmac {
20 
21 /**
22  * The main interface for something that can respond to an event (sst_message).
23  */
25 {
26  public:
27  static const int null_lpid = -1;
28  static const int null_threadid = -1;
29 
30 #if SSTMAC_INTEGRATED_SST_CORE
31  public:
32  typedef enum {
33  self_handler,
34  link_handler
35  } type_t;
36 
37  type_t type() const {
38  return type_;
39  }
40 
41  protected:
42  event_handler() : type_(self_handler), thread_id_(null_threadid) {}
43 
44  event_handler(type_t ty) : type_(ty), thread_id_(null_threadid) {}
45 
46  private:
47  type_t type_;
48 #else
49  protected:
50  event_handler() : thread_id_(null_threadid) {}
51 #endif
52 
53  public:
54  virtual std::string
55  to_string() const = 0;
56 
57  virtual ~event_handler() {}
58 
59  virtual void
60  handle(event* ev) = 0;
61 
63  event_location() const {
64  return loc_id_;
65  }
66 
67  /**
68  * Whether an event handler is a "fake" handler that represents
69  * logical process boundary. Messages scheduled here are sent to another process.
70  * @return If this is an IPC stub handler
71  */
72  virtual bool
73  ipc_handler() const {
74  return false;
75  }
76 
77  int
78  thread_id() const {
79  return thread_id_;
80  }
81 
82  virtual void
84 
85  virtual void
87 
88  protected:
89  void
91  loc_id_ = id;
92  }
93 
94  void
95  init_thread_id(int id){
96  thread_id_ = id;
97  }
98 
99 
100  private:
103 
104 };
105 
106 
107 } // end of namespace sstmac
108 #endif
109 
void init_thread_id(int id)
Definition: event_handler.h:95
virtual void handle(event *ev)=0
virtual bool ipc_handler() const
Whether an event handler is a "fake" handler that represents logical process boundary.
Definition: event_handler.h:73
static const int null_lpid
Definition: event_handler.h:27
int thread_id() const
Definition: event_handler.h:78
void init_loc_id(event_loc_id id)
Definition: event_handler.h:90
The main interface for something that can respond to an event (sst_message).
Definition: event_handler.h:24
SUMI = Simulator unified messagine interface It is also the name for a solid ink in Japanese - i...
event_loc_id event_location() const
Definition: event_handler.h:63
virtual void deadlock_check(event *ev)
Definition: event_handler.h:83
virtual void deadlock_check()
Definition: event_handler.h:86
static const int null_threadid
Definition: event_handler.h:28
virtual std::string to_string() const =0