Posted on 2001-07-26
I think it is a design flaw in the Object Pascal language that interfaces are assumed to be mainly used for COM.
I have a few interfaces that I have written that I would like to use with some of my objects; however, I am forced to implement the methods in IUnknown. This is not a huge problem, but I do not want my objects to be reference counted.
I want each instance of my object to live until I tell it to die, regardless of whether or not there are any interface pointers pointing to it.
Therefore, my plan is to:
1. Copy the implementation of QueryInterface from the QueryInterface of TInterfacedObject.
2. Do nothing in _AddRef and _Release.
I am the only one who is going to be using the interfaces and objects. I just want some advice on whether or not this is safe.
(btw, most of my classes in question inherit from TPersistent. Inheriting from TInterfacedObject is not an option)