473,408 Members | 1,968 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

The best way to create a plugin based application in C++?

Hi,

I have a couple of doubts reggarding a plugin based application in C++?

I want to build a c++ plugin based app. I have searched alot of things
in the net but I still don't know how to start this.

For example:
I want the plugin to be able to expose functions and HANDLES (for
synchronization with WaitForSingleObject for example).
I want the plugin to internally be able to run a thread which is called
by an exposed function and stopped that thread by an other function.

I WOULD LIKE TO AVOID auto generated code because..well I didn't do it
and I will get a hard time trying to correct an error. The other
problem is the C++ sintax. I would like to keep it clean. Perhaps this
is a dum' question but why does C++ has so many types for the same
thing? Why does it have to be a long, LONG, HRESULT, etc... Why just
not long and thats it.

1º - Which strategy is best in order to perform this task? A simple
DLL, or more of a COM style dll with interfaces?

2º - How do I develop that strategy (the plugin structure, the
wrapper, etc..)?

3º - Regarding variables, threads and HANDLES. How should they be
created? In a class? Global variables?
How does the cliente application uses and see them and uses them?
Thanks in advanced...

Dec 1 '06 #1
4 3704
Paciente8159 AKA Klayman wrote:
I have a couple of doubts reggarding a plugin based application in
C++?
Why is that a question? How should we know if you have doubts?
I want to build a c++ plugin based app. I have searched alot of things
in the net but I still don't know how to start this.
Every C++ program has to have the 'main' function. Here is its simplest
implementation:

int main()
{
}

'return 0' is optional. Start by introducing the translation unit into
your program and placing the 'main' function there.
For example:
I want the plugin to be able to [..]

I WOULD LIKE TO AVOID auto generated code [..]

1º - Which strategy is best in order to perform this task? A simple
DLL, or more of a COM style dll with interfaces?

2º - How do I develop that strategy (the plugin structure, the
wrapper, etc..)?

3º - Regarding variables, threads and HANDLES. How should they be
created? In a class? Global variables?
How does the cliente application uses and see them and uses them?
None of those question relate to C++ langauge. I strongly recommend
you to post your questions to 'comp.software-eng'. The fact that you
want to implement your architecture in C++ has no relevance here.

When you encounter a C++ _language_ problem, come back, read the FAQ,
post according to the guidelines, and we will try to help you.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Dec 1 '06 #2

Victor Bazarov wrote:
I WOULD LIKE TO AVOID auto generated code [..]

1º - Which strategy is best in order to perform this task? A simple
DLL, or more of a COM style dll with interfaces?

2º - How do I develop that strategy (the plugin structure, the
wrapper, etc..)?

3º - Regarding variables, threads and HANDLES. How should they be
created? In a class? Global variables?
How does the cliente application uses and see them and uses them?

None of those question relate to C++ langauge. I strongly recommend
you to post your questions to 'comp.software-eng'.
Actually, many of those question are highly relevant to C++ language
design, or at least common implementation.

E.g. "simple DLL" approach using C++ has the problem that to maintain
plugin interfaces can be somewhat difficult as adding any virtual
function or data member anywhere breaks the interface. This is quite
C++ specific problem.

With "COM style" original poster does not want to discuss windows
architecture, but rather avoiding large portion of above problem by
exposing just interfaces based on virtual methods (possiby pure
virtual).

I believe that question 3 mostly deals with problem of wrapping
resources and distributing the problem between plugin interface and
plugin / application code.

If you are using "COM like" interfaces, you have resource management
problem, because these interfaces are usually exposed as pointers. So I
guess the question there was whether, how and where to provide helper
classes to manage interface lifetimes. Or maybe to use PIMPL?

Many interesting and C++ related problems. Deserves discussion here
IMHO.

Mirek

Dec 2 '06 #3
Mirek Fidler wrote:
Victor Bazarov wrote:
>>I WOULD LIKE TO AVOID auto generated code [..]

1º - Which strategy is best in order to perform this task? A simple
DLL, or more of a COM style dll with interfaces?

2º - How do I develop that strategy (the plugin structure, the
wrapper, etc..)?

3º - Regarding variables, threads and HANDLES. How should they be
created? In a class? Global variables?
How does the cliente application uses and see them and uses them?

None of those question relate to C++ langauge. I strongly recommend
you to post your questions to 'comp.software-eng'.

Actually, many of those question are highly relevant to C++ language
design, or at least common implementation.
Are you saying that by answering those questions we can figure out how
to design C++ better? Or are you saying that the design of C++ already
dictates the answers to those questions?
E.g. "simple DLL" approach using C++ has the problem that to maintain
plugin interfaces can be somewhat difficult as adding any virtual
function or data member anywhere breaks the interface. This is quite
C++ specific problem.
This is not a language problem. It's a system maintenance problem.
And it doesn't relate to C++ alone, but to any language where virtual
functions are implemented. That is why the answer cannot be given
in terms of C++ language, can it?

