ArcGIS Procedural Runtime  3.2.10650
PRTUtils.h
1 /*
2  COPYRIGHT (c) 2012-2024 Esri R&D Center Zurich
3  TRADE SECRETS: ESRI PROPRIETARY AND CONFIDENTIAL
4  Unpublished material - all rights reserved under the
5  Copyright Laws of the United States and applicable international
6  laws, treaties, and conventions.
7 
8  For additional information, contact:
9  Environmental Systems Research Institute, Inc.
10  Attn: Contracts and Legal Services Department
11  380 New York Street
12  Redlands, California, 92373
13  USA
14 
15  email: contracts@esri.com
16 */
17 
18 #ifndef PRTX_CLASSUTILS_H_
19 #define PRTX_CLASSUTILS_H_
20 
21 #include "prt/Object.h"
22 
23 #include "prtx/prtx.h"
24 
25 #include <memory>
26 #include <string>
27 
28 
29 namespace prt {
30 
31 class AttributeMap;
32 class AttributeMapBuilder;
33 class ResolveMap;
34 class ResolveMapBuilder;
35 class InitialShape;
36 class InitialShapeBuilder;
37 class RuleFileInfo;
38 class EncoderInfo;
39 class EncoderInfoBuilder;
40 class DecoderInfo;
41 class Annotation;
42 class CacheObject;
43 class OcclusionSet;
44 class FileOutputCallbacks;
45 class MemoryOutputCallbacks;
46 
47 } // namespace prt
48 
49 
50 namespace prtx {
51 
52 
56 namespace PRTUtils {
57 
58 
63  void operator()(prt::Object const* p) { if(p != nullptr) p->destroy(); }
64 };
65 
66 
70 template<typename P> class ObjectPtr {
71 public:
72  typedef P type;
73  typedef P* ptrType;
74 
75  ObjectPtr() { }
76  explicit ObjectPtr(P* p) : mPRT(p, ObjectDestroyer()) { }
77  virtual ~ObjectPtr() { }
78 
79  P* get() const { return mPRT.get(); }
80  P* operator->() const { return mPRT.get(); }
81  P& operator*() const { return *mPRT; }
82  bool operator<(const ObjectPtr<P>& rhs) const { return (mPRT.get() < rhs.mPRT.get()); }
83  bool operator==(const ObjectPtr<P>& rhs) const { return (mPRT.get() == rhs.mPRT.get()); }
84  bool operator()() const { return (bool)mPRT; }
85  explicit operator bool() const { return mPRT.operator bool(); }
86 
87  void reset(P* p) { mPRT.reset(p, ObjectDestroyer()); }
88 
89 protected:
90  std::shared_ptr<P> mPRT;
91 };
92 
93 
96 
99 
102 
104 
110 
111 
116 using AttributeMapUPtr = std::unique_ptr<prt::AttributeMap const, prtx::PRTUtils::ObjectDestroyer>;
117 using AttributeMapBuilderUPtr = std::unique_ptr<prt::AttributeMapBuilder, prtx::PRTUtils::ObjectDestroyer>;
118 using ResolveMapUPtr = std::unique_ptr<prt::ResolveMap const, prtx::PRTUtils::ObjectDestroyer>;
119 using ResolveMapBuilderUPtr = std::unique_ptr<prt::ResolveMapBuilder, prtx::PRTUtils::ObjectDestroyer>;
120 using EncoderInfoUPtr = std::unique_ptr<prt::EncoderInfo const, prtx::PRTUtils::ObjectDestroyer>;
121 using EncoderInfoBuilderUPtr = std::unique_ptr<prt::EncoderInfoBuilder, prtx::PRTUtils::ObjectDestroyer>;
122 
124 using FileOutputCallbacksUPtr = std::unique_ptr<prt::FileOutputCallbacks, prtx::PRTUtils::ObjectDestroyer>;
126 using MemoryOutputCallbacksUPtr = std::unique_ptr<prt::MemoryOutputCallbacks, prtx::PRTUtils::ObjectDestroyer>;
127 
128 
132 PRTX_EXPORTS_API std::string objectToXML(prt::Object const* const p);
133 
134 
135 } // namespace PRTUtils
136 
137 
138 } // namespace prtx
139 
140 
141 #endif /* PRTX_CLASSUTILS_H_ */
std::unique_ptr< prt::AttributeMap const, prtx::PRTUtils::ObjectDestroyer > AttributeMapUPtr
Definition: PRTUtils.h:116
std::string objectToXML(prt::Object const *const p)
Definition: PRTUtils.h:62
Definition: PRTUtils.h:70
The Procedural Runtime eXtension namespace. The prtx namespace contains the tools to extend the Proce...
Definition: AnnotationBuilder.h:35
void destroy() const
Definition: Object.h:35
The Procedural Runtime API namespace. The prt namespace contains the top level entry points into the ...
Definition: Annotation.h:24