// @(#)root/meta:$Id$
// Author: Fons Rademakers   20/06/96

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TDictionary                                                          //
//                                                                      //
// This class defines an abstract interface that must be implemented    //
// by all classes that contain dictionary information.                  //
//                                                                      //
// The dictionary is defined by the followling classes:                 //
// TDataType                              (typedef definitions)         //
// TGlobal                                (global variables)            //
// TGlobalFunc                            (global functions)            //
// TClass                                 (classes)                     //
//    TBaseClass                          (base classes)                //
//    TDataMember                         (class datamembers)           //
//    TMethod                             (class methods)               //
//       TMethodArg                       (method arguments)            //
//                                                                      //
// All the above classes implement the TDictionary abstract interface.  //
// Note: the indentation shows aggregation not inheritance.             //
//                                                                      //
// TMethodCall                            (method call environment)     //
//                                                                      //
//Begin_Html
/*
<img src="gif/tdictionary_classtree.gif">
*/
//End_Html
//////////////////////////////////////////////////////////////////////////

#include "TDictionary.h"
#include "TClass.h"
#include "TClassEdit.h"
#include "TDataType.h"
#include "TDictAttributeMap.h"
#include "TInterpreter.h"
#include "TROOT.h"


ClassImp(TDictionary)

TDictionary::TDictionary(const TDictionary& dict):
   TNamed(dict),
   fAttributeMap(dict.fAttributeMap ?
                 ((TDictAttributeMap*)dict.fAttributeMap->Clone()) : 0 ),
   fUpdatingTransactionCount(0)
{
   // Copy constructor, cloning fAttributeMap.
}

TDictionary::~TDictionary()
{
   // Destruct a TDictionary, delete the attribute map.
   delete fAttributeMap;
}

TDictionary &TDictionary::operator=(const TDictionary& dict)
{
  // Assignment op, cloning fAttributeMap.
  TNamed::operator=(dict);

  delete fAttributeMap;
  fAttributeMap = 0;
  if (dict.fAttributeMap)
    fAttributeMap = ((TDictAttributeMap*)dict.fAttributeMap->Clone());

  return *this;
}

void TDictionary::CreateAttributeMap()
{
   //Create a TDictAttributeMap for a TClass to be able to add attribute pairs
   //key-value to the TClass.

   if (!fAttributeMap)
      fAttributeMap = new TDictAttributeMap;
}

TDictionary* TDictionary::GetDictionary(const char* name)
{
   // Retrieve the type (class, fundamental type, typedef etc)
   // named "name". Returned object is either a TClass or TDataType.
   // Returns 0 if the type is unknown.

   TDictionary* ret = (TDictionary*)gROOT->GetListOfTypes()->FindObject(name);
   if (ret) return ret;

   return TClass::GetClass(name, true);
}

TDictionary* TDictionary::GetDictionary(const type_info &typeinfo)
{
   // Retrieve the type (class, fundamental type, typedef etc)
   // with typeid typeinfo. Returned object is either a TClass or TDataType.
   // Returns 0 if the type is unknown.

   EDataType datatype = TDataType::GetType(typeinfo);
   TDictionary* ret = TDataType::GetDataType(datatype);
   if (ret) return ret;

   return TClass::GetClass(typeinfo, true);
}

Bool_t TDictionary::UpdateInterpreterStateMarker()
{
   // Return true if there were any transactions that could have changed the
   // state of the object.
   ULong64_t currentTransaction = gInterpreter->GetInterpreterStateMarker();
   if (currentTransaction == fUpdatingTransactionCount) {
      return false;
   }
   fUpdatingTransactionCount = currentTransaction;
   return true;
}
 TDictionary.cxx:1
 TDictionary.cxx:2
 TDictionary.cxx:3
 TDictionary.cxx:4
 TDictionary.cxx:5
 TDictionary.cxx:6
 TDictionary.cxx:7
 TDictionary.cxx:8
 TDictionary.cxx:9
 TDictionary.cxx:10
 TDictionary.cxx:11
 TDictionary.cxx:12
 TDictionary.cxx:13
 TDictionary.cxx:14
 TDictionary.cxx:15
 TDictionary.cxx:16
 TDictionary.cxx:17
 TDictionary.cxx:18
 TDictionary.cxx:19
 TDictionary.cxx:20
 TDictionary.cxx:21
 TDictionary.cxx:22
 TDictionary.cxx:23
 TDictionary.cxx:24
 TDictionary.cxx:25
 TDictionary.cxx:26
 TDictionary.cxx:27
 TDictionary.cxx:28
 TDictionary.cxx:29
 TDictionary.cxx:30
 TDictionary.cxx:31
 TDictionary.cxx:32
 TDictionary.cxx:33
 TDictionary.cxx:34
 TDictionary.cxx:35
 TDictionary.cxx:36
 TDictionary.cxx:37
 TDictionary.cxx:38
 TDictionary.cxx:39
 TDictionary.cxx:40
 TDictionary.cxx:41
 TDictionary.cxx:42
 TDictionary.cxx:43
 TDictionary.cxx:44
 TDictionary.cxx:45
 TDictionary.cxx:46
 TDictionary.cxx:47
 TDictionary.cxx:48
 TDictionary.cxx:49
 TDictionary.cxx:50
 TDictionary.cxx:51
 TDictionary.cxx:52
 TDictionary.cxx:53
 TDictionary.cxx:54
 TDictionary.cxx:55
 TDictionary.cxx:56
 TDictionary.cxx:57
 TDictionary.cxx:58
 TDictionary.cxx:59
 TDictionary.cxx:60
 TDictionary.cxx:61
 TDictionary.cxx:62
 TDictionary.cxx:63
 TDictionary.cxx:64
 TDictionary.cxx:65
 TDictionary.cxx:66
 TDictionary.cxx:67
 TDictionary.cxx:68
 TDictionary.cxx:69
 TDictionary.cxx:70
 TDictionary.cxx:71
 TDictionary.cxx:72
 TDictionary.cxx:73
 TDictionary.cxx:74
 TDictionary.cxx:75
 TDictionary.cxx:76
 TDictionary.cxx:77
 TDictionary.cxx:78
 TDictionary.cxx:79
 TDictionary.cxx:80
 TDictionary.cxx:81
 TDictionary.cxx:82
 TDictionary.cxx:83
 TDictionary.cxx:84
 TDictionary.cxx:85
 TDictionary.cxx:86
 TDictionary.cxx:87
 TDictionary.cxx:88
 TDictionary.cxx:89
 TDictionary.cxx:90
 TDictionary.cxx:91
 TDictionary.cxx:92
 TDictionary.cxx:93
 TDictionary.cxx:94
 TDictionary.cxx:95
 TDictionary.cxx:96
 TDictionary.cxx:97
 TDictionary.cxx:98
 TDictionary.cxx:99
 TDictionary.cxx:100
 TDictionary.cxx:101
 TDictionary.cxx:102
 TDictionary.cxx:103
 TDictionary.cxx:104
 TDictionary.cxx:105
 TDictionary.cxx:106
 TDictionary.cxx:107
 TDictionary.cxx:108
 TDictionary.cxx:109
 TDictionary.cxx:110
 TDictionary.cxx:111
 TDictionary.cxx:112
 TDictionary.cxx:113
 TDictionary.cxx:114
 TDictionary.cxx:115
 TDictionary.cxx:116
 TDictionary.cxx:117
 TDictionary.cxx:118
 TDictionary.cxx:119
 TDictionary.cxx:120
 TDictionary.cxx:121
 TDictionary.cxx:122
 TDictionary.cxx:123
 TDictionary.cxx:124