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
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00049 #ifndef TOPPERS_FMEMPOOL_HPP_
00050 #define TOPPERS_FMEMPOOL_HPP_
00051
00052 #include <toppers/object.hpp>
00053
00054 namespace toppers
00055 {
00056
00067 template <ID Id = 0,
00068 class Diagnostics = TOPPERS_DEFAULT_DIAGNOSTICS,
00069 class Stub = TOPPERS_DEFAULT_STUB >
00070 class fmempool : Diagnostics
00071 {
00072 typedef object_controller<Id, obj_fmempool, Stub> controller;
00073 object_id<Id> objid_;
00074
00075 public:
00076 typedef t_cmpf creation;
00077 typedef t_rmpf reference;
00078
00081
00083 fmempool() {}
00085 explicit fmempool(ID id) : objid_(id) {}
00086
00088 template <ID Id2, class Diagnostics2, class Stub2>
00089 fmempool(const fmempool<Id2, Diagnostics2, Stub2>& other)
00090 : objid_(get_unsafe_id(other))
00091 {
00092 TOPPERS_STATIC_ASSERT(Id == 0);
00093 }
00094
00096
00099
00100
00101 ER create(creation* pk_cobj)
00102 {
00103 ER ercd = controller::create(objid_, pk_cobj);
00104 return handle_error(ercd);
00105 }
00107 ER create(const creation* pk_cobj)
00108 {
00109 ER ercd = controller::create(objid_, pk_cobj);
00110 return handle_error(ercd);
00111 }
00113 ER create(ATR mpfatr = TA_TFIFO, UINT blkcnt = 32, UINT blksz = 32, VP mpf = 0)
00114 {
00115 creation packet;
00116 packet.mpfatr = mpfatr;
00117 packet.blkcnt = blkcnt;
00118 packet.blksz = blksz;
00119 packet.mpf = mpf;
00120 return create(&packet);
00121 }
00123 ER destroy()
00124 {
00125 ER ercd = controller::destroy(objid_);
00126 return handle_error(ercd);
00127 }
00128
00130
00133
00135 ER refer(reference* pk_robj) const
00136 {
00137 ER ercd = controller::refer(objid_, pk_robj);
00138 return handle_error(ercd);
00139 }
00140
00142
00145
00147 ER get(VP* p_blk, forever_tag = forever) const
00148 {
00149 ER ercd = Stub::stub_get_mpf(objid_.id(), p_blk);
00150 return handle_error(ercd);
00151 }
00153 ER get(VP* p_blk, polling_tag) const
00154 {
00155 ER ercd = Stub::stub_pget_mpf(objid_.id(), p_blk);
00156 return handle_error(ercd);
00157 }
00159 ER get(VP* p_blk, TMO tmout) const
00160 {
00161 ER ercd = Stub::stub_tget_mpf(objid_.id(), p_blk, tmout);
00162 return handle_error(ercd);
00163 }
00164
00166 ER get(UINT, VP* p_blk, forever_tag = forever) const
00167 {
00168 return get(p_blk, forever);
00169 }
00171 ER get(UINT, VP* p_blk, polling_tag) const
00172 {
00173 return get(p_blk, polling);
00174 }
00176 ER get(UINT, VP* p_blk, TMO tmout) const
00177 {
00178 return get(p_blk, tmout);
00179 }
00180
00182 ER release(VP blk) const
00183 {
00184 ER ercd = Stub::stub_rel_mpf(objid_.id(), blk);
00185 return handle_error(ercd);
00186 }
00187
00189
00191 friend ID get_unsafe_id(const fmempool<Id, Diagnostics, Stub>& obj)
00192 {
00193 return obj.objid_.id();
00194 }
00195 };
00196
00197 }
00198
00199 #endif // ! TOPPERS_FMEMPOOL_HPP_