ClassLibrary.h
Go to the documentation of this file.
00001 //
00002 // ClassLibrary.h
00003 //
00004 // $Id: //poco/1.3/Foundation/include/Poco/ClassLibrary.h#3 $
00005 //
00006 // Library: Foundation
00007 // Package: SharedLibrary
00008 // Module:  ClassLoader
00009 //
00010 // Definitions for class libraries.
00011 //
00012 // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
00013 // and Contributors.
00014 //
00015 // Permission is hereby granted, free of charge, to any person or organization
00016 // obtaining a copy of the software and accompanying documentation covered by
00017 // this license (the "Software") to use, reproduce, display, distribute,
00018 // execute, and transmit the Software, and to prepare derivative works of the
00019 // Software, and to permit third-parties to whom the Software is furnished to
00020 // do so, all subject to the following:
00021 // 
00022 // The copyright notices in the Software and this entire statement, including
00023 // the above license grant, this restriction and the following disclaimer,
00024 // must be included in all copies of the Software, in whole or in part, and
00025 // all derivative works of the Software, unless such copies or derivative
00026 // works are solely in the form of machine-executable object code generated by
00027 // a source language processor.
00028 // 
00029 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00030 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00031 // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
00032 // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
00033 // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
00034 // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00035 // DEALINGS IN THE SOFTWARE.
00036 //
00037 
00038 
00039 #ifndef Foundation_ClassLibrary_INCLUDED
00040 #define Foundation_ClassLibrary_INCLUDED
00041 
00042 
00043 #include "Poco/Foundation.h"
00044 #include "Poco/Manifest.h"
00045 #include <typeinfo>
00046 
00047 
00048 #if defined(_WIN32)
00049         #define POCO_LIBRARY_API __declspec(dllexport)
00050 #else
00051         #define POCO_LIBRARY_API
00052 #endif
00053 
00054 
00055 //
00056 // the entry points for every class library
00057 //
00058 extern "C"
00059 {
00060         bool POCO_LIBRARY_API pocoBuildManifest(Poco::ManifestBase* pManifest);
00061         void POCO_LIBRARY_API pocoInitializeLibrary();
00062         void POCO_LIBRARY_API pocoUninitializeLibrary();
00063 } 
00064 
00065 
00066 //
00067 // additional support for named manifests
00068 //
00069 #define POCO_DECLARE_NAMED_MANIFEST(name) \
00070 extern "C"      \
00071 {                       \
00072         bool POCO_LIBRARY_API POCO_JOIN(pocoBuildManifest, name)(Poco::ManifestBase* pManifest); \
00073 }
00074 
00075 
00076 //
00077 // Macros to automatically implement pocoBuildManifest
00078 //
00079 // usage:
00080 //
00081 // POCO_BEGIN_MANIFEST(MyBaseClass)
00082 //     POCO_EXPORT_CLASS(MyFirstClass)
00083 //     POCO_EXPORT_CLASS(MySecondClass)
00084 //     ...
00085 // POCO_END_MANIFEST
00086 //
00087 #define POCO_BEGIN_MANIFEST_IMPL(fnName, base) \
00088         bool fnName(Poco::ManifestBase* pManifest_)                                                                             \
00089         {                                                                                                                                                               \
00090                 typedef base _Base;                                                                                                                     \
00091                 typedef Poco::Manifest<_Base> _Manifest;                                                                        \
00092                 std::string requiredType(typeid(_Manifest).name());                                                     \
00093                 std::string actualType(pManifest_->className());                                                        \
00094                 if (requiredType == actualType)                                                                                         \
00095                 {                                                                                                                                                       \
00096                         Poco::Manifest<_Base>* pManifest = static_cast<_Manifest*>(pManifest_);
00097 
00098 
00099 #define POCO_BEGIN_MANIFEST(base) \
00100         POCO_BEGIN_MANIFEST_IMPL(pocoBuildManifest, base)
00101 
00102 
00103 #define POCO_BEGIN_NAMED_MANIFEST(name, base)   \
00104         POCO_DECLARE_NAMED_MANIFEST(name)                       \
00105         POCO_BEGIN_MANIFEST_IMPL(POCO_JOIN(pocoBuildManifest, name), base)
00106 
00107 
00108 #define POCO_END_MANIFEST \
00109                         return true;    \
00110                 }                                       \
00111                 else return false;      \
00112         }
00113 
00114 
00115 #define POCO_EXPORT_CLASS(cls) \
00116     pManifest->insert(new Poco::MetaObject<cls, _Base>(#cls));
00117 
00118 
00119 #define POCO_EXPORT_SINGLETON(cls) \
00120         pManifest->insert(new Poco::MetaSingleton<cls, _Base>(#cls));
00121 
00122 
00123 #endif // Foundation_ClassLibrary_INCLUDED


pluginlib
Author(s): Tully Foote and Eitan Marder-Eppstein
autogenerated on Sat Dec 28 2013 17:20:19