//*-- Author : Valeriy Onuchin 11/09/2000 
//
//
////////////////////////////////////////////////////////////////////////////////
//
// rooContObj corresponds to ooHandle(ooContObj) class
//
// Handle class for containers

#include "rooObjy.h"
#include <ooas.h>
#include <oo.h>
#include <TROOT.h>
#include <TBrowser.h>

ClassImp(rooContObj)

////////////////////////////////////////////////////////////////////////////////
//______________________________________________________________________________
 rooContObj::rooContObj()
{
   // default ctor.
   
   fImp = new ooHandle(ooContObj)();
}

//______________________________________________________________________________
 rooContObj::rooContObj(const rooContObj& cnt)
{
   // ooHandleStructor(ooContObj)(const ooHandle(ooContObj)& objH);

   fImp = new ooHandle(ooContObj)(*((ooHandle(ooContObj)*)cnt.getImp()));
}

//______________________________________________________________________________
 rooContObj::rooContObj(const rooObj& obj)
{
   // ooHandleStructor(ooContObj)(const ooId& id);

   ooHandle(ooObj)* in = (ooHandle(ooObj)*)obj.getImp();
   fImp = new ooHandle(ooContObj)((ooId&)*in);
}

//______________________________________________________________________________
rooContObj& rooContObj::operator=(const rooContObj& cnt)
{
   // assign  ooperator

   *((ooHandle(ooContObj)*)fImp) = *((ooHandle(ooContObj)*)cnt.getImp());
   return *this; 
}

//______________________________________________________________________________
 Bool_t rooContObj::close() const
{
   // Explicitly closes container
   
   return ((ooHandle(ooContObj)*)fImp)->close();
}

//______________________________________________________________________________
 rooDBObj rooContObj::containedIn() const
{
   // Returns objecthandle to database in which the container
   // is contained.

   ooHandle(ooDBObj) db = ((ooHandle(ooContObj)*)fImp)->containedIn();
   return rooDBObj(&db);
}

//______________________________________________________________________________
//rooDBObj& rooContObj::containedIn(rooDBObj& db) const
//{
   //
//
//   ooHandle(ooDBObj) contDB;
//   contDB = ((ooHandle(ooContObj)*)fImp)->containedIn(contDB);
//   db.setImp((void*)&contDB);
//   return &db;
//}

//______________________________________________________________________________
 Bool_t rooContObj::contains(rooObjItr& itr,Int_t openMode) const
{
   // Initializes the iterator itr to traverse all referenced basic objects in
   // the container. Objects of the iteration are automatically opened in the
   // mode specified by openMode; the default is kooNoOpen (do not open the
   // container automatically).
   
   ooItr(ooObj)* objItr =  (ooItr(ooObj)*)itr.getImp();
   return ((ooHandle(ooContObj)*)fImp)->contains(*objItr,(ooMode)openMode);
}

//______________________________________________________________________________
 Bool_t rooContObj::convertObjects()
{
   // Convert all objects affected by schema evolution operations within a
   // container to their current class representations. This will also bring 
   // all indexes up to date. Calling this member function more than once on a
   // specific container has no effect.
   
   return ((ooHandle(ooContObj)*)fImp)->convertObjects();
}

//______________________________________________________________________________
 Bool_t rooContObj::exist(const rooDBObj &db,
                         const TString& contName,
                         Int_t openMode)
{
   // Test for the existence of a container. Returns the constant kTRUE if
   // the container with system name contSysName exists in the database
   // referenced by handle db, otherwise returns kFALSE. If the
   // container exists and openMode is kooRead or kooUpdate, the
   // container is opened and its object reference or handle is initialized to
   // the container. If openMode is kooRead or kooUpdate, and exist
   // returns kFALSE, the container either does not exist or the container
   // exists but is not accessible, and the object reference or handle is set to
   // null. If openMode is kooNoOpen and the container exists, the container
   // is not opened, but the object reference or handle is initialized to the
   // container. If openMode is kooNoOpen and the container does not exist,
   // the container is not opened, and the object reference or handle is set to
   // null.
   
   ooHandle(ooDBObj)* obj = (ooHandle(ooDBObj)*) db.getImp();
   return ((ooHandle(ooContObj)*)fImp)->exist(*obj,contName.Data(),(ooMode)openMode);
}

//______________________________________________________________________________
 Int_t rooContObj::hash() const
{
   // Returns the hash value used as a clustering factor for an indexed
   // container. The hash value is the number of sequentially indexed objects
   // to place into a page when creating named or keyed objects within the
   // container. The hash value is set when the container is created. 
   //
   // Returns 0 if the container is not hashed; otherwise, returns a non-zero
   // value. Returns -1 f the handle is null or the container can not be
   // opened.
   
   return ((ooHandle(ooContObj)*)fImp)->hash();
}

//______________________________________________________________________________
 Bool_t rooContObj::isUpdated() const
{
   // Returns kTRUE only if the container has been updated by another
   // process since being opened by the current process for an MROW read
   // operation. It returns kFALSE in all other cases.
   
   return ((ooHandle(ooContObj)*)fImp)->isUpdated();
}

