include/ax_resource/ax_resource.h

Go to the documentation of this file.
00001 
00002 // Name:        ax_resource.h
00003 // Purpose:     Accessibility classes: AxResource
00004 // Author:      Julian Smart
00005 // Modified by:
00006 // Created:     2009-03-20
00007 // RCS-ID:
00008 // Copyright:   (c) Julian Smart
00009 // Licence:     New BSD License
00011 
00012 #ifndef _AX_RESOURCE_H_
00013 #define _AX_RESOURCE_H_
00014 
00015 /*
00016  * Includes
00017  */
00018 
00019 #include "wx/dynarray.h"
00020 
00021 #include "ax/ax_property.h"
00022 #include "ax/ax_document.h"
00023 
00024 class AxResource;
00025 class wxDataStreamHelper;
00026 
00027 WX_DEFINE_ARRAY_PTR(AxResource*, AxResourceArray);
00028 
00029 /*
00030  * Common resource property names
00031  */
00032 
00033 #define axPROPERTY_TITLE            wxT("Title")
00034 #define axPROPERTY_LONG_TITLE       wxT("Long title")
00035 #define axPROPERTY_AUTHOR           wxT("Author")
00036 #define axPROPERTY_CONTRIBUTORS     wxT("Contributors")
00037 #define axPROPERTY_PUBLISHER        wxT("Publisher")
00038 #define axPROPERTY_CREATION_DATE    wxT("Creation date")
00039 #define axPROPERTY_LANGUAGE         wxT("Language")
00040 #define axPROPERTY_IDENTIFIER       wxT("Identifier")
00041 #define axPROPERTY_SUBJECT          wxT("Subject")
00042 #define axPROPERTY_GENRE            wxT("Genre")
00043 #define axPROPERTY_DESCRIPTION      wxT("Description")
00044 #define axPROPERTY_FORMAT           wxT("Format")
00045 #define axPROPERTY_NOTES            wxT("Notes")
00046 #define axPROPERTY_SOURCE           wxT("Source")
00047 #define axPROPERTY_SOURCE_URL       wxT("Source URL")
00048 #define axPROPERTY_COVERAGE         wxT("Coverage")
00049 #define axPROPERTY_RIGHTS           wxT("Rights")
00050 #define axPROPERTY_PROVIDER_URL     wxT("Provider URL")
00051 #define axPROPERTY_FILENAME         wxT("Filename")
00052 #define axPROPERTY_RESOURCE_TYPE    wxT("Resource type")
00053 #define axPROPERTY_RESOURCE_STATUS  wxT("Resource status")
00054 
00055 #define axPROPERTY_RELEVANT_FROM_DATE   wxT("Relevant from date")
00056 #define axPROPERTY_RELEVANT_TO_DATE     wxT("Relevant to date")
00057 #define axPROPERTY_ACTIVATE_DATE        wxT("Activate date")
00058 
00059 /*
00060  * Common resource property values
00061  */
00062 
00063 // Resource types
00064 
00065 #define axPROPERTY_RESOURCE_TYPE_EBOOK          wxT("Ebook")
00066 #define axPROPERTY_RESOURCE_TYPE_PRINT_BOOK     wxT("Print book")
00067 #define axPROPERTY_RESOURCE_TYPE_AUDIO_BOOK     wxT("Audio book")
00068 #define axPROPERTY_RESOURCE_TYPE_AUDIO_ALBUM    wxT("Audio album")
00069 #define axPROPERTY_RESOURCE_TYPE_AUDIO_TRACK    wxT("Audio track")
00070 #define axPROPERTY_RESOURCE_TYPE_VIDEO          wxT("Video")
00071 #define axPROPERTY_RESOURCE_TYPE_DOCUMENT       wxT("Document")
00072 #define axPROPERTY_RESOURCE_TYPE_UTILITY        wxT("Utility")
00073 #define axPROPERTY_RESOURCE_TYPE_SERVICE        wxT("Service")
00074 #define axPROPERTY_RESOURCE_TYPE_REMINDER       wxT("Reminder")
00075 #define axPROPERTY_RESOURCE_TYPE_UNKNOWN        wxT("Unknown")
00076 
00077 // Resource statuses
00078 
00079 #define axPROPERTY_RESOURCE_STATUS_OWNED        wxT("Owned")
00080 #define axPROPERTY_RESOURCE_STATUS_WANTED       wxT("Wanted")
00081 #define axPROPERTY_RESOURCE_STATUS_UNKNOWN      wxT("Unknown")
00082 
00091 class AxResource: public AxDocument
00092 {
00093     DECLARE_DYNAMIC_CLASS( AxResource )
00094 
00095 public:
00096 // Constructors
00097 
00098     AxResource(const AxResource& resource) { Init(); Copy(resource); }
00099     AxResource() { Init(); }
00100     ~AxResource();
00101 
00102 // Operations
00103 
00104     void Init();
00105 
00107     void Copy(const AxResource& resource);
00108 
00110     void operator=(const AxResource& resource) { Copy(resource); }
00111 
00113     bool Eq(const AxResource& resource) const;
00114 
00116     virtual AxDocument* Clone() const { return new AxResource(*this); }
00117 
00120     virtual bool Read(wxDataStreamHelper& helper);
00121 
00123     virtual bool ReadProperties(wxDataStreamHelper& helper);
00124 
00127     virtual bool Write(wxDataStreamHelper& helper);
00128 
00130     virtual bool WriteProperties(wxDataStreamHelper& helper);
00131 
00133     virtual bool ReadChildren(wxDataStreamHelper& helper);
00134 
00136     virtual bool WriteChildren(wxDataStreamHelper& helper);
00137 
00139     virtual void SetFilename(const wxString& filename) { SetProperty(axPROPERTY_FILENAME, filename); }
00140 
00142     virtual wxString GetFilename() const { return GetPropertyString(axPROPERTY_FILENAME); }
00143 
00145     virtual wxString GetLongDescription() const { return GetPropertyString(axPROPERTY_DESCRIPTION); }
00146 
00148     virtual wxString GetShortDescription() const { return GetPropertyString(axPROPERTY_DESCRIPTION); }
00149 
00151     AxProperties& GetProperties() { return m_properties; }
00152 
00154     virtual void SetProperty(const AxProperty& property);
00155     virtual void SetProperty(const wxString& name, const wxString& value);
00156     virtual void SetProperty(const wxString& name, const wxChar* value) { SetProperty(name, wxString(value)); }
00157     virtual void SetProperty(const wxString& name, const wxString& value, const wxArrayString& choices);
00158     virtual void SetProperty(const wxString& name, long value);
00159     virtual void SetProperty(const wxString& name, int value);
00160     virtual void SetProperty(const wxString& name, bool value);
00161     virtual void SetProperty(const wxVariant& value);
00162 
00164     virtual AxProperty GetProperty(const wxString& name) const;
00165 
00167     virtual wxVariant GetPropertyValue(const wxString& name) const;
00168 
00170     virtual wxString GetPropertyString(const wxString& name) const;
00171     virtual wxString GetPropertyString(const wxChar* name) const { return GetPropertyString(wxString(name)); }
00172 
00174     virtual long GetPropertyLong(const wxString& name) const;
00175 
00177     virtual double GetPropertyDouble(const wxString& name) const;
00178 
00180     virtual long GetPropertyBool(const wxString& name) const;
00181 
00183     virtual bool HasProperty(const wxString& name) const;
00184 
00186     virtual wxArrayString EnumerateProperties() const;
00187 
00189     virtual int GetPropertyCount() const { return m_properties.GetCount(); }
00190 
00192     virtual AxProperty GetProperty(size_t i) const;
00193     virtual AxProperty* GetPropertyPtr(size_t i) const { return m_properties.GetNth(i); }
00194 
00196     AxResourceArray& GetChildren() { return m_children; }
00197     const AxResourceArray& GetChildren() const { return m_children; }
00198 
00200     void ClearChildren();
00201     void Clear() { ClearChildren(); }
00202 
00204     bool AddChild(AxResource* resource);
00205 
00207     bool RemoveChild(AxResource* resource);
00208 
00210     size_t GetCount() const { return m_children.GetCount(); }
00211 
00213     AxResource* GetChild(size_t i) const { return m_children[i]; }
00214 
00216     bool GetLocalFile() const { return m_localFile; }
00217     void SetLocalFile(bool mod) { m_localFile = mod; }
00218 
00220     virtual AxResource* FindByFilename(const wxString& filename) const;
00221 
00222 protected:
00223 
00224     AxProperties            m_properties;
00225     AxResourceArray         m_children;
00226 
00227     bool                    m_localFile;
00228 };
00229 
00230 #endif
00231     // _AX_RESOURCE_H_

Generated on Wed May 6 19:20:18 2009 for AxTk by  doxygen 1.5.1