Software Archive
Read-only legacy content
17061 Discussions

overloadin in COM server

rahzan
Novice
301 Views
I am still a bit unclear as to whether the COM server methods are placed in a module or not. Specifically, I would like to overload a method and the only trick I know is by way of Interface and module-procedure statements. Can this be done for the methods of a COM server??
if so, how?

Thanks in advance,
Tim
0 Kudos
5 Replies
canaimasoft
Beginner
301 Views
Tim,

I think the concept of overloading doesn't exist in COM. You have objects that support interfaces, which are sort of a contract, and that's about it. An object can support many interfaces, but the methods and arguments to these methods are defined in the interface and fixed. Your objects either support or don't support an interface as a whole. This of course doen't stop you from implementing overloading inside your object, but this is something that has to be dealt with internally.

regards,

Marco A. Garcia
Canaima Software
P.O. Box 13162
La Jolla, CA. 92039
U.S.A.
e-mail:mgarcia@canaimasoft.com
Tel/Fax: (619) 233-6831
http://www.canaimasoft.com
Developers of f90SQL the Database Connectivity Solution for Fortran, and f90VB the Library for Fortran-OLE Automation and Fortran-VB Programming
0 Kudos
rahzan
Novice
301 Views
Thanks Marco,
I am finding out more and more than the O in COM has little resemblence to the usual O in OOP!
First I find out that I cannot pass arg's to the "constructor" hence it's not really a constrcutor as in OOP and now you say overloading/polymorphism is out.

At least I'm glad for once that these things are not Fortran's shortcoming.

Tim
0 Kudos
canaimasoft
Beginner
301 Views
Hi Tim,

I didn't say polymorphism, just overloading. In COM, polymorphism (although perhaps not in the strict sense) can be achieved through the use of interfaces...

regards,

Marco A. Garcia
Canaima Software, Inc.
www.canaimasoft.com
0 Kudos
rahzan
Novice
301 Views
Sorry to use loose language, still:
overloading is acheived in CVF (as I understand it) only by way of interfaces. (as I mentioned byu way of Module-procedure etc). So are yousaying that there is a way to do overloading using interfaces?

Tim
0 Kudos
canaimasoft
Beginner
301 Views
Tim,

When I say overloading, I'm talking about function overloading. Without intention of discussing their merits, there are two concepts extensively used in OOP that are not supported in COM: function overloading and multiple inheritance. The definition of a function (method) in a COM interface cannot be overloaded. In other words, a single COM interface cannot have three methods called MyMethod, each taking different types of arguments.

Regarding polymorphism, it is possible in COM. Here is a typical example (From Inside OLE ? Brockschmidt):
 
 
interface IAnimal : IUnknown 
    { 
    HRESULT Eat(...); 
    HRESULT Sleep(...); 
    HRESULT Procreate(...); 
    } 
 
interface IRabbit : IAnimal 
    { 
    HRESULT RaidGardens(...); 
    HRESULT Hop(...); 
    HRESULT DigWarrens(...); 
    } 
 
interface IKoala : IAnimal 
    { 
    HRESULT ClimbEucalyptusTrees(...); 
    HRESULT PouchOpensDown(...); 
    HRESULT SleepForHoursAfterEating(...); 
    } 
 


A Rabbit object (which implements the IRabbit interface) is polymorphic, because it can be also treated as a general Animal (the IAnimal interface). You can call the Eat method of a rabbit object, and the same for a Koala object (implementing IKoala interface). The implementation of the Eat method, however, doesn?t have to be the same for both animals.

Note that I have been always talking about COM interfaces, do not confuse Fortran interfaces with COM interfaces. They are completely different animals

regards,

Marco A. Garcia
0 Kudos
Reply