NCBI C++ ToolKit
helloapp.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

00001 /*  $Id: helloapp.cpp 33815 2007-05-04 17:18:18Z kazimird $
00002  * ===========================================================================
00003  *
00004  *                            PUBLIC DOMAIN NOTICE
00005  *               National Center for Biotechnology Information
00006  *
00007  *  This software/database is a "United States Government Work" under the
00008  *  terms of the United States Copyright Act.  It was written as part of
00009  *  the author's official duties as a United States Government employee and
00010  *  thus cannot be copyrighted.  This software/database is freely available
00011  *  to the public for use. The National Library of Medicine and the U.S.
00012  *  Government have not placed any restriction on its use or reproduction.
00013  *
00014  *  Although all reasonable efforts have been taken to ensure the accuracy
00015  *  and reliability of the software and data, the NLM and the U.S.
00016  *  Government do not and cannot warrant the performance or results that
00017  *  may be obtained by using this software or data. The NLM and the U.S.
00018  *  Government disclaim all warranties, express or implied, including
00019  *  warranties of performance, merchantability or fitness for any particular
00020  *  purpose.
00021  *
00022  *  Please cite the author in any work or product based on this material.
00023  *
00024  * ===========================================================================
00025  *
00026  * Author:  Lewis Geer, Vsevolod Sandomirskiy, etc.
00027  *
00028  * File Description:  This is the main section of the program.
00029  *
00030  */
00031 
00032 #include <ncbi_pch.hpp>
00033 #include "helloapp.hpp"
00034 #include "hellores.hpp"
00035 #include "hellocmd.hpp"
00036 #include <cgi/cgictx.hpp>
00037 
00038 #include <common/test_assert.h> /* This header must go last */
00039 
00040 
00041 /////////////////////////////////
00042 // APPLICATION OBJECT
00043 //   and
00044 // MAIN
00045 //
00046 
00047 USING_NCBI_SCOPE;
00048 
00049 // Note that if the application's object ("theHelloApp") was defined
00050 // inside the scope of function "main()", then its destructor could be
00051 // called *before* destructors of other statically allocated objects
00052 // defined in other modules.
00053 // It would cause a premature closure of diag. stream, and disallow the
00054 // destructors of other projects to refer to this application object:
00055 //  - the singleton method CNcbiApplication::Instance() would return NULL, and
00056 //  - if there is a "raw"(direct) pointer to "theTestApplication" then it
00057 //    might cause a real trouble.
00058 static CHelloApp theHelloApp;
00059 
00060 
00061 int main(int argc, const char* argv[])
00062 {
00063     // Execute main application function
00064     return theHelloApp.AppMain(argc, argv);
00065 }
00066 
00067 
00068 
00069 /////////////////////////////////
00070 // CHelloApp::
00071 //   -- implementation of LoadResource() and ProcessRequest() virtual methods
00072 //
00073 
00074 
00075 BEGIN_NCBI_SCOPE
00076 
00077 CNcbiResource* CHelloApp::LoadResource(void)
00078 { 
00079     auto_ptr<CHelloResource> resource(new CHelloResource( GetConfig() ));  
00080 
00081     // add commands to the resource class
00082     resource->AddCommand( new CHelloBasicCommand(*resource) );
00083     resource->AddCommand( new CHelloReplyCommand(*resource) );
00084     
00085     return resource.release();
00086 }
00087 
00088 
00089 int CHelloApp::ProcessRequest(CCgiContext& ctx)
00090 {
00091     // execute request
00092     ctx.GetResource().HandleRequest(ctx);
00093     return 0;
00094 }
00095 
00096 END_NCBI_SCOPE
Modified on Sat May 23 10:11:13 2015 by modify_doxy.py rev. 426318