Oracle ODB Runtime Library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
auto-descriptor.hxx
Go to the documentation of this file.
1 // file : odb/oracle/auto-descriptor.hxx
2 // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC
3 // license : ODB NCUEL; see accompanying LICENSE file
4 
5 #ifndef ODB_ORACLE_AUTO_DESCRIPTOR_HXX
6 #define ODB_ORACLE_AUTO_DESCRIPTOR_HXX
7 
8 #include <odb/pre.hxx>
9 
10 #include <odb/oracle/version.hxx>
12 
13 #include <odb/oracle/details/export.hxx>
14 
15 namespace odb
16 {
17  namespace oracle
18  {
20  {
27  };
28 
29  LIBODB_ORACLE_EXPORT void
30  oci_descriptor_free (void* descriptor, descriptor_type type);
31 
32  //
33  // descriptor_type_traits
34  //
35 
36  template <typename D>
38 
39  template <>
41  { static const descriptor_type dtype = dt_param; };
42 
43  template <>
45  { static const descriptor_type dtype = dt_lob; };
46 
47  //
48  // auto_descriptor_base
49  //
50 
51  template <typename D, descriptor_type type>
53  {
54  static void
55  release (D* d)
56  {
57  oci_descriptor_free (d, type);
58  }
59  };
60 
61  template <typename D>
63  {
64  static void
65  release (D* d)
66  {
68  }
69  };
70 
71  //
72  // auto_descriptor
73  //
74 
75  template <typename D, descriptor_type type = dt_default>
77  {
78  public:
79  auto_descriptor (D* d = 0)
80  : d_ (d)
81  {
82  }
83 
85  {
86  if (d_ != 0)
87  this->release (d_);
88  }
89 
90  operator D* () const
91  {
92  return d_;
93  }
94 
95  D*&
96  get ()
97  {
98  return d_;
99  }
100 
101  D*
102  get () const
103  {
104  return d_;
105  }
106 
107  void
108  reset (D* d = 0)
109  {
110  if (d_ != 0)
111  this->release (d_);
112 
113  d_ = d;
114  }
115 
116  private:
118  auto_descriptor& operator= (const auto_descriptor&);
119 
120  protected:
121  D* d_;
122  };
123  }
124 }
125 
126 #include <odb/post.hxx>
127 
128 #endif // ODB_ORACLE_AUTO_DESCRIPTOR_HXX
Definition: auto-descriptor.hxx:23
static void release(D *d)
Definition: auto-descriptor.hxx:55
~auto_descriptor()
Definition: auto-descriptor.hxx:84
Definition: auto-descriptor.hxx:24
Definition: auto-descriptor.hxx:37
static void release(D *d)
Definition: auto-descriptor.hxx:65
Definition: auto-descriptor.hxx:25
Definition: auto-descriptor.hxx:26
struct OCILobLocator OCILobLocator
Definition: oracle-fwd.hxx:30
Definition: auto-descriptor.hxx:76
D * d_
Definition: auto-descriptor.hxx:121
struct OCIParam OCIParam
Definition: oracle-fwd.hxx:29
descriptor_type
Definition: auto-descriptor.hxx:19
Definition: auto-descriptor.hxx:52
void reset(D *d=0)
Definition: auto-descriptor.hxx:108
auto_descriptor(D *d=0)
Definition: auto-descriptor.hxx:79
Definition: auto-descriptor.hxx:22
Definition: auto-descriptor.hxx:21
LIBODB_ORACLE_EXPORT void oci_descriptor_free(void *descriptor, descriptor_type type)