| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/drivers/Oracle/OCI/include/occiObjects.h
Go to the documentation of this file.

    00001 /* Copyright (c) 2000, 2003, Oracle Corporation.  All rights reserved.  */
    00002
    00003 /*
    00004    NAME
    00005      occiObjects.h - header file for OCCI object classes
    00006
    00007    DESCRIPTION
    00008      Class definitions for Ref, RefAny, AnyData
    00009
    00010    RELATED DOCUMENTS
    00011      <note any documents related to this facility>
    00012
    00013    EXPORT FUNCTION(S)
    00014      <external functions declared for use outside package - one-line
    00015      descriptions>
    00016
    00017    INTERNAL FUNCTION(S)
    00018      <other external functions declared - one-line descriptions>
    00019
    00020    EXAMPLES
    00021
    00022    NOTES
    00023      <other useful comments, qualifications, etc.>
    00024
    00025    MODIFIED   (MM/DD/YY)
    00026    cparampa    10/28/03 - add PObject::getSQLTypeName
    00027    shiyer      01/01/03 - add PObject::refresh
    00028    cparampa    02/19/03 - bug2732941-setFromRef takes schema and typename
    00029    rvallam     02/12/03 - modify Bfloat/Bdouble interface to use the new
    00030                           Bfloat/Bdouble type
    00031    rvallam     11/19/02 - objects support for interval classes
    00032    cparampa    12/26/02 - Added getType for AnyData,
    00033                           removed getAs/setFrom methods for Blob/Clob
    00034    cparampa    10/12/02 - making AnyData a public type
    00035    rvallam     10/12/02 - added method getCor to get the COR handle and the
    00036                           setPinnedObject method - arrayPin
    00037    rvallam     10/10/02 - objects performance enhancement - modified
    00038                           getObject and getVector<T *> to take the
    00039                           schName and typeName of the object
    00040    rvallam     10/11/02 - added native float/double API - get(set) methods
    00041                           for AnyData class
    00042    shiyer      09/17/02 - Refs performance improvement
    00043    shiyer      08/14/02 - 10iR1, OCCI Globalization support
    00044    aahluwal    06/04/02 - bug 2360115
    00045    vvinay      12/24/01 - declarations for setNull() and isClear() in RefImpl
    00046    rvallam     11/17/01 - implemented transactional consistency of refs
    00047    gayyappa    10/01/01 - reserve memory for vectors in set/getVector
    00048    rkasamse    07/31/01 - add PObject::new(size_t, void*)
    00049    gayyappa    07/17/01 - use C style comment in end of #ifdef WIN32COMMON.
    00050    gayyappa    06/20/01 - fix linux porting bug 1801312.
    00051    rvallam     06/14/01 - replace call to get(set)VectorOfRefs in
    00052                           get(set)Vector for Ref<T> with code in
    00053                           get(set)VectorOfRefs
    00054    rvallam     11/06/01 - renamed internal methods in get/setVector to
    00055                           get(set)VectorOfPObjects/get(set)VectorOfOCIRefs
    00056                           as part of NT porting fix
    00057                           added destructor to AnyData
    00058    rratnam     06/07/01 - fixed bug 1816387.
    00059    rvallam     06/07/01 - fixed bug 1811749 :replaced .data() to .c_str()
    00060                           for string to char* conversion.
    00061    rvallam     04/30/01 - modified const methods in Ref (->, *, ptr)
    00062    rvallam     04/12/01 - passed dummy argument OCCIPOBJECT in getVector
    00063                           of AnyData for PObject *
    00064    rvallam     04/09/01 - fixed bug 1721365- call RefAny default constructor
    00065                           for a NULL Ref in operator RefAny
    00066    gayyappa    03/29/01 - remove methods for get/set int/float/double/unsigned
    00067                           int , wasLastAttrNull, setAttrNull , geSQLTypeName
    00068                           from AnyData
    00069                           as OTT does not use them.
    00070    gayyappa    03/15/01 - add OCCItype parameter to getVector for OCCIRef.
    00071    rratnam     03/15/01 - fixed set and getRef / get and setVector for NULL
    00072                           Refs, fixed NT compilation errors
    00073    rratnam     03/13/01 - changed AnyData constructor to take a freeImg flag,
    00074    rkasamse    03/15/01 - pass OCCI_SQLT_REF to getVector
    00075    chliang     03/05/01 - disable olint.
    00076    rvallam     03/01/01 - changed getSessionPtr() to getConnection()
    00077                           added const methods for dereferencing in Ref
    00078    gayyappa    02/23/01 - correct template code for setVector
    00079    gayyappa    12/13/00 - remove allocator from list member for PObject.
    00080                           bug#1529973
    00081                           nullify object pointer in clear method of Ref
    00082    rvallam     11/08/00 - make RefAny constructor public
    00083    gayyappa    08/21/00 - replace objPtr by objptr.
    00084                           move templated get/set vector code of anydata
    00085                           to header.
    00086    rkasamse    08/07/00 - make getVector friend of RefAny
    00087    rkasamse    07/11/00 - take void* instead of AnyDataCtx*
    00088    rkasamse    07/26/00 - make ResultSetImp friend of RefAny
    00089    rratnam     06/19/00 - added getConnection in PObject
    00090    rvallam     06/13/00 - added Ref<T> and occiRefImpl code
    00091    rvallam     06/05/00 - to add the Ref<T> code
    00092    kmohan      06/02/00 -
    00093    kmohan      05/31/00 - Datamember Connection * changed to ConnectionImpl *
    00094                           in class RefAny
    00095    kmohan      04/11/00 - Ref, RefAny, AnyData class definitions
    00096                           added
    00097    rkasamse    04/03/00 - header (interface) files for OCCI Objects clases
    00098    rkasamse    04/03/00 - Creation
    00099
    00100 */
    00101
    00102 #ifndef _olint   /* disable olint check */
    00103
    00104 #ifndef OCCIOBJECTS_ORACLE
    00105 # define OCCIOBJECTS_ORACLE
    00106
    00107 #ifndef OCCICOMMON_ORACLE
    00108 #include <occiCommon.h>
    00109 #endif
    00110
    00111 namespace oracle {
    00112 namespace occi {
    00113 struct AnyDataCtx {
    00114    ConnectionImpl *occiSession;
    00115    OCIAnyData *anyData;
    00116    dvoid *objHeader;
    00117    ub4 errNum;
    00118 };
    00119 typedef struct AnyDataCtx AnyDataCtx;
    00120
    00121 class PObject
    00122 {
    00123   public:
    00124         enum LockOption {OCCI_LOCK_WAIT, OCCI_LOCK_NOWAIT};
    00125         enum UnpinOption {OCCI_PINCOUNT_DECR, OCCI_PINCOUNT_RESET};
    00126         static void destroy(void *);
    00127         static void refresh(void *);
    00128         PObject();
    00129         PObject(const void *ctx);
    00130         PObject(const PObject& obj);
    00131         virtual ~PObject();
    00132         PObject& operator=(const PObject& obj);
    00133         void *operator new(size_t size);
    00134         void *operator new(size_t size, const Connection *x,
    00135                            const OCCI_STD_NAMESPACE::string& tablename,
    00136                            const char *typeName);
    00137         void *operator new(size_t size, const Connection *sess,
    00138                const OCCI_STD_NAMESPACE::string& tablename,
    00139                const OCCI_STD_NAMESPACE::string& typName ,
    00140                const OCCI_STD_NAMESPACE::string& schTabName="",
    00141                const OCCI_STD_NAMESPACE::string& schTypName = "");
    00142         void *operator new(size_t size, const Connection *sess,
    00143                const UString& tablename, const UString &typName,
    00144                const UString& schTabName, const UString& schTypName);
    00145         void *operator new(size_t size, void *adctx);
    00146         void operator delete(void *obj, size_t size);
    00147         RefAny getRef() const;
    00148         bool isLocked() const;
    00149         void unpin(UnpinOption mode=OCCI_PINCOUNT_DECR);
    00150         void pin();
    00151         void lock(PObject::LockOption lock_option);
    00152         void unmark();
    00153         void flush();
    00154         void markDelete();
    00155         void markModified();
    00156         bool isNull() const;
    00157         void setNull();
    00158         const Connection *getConnection() const;
    00159         virtual OCCI_STD_NAMESPACE::string getSQLTypeName() const = 0;
    00160         virtual void getSQLTypeName(Environment *env, void **schName,
    00161                      unsigned int &schNameLen, void **typeName,
    00162                      unsigned int &typeNameLen) const = 0;
    00163         void getSQLTypeName(Environment *env, void *(*rSQL)(void *),
    00164                             void **schname, unsigned int &schnamelen,
    00165                             void **typname, unsigned int &typnamelen) const;
    00166         virtual void writeSQL(AnyData& stream) = 0;
    00167         virtual void readSQL(AnyData& stream) = 0;
    00168   private:
    00169        static void initialise( void * obj, const Connection * sess,
    00170               void *schTabName, unsigned int schTabLen,
    00171               void *tableName, unsigned int tabLen,
    00172               void *schTypName, unsigned int schTypLen,
    00173               void *typeName, unsigned int typLen);
    00174
    00175         ConnectionImpl  *occiSession_;
    00176         dvoid *objHeader_;
    00177         ub2 customNewed_;
    00178         enum {CUSTOM_NEWED = 0x5cde};
    00179         ub2 flags_;
    00180         enum {NULL_INFO = 0x0001, GARBAGE_COLLECTED = 0x0002,
    00181               REFRESH_OBJECT = 0x0004};
    00182         // for future use
    00183         void *pobjectExt;
    00184         friend class RefImpl;
    00185 };
    00186
    00187 class AnyData
    00188 {
    00189     public:
    00190     ~AnyData();
    00191     AnyData(void *any) ;
    00192     AnyData(const Connection *sessp);
    00193     AnyData(const Connection *sessp, OCIAnyData *any, bool freeImg = true) ;
    00194
    00195     AnyData(const AnyData &src);
    00196     AnyData& operator = (const AnyData &src);
    00197
    00198     OCIAnyData* getOCIAnyData() const;
    00199     const Connection* getConnection() const;
    00200
    00201
    00202     bool isNull() const ;
    00203     void setNull() ;
    00204     OCCI_STD_NAMESPACE::string getString() const ;
    00205     UString getUString() const ;
    00206     Blob getBlob() const ;
    00207     Clob getClob() const ;
    00208     Bfile getBfile() const ;
    00209     BFloat  getBFloat() const ;
    00210     BDouble getBDouble() const ;
    00211     Number getNumber() const ;
    00212     Bytes getBytes() const ;
    00213     Date getDate() const ;
    00214     Timestamp getTimestamp() const ;
    00215     IntervalYM getIntervalYM() const ;
    00216     IntervalDS getIntervalDS() const ;
    00217     PObject *getObject(void *(*rSQL)(void *)) const ;
    00218     RefAny getRef() const ;
    00219
    00220     void setString(const OCCI_STD_NAMESPACE::string &str)  ;
    00221     void setUString(const UString &str)  ;
    00222     void setBlob(const Blob &blob) ;
    00223     void setClob(const Clob &clob) ;
    00224     void setBfile(const Bfile &bfile) ;
    00225     void setBFloat(const BFloat &n) ;
    00226     void setBDouble(const BDouble &n) ;
    00227     void setNumber(const Number &n) ;
    00228     void setBytes(const Bytes &bytes) ;
    00229     void setDate(const Date &date) ;
    00230     void setTimestamp(const Timestamp &timestamp)  ;
    00231     void setIntervalYM(const IntervalYM &intervalym)  ;
    00232     void setIntervalDS(const IntervalDS &intervalds)  ;
    00233     void setObject(const PObject *objptr) ;
    00234     void setRef(const RefAny &ref) ;
    00235
    00236     void setFromString(const OCCI_STD_NAMESPACE::string &str)  ;
    00237     void setFromBfile(const Bfile &bfile) ;
    00238     void setFromBFloat(const BFloat &n) ;
    00239     void setFromBDouble(const BDouble &n) ;
    00240     void setFromNumber(const Number &n) ;
    00241     void setFromBytes(const Bytes &bytes) ;
    00242     void setFromDate(const Date &date) ;
    00243     void setFromTimestamp(const Timestamp &timestamp)  ;
    00244     void setFromIntervalYM(const IntervalYM &intervalym)  ;
    00245     void setFromIntervalDS(const IntervalDS &intervalds)  ;
    00246     void setFromObject(const PObject *objptr) ;
    00247     void setFromRef(const RefAny &ref,
    00248                     const OCCI_STD_NAMESPACE::string &typname,
    00249                     const OCCI_STD_NAMESPACE::string &schname) ;
    00250
    00251     OCCI_STD_NAMESPACE::string getAsString() const ;
    00252     Bfile getAsBfile() const ;
    00253     BFloat  getAsBFloat() const ;
    00254     BDouble getAsBDouble() const ;
    00255     Number getAsNumber() const ;
    00256     Bytes getAsBytes() const ;
    00257     Date getAsDate() const ;
    00258     Timestamp getAsTimestamp() const ;
    00259     IntervalYM getAsIntervalYM() const ;
    00260     IntervalDS getAsIntervalDS() const ;
    00261     PObject *getAsObject() const ;
    00262     RefAny getAsRef() const ;
    00263
    00264     TypeCode getType() const;
    00265
    00266     private:
    00267
    00268
    00269     // private data members
    00270     Ptr<AnyDataImpl> anyDataImplPtr;
    00271
    00272
    00273 };
    00274
    00275 template <class T>
    00276 class Ref
    00277 {
    00278   public:
    00279
    00280   Ref();
    00281   Ref(const T *obj) ;
    00282   Ref(const RefAny &refAny) ;
    00283   Ref(const Ref<T> &src) ;
    00284   Ref(const Connection *sessp, OCIRef *tref, bool copy=TRUE)
    00285   ;
    00286  ~Ref();
    00287   Ref<T>& operator=(const Ref<T> &src)
    00288   ;
    00289   Ref<T>& operator=(const T *obj) ;
    00290   Ref<T>& operator=(const RefAny &src);
    00291   T * operator->() ;
    00292   T * ptr() ;
    00293   T & operator *() ;
    00294   const T * operator->() const;
    00295   const T * ptr()  const;
    00296   const T & operator *() const ;
    00297   void markDelete() ;
    00298   void unmarkDelete() ;
    00299   void setNull();
    00300   bool isNull() const;
    00301   void clear() ;
    00302   bool isClear() const;
    00303   void setPrefetch(const OCCI_STD_NAMESPACE::string &typeName,
    00304                    unsigned int depth);
    00305   void setPrefetch(const OCCI_STD_NAMESPACE::string &schName,
    00306                    const OCCI_STD_NAMESPACE::string &typeName,
    00307                    unsigned int depth);
    00308   void setPrefetch(const UString &schName,
    00309                    const UString &typeName,
    00310                    unsigned int depth);
    00311   void setPrefetch(unsigned int depth) ;
    00312   void setLock(LockOptions );
    00313   operator RefAny() const;
    00314   OCIRef *getRef() const;
    00315   const Connection *getConnection() const;
    00316   bool operator == (const Ref<T> &ref) const;
    00317   bool operator != (const Ref<T> &ref) const;
    00318   bool operator == (const RefAny &refAnyR) const ;
    00319   bool operator != (const RefAny &refAnyR) const ;
    00320   OCIComplexObject *getCor() const;
    00321   void destroy();
    00322   void setPinnedObject(PObject *objPtr);
    00323  private:
    00324
    00325   RefImpl  *rimplPtr;
    00326 };
    00327
    00328
    00329 class RefImpl
    00330 {
    00331   public:
    00332
    00333   RefImpl();
    00334   RefImpl(PObject *obj) ;
    00335   RefImpl(const RefAny &refAny) ;
    00336   RefImpl(const RefImpl &src) ;
    00337   RefImpl(const Connection *sessp, OCIRef *tref,
    00338   bool copy=TRUE) ;
    00339   ~RefImpl();
    00340   bool isNull() const ;
    00341   void setNull() ;
    00342   void markDelete() ;
    00343   void unmarkDelete() ;
    00344   void clear() ;
    00345   bool isClear() const ;
    00346   void setPrefetch(const OCCI_STD_NAMESPACE::string &typeName,
    00347                    unsigned int depth) ;
    00348   void setPrefetch(const OCCI_STD_NAMESPACE::string &schName,
    00349                    const OCCI_STD_NAMESPACE::string &typeName,
    00350                    unsigned int depth);
    00351   void setPrefetch(const UString &schName,
    00352                    const UString &typeName,
    00353                    unsigned int depth);
    00354   void setPrefetch(unsigned int depth) ;
    00355   void setLock(LockOptions lckOption) ;
    00356   PObject *pin() ;
    00357   void unpin(PObject *obj) ;
    00358   void setRefFromObjPtr(const PObject *obj) ;
    00359   OCIRef* getRef() const;
    00360   void setRefImpl(RefImpl *rptr);
    00361   const Connection * getConnection() const;
    00362   bool operator == (const RefImpl &refI) const ;
    00363   bool operator == (const RefAny &refAnyR) const ;
    00364   void assignObj(PObject *newObjPtr) ;
    00365   void assignRefAny(const RefAny &src) ;
    00366   // added following methods
    00367   bool isEqual(PObject *obj);
    00368   void operator = ( const RefImpl &src);
    00369   void destroy();
    00370   OCIComplexObject *getCor() const;
    00371   void setPinnedObject( PObject *objPtr);
    00372  private:
    00373
    00374   OCIRef *ref;
    00375   const ConnectionImpl *sessp;
    00376   OCIComplexObject *corhp;
    00377   OCCI_STD_NAMESPACE::list<void *> descriptorList;
    00378   LockOptions lockOption;
    00379   // added data member for object header
    00380   dvoid *objHeader;
    00381   //common implementation function for setPrefetch
    00382   void do_setPrefetch(void *schName, unsigned int schNameLen,
    00383                       void *typeName, unsigned int typeNameLen,
    00384                       unsigned int depth);
    00385 };
    00386
    00387
    00388 class RefAny
    00389 {
    00390   public:
    00391
    00392   RefAny();
    00393   RefAny (const Connection *sessptr, const OCIRef *ref);
    00394   RefAny (const Connection *sessptr, const OCIRef *ref, bool isowner);
    00395   ~RefAny() ;
    00396   RefAny(const RefAny& src) ;
    00397   RefAny& operator=(const RefAny& src) ;
    00398   void markDelete() ;
    00399   void unmarkDelete() ;
    00400   void clear() ;
    00401   bool isNull() const;
    00402   OCIRef * getRef() const;
    00403   const Connection * getConnection() const;
    00404   bool operator == (const RefAny &refAnyR) const;
    00405   bool operator != (const RefAny &refAnyR) const;
    00406   bool isOwner() const;
    00407
    00408   private:
    00409
    00410   OCIRef *ref;
    00411   const ConnectionImpl *sessp;
    00412   // for future use
    00413   void *refanyExt;
    00414   bool owner;
    00415
    00416   friend RefAny MetaData::getRef(MetaData::AttrId) const;
    00417   friend RefAny PObject::getRef() const;
    00418   friend class AnyDataImpl;
    00419   friend class ResultSetImpl;
    00420   friend class StatementImpl;
    00421   friend void getVector(const ResultSet  *rs,
    00422                         unsigned int colIndex,
    00423                         OCCI_STD_NAMESPACE::vector<RefAny> &vect) ;
    00424   friend void getVector(const Statement  *stmt,
    00425                         unsigned int colIndex,
    00426                         OCCI_STD_NAMESPACE::vector<RefAny> &vect) ;
    00427 };
    00428
    00429 template <class T>
    00430 Ref<T>::Ref()
    00431 {
    00432    rimplPtr = new RefImpl();
    00433 }
    00434
    00435 template <class T>
    00436 Ref<T>::Ref(const T *obj)
    00437 {
    00438    rimplPtr = new RefImpl((PObject *)obj);
    00439 }
    00440
    00441 template <class T>
    00442 Ref<T>::Ref(const RefAny &refAny)
    00443
    00444 {
    00445   rimplPtr = new RefImpl(refAny);
    00446 }
    00447
    00448 template <class T>
    00449 Ref<T>::Ref(const Ref<T>& src)
    00450
    00451 {
    00452     rimplPtr = new RefImpl(*(src.rimplPtr));
    00453 }
    00454
    00455 template <class T>
    00456 Ref<T>::Ref(const Connection *sessp, OCIRef *tref, bool copy)
    00457
    00458 {
    00459    rimplPtr = new RefImpl(sessp, tref, copy);
    00460 }
    00461
    00462 template <class T>
    00463 Ref<T>::~Ref()
    00464 {
    00465   delete rimplPtr;
    00466 }
    00467
    00468
    00469 template <class T>
    00470 Ref<T>& Ref<T>::operator=(const Ref<T> &src)
    00471 {
    00472    if (&src == this)
    00473      return *this;
    00474    *rimplPtr = *(src.rimplPtr);
    00475    return *this;
    00476 }
    00477
    00478 template <class T>
    00479 Ref<T>& Ref<T>::operator=(const T *obj)
    00480 {
    00481   if (rimplPtr->isEqual((PObject *)obj))
    00482     return *this;
    00483   rimplPtr->assignObj((PObject *)obj);
    00484   return *this;
    00485 }
    00486
    00487 template <class T>
    00488 Ref<T>& Ref<T>::operator=(const RefAny &src)
    00489 {
    00490   rimplPtr->assignRefAny(src);
    00491   return *this;
    00492 }
    00493
    00494 template <class T>
    00495 T* Ref<T>::operator->()
    00496 {
    00497   return ((T *)rimplPtr->pin());
    00498 }
    00499
    00500 template <class T>
    00501 T* Ref<T>::ptr()
    00502 {
    00503   return ((T *)rimplPtr->pin());
    00504 }
    00505
    00506 template <class T>
    00507 T& Ref<T>::operator * ()
    00508 {
    00509   return ((T &)(*(rimplPtr->pin())));
    00510 }
    00511
    00512 template <class T>
    00513 const T* Ref<T>::operator->() const
    00514 {
    00515   return ((const T *)rimplPtr->pin());
    00516 }
    00517
    00518 template <class T>
    00519 const T* Ref<T>::ptr() const
    00520 {
    00521   return ((const T *)rimplPtr->pin());
    00522 }
    00523
    00524 template <class T>
    00525 const T& Ref<T>::operator * () const
    00526 {
    00527   return ((const T &)(*(rimplPtr->pin())));
    00528 }
    00529
    00530 template <class T>
    00531 void Ref<T>::markDelete ()
    00532 {
    00533    rimplPtr->markDelete();
    00534 }
    00535
    00536 template <class T>
    00537 void Ref<T>::unmarkDelete ()
    00538 {
    00539    rimplPtr->unmarkDelete();
    00540 }
    00541
    00542 template <class T>
    00543 void Ref<T>::setNull()
    00544 {
    00545    rimplPtr->setNull();
    00546 }
    00547
    00548 template <class T>
    00549 bool Ref<T>::isNull() const
    00550 {
    00551   return rimplPtr->isNull();
    00552 }
    00553
    00554 template <class T>
    00555 void Ref<T>::clear ()
    00556 {
    00557    rimplPtr->clear();
    00558 }
    00559
    00560 template <class T>
    00561 bool Ref<T>::isClear() const
    00562 {
    00563    return rimplPtr->isClear();
    00564 }
    00565
    00566 template <class T>
    00567 void Ref<T>::setPrefetch (const OCCI_STD_NAMESPACE::string &typeName,
    00568 unsigned int depth)
    00569
    00570 {
    00571   rimplPtr->setPrefetch(typeName,depth);
    00572 }
    00573
    00574 template <class T>
    00575 void Ref<T>::setPrefetch (const OCCI_STD_NAMESPACE::string &schemaName,
    00576 const OCCI_STD_NAMESPACE::string &typeName,
    00577 unsigned int depth)
    00578
    00579 {
    00580   rimplPtr->setPrefetch(schemaName,typeName,depth);
    00581 }
    00582
    00583 template <class T>
    00584 void Ref<T>::setPrefetch (const UString &schemaName,
    00585 const UString &typeName,
    00586 unsigned int depth)
    00587
    00588 {
    00589   rimplPtr->setPrefetch(schemaName,typeName,depth);
    00590 }
    00591
    00592 template <class T>
    00593 void Ref<T>::setPrefetch (unsigned int depth)
    00594
    00595 {
    00596   rimplPtr->setPrefetch(depth);
    00597 }
    00598
    00599 template <class T>
    00600 void Ref<T>::setLock (LockOptions lckOption)
    00601 {
    00602   rimplPtr->setLock(lckOption);
    00603 }
    00604
    00605 template <class T>
    00606 OCIRef* Ref<T>::getRef() const
    00607 {
    00608   return (rimplPtr->getRef());
    00609 }
    00610
    00611 template<class T>
    00612 const Connection* Ref<T>::getConnection () const
    00613 {
    00614   return (rimplPtr->getConnection());
    00615 }
    00616
    00617 template <class T>
    00618 Ref<T>::operator RefAny () const
    00619 {
    00620   if (isNull())
    00621     return  RefAny();
    00622   return (RefAny(rimplPtr->getConnection(), rimplPtr->getRef()));
    00623 }
    00624
    00625 template <class T>
    00626 bool Ref<T>::operator ==(const Ref<T> &ref) const
    00627
    00628 {
    00629   return ( (*rimplPtr) == (*(ref.rimplPtr)) );
    00630 }
    00631
    00632 template <class T>
    00633 bool Ref<T>::operator !=(const Ref<T> &ref) const
    00634
    00635 {
    00636   return ( !((*rimplPtr) == (*(ref.rimplPtr))) );
    00637 }
    00638
    00639 template <class T>
    00640 bool Ref<T>::operator == (const RefAny & refAnyR) const
    00641
    00642 {
    00643   return ( (*rimplPtr) == refAnyR );
    00644 }
    00645
    00646 template <class T>
    00647 bool Ref<T>::operator != (const RefAny & refAnyR) const
    00648
    00649 {
    00650   return ( !((*rimplPtr) == refAnyR ));
    00651 }
    00652
    00653 template <class T>
    00654 void Ref<T>::destroy()
    00655 {
    00656    rimplPtr->destroy();
    00657 }
    00658
    00659 template <class T>
    00660 OCIComplexObject * Ref<T>::getCor() const
    00661 {
    00662   return (rimplPtr->getCor());
    00663 }
    00664
    00665 template < class T>
    00666 void Ref<T>::setPinnedObject( PObject *objPtr)
    00667 {
    00668    rimplPtr->setPinnedObject(objPtr);
    00669 }
    00670
    00671 /*---------------------------------------------------------------------------
    00672                 PROTOTYPES USED BY FUNCTION TEMPLATES
    00673  ---------------------------------------------------------------------------*/
    00674   void getVectorOfOCIRefs( const AnyData &any,
    00675   OCCI_STD_NAMESPACE::vector<void *> &vect);
    00676   void getVectorOfPObjects( const AnyData &any,
    00677   OCCI_STD_NAMESPACE::vector< PObject* > &vect,
    00678   void *(*rSQL)(void *))  ;
    00679   void setVectorOfOCIRefs( AnyData &any,
    00680   const OCCI_STD_NAMESPACE::vector<void *> &vect,
    00681   const OCCI_STD_NAMESPACE::vector< OCIInd> &vec_ind) ;
    00682   void setVectorOfPObjects( AnyData &any,
    00683   const OCCI_STD_NAMESPACE::vector< PObject* > &vect) ;
    00684
    00685 /*---------------------------------------------------------------------------
    00686                            EXPORT FUNCTIONS
    00687   ---------------------------------------------------------------------------*/
    00688
    00689 /*------------------- getVector for POBject----------------------------*/
    00690 /*
    00691    NAME
    00692       getVector - overloaded function. Retrieves the attribute in the
    00693    current position as a vector of PObject
    00694
    00695    PARAMETERS
    00696       any - AnyData
    00697       vect- reference to vector of PObject (OUT parameter).
    00698
    00699    DESCRIPTION
    00700    Retrieves the attribute in the current position as a vector
    00701    of PObject
    00702    The attribute at the current position should be a collection
    00703    type (varray or nested table). The SQL type of the elements in
    00704    the collection should be compatible with PObject
    00705
    00706    RETURNS
    00707      nothing
    00708
    00709    NOTES
    00710      compatible SQL types : user defined types (SQLT_NTY) etc.
    00711 */
    00712
    00713 #ifdef WIN32COMMON
    00714 // and other platforms that do not support
    00715 // partial function template specialization
    00716  template <class T>
    00717  void getVector(const AnyData &any, OCCI_STD_NAMESPACE::vector<T> &vect,
    00718  void *(*rSQL)(void *))
    00719  {
    00720    OCCI_STD_NAMESPACE::vector< PObject *> vec_pobj;
    00721    getVectorOfPObjects( any, vec_pobj, rSQL);
    00722
    00723    vect.clear();
    00724    unsigned int size= vec_pobj.size();
    00725    vect.reserve( size );
    00726    for( unsigned int i=0; i< size; i++)
    00727       vect.push_back( (T)vec_pobj[i] );
    00728  }
    00729 #else
    00730  template <class T>
    00731  void getVector(const AnyData &any, OCCI_STD_NAMESPACE::vector<T*> &vect,
    00732  void *(*rSQL)(void *))
    00733  {
    00734    OCCI_STD_NAMESPACE::vector< PObject *> vec_pobj;
    00735    getVectorOfPObjects( any, vec_pobj, rSQL);
    00736
    00737    vect.clear();
    00738    unsigned int size= vec_pobj.size();
    00739    vect.reserve( size );
    00740    for( unsigned int i=0; i< size; i++)
    00741       vect.push_back( (T*)vec_pobj[i] );
    00742  }
    00743 #endif /* end of #ifdef WIN32COMMON */
    00744
    00745  /*------------------- getVector for Ref<T>----------------------------*/
    00746 /*
    00747    NAME
    00748       getVector - overloaded function. Retrieves the attribute in the
    00749    current position as a vector of PObject
    00750
    00751    PARAMETERS
    00752       any - AnyData
    00753       vect- reference to vector of PObject (OUT parameter).
    00754
    00755    DESCRIPTION
    00756    Retrieves the attribute in the current position as a vector
    00757    of PObject
    00758    The attribute at the current position should be a collection
    00759    type (varray or nested table). The SQL type of the elements in
    00760    the collection should be compatible with PObject
    00761
    00762    RETURNS
    00763      nothing
    00764
    00765    NOTES
    00766      compatible SQL types : user defined types (SQLT_NTY) etc.
    00767 */
    00768 #ifndef WIN32COMMON
    00769  template <class T>
    00770  void getVector(const AnyData &any,OCCI_STD_NAMESPACE::vector< Ref<T> > &vect)
    00771  {
    00772    OCCI_STD_NAMESPACE::vector< void *> vec_ref;
    00773    getVectorOfOCIRefs( any, vec_ref);
    00774
    00775    vect.clear();
    00776    unsigned int size = vec_ref.size();
    00777    vect.reserve( size );
    00778    const Connection *sess = any.getConnection();
    00779
    00780    for (unsigned int i=0; i< size; i++)
    00781    {
    00782      if (vec_ref[i] == (OCIRef *)0)
    00783        vect.push_back(Ref<T>());     // pushing a default-constructed Ref
    00784      else
    00785        vect.push_back(Ref<T>(sess, (OCIRef *)vec_ref[i], FALSE));
    00786    }
    00787  }
    00788 #endif /* end of #ifndef WIN32COMMON  */
    00789
    00790 /*-----------------------setVector for PObject--------------------------*/
    00791 /*
    00792    NAME
    00793      setVector - overloaded function. sets the attribute in the current
    00794    position of anydata with the vector elements.
    00795
    00796    PARAMETERS
    00797       none.
    00798
    00799    DESCRIPTION
    00800       sets the attribute in the current position in anydata with the
    00801    vector elements.
    00802   The attribute in the current position of anydata should be a
    00803   collection type. If the collection type is a varray, the input vector
    00804   size should be equal to the size of the varray. Also the SQL type of
    00805   the collection's elements should be compatible with PObject.
    00806
    00807    RETURNS
    00808      nothing.
    00809
    00810    NOTES
    00811      compatible SQL types : SQLT_NTY  (user defined types).
    00812 */
    00813 #ifdef WIN32COMMON
    00814 // and other platforms that do not support
    00815 // partial function template specialization
    00816
    00817  template <class T>
    00818  void setVector(AnyData &any, const OCCI_STD_NAMESPACE::vector<T> &vect)
    00819  {
    00820    OCCI_STD_NAMESPACE::vector< PObject *> vec_pobj;
    00821    unsigned int size= vect.size();
    00822    vec_pobj.reserve( size );
    00823    for( unsigned int i=0; i< size; i++)
    00824       vec_pobj.push_back( vect[i] );
    00825    setVectorOfPObjects( any, vec_pobj);
    00826
    00827  }
    00828
    00829 #else
    00830
    00831  template <class T>
    00832  void setVector(AnyData &any, const OCCI_STD_NAMESPACE::vector<T*> &vect)
    00833  {
    00834    OCCI_STD_NAMESPACE::vector< PObject *> vec_pobj;
    00835    unsigned int size= vect.size();
    00836    vec_pobj.reserve( size );
    00837    for( unsigned int i=0; i< size; i++)
    00838       vec_pobj.push_back( vect[i] );
    00839    setVectorOfPObjects( any, vec_pobj);
    00840
    00841  }
    00842 #endif /* end of #ifdef WIN32COMMON */
    00843
    00844 /*-----------------------setVector for Ref<T>--------------------------*/
    00845 /*
    00846    NAME
    00847      setVector - overloaded function. sets the attribute in the current
    00848    position of anydata with the vector elements.
    00849
    00850    PARAMETERS
    00851       none.
    00852
    00853    DESCRIPTION
    00854       sets the attribute in the current position in anydata with the
    00855    vector elements.
    00856   The attribute in the current position of anydata should be a
    00857   collection type. If the collection type is a varray, the input vector
    00858   size should be equal to the size of the varray. Also the SQL type of
    00859   the collection's elements should be compatible with PObject.
    00860
    00861    RETURNS
    00862      nothing.
    00863
    00864    NOTES
    00865      compatible SQL types : SQLT_NTY  (user defined types).
    00866 */
    00867 #ifndef WIN32COMMON
    00868  template <class T>
    00869  void setVector(AnyData &any, const OCCI_STD_NAMESPACE::vector< Ref<T> > &vect)
    00870  {
    00871    OCCI_STD_NAMESPACE::vector< void *> vec_ref;
    00872    OCCI_STD_NAMESPACE::vector<OCIInd> vec_ind;
    00873
    00874    unsigned int size= vect.size();
    00875    vec_ref.reserve( size );
    00876    vec_ind.reserve( size );
    00877    for( unsigned int i=0; i< size; i++)
    00878    {
    00879       vec_ref.push_back( vect[i].getRef() );
    00880       vec_ind.push_back(vect[i].isNull() ? OCI_IND_NULL : OCI_IND_NOTNULL);
    00881    }
    00882    setVectorOfOCIRefs( any, vec_ref, vec_ind);
    00883
    00884  }
    00885 #endif  /* end of #ifndef WIN32COMMON */
    00886
    00887 // Platform independent get/setVectorOfRefs method added
    00888 // get(set)Vector of Ref<T> and get(set)VectorOfRefs are identical
    00889 // in functionality.
    00890
    00891  /*------------------- getVectorOfRefs for Ref<T>----------------------------*/
    00892 /*
    00893    NAME
    00894       getVectorOfRefs - overloaded function. Retrieves the attribute in the
    00895    current position as a vector of PObject
    00896
    00897    PARAMETERS
    00898       any - AnyData
    00899       vect- reference to vector of PObject (OUT parameter).
    00900
    00901    DESCRIPTION
    00902    Retrieves the attribute in the current position as a vector
    00903    of PObject
    00904    The attribute at the current position should be a collection
    00905    type (varray or nested table). The SQL type of the elements in
    00906    the collection should be compatible with PObject
    00907
    00908    RETURNS
    00909      nothing
    00910
    00911    NOTES
    00912      compatible SQL types : user defined types (SQLT_NTY) etc.
    00913 */
    00914
    00915  template <class T>
    00916  void getVectorOfRefs(const AnyData &any,
    00917                       OCCI_STD_NAMESPACE::vector< Ref<T> > &vect)
    00918  {
    00919    OCCI_STD_NAMESPACE::vector< void *> vec_ref;
    00920    getVectorOfOCIRefs( any, vec_ref);
    00921
    00922    vect.clear();
    00923    unsigned int size = vec_ref.size();
    00924    vect.reserve( size );
    00925    const Connection *sess = any.getConnection();
    00926
    00927    for (unsigned int i=0; i< size; i++)
    00928    {
    00929      if (vec_ref[i] == (OCIRef *)0)
    00930        vect.push_back(Ref<T>());     // pushing a default-constructed Ref
    00931      else
    00932        vect.push_back(Ref<T>(sess, (OCIRef *)vec_ref[i], FALSE));
    00933    }
    00934  }
    00935
    00936 /*-----------------------setVectorOfRefs for Ref<T>--------------------------*/
    00937 /*
    00938    NAME
    00939      setVectorOfRefs - overloaded function. sets the attribute in the current
    00940    position of anydata with the vector elements.
    00941
    00942    PARAMETERS
    00943       none.
    00944
    00945    DESCRIPTION
    00946       sets the attribute in the current position in anydata with the
    00947    vector elements.
    00948   The attribute in the current position of anydata should be a
    00949   collection type. If the collection type is a varray, the input vector
    00950   size should be equal to the size of the varray. Also the SQL type of
    00951   the collection's elements should be compatible with PObject.
    00952
    00953    RETURNS
    00954      nothing.
    00955
    00956    NOTES
    00957      compatible SQL types : SQLT_NTY  (user defined types).
    00958 */
    00959
    00960  template <class T>
    00961  void setVectorOfRefs(AnyData &any,
    00962                       const OCCI_STD_NAMESPACE::vector< Ref<T> > &vect)
    00963
    00964  {
    00965    OCCI_STD_NAMESPACE::vector< void *> vec_ref;
    00966    OCCI_STD_NAMESPACE::vector<OCIInd> vec_ind;
    00967
    00968    unsigned int size= vect.size();
    00969    vec_ref.reserve( size );
    00970    vec_ind.reserve( size );
    00971    for( unsigned int i=0; i< size; i++)
    00972    {
    00973       vec_ref.push_back( vect[i].getRef() );
    00974       vec_ind.push_back(vect[i].isNull() ? OCI_IND_NULL : OCI_IND_NOTNULL);
    00975    }
    00976    setVectorOfOCIRefs( any, vec_ref, vec_ind);
    00977
    00978  }
    00979
    00980
    00981 /*---------------------------------------------------------------------------
    00982                           INTERNAL FUNCTIONS
    00983   ---------------------------------------------------------------------------*/
    00984
    00985
    00986 } /* end of namespace occi */
    00987 } /* end of namespace oracle */
    00988 #endif                                              /* OCCIOBJECTS_ORACLE */
    00989
    00990 #endif                                              /* _olint */

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines