473,756 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Interfaces problem

pnp
Hi all,
I've created an app that loads some dlls dynamically from the
filesystem. All the dlls implement a certain interface so that they can
be easily manipulated from the main app. The dlls work as plugins for
the main app.
What I want to do is give some extra functionality to the dlls so that
each dll can have some extra functions inside it, that the other dlls
are not required to have (so I cannot add more functions to the main
interface that all the dlls implement). I would like all the changes to
be made to the plugin dlls and not the main app (so when a new plugin is
created I wouldn't like to change the main app as well).

How can I achieve this?

-pnp
Nov 16 '05 #1
3 1124
pnp wrote:
Hi all,
I've created an app that loads some dlls dynamically from the
filesystem. All the dlls implement a certain interface so that they can
be easily manipulated from the main app. The dlls work as plugins for
the main app.
What I want to do is give some extra functionality to the dlls so
that each dll can have some extra functions inside it, that the other
dlls are not required to have (so I cannot add more functions to the
main interface that all the dlls implement). I would like all the
changes to be made to the plugin dlls and not the main app (so when a
new plugin is created I wouldn't like to change the main app as well).

How can I achieve this?

-pnp

You can create the classes inheriting from the classes which implement
the common interfaces. I just don't see why there is any problem there.

Jianwei
Nov 16 '05 #2
pnp
When I load the dll, I use it's functionality by unwraping it and
casting it to the main interface. If I create a class that inherits from
a class that implements the interface how would I use it's functions?

John Sun wrote:
pnp wrote:
Hi all,
I've created an app that loads some dlls dynamically from the
filesystem. All the dlls implement a certain interface so that they
can be easily manipulated from the main app. The dlls work as plugins
for the main app.
What I want to do is give some extra functionality to the dlls so
that each dll can have some extra functions inside it, that the other
dlls are not required to have (so I cannot add more functions to the
main interface that all the dlls implement). I would like all the
changes to be made to the plugin dlls and not the main app (so when a
new plugin is created I wouldn't like to change the main app as well).

How can I achieve this?

-pnp


You can create the classes inheriting from the classes which implement
the common interfaces. I just don't see why there is any problem there.

Jianwei

Nov 16 '05 #3
I see two possible solutions, depending upon how the extra functions in
the various DLLs are related, and whether they logically fall into
groups that must either be completely implemented or not implemented at
all.

If you are going to have groups of extra functions, you could create
other interfaces that a given class may implement or not. Then, in the
main class, you could say

IOptionalInterf ace1 oi1 = loadedClass as IOptionalInterf ace1;
if (oi1 != null)
{
... call methods in optional interface ...
}

On the other hand, if your optional methods / properties are not
related in this way, then you may have to resort to using Reflection
and testing for particular method names. You can then invoke the
methods using Reflection as well.

Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
2026
by: Franco Gustavo | last post by:
Hi, Please help me to understand this, because I don't see what I'm missing. I was reading a lot of examples on Internet that explain that C# doesn't implement multiple inheritance it implement multiple interfaces.
3
1229
by: Darren | last post by:
Do event members belong in interfaces? I have used events in interfaces to report state changes and they work well. However; I really never see event members in any of the framework interfaces. So, is there some reason for this lack of event members in the framework interfaces beside the fact that they may not be needed? Is it a performance issue or a design issue or maybe there is not problem with this design?
17
2353
by: Picho | last post by:
Hi all, I popped up this question a while ago, and I thought it was worth checking again now... (maybe something has changed or something will change). I read this book about component oriented design (owreilly - Juval Lowy), and it was actually very nice. The book goes on about how we should use Interfaces exposure instead of classes (this is my terminology and english is not my language so I hope you understand what I'm on about...).
30
2512
by: Frank Rizzo | last post by:
We are having one of those religious debates at work: Interfaces vs Classes. My take is that Classes give you more flexibility. You can enforce a contract on the descendant classes by marking methods abstract (which is all that an interface does). In addition, the classes allow you to be flexible by adding functionality that child classes inherit. Or by providing optional functionality via virtual methods. Now, I understand that...
18
1985
by: _dee | last post by:
Question about best use of interfaces: Say there's a 'Master' class that needs to implement a few interfaces: class Master : I1, I2, I3 { } The actual code already exists in smaller classes that each
22
2111
by: RSH | last post by:
Hi, I have been reading on interfaces working on samples I've run across on the web. For the life of me I cannot seem to grasp them. It appears to me that interfaces are simply blueprints to a class, that when implemented, they require the implementing calss to make sure that each of the properties, functions etc. are handled by the class. (????) What I am really having a problem with is how they overcome the limitation
23
2217
by: A.Gallus | last post by:
If I declare a function pure virtual: class A { virtual void myfunc() = 0; } and I derive a class from A: class B : public A
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10034
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5142
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.