473,326 Members | 1,972 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,326 software developers and data experts.

Implementation of Factory Patern using C++ DLL's

Roi
Hello,

I'm trying to implements Factory Patern using 2 DLL's.
On the first DLL i implemented the Factory,
and on the other I defines global variables which activating the
Factory.

the problem is:
The DLL's aren't loaded until I call a function from them,
therefore the global variables aren't initialized and the Factory
doesn't work

Can anyone help me?

Regards in your advice,
Roi

Nov 1 '05 #1
1 2510
On 1 Nov 2005 05:01:59 -0800, "Roi" <ro*******@yahoo.com> wrote:
Hello,

I'm trying to implements Factory Patern using 2 DLL's.
On the first DLL i implemented the Factory,
and on the other I defines global variables which activating the
Factory.

the problem is:
The DLL's aren't loaded until I call a function from them,
therefore the global variables aren't initialized and the Factory
doesn't work

Can anyone help me?

Regards in your advice,
Roi


You might be able to initialize your factory like this: first, put
these in some header file:

extern void FunctionInDll();
struct FactoryInit {
FactoryInit() { FunctionInDll(); }
};

FunctionInDll() can be just a dummy function, or it can do real work
initializing your globals. Often it will increment a counter or set a
flag in order to tell whether the function had been previously called
and/or how many times.

In one of your .cpp files which implement the non-DLL part of your
application, define a static global variable of type FactoryInit:

static FactoryInit fi;

It will be initialized before main() or whatever the entry point is.
The constructor will call the DLL function, thus your globals should
be set up after the object has finished construction.

If you need to control the order of initialization so that this is
done before any other static or global variables, you'll have to
resort to compiler- and platform-specific mechanisms (OT hint: for
MSVC++, look for #pragma init_seg).

--
Bob Hairgrove
No**********@Home.com
Nov 1 '05 #2

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

Similar topics

2
by: mag31 | last post by:
This is a technically challenging question but it would help me significantly if anyone can answer it. In essence I have the following: A factory class, which can create producer classes which...
2
by: Ryan Mitchley | last post by:
Hi all I have code for an object factory, heavily based on an article by Jim Hyslop (although I've made minor modifications). The factory was working fine using g++, but since switching to the...
4
by: Howie | last post by:
Hi, i have a normal class: //test.h class CForwardData; class CTest { CForwardData *pData;
10
by: Mark | last post by:
I have an abstract class, and a set of classes that inherit from my abstract class. The fact that it is abstract is likely irrelevant. I have a static factory method in my abstract class that...
2
by: Sakke | last post by:
Hello! We have written a GCryptoSvr.dll COM server in C++. Inside that resides WebClient COM component. WebClient CLSID is {8DC27D48-F94C-434B-A509-C3E1A3E75B9E}. When we are using that...
1
by: jimmyfo | last post by:
Hi, I recently wrote an ASP.Net web application in VS2005 and published (using VS2005 Publish feature) it to a relatively clean machine with ASP.Net 2.0 and MDAC 2.8 installed on it. However, when...
20
by: Luc Kumps | last post by:
(Sorry about the previous post, it got transmitted before it was complete) We try to separate implementation and interface defintions, but we run into a problem. I hope the guru's can solve this,...
8
by: googlegroups | last post by:
Hi, I need to parse a binary file produced by an embedded system, whose content consists in a set of events laid-out like this: <event 1<data 1<event 2<data 2... <event n<data n> Every...
3
by: suresh_rai | last post by:
Hello I am hoping someone can give me very needed help. I am wanting some C+ + code for 'C++ Abstract Factory'. I need code to be free. I am been learning Design patterns. I found some code on...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.