13 #ifndef XPACE_SHAREDIMPL_H 14 #define XPACE_SHAREDIMPL_H 18 #pragma warning(disable: 4251) 81 template <
typename T,
bool cached = false>
179 extern FILE* _trace_file;
181 template <
typename T>
186 fopen_s(&_trace_file,
"_TRACE_SHARE_",
"wt");
187 fprintf(_trace_file,
"Impl %s: (%s) %p %u\n", str,
typeid(T).
name(), constData(), getRefCount());
192 template <
typename T,
bool cached>
201 template <
typename T,
bool cached>
208 template <
typename T,
bool cached>
217 template <
typename T,
bool cached>
225 template <
typename T,
bool cached>
235 template <
typename T,
bool cached>
245 template <
typename T,
bool cached>
247 bool SharedImplPointer<T, cached>::operator!
254 template <
typename T,
bool cached>
259 return static_cast<T*
>(v.data(cached));
262 template <
typename T,
bool cached>
268 return static_cast<const T*
>(v.constData());
271 template <
typename T,
bool cached>
277 return static_cast<const T*
>(v.constData());
281 template <
typename T,
bool cached>
287 return v.getRefCount();
291 #define DECLARE_IMPL_COMMON(className, cached) \ 296 SharedImplPointer<Impl, cached> si; \ 297 className(Impl* i) : si(i) {}; \ 299 { return static_cast<Impl*>(si.data()); }; \ 300 const Impl* impl() const \ 301 { return static_cast<const Impl*>(si.data()); }; \ 302 const Impl* constImpl() const \ 303 { return static_cast<const Impl*>(si.constData()); }; 305 #define DECLARE_IMPL(className) \ 306 DECLARE_IMPL_COMMON(className, false) 308 #define DECLARE_IMPL_BASE(className, base) \ 309 DECLARE_IMPL_COMMON(className, false) \ 310 className(const className& rhs) : \ 311 base(), si(rhs.si) {} 313 #define DECLARE_CACHED_IMPL(className) \ 314 DECLARE_IMPL_COMMON(className, true) \ 315 className(const className& rhs) : \ 318 #define DECLARE_CACHED_IMPL_BASE(className, base) \ 319 DECLARE_IMPL_COMMON(className, true) \ 320 className(const className& rhs) : \ 321 base(), si(rhs.si) {} 323 #define DECLARE_CONFIG \ 324 virtual const Configuration& getConfig() const override; 326 #define DEFINE_CONFIG(className) \ 327 String className::getConfig() const \ 328 { return constImpl()->getConfig().toString(); }
A wrapper around a shared class object Used to store objects in containers (e.g.
A pointer to a shared class object Copying the pointer calls T::clone() T must inherit SharedImpl...
const T * constData() const
The base class for all shared implementations.
const Xpace_Char16 * name
Sink callbacks for table data.
Copyright (C) 2012 Xpace, LLC.
uint const Xpace_Char8 * data
Xpace project main namespace
an anonymous pointer, used only in conjunction with SharedImplPointer