Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > C++ framework design

Reply
Thread Tools

C++ framework design

 
 
Chicken McNuggets
Guest
Posts: n/a
 
      03-22-2013
Hi,

I'm working on a C++ web framework as a hobby project and am looking for
some advice on the best way to design it.

Currently my plan is the following:

* Create a Unix daemon which loads a set of configuration files which
specify the location of a group of shared libraries (and other settings).

* The daemon then forks enough processes so each configuration file is
associated with a single process.

* Each process then loads its dynamic library using dlopen().

* Once the dynamic library has been loaded a pre-determined entry point
is called in each dynamic library which returns the required information
to the main daemon.

* The daemon then uses that information to start using the dynamic
library to execute the client supplied code.

Does that sound like a decent idea of how to go about creating a C++
framework or can anyone provide some hints or tips for the best method
to use in this case?
 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      03-22-2013
Chicken McNuggets wrote:
> Hi,
>
> I'm working on a C++ web framework as a hobby project and am looking for
> some advice on the best way to design it.
>
> Currently my plan is the following:
>
> * Create a Unix daemon which loads a set of configuration files which
> specify the location of a group of shared libraries (and other settings).
>
> * The daemon then forks enough processes so each configuration file is
> associated with a single process.
>
> * Each process then loads its dynamic library using dlopen().
>
> * Once the dynamic library has been loaded a pre-determined entry point
> is called in each dynamic library which returns the required information
> to the main daemon.
>
> * The daemon then uses that information to start using the dynamic
> library to execute the client supplied code.
>
> Does that sound like a decent idea of how to go about creating a C++
> framework or can anyone provide some hints or tips for the best method
> to use in this case?


You don't say what the purpose of your framework is.

--
Ian Collins
 
Reply With Quote
 
 
 
 
Chicken McNuggets
Guest
Posts: n/a
 
      03-22-2013
On 22/03/13 08:57, Christian Gollwitzer wrote:
> Sorry, I overlooked the word "web framework". Still, it might actually
> be easier to use processes - i.e., CGI. FastCGI comes to mind and the
> question, why on earth you are not using an existing web server.
>
> Am 22.03.13 08:43, schrieb Christian Gollwitzer:
>> Am 22.03.13 08:09, schrieb Chicken McNuggets:
>>> Currently my plan is the following:
>>>
>>> * Create a Unix daemon which loads a set of configuration files which
>>> specify the location of a group of shared libraries (and other
>>> settings).
>>>
>>> * The daemon then forks enough processes so each configuration file is
>>> associated with a single process.
>>>
>>> ...
>> >
>>> * The daemon then uses that information to start using the dynamic
>>> library to execute the client supplied code.

>>
>> Yeah, but what is this good for? That is unclear to me.
>>
>> 1. Why do you need the daemon?
>> For running a bunch of programs in parallel, just use a shell script.
>> Maybe you want to do something like launchd on OSX, which schedules
>> service providers? Look at dbus. Timetable? Use cron etc.
>>
>> 2.
>> If you just want to schedule the start (like cron et al.), then why not
>> use a main executable for the processes. It's a standardized interface
>> and available for all languages on that platform. A shared lib only
>> makes sens, if you want to call back into the daemon code. Even then, it
>> might be better to use stdin/stdout for IPC.
>>
>> Christian

>


Sorry I should have been clearer. The framework is a web framework as
you say and it will be based on FastCGI but you are getting confused
between a web server (HTTP) and a FastCGI server which communicates with
a FastCGI client which is also normally the HTTP server.

For example Nginx is an HTTP server and also a FastCGI client. It
receives HTTP requests and translates them into a FastCGI request which
is sent to the FastCGI server (my daemon) the FastCGI server then
processes the request and sends a response back to the FastCGI client
(Nginx). The FastCGI client then transforms the FastCGI response and
sends it back to the HTTP client (the web browser) as an HTTP response.