//______________________________________________________________________________
 Bool_t rooContObj::lockNoProp(Int_t lockMode) const
{
   // Explicitly locks the container without propagation semantics.
   
   return ((ooHandle(ooContObj)*)fImp)->lockNoProp((ooLockMode)lockMode);
}

//______________________________________________________________________________
 Bool_t rooContObj::lookupObj(const rooObj& scope,
                             const TString& name,Int_t openMode) const
{
   // Sets object reference or handle to reference the container with the
   // name name in the scope of the object specified by the handle scope,
   // and opens the container in the mode specified by openMode. Default
   // scope object is gooTopDB.
   
   ooHandle(ooObj)* obj =  (ooHandle(ooObj)*)scope.getImp();
   return ((ooHandle(ooContObj)*)fImp)->lookupObj(*obj,name.Data(),(ooMode)openMode);
}

//______________________________________________________________________________
 Bool_t rooContObj::lookupObj(const TString& name,Int_t openMode) const
{
   // Sets object reference or handle to reference the container with the
   // name name in the scope of the object specified by the handle scope,
   // and opens the container in the mode specified by openMode. Default
   // scope object is gooTopDB.
   
   return ((ooHandle(ooContObj)*)fImp)->lookupObj(name.Data(),(ooMode)openMode);
}

//______________________________________________________________________________
 TString rooContObj::name() const
{
   // Returns the system name of the referenced container. 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(ooContObj)*)fImp)->name());
}

//______________________________________________________________________________
 ULong_t rooContObj::nPage() const
{
   // Returns current number of pages in the container.
   
   return ((ooHandle(ooContObj)*)fImp)->nPage();
}

//______________________________________________________________________________
 Bool_t rooContObj::open(Int_t openMode) const
{
   // Opens the referenced container in the access mode specified by
   // openMode, either kooRead and kooUpdate. The default open mode is
   // kooRead.
   //
   // Any number of processes may open the same container for read access
   // as long as no process has it open for update access. No process may
   // open a container for update access if any other process has it open for
   // read access. No other process may open a container if any other process
   // has it open for update access unless MROW is in effect. The access
   // restrictions imposed by a process's access to a container applies until
   // the transaction in which the container was opened is terminated
   // (either committed or aborted).
   
   return ((ooHandle(ooContObj)*)fImp)->open((ooMode)openMode);
}

//______________________________________________________________________________
 Bool_t rooContObj::open(const TString& name,Int_t openMode) const
{
   // Opens the referenced container in the access mode specified by
   // openMode, either kooRead and kooUpdate. The default open mode is
   // kooRead.
   //
   // Opens the container specified by system name - name.
   //
   // Any number of processes may open the same container for read access
   // as long as no process has it open for update access. No process may
   // open a container for update access if any other process has it open for
   // read access. No other process may open a container if any other process
   // has it open for update access unless MROW is in effect. The access
   // restrictions imposed by a process's access to a container applies until
   // the transaction in which the container was opened is terminated
   // (either committed or aborted).
   
   return ((ooHandle(ooContObj)*)fImp)->open(name.Data(),(ooMode)openMode);
}

//______________________________________________________________________________
 Bool_t rooContObj::open(const rooDBObj& db,
                        const TString& name,Int_t openMode) const
{
   // Opens the referenced container in the access mode specified by
   // openMode, either kooRead and kooUpdate. The default open mode is
   // kooRead.
   //
   // Opens the container specified by system name and the database
   // in which the container resides, db.
   //
   // Any number of processes may open the same container for read access
   // as long as no process has it open for update access. No process may
   // open a container for update access if any other process has it open for
   // read access. No other process may open a container if any other process
   // has it open for update access unless MROW is in effect. The access
   // restrictions imposed by a process's access to a container applies until
   // the transaction in which the container was opened is terminated
   // (either committed or aborted).
   
   ooHandle(ooDBObj)* obj = (ooHandle(ooDBObj)*) db.getImp();
   return ((ooHandle(ooContObj)*)fImp)->open(*obj,name.Data(),(ooMode)openMode);
}

//______________________________________________________________________________
 Int_t rooContObj::openMode() const
{
   // Returns the mode in which the currently referenced container has been
   // opened.
   
   return ((ooHandle(ooContObj)*)fImp)->openMode();
}

//______________________________________________________________________________
 ULong_t rooContObj::percentGrow() const
{
   // Returns the growth factor for the container. The container grows by
   // this percent of its current size. The percent growth is set when the
   // container is created.
   
   return ((ooHandle(ooContObj)*)fImp)->percentGrow();
}

//______________________________________________________________________________
//   Bool_t   refreshOpen(Int_t openMode=oocRead,) const;

//______________________________________________________________________________
 void rooContObj::Print(Option_t *option)
{
   // print out persistent data for all bject inthis container

   rooObjItr oI;
   Bool_t rc;

   rc = contains(oI);
   if(!rc) return;

   while(oI.next()) {
      oI.Print();
   }   
}

//______________________________________________________________________________
 void rooContObj::Browse(TBrowser *b)
{
   // Browse content of this container

   rooObj* obj;
   rooObjItr oI;
   Bool_t rc;

   if(!b) return;
   rc = contains(oI);
   if(!rc) return;

   while(oI.next()) {
      obj = new rooObj(oI);   // mem.leak?   
      b->Add(obj);
   }   
}


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.