00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "BaBar/BaBar.hh"
00010
00011 #include "CdbBdbShared/CdbBdbSDatabase.hh"
00012
00013 #include "CdbBase/Cdb.hh"
00014 #include "CdbBase/CdbView.hh"
00015 #include "CdbBase/CdbId.hh"
00016 #include "CdbBase/CdbCompositeName.hh"
00017 #include "CdbBase/CdbEnvironment.hh"
00018 #include "CdbBase/CdbPartition.hh"
00019 #include "CdbBase/CdbProperty.hh"
00020 #include "CdbBase/CdbOrigin.hh"
00021 #include "CdbBase/CdbFolder.hh"
00022 #include "CdbBase/CdbCondition.hh"
00023 #include "CdbBase/CdbSimpleVectorAdapterItr.hh"
00024
00025 #include "CdbBdbShared/CdbBdbSOriginP.hh"
00026 #include "CdbBdbShared/CdbBdbSView.hh"
00027 #include "CdbBdbShared/CdbBdbSViewItr.hh"
00028 #include "CdbBdbShared/CdbBdbSPartitionsLayoutP.hh"
00029 #include "CdbBdbShared/CdbBdbSPartitionP.hh"
00030 #include "CdbBdbShared/CdbBdbSCondition.hh"
00031
00032 #include <iostream>
00033 using std::cout;
00034 using std::cerr;
00035 using std::endl;
00036
00037 namespace {
00038
00039
00040
00041
00042
00043
00044
00045
00046 class CdbBdbSPartitionItr : public CdbItr<unsigned short>::InterfaceType {
00047
00048 private:
00049
00050
00051
00052
00053 CdbBdbSPartitionItr( );
00054
00055 public:
00056
00057
00058
00059
00060 CdbBdbSPartitionItr( const CdbItr<d_UShort>& theInputItr );
00061
00062
00063
00064
00065
00066 CdbBdbSPartitionItr( const CdbBdbSPartitionItr& theItr );
00067
00068
00069
00070
00071
00072 CdbBdbSPartitionItr& operator=( const CdbBdbSPartitionItr& theItr );
00073
00074
00075
00076
00077
00078 virtual ~CdbBdbSPartitionItr( );
00079
00080
00081
00082
00083
00084
00085
00086
00087 virtual CdbStatus reset( );
00088
00089
00090
00091
00092
00093
00094
00095 virtual bool next( );
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106 virtual ValueType value( );
00107
00108
00109
00110
00111
00112
00113
00114 virtual bool isValid( );
00115
00116
00117
00118
00119
00120 virtual InterfaceType* clone( ) const;
00121
00122 private:
00123
00124 CdbItr<d_UShort> _itr;
00125 };
00126
00127 CdbBdbSPartitionItr::CdbBdbSPartitionItr( const CdbItr<d_UShort>& theInputItr ) :
00128 _itr(theInputItr)
00129 { }
00130
00131 CdbBdbSPartitionItr::CdbBdbSPartitionItr( const CdbBdbSPartitionItr& theItr ) :
00132 _itr(theItr._itr)
00133 { }
00134
00135 CdbBdbSPartitionItr::~CdbBdbSPartitionItr( )
00136 { }
00137
00138 CdbBdbSPartitionItr&
00139 CdbBdbSPartitionItr::operator=( const CdbBdbSPartitionItr& theItr )
00140 {
00141 if( this != &theItr ) {
00142 _itr = theItr._itr;
00143 }
00144 return *this;
00145 }
00146
00147 CdbStatus
00148 CdbBdbSPartitionItr::reset( )
00149 {
00150 return _itr.reset( );
00151 }
00152
00153 bool
00154 CdbBdbSPartitionItr::next( )
00155 {
00156 return _itr.next( );
00157 }
00158
00159 CdbBdbSPartitionItr::ValueType
00160 CdbBdbSPartitionItr::value( )
00161 {
00162 return _itr.value( );
00163 }
00164
00165 bool
00166 CdbBdbSPartitionItr::isValid( )
00167 {
00168 return _itr.isValid( );
00169 }
00170
00171 CdbBdbSPartitionItr::InterfaceType*
00172 CdbBdbSPartitionItr::clone( ) const
00173 {
00174 return new CdbBdbSPartitionItr( *this );
00175 }
00176
00177
00178
00179
00180
00181 class CdbBdbSPartition : public CdbPartition {
00182
00183 private:
00184
00185
00186
00187
00188 CdbBdbSPartition( );
00189
00190
00191
00192
00193
00194 CdbBdbSPartition( const CdbBdbSPartition& thePartition );
00195
00196
00197
00198
00199
00200 CdbBdbSPartition& operator=( const CdbBdbSPartition& thePartition );
00201
00202 public:
00203
00204
00205
00206
00207 CdbBdbSPartition( const CdbDatabasePtr& theDatabasePtr,
00208 const BdbHandle(CdbBdbSPartitionP)& thePartitionH,
00209 unsigned short theOwnerId,
00210 const char* theOwnerName );
00211
00212
00213
00214
00215
00216 virtual ~CdbBdbSPartition( );
00217
00218
00219
00220
00221
00222
00223
00224 virtual BdbTime endInsertion( ) const;
00225
00226
00227
00228
00229
00230
00231
00232 virtual BdbTime modified( ) const;
00233
00234
00235
00236
00237
00238
00239
00240 virtual bool isClosed( ) const;
00241
00242
00243
00244
00245
00246
00247
00248 virtual bool isInstantiated( ) const;
00249
00250 private:
00251
00252 BdbHandle(CdbBdbSPartitionP) _partitionH;
00253 };
00254
00255 CdbBdbSPartition::CdbBdbSPartition( const CdbDatabasePtr& theDatabasePtr,
00256 const BdbHandle(CdbBdbSPartitionP)& thePartitionH,
00257 unsigned short theOwnerId,
00258 const char* theOwnerName ) :
00259 CdbPartition( theDatabasePtr,
00260 thePartitionH->id( ),
00261 theOwnerId,
00262 theOwnerName,
00263 thePartitionH->description( ).head( ),
00264 thePartitionH->created( ),
00265 thePartitionH->cell( ).beginValidity,
00266 thePartitionH->cell( ).endValidity,
00267 thePartitionH->cell( ).beginInsertion ),
00268 _partitionH(thePartitionH)
00269 { }
00270
00271 CdbBdbSPartition::~CdbBdbSPartition( )
00272 { }
00273
00274 BdbTime
00275 CdbBdbSPartition::endInsertion( ) const
00276 {
00277 return _partitionH->cell( ).endInsertion;
00278 }
00279
00280 BdbTime
00281 CdbBdbSPartition::modified( ) const
00282 {
00283 return _partitionH->modified( );
00284 }
00285
00286 bool
00287 CdbBdbSPartition::isClosed( ) const
00288 {
00289 return _partitionH->isClosed( );
00290 }
00291
00292 bool
00293 CdbBdbSPartition::isInstantiated( ) const
00294 {
00295 return _partitionH->isInstantiated( );
00296 }
00297
00298
00299
00300
00301
00302
00303
00304
00305 class CdbBdbSOriginItr : public CdbItr<unsigned short>::InterfaceType {
00306
00307 private:
00308
00309
00310
00311
00312 CdbBdbSOriginItr( );
00313
00314 public:
00315
00316
00317
00318
00319 CdbBdbSOriginItr( const CdbItr<d_UShort>& theInputItr );
00320
00321
00322
00323
00324
00325 CdbBdbSOriginItr( const CdbBdbSOriginItr& theItr );
00326
00327
00328
00329
00330
00331 CdbBdbSOriginItr& operator=( const CdbBdbSOriginItr& theItr );
00332
00333
00334
00335
00336
00337 virtual ~CdbBdbSOriginItr( );
00338
00339
00340
00341
00342
00343
00344
00345
00346 virtual CdbStatus reset( );
00347
00348
00349
00350
00351
00352
00353
00354 virtual bool next( );
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365 virtual ValueType value( );
00366
00367
00368
00369
00370
00371
00372
00373 virtual bool isValid( );
00374
00375
00376
00377
00378
00379 virtual InterfaceType* clone( ) const;
00380
00381 private:
00382
00383 CdbItr<d_UShort> _itr;
00384 };
00385
00386 CdbBdbSOriginItr::CdbBdbSOriginItr( const CdbItr<d_UShort>& theInputItr ) :
00387 _itr(theInputItr)
00388 { }
00389
00390 CdbBdbSOriginItr::CdbBdbSOriginItr( const CdbBdbSOriginItr& theItr ) :
00391 _itr(theItr._itr)
00392 { }
00393
00394 CdbBdbSOriginItr::~CdbBdbSOriginItr( )
00395 { }
00396
00397 CdbBdbSOriginItr&
00398 CdbBdbSOriginItr::operator=( const CdbBdbSOriginItr& theItr )
00399 {
00400 if( this != &theItr ) {
00401 _itr = theItr._itr;
00402 }
00403 return *this;
00404 }
00405
00406 CdbStatus
00407 CdbBdbSOriginItr::reset( )
00408 {
00409 return _itr.reset( );
00410 }
00411
00412 bool
00413 CdbBdbSOriginItr::next( )
00414 {
00415 return _itr.next( );
00416 }
00417
00418 CdbBdbSOriginItr::ValueType
00419 CdbBdbSOriginItr::value( )
00420 {
00421 return _itr.value( );
00422 }
00423
00424 bool
00425 CdbBdbSOriginItr::isValid( )
00426 {
00427 return _itr.isValid( );
00428 }
00429
00430 CdbBdbSOriginItr::InterfaceType*
00431 CdbBdbSOriginItr::clone( ) const
00432 {
00433 return new CdbBdbSOriginItr( *this );
00434 }
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445 class CdbBdbSOriginPropertyItr : public CdbItr<CdbProperty>::InterfaceType {
00446
00447 private:
00448
00449
00450
00451
00452 CdbBdbSOriginPropertyItr( );
00453
00454 public:
00455
00456
00457
00458
00459
00460 CdbBdbSOriginPropertyItr( const char* theDBIDRangeName );
00461
00462
00463
00464
00465
00466 CdbBdbSOriginPropertyItr( const CdbBdbSOriginPropertyItr& theItr );
00467
00468
00469
00470
00471
00472 CdbBdbSOriginPropertyItr& operator=( const CdbBdbSOriginPropertyItr& theItr );
00473
00474
00475
00476
00477
00478 virtual ~CdbBdbSOriginPropertyItr( );
00479
00480
00481
00482
00483
00484
00485
00486
00487 virtual CdbStatus reset( );
00488
00489
00490
00491
00492
00493
00494
00495 virtual bool next( );
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506 virtual ValueType value( );
00507
00508
00509
00510
00511
00512
00513
00514 virtual bool isValid( );
00515
00516
00517
00518
00519
00520 virtual InterfaceType* clone( ) const;
00521
00522 private:
00523
00524 bool _isValid;
00525 bool _hasEverBeenAdvanced;
00526
00527 CdbProperty _value;
00528 };
00529
00530 CdbBdbSOriginPropertyItr::CdbBdbSOriginPropertyItr( const char* theDBIDRangeName ) :
00531 _isValid(false),
00532 _hasEverBeenAdvanced(false),
00533 _value( "DBID Range Name", theDBIDRangeName )
00534 { }
00535
00536 CdbBdbSOriginPropertyItr::CdbBdbSOriginPropertyItr( const CdbBdbSOriginPropertyItr& theItr ) :
00537 _isValid(theItr._isValid),
00538 _hasEverBeenAdvanced(theItr._hasEverBeenAdvanced),
00539 _value(theItr._value)
00540 { }
00541
00542 CdbBdbSOriginPropertyItr::~CdbBdbSOriginPropertyItr( )
00543 { }
00544
00545 CdbBdbSOriginPropertyItr&
00546 CdbBdbSOriginPropertyItr::operator=( const CdbBdbSOriginPropertyItr& theItr )
00547 {
00548 if( &theItr != this ) {
00549 _isValid = theItr._isValid;
00550 _hasEverBeenAdvanced = theItr._hasEverBeenAdvanced;
00551 _value = theItr._value;
00552 }
00553 return *this;
00554 }
00555
00556 CdbStatus
00557 CdbBdbSOriginPropertyItr::reset( )
00558 {
00559 _isValid = false;
00560 _hasEverBeenAdvanced = false;
00561
00562 return CdbStatus::Success;
00563 }
00564
00565 bool
00566 CdbBdbSOriginPropertyItr::next( )
00567 {
00568 if( _isValid ) {
00569 _isValid = false;
00570 } else {
00571 _isValid = true;
00572 _hasEverBeenAdvanced = true;
00573 }
00574 return _isValid;
00575 }
00576
00577 CdbBdbSOriginPropertyItr::ValueType
00578 CdbBdbSOriginPropertyItr::value( )
00579 {
00580 assert( isValid( ));
00581 return _value;
00582 }
00583
00584 bool
00585 CdbBdbSOriginPropertyItr::isValid( )
00586 {
00587 return _isValid;
00588 }
00589
00590 CdbBdbSOriginPropertyItr::InterfaceType*
00591 CdbBdbSOriginPropertyItr::clone( ) const
00592 {
00593 return new CdbBdbSOriginPropertyItr( *this );
00594 }
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604 class CdbBdbSOrigin : public CdbOrigin {
00605
00606 private:
00607
00608
00609
00610
00611
00612 CdbBdbSOrigin( );
00613
00614
00615
00616
00617
00618 CdbBdbSOrigin( const CdbBdbSOrigin& theOrigin );
00619
00620
00621
00622
00623
00624 CdbBdbSOrigin& operator=( const CdbBdbSOrigin& theOrigin );
00625
00626 public:
00627
00628
00629
00630
00631
00632
00633
00634
00635 CdbBdbSOrigin( const CdbDatabasePtr& theDatabasePtr,
00636 const BdbRef(CdbBdbSOriginP)& theOriginRef
00637 );
00638
00639
00640
00641
00642
00643 virtual ~CdbBdbSOrigin( );
00644
00645
00646
00647
00648
00649
00650
00651 virtual BdbTime created( );
00652
00653
00654
00655
00656
00657
00658
00659 virtual std::string description( );
00660
00661
00662
00663
00664
00665
00666
00667 virtual bool isLocal( ) const;
00668
00669
00670
00671
00672
00673
00674
00675 virtual bool isInstantiated( ) const;
00676
00677
00678
00679
00680
00681
00682
00683 virtual bool isMaster( ) const;
00684
00685
00686
00687
00688
00689
00690
00691 virtual bool isSlave( ) const;
00692
00693
00694
00695
00696
00697
00698
00699 virtual bool isTest( ) const;
00700
00701
00702
00703
00704
00705
00706
00707 virtual CdbStatus propertyIterator( CdbItr<CdbProperty>& theItr );
00708
00709 private:
00710
00711 BdbHandle(CdbBdbSOriginP) _originH;
00712 };
00713
00714 CdbBdbSOrigin::CdbBdbSOrigin( const CdbDatabasePtr& theDatabasePtr,
00715 const BdbRef(CdbBdbSOriginP)& theOriginRef ) :
00716 CdbOrigin( theDatabasePtr,
00717 theOriginRef->name( ).head( ),
00718 theOriginRef->id( )),
00719 _originH(theOriginRef)
00720 { }
00721
00722 CdbBdbSOrigin::~CdbBdbSOrigin( )
00723 { }
00724
00725 BdbTime
00726 CdbBdbSOrigin::created( )
00727 {
00728 return _originH->created( );
00729 }
00730
00731 std::string
00732 CdbBdbSOrigin::description( )
00733 {
00734 return std::string( _originH->description( ).head( ));
00735 }
00736
00737 bool
00738 CdbBdbSOrigin::isLocal( ) const
00739 {
00740
00741
00742 return parent( )->localOrigin( )->id( ) == _originH->id( );
00743 }
00744
00745 bool
00746 CdbBdbSOrigin::isInstantiated( ) const
00747 {
00748
00749
00750
00751
00752
00753 BdbHandle(CdbBdbSRegistryP) h;
00754 return CdbStatus::Success == CdbBdbSRegistryP::findByOrigin( h, _originH->id( ));
00755 }
00756
00757 bool
00758 CdbBdbSOrigin::isMaster( ) const
00759 {
00760 return _originH->type( ) == CdbBdbSOriginP::MASTER;
00761 }
00762
00763 bool
00764 CdbBdbSOrigin::isSlave( ) const
00765 {
00766 return _originH->type( ) == CdbBdbSOriginP::SLAVE;
00767 }
00768
00769 bool
00770 CdbBdbSOrigin::isTest( ) const
00771 {
00772 return _originH->type( ) == CdbBdbSOriginP::TEST;
00773 }
00774
00775 CdbStatus
00776 CdbBdbSOrigin::propertyIterator( CdbItr<CdbProperty>& theItr )
00777 {
00778
00779
00780
00781 theItr = CdbItr<CdbProperty>( new CdbBdbSOriginPropertyItr( _originH->dbidrange( ).head( )));
00782
00783 return CdbStatus::Success;
00784 }
00785
00786 };
00787
00788
00789
00790
00791
00792 CdbDatabase*
00793 CdbBdbSDatabase::clone( ) const
00794 {
00795
00796
00797 CdbBdbSDatabase* mySelf = const_cast<CdbBdbSDatabase*>( this );
00798 return new CdbBdbSDatabase( mySelf->parent( ),
00799 mySelf->name( ));
00800 }
00801
00802 CdbBdbSDatabase::CdbBdbSDatabase( const CdbPtr& theCdbPtr,
00803 const char* theName ) :
00804 CdbDatabase( theCdbPtr,
00805 theName ),
00806 _isValid(true),
00807 _isOpen(false)
00808 { }
00809
00810 CdbBdbSDatabase::~CdbBdbSDatabase( )
00811 { }
00812
00813 bool
00814 CdbBdbSDatabase::isValid( )
00815 {
00816 return _isValid;
00817 }
00818
00819 bool
00820 CdbBdbSDatabase::isOpen( )
00821 {
00822 return _isOpen;
00823 }
00824
00825 CdbStatus
00826 CdbBdbSDatabase::open( )
00827 {
00828 const char* errorStr = "CdbBdbSDatabase::open() - ERROR.";
00829
00830 CdbStatus result = CdbStatus::Error;
00831 do {
00832
00833 if( ! _isOpen ) {
00834
00835
00836
00837 if( CdbStatus::Success != CdbBdbSRegistryP::findLocal( _localRegistryH )) {
00838 cout << errorStr << endl
00839 << " Failed to find the local registry. The database was not properly" << endl
00840 << " initialized/loaded." << endl;
00841 break;
00842 }
00843
00844
00845
00846 if( _localRegistryH->isMaster( )) {
00847 _masterRegistryH = _localRegistryH;
00848 } else {
00849 if( CdbStatus::Success != CdbBdbSRegistryP::findMaster( _masterRegistryH )) {
00850 cout << errorStr << endl
00851 << " Failed to find the master registry. The database was not properly" << endl
00852 << " initialized/loaded." << endl;
00853 break;
00854 }
00855 }
00856 _isOpen = true;
00857 }
00858
00859
00860
00861 result = CdbStatus::Success;
00862
00863 } while( false );
00864
00865 return result;
00866 }
00867
00868 CdbStatus
00869 CdbBdbSDatabase::close( )
00870 {
00871 if( _isOpen ) {
00872 _isOpen = false;
00873
00874 _masterRegistryH = 0;
00875 _localRegistryH = 0;
00876 }
00877 return CdbStatus::Success;
00878 }
00879
00880 BdbTime
00881 CdbBdbSDatabase::id( )
00882 {
00883
00884
00885 if( CdbStatus::Success != open( )) {
00886 assert( 0 );
00887 return BdbTime::plusInfinity;
00888 }
00889 return _localRegistryH->id( );
00890 }
00891
00892 BdbTime
00893 CdbBdbSDatabase::created( )
00894 {
00895
00896
00897 if( CdbStatus::Success != open( )) {
00898 assert( 0 );
00899 return BdbTime::plusInfinity;
00900 }
00901 return _localRegistryH->created( );
00902 }
00903
00904 std::string
00905 CdbBdbSDatabase::description( )
00906 {
00907
00908
00909 if( CdbStatus::Success != open( )) {
00910 assert( 0 );
00911 return std::string( );
00912 }
00913 return std::string( _localRegistryH->description( ).head( ));
00914 }
00915
00916 std::string
00917 CdbBdbSDatabase::defaultView( ) const
00918 {
00919 return CdbEnvironment::defaultView( parent( )->technologyName( ),
00920 parent( )->implementationName( ),
00921 name( ));
00922 }
00923
00924 CdbStatus
00925 CdbBdbSDatabase::findView( CdbViewPtr& thePtr,
00926 const char* theName )
00927 {
00928 const char* errorStr = "CdbBdbSDatabase::findView(name) -- ERROR" ;
00929
00930 CdbStatus result = CdbStatus::Error;
00931 do {
00932
00933
00934
00935 if( CdbStatus::Success != open( )) break;
00936
00937
00938
00939
00940 std::string viewName = defaultView( );
00941 if( 0 != theName ) viewName = theName;
00942
00943 CdbCompositeName vName( viewName.c_str( ));
00944 if( !vName.isValid( )) {
00945 cout << errorStr << endl
00946 << " The view name passed to the procedure has invalid format: \"" << viewName.c_str( ) << "\"" << endl;
00947 break;
00948 }
00949
00950
00951
00952 std::string originName = vName.first( );
00953 std::string localViewName = vName.last( );
00954
00955
00956
00957
00958
00959
00960 BdbHandle(CdbBdbSRegistryP) rH;
00961 if( "<master>" == originName ) rH = _masterRegistryH;
00962 else if( "<local>" == originName ) rH = _localRegistryH;
00963 else {
00964 if( CdbStatus::Success != CdbBdbSRegistryP::findByOrigin( rH,
00965 originName.c_str( ))) {
00966 cout << errorStr << endl
00967 << " Registry for specified origin was not found." << endl;
00968 break;
00969 }
00970 }
00971
00972
00973
00974 BdbRef(CdbBdbSViewCollectionP) vCollRef = rH->viewCollection( );
00975 assert( ! BdbIsNull(vCollRef));
00976
00977
00978
00979
00980
00981 BdbRef(CdbBdbSViewP) vRef;
00982 if( 0 == strcmp( "<recent>", localViewName.c_str( ))) {
00983 if( CdbStatus::Success != vCollRef->newest( vRef )) {
00984 result = CdbStatus::NotFound;
00985 break;
00986 }
00987 } else {
00988 if( CdbStatus::Success != vCollRef->find( localViewName.c_str( ),
00989 vRef )) {
00990 result = CdbStatus::NotFound;
00991 break;
00992 }
00993 }
00994
00995
00996
00997
00998 CdbId viewId( rH->originId( ),
00999 vRef->id( ));
01000
01001
01002
01003
01004
01005
01006
01007
01008 CdbDatabasePtr myPtr( this->clone( ));
01009
01010 thePtr = new CdbBdbSView( myPtr,
01011 viewName.c_str( ),
01012 viewId,
01013 vRef,
01014 _masterRegistryH,
01015 _localRegistryH );
01016
01017 result = CdbStatus::Success;
01018
01019 } while( false );
01020
01021 return result;
01022 }
01023
01024 CdbStatus
01025 CdbBdbSDatabase::findView( CdbViewPtr& thePtr,
01026 const CdbId& theId )
01027 {
01028 const char* errorStr = "CdbBdbSDatabase::findView(id) -- ERROR" ;
01029
01030 CdbStatus result = CdbStatus::Error;
01031 do {
01032
01033
01034
01035 if( CdbStatus::Success != open( )) break;
01036
01037
01038
01039
01040
01041
01042 BdbHandle(CdbBdbSRegistryP) rH;
01043 if( theId.origin == _masterRegistryH->originId( )) rH = _masterRegistryH;
01044 else if( theId.origin == _localRegistryH->originId( )) rH = _localRegistryH;
01045 else {
01046 if( CdbStatus::Success != CdbBdbSRegistryP::findByOrigin( rH,
01047 theId.origin )) {
01048 cout << errorStr << endl
01049 << " Registry for specified origin was not found." << endl;
01050 break;
01051 }
01052 }
01053
01054
01055
01056 BdbRef(CdbBdbSViewCollectionP) vCollRef = rH->viewCollection( );
01057 assert( ! BdbIsNull(vCollRef));
01058
01059
01060
01061 BdbRef(CdbBdbSViewP) vRef;
01062 if( CdbStatus::Success != vCollRef->find( theId.local,
01063 vRef )) {
01064 result = CdbStatus::NotFound;
01065 break;
01066 }
01067
01068
01069
01070 std::string viewName( "" );
01071 {
01072 BdbRef(CdbBdbSOriginCollectionP) oCollRef = _masterRegistryH->originCollection( );
01073 assert( ! BdbIsNull(oCollRef));
01074
01075 BdbRef(CdbBdbSOriginP) oRef;
01076 if( CdbStatus::Success != oCollRef->find( theId.origin,
01077 oRef )) {
01078 cout << errorStr << endl
01079 << " The origin with ID: " << theId.origin << " not found in the master." << endl;
01080 break;
01081 }
01082 CdbCompositeName vName( oRef->name( ), vRef->name( ));
01083 assert( vName.isValid( ));
01084
01085 viewName = vName.getName( );
01086 }
01087
01088
01089
01090
01091
01092
01093
01094
01095 CdbDatabasePtr myPtr( this->clone( ));
01096
01097 thePtr = new CdbBdbSView( myPtr,
01098 viewName.c_str( ),
01099 theId,
01100 vRef,
01101 _masterRegistryH,
01102 _localRegistryH );
01103
01104 result = CdbStatus::Success;
01105
01106 } while( false );
01107
01108 return result;
01109 }
01110
01111 CdbStatus
01112 CdbBdbSDatabase::viewIterator( CdbViewItr& theItr )
01113 {
01114 CdbStatus result = CdbStatus::Error;
01115 do {
01116
01117
01118
01119 if( CdbStatus::Success != open( )) break;
01120
01121
01122
01123
01124 theItr = CdbViewItr( new CdbBdbSViewItr( _masterRegistryH ));
01125
01126
01127
01128 result = CdbStatus::Success;
01129
01130 } while( false );
01131
01132 return result;
01133 }
01134
01135 CdbStatus
01136 CdbBdbSDatabase::physicalConditionIterator( CdbItr<CdbId>& theItr )
01137 {
01138 const char* errorStr = "CdbBdbSDatabase::physicalConditionIterator() -- ERROR" ;
01139
01140 CdbStatus result = CdbStatus::Error;
01141
01142
01143
01144 if( CdbStatus::Success != open( )) return CdbStatus::Error;
01145
01146
01147
01148
01149 std::vector<CdbId> vectorOfIds;
01150
01151 CdbBdbSOriginCollectionP::IteratorOfIdentifiers originItr = _masterRegistryH->originCollection( )->iterator_identifiers( );
01152 while( originItr.next( )) {
01153
01154 d_UShort originId = originItr.value( );
01155
01156
01157
01158
01159 BdbHandle(CdbBdbSRegistryP) registryH;
01160 {
01161 if( CdbStatus::Success != ( result = CdbBdbSRegistryP::findByOrigin( registryH,
01162 originId ))) {
01163 if( CdbStatus::NotFound == result ) {
01164
01165
01166
01167
01168 continue;
01169
01170 } else {
01171 cerr << errorStr << endl
01172 << " Failed to find a registry for origin ID = " << originId << "." << endl;
01173 return result;
01174 }
01175 }
01176 }
01177
01178
01179
01180
01181
01182 BdbHandle(CdbBdbSConditionCollectionP) conditionCollectionH = registryH->conditionCollection( );
01183 if( !BdbIsNull(conditionCollectionH)) {
01184
01185 CdbBdbSConditionCollectionP::IteratorOfIdentifiers pConditionItr = conditionCollectionH->iterator_identifiers( );
01186 while( pConditionItr.next( )) {
01187 vectorOfIds.push_back( CdbId( originId,
01188 pConditionItr.value( )));
01189 }
01190 }
01191 }
01192
01193
01194
01195 theItr = CdbItr<CdbId>( new CdbSimpleVectorAdapterItr<CdbId>( vectorOfIds ));
01196
01197 return CdbStatus::Success;
01198 }
01199
01200 CdbStatus
01201 CdbBdbSDatabase::findCondition( CdbConditionPtr& thePtr,
01202 const CdbId& theId )
01203 {
01204 const char* errorStr = "CdbBdbSDatabase::findCondition('physical address') -- ERROR" ;
01205
01206 CdbStatus result = CdbStatus::Error;
01207 do {
01208
01209
01210
01211 if( CdbStatus::Success != open( )) break;
01212
01213
01214
01215
01216
01217
01218 BdbHandle(CdbBdbSRegistryP) rH;
01219 if( theId.origin == _masterRegistryH->originId( )) rH = _masterRegistryH;
01220 else if( theId.origin == _localRegistryH->originId( )) rH = _localRegistryH;
01221 else {
01222 if( CdbStatus::Success != CdbBdbSRegistryP::findByOrigin( rH,
01223 theId.origin )) {
01224 cout << errorStr << endl
01225 << " Registry for specified origin " << theId.origin << " was not found." << endl;
01226 break;
01227 }
01228 }
01229
01230
01231
01232 BdbRef(CdbBdbSConditionCollectionP) cCollRef = rH->conditionCollection( );
01233 assert( ! BdbIsNull(cCollRef));
01234
01235
01236
01237 BdbRef(CdbBdbSConditionP) cRef;
01238 if( CdbStatus::Success != cCollRef->find( theId.local,
01239 cRef )) {
01240 result = CdbStatus::NotFound;
01241 break;
01242 }
01243
01244
01245
01246 std::string conditionName( "" );
01247 {
01248 BdbRef(CdbBdbSOriginCollectionP) oCollRef = _masterRegistryH->originCollection( );
01249 assert( ! BdbIsNull(oCollRef));
01250
01251 BdbRef(CdbBdbSOriginP) oRef;
01252 if( CdbStatus::Success != oCollRef->find( theId.origin,
01253 oRef )) {
01254 cout << errorStr << endl
01255 << " The origin with ID: " << theId.origin << " not found in the master." << endl;
01256 break;
01257 }
01258 conditionName = std::string( oRef->name( )) + std::string( "::" ) + std::string( cRef->name( ).head( ));
01259 }
01260
01261
01262
01263
01264 CdbFolderPtr fPtr = 0;
01265 BdbHandle(CdbBdbSConditionAtFolderP) conditionAtFolderH = 0;
01266
01267
01268
01269
01270
01271
01272 CdbDatabasePtr myPtr( this->clone( ));
01273
01274 thePtr = new CdbBdbSCondition( fPtr,
01275 myPtr,
01276 conditionName.c_str( ),
01277 CdbBdbSId( theId.origin,
01278 theId.local ),
01279 conditionAtFolderH,
01280 cRef,
01281 _masterRegistryH,
01282 _localRegistryH );
01283
01284 result = CdbStatus::Success;
01285
01286 } while( false );
01287
01288 return result;
01289 }
01290
01291 CdbStatus
01292 CdbBdbSDatabase::findCondition( CdbConditionPtr& thePtr,
01293 const CdbCompositeName& thePhysicalName )
01294 {
01295 const char* errorStr = "CdbBdbSDatabase::findCondition('physical name') -- ERROR" ;
01296
01297 CdbStatus result = CdbStatus::Error;
01298 do {
01299
01300
01301
01302 if( CdbStatus::Success != open( )) break;
01303
01304
01305
01306 if( !thePhysicalName.isValid( )) {
01307 cout << errorStr << endl
01308 << " The 'physical name' name passed to the procedure has invalid format: \"" << thePhysicalName.getName( ).c_str( ) << "\"" << endl;
01309 break;
01310 }
01311
01312
01313
01314 std::string originName = thePhysicalName.first( );
01315 std::string localConditionName = thePhysicalName.last( );
01316
01317
01318
01319
01320
01321
01322 BdbHandle(CdbBdbSRegistryP) rH;
01323 if ( "<master>" == originName ) rH = _masterRegistryH;
01324 else if( "<local>" == originName ) rH = _localRegistryH;
01325 else {
01326 if( CdbStatus::Success != CdbBdbSRegistryP::findByOrigin( rH,
01327 originName.c_str( ))) {
01328 cout << errorStr << endl
01329 << " Registry for specified origin \"" << originName.c_str( ) << "\" was not found." << endl;
01330 break;
01331 }
01332 }
01333
01334
01335
01336 BdbRef(CdbBdbSConditionCollectionP) cCollRef = rH->conditionCollection( );
01337 assert( ! BdbIsNull(cCollRef));
01338
01339
01340
01341 BdbRef(CdbBdbSConditionP) cRef;
01342 if( CdbStatus::Success != cCollRef->find( localConditionName.c_str( ),
01343 cRef )) {
01344 result = CdbStatus::NotFound;
01345 break;
01346 }
01347
01348
01349
01350
01351 CdbFolderPtr fPtr = 0;
01352 BdbHandle(CdbBdbSConditionAtFolderP) conditionAtFolderH = 0;
01353
01354
01355
01356
01357
01358
01359 CdbDatabasePtr myPtr( this->clone( ));
01360
01361 thePtr = new CdbBdbSCondition( fPtr,
01362 myPtr,
01363 thePhysicalName.getName( ).c_str( ),
01364 CdbBdbSId( rH->originId( ),
01365 cRef->id( )),
01366 conditionAtFolderH,
01367 cRef,
01368 _masterRegistryH,
01369 _localRegistryH );
01370
01371 result = CdbStatus::Success;
01372
01373 } while( false );
01374
01375 return result;
01376 }
01377
01378 CdbStatus
01379 CdbBdbSDatabase::historyEventIterator( CdbHistoryEventItr& theItr,
01380 const BdbTime& theBeginTime,
01381 const BdbTime& theEndTime,
01382 const char** theEventsToSelect )
01383 {
01384 return CdbStatus::NotImplemented;
01385 }
01386
01387 CdbStatus
01388 CdbBdbSDatabase::historyEventTypeIterator( CdbHistoryEventTypeItr& theItr )
01389 {
01390 return CdbStatus::NotImplemented;
01391 }
01392
01393 CdbStatus
01394 CdbBdbSDatabase::partitionIterator( CdbItr<unsigned short>& theItr )
01395 {
01396 CdbStatus result = CdbStatus::Error;
01397 do {
01398
01399
01400
01401 if( CdbStatus::Success != open( )) break;
01402
01403
01404
01405
01406 theItr = CdbItr<unsigned short>( new CdbBdbSPartitionItr( _masterRegistryH->partitionsLayout( )->iterator( )));
01407
01408
01409
01410 result = CdbStatus::Success;
01411
01412 } while( false );
01413
01414 return result;
01415 }
01416
01417 CdbStatus
01418 CdbBdbSDatabase::partitionIterator( CdbItr<unsigned short>& theItr,
01419 unsigned int theOriginId )
01420 {
01421 const char* errorStr = "CdbBdbSDatabase::partitionIterator(by origin id) - ERROR.";
01422
01423 CdbStatus result = CdbStatus::Error;
01424 do {
01425
01426
01427
01428 if( CdbStatus::Success != open( )) break;
01429
01430
01431
01432 BdbHandle(CdbBdbSRegistryP) registryH;
01433 CdbStatus status = CdbBdbSRegistryP::findByOrigin( registryH,
01434 theOriginId );
01435 if( CdbStatus::Success != status ) {
01436 if( CdbStatus::NotFound == status ) {
01437 cout << errorStr << endl
01438 << " The specified origin identifier " << theOriginId << " does not correspond to any" << endl
01439 << " known origin in the current database. Please check the logic of your application." << endl;
01440 } else {
01441 cout << errorStr << endl
01442 << " Failed to find the registry for specified origin identifier " << theOriginId << "." << endl
01443 << " Perhaps the database was not properly initialized/loaded." << endl;
01444 }
01445 break;
01446 }
01447
01448
01449
01450
01451 BdbRef(CdbBdbSPartitionsLayoutP) pLayoutRef = registryH->partitionsLayout( );
01452 if( BdbIsNull(pLayoutRef)) {
01453 result = CdbStatus::NotFound;
01454 break;
01455 }
01456
01457
01458
01459
01460 theItr = CdbItr<unsigned short>( new CdbBdbSPartitionItr( pLayoutRef->iterator( )));
01461
01462
01463
01464 result = CdbStatus::Success;
01465
01466 } while( false );
01467
01468 return result;
01469 }
01470
01471 CdbStatus
01472 CdbBdbSDatabase::partitionIterator( CdbItr<unsigned short>& theItr,
01473 const char* theOriginName )
01474 {
01475 const char* errorStr = "CdbBdbSDatabase::partitionIterator(by origin name) - ERROR.";
01476
01477 CdbStatus result = CdbStatus::Error;
01478 do {
01479
01480
01481
01482 if( CdbStatus::Success != open( )) break;
01483
01484
01485
01486 BdbHandle(CdbBdbSRegistryP) registryH;
01487 CdbStatus status = CdbBdbSRegistryP::findByOrigin( registryH,
01488 theOriginName );
01489 if( CdbStatus::Success != status ) {
01490 if( CdbStatus::NotFound == status ) {
01491 cout << errorStr << endl
01492 << " The specified origin name \"" << theOriginName << "\" does not correspond to any" << endl
01493 << " known origin in the current database. Please check the logic of your application." << endl;
01494 } else {
01495 cout << errorStr << endl
01496 << " Failed to find the registry for specified origin name \"" << theOriginName << "\"." << endl
01497 << " Perhaps the database was not properly initialized/loaded." << endl;
01498 }
01499 break;
01500 }
01501
01502
01503
01504
01505 BdbRef(CdbBdbSPartitionsLayoutP) pLayoutRef = registryH->partitionsLayout( );
01506 if( BdbIsNull(pLayoutRef)) {
01507 result = CdbStatus::NotFound;
01508 break;
01509 }
01510
01511
01512
01513
01514 theItr = CdbItr<unsigned short>( new CdbBdbSPartitionItr( pLayoutRef->iterator( )));
01515
01516
01517
01518 result = CdbStatus::Success;
01519
01520 } while( false );
01521
01522 return result;
01523 }
01524
01525 CdbStatus
01526 CdbBdbSDatabase::findPartition( CdbPartitionPtr& thePtr,
01527 unsigned short thePartition )
01528 {
01529 const char* errorStr = "CdbBdbSDatabase::findPartition() -- ERROR" ;
01530
01531 CdbStatus result = CdbStatus::Error;
01532 do {
01533
01534
01535
01536 if( CdbStatus::Success != open( )) break;
01537
01538
01539
01540
01541
01542
01543
01544 BdbHandle( CdbBdbSPartitionP ) pH;
01545 {
01546 BdbRef(CdbBdbSPartitionsLayoutP) pLayoutRef = _masterRegistryH->partitionsLayout( );
01547 if( BdbIsNull(pLayoutRef)) {
01548 assert( 0 );
01549 break;
01550 }
01551
01552 BdbRef( CdbBdbSPartitionP ) pRef;
01553 if( CdbStatus::Success != pLayoutRef->find( thePartition,
01554 pRef )) {
01555 result = CdbStatus::NotFound;
01556 break;
01557 }
01558 pH = pRef;
01559
01560 if( pH->originId( ) != _masterRegistryH->originId( )) {
01561 if( pH->originId( ) == _localRegistryH->originId( )) {
01562
01563 pLayoutRef = _localRegistryH->partitionsLayout( );
01564 if( BdbIsNull(pLayoutRef)) {
01565 assert( 0 );
01566 break;
01567 }
01568 if( CdbStatus::Success != pLayoutRef->find( thePartition,
01569 pRef )) {
01570 cout << errorStr << endl
01571 << " Failed to find partition with ID=" << thePartition << " at the current" << endl
01572 << " database to whom the partition is supposed to belong to. The database" << endl
01573 << " may not be properly initialized/loaded." << endl;
01574
01575 result = CdbStatus::NotFound;
01576 break;
01577 }
01578 pH = pRef;
01579 }
01580 }
01581 }
01582 if( BdbIsNull(pH)) {
01583 assert( 0 );
01584 break;
01585 }
01586
01587
01588
01589 std::string ownerOriginName;
01590 {
01591 BdbHandle(CdbBdbSOriginCollectionP) oCollectionH;
01592
01593 oCollectionH = _masterRegistryH->originCollection( );
01594 assert( !BdbIsNull(oCollectionH));
01595
01596 BdbRef(CdbBdbSOriginP) oRef;
01597 if( CdbStatus::Success != oCollectionH->find( pH->originId( ),
01598 oRef )) {
01599 cout << errorStr << endl
01600 << " There is no information on the origin ID=" << pH->originId( ) << endl
01601 << " in the corresponding collection of the MASTER's registry." << endl
01602 << " The database may be corrupted or in an inconsistent state." << endl;
01603 break;
01604 }
01605
01606 ownerOriginName = oRef->name( );
01607 }
01608
01609
01610
01611
01612
01613
01614
01615
01616 CdbDatabasePtr myPtr = this->clone( );
01617
01618 thePtr = new CdbBdbSPartition( myPtr,
01619 pH,
01620 pH->originId( ),
01621 ownerOriginName.c_str( ));
01622
01623
01624
01625 result = CdbStatus::Success;
01626
01627 } while( false );
01628
01629 return result;
01630 }
01631
01632 CdbStatus
01633 CdbBdbSDatabase::findPartition( CdbPartitionPtr& thePtr,
01634 unsigned short thePartition,
01635 unsigned int theOriginId )
01636 {
01637 const char* errorStr = "CdbBdbSDatabase::findPartition(by origin id) -- ERROR" ;
01638
01639 CdbStatus result = CdbStatus::Error;
01640 do {
01641
01642
01643
01644 if( CdbStatus::Success != open( )) break;
01645
01646
01647
01648 BdbHandle(CdbBdbSRegistryP) registryH;
01649 CdbStatus status = CdbBdbSRegistryP::findByOrigin( registryH,
01650 theOriginId );
01651 if( CdbStatus::Success != status ) {
01652 if( CdbStatus::NotFound == status ) {
01653 cout << errorStr << endl
01654 << " The specified origin identifier " << theOriginId << " does not correspond to any" << endl
01655 << " known origin in the current database. Please check the logic of your application." << endl;
01656 } else {
01657 cout << errorStr << endl
01658 << " Failed to find the registry for specified origin identifier " << theOriginId << "." << endl
01659 << " Perhaps the database was not properly initialized/loaded." << endl;
01660 }
01661 break;
01662 }
01663
01664
01665
01666 BdbRef(CdbBdbSPartitionsLayoutP) pLayoutRef = registryH->partitionsLayout( );
01667 if( BdbIsNull(pLayoutRef)) {
01668 cout << errorStr << endl
01669 << " The origin for specified origin identifier " << theOriginId << " is not allowed" << endl
01670 << " to have partitions. Please check the logic of your application." << endl;
01671 break;
01672 }
01673
01674
01675
01676 BdbHandle( CdbBdbSPartitionP ) pH;
01677 {
01678 BdbRef( CdbBdbSPartitionP ) pRef;
01679 if( CdbStatus::Success != pLayoutRef->find( thePartition,
01680 pRef )) {
01681 result = CdbStatus::NotFound;
01682 break;
01683 }
01684 pH = pRef;
01685 }
01686
01687
01688
01689 std::string ownerOriginName;
01690 {
01691 BdbHandle(CdbBdbSOriginCollectionP) oCollectionH;
01692
01693 oCollectionH = _masterRegistryH->originCollection( );
01694 assert( !BdbIsNull(oCollectionH));
01695
01696 BdbRef(CdbBdbSOriginP) oRef;
01697 if( CdbStatus::Success != oCollectionH->find( pH->originId( ),
01698 oRef )) {
01699 cout << errorStr << endl
01700 << " There is no information on the origin ID=" << pH->originId( ) << endl
01701 << " in the corresponding collection of the MASTER's registry." << endl
01702 << " The database may be corrupted or in an inconsistent state." << endl;
01703 break;
01704 }
01705
01706 ownerOriginName = oRef->name( );
01707 }
01708
01709
01710
01711
01712
01713
01714
01715
01716 CdbDatabasePtr myPtr = this->clone( );
01717
01718 thePtr = new CdbBdbSPartition( myPtr,
01719 pH,
01720 pH->originId( ),
01721 ownerOriginName.c_str( ));
01722
01723
01724
01725 result = CdbStatus::Success;
01726
01727 } while( false );
01728
01729 return result;
01730 }
01731
01732 CdbStatus
01733 CdbBdbSDatabase::findPartition( CdbPartitionPtr& thePtr,
01734 unsigned short thePartition,
01735 const char* theOriginName )
01736 {
01737 const char* errorStr = "CdbBdbSDatabase::findPartition(by origin name) -- ERROR" ;
01738
01739 CdbStatus result = CdbStatus::Error;
01740 do {
01741
01742
01743
01744 if( CdbStatus::Success != open( )) break;
01745
01746
01747
01748 BdbHandle(CdbBdbSRegistryP) registryH;
01749 CdbStatus status = CdbBdbSRegistryP::findByOrigin( registryH,
01750 theOriginName );
01751 if( CdbStatus::Success != status ) {
01752 if( CdbStatus::NotFound == status ) {
01753 cout << errorStr << endl
01754 << " The specified origin name \"" << theOriginName << "\" does not correspond to any" << endl
01755 << " known origin in the current database. Please check the logic of your application." << endl;
01756 } else {
01757 cout << errorStr << endl
01758 << " Failed to find the registry for specified origin name \"" << theOriginName << "\"." << endl
01759 << " Perhaps the database was not properly initialized/loaded." << endl;
01760 }
01761 break;
01762 }
01763
01764
01765
01766 BdbRef(CdbBdbSPartitionsLayoutP) pLayoutRef = registryH->partitionsLayout( );
01767 if( BdbIsNull(pLayoutRef)) {
01768 cout << errorStr << endl
01769 << " The origin for specified origin name \"" << theOriginName << "\" is not allowed" << endl
01770 << " to have partitions. Please check the logic of your application." << endl;
01771 break;
01772 }
01773
01774
01775
01776 BdbHandle( CdbBdbSPartitionP ) pH;
01777 {
01778 BdbRef( CdbBdbSPartitionP ) pRef;
01779 if( CdbStatus::Success != pLayoutRef->find( thePartition,
01780 pRef )) {
01781 result = CdbStatus::NotFound;
01782 break;
01783 }
01784 pH = pRef;
01785 }
01786
01787
01788
01789 std::string ownerOriginName;
01790 {
01791 BdbHandle(CdbBdbSOriginCollectionP) oCollectionH;
01792
01793 oCollectionH = _masterRegistryH->originCollection( );
01794 assert( !BdbIsNull(oCollectionH));
01795
01796 BdbRef(CdbBdbSOriginP) oRef;
01797 if( CdbStatus::Success != oCollectionH->find( pH->originId( ),
01798 oRef )) {
01799 cout << errorStr << endl
01800 << " There is no information on the origin ID=" << pH->originId( ) << endl
01801 << " in the corresponding collection of the MASTER's registry." << endl
01802 << " The database may be corrupted or in an inconsistent state." << endl;
01803 break;
01804 }
01805
01806 ownerOriginName = oRef->name( );
01807 }
01808
01809
01810
01811
01812
01813
01814
01815
01816 CdbDatabasePtr myPtr = this->clone( );
01817
01818 thePtr = new CdbBdbSPartition( myPtr,
01819 pH,
01820 pH->originId( ),
01821 ownerOriginName.c_str( ));
01822
01823
01824
01825 result = CdbStatus::Success;
01826
01827 } while( false );
01828
01829 return result;
01830 }
01831
01832 CdbOriginPtr
01833 CdbBdbSDatabase::localOrigin( )
01834 {
01835
01836
01837 if( CdbStatus::Success != open( )) {
01838 assert( 0 );
01839 return 0;
01840 }
01841
01842
01843
01844 if( _localOriginPtr.isNull( )) {
01845 if( CdbStatus::Success != findOrigin( _localOriginPtr,
01846 _localRegistryH->originId( ))) {
01847 assert( 0 );
01848 return 0;
01849 }
01850 }
01851 return _localOriginPtr;
01852 }
01853
01854 CdbStatus
01855 CdbBdbSDatabase::originIterator( CdbItr<unsigned short>& theItr )
01856 {
01857 CdbStatus result = CdbStatus::Error;
01858 do {
01859
01860
01861
01862 if( CdbStatus::Success != open( )) break;
01863
01864
01865
01866
01867 BdbRef(CdbBdbSOriginCollectionP) oCollRef = _masterRegistryH->originCollection( );
01868 assert( ! BdbIsNull(oCollRef));
01869
01870
01871
01872
01873 theItr = CdbItr<unsigned short>( new CdbBdbSOriginItr( oCollRef->iterator_identifiers( )));
01874
01875
01876
01877 result = CdbStatus::Success;
01878
01879 } while( false );
01880
01881 return result;
01882 }
01883
01884 CdbStatus
01885 CdbBdbSDatabase::findOrigin( CdbOriginPtr& thePtr,
01886 const char* theName )
01887 {
01888 assert( 0 != theName );
01889
01890 CdbStatus result = CdbStatus::NotFound;
01891 do {
01892
01893
01894
01895 if( CdbStatus::Success != open( )) {
01896 result = CdbStatus::Error;
01897 break;
01898 }
01899
01900
01901
01902
01903 BdbRef(CdbBdbSOriginCollectionP) oCollRef = _masterRegistryH->originCollection( );
01904 assert( ! BdbIsNull(oCollRef));
01905
01906 BdbRef(CdbBdbSOriginP) oRef;
01907 {
01908 result = oCollRef->find( theName, oRef );
01909 if( CdbStatus::Success != result ) break;
01910 }
01911 assert( ! BdbIsNull(oRef));
01912
01913
01914
01915
01916
01917
01918
01919
01920 CdbDatabasePtr myPtr( this->clone( ));
01921
01922 thePtr = new CdbBdbSOrigin( myPtr,
01923 oRef );
01924
01925
01926
01927 result = CdbStatus::Success;
01928
01929 } while( false );
01930
01931 return result;
01932 }
01933
01934 CdbStatus
01935 CdbBdbSDatabase::findOrigin( CdbOriginPtr& thePtr,
01936 unsigned short theId )
01937 {
01938 CdbStatus result = CdbStatus::NotFound;
01939 do {
01940
01941
01942
01943 if( CdbStatus::Success != open( )) {
01944 result = CdbStatus::Error;
01945 break;
01946 }
01947
01948
01949
01950
01951 BdbRef(CdbBdbSOriginCollectionP) oCollRef = _masterRegistryH->originCollection( );
01952 assert( ! BdbIsNull(oCollRef));
01953
01954 BdbRef(CdbBdbSOriginP) oRef;
01955 {
01956 result = oCollRef->find( theId, oRef );
01957 if( CdbStatus::Success != result ) break;
01958 }
01959 assert( ! BdbIsNull(oRef));
01960
01961
01962
01963
01964
01965
01966
01967
01968 CdbDatabasePtr myPtr( this->clone( ));
01969
01970 thePtr = new CdbBdbSOrigin( myPtr,
01971 oRef );
01972
01973
01974
01975 result = CdbStatus::Success;
01976
01977 } while( false );
01978
01979 return result;
01980 }
01981
01982
01983
01984