Questions tagged [rtti]

RTTI stands for Run-Time Type Information, it is also known as reflection; it allows access to compile-time data at run-time.

RTTI refers to the ability of the system to report on the dynamic type of an object and to provide information about that type at runtime (as opposed to at compile time). When utilized consistently, it can be a powerful tool to ease the work of the programmer in managing resources, or as the basis for writing reflective code. Further explanation can be found on Wikipedia

824 questions
9
votes
2 answers

Get object's type from pointer to base class at runtime

I'm working with a class library where all classes are, directly or indirectly, derived from a base class Base and have a name. The library provides a facility to search for objects by a name, which will return a Base*. Is there any way to find the…
rainer
  • 6,769
  • 3
  • 23
  • 37
9
votes
4 answers

Delphi Rtti: Explore properties of interfaces?

Is there a way to explore a interface's properties with Rtti? The following code does not work: procedure ExploreProps; var Ctx: TRttiContext; RttiType: TRttiType; RttiProp: TRttiProp; begin RttiType := Ctx.GetType(TypeInfo(IMyInterface)); …
Christian Metzler
  • 2,971
  • 5
  • 24
  • 30
9
votes
3 answers

How do I get the name of the method a method pointer points to?

I have defined the following : a method pointer that returns 0 if a verification is OK or an error code TValidationFunc = Function(AParam: TAnObject): integer Of Object; a list of functions to perform: Functions: TObjectList <…
o.schwab
  • 101
  • 1
  • 7
9
votes
2 answers

Difference between RTTI and reflection in Java

My question is when how does the class info gets loaded during runtime? When someone calls instanceof is that considered RTTI or reflection? Or it depends on the actual situation?
gdlamp
  • 613
  • 1
  • 6
  • 24
9
votes
3 answers

Mixing RTTI flags in C++

If I have multiple linked C++ statically linked libraries in C++, is it possible for them to share (pass to and from functions) class objects if they have been compiled with differing values of enabled/disabled run time type information…
Akusete
  • 10,704
  • 7
  • 57
  • 73
9
votes
1 answer

Setting property value by name

In a Delphi class I have some properties that I would like to set by accessing them by their name. Now I use e.g. Settings.AllowSysop := True; That I would like to do something like Settings('AllowSysop').Value := True; The reason for this is that…
OZ8HP
  • 1,443
  • 4
  • 31
  • 61
9
votes
3 answers

Is an object allowed to legally change its type during its lifetime in C++?

I have this code: class Class { public: virtual void first() {}; virtual void second() {}; }; Class* object = new Class(); object->first(); object->second(); delete object; that I compile with Visual C++ 10 with /O2 and have this…
sharptooth
  • 167,383
  • 100
  • 513
  • 979
8
votes
5 answers

How can I get a dataset of in-memory objects?

Does anyone know of a TDataset descendant that works with Generics and RTTI, so that I can write code like this, and make use of data-aware components in the GUI? : ... ds:TDataset; ... procedure DoStuff; begin …
Wouter van Nifterick
  • 23,603
  • 7
  • 78
  • 122
8
votes
1 answer

How to grab TRTTIParamter's default value

I have this class: TMyClass = class public function DoSomethingNice(const Value: string = 'Yes please!'): Boolean; end; Now, using RTTI, is it possible to get default value of parameter Value of method DoSomethingNice? if so, how? I'm mostly…
user497849
8
votes
1 answer

Is it possible to create TRttiMethod instance for TRttiType with TypeKind=tkMethod?

hi all :) it is my first question at stackoverflow :) in Delphi XE2 RTTI we have TRttiMethod class and it has function CreateImplementation() wich allows to dynamically create procedure or function with the same signature and a anonimous method as…
teran
  • 3,214
  • 1
  • 21
  • 30
8
votes
5 answers

C++ double dispatch "extensible" without RTTI

Does anyone know a way to have double dispatch handled correctly in C++ without using RTTI and dynamic_cast<> and also a solution, in which the class hierarchy is extensible, that is the base class can be derived from further and its…
George Penn.
  • 383
  • 3
  • 13
8
votes
1 answer

Delphi: Is it possible to enumerate all instances of a record (~typed constants) in the global namespace?

From the research I've done so far, I'm already guessing the answer is no but just to make sure... (also, this entry can be updated once support for this is available). The question title should already be self-sufficient I think, but FWIW what I'm…
Oliver Giesen
  • 9,129
  • 6
  • 46
  • 82
8
votes
0 answers

GDB warning: RTTI symbol not found for class

I use Eclipse with GDB. For any smart pointer class I have such as a MyString, I keep getting warning: RTTI symbol not found for class MyString And indeed, I can't see the value held by a smart pointer container: MyString str = "test"; //can see…
user703047
  • 151
  • 1
  • 1
  • 4
8
votes
1 answer

Get Variable Name Using RTTI

I'm trying to get variable name using RTTI like this. Here is my test. type TStringHelper = record helper for string function Name: string; end; TMyRecord = record Field1:string; end; implementation { TStringHelper } function…
İsmail Kocacan
  • 1,204
  • 13
  • 38
8
votes
1 answer

How get ownership property of (Method: TRttiMethod) in TVirtualInterface TVirtualInterfaceInvokeEvent?

how i get ownership property of Method: TRttiMethod in OnInvoke method of TVirtualInterface class? I have this interface: IPerson = interface(IInvokable) ['{45CE428C-F880-4D61-A2C1-0F3CB47130B5}'] procedure SetName(const Value: string); …
Passella
  • 640
  • 1
  • 8
  • 23