CRenderedObjectFileLoaderComp.h
Go to the documentation of this file.
1 #ifndef ifileproc_CRenderedObjectFileLoaderComp_included
2 #define ifileproc_CRenderedObjectFileLoaderComp_included
3 
4 
5 // Qt includes
6 #include <QtCore/QDateTime>
7 
8 // ACF includes
9 #include <istd/TSmartPtr.h>
10 #include <iser/ISerializable.h>
11 #include <icomp/CComponentBase.h>
12 #include <ifile/IFilePersistence.h>
13 #include <iimg/CBitmap.h>
14 #include <iproc/IProcessor.h>
15 
16 
17 namespace ifileproc
18 {
19 
20 
22  public icomp::CComponentBase,
23  virtual public ifile::IFilePersistence,
24  virtual public iser::ISerializable
25 {
26 public:
28 
29  I_BEGIN_COMPONENT(CRenderedObjectFileLoaderComp);
30  I_REGISTER_INTERFACE(istd::IChangeable);
31  I_REGISTER_INTERFACE(ifile::IFilePersistence);
32  I_REGISTER_INTERFACE(iser::ISerializable);
33  I_ASSIGN_MULTI_0(m_fileLoadersCompPtr, "FileLoaders", "List of the supported file loaders, which will be used to open the input file", true);
34  I_ASSIGN_MULTI_0(m_dataObjectFactCompPtr, "DataObjectFactories", "List of factories used for creation of preview's data model", true);
35  I_ASSIGN_MULTI_0(m_previewGenerationProcessorsCompPtr, "PreviewGenerationProcessors", "Processor used for generation of the preview bitmap", true);
36  I_ASSIGN(m_widthAttrPtr, "BitmapWidth", "Width of the generated preview bitmap", true, 128);
37  I_ASSIGN(m_heightAttrPtr, "BitmapHeight", "Height of the generated preview bitmap", true, 128);
38  I_ASSIGN(m_maxCacheSizeAttrPtr, "MaxCacheSize", "Maximal number of bitmaps in cache", false, 100);
39  I_ASSIGN(m_useTempFileAttrPtr, "UseTempFile", "If enabled, the temporary copy of the input file will be created and used for rendering", true, true);
40  I_END_COMPONENT;
41 
42  // reimplemented (ifile::IFilePersistence)
43  virtual bool IsOperationSupported(
44  const istd::IChangeable* dataObjectPtr,
45  const QString* filePathPtr = NULL,
46  int flags = -1,
47  bool beQuiet = true) const;
48  virtual int LoadFromFile(
49  istd::IChangeable& data,
50  const QString& filePath = QString(),
51  ibase::IProgressManager* progressManagerPtr = NULL) const;
52  virtual int SaveToFile(
53  const istd::IChangeable& data,
54  const QString& filePath = QString(),
55  ibase::IProgressManager* progressManagerPtr = NULL) const;
56 
57  // reimplemented (ifile::IFileTypeInfo)
58  virtual bool GetFileExtensions(QStringList& result, const istd::IChangeable* dataObjectPtr = NULL, int flags = -1, bool doAppend = false) const;
59  virtual QString GetTypeDescription(const QString* extensionPtr = NULL) const;
60 
61  // reimplemented (iser::ISerializable)
62  virtual bool Serialize(iser::IArchive& archive);
63 
64 protected:
65  // reimplemented (icomp::CComponentBase)
66  virtual void OnComponentCreated();
67 
68 private:
69  ifile::IFilePersistence* GetLoaderForFile(const QString& filePath) const;
70  istd::IChangeable* GetDataObjectForFile(const QString& filePath) const;
71  iproc::IProcessor* GetPreviewGeneratorForFile(const QString& filePath) const;
72 
73 private:
74  I_MULTIREF(ifile::IFilePersistence, m_fileLoadersCompPtr);
75  I_MULTIFACT(istd::IChangeable, m_dataObjectFactCompPtr);
76  I_MULTIREF(iproc::IProcessor, m_previewGenerationProcessorsCompPtr);
77  I_ATTR(int, m_widthAttrPtr);
78  I_ATTR(int, m_heightAttrPtr);
79  I_ATTR(int, m_maxCacheSizeAttrPtr);
80  I_ATTR(bool, m_useTempFileAttrPtr);
81 
82  struct Configuration
83  {
84  Configuration()
85  :filePersistencePtr(NULL),
86  previewGenerationProcessorPtr(NULL)
87  {
88  }
89 
90  bool IsValid() const
91  {
92  return (filePersistencePtr != NULL) && dataObjectPtr.IsValid() && (previewGenerationProcessorPtr != NULL);
93  }
94 
95  ifile::IFilePersistence* filePersistencePtr;
97  iproc::IProcessor* previewGenerationProcessorPtr;
98  };
99 
100  typedef QList<Configuration> Configurations;
101 
102  struct FileInfo
103  {
104  QDateTime fileTimeStamp;
105  istd::TSmartPtr<iimg::CBitmap> fileBitmapPtr;
106  };
107 
108  typedef QMap<QString, FileInfo> PreviewCache;
109 
110  mutable PreviewCache m_previewCache;
111 
112  mutable Configurations m_workingConfigurations;
113 };
114 
115 
116 } // namespace ifileproc
117 
118 
119 #endif // !ifileproc_CRenderedObjectFileLoaderComp_included
120 
121 
virtual int LoadFromFile(istd::IChangeable &data, const QString &filePath=QString(), ibase::IProgressManager *progressManagerPtr=NULL) const
virtual int SaveToFile(const istd::IChangeable &data, const QString &filePath=QString(), ibase::IProgressManager *progressManagerPtr=NULL) const
virtual bool GetFileExtensions(QStringList &result, const istd::IChangeable *dataObjectPtr=NULL, int flags=-1, bool doAppend=false) const
virtual bool IsOperationSupported(const istd::IChangeable *dataObjectPtr, const QString *filePathPtr=NULL, int flags=-1, bool beQuiet=true) const
virtual bool Serialize(iser::IArchive &archive)
virtual QString GetTypeDescription(const QString *extensionPtr=NULL) const
#define NULL
Interface for all synchrone and asynchrone processors with "push data" model.
Definition: IProcessor.h:24

© 2007-2017 Witold Gantzke and Kirill Lepskiy