Qt-interest Archive, October 2007
Re: Plugins loadable once, per Application or per Thread?
Message 1 in thread
Hi Justin!
Not sure what exactly a factory is, but plugins seem to
be loadable in every thread.
Thanks anyway..
Frank
Justin Noel wrote:
> Frank wrote:
>> Hello!
>>
>> The Plugins can be loadable only once into memory, I know.
>> But what about loading them annother time but in a different Thread?
>> That's a rare situation and one would like a code avoiding this,
>> but I my situation it might be the fastest (refering to code
>> development time) solution.
>>
>
> How about making the actual Qt Plugins just factories for the classes
> you are currently calling your "plugins". Once the factories are in
> memory you can create and destroy as many instances as you want.
>
> --Justin
--
[ signature omitted ]
Message 2 in thread
Frank,
I suggest reading this page about the Factory Pattern:
http://en.wikipedia.org/wiki/Factory_pattern
I also suggest this book:
http://www.amazon.com/Design-Patterns-Object-Oriented-Addison-Wesley-Professional/dp/0201633612
Factories are classes whose sole purpose is to create instances of other
classes. The setup usually looks like this:
//An Abstract Class
class AbstractClass : public QObject
{
Q_OBJECT
public:
virtual void someVirtual()=0;
}
//A concrete class
class ActualClass : public AbstractClass
{
Q_OBJECT
public:
virtual void someVirtual();
}
//Abstract Factory
class AbstractClassFactory
{
public:
virtual AbstractClass* create()=0;
};
//Factory for ActualClass
class ActualClassFactory : AbstractClassFactory
{
public:
virtual AbstractClass* create() { return new ActualClass; }
};
If the plugins were factories then you wouldn't have to waste the time
and energy to reload all the libraries.
--Justin
Frank wrote:
> Hi Justin!
>
> Not sure what exactly a factory is, but plugins seem to
> be loadable in every thread.
>
> Thanks anyway..
> Frank
>
> Justin Noel wrote:
>
>
>> Frank wrote:
>>
>>> Hello!
>>>
>>> The Plugins can be loadable only once into memory, I know.
>>> But what about loading them annother time but in a different Thread?
>>> That's a rare situation and one would like a code avoiding this,
>>> but I my situation it might be the fastest (refering to code
>>> development time) solution.
>>>
>>>
>> How about making the actual Qt Plugins just factories for the classes
>> you are currently calling your "plugins". Once the factories are in
>> memory you can create and destroy as many instances as you want.
>>
>> --Justin
>>
>
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
begin:vcard
begin:vcard
fn:Justin Noel
n:Noel;Justin
org:ICS;Engineering
adr:;;54B Middlesex Trpk;Bedford;MA;01730;USA
email;internet:justin@xxxxxxx
title:Sr. Consulting Engineer / Certified Qt Instructor
tel;work:(617) 621-0060
url:http://www.ics.com
version:2.1
end:vcard