//*-- Author : Valeriy Onuchin 11/09/2000 
//
//
////////////////////////////////////////////////////////////////////////////////
//
// rooAttribute corresponds to d_Attribute Class
//
// The class rooClass ( aka d_Class ) represents descriptors for attributes of
// classes in the schema of the federated database. An instance of rooAttribute
// (aka d_Attribute) is called an attribute descriptor.
//
//______________________________________________________________________________
//
//             About Attribute Descriptors
//
// An attribute descriptor provides information about a particular attribute, 
// called its described attribute. The described attribute is defined by some 
// class. It stores a particular piece of data for a persistent instance of 
// that class and its derived classes. The described attribute holds either a 
// single value of some type, or a fixed-size array of values of the same type.
//
//______________________________________________________________________________
//
//             Obtaining an Attribute Descriptor
//
// You should never instantiate this class directly. Instead, you can obtain an
// attribute descriptor by calling a member function of either a class 
// descriptor for the class that defines the attribute or a class descriptor 
// for a class that inherits the attribute.

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

ClassImp(rooAttribute)

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

   fImp = 0;
}

//______________________________________________________________________________
 rooAttribute::~rooAttribute()
{
   // dtor. for internal use only
   
   fImp = 0;
}

//______________________________________________________________________________
 UInt_t rooAttribute::dimension() const
{
    // dimension() returns the layout size of the attribute on the platform
    // running the application.

   return fImp ? ((d_Attribute*)fImp)->dimension() : 0;
}

//______________________________________________________________________________
 UInt_t rooAttribute::id() const
{
   // The methods position() and id() yield different numbers.  The one
    // Active Schema uses to access objects is position().  id() is useful
    // because unlike position(), the value it returns stays constant
    // across a schema evolution.  Note also that unlike position() values,
    // id() values are 1-based; they are never zero.
    //
    // Second, position() as the characteristic of an attribute may be
    // misleading in inherited contexts.  If an attribute's class is used
    // as a non-leftmost base class, instances of the derived class may
    // start at, say, position 2, but for the base's first attribute--which
    // could well have other inheritance contexts--position() returns 0.
    // To avoid misinterpretation one can use the d_Class method
    // position_in_class(), which always reflects inheritance context.

   return fImp ? ((d_Attribute*)fImp)->id() : 0;
}

//______________________________________________________________________________
 Int_t rooAttribute::position() const
{
   // The methods position() and id() yield different numbers.  The one
    // Active Schema uses to access objects is position().  id() is useful
    // because unlike position(), the value it returns stays constant
    // across a schema evolution.  Note also that unlike position() values,
    // id() values are 1-based; they are never zero.
    //
    // Second, position() as the characteristic of an attribute may be
    // misleading in inherited contexts.  If an attribute's class is used
    // as a non-leftmost base class, instances of the derived class may
    // start at, say, position 2, but for the base's first attribute--which
    // could well have other inheritance contexts--position() returns 0.
    // To avoid misinterpretation one can use the d_Class method
    // position_in_class(), which always reflects inheritance context.

   return fImp ? ((d_Attribute*)fImp)->position() : 0;
}

//______________________________________________________________________________
 Int_t rooAttribute::array_size() const
{
   // For static array attributes, array_size() returns the cardinality
   // of the array--or 1 if it is not an array.  

   return fImp ? ((d_Attribute*)fImp)->array_size() : 0;
}

//______________________________________________________________________________
 Int_t rooAttribute::element_size() const
{
   // element_size() returns the size in bytes of the type of the attribute
   // on the running platform.  Therefore, dimension() is
   // (element_size() * array_size()).  
   //
   // If the described attribute is not a fixed-size array, this member function
   // returns the same number as dimension.
   
   return fImp ? ((d_Attribute*)fImp)->element_size() : 0;
}

//______________________________________________________________________________
 Bool_t rooAttribute::is_base_class() const
{
   // Returns kTRUE if the described attribute is a base class; 
   // otherwise, kFALSE.
   //
   // A base class is described like an embedded-class attribute; 
   // this member function allows you to test whether an embedded-class 
   // attribute is a base class.
   
   return fImp ? ((d_Attribute*)fImp)->is_base_class() : 0;
}

//______________________________________________________________________________
const rooClass & rooAttribute::class_type_of()
{
   // Returns a class descriptor for the class that is the type of the described
   // attribute.
   //   
   // You should call this member function only if you know that the described 
   // attribute is an embedded-class attribute (or a base class). If the 
   // attribute's type is not a class, this member function throws an 
   // AttributeTypeError exception.

   d_Class& cl = ((d_Attribute*)fImp)->class_type_of();
   if(!cl) return 0;

   if(!fClassTypeOf) fClassTypeOf = new rooClass((void*)&cl);      
   else fClassTypeOf->setImp((void*)&cl);
   return *fClassTypeOf;
}

//______________________________________________________________________________
 Bool_t rooAttribute::has_default_value() const
{
   // Returns kTRUE if the described attribute has a default value; 
   // otherwise, kFALSE.

   return fImp ? ((d_Attribute*)fImp)->has_default_value() : 0;
}

//______________________________________________________________________________
 rooNumericValue rooAttribute::default_value()
{
   // Returns a numeric value containing the default value for the described 
   // attribute, or an invalid numeric value if the described attribute type 
   // is not a basic numeric type or if the attribute has no default value.
   //
   // You can call has_default_value() to test whether the described attribute 
   // has a default value.

   if(!fImp) return 0;
   Numeric_Value val = ((d_Attribute*)fImp)->default_value();

   if(!fDefaultValue) fDefaultValue = new rooNumericValue((void*)&val);      
   else fDefaultValue->setImp((void*)&val);
   return *fDefaultValue;
}

//______________________________________________________________________________
Bool_t rooAttribute::operator==(const rooAttribute & in) const
{
   // Equality operator; tests whether this attribute descriptor is
   // equal to the specified attribute descriptor.

   if(!fImp) return 0;
   return *((d_Attribute*)fImp) == *((d_Attribute*)(in.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.