rtti

Delphi: RTTI and TObjectList<TObject>

笑着哭i 提交于 2020-02-02 04:06:47
问题 Based on one answer to an earlier post, I'm investigating the possibility of the following design TChildClass = class(TObject) private FField1: string; FField2: string; end; TMyClass = class(TObject) private FField1: TChildClass; FField2: TObjectList<TChildClass>; end; Now, in the real world, TMyClass will have 10 different lists like this, so I would like to be able to address these lists using RTTI. However, I'm not interested in the other fields of this class, so I need to check if a

Why do Items from one comboBox not copy to another?

不羁岁月 提交于 2020-01-25 12:25:49
问题 I have multiple comboboxes on a tabpage on a tabcontrol on a form. Trying to loop through the controls has not worked (see this). So, I tried to go at it from another angle: finding the controls based on their name. As an initial POC, I just wanted to brute force it by providing the name of one of the combo boxes that is empty at design time ("cmbxRow0Element1") and assign the items from cmbxRow0Element0 to it. But both this attempt: Control ctrl = this.Controls["cmbxRow0Element1"]; ComboBox

Does using __declspec(novtable) on abstract base classes affect RTTI in any way?

て烟熏妆下的殇ゞ 提交于 2020-01-22 17:45:29
问题 Or, are there any other known negative affects of employing __declspec(novtable)? I can't seem to find references to any issues. 回答1: MSCV uses one vptr per object and one vtbl per class to implement OO mechanism such as RTTI and virtual functions. So RTTI and virtual functions will work fine if and only if the vptr has been set correctly. struct __declspec(novtable) B { virtual void f() = 0; }; struct D1 : B { D1() { } // after the construction of D1, vptr will be set to vtbl of D1. }; D1 d1

TRttiMethod.Invoke function doesn't work in overloaded methods?

空扰寡人 提交于 2020-01-20 05:05:15
问题 I'm creating an instance of a class using the TRttiMethod.Invoke function , but when the constructor or a method is overloaded, the rtti does not call the proper method. I wrote a sample app to ilustate my problem. program ProjectFoo; {$APPTYPE CONSOLE} {$R *.res} uses Rtti, System.SysUtils; type TFoo=class public constructor Create(Value : Integer);overload; constructor Create(const Value : string);overload; function Bar(value : integer) : Integer; overload; function Bar(const value : string

TRttiMethod.Invoke function doesn't work in overloaded methods?

浪尽此生 提交于 2020-01-20 05:04:45
问题 I'm creating an instance of a class using the TRttiMethod.Invoke function , but when the constructor or a method is overloaded, the rtti does not call the proper method. I wrote a sample app to ilustate my problem. program ProjectFoo; {$APPTYPE CONSOLE} {$R *.res} uses Rtti, System.SysUtils; type TFoo=class public constructor Create(Value : Integer);overload; constructor Create(const Value : string);overload; function Bar(value : integer) : Integer; overload; function Bar(const value : string

Managing diverse classes with a central manager without RTTI

无人久伴 提交于 2020-01-16 05:12:05
问题 I have a design question that has been bugging me for a while but I cannot find a good (in a OOP sense) solution for this. The language is C++ and I keep coming back to RTTI - which is often referred to as an indicator for bad design. Suppose we have a set of different kinds of modules implemented as different classes. Each kind of module is characterized by a defined interface, however the implementation may vary. Thus my first idea was to create an interface (pure abstract) class for each

Can type_info pointers be used to distingush types in C++?

好久不见. 提交于 2020-01-15 23:13:24
问题 I have a set of polymorphic C++ classes and they are all instantiated by the same module (Windows DLL). Now having two pointers to such classes and having called typeid : SomeCommonBase* first = ...; //valid pointer SomeCommonBase* second = ...; //valid pointer const type_info& firstInfo = typeid( first ); const type_info& secondInfo = typeid( second ); can I compare retrieved type_info addresses if( &firstInfo == &secondInfo ) { //objects are of the same class } else { //objects are of

How do I turn on RTTI with Cygwin?

柔情痞子 提交于 2020-01-14 12:37:27
问题 When my Android NDK C++ native code is compiled, the following error appears: error: 'dynamic_cast' not permitted with -fno-rtti Someone told me to turn on RTTI, but I didn't know how to do. Do I need to modify Application.mk or what? my Application.mk : # it is needed for ndk-r5 APP_STL := stlport_static APP_ABI := armeabi armeabi-v7a APP_MODULES := cocos2d cocosdenshion chipmunk box2d tempestkeep When I add APP_CPPFLAGS += -frtti in some .o file appears another error: undefined reference to

warning message RTTI symbol not found when using boost::iostreams

喜欢而已 提交于 2020-01-14 08:59:12
问题 I use Boost::iostreams to write simultaneously to my console and a file. When i use eclipse to debug(with gdb of course), i receive a warning which says RTTI symbol not found for one of the classes that i am using from Boost::iostreams. Here is the minimal code to reproduce the problem. #ifndef BOOST_IO_STREAM_H_ #define BOOST_IO_STREAM_H_ #include <fstream> #include <boost/iostreams/tee.hpp> #include <boost/iostreams/stream.hpp> using boost::iostreams::tee_device; using boost::iostreams:

C++: using typeinfo to test class inheritance

て烟熏妆下的殇ゞ 提交于 2020-01-10 03:06:07
问题 I have a pointer to a polymorphic type, p . I also have a type_info for a class somewhere in the same hierarchy, ti . If I just compare the typeid(*p) == ti , then I can test at runtime whether the pointer is pointing to a direct instance of that class. Is there a similar way to use C++'s RTTI to test whether *p inherits from that class? 回答1: There's no way to do this in standard C++ alone. If you're using an implementation that has the Itanium C++ ABI 1 you can do this though, for example: