Oracle Coherence for C++ API
Release 3.7.0.0

E18684-01

coherence/io/pof/SystemPofContext.hpp

00001 /*
00002 * SystemPofContext.hpp
00003 *
00004 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
00005 *
00006 * Oracle is a registered trademarks of Oracle Corporation and/or its
00007 * affiliates.
00008 *
00009 * This software is the confidential and proprietary information of Oracle
00010 * Corporation. You shall not disclose such confidential and proprietary
00011 * information and shall use it only in accordance with the terms of the
00012 * license agreement you entered into with Oracle.
00013 *
00014 * This notice may not be removed or altered.
00015 */
00016 #ifndef COH_SYSTEM_POF_CONTEXT_HPP
00017 #define COH_SYSTEM_POF_CONTEXT_HPP
00018 
00019 #include "coherence/lang.ns"
00020 
00021 #include "coherence/io/pof/SimplePofContext.hpp"
00022 
00023 COH_OPEN_NAMESPACE3(coherence,io,pof)
00024 
00025 
00026 /**
00027 * System-wide PofContext implementation that allows POF user types to
00028 * be registered programatically.
00029 *
00030 * @author jh  2008.02.21
00031 */
00032 class COH_EXPORT SystemPofContext
00033     : public class_spec<SystemPofContext,
00034         extends<SimplePofContext> >
00035     {
00036     friend class factory<SystemPofContext>;
00037 
00038     // ----- constructors ---------------------------------------------------
00039 
00040     protected:
00041         /**
00042         * @internal
00043         */
00044         using this_spec::create;
00045 
00046     private:
00047         /**
00048         * @internal
00049         */
00050         SystemPofContext();
00051 
00052 
00053     public:
00054         /**
00055         * Return the SystemPofContext singleton instance.
00056         *
00057         * @return the global SystemPofContext
00058         */
00059         static Handle getInstance();
00060 
00061         /**
00062         * Executable entrypoint for the SystemPofContext class.
00063         *
00064         * Print the POF registrations.
00065         *
00066         * @param vasArg  a list of libraries to load, and print their
00067         *                registered classes.
00068         */
00069         static void main(ObjectArray::View vasArg);
00070     };
00071 
00072 
00073 // ----- helper macros ------------------------------------------------------
00074 
00075 /**
00076 * Register a PofSerializer with the system PofContext. The call will also
00077 * register the class with the SystemClassLoader.
00078 *
00079 * @param POF_TYPE_ID     the POF type identifier
00080 * @param CLASS           the associated class to register
00081 * @param POF_SERIALIZER  the PofSerializer instance to register
00082 */
00083 #define COH_REGISTER_POF_SERIALIZER(POF_TYPE_ID, CLASS, POF_SERIALIZER) \
00084     COH_STATIC_INIT(coherence::io::pof::SystemPofContext::getInstance()-> \
00085         registerUserType(POF_TYPE_ID, \
00086             coherence::lang::SystemClassLoader::getInstance()-> \
00087             registerClass(CLASS), POF_SERIALIZER))
00088 
00089 /**
00090 * Register a PortableObject implementation with the system ClassLoader and
00091 * PofContext.
00092 *
00093 * @param POF_TYPE_ID  the POF type identifier
00094 * @param TYPE         the class type to register
00095 */
00096 #define COH_REGISTER_PORTABLE_CLASS(POF_TYPE_ID, TYPE) \
00097     COH_REGISTER_POF_SERIALIZER(POF_TYPE_ID, \
00098         coherence::lang::TypedClass<TYPE >::create(), \
00099         coherence::io::pof::PortableObjectSerializer::create(POF_TYPE_ID))
00100 
00101 /**
00102 * Register a Managed object implementation with the system ClassLoader and
00103 * PofContext.
00104 *
00105 * @param POF_TYPE_ID  the POF type identifier
00106 * @param TYPE         the class type to register
00107 */
00108 #define COH_REGISTER_MANAGED_CLASS(POF_TYPE_ID, TYPE) \
00109     COH_REGISTER_POF_SERIALIZER(POF_TYPE_ID, \
00110         coherence::lang::TypedClass<coherence::lang::Managed<TYPE > >::create(), \
00111         coherence::io::pof::TypedSerializer<coherence::lang::Managed<TYPE > >::create())
00112 
00113 COH_CLOSE_NAMESPACE3
00114 
00115 #endif // COH_SYSTEM_POF_CONTEXT_HPP
Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.