Synesis Software STLSoft - ... Robust, Lightweight, Cross-platform, Template Software ...

pantheios/internal/initialiser.hpp

Go to the documentation of this file.
00001 /* /////////////////////////////////////////////////////////////////////////
00002  * File:        pantheios/internal/initialiser.hpp
00003  *
00004  * Purpose:     Automatic initialisation of Pantheios Core API
00005  *
00006  * Created:     21st June 2005
00007  * Updated:     2nd August 2010
00008  *
00009  * Home:        http://www.pantheios.org/
00010  *
00011  * Copyright (c) 2005-2010, Matthew Wilson and Synesis Software
00012  * Copyright (c) 1999-2005, Synesis Software and Matthew Wilson
00013  * All rights reserved.
00014  *
00015  * Redistribution and use in source and binary forms, with or without
00016  * modification, are permitted provided that the following conditions are
00017  * met:
00018  *
00019  * - Redistributions of source code must retain the above copyright notice,
00020  *   this list of conditions and the following disclaimer.
00021  * - Redistributions in binary form must reproduce the above copyright
00022  *   notice, this list of conditions and the following disclaimer in the
00023  *   documentation and/or other materials provided with the distribution.
00024  * - Neither the name(s) of Matthew Wilson and Synesis Software nor the
00025  *   names of any contributors may be used to endorse or promote products
00026  *   derived from this software without specific prior written permission.
00027  *
00028  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
00029  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
00030  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00031  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
00032  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00033  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00034  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00035  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00036  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00037  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00038  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00039  *
00040  * ////////////////////////////////////////////////////////////////////// */
00041 
00042 
00053 #ifndef PANTHEIOS_INCL_PANTHEIOS_HPP_INITIALISER
00054 #define PANTHEIOS_INCL_PANTHEIOS_HPP_INITIALISER
00055 
00056 /* /////////////////////////////////////////////////////////////////////////
00057  * Includes
00058  */
00059 
00060 #ifndef PANTHEIOS_INCL_PANTHEIOS_H_PANTHEIOS
00061 # include <pantheios/pantheios.h>
00062 #endif /* !PANTHEIOS_INCL_PANTHEIOS_H_PANTHEIOS */
00063 
00064 /* /////////////////////////////////////////////////////////////////////////
00065  * Classes
00066  */
00067 
00098 class pantheios_initialiser
00099 {
00102 public:
00103     typedef pantheios_initialiser   class_type;
00105 
00108 public:
00112     pantheios_initialiser()
00113     {
00114 #ifndef PANTHEIOS_NO_NAMESPACE
00115         using namespace pantheios;
00116         using namespace pantheios::core;
00117 #endif /* !PANTHEIOS_NO_NAMESPACE */
00118 
00119         if(pantheios_init() < 0)
00120         {
00121             pantheios_exitProcess(1);
00122         }
00123     }
00127     ~pantheios_initialiser()
00128     {
00129 #ifndef PANTHEIOS_NO_NAMESPACE
00130         using namespace pantheios;
00131 #endif /* !PANTHEIOS_NO_NAMESPACE */
00132 
00133         pantheios_uninit();
00134     }
00136 
00139 private:
00140     pantheios_initialiser(class_type const&);
00141     class_type& operator =(class_type const&);
00143 };
00144 
00145 namespace
00146 {
00149     static pantheios_initialiser    s_pantheios_initialiser;
00150 
00151 } /* anonymous namespace */
00152 
00153 /* ////////////////////////////////////////////////////////////////////// */
00154 
00155 #endif /* !PANTHEIOS_INCL_PANTHEIOS_HPP_INITIALISER */
00156 
00157 /* ///////////////////////////// end of file //////////////////////////// */

pantheios Library documentation © Matthew Wilson & Synesis Software, 2006-2011 SourceForge.net Logo