00001 /************************************************************************************ 00002 * This file is part of the MynahSA streaming and archiving toolkit * 00003 * Copyright (C) 2006 Mynah-Software Ltd. All Rights Reserved. * 00004 * * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License, version 2 * 00007 * as published by the Free Software Foundation. * 00008 * * 00009 * This program is distributed in the hope that it will be useful, * 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00012 * GNU General Public License for more details. * 00013 * * 00014 * You should have received a copy of the GNU General Public License along * 00015 * with this program; if not, write to the Free Software Foundation, Inc., * 00016 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * 00017 * * 00018 ************************************************************************************/ 00019 00020 #ifndef __i_archive_register_hpp 00021 #define __i_archive_register_hpp 00022 00029 #include "iobase.hpp" 00030 #include "archive.hpp" 00031 00032 #include <mynahsa/spimpl.hpp> 00033 00034 00035 // This macro defines a class named XConstrcutor where X is replaced by the macro name. 00036 // The purpose of this macro is to simplify the definition of a constructor class for 00037 // the input archive handler. 00038 // 00039 // Each class to be handled by the input archive handler must have this macro used 00040 // for it to define a constructor object. 00041 00042 #define MYNAHSA_BUILD_CONSTRUCTOR( X ) \ 00043 class X##Constructor : public MynahSA::Archive::ArchiveConstructor { \ 00044 public: \ 00045 X##Constructor() { } \ 00046 ~X##Constructor() { } \ 00047 SHARED_PTR<MynahSA::IoBase> operator()() const { \ 00048 SHARED_PTR< X > rv(new X); \ 00049 return rv; \ 00050 } \ 00051 }; 00052 00053 // This macro is used to insert a class constructor into an iarchive instance. 00054 // the macro paramaters are: Input Archive (or Archive) IA, Instance 00055 #define MYNAHSA_REGISTER_CONSTRUCTOR( IA, TypeName ) IA.registerConstructor( TypeName().ioName(), \ 00056 SHARED_PTR< MynahSA::Archive::ArchiveConstructor >(new TypeName##Constructor)) 00057 00058 00059 #endif