Graeme Geldenhuys wrote:
So what do I use to create interfaces and classes that implement interfaces?
Which declaration style do I use? Or doesn't it make a difference?
type
ICommand = interface(IInterface)
vs
ICommand = interface(IUnkown)
They are exactly the same ? (D<=5 and D>=6 compatibility)
ICommand = interface
Under $interfaces com, interface = interface(iunknown)
Now for created classes that implement those interfaces. What base
object do I use?
type
TCommandClass = class(TInterfacedObject, ICommand)
vs
TCommandClass = class(TSomeCustomNonReferenceCountedClass, ICommand)
I am using my own classes that implement _addref, _release and QueryIntf
and am very happy with them. I do use refcounting where I want
(everywhere btw) and don't destroy the instance where I don't want.
You will want to use TInterfacedObject class if you:
1. Want refcounting;
2. Don't want to destroy the instance if the refcount <> 0 (the object
will raise an exception);
3. Don't need to descend from another class.
4. Will take care with circular references.
Otherwise you will need to create your own class and:
1. implement _addref, _release and QueryIntf if using com interfaces;
2. do nothing if using corba interfaces (I have no idea how an interface
is "queried" here).
I can't imagine that usig Corba style interfaces that I'm allowed to
use TInterfacedObject as a based class, because TInterfacedObject
implements reference counting. Is there some other base class I'm
supposed to use with Corba style interfaces?
Any class. Afaik corba interfaces doesn't implement a method ?
Does FPC have a Non-Reference counted base class already? It's quite
simple to implement you own, but is stupid if FPC doesn't already have
one.
Err... a class doesn't have refcount, just start with TObject or a
descendant.
Also, do I have to specify {$Interfaces Corba} in every unit I have,
or is it only needed in the using that defines the interface itself?
You need. See eg MSE units.
Basically, is that compiler setting unit based or project (global)
based. Why I ask, is because {$mode xxx} is unit based, not global
across my whole project. So can I mix Reference counted and
Non-Reference counted interface styles in the same project?
Any compiler directive is unit based. The unit where you declared the
interface is what will count here.
I found find any help referencing these issues.... The help topics on
interfaces and $Interfaces styles are very vague.
Not vague, they was straight to the point imo.
--
Joao Morais
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel