//*-- Author : Valeriy Onuchin 11/09/2000 
//
//
////////////////////////////////////////////////////////////////////////////////
//
// rooRelationship corresponds to d_Relationship class. 
//
// The class rooRelationship represents descriptors for relationships between
// classes in the schema of the federated database. An instance of 
// rooRelationship is called a relationship descriptor.
//
//______________________________________________________________________________
//
//             About Relationship Descriptors
//
// A relationship descriptor provides information about a particular 
// relationship, called its described relationship.
// You should never instantiate this class directly. Instead, you can obtain 
// a relationship descriptor from a class descriptor for the class that defines
// the relationship:
//
//    Call the rooClass::resolve_relationship() member function of the class 
//    descriptor to look up the relationship by name.
//
//    Call the rooClass::defines_relationship_begin() member function of the 
//    class descriptor to get an iterator for all relationships defined in the 
//    class.
// 
// Because a relationship descriptor is a special kind of attribute 
// descriptor, you can also obtain a relationship descriptor as you would 
// obtain any attribute descriptor. If you do so, however, you need to cast 
// the resulting attribute descriptor to a relationship descriptor before 
// you can call any member function defined in this class.


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

ClassImp(rooRelationship)

////////////////////////////////////////////////////////////////////////////////
//______________________________________________________________________________
 rooRelationship::rooRelationship()
{
   // for internal use only

   fImp = 0;
}

//______________________________________________________________________________
 rooRelationship::~rooRelationship()
{
   //
   
   fImp = 0;
}

//______________________________________________________________________________
 Int_t rooRelationship::rel_kind() const
{
   // Gets the ODMG relationship kind of the described relationship.
   //
   // Returns: The ODMG relationship kind of the described relationship; 
   //    one of the following:
   //       kooREL_REF indicates a to-one relationship.
   //       kooREL_LIST indicates a to-many relationship.
   //
   // Because Objectivity/DB does not support the ODMG relationship type 
   // kooREL_SET, this member function simply tells whether the relationship 
   // is to-one or to-many.
   // The is_to_many() member function is a simpler way to obtain the same
   // information.
 
   return fImp ? ((d_Relationship*)fImp)->rel_kind() : 0;  
}

//______________________________________________________________________________
const rooRelationship & rooRelationship::inverse()
{
   // Returns a relationship descriptor for the inverse relationship of the 
   // described bidirectional relationship, or the null descriptor if the 
   // described relationship is unidirectional.
   //
   // This member function signals a CantFindRelInverse error if it fails to 
   // find the inverse of the described bidirectional relationship.

   if(!fImp) return 0;
   d_Relationship& rel = ((d_Relationship*)fImp)->inverse();
   if(!rel) return 0;

   if(!fInverse)fInverse = new rooRelationship((void*)&rel);      
   else fInverse->setImp((void*)&rel);
   return *fInverse;
}

//______________________________________________________________________________
 Bool_t rooRelationship::is_relationship() const
{
   // Overrides the inherited member function. Indicates that this is a 
   // relationship descriptor. Returns kTRUE

   return fImp ? ((d_Relationship*)fImp)->is_relationship() : 0;
}

//______________________________________________________________________________
 Bool_t rooRelationship::is_bidirectional() const
{
   // Returns kTRUE if the described relationship is bidirectional; 
   // otherwise, kFALSE. 

   return fImp ? ((d_Relationship*)fImp)->is_bidirectional() : 0;
}

//______________________________________________________________________________
 Bool_t rooRelationship::is_inline() const
{
   // Returns kTRUE if the described relationship is an inline relationship; 
   // otherwise, kFALSE

   return fImp ? ((d_Relationship*)fImp)->is_inline() : 0;  
}

//______________________________________________________________________________
 Bool_t rooRelationship::is_short() const
{
   // Returns kTRUE if the described relationship is a short relationship; 
   // otherwise, kFALSE.

   return fImp ? ((d_Relationship*)fImp)->is_short() : 0;
}

//______________________________________________________________________________
 Bool_t rooRelationship::is_to_many() const
{
   // Returns kTRUE if the described relationship is a to-many relationship and
   // kFALSE if it is a to-one relationship.

   return fImp ? ((d_Relationship*)fImp)->is_to_many() : 0; 
}

//______________________________________________________________________________
const rooClass & rooRelationship::other_class()
{
   // Returns a class descriptor for the destination class of the described 
   // relationship.
   //
   // To get the source class of the described relationship, call this 
   // relationship descriptor's inherited defined_in_class() member function.

   if(!fImp) return 0;
   d_Class& cl = ((d_Relationship*)fImp)->other_class();
   if(!cl) return 0;

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

//______________________________________________________________________________
 Int_t rooRelationship::encoded_assoc_number() const
{
   // Returns the type number encoding characteristics of the described 
   // relationship.
   //
   // The bidirectional relationships in the schema are assigned 
   // serially-allocated 32-bit integers, called their encoded association 
   // numbers. Certain high-order bits of an encoded association number are 
   // set to encrypt the relationship's direction and other characteristics.
   // Most applications do not need to work with encoded association numbers.
   // However, if you need to exactly recreate another schema description, 
   // you can call this member function of a relationship descriptor for a 
   // bidirectional relationship that you want to recreate. You can pass the 
   // resulting number as the specifiedAssocNum parameter to the 
   // add_bidirectional_relationship() member function of the proposed class 
   // in which you are duplicating the existing description.
   
   return fImp ? ((d_Relationship*)fImp)->encoded_assoc_number() : 0;
}

//______________________________________________________________________________
 Int_t rooRelationship::versioning() const
{
   // Returns the versioning mode of the described relationship, which 
   // specifies what happens to an association from a source object to a 
   // destination object when a new version of the source object is created; 
   // one of the following:
   //    0 - indicates that this relationship descriptor has no information 
   //       about the versioning mode.
   //    kooVersionDrop - indicates that the association is deleted.
   //    kooVersionMove - indicates that the association is moved from the 
   //       source object to its new version.
   //    kooVersionCopy - indicates that the association is copied from the 
   //       source object to its new version.

   return fImp ? ((d_Relationship*)fImp)->versioning() : 0;
}

//______________________________________________________________________________
 Int_t rooRelationship::propagation() const
{
   // Returns the propagation behavior of the described relationship, 
   // which specifies whether the locking and deletion operations are 
   // propagated from locked or deleted source objects to their related 
   // destination objects; one of the following:
   //
   //    0 - indicates that neither locks nor deletions are propagated.
   //    kooLockPropagationYesDeletePropagationNo - indicates that locks are
   //                   propagated, but deletions are not.
   //    kooLockPropagationNoDeletePropagationYes - indicates that deletions
   //                   are propagated, but locks are not.
   //    kooLockPropagationYesDeletePropagationYes - indicates that both locks
   //                   and deletions are propagated.

   return fImp ? ((d_Relationship*)fImp)->propagation() : 0; 
}

//______________________________________________________________________________
 Int_t rooRelationship::copy_mode() const
{
   // Returns the copy mode of the described relationship, which specifies what
   // happens to an association from a source object to a destination object 
   // when the source object is copied; one of the following:
   //
   //    0 - indicates that this relationship descriptor has no information 
   //       about the copy mode.
   //    kooCopyDrop - indicates that the association is deleted.
   //    kooCopyMove - indicates that the association is moved from the source 
   //                   object to its new copy.
   //    kooCopyCopy - indicates that the association is copied from the source 
   //                   object to the new object.

   return fImp ? ((d_Relationship*)fImp)->copy_mode() : 0;
}


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.