00001
00002
00003
00004
00005
00006
00007
00008 #define DBCNV_DBFEDERATION_CPP
00009
00010
00011 #include "GaudiDb/DbFederation.h"
00012 #include "GaudiDb/DbObject.h"
00013 #include "DbDataBaseObj.h"
00014 #include "DbContainerObj.h"
00015 #include "DbFederationObj.h"
00016
00017
00018 dbHandle<DbFederation>::dbHandle(DbFederation* fed) {
00019 switchPtr( fed );
00020 if ( fed ) {
00021 m_name = fed->name();
00022 m_mode = fed->mode();
00023 m_type = fed->type();
00024 }
00025 }
00026
00027
00028 long dbHandle<DbFederation>::addRef() const {
00029 if ( isValid() ) {
00030 return m_ptr->addRef();
00031 }
00032 return -1;
00033 }
00034
00035
00036 long dbHandle<DbFederation>::release() const {
00037 if ( isValid() ) {
00038 long cnt = m_ptr->release();
00039 if ( 0 >= cnt ) {
00040 m_ptr = 0;
00041 }
00042 return cnt;
00043 }
00044 return -1;
00045 }
00046
00047 const char* dbHandle<DbFederation>::typeName() const {
00048 return "DbFederation";
00049 }
00050
00051 DbResult dbHandle<DbFederation>::open(const dbHandle<DbSession>& sessionH, const std::string& name, DbAccessMode mode) const {
00052 if ( sessionH.isValid() ) {
00053 DbFederation* fed = sessionH.find(name);
00054 m_mode = mode;
00055 if ( !fed ) {
00056 fed = new DbFederation(sessionH, name, m_mode);
00057 }
00058 switchPtr(fed);
00059 m_name = name;
00060 return fed->open();
00061 }
00062 close();
00063 return DbOOMs::DbError;
00064 }
00065
00066 DbResult dbHandle<DbFederation>::close() const {
00067 if ( isValid() ) {
00068 m_ptr->close();
00069 }
00070 m_name = "";
00071 m_mode = DbOOMs::READ;
00072 switchPtr(0);
00073 return DbOOMs::DbSuccess;
00074 }
00075
00076 bool dbHandle<DbFederation>::exist(const dbHandle<DbSession>& sessionH, const std::string& name) const {
00077 if ( sessionH.isValid() ) {
00078 dbHandle<DbFederation> p = sessionH.find(name);
00079 return p.isValid();
00080 }
00081 return false;
00082 }
00083
00084 dbHandle<DbSession> dbHandle<DbFederation>::containedIn() const {
00085 if ( isValid() ) {
00086 return m_ptr->session();
00087 }
00088 dbHandle<DbSession> handle(type());
00089 return handle;
00090 }
00091
00093 void dbHandle<DbFederation>::switchPtr(dbHandle<DbFederation>::_DataType* obj) const {
00094 if ( obj ) obj->addRef();
00095 if ( m_ptr ) m_ptr->release();
00096 m_ptr = obj;
00097 if ( m_ptr ) {
00098 m_type = obj->type();
00099 }
00100 }
00101
00102
00103 DbResult dbHandle<DbFederation>::add(const std::string& name, DbDataBase* dbH) const {
00104 if ( isValid() && dbH ) {
00105 return m_ptr->add( name, dbH );
00106 }
00107 return DbOOMs::DbError;
00108 }
00109
00110
00111 DbDataBase* dbHandle<DbFederation>::find(const std::string& name) const {
00112 if ( isValid() ) {
00113 return m_ptr->find(name);
00114 }
00115 return 0;
00116 }
00117
00118
00119 DbResult dbHandle<DbFederation>::remove(DbDataBase* dbH) const {
00120 if ( isValid() ) {
00121 return m_ptr->remove(dbH) ? DbOOMs::DbSuccess : DbOOMs::DbError;
00122 }
00123 return DbOOMs::DbError;
00124 }
00125
00127 bool dbHandle<DbFederation>::existsDbase( const std::string& name ) const {
00128 if ( isValid() ) {
00129 return m_ptr->existsDbase(name);
00130 }
00131 return false;
00132 }
00133
00134
00135 IDbFederation* dbHandle<DbFederation>::info() const {
00136 if ( isValid() ) {
00137 return m_ptr->info();
00138 }
00139 return 0;
00140 }
00141
00142
00143 IOODataBase* dbHandle<DbFederation>::db() {
00144 if ( isValid() ) {
00145 return m_ptr->db();
00146 }
00147 return 0;
00148 }
00149
00150
00151 IMessageSvc* dbHandle<DbFederation>::msgSvc() {
00152 if ( isValid() ) {
00153 return m_ptr->msgSvc();
00154 }
00155 return 0;
00156 }