HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
declarePtrs.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the terms set forth in the LICENSE.txt file available at
5 // https://openusd.org/license.
6 //
7 #ifndef PXR_BASE_TF_DECLARE_PTRS_H
8 #define PXR_BASE_TF_DECLARE_PTRS_H
9 
10 /// \file tf/declarePtrs.h
11 /// Standard pointer typedefs.
12 ///
13 /// This file provides typedefs for standard pointer types.
14 
15 #include "pxr/pxr.h"
16 #include "pxr/base/tf/weakPtr.h"
17 #include "pxr/base/tf/refPtr.h"
18 
19 #include <vector>
20 
22 
23 /// \struct TfDeclarePtrs
24 /// Templated struct used for type definition macros.
25 template<typename T> struct TfDeclarePtrs {
28  typedef std::vector< Ptr > PtrVector;
29  typedef std::vector< ConstPtr > ConstPtrVector;
30 
33  typedef std::vector< RefPtr > RefPtrVector;
34  typedef std::vector< ConstRefPtr > ConstRefPtrVector;
35 };
36 
37 /// Define standard weak pointer types.
38 ///
39 /// \param type is a class name.
40 ///
41 /// \c TF_DECLARE_WEAK_PTRS(Class) declares ClassPtr, ClassConstPtr,
42 /// ClassPtrVector and ClassConstPtrVector.
43 ///
44 /// \hideinitializer
45 #define TF_DECLARE_WEAK_PTRS(type) \
46  typedef TfDeclarePtrs< class type >::Ptr type##Ptr; \
47  typedef TfDeclarePtrs< class type >::ConstPtr type##ConstPtr; \
48  typedef TfDeclarePtrs< class type >::PtrVector type##PtrVector; \
49  typedef TfDeclarePtrs< class type >::ConstPtrVector type##ConstPtrVector
50 
51 /// Define standard ref pointer types.
52 ///
53 /// \param type is a class name.
54 ///
55 /// \c TF_DECLARE_REF_PTRS(Class) declares ClassRefPtr and ClassConstRefPtr.
56 ///
57 /// \hideinitializer
58 #define TF_DECLARE_REF_PTRS(type) \
59  typedef TfDeclarePtrs< class type >::RefPtr type##RefPtr; \
60  typedef TfDeclarePtrs< class type >::ConstRefPtr type##ConstRefPtr; \
61  typedef TfDeclarePtrs< class type >::RefPtrVector type##RefPtrVector; \
62  typedef TfDeclarePtrs< class type >::ConstRefPtrVector type##ConstRefPtrVector
63 
64 /// Define standard weak, ref, and vector pointer types.
65 ///
66 /// \param type is a class name.
67 ///
68 /// \c TF_DECLARE_WEAK_AND_REF_PTRS(Class) declares ClassPtr, ClassConstPtr,
69 /// ClassPtrVector, ClassConstPtrVector, ClassRefPtr and ClassConstRefPtr.
70 ///
71 /// \hideinitializer
72 #define TF_DECLARE_WEAK_AND_REF_PTRS(type) \
73  TF_DECLARE_WEAK_PTRS(type); \
74  TF_DECLARE_REF_PTRS(type)
75 
77 
78 #endif
std::vector< Ptr > PtrVector
Definition: declarePtrs.h:28
TfWeakPtr< const T > ConstPtr
Definition: declarePtrs.h:27
TfRefPtr< T > RefPtr
Definition: declarePtrs.h:31
std::vector< RefPtr > RefPtrVector
Definition: declarePtrs.h:33
std::vector< ConstPtr > ConstPtrVector
Definition: declarePtrs.h:29
TfRefPtr< const T > ConstRefPtr
Definition: declarePtrs.h:32
std::vector< ConstRefPtr > ConstRefPtrVector
Definition: declarePtrs.h:34
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
TfWeakPtr< T > Ptr
Definition: declarePtrs.h:26