| VRS - The Virtual Rendering System |
| version 3.3 |
00001 /****************************************************************************** 00002 * VRS - The Virtual Rendering System 00003 * Copyright (C) 2003 Computer Graphics Systems Group at the 00004 * Hasso-Plattner-Institute (HPI), Potsdam, Germany. 00005 * 00006 * This library is free software; you can redistribute it and/or modify it 00007 * under the terms of the GNU Lesser General Public License as published by 00008 * the Free Software Foundation; either version 2.1 of the License, or (at 00009 * your option) any later version. This library is distributed in the hope 00010 * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied 00011 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU Lesser General Public License for more details. You should have received 00013 * a copy of the GNU Lesser+ General Public License along with this library; if 00014 * not, write to the FreeSoftware Foundation, Inc., 59 Temple Place, Suite 330, 00015 * Boston, MA, 02111-1307, USA. 00016 ******************************************************************************/ 00017 00018 // $Id: objectsaver.h 5191 2006-02-15 14:58:18Z baumann $ 00019 // 00020 // $Log$ 00021 // Revision 1.12 2006/02/15 14:58:18 baumann 00022 // move ObjectLoader and ObjectSaver into vrs_core 00023 // 00024 // Revision 1.11 2005/11/30 15:56:27 baumann 00025 // added objectWriterID to writeToMemory() method 00026 // 00027 // Revision 1.10 2005/03/29 11:12:30 baumann 00028 // new method writeToMemory() added 00029 // 00030 // Revision 1.9 2005/01/03 01:43:09 klimetschek 00031 // - modified win32 project layout, splitted vrs.vcproj into vrs_container, vrs_core, vrs_sg, vrs_image, vrs_opengl and vrs_io 00032 // - removed vrs.vcproj 00033 // minor things: 00034 // - added all glutexamples to vrs4glut.sln 00035 // - fixed some problems in glutexamples 00036 // - removed all project references from all VS projects (using solution wide project dependencies instead) 00037 // 00038 // Revision 1.8 2004/12/09 18:42:35 kirsch 00039 // fixed VRS_SaveObject macros (once again) 00040 // 00041 // Revision 1.6 2004/11/03 11:56:56 saar 00042 // Class comment changed (Doxygen style) 00043 // 00044 // Revision 1.5 2004/09/07 13:04:44 baumann 00045 // new macro VRS_ANONYMOUS_IDENTIFIER() added 00046 // 00047 // Revision 1.4 2004/03/12 16:28:40 baumann 00048 // macros VRS_NAMESPACE_BEGIN/_END expanded and removed 00049 // 00050 // Revision 1.3 2003/12/07 10:38:40 kirsch 00051 // added qualified namespace of std::string 00052 // 00053 // Revision 1.2 2003/11/07 14:19:25 kirsch 00054 // removed leading underscore from include guards 00055 // 00056 // Revision 1.1 2003/11/06 13:49:20 baumgarten 00057 // added objectsaver 00058 // 00059 00060 #ifndef VRS_IO_OBJECTSAVER_H 00061 #define VRS_IO_OBJECTSAVER_H 00062 00063 #include <vrs/sharedobj.h> 00064 00065 namespace VRS { 00066 00067 class DataResource; 00068 class ObjectWriter; 00069 00071 class VRS_CORE_API ObjectSaver : public SharedObj { 00072 public: 00073 static bool install(ObjectWriter*); 00074 static bool uninstall(ObjectWriter*); 00075 static Iterator<SO<ObjectWriter> >* objectWriters(); 00077 00078 static bool write(SharedObj* obj, const std::string& filename); 00079 static SO<DataResource> writeToMemory( 00080 SO<SharedObj> obj, 00081 const std::string& objectWriterID = "" 00082 ); 00083 static ObjectWriter* lastWriter(); 00090 static std::string supportedFileExtensions( 00091 SharedObj* obj, 00092 const std::string& prefix = "*.", 00093 const std::string& separator = " ", 00094 const std::string& postfix = "" 00095 ); 00102 static std::string supportedFiles( 00103 SharedObj* obj, 00104 bool addFormatName = true, 00105 bool addParenthesis = true, 00106 const std::string& formatSeparator = "\n", 00107 const std::string& extPrefix = "*.", 00108 const std::string& extSeparator = " ", 00109 const std::string& extSuffix = "" 00110 ); 00116 VRS_TYPEINFO(ObjectSaver, SharedObj); 00117 }; 00118 00119 #define VRS_SaveObject(OBJECT, FILE_NAME) \ 00120 ::VRS::ObjectSaver::write((OBJECT), (FILE_NAME)) 00121 00122 #define VRS_GuardedSaveObject(OBJECT, FILE_NAME) \ 00123 { \ 00124 bool returnValue = ::VRS::ObjectSaver::write(OBJECT, FILE_NAME); \ 00125 VRS_InternalError(returnValue, "saving object to file '" << FILE_NAME << "' failed"); \ 00126 } 00127 00128 00129 #define VRS_REGISTER_WRITER(WRITER) \ 00130 namespace { \ 00131 bool VRS_ANONYMOUS_IDENTIFIER(registration) = ::VRS::ObjectSaver::install(new WRITER); \ 00132 } 00133 00134 } // namespace VRS 00135 00136 #endif // VRS_IO_OBJECTSAVER_H