factory.cc

Go to the documentation of this file.
00001 
00005 
00006 //
00007 // Copyright (c) 1999-2004 California Institute of Technology
00008 // Copyright (c) 2004-2007 University of Southern California
00009 // Rob Peters <rjpeters at usc dot edu>
00010 //
00011 // created: Sat Nov 20 22:37:31 1999
00012 // commit: $Id: factory.cc 10065 2007-04-12 05:54:56Z rjpeters $
00013 // $HeadURL: file:///lab/rjpeters/svnrepo/code/trunk/groovx/src/rutz/factory.cc $
00014 //
00015 // --------------------------------------------------------------------
00016 //
00017 // This file is part of GroovX.
00018 //   [http://ilab.usc.edu/rjpeters/groovx/]
00019 //
00020 // GroovX is free software; you can redistribute it and/or modify it
00021 // under the terms of the GNU General Public License as published by
00022 // the Free Software Foundation; either version 2 of the License, or
00023 // (at your option) any later version.
00024 //
00025 // GroovX is distributed in the hope that it will be useful, but
00026 // WITHOUT ANY WARRANTY; without even the implied warranty of
00027 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00028 // General Public License for more details.
00029 //
00030 // You should have received a copy of the GNU General Public License
00031 // along with GroovX; if not, write to the Free Software Foundation,
00032 // Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00033 //
00035 
00036 #ifndef GROOVX_RUTZ_FACTORY_CC_UTC20050626084020_DEFINED
00037 #define GROOVX_RUTZ_FACTORY_CC_UTC20050626084020_DEFINED
00038 
00039 #include "factory.h"
00040 
00041 #include "rutz/trace.h"
00042 
00043 namespace
00044 {
00045   class function_fallback : public rutz::factory_fallback
00046   {
00047   public:
00048     typedef rutz::factory_base::fallback_t fallback_t;
00049 
00050     function_fallback(fallback_t* f) throw() : m_func(f) {}
00051 
00052     virtual ~function_fallback() throw() {}
00053 
00054     virtual void try_fallback(const rutz::fstring& key) const
00055     {
00056       if (m_func != 0)
00057         (*m_func)(key);
00058     }
00059 
00060   private:
00061     fallback_t* m_func;
00062   };
00063 }
00064 
00065 rutz::factory_fallback::factory_fallback() throw()
00066 {}
00067 
00068 rutz::factory_fallback::~factory_fallback() throw()
00069 {}
00070 
00071 rutz::factory_base::factory_base() throw()
00072   :
00073   m_fallback()
00074 {
00075 GVX_TRACE("rutz::factory_base::factory_base");
00076 }
00077 
00078 rutz::factory_base::~factory_base() throw()
00079 {
00080 GVX_TRACE("rutz::factory_base::~factory_base");
00081 }
00082 
00083 void rutz::factory_base::set_fallback(rutz::shared_ptr<factory_fallback> f)
00084 {
00085 GVX_TRACE("rutz::factory_base::set_fallback(object)");
00086 
00087   m_fallback = f;
00088 }
00089 
00090 void rutz::factory_base::set_fallback(fallback_t* fptr)
00091 {
00092 GVX_TRACE("rutz::factory_base::set_fallback");
00093   m_fallback = rutz::make_shared(new function_fallback(fptr));
00094 }
00095 
00096 void rutz::factory_base::try_fallback(const rutz::fstring& key) const
00097 {
00098 GVX_TRACE("rutz::factory_base::try_fallback");
00099 
00100   if (m_fallback.get() != 0)
00101     m_fallback->try_fallback(key);
00102 }
00103 
00104 static const char __attribute__((used)) vcid_groovx_rutz_factory_cc_utc20050626084020[] = "$Id: factory.cc 10065 2007-04-12 05:54:56Z rjpeters $ $HeadURL: file:
00105 #endif // !GROOVX_RUTZ_FACTORY_CC_UTC20050626084020_DEFINED

The software described here is Copyright (c) 1998-2005, Rob Peters.
This page was generated Wed Dec 3 06:49:40 2008 by Doxygen version 1.5.5.