FastCGI is a protocol that keeps the process alive between requests
hence the requirement for a daemon. Keeping it running all the time
reduces the need for start up and shut down costs (as is the case with
traditional CGI apps) and also allows persistent connections which is
also more efficient.

As for the reason I am writing a web framework in C++? I'm simply doing
it as a hobby.

Basically my daemon is intended to provide a simple framework that
people then hook in their own views and data (from a database or some
other source). I was planning to allow people to just write a simple
library that the daemon then loads at runtime and it then passes FastCGI
requests to the correct view in the library. The library then contains
all the code required to access the data sources and then the framework
simply takes the return value of the view and passes it back to the
FastCGI client in a form which can be returned to a browser.

I'm fairly certain that post is not particularly clear but if there is
anything I have missed out or you need some more information then let me
know. I'm in a bit of a rush at the moment.
 
Reply With Quote
 
Jorgen Grahn
Guest
Posts: n/a
 
      03-22-2013
On Fri, 2013-03-22, Ian Collins wrote:
> Chicken McNuggets wrote:
>> Hi,
>>
>> I'm working on a C++ web framework as a hobby project and am looking for
>> some advice on the best way to design it.
>>
>> Currently my plan is the following:
>>

....
> You don't say what the purpose of your framework is.


Put differently: IMO it's suicide to design a framework or an API
without at the same time designing at least one non-toy, real
application which uses it.

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      03-22-2013
On 3/22/2013 10:11 AM, Jorgen Grahn wrote:
> On Fri, 2013-03-22, Ian Collins wrote:
>> Chicken McNuggets wrote:
>>> Hi,
>>>
>>> I'm working on a C++ web framework as a hobby project and am looking for
>>> some advice on the best way to design it.
>>>
>>> Currently my plan is the following:
>>>

> ...
>> You don't say what the purpose of your framework is.

>
> Put differently: IMO it's suicide to design a framework or an API
> without at the same time designing at least one non-toy, real
> application which uses it.


"Suicide"? It can be a waste of time. It can be laden with
frustration. It can mean more work later (re-working and re-designing
is often more laborious than doing it correctly from scratch). But
"suicide"? Come on!...

V
--
I do not respond to top-posted replies, please don't ask
 
Reply With Quote
 
Öö Tiib
Guest
Posts: n/a
 
      03-22-2013
On Friday, 22 March 2013 16:11:49 UTC+2, Jorgen Grahn wrote:
> On Fri, 2013-03-22, Ian Collins wrote:
> > Chicken McNuggets wrote:
> >> Hi,
> >>
> >> I'm working on a C++ web framework as a hobby project and am looking for
> >> some advice on the best way to design it.
> >>
> >> Currently my plan is the following:
> >>

> ...
> > You don't say what the purpose of your framework is.

>
> Put differently: IMO it's suicide to design a framework or an API
> without at the same time designing at least one non-toy, real
> application which uses it.


I suspect that suicide is too strong term here. Sounds almost like
"watching TV is suicide". OP is making a solution without solving
any actual problems as a hobby. That is usually not too productive.
Hobbies must not be productive.
 
Reply With Quote
 
woodbrian77@gmail.com
Guest
Posts: n/a
 
      03-22-2013
On Friday, March 22, 2013 9:20:23 AM UTC-5, Victor Bazarov wrote:
> On 3/22/2013 10:11 AM, Jorgen Grahn wrote:
>
>
> > Put differently: IMO it's suicide to design a framework or an API

>
> > without at the same time designing at least one non-toy, real

>
> > application which uses it.

>
>
>
> "Suicide"? It can be a waste of time. It can be laden with
>
> frustration. It can mean more work later (re-working and re-designing
>
> is often more laborious than doing it correctly from scratch). But
>
> "suicide"? Come on!...
>


Maybe unintentional suicide. Being foolish leads to
death sometimes.

Brian
Ebenezer Enterprises - an ounce of prevention is worth
more than a pound of cure.
http://webEbenezer.net
 
