SystemC  2.3.2
Accellera SystemC proof-of-concept library
sc_dynamic_processes.h
Go to the documentation of this file.
1 /*****************************************************************************
2 
3  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4  more contributor license agreements. See the NOTICE file distributed
5  with this work for additional information regarding copyright ownership.
6  Accellera licenses this file to you under the Apache License, Version 2.0
7  (the "License"); you may not use this file except in compliance with the
8  License. You may obtain a copy of the License at
9 
10  http://www.apache.org/licenses/LICENSE-2.0
11 
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15  implied. See the License for the specific language governing
16  permissions and limitations under the License.
17 
18  *****************************************************************************/
19 
20 /*****************************************************************************
21 
22  sc_dynamic_process.h -- Dynamic Process Package Definitions
23 */
34 #ifndef SC_DYNAMIC_PROCESSES_H
35 #define SC_DYNAMIC_PROCESSES_H
36 
37 #include "sysc/kernel/sc_cmnhdr.h"
38 #include "sysc/kernel/sc_except.h"
39 #include "sysc/kernel/sc_spawn.h"
40 #include "sysc/kernel/sc_join.h"
41 
42 #if SC_CPLUSPLUS >= 201103L // C++11 or later has std::bind
43 # include <functional>
44 
45 namespace sc_unnamed {
46 using namespace std::placeholders;
47 } // namespace sc_unnamed
48 
49 namespace sc_core {
50 
51 template<typename F, typename... Args>
52 auto sc_bind( F&& f, Args&&... args )
53 # if SC_CPLUSPLUS < 201402L // explicit return type needed before C++14
54  -> decltype( std::bind(std::forward<F>(f), std::forward<Args>(args)...) )
55 # endif
56  { return std::bind( std::forward<F>(f), std::forward<Args>(args)... ); }
57 
58 template<typename T>
59 auto sc_ref( T&& v )
60 # if SC_CPLUSPLUS < 201402L // explicit return type needed before C++14
61  -> decltype( std::ref(std::forward<T>(v) ) )
62 # endif
63  { return std::ref( std::forward<T>(v) ); }
64 
65 template<typename T>
66 auto sc_cref( T&& v )
67 # if SC_CPLUSPLUS < 201402L // explicit return type needed before C++14
68  -> decltype( std::cref(std::forward<T>(v) ) )
69 # endif
70  { return std::cref( std::forward<T>(v) ); }
71 
72 } // namespace sc_core
73 
74 // bring sc_bind, sc_ref, sc_cref into global namespace - unless asked not to
75 // TODO: invert default for IEEE 1666-202x
76 #if ! (defined(SC_BIND_IN_GLOBAL_NAMESPACE) && SC_BIND_IN_GLOBAL_NAMESPACE == 0)
77 using sc_core::sc_bind;
78 using sc_core::sc_ref;
79 using sc_core::sc_cref;
80 #endif // SC_BIND_IN_GLOBAL_NAMESPACE
81 
82 #else // use Boost implementation
83 # include "sysc/packages/boost/bind.hpp"
84 # include "sysc/packages/boost/ref.hpp"
85 
86 # define sc_bind sc_boost::bind
87 # define sc_ref(r) sc_boost::ref(r)
88 # define sc_cref(r) sc_boost::cref(r)
89 
90 #endif // C++11 implementation
91 
92 // $Log: sc_dynamic_processes.h,v $
93 // Revision 1.5 2011/08/26 20:46:09 acg
94 // Andy Goodrich: moved the modification log to the end of the file to
95 // eliminate source line number skew when check-ins are done.
96 //
97 // Revision 1.4 2011/02/18 20:27:14 acg
98 // Andy Goodrich: Updated Copyrights.
99 //
100 // Revision 1.3 2011/02/13 21:47:37 acg
101 // Andy Goodrich: update copyright notice.
102 //
103 // Revision 1.2 2008/05/22 17:06:25 acg
104 // Andy Goodrich: updated copyright notice to include 2008.
105 //
106 // Revision 1.1.1.1 2006/12/15 20:20:05 acg
107 // SystemC 2.3
108 //
109 // Revision 1.5 2006/04/20 17:08:16 acg
110 // Andy Goodrich: 3.0 style process changes.
111 //
112 // Revision 1.4 2006/04/11 23:13:20 acg
113 // Andy Goodrich: Changes for reduced reset support that only includes
114 // sc_cthread, but has preliminary hooks for expanding to method and thread
115 // processes also.
116 //
117 // Revision 1.3 2006/01/13 18:44:29 acg
118 // Added $Log to record CVS changes into the source.
119 //
120 
121 #endif // SC_DYNAMIC_PROCESSES_H
#define sc_bind
#define sc_ref(r)
Process spawning support.
#define sc_cref(r)
Join Process Synchronization Definition.