// @(#)root/cont
// Author: Philippe Canal Aug 2013

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

#ifndef ROOT_TListOfFunctionTemplates
#define ROOT_TListOfFunctionTemplates

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TListOfFunctionTemplates                                             //
//                                                                      //
// A collection of TFunctionTemplate objects designed for fast access   //
// given a DeclId_t and for keep track of TFunctionTempalte that were   //
// described unloaded function.                                         //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_THastList
#include "THashList.h"
#endif

#ifndef ROOT_THastTable
#include "THashTable.h"
#endif

#ifndef ROOT_TDictionary
#include "TDictionary.h"
#endif

class TExMap;
class TFunctionTemplate;

class TListOfFunctionTemplates : public THashList
{
private:
   typedef TDictionary::DeclId_t DeclId_t;
   TClass    *fClass; // Context of this list.  Not owned.

   TExMap    *fIds;      // Map from DeclId_t to TFunction*
   THashList *fUnloaded; // Holder of TFunction for unloaded functions.
   THashTable fOverloads; // TLists of overloads.
   ULong64_t  fLastLoadMarker; // Represent interpreter state when we last did a full load.

   TListOfFunctionTemplates(const TListOfFunctionTemplates&);              // not implemented
   TListOfFunctionTemplates& operator=(const TListOfFunctionTemplates&);   // not implemented
   TList     *GetListForObjectNonConst(const char* name);

   void       MapObject(TObject *obj);
   void       UnmapObject(TObject *obj);

public:

   TListOfFunctionTemplates(TClass *cl);
   ~TListOfFunctionTemplates();

   virtual void Clear(Option_t *option);
   virtual void Delete(Option_t *option="");

   using THashList::FindObject;
   virtual TObject   *FindObject(const char *name) const;
   virtual TList     *GetListForObject(const char* name) const;
   virtual TList     *GetListForObject(const TObject* obj) const;

   TFunctionTemplate *Get(DeclId_t id);

   void       AddFirst(TObject *obj);
   void       AddFirst(TObject *obj, Option_t *opt);
   void       AddLast(TObject *obj);
   void       AddLast(TObject *obj, Option_t *opt);
   void       AddAt(TObject *obj, Int_t idx);
   void       AddAfter(const TObject *after, TObject *obj);
   void       AddAfter(TObjLink *after, TObject *obj);
   void       AddBefore(const TObject *before, TObject *obj);
   void       AddBefore(TObjLink *before, TObject *obj);

   void       RecursiveRemove(TObject *obj);
   TObject   *Remove(TObject *obj);
   TObject   *Remove(TObjLink *lnk);

   void Load();
   void Unload();
   void Unload(TFunctionTemplate *func);

   ClassDef(TListOfFunctionTemplates,0);  // List of TFunctions for a class
};

#endif // ROOT_TListOfFunctionTemplates
 TListOfFunctionTemplates.h:1
 TListOfFunctionTemplates.h:2
 TListOfFunctionTemplates.h:3
 TListOfFunctionTemplates.h:4
 TListOfFunctionTemplates.h:5
 TListOfFunctionTemplates.h:6
 TListOfFunctionTemplates.h:7
 TListOfFunctionTemplates.h:8
 TListOfFunctionTemplates.h:9
 TListOfFunctionTemplates.h:10
 TListOfFunctionTemplates.h:11
 TListOfFunctionTemplates.h:12
 TListOfFunctionTemplates.h:13
 TListOfFunctionTemplates.h:14
 TListOfFunctionTemplates.h:15
 TListOfFunctionTemplates.h:16
 TListOfFunctionTemplates.h:17
 TListOfFunctionTemplates.h:18
 TListOfFunctionTemplates.h:19
 TListOfFunctionTemplates.h:20
 TListOfFunctionTemplates.h:21
 TListOfFunctionTemplates.h:22
 TListOfFunctionTemplates.h:23
 TListOfFunctionTemplates.h:24
 TListOfFunctionTemplates.h:25
 TListOfFunctionTemplates.h:26
 TListOfFunctionTemplates.h:27
 TListOfFunctionTemplates.h:28
 TListOfFunctionTemplates.h:29
 TListOfFunctionTemplates.h:30
 TListOfFunctionTemplates.h:31
 TListOfFunctionTemplates.h:32
 TListOfFunctionTemplates.h:33
 TListOfFunctionTemplates.h:34
 TListOfFunctionTemplates.h:35
 TListOfFunctionTemplates.h:36
 TListOfFunctionTemplates.h:37
 TListOfFunctionTemplates.h:38
 TListOfFunctionTemplates.h:39
 TListOfFunctionTemplates.h:40
 TListOfFunctionTemplates.h:41
 TListOfFunctionTemplates.h:42
 TListOfFunctionTemplates.h:43
 TListOfFunctionTemplates.h:44
 TListOfFunctionTemplates.h:45
 TListOfFunctionTemplates.h:46
 TListOfFunctionTemplates.h:47
 TListOfFunctionTemplates.h:48
 TListOfFunctionTemplates.h:49
 TListOfFunctionTemplates.h:50
 TListOfFunctionTemplates.h:51
 TListOfFunctionTemplates.h:52
 TListOfFunctionTemplates.h:53
 TListOfFunctionTemplates.h:54
 TListOfFunctionTemplates.h:55
 TListOfFunctionTemplates.h:56
 TListOfFunctionTemplates.h:57
 TListOfFunctionTemplates.h:58
 TListOfFunctionTemplates.h:59
 TListOfFunctionTemplates.h:60
 TListOfFunctionTemplates.h:61
 TListOfFunctionTemplates.h:62
 TListOfFunctionTemplates.h:63
 TListOfFunctionTemplates.h:64
 TListOfFunctionTemplates.h:65
 TListOfFunctionTemplates.h:66
 TListOfFunctionTemplates.h:67
 TListOfFunctionTemplates.h:68
 TListOfFunctionTemplates.h:69
 TListOfFunctionTemplates.h:70
 TListOfFunctionTemplates.h:71
 TListOfFunctionTemplates.h:72
 TListOfFunctionTemplates.h:73
 TListOfFunctionTemplates.h:74
 TListOfFunctionTemplates.h:75
 TListOfFunctionTemplates.h:76
 TListOfFunctionTemplates.h:77
 TListOfFunctionTemplates.h:78
 TListOfFunctionTemplates.h:79
 TListOfFunctionTemplates.h:80
 TListOfFunctionTemplates.h:81
 TListOfFunctionTemplates.h:82
 TListOfFunctionTemplates.h:83
 TListOfFunctionTemplates.h:84
 TListOfFunctionTemplates.h:85
 TListOfFunctionTemplates.h:86
 TListOfFunctionTemplates.h:87
 TListOfFunctionTemplates.h:88
 TListOfFunctionTemplates.h:89
 TListOfFunctionTemplates.h:90
 TListOfFunctionTemplates.h:91
 TListOfFunctionTemplates.h:92
 TListOfFunctionTemplates.h:93
 TListOfFunctionTemplates.h:94