00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00042 #ifndef RC_OBJECT_HANDLE_H_
00043 #define RC_OBJECT_HANDLE_H_
00044
00045 #include "ReChannel/util/rc_port_handle.h"
00046 #include "ReChannel/util/rc_export_handle.h"
00047
00048 namespace ReChannel {
00049
00060 class rc_object_handle
00061 {
00062 public:
00064 rc_object_handle();
00065
00067 rc_object_handle(sc_object& obj_);
00068
00070 rc_object_handle(const rc_port_handle& port_);
00071
00073 template<class IF, int N, sc_port_policy POL>
00074 rc_object_handle(sc_port<IF, N, POL>& port_);
00075
00077 rc_object_handle(const rc_export_handle& export_);
00078
00080 template<class IF>
00081 rc_object_handle(sc_export<IF>& export_);
00082
00083 public:
00084 rc_object_handle& operator=(sc_object& obj_);
00085
00086 template<class IF, int N, sc_port_policy POL>
00087 rc_object_handle& operator=(sc_port<IF, N, POL>& port_);
00088
00089 rc_object_handle& operator=(const rc_port_handle& port_);
00090
00091 template<class IF>
00092 rc_object_handle& operator=(sc_export<IF>& export_);
00093
00094 rc_object_handle& operator=(const rc_export_handle& export_);
00095
00097 inline bool valid() const
00098 { return (p_object != NULL); }
00099
00101 inline bool is_port() const
00102 { return p_port.valid(); }
00103
00105 inline bool is_export() const
00106 { return p_export.valid(); }
00107
00109 inline bool is_channel() const
00110 { return p_channel_if != NULL; }
00111
00113 inline bool is_comm_object() const
00114 { return (is_channel() || is_port() || is_export()); }
00115
00117 inline rc_port_handle get_port() const
00118 { return p_port; }
00119
00121 inline rc_export_handle get_export() const
00122 { return p_export; }
00123
00125 sc_interface* get_interface() const;
00126
00128 inline sc_object* get_object() const
00129 { return p_object; }
00130
00132 sc_object* operator->() const
00133 { return p_object; }
00134
00136 sc_object* operator*() const
00137 { return p_object; }
00138
00139 inline operator sc_object*() const
00140 { return p_object; }
00141
00145 bool operator==(const rc_object_handle& other) const
00146 { return p_object == other.p_object; }
00147
00152 bool operator<(const rc_object_handle& other) const
00153 { return p_object < other.p_object; }
00154
00155 private:
00157 sc_object* p_object;
00159 sc_interface* p_channel_if;
00161 rc_port_handle p_port;
00163 rc_export_handle p_export;
00164 };
00165
00166
00167
00168 template<class IF, int N, sc_port_policy POL>
00169 rc_object_handle::rc_object_handle(sc_port<IF, N, POL>& port_)
00170 : p_object(static_cast<sc_object*>(&port_)), p_channel_if(NULL),
00171 p_port(port_)
00172 { }
00173
00174 template<class IF>
00175 rc_object_handle::rc_object_handle(sc_export<IF>& export_)
00176 : p_object(static_cast<sc_object*>(&export_)), p_channel_if(NULL),
00177 p_export(export_)
00178 { }
00179
00180 template<class IF, int N, sc_port_policy POL>
00181 rc_object_handle& rc_object_handle::operator=(sc_port<IF, N, POL>& port_)
00182 {
00183 p_object = static_cast<sc_object*>(&port_);
00184 p_channel_if = NULL;
00185 p_port = port_;
00186 p_export.reset();
00187 return *this;
00188 }
00189
00190 template<class IF>
00191 rc_object_handle& rc_object_handle::operator=(sc_export<IF>& export_)
00192 {
00193 p_object = static_cast<sc_object*>(&export_);
00194 p_channel_if = NULL;
00195 p_port.reset();
00196 p_export = export_;
00197 return *this;
00198 }
00199
00200 }
00201
00202 #endif // RC_PORT_HANDLE_H_
00203
00204
00205
00206
00207