XamlResource.h

00001 //
00002 //  Copyright (c) 1996-2006 by Autodesk, Inc.
00003 //
00004 //  By using this code, you are agreeing to the terms and conditions of
00005 //  the License Agreement included in the documentation for this code.
00006 //
00007 //  AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE CORRECTNESS
00008 //  OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE IT. AUTODESK
00009 //  PROVIDES THE CODE ON AN "AS-IS" BASIS AND EXPLICITLY DISCLAIMS ANY
00010 //  LIABILITY, INCLUDING CONSEQUENTIAL AND INCIDENTAL DAMAGES FOR ERRORS,
00011 //  OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
00012 //
00013 //  Use, duplication, or disclosure by the U.S. Government is subject to
00014 //  restrictions set forth in FAR 52.227-19 (Commercial Computer Software
00015 //  Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical
00016 //  Data and Computer Software), as applicable.
00017 //
00018 #if !defined XAML_RESOURCE_H
00019 #define XAML_RESOURCE_H
00020 
00021 #include "dwfcore/DWFXMLSerializer.h"
00022 #include "whiptk/whip_toolkit.h"
00023 #include "whiptk/typedefs_defines.h"
00024 
00025 
00026 class WT_XAML_File;
00027 
00028 //
00029 // XAML resource, whose definition is streamed out in a separate
00030 // dictionary stream for lightweight referencing
00031 //
00032 class XamlResource
00033 {
00034 
00035 public:
00036 
00037     //
00038     // resource type, should map to a given class
00039     //
00040     typedef enum {
00041         eUserHatchBrushResource,
00042         eFixedPatternBrushResource,
00043         eUserPatternBrushResource,
00044         eImageBrushResource,
00045         eDecoratedLineStyleResource,
00046         eMacroVisualBrushResource
00047     } eResourceType;
00048 
00049     //
00050     // dtor
00051     //
00052     virtual ~XamlResource() {}
00053 
00054     //
00055     // comparison operator on resources
00056     //
00057     virtual bool operator==(
00058         const XamlResource& ) const = 0;     // comparee
00059 
00060     //
00061     // deep copy operation
00062     //
00063     virtual XamlResource *copy() const = 0;
00064 
00065     //
00066     // returns the resource type
00067     //
00068     virtual eResourceType resourceType() const = 0;
00069 
00070     //
00071     // outputs the resource as XAML for the given key and
00072     // serializer
00073     //
00074     // note : the implementing code must output the x:Key attribute
00075     //
00076     virtual WT_Result serializeResource(
00077         const wchar_t *,                // key, != 0
00078         WT_XAML_File &,                 // file
00079         DWFXMLSerializer &) const = 0;  // serializer
00080 };
00081 
00082 //
00083 // lookup table keying resource instances by strings
00084 //
00085 // the resource instances are duplicated and kept alive until the dtor
00086 // is called
00087 //
00088 // the lookup operation is always guaranteed to succeed and return a string
00089 //
00090 class XamlDictionary
00091 {
00092 public :
00093 
00094     //
00095     // ctor, wrapping an xml serializer
00096     //
00097     XamlDictionary(
00098         WT_XAML_File &);            // file
00099 
00100     //
00101     // dtor, releases the internal allocated resources
00102     //
00103     ~XamlDictionary();
00104 
00105     //
00106     // resource instance to key lookup (linear)
00107     //
00108     // the returned key string is guaranteed unique within this
00109     // dictionary and non-null
00110     //
00111     // if the instance is not yet keyed, it is deep-copied and
00112     // placed in the internal map under a newly allocated key string
00113     // it is then streamed out to the dictionary stream
00114     //
00115     const wchar_t * lookup(
00116         const XamlResource &what);  // resource to lookup  
00117 
00118 private :
00119 
00120     //
00121     // private assignment operator, avoiding warning C4512
00122     //
00123     XamlDictionary &operator = (
00124         XamlDictionary & );         // assignee
00125 
00126 protected :
00127 
00128     WT_Integer32                    _nKeyId;                // unique id sequence
00129     WT_XAML_File &                  _rFile;                 // file
00130     map<const wchar_t *, XamlResource *>  _oKeyToResource;  // string->ptr map
00131 };
00132 
00133 #endif //XAML_RESOURCE_H
00134 

Generated on Tue Jan 6 22:40:06 2009 for Autodesk DWF Toolkit by  doxygen 1.4.5