Overview
Features
Download
Documentation
Community
Add-Ons & Services

How to use function that initialized from Application

Please post support and help requests here.

How to use function that initialized from Application

Postby ShrewMouse » 09 Dec 2008, 10:08

Hi All,

Currently I write an server application using [Poco::Util::ServerApplication]. And I have a X class that need to construct one time at first for using later. So I construct it in initialize() function of application. The problem is : I need to use X::myFunction() in handleRequest function of MyRequestHandler : public HTTPRequestHandler to return the client.

I did following this way but it's not work;
This is MyRequestHandler:
Code: Select all

# include "MyServer.h"

void MyRequestHandler::handleRequest(HTTPServerRrequest &request_, HTTPServerResponse &response_)
{
    ...
     MyServer server = MyServer::instance();
     server.X.myFunction();
   ...

}

Is there any way to solve this problem ?
Thanks so much for any helps


ShrewMouse
 
Posts: 9
Joined: 01 Oct 2008, 04:45

Re: How to use function that initialized from Application

Postby alex » 09 Dec 2008, 11:58

> Is there any way to solve this problem ?

Probably, if you explain what the problem is.
alex
 
Posts: 1101
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: Re: How to use function that initialized from Application

Postby ShrewMouse » 11 Dec 2008, 06:05

> > Is there any way to solve this problem ?
>
> Probably, if you explain what the problem is.
>

Hi Alex,

I'd like to use a member of MyServer in MyRequestHandler

The problem is : there is a circle loop of include here : MyServer.h ---> MyRequestHandlerFactory.h --->MyRequestHandler.h ---> MyServer.h...And so class MyRequestHandler will be redefined....But If I don't include MyServer.h. in MyRequestHandler.h, the compiler will don't understand this code:

^ MyServer server = MyServer::instance();
server.X.myFunction();
^

The question is : How can I use member (or function X.myFunction()) of MyServer class from MyRequestHandler class ?

Thansk for your reply

PS:
Sorry for late respond , my internet is disconnected someday recently
ShrewMouse
 
Posts: 9
Joined: 01 Oct 2008, 04:45

Re: Re: Re: How to use function that initialized from Application

Postby alex » 11 Dec 2008, 12:44

> The problem is : there is a circle loop of include here : ^

The solution is foward declaration.
alex
 
Posts: 1101
Joined: 11 Jul 2006, 16:27
Location: United_States


Return to Support

Who is online

Users browsing this forum: No registered users and 4 guests