Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TMethodArg.cxx
Go to the documentation of this file.
1 // @(#)root/meta:$Id$
2 // Author: Rene Brun 04/02/95
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #include "TMethodArg.h"
13 #include "TROOT.h"
14 #include "TInterpreter.h"
15 #include "Strlen.h"
16 #include "TMethod.h"
17 #include "TMethodCall.h"
18 #include "TDataMember.h"
19 
20 /** \class TMethodArg
21 Each ROOT method (see TMethod) has a linked list of its arguments.
22 This class describes one single method argument.
23 The method argument info is obtained via the CINT api.
24 See class TCling.
25 
26 The method argument information is used a.o. in the TContextMenu
27 and THtml classes.
28 */
29 
30 ClassImp(TMethodArg);
31 
32 ////////////////////////////////////////////////////////////////////////////////
33 /// Default TMethodArg ctor. TMethodArgs are constructed in TFunction
34 /// via a call to TCling::CreateListOfMethodArgs().
35 
36 TMethodArg::TMethodArg(MethodArgInfo_t *info, TFunction *method) : TDictionary()
37 {
38  fDataMember = 0;
39  fInfo = info;
40  fMethod = method;
41  if (fInfo) {
42  SetName(gCling->MethodArgInfo_Name(fInfo));
43  SetTitle(gCling->MethodArgInfo_TypeName(fInfo));
44  }
45 }
46 
47 ////////////////////////////////////////////////////////////////////////////////
48 /// TMethodArg dtor deletes adopted CINT MethodArgInfo object.
49 
50 TMethodArg::~TMethodArg()
51 {
52  if (fInfo) gCling->MethodArgInfo_Delete(fInfo);
53 }
54 
55 ////////////////////////////////////////////////////////////////////////////////
56 /// Get default value of method argument.
57 
58 const char *TMethodArg::GetDefault() const
59 {
60  return gCling->MethodArgInfo_DefaultValue(fInfo);
61 }
62 
63 ////////////////////////////////////////////////////////////////////////////////
64 /// Get type of method argument, e.g.: "class TDirectory*" -> "TDirectory"
65 /// Result needs to be used or copied immediately.
66 
67 const char *TMethodArg::GetTypeName() const
68 {
69  return gCling->TypeName(gCling->MethodArgInfo_TypeName(fInfo));
70 }
71 
72 ////////////////////////////////////////////////////////////////////////////////
73 /// Get full type description of method argument, e.g.: "class TDirectory*".
74 
75 const char *TMethodArg::GetFullTypeName() const
76 {
77  return gCling->MethodArgInfo_TypeName(fInfo);
78 }
79 
80 ////////////////////////////////////////////////////////////////////////////////
81 /// Get the normalized name of the return type. A normalized name is fully
82 /// qualified and has all typedef desugared except for the 'special' typedef
83 /// which include Double32_t, Float16_t, [U]Long64_t and std::string. It
84 /// also has std:: removed [This is subject to change].
85 
86 std::string TMethodArg::GetTypeNormalizedName() const
87 {
88  return gCling->MethodArgInfo_TypeNormalizedName(fInfo);
89 }
90 
91 ////////////////////////////////////////////////////////////////////////////////
92 /// Get property description word. For meaning of bits see EProperty.
93 
94 Long_t TMethodArg::Property() const
95 {
96  return gCling->MethodArgInfo_Property(fInfo);
97 }
98 
99 ////////////////////////////////////////////////////////////////////////////////
100 /// Returns list of possible options - according to pointed datamember.
101 /// If there is no datamember field assigned to this methodarg - returns 0.
102 
103 TList *TMethodArg::GetOptions() const
104 {
105  return (TList*)(fDataMember ? fDataMember->GetOptions() : 0);
106 }
107 
108 ////////////////////////////////////////////////////////////////////////////////
109 /// Returns TDataMember pointed by this methodarg.
110 /// If you want to specify list of options or current value for your
111 /// MethodArg (i.e. it is used as initial values in argument-asking dialogs
112 /// popped up from context-meny),you can get this value from one of data
113 /// members of the class.
114 ///
115 /// The only restriction is, that this DataMember object must have its
116 /// Getter/Setter methods set-up correctly - for details look at TDataMember.
117 /// To learn how to specify the data member to which the argument should
118 /// "point", look at TMethod. This is TMethod which sets up fDataMember,
119 /// so it could work correctly.
120 
121 TDataMember *TMethodArg::GetDataMember() const
122 {
123  return fDataMember;
124 }
125 
126 ////////////////////////////////////////////////////////////////////////////////
127 /// Update fInfo (to 0 for unloading and non-zero for reloading).
128 /// This takes ownership of 'info'
129 
130 void TMethodArg::Update(MethodArgInfo_t *info)
131 {
132  if (fInfo) gCling->MethodArgInfo_Delete(fInfo);
133  fInfo = info;
134  if (fInfo) {
135  SetTitle(gCling->MethodArgInfo_TypeName(fInfo));
136  }
137 }