//*-- Author : Valeriy Onuchin 11/09/2000
//
//
////////////////////////////////////////////////////////////////////////////////
//
// rooFDObj corresponds to ooHandle(ooFDObj) class
//
// Handle class for fedrated databases
#include "rooObjy.h"
#include <ooas.h>
#include <oo.h>
#include <TROOT.h>
#include <TBrowser.h>
ClassImp(rooFDObj)
rooFDObj* gprevFD = 0; // previously opened federated database
rooFDObj* gooTopFD = 0; // most recently opened federated database
////////////////////////////////////////////////////////////////////////////////
//______________________________________________________________________________
rooFDObj::rooFDObj()
{
// default ctor.
fImp = new ooHandle(ooFDObj)();
}
//______________________________________________________________________________
rooFDObj::rooFDObj(const rooFDObj& fd)
{
// copy ctor.
fImp = new ooHandle(ooFDObj)(*((ooHandle(ooFDObj)*)fd.getImp()));
}
//______________________________________________________________________________
rooFDObj& rooFDObj::operator=(const rooFDObj& fd)
{
// Sets object r handle to reference specified federated
// database.
*((ooHandle(ooFDObj)*)fImp) = *((ooHandle(ooFDObj)*)fd.getImp());
return *this;
}
//______________________________________________________________________________
Bool_t rooFDObj::change(const TString& bootFile,
const TString& lockServer,
Int_t fdNumber,
FILE* fp) const
{
// bootFile - path to the boot file of the federated database.
// The default value is "".
// lockServer - name of the new host running the lock server
// process for this federated database. The default
// value is "".
// fdNumber - new identifier of the federated database
// fp - pointer to the transcript file to which the
// system name of the federated database, the
// lock server host name, and the identifier of the
// federated database are echoed before and after
// the change member function is invoked. The
// default value is stdout.
//
// Change federated database attributes. If any of the
// first three arguments has a value other than zero, then the catalog
// information corresponding to that argument is set to the specified
// value. Catalog information corresponding to arguments with zero
// values is not modified. After calling change, the old boot file remains.
// You must delete this file manually.
//
// When using the rooFDObj::change member function
// to modify the attributes of a federated database, you must strictly
// follow these steps:
//
// 1. Shut down the lock server.
// 2. Run in single-user mode (call ooNoLock in your program).
// 3. Start a transaction.
// 4. Open the federated database for update.
// 5. Invoke the rooFDObj::change member function.
// 6. Commit the transaction.
// 7. Exit from the process.
// 8. Restart the lock server.
//
// The federated database attributes are in a new and different state after
// the rooFDObj::change member function has been run. For this reason, it
// is mandatory to exit from the process immediately after changing
// attributes.
const char* boot = bootFile.IsNull() ? 0 : bootFile.Data();
const char* lock = lockServer.IsNull() ? 0 : lockServer.Data();
Bool_t ret = ((ooHandle(ooFDObj)*)fImp)->change(boot,lock,fdNumber,fp);
if(ret && boot) {
gROOT->GetListOfBrowsables()->Remove(this);
gROOT->GetListOfBrowsables()->Add(this,boot);
fTitle = bootFile;
}
return ret;
}
//______________________________________________________________________________
Bool_t rooFDObj::close()
{
// Closes the referenced federated database
gooTopFD = gprevFD;
return ((ooHandle(ooFDObj)*)fImp)->close();
}
//______________________________________________________________________________
Bool_t rooFDObj::contains(rooDBItr& itr,Int_t openMode) const
{
// Initializes the iterator itr to traverse all databases in the referenced
// federated database. Objects of the iteration are automatically opened in
// the mode specified by openMode. The default is kooNoOpen (do not
// open the federated database automatically).
ooItr(ooDBObj)* contItr = (ooItr(ooDBObj)*)itr.getImp();
return ((ooHandle(ooFDObj)*)fImp)->contains(*contItr,(ooMode)openMode);
}
//______________________________________________________________________________
Bool_t rooFDObj::convertObjects()
{
// Convert all objects affected by schema evolution operations within a
// federated database to their current class representations. Schema
// information used for object conversion will be purged as a side-effect of
// this operation.
return ((ooHandle(ooFDObj)*)fImp)->convertObjects();
}
//______________________________________________________________________________
Bool_t rooFDObj::decodeSchema(const TString& pswd) const
{
// OBSOLETE ???
return kFALSE; // OBSOLETE ???
// return ((ooHandle(ooFDObj)*)fImp)->decodeSchema(pswd.Data());
}
//______________________________________________________________________________
Bool_t rooFDObj::dumpCatalog(FILE* fp,
Int_t fileNameFormat,
Bool_t printLabels) const
{
// fp - pointer to the output file that stores the
// federated database attribute information
// normally printed in the standard output by the
// oodumpcatalog tool. The default value is stdout.
// fileNameFormat - flag indicating the format of the printed file
// name. The default value is kooHostLocal,
// which formats the file name as host:localPath. The
// other allowable value is kooNative, which
// formats the file name as a full path name or
// just a local name (for example, /net/object/usr/mnt/ed/dsgn/up.FDB).
// printLabels - specifies whether or not to label the file in the
// output. The default is oocTrue, which specifies
// that each file name in the output is labeled.
return ((ooHandle(ooFDObj)*)fImp)->dumpCatalog(fp,(ooFileNameFormat)fileNameFormat,
printLabels);
}
//______________________________________________________________________________
Bool_t rooFDObj::encodeSchema(const TString& pswd) const
{
// OBSOLETE ???
return kFALSE; // OBSOLETE ???
// return ((ooHandle(ooFDObj)*)fImp)->encodeSchema(pswd.Data());
}
//______________________________________________________________________________
Bool_t rooFDObj::exist(const TString& bootFile,Int_t openMode)
{
// Tests for the existence of the federated database specified by boot file
// bootFile. If the federated database exists and openMode is
// kooRead or kooUpdate, the federated database is opened and its object
// reference or handle is initialized. If openMode is not kooNoOpen, and
// exist returns kFALSE, the object either does not exist or the object
// exists but is not accessible.
return ((ooHandle(ooFDObj)*)fImp)->exist(bootFile.Data(),(ooMode)openMode);
}
//______________________________________________________________________________
Bool_t rooFDObj::isValid() const
{
// Checks the validity of an object reference or handle.
return ((ooHandle(ooFDObj)*)fImp)->isValid();
}
//______________________________________________________________________________
Bool_t rooFDObj::lock(Int_t lockMode) const
{
// Explicitly locks the federated database and propagates the lock to any
// objects associated through links that have lock propagation enabled.
return ((ooHandle(ooFDObj)*)fImp)->lock((ooLockMode)lockMode);
}
//______________________________________________________________________________
TString rooFDObj::lockServerName() const
{
// Retrieves the name of the host running the lock
// server process for the federated database.
return TString(((ooHandle(ooFDObj)*)fImp)->lockServerName());
}
//______________________________________________________________________________
TString rooFDObj::name() const
{
// Returns the system name of the referenced federated database. The
// string is statically allocated by the member function and is overwritten
// with each invocation (you may wish to copy the string to locally
// allocated storage rather than storing the pointer).
return TString(((ooHandle(ooFDObj)*)fImp)->name());
}
//______________________________________________________________________________
ULong_t rooFDObj::number() const
{
// Retrieves the identifier of the federated database.
return ((ooHandle(ooFDObj)*)fImp)->number();
}
//______________________________________________________________________________
Bool_t rooFDObj::open(const TString& bootFile,
Int_t openMode,
Bool_t recover) const
{
// bootFile - path to the boot file of the federated database.
// The default value is "". You can specify this
// path with or without a host name. If you specify
// it as a host path, use the format host::path.
// openMode - specifies the open mode for the federated database.
// Valid values for openMode are the constants kooRead
// and kooUpdate. The default open mode is kooRead.
// recover - specifies whether automatic recovery on the local
// host should be performed on application startup.
//
// Initializes object reference or handle to reference the federated
// database specified by bootFilePath. The federated database is
// opened in the mode specified by openMode.
//
// Any number of processes may open the same federated database for
// either read or update access as long as no other process has obtained
// an explicit lock on it using the lock member function. If a process has
// obtained an explicit read lock, any other process may open the
// federated database for read access. If a process has obtained an explicit
// update lock, no other process may open it.
//
// If you intend to alter the contents (any objects it contains) of a
// federated database, you must open it for update access, or any changes
// made will be lost.
const char* boot = bootFile.IsNull() ? 0 : bootFile.Data();
Bool_t ret = ((ooHandle(ooFDObj)*)fImp)->open(boot,
(ooMode)openMode,recover);
if(ret) {
if(boot) gROOT->GetListOfBrowsables()->Add(this,boot);
fTitle = bootFile;
gprevFD = gooTopFD;
gooTopFD = this;
}
return ret;
}
//______________________________________________________________________________
Int_t rooFDObj::openMode() const
{
// Returns the mode in which the currently referenced federated database
// has been opened.
return ((ooHandle(ooFDObj)*)fImp)->openMode();
}
//______________________________________________________________________________
UInt_t rooFDObj::pageSize() const
{
// Obtains the page size of the federated database.
return ((ooHandle(ooFDObj)*)fImp)->pageSize();
}
//______________________________________________________________________________
Bool_t rooFDObj::tidy(FILE* fp,
const TString& hostName,
const TString& pathName) const
{
// fp - pointer to the file in which to store the audit
// report generated by running the member function
// hostName - specifies the name of the host machine on
// which to create the scratch file.
// pathName - specifies the path for the scratch file.
//
// Tidies all of the databases in a federated database.
return ((ooHandle(ooFDObj)*)fImp)->tidy(fp,hostName.Data(),
pathName.Data());
}
//______________________________________________________________________________
Int_t rooFDObj::typeN() const
{
// Type number of the federated database.
return ((ooHandle(ooFDObj)*)fImp)->typeN();
}
//______________________________________________________________________________
TString rooFDObj::typeName() const
{
// Returns the string "ooFDObj"
return TString(((ooHandle(ooFDObj)*)fImp)->typeName());
}
//______________________________________________________________________________
Bool_t rooFDObj::update() const
{
// Opens the referenced federated database in update access mode.
return ((ooHandle(ooFDObj)*)fImp)->update();
}
//______________________________________________________________________________
Bool_t rooFDObj::upgradeObjects()
{
// Convert objects using stored schema evolution information and
// user-defined functions (if any).
//
// After object conversion is complete, the evolved classes are marked so
// that applications created using the evolved schema can access the
// federated database. Also, unneeded stored schema evolution
// information is deleted upon successful completion.
return ((ooHandle(ooFDObj)*)fImp)->upgradeObjects();
}
//______________________________________________________________________________
void rooFDObj::Browse(TBrowser *b)
{
// browse databases in this federated database
rooDBObj* db;
if(!isValid() || !b) return;
rooDBItr dbI;
Bool_t rc;
rc = contains(dbI);
if(!rc) return;
while(dbI.next()) {
db = new rooDBObj(dbI);
b->Add(db);
}
}
ROOT page - Class index - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.