2011-02-08

Howto design a webapp C++ MVC API part 2

Doing a MVC implementation that is intuitive in C++ isn't very easy. I'm thinking about how to implement the controllers. Should the controller-class be inherited by the implementations or should it provide some kind of callback/signal-system. For some reason I seem to be against inheriting from the controller, but compared to a signal/slot or similar callbacksystem, this is probably the best and most intuitive option.

So I'm thinking something like this:
-----
// Create a webapp
forumApp myforum;
http_server.add_webapp("forum",myforum); // add the forumApp to the "/forum/"-path
-----
// Looking at the forumApp-class, it inherits the webapp_controller
class forumApp : public webapp_controller{


    // Set up the "sub" controllers in a static method
    static void add_controllers(dispatcher::ptr dispatcher){
        // Add the controller "forumAdministration" to the subpath "/forum/admin/"
        dispatcher->add_controller<forumAdministration>("admin"); 
        // Add the controller "forumThread" to the subpath "/forum/thread/"
        dispatcher->add_controller<forumThread>("thread");
        // Also add actions related to this controller 
        dispatcher->add_action(&forumApp::about,"about");
     }

     void about(connection &con){
         con.send_response("this is the best forumapp ever");
     }
}
-------
So, this is just initial thoughts. Writing about this helps me figure out how code would look like, and who knows, maybe I can catch someones attention.

Next up is how views should work and what type if template-system to use or not to use.

2 comments:

  1. Decongestants lessen this bloating of the mucus filters. Usuallu when you use most of these, sinus congestion is actually diminished, improving the best way to better sinus pathways. These readily available passageways might far more readily exude undesired mucus in addition to infectious dust in the nose places, resulting in cleanser in addition to disinfected nose cavities.Kyäni

    ReplyDelete
  2. Apartments with Alanya stay fairly cheep, with spite associated with fees growing significantly. even though your own market have been affected through recent financial events, It has proved to help always be much further robust compared to inside quite a few additional countries. because the new laws came in The strain allowing foreigners for you to buy land, both call for AS WELL AS prices have increased. Prices, particularly lower your coast, usually are rising rapidly, IN ADDITION TO are required to help continue to be able to do thus through the after that several to help nine years.It doesn't need to utilize an estate agent looking for AS WELL AS buy a good Apartment inside Alanya. However, many buyers Pick to help do, and so In the same way estate agents cater to the catered Requirements of foreigners AS WELL AS tend to be aware associated with all the legal requirements. sooner committing in order to procuring the Apartment, you\'ll want to transaction regardless of whether You will discover almost any extraordinary debts on the property.
    lägenhet i Alanya

    ReplyDelete