Advanced Delphi

Moderators: None (Apply to moderate this forum)
Number of threads: 333
Number of posts: 743

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Ancestor Class visibility and Class Incompatibility Posted by DelphiScribe on 7 Oct 2008 at 3:58 AM
I am working on a project that consists of a suite of applications written in D5. I estimate that there are around 2 million lines of code in all.
The database used is MySQL, and for various reasons which I won't go into, I am writing the needed code to migrate to Firebird SQL 2.x.
Database access code is largely restricted to a single unit, with two other dependent units playing a lesser role.
So, for example, there are classes such as TMySQLConn (DB Connection component), TMySQLQuery (Query component), TMySQLFields (collection of TMySLQFields, which is a property of TMySQLQuery), etc.
The source code is littered with calls this database code, such as:
with TMySQLQuery.Create (of the order of 698 such calls)
The intention is to avoid having to change this code in any way, so I've written a parallel class library, for want of a better term, which uses the IBXpress Components as ancestors for the components needed, with the same names. a #DEFINE at the start of the unit, tells the compiler which code to compile.
I'm now attempting to compile the code of the principal application, and am encountering a variety of problems, most of which are easily solvable, often with help from this forum.
I've now encountered something that has me baffled.
In the source code which I do not want to change, are calls to TMySQLField. In the database class library I've written, TMySQLField inherits from TField. When I compile the code, the error message says their is a class incompatibility between TMySQLField and TField. It looks like the compiler is looking up the inheritance chain and identifying my TMySLQField as of type TField, which it is since TMySQLField inherits from TField.
Note also that TMySQLField and TField are not identical.
There are a few methods in TMySQLField that do not exist in TField, and there are calls to these methods in the application source code. In other words, TMySQLField TField.
Short of changing the TMySQLField to TField in the application source code, something I am very reluctant to do, is there any other way around the problem?
Regards,
Morman McFarlane

Report
Re: Ancestor Class visibility and Class Incompatibility Posted by pritaeas on 7 Oct 2008 at 5:54 AM
: Short of changing the TMySQLField to TField in the application
: source code, something I am very reluctant to do, is there any other
: way around the problem?
: Regards,
: Morman McFarlane

Is it possible that there is a naming conflict somewhere ? Maybe there is another TField it is looking at.

I don't know your code, but perhaps it is possible to use a typecast.

TMySqlField(MyField) or TField(MySqlField)
Report
Re: Ancestor Class visibility and Class Incompatibility Posted by DelphiScribe on 27 Oct 2008 at 2:53 AM
: : Short of changing the TMySQLField to TField in the application
: : source code, something I am very reluctant to do, is there any other
: : way around the problem?
: : Regards,
: : Morman McFarlane
:
: Is it possible that there is a naming conflict somewhere ? Maybe
: there is another TField it is looking at.
:
: I don't know your code, but perhaps it is possible to use a typecast.
:
: TMySqlField(MyField) or TField(MySqlField)
Thanks, already tried that, and it doesn't work. It raises an exception.
Regards,
Norman



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.