Reply With Quote
 
Luca Risolia
Guest
Posts: n/a
 
      03-22-2013
On 22/03/2013 13:50, Chicken McNuggets wrote:
> I'm fairly certain that post is not particularly clear but if there is
> anything I have missed out or you need some more information then let me
> know. I'm in a bit of a rush at the moment.


The steps you mentioned in your original question are a valid starting
point, although I would not fork the daemon from within the daemon
itself. I would rather use a second, external component for reading the
entries in the configuration file and spawning the corresponding daemons
by passing all the informations needed to identify the correct plug-in
to load.

 
Reply With Quote
 
Chicken McNuggets
Guest
Posts: n/a
 
      03-22-2013
On 22/03/13 15:34, http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> On Friday, March 22, 2013 9:20:23 AM UTC-5, Victor Bazarov wrote:
>> On 3/22/2013 10:11 AM, Jorgen Grahn wrote:
>>
>>
>>> Put differently: IMO it's suicide to design a framework or an API

>>
>>> without at the same time designing at least one non-toy, real

>>
>>> application which uses it.

>>
>>
>>
>> "Suicide"? It can be a waste of time. It can be laden with
>>
>> frustration. It can mean more work later (re-working and re-designing
>>
>> is often more laborious than doing it correctly from scratch). But
>>
>> "suicide"? Come on!...
>>

>
> Maybe unintentional suicide. Being foolish leads to
> death sometimes.
>
> Brian
> Ebenezer Enterprises - an ounce of prevention is worth
> more than a pound of cure.
> http://webEbenezer.net
>


The problem I have at the moment is deciding on the best way to
integrate client code with the main framework. Once I have that figured
out the specifics of how the two sides will communicate will evolve as I
create a client library for testing. But until I have some method
figured out for the best method to load client code I can't really
create a client library to help develop the rest of the framework / API.

Basically I'm just looking for advice on common practice when it comes
to extending a C++ daemon with third party code. I'm not looking for
specifics of an API design as I haven't got that far yet.
 
Reply With Quote
 
Jorgen Grahn
Guest
Posts: n/a
 
      03-22-2013
On Fri, 2013-03-22, Victor Bazarov wrote:
> On 3/22/2013 10:11 AM, Jorgen Grahn wrote:
>> On Fri, 2013-03-22, Ian Collins wrote:
>>> Chicken McNuggets wrote:
>>>> Hi,
>>>>
>>>> I'm working on a C++ web framework as a hobby project and am looking for
>>>> some advice on the best way to design it.
>>>>
>>>> Currently my plan is the following:
>>>>

>> ...
>>> You don't say what the purpose of your framework is.

>>
>> Put differently: IMO it's suicide to design a framework or an API
>> without at the same time designing at least one non-toy, real
>> application which uses it.

>
> "Suicide"? It can be a waste of time. It can be laden with
> frustration. It can mean more work later (re-working and re-designing
> is often more laborious than doing it correctly from scratch). But
> "suicide"? Come on!...


It should be obvious that I didn't mean that literally, right?

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
delete .NET FRAMEWORK 1.1 before installing .NET FRAMEWORK 2 ???? moi ASP .Net 3 09-26-2008 02:19 PM
Installing 1.1 Framework and 2.0 Framework on the same web server Mark ASP .Net 4 11-17-2005 03:30 PM
spring framework versus struts framework jrefactors@hotmail.com Java 2 09-11-2005 09:54 PM
microsoft.public.dotnet.faqs,microsoft.public.dotnet.framework,microsoft.public.dotnet.framework.windowsforms,microsoft.public.dotnet.general,microsoft.public.dotnet.languages.vb Charles A. Lackman ASP .Net 1 12-08-2004 07:08 PM
COMInterop does not work in Framework 1.1 without Framework 1.0 Anatoly Volodko ASP .Net 1 08-14-2003 08:11 PM



Advertisments