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
0
votes
1 answer

Adding layer of drawable objects to separate logic from graphics

I am trying to program classical snake game. I have logic working (eating, growing moving etc.). Now I want to add some nice graphics. So far I have some ugly graphics i made with this code: (pseudocode) void drawWorld(const std::vector
roslav
  • 470
  • 3
  • 15
0
votes
1 answer

Error passing a generic type from a class to another

I am using Delphi 2010 I get the error: E2506 Method of parameterized type declared in interface section must not use local symbol. Is there a way to accomplish this task? unit Unit1; interface uses Windows, Messages, SysUtils, Variants,…
0
votes
6 answers

C++: treating structure members as an array

I have a structure containing lots (like, hundreds) of pointers. Each pointer is a different type, but they all inherit from a common base class --- let's call it Base. I'm using multiple inheritance. (This is all machine-generated, which is why…
David Given
  • 13,277
  • 9
  • 76
  • 123
0
votes
2 answers

Verify base object is of a particular derived type

I have a Visual Studio 2008 C++03 project where I would like to verify if an object is of a certain type. For example: int main() { struct A { virtual ~A() { }; }; struct B : public A { }; struct C : public A { }; A* b = new B(); …
PaulH
  • 7,759
  • 8
  • 66
  • 143
0
votes
1 answer

Why does my C++Builder 'enum' not work correctly with RTTI

Possible Duplicate: Why do I get “type has no typeinfo” error with an enum type I have a component with a property like this:- enum class Foo {VAL0, VAL1, VAL2, VAL4 =4}; class TDummy : public TComponent { ... Foo f; TDummy() : f(Foo:VAL2)…
Roddy
  • 66,617
  • 42
  • 165
  • 277
0
votes
1 answer

Delphi XE TValue.From(True) does not yield TValue boolean

I have a boolean field which I want to set using MyField.SetValue(Self, MyValue). No matter what I tried, I keep getting typecast errors. The problem is that MyValue always contains an ordinal and is not recognized as containing a boolean. I know…
deColaman
  • 213
  • 2
  • 14
0
votes
1 answer

how to get all the classes in an application

I am writing a localization application in which i am reading the DFM information from the application resource through EnumResourceNames API call. However, the function returns me a name of the form for which the DFM is associated. I tried getting…
Rahul W
  • 833
  • 11
  • 26
0
votes
2 answers

Retrieving just the type of an object

I am using OGRE and I have run into an issue that is not so much specific to ORGE, but is a genreal C++ issue I am dealing with. ORGE just helps with the context of the question. There is a macro that is something such as OGRE_DELETE_T(obj,…
jack
  • 562
  • 1
  • 11
  • 22
-1
votes
2 answers

C++ gcc 9.3.0 typeid of derived pointer always return typeid(BaseClass*) but dynamic_cast works fine

There are a few similar posts, here is my minimal case code: bool useDerived=true; BaseClass* maker; if (useDerived) { maker = new DerivedClass(); } else { maker = new BaseClass(); } if (typeid(maker) == typeid(DerivedClass*)) { cerr <<…
Kemin Zhou
  • 6,264
  • 2
  • 48
  • 56
-1
votes
1 answer

How can I save just the last result of ping (using linux terminal)?

I have this bash command bellow (I think this is bash) but it's not overriding the last result. I've tried with only one ">" and ">|" as well, but no success. My goal is to save only the last line on a .txt file (if possible just save the "time"…
-1
votes
2 answers

Avoiding object-slicing in vector>

I'm storing my game's states (collections of entities, essentially) in a vector of shared pointers. When adding states to the vector, the derived part of the states is lost and they revert to the base state class. It all compiles fine, but when I…
Inigo Selwood
  • 822
  • 9
  • 20
-1
votes
1 answer

Is it possible to retrieve TypeInfo from a string using the new Delphi's RTTI library?

I'm wondering if this is possible. I want to get the TypeInfo, passing the type's name as a string. Something like this: type TSomeValues = record ValueOne: Integer; ValueTwo: string; end; function ReturnTypeInfo(aTypeName: string):…
Leo Bruno
  • 474
  • 3
  • 16
-1
votes
1 answer

Setting dynamicly a property of an object containing datetime

I have a bunch of different methods for creating, calling and setting properties of different objects using Delphi's RTTI. But now I have come to an error where setting a TDateTime triggers an error like: "Cannot convert variant into double". Google…
John
  • 261
  • 2
  • 16
-1
votes
1 answer

How to read other process memory

So, I have a class that uses WM_COPYDATA to allow applications to communicate. type TMyRec = record Name: string[255]; Age: integer; Birthday: TDateTime; end; function TAppCommunication.SendRecord(const ARecordToSend: Pointer; const…
-1
votes
1 answer

inherit from std::function (despite the existing advice)

I have read the reasons why inheriting from std::function is a bad idea. I can live with no virtual destructor: there is only one place in my program where the subclass needs to be deleted, and I know exactly where that is, so I'm happy to do the…
1 2 3
54
55