HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PY_OpaqueObject.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * COMMENTS:
7  * Instances of this class hold a reference to a Python object. When this
8  * object is destroyed, the reference count on the Python object will be
9  * decremented.
10  *
11  * Unlike PY_AutoObject.h, it is ok to include this header file from other
12  * header files.
13  */
14 
15 #ifndef __PY_OpaqueObject_h__
16 #define __PY_OpaqueObject_h__
17 
18 #include "PY_API.h"
19 #include <string.h>
20 
22 {
23 public:
24  // Construct instances of this class with an opaque PY_PyObject pointer
25  // (which may be null). The constructor increments the reference count
26  // (so the caller should not) and the destructor decrements the count.
27  PY_OpaqueObject(void *opaque_py_object = NULL);
28  ~PY_OpaqueObject();
29 
30  PY_OpaqueObject(const PY_OpaqueObject &opaque_object);
31  PY_OpaqueObject &operator=(const PY_OpaqueObject &opaque_object);
32 
33  // Return a borrowed reference to our opaque PyObject *. If the caller
34  // will hold a reference to this object after the PY_OpaqueObject has been
35  // deleted, it is up to the caller to increment the reference count.
36  void *opaqueObject() const
37  { return myOpaqueObject; }
38 
39  // The comparison operators and equalsOpaqueObject compare using the __eq__
40  // operator.
41  bool operator==(const PY_OpaqueObject &opaque_object) const
42  { return equalsOpaqueObject(opaque_object.myOpaqueObject); }
43  bool operator!=(const PY_OpaqueObject &opaque_object) const
44  { return !operator==(opaque_object); }
45  bool equalsOpaqueObject(void *opaque_py_object) const;
46 
47 private:
48  void *myOpaqueObject;
49 };
50 
51 #endif
bool operator==(const BaseDimensions< T > &a, const BaseDimensions< Y > &b)
Definition: Dimensions.h:137
#define PY_API
Definition: PY_API.h:10
void * opaqueObject() const
bool operator==(const PY_OpaqueObject &opaque_object) const
bool operator!=(const PY_OpaqueObject &opaque_object) const