//*-- Author : Valeriy Onuchin 11/09/2000 
//
//
////////////////////////////////////////////////////////////////////////////////
//
// rooClassPosition corresponds to Class_Position Class 
//
// rooClassPosition represents the positions of attributes within classes. 
// Each instance of this class, called a class position, gives the position 
// of a particular attribute in the physical layout for objects of a particular
//  class.
//
//______________________________________________________________________________
//
//             About Class Positions
//
// A class position indicates nesting of data inherited from base classes; 
// You do not instantiate this class directly, instead, you obtain
// the class position for a particular attribute of a particular class by 
// calling the rooClass::position_in_class() member function of a class 
// descriptor,  a class object, or a proposed class; the parameter to the 
// function specifies the attribute of interest.
//
// The class position for an immediate base class or an attribute that is not 
// inherited contains a single number. Such a class position can be converted 
// to and from an unsigned integer. You can call the is_convertible_to_uint() 
// member function to see whether such conversion is possible.
//
// If a class position is one or more levels of inheritance deep, you may not 
// convert it to an integer. An attempt to do so throws a 
// ConvertDeepPositionToInt exception.

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

ClassImp(rooClassPosition)

////////////////////////////////////////////////////////////////////////////////
//______________________________________________________________________________
 rooClassPosition::rooClassPosition() 
{
   // default  ctor., for internal use only

   fImp = new Class_Position();
}

//______________________________________________________________________________
 rooClassPosition::~rooClassPosition()
{
   // or., for internal use only
   
   fImp = 0;
}

//______________________________________________________________________________
Bool_t rooClassPosition::operator==(const rooClassPosition & cp) const
{
   // Returns kTRUE if the two class positions indicate the same path of 
   // attribute positions; 

   if(!fImp) return 0; 
   return *((Class_Position*)fImp) == *((Class_Position*)cp.getImp());
}

//______________________________________________________________________________
rooClassPosition &  rooClassPosition::operator=(const rooClassPosition & cp)
{
   // Returns this class position after it has been updated to be a copy of cp.

   if(fImp) *((Class_Position*)fImp) = *((Class_Position*)cp.getImp());
   else fImp = new Class_Position(*((Class_Position*)cp.getImp()));
   return *this;
}

//______________________________________________________________________________
 Bool_t rooClassPosition::is_convertible_to_uint() const
{
   // Returns kTRUE if this class position gives the position of an immediate 
   // base class or an attribute defined in the class; kFALSE if it gives 
   // the position of an ancestor class or an inherited attribute.

   return fImp ? ((Class_Position*)fImp)->is_convertible_to_uint() : 0;
}

//______________________________________________________________________________
rooClassPosition::operator size_t() const
{
   // Returns this class position converted to the integral position, or -1 if 
   // this is the null class position.
   //   
   // If this is the class position for an immediate base class or an attribute
   // that is not inherited, the returned integer is the attribute position of
   // the base class or attribute within its defining class. If this class 
   // position is one or more levels of inheritance deep, an attempt to convert
   // it to an integer throws a ConvertDeepPositionToInt exception.
   // You can call the is_convertible_to_uint() member function to see whether
   // this class position can be converted to an integer.

   return fImp ? (size_t)(*((Class_Position*)fImp)) : 0;
}

//______________________________________________________________________________
//rooClassPosition::rooClassPosition(Int_t p, rooClassPosition *nP)
//{
   //
//}

//______________________________________________________________________________
 rooClassPosition::rooClassPosition(const rooClassPosition & cp)
{
   // copy constructor
   
   fImp = new Class_Position(*((Class_Position*)cp.getImp()));
}



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.