Fresco/Fresco-C++/include/Fresco resolve.hh,1.15,1.16

Neil John Pilgrim <[email protected]>
Newsgroups gmane.comp.video.fresco.cvs
Message-ID <[email protected]>
Update of /cvs/fresco/Fresco/Fresco-C++/include/Fresco
In directory purcel:/tmp/cvs-serv21066/Fresco-C++/include/Fresco

Modified Files:
	resolve.hh 
Log Message:
Fix for task54: add resolve_kit wrappers which do not require the repo-id 
strings for core kits, using a template traits technique.


Index: resolve.hh
===================================================================
RCS file: /cvs/fresco/Fresco/Fresco-C++/include/Fresco/resolve.hh,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- resolve.hh	9 Apr 2003 22:18:24 -0000	1.15
+++ resolve.hh	11 Apr 2003 00:09:34 -0000	1.16
@@ -147,6 +147,7 @@
 
 // -----------------------------------------------------------------------------
 // Wrappers for resolving Fresco kits
+// XXX Should these be in the Fresco namespace?
 // -----------------------------------------------------------------------------
 template <class T>
 typename T::_ptr_type resolve_kit(Fresco::ServerContext_ptr context, 
@@ -189,6 +190,51 @@
     Fresco::Kit::PropertySeq empty;
     empty.length(0);
     return resolve_kit<T>(context, name, empty);
+}
+
+// Simplified wrappers, to avoid writing out the repo-id repeatedly
+
+// need to predeclare core kits
+namespace Fresco
+{
+  class LayoutKit;
+  class ToolKit;
+  class TextKit;
+  class DesktopKit;
+  class CommandKit;
+  class WidgetKit;
+  class RasterKit;
+  class FigureKit;
+  class GadgetKit;
+  class PrimitiveKit;
+};
+
+// Kit traits, pre-specialised for core kits
+template<typename T> struct Kit_traits{};
+template<> struct Kit_traits<Fresco::LayoutKit> {static char const id[];};
+template<> struct Kit_traits<Fresco::ToolKit> {static char const id[];};
+template<> struct Kit_traits<Fresco::TextKit> {static char const id[];};
+template<> struct Kit_traits<Fresco::DesktopKit> {static char const id[];};
+template<> struct Kit_traits<Fresco::CommandKit> {static char const id[];};
+template<> struct Kit_traits<Fresco::WidgetKit> {static char const id[];};
+template<> struct Kit_traits<Fresco::RasterKit> {static char const id[];};
+template<> struct Kit_traits<Fresco::FigureKit> {static char const id[];};
+template<> struct Kit_traits<Fresco::GadgetKit> {static char const id[];};
+template<> struct Kit_traits<Fresco::PrimitiveKit> {static char const id[];};
+
+template <class T>
+typename T::_ptr_type resolve_kit(Fresco::ServerContext_ptr context, 
+                                  Fresco::Kit::PropertySeq const &props)
+{
+    return resolve_kit<T>(context, Kit_traits<T>::id, props);
+}
+
+template <class T>
+typename T::_ptr_type resolve_kit(Fresco::ServerContext_ptr context)
+{
+    Fresco::Kit::PropertySeq empty;
+    empty.length(0);
+    return resolve_kit<T>(context, Kit_traits<T>::id, empty);
 }
 
 // -----------------------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.