Overview
Features
Download
Documentation
Community
Add-Ons & Services

Global class in HTTPFormServer

Please post support and help requests here.

Global class in HTTPFormServer

Postby newbie » 01 Aug 2007, 02:12

Hello!

I am reviewing the example HTTPFormServer from Poco - Net - Samples. I would like to know how to access a global public class I have created in HTTPFormServer constructor from within the handleRequest method of class FormRequestHandler.

Thanks in advance.
newbie
 
Posts: 6
Joined: 13 Jun 2007, 21:07

Re: Global class in HTTPFormServer

Postby peter » 01 Aug 2007, 08:01

> Hello!
>
> I am reviewing the example HTTPFormServer from Poco - Net - Samples. I would like to know how to access a global public class I have created in HTTPFormServer constructor from within the handleRequest method of class FormRequestHandler.
>
> Thanks in advance.
>
Well, not sure what you try to achieve because if you have an instance of that class that is global and public, access should be no problem?

Anyway, theer are three possibilites how you can access another class in your FormRequestHandler:
* public, global instance: really bad, don't use
* singleton pattern: Poco_Util_Application is an example for that. No public constructor, copy constructor, destructor, assignement operator. Only a static MyClass& instance method which holds in its implementation a static local variable of type Poco::SingletonHolder. This is better than the first alternative.
* Ask yourself if you really must make that class available globally. If not, keep it inside your application as a variable, and change the FormRequesthandlerFactory plus the FormRequestHandler to take as input all required values.

br

Peter
peter
 
Posts: 67
Joined: 11 Jul 2006, 16:26
Location: Austria

Re: Global class in HTTPFormServer

Postby newbie » 01 Aug 2007, 23:51

OK Peter, thank you for your observations. I think the singleton option might do the job, and I will consider not to make it public.

Thanks again.

newbie
 
Posts: 6
Joined: 13 Jun 2007, 21:07

Re: Global class in HTTPFormServer

Postby bdonline » 11 Apr 2009, 17:49

I'm guessing you'd have to take care of thread-safety if you're modifying anything in the singleton class?
bdonline
 
Posts: 1
Joined: 11 Apr 2009, 17:42


Return to Support

Who is online

Users browsing this forum: killerbot and 2 guests