TECA
The Toolkit for Extreme Climate Analysis
teca_shared_object.h
Go to the documentation of this file.
1 #ifndef teca_shared_object_h
2 #define teca_shared_object_h
3 
4 /// @file
5 
6 #include <memory>
7 
8 // convenience macro. every teca_algrotihm/dataset
9 // should have the following forward declarations
10 
11 #ifdef SWIG
12 
13 // SWIG doesn't handle alias templates yet. OK for the
14 // shared object forward but the shared object template
15 // forward has no direct mapping into c++03.
16 
17 #define TECA_SHARED_OBJECT_FORWARD_DECL(_cls) \
18  class _cls; \
19  typedef std::shared_ptr<_cls> p_##_cls; \
20  typedef std::shared_ptr<const _cls> const_p_##_cls;
21 
22 #define TECA_SHARED_OBJECT_TEMPLATE_FORWARD_DECL(_cls) \
23  template<typename T> class _cls;
24 
25 #else
26 
27 #define TECA_SHARED_OBJECT_FORWARD_DECL(_cls) \
28  class _cls; \
29  \
30  /** a shared pointer to an instance of _cls */ \
31  using p_##_cls = std::shared_ptr<_cls>; \
32  \
33  /** A shared pointer to a const instance of _cls */ \
34  using const_p_##_cls = std::shared_ptr<const _cls>;
35 
36 #define TECA_SHARED_OBJECT_TEMPLATE_FORWARD_DECL(_cls) \
37  template<typename T> class _cls; \
38  \
39  /** a shared pointer to an instance of _cls */ \
40  template<typename T> \
41  using p_##_cls = std::shared_ptr<_cls<T>>; \
42  \
43  /** A shared pointer to a const instance of _cls */ \
44  template<typename T> \
45  using const_p_##_cls = std::shared_ptr<const _cls<T>>;
46 
47 #endif
48 #endif