Choosing "simple DLL" over "COM" is based on the mere merits of those
approaches, and NOT on any features of the language. Virtual functions
are means to an end, they don't have any trait which would make them
a decision-making point, speaking in the language terms. It is purely
a *software engineering* decision.
With "COM style" original poster does not want to discuss windows
architecture, but rather avoiding large portion of above problem by
exposing just interfaces based on virtual methods (possiby pure
virtual).
So? How is it a language problem? If he wants to expose it, let him.
He's not really asking "how", is he? Because that's a COM question,
isn't it?
I believe that question 3 mostly deals with problem of wrapping
resources and distributing the problem between plugin interface and
plugin / application code.
And how is that a language problem, again? The language does *not*
make any of those things preferrable. It all depends on the choice
of the development team and/or the designers of the library/app.
How any of their concerns can be addressed in terms of C++?
If you are using "COM like" interfaces, you have resource management
problem, because these interfaces are usually exposed as pointers. So
I guess the question there was whether, how and where to provide
helper classes to manage interface lifetimes. Or maybe to use PIMPL?
PIMPL is *not* a feature of the language. And it does not serve any
*language*-related problem, does it? It serves the purpose of reducing
the compilation time by reducing dependencies.
Many interesting and C++ related problems. Deserves discussion here
IMHO.
Good. Prove me wrong. Answer the OP's concerns in terms of the C++
language alone. Keep in mind, though, that as soon as you start
comparing technologies ("COM vs simple DLL") based on their own merits,
you're off topic.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Dec 4 '06 #4

Victor Bazarov wrote:
Are you saying that by answering those questions we can figure out how
to design C++ better?
I guess designing better C++ is not the main purpose of this group.
Or are you saying that the design of C++ already
dictates the answers to those questions?
Yes.
This is not a language problem. It's a system maintenance problem.
And it doesn't relate to C++ alone, but to any language where virtual
functions are implemented.
In no language the problem is as prevailing as in C++.
That is why the answer cannot be given
in terms of C++ language, can it?
Why not?
approaches, and NOT on any features of the language. Virtual functions
are means to an end, they don't have any trait which would make them
a decision-making point, speaking in the language terms. It is purely
a *software engineering* decision.
Everything is a *software engineering* decision.
So? How is it a language problem? If he wants to expose it, let him.
He's not really asking "how", is he? Because that's a COM question,
isn't it?
That has nothing to do with COM.
I believe that question 3 mostly deals with problem of wrapping
resources and distributing the problem between plugin interface and
plugin / application code.

And how is that a language problem, again?
So it is forbidden to discuss merits and pitfalls of e.g.
boost::shared_ptr here?

Is not reference counting just generic programming technique?
Good. Prove me wrong. Answer the OP's concerns in terms of the C++
language alone. Keep in mind, though, that as soon as you start
comparing technologies ("COM vs simple DLL") based on their own merits,
you're off topic.
The real question is: What are problems of inter-modul interface when
using *C++* to implement modules?

If you replace "C++" in the question with "Objective C" or "Visual
Basic" or "C#", answers will be radically different. Therefore this is
strongly C++ related problem.

Any "answer" has to deal with following C++ specific features:

- C++ lacks garbage collector
- C++ lacks introspection
- C++ object layout makes any interface extremely fragile with respect
to module version

Mirek

Dec 4 '06 #5

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

Similar topics

53
by: Paul Rubin | last post by:
I've been approached about writing a Windows app which will need a really professional looking GUI. Forget TKinter, this has to actually look good (real artists will be available to get the visual...
7
by: Reinhold Birkenfeld | last post by:
Hello, another philosophical question: How would you implement a plugin system (for a web-based application)? Conditions are: - One plugin can have one or many "parts" (or "subplugins", or...
0
by: serge calderara | last post by:
Dear all, I have a library named Video.dll which provide certain vido functionnality as wel as menu and proprety using an interface. This library is working as a plugin Then I have my main...
5
by: Christoph Haas | last post by:
Dear coders... I'm working on an application that is supposed to support "plugins". The idea is to use the plugins as packages like this: Plugins/ __init__.py Plugin1.py Plugin2.py...
3
by: Roger Boesch | last post by:
Im currently working on a plugin architectur for a software product written in c# and have found the following problem: Project a) Application, Application with all classes used in this app ...
0
by: David Levine | last post by:
This is a lengthy post; please bear with me... This will be a large system with dozens of plugins. In addition to plugins developed internally there will be 3rd parties that will write their own...
0
by: Greg Conely via .NET 247 | last post by:
I am creating a application that will be using plugins. I am doing this so that when I want to let this application work with another type of dbase system, I only have to write\install one plugin,...
6
by: S. Lorétan | last post by:
Hi guys. I am preparing the rewriting of an huge existing application in VB6. This software is a mess of 10 years of patchs and new functionalities added randomly, and didn't have any logical or...
8
by: Flavio | last post by:
Hi, Nowadays the addition of functionality to programs by means of plugins is very frequent. I want to know the opinions of experienced Python developers about the best practices when it...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.