ResourceDefinition.h

Go to the documentation of this file.
00001 /*
00002 // $Id: //open/dev/fennel/common/ResourceDefinition.h#12 $
00003 // Fennel is a library of data storage and processing components.
00004 // Copyright (C) 2005-2009 The Eigenbase Project
00005 // Copyright (C) 2004-2009 SQLstream, Inc.
00006 // Copyright (C) 2005-2009 LucidEra, Inc.
00007 //
00008 // This program is free software; you can redistribute it and/or modify it
00009 // under the terms of the GNU General Public License as published by the Free
00010 // Software Foundation; either version 2 of the License, or (at your option)
00011 // any later version approved by The Eigenbase Project.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the Free Software
00020 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 */
00022 
00023 #ifndef Fennel_ResourceDefinition_Included
00024 #define Fennel_ResourceDefinition_Included
00025 
00026 #include <string>
00027 #include <boost/format.hpp>
00028 
00029 #include "fennel/common/ResourceBundle.h"
00030 
00031 FENNEL_BEGIN_NAMESPACE
00032 
00033 class FENNEL_COMMON_EXPORT ResourceDefinition
00034 {
00035     const std::string _key;
00036 
00037 public:
00038     explicit ResourceDefinition(
00039         ResourceBundle *bundle,
00040         const std::string &key);
00041 
00042     virtual ~ResourceDefinition();
00043 
00044     std::string format() const;
00045 
00046     template<typename t0>
00047     std::string format(const t0 &p0) const
00048     {
00049         boost::format fmt = prepareFormatter(1);
00050 
00051         return boost::io::str(fmt % p0);
00052     }
00053 
00054     template<typename t0, typename t1>
00055     std::string format(const t0 &p0, const t1 &p1) const
00056     {
00057         boost::format fmt = prepareFormatter(2);
00058 
00059         return boost::io::str(fmt % p0 % p1);
00060     }
00061 
00062     template<typename t0, typename t1, typename t2>
00063     std::string format(const t0 &p0, const t1 &p1, const t2 &p2) const
00064     {
00065         boost::format fmt = prepareFormatter(3);
00066 
00067         return boost::io::str(fmt % p0 % p1 % p2);
00068     }
00069 
00070     template<typename t0, typename t1, typename t2, typename t3>
00071     std::string format(
00072         const t0 &p0, const t1 &p1, const t2 &p2, const t3 &p3) const
00073     {
00074         boost::format fmt = prepareFormatter(4);
00075 
00076         return boost::io::str(fmt % p0 % p1 % p2 % p3);
00077     }
00078 
00079     template<typename t0, typename t1, typename t2, typename t3, typename t4>
00080     std::string format(
00081         const t0 &p0, const t1 &p1, const t2 &p2, const t3 &p3,
00082         const t4 &p4) const
00083     {
00084         boost::format fmt = prepareFormatter(5);
00085 
00086         return boost::io::str(fmt % p0 % p1 % p2 % p3 % p4);
00087     }
00088 
00089     template<typename t0, typename t1, typename t2, typename t3, typename t4,
00090              typename t5>
00091     std::string format(
00092         const t0 &p0, const t1 &p1, const t2 &p2, const t3 &p3,
00093         const t4 &p4, const t5 &p5) const
00094     {
00095         boost::format fmt = prepareFormatter(6);
00096 
00097         return boost::io::str(fmt % p0 % p1 % p2 % p3 % p4 % p5);
00098     }
00099 
00100     template<typename t0, typename t1, typename t2, typename t3, typename t4,
00101              typename t5, typename t6>
00102     std::string format(
00103         const t0 &p0, const t1 &p1, const t2 &p2, const t3 &p3,
00104         const t4 &p4, const t5 &p5, const t6 &p6) const
00105     {
00106         boost::format fmt = prepareFormatter(7);
00107 
00108         return boost::io::str(fmt % p0 % p1 % p2 % p3 % p4 % p5 % p6);
00109     }
00110 
00111     template<typename t0, typename t1, typename t2, typename t3, typename t4,
00112              typename t5, typename t6, typename t7>
00113     std::string format(
00114         const t0 &p0, const t1 &p1, const t2 &p2, const t3 &p3,
00115         const t4 &p4, const t5 &p5, const t6 &p6, const t7 &p7) const
00116     {
00117         boost::format fmt = prepareFormatter(8);
00118 
00119         return boost::io::str(fmt % p0 % p1 % p2 % p3 % p4 % p5 % p6 % p7);
00120     }
00121 
00122     template<typename t0, typename t1, typename t2, typename t3, typename t4,
00123              typename t5, typename t6, typename t7, typename t8>
00124     std::string format(
00125         const t0 &p0, const t1 &p1, const t2 &p2, const t3 &p3,
00126         const t4 &p4, const t5 &p5, const t6 &p6, const t7 &p7,
00127         const t8 &p8) const
00128     {
00129         boost::format fmt = prepareFormatter(9);
00130 
00131         return boost::io::str(fmt % p0 % p1 % p2 % p3 % p4 % p5 % p6 % p7 % p8);
00132     }
00133 
00134     template<typename t0, typename t1, typename t2, typename t3, typename t4,
00135              typename t5, typename t6, typename t7, typename t8, typename t9>
00136     std::string format(
00137         const t0 &p0, const t1 &p1, const t2 &p2, const t3 &p3,
00138         const t4 &p4, const t5 &p5, const t6 &p6, const t7 &p7,
00139         const t8 &p8, const t9 &p9) const
00140     {
00141         boost::format fmt = prepareFormatter(10);
00142 
00143         return boost::io::str(
00144             fmt % p0 % p1 % p2 % p3 % p4 % p5 % p6 % p7 % p8 % p9);
00145     }
00146 
00147     // TODO: more format methods?
00148 
00149 protected:
00150     boost::format prepareFormatter(int numArgs) const;
00151 
00152 private:
00153     ResourceBundle *_bundle;
00154 };
00155 
00156 FENNEL_END_NAMESPACE
00157 
00158 #endif // not Fennel_ResourceDefinition_Included
00159 
00160 // End ResourceDefinition.h

Generated on Mon Jun 22 04:00:18 2009 for Fennel by  doxygen 1.5.1