implementation.C

00001 /*
00002  * This file is part of the "Archon" framework.
00003  * (http://files3d.sourceforge.net)
00004  *
00005  * Copyright © 2006 by Kristian Spangsege and Brian Kristiansen.
00006  *
00007  * Permission to use, copy, modify, and distribute this software and
00008  * its documentation under the terms of the GNU General Public License is
00009  * hereby granted. No representations are made about the suitability of
00010  * this software for any purpose. It is provided "as is" without express
00011  * or implied warranty. See the GNU General Public License
00012  * (http://www.gnu.org/copyleft/gpl.html) for more details.
00013  *
00014  * The characters in this file are ISO8859-1 encoded.
00015  *
00016  * The documentation in this file is in "Doxygen" style
00017  * (http://www.doxygen.org).
00018  */
00019 
00020 #include <vector>
00021 
00022 #include <archon/util/ref.H>
00023 #include <archon/display/implementation.H>
00024 
00025 #include <archon/config.h>
00026 
00027 #ifndef X_DISPLAY_MISSING
00028 #include <archon/display/x11/implementation.H>
00029 #endif
00030 
00031 namespace Archon
00032 {
00033   namespace Display
00034   {
00035     using namespace std;
00036     using namespace Archon::Utilities;
00037 
00038     namespace
00039     {
00040       struct ImplementationRegistry
00041       {
00042         ImplementationRegistry()
00043         {
00044 #ifndef X_DISPLAY_MISSING
00045           implementations.push_back(getImplementationX11());
00046 #endif
00047         }
00048 
00049         vector<Ref<Archon::Display::Implementation> > implementations;
00050       };
00051 
00052       const ImplementationRegistry *getImplementationRegistry()
00053       {
00054         static ImplementationRegistry registry;
00055         return &registry;
00056       }
00057     }
00058 
00059 
00060     Ref<Implementation> getDefaultImplementation() throw(NoImplementationException)
00061     {
00062       const ImplementationRegistry *r = getImplementationRegistry();
00063       if(r->implementations.empty()) ARCHON_THROW(NoImplementationException);
00064       return r->implementations[0];
00065     }
00066 
00067     int getNumberOfImplementations()
00068     {
00069       return getImplementationRegistry()->implementations.size();
00070     }
00071 
00072     Ref<Implementation> getImplementation(int index) throw(out_of_range)
00073     {
00074       return getImplementationRegistry()->implementations.at(index);
00075     }
00076   }
00077 }

Generated on Sun Jul 30 22:55:42 2006 for Archon by  doxygen 1.4.4