1 /* 2 * Copyright 2006, 2007, 2011, Stephan Aßmus <superstippi@gmx.de>. 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 #ifndef EXPORTER_H 6 #define EXPORTER_H 7 8 9 #include <Entry.h> 10 #include <OS.h> 11 12 #include "IconBuild.h" 13 14 15 class BPositionIO; 16 class Document; 17 18 19 _BEGIN_ICON_NAMESPACE 20 class Icon; 21 _END_ICON_NAMESPACE 22 23 _USING_ICON_NAMESPACE 24 25 /*! Base class for all exporters to implement. */ 26 class Exporter { 27 public: 28 Exporter(); 29 virtual ~Exporter(); 30 31 /*! Export the Document to the specified entry_ref. 32 Spawns a separate thread to do the actual exporting. 33 Uses the virtual Export function defined after this function to do the 34 actual export. 35 */ 36 status_t Export(Document* document, 37 const entry_ref& ref); 38 39 virtual status_t Export(const Icon* icon, 40 BPositionIO* stream) = 0; 41 42 virtual const char* MIMEType() = 0; 43 44 /*! If \a selfDestroy is true, class deletes itself when export thread is 45 finished. 46 */ 47 void SetSelfDestroy(bool selfDestroy); 48 49 void WaitForExportThread(); 50 51 private: 52 static int32 _ExportThreadEntry(void* cookie); 53 int32 _ExportThread(); 54 status_t _Export(const Icon* icon, 55 const entry_ref* docRef); 56 57 Document* fDocument; 58 Icon* fClonedIcon; 59 entry_ref fRef; 60 thread_id fExportThread; 61 bool fSelfDestroy; 62 }; 63 64 #endif // EXPORTER_H 65