stlab.adobe.com Adobe Systems Incorporated

drag_and_drop_converter_concept.hpp

Go to the documentation of this file.
00001 /*
00002     Copyright 2007 Adobe Systems Incorporated
00003     Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
00004     or a copy at http://stlab.adobe.com/licenses.html)
00005 */
00006 
00007 /**************************************************************************************************/
00008 
00009 #ifndef ADOBE_DRAG_AND_DROP_CONVERTER_CONCEPT_HPP
00010 #define ADOBE_DRAG_AND_DROP_CONVERTER_CONCEPT_HPP
00011 
00012 /**************************************************************************************************/
00013 
00014 #include <boost/concept_check.hpp>
00015 #include <boost/ref.hpp>
00016 
00017 #include <adobe/regular_concept.hpp>
00018 
00019 /**************************************************************************************************/
00020 
00021 namespace adobe {
00022 
00023 /*************************************************************************************************/
00031 /*************************************************************************************************/
00032     
00036 template <class Converter>
00037 struct dnd_converter_source_type 
00038 {
00039     typedef typename boost::unwrap_reference<Converter>::type::source_type type;
00040 };
00041 
00042 /*************************************************************************************************/
00043     
00047 template <class Converter>
00048 struct dnd_converter_dest_type 
00049 {
00050     typedef typename boost::unwrap_reference<Converter>::type::dest_type type;
00051 };
00052 
00053 /*************************************************************************************************/
00057 template <class DNDC> // DNDC models DragAndDropConverter
00058 inline typename dnd_converter_dest_type<DNDC>::type
00059 convert(const DNDC&                                           dndc,
00060         const typename dnd_converter_source_type<DNDC>::type& raw_value)
00061 { return dndc.convert(raw_value); }
00062 
00063 /*************************************************************************************************/
00069 template <class DragAndDropConverter>
00070 struct DragAndDropConverterConcept
00071 {
00073     typedef typename dnd_converter_source_type<DragAndDropConverter>::type source_type; 
00074     typedef typename dnd_converter_dest_type<DragAndDropConverter>::type   dest_type; 
00075 
00078     static dest_type convert(const DragAndDropConverter& converter, const source_type& src_value)
00079     {
00080         using adobe::convert;
00081         return convert(converter, src_value);
00082     }
00083 
00084 #ifndef ADOBE_NO_DOCUMENTATION
00085     // Concept checking:
00086     // Use pointers since not required to be default constructible
00087 
00088     const DragAndDropConverter* converter;
00089     source_type*                src_value;
00090     dest_type*                  dest_value;
00091 #endif
00092 
00094     void constraints() {
00095         // associated types:
00096         typedef typename dnd_converter_source_type<DragAndDropConverter>::type associated_type1;
00097         typedef typename dnd_converter_dest_type<DragAndDropConverter>::type associated_type2;
00098 
00099         using adobe::convert;
00100         convert(*converter, *src_value);
00101     }
00102 };
00103 
00108 template <class DragAndDropConverter>
00109 struct DragAndDropConverterConcept<boost::reference_wrapper<DragAndDropConverter> > : 
00110     DragAndDropConverterConcept<DragAndDropConverter>
00111 {
00112     void constraints() {
00113         //boost concept check lib gets confused on VC8 without this
00114         DragAndDropConverterConcept<DragAndDropConverter>::constraints();
00115     }
00116 };
00117 
00118 /*************************************************************************************************/
00119 
00120 } // namespace adobe
00121 
00122 /**************************************************************************************************/
00123 
00124 // ADOBE_DRAG_AND_DROP_CONVERTER_CONCEPT_HPP
00125 #endif
00126 
00127 /**************************************************************************************************/

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google