SST/macro
library.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_SOFTWARE_LIBRARIES_LIBRARY_H_INCLUDED
13 #define SSTMAC_SOFTWARE_LIBRARIES_LIBRARY_H_INCLUDED
14 
22 #include <map>
23 
24 
25 namespace sstmac {
26 namespace sw {
27 
28 class library {
29 
30  public:
31  virtual void
33 
34  virtual std::string
35  to_string() const {
36  return libname_;
37  }
38 
39  virtual std::string
40  lib_name() const {
41  return libname_;
42  }
43 
44  virtual void
46 
47  virtual void
48  consume_params(sprockit::sim_parameters* params);
49 
50  virtual void
51  incoming_event(event* ev) = 0;
52 
54  os() const {
55  return os_;
56  }
57 
59  sid() const {
60  return sid_;
61  }
62 
63  virtual ~library();
64 
65  protected:
66  library(const std::string& libname, software_id sid) :
67  sid_(sid), libname_(libname), os_(0)
68  {
69  }
70 
71  library(const char* prefix, software_id sid) :
72  sid_(sid), libname_(sprockit::printf("%s%s", prefix, sid.to_string().c_str())), os_(0)
73  {
74  }
75 
76  /**
77  * This function is provided so that libraries can instantiate, register, and use other libraries.
78  * @param lib the library to register
79  */
80  void
81  register_lib(library* lib);
82 
83  protected:
87 
88  private:
89  std::string libname_;
90 
91 };
92 
94  public library
95 {
96  protected:
97  blocking_library(const char* prefix, software_id sid) :
98  library(prefix, sid)
99  {
100  }
101 
102  blocking_library(const std::string& libname, software_id sid) :
103  library(libname, sid)
104  {
105  }
106 
107  void wait_event(event* ev, key::category = key::general);
108 
109  virtual void
110  incoming_event(event *ev);
111 
112  private:
113  std::map<event*,key*> blocked_events_;
114 
115 };
116 
117 
118 }
119 } //end of namespace sstmac
120 
121 #endif
122 
virtual void consume_params(sprockit::sim_parameters *params)
virtual std::string lib_name() const
Definition: library.h:40
std::string printf(const char *fmt,...)
software_id sid_
Definition: library.h:86
virtual void incoming_event(event *ev)=0
void register_lib(library *lib)
This function is provided so that libraries can instantiate, register, and use other libraries...
blocking_library(const char *prefix, software_id sid)
Definition: library.h:97
static category general
Definition: key.h:66
blocking_library(const std::string &libname, software_id sid)
Definition: library.h:102
SUMI = Simulator unified messagine interface It is also the name for a solid ink in Japanese - i...
library(const char *prefix, software_id sid)
Definition: library.h:71
virtual void unregister_all_libs()
virtual void init_os(operating_system *os)
std::string libname_
Definition: library.h:89
key::category key_cat_
Definition: library.h:85
virtual std::string to_string() const
Definition: library.h:35
library(const std::string &libname, software_id sid)
Definition: library.h:66
software_id sid() const
Definition: library.h:59
operating_system * os_
Definition: library.h:84
std::map< event *, key * > blocked_events_
Definition: library.h:113
A wrapper for an appid, taskid pair.
Definition: software_id.h:28
operating_system * os() const
Definition: library.h:54