coherence/lang/abstract_spec.hpp

00001 /*
00002 * abstract_spec.hpp
00003 *
00004 * Copyright 2001-2008 by Oracle. 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_ABSTRACT_SPEC_HPP
00017 #define COH_ABSTRACT_SPEC_HPP
00018 
00019 #include "coherence/lang/compatibility.hpp"
00020 
00021 #include "coherence/lang/class_spec.hpp"
00022 
00023 COH_OPEN_NAMESPACE2(coherence,lang)
00024 
00025 class Object;
00026 
00027 /**
00028 * Helper for defining an abstract managed class.
00029 *
00030 * Managed classes are implementations of coherence::lang::Object, and include
00031 * a set of well known features, which are auto-generated by this helper class:
00032 *
00033 * - Handle/View/Holder defintions
00034 * - super class definition
00035 * - virtual interface inheritance of up to 16 interfaces
00036 *
00037 * The template takes three parameters:
00038 *
00039 * - The name of the class being defined
00040 * - The defined classes parent class, indicated as extends<parent>
00041 * - An optional list of interfaces to implement, indicated as
00042 *   implements<i1, i2, ...>
00043 *
00044 * A normal class defintion would be:
00045 * @code
00046 * class Bar
00047 *   : public abstract_spec<Bar,
00048 *       extends<Object>,
00049 *       implements<SomeInterface, SomeOtherInterface> >
00050 *   {
00051 *   public:
00052 *       // normal abstract class definition....
00053 *   };
00054 * @endcode
00055 *
00056 * @see extends
00057 * @see implements
00058 *
00059 * @author mf 2008.07.14
00060 */
00061 template<class T, class E = extends<Object>, class I = implements<> >
00062 class COH_EXPORT_SPEC abstract_spec
00063     : public class_spec<T, E, I>
00064     {
00065     // ----- typedefs -------------------------------------------------------
00066 
00067     public:
00068         /**
00069         * Specification definition
00070         */
00071         typedef abstract_spec this_spec;
00072 
00073         /**
00074         * Definition T's parent class
00075         */
00076         typedef abstract_spec super;
00077 
00078 
00079     // ----- constructors ---------------------------------------------------
00080 
00081     protected:
00082         /**
00083         * Generate a set of proxy constuctors matching the signatures of the
00084         * parent class's constructors.
00085         *
00086         * NOTE: Compilation errors referencing this line likely indicate that
00087         *       class being defined by this spec makes calls a "super"
00088         *       constructor supplying a set of parameters for which there is
00089         *       no exact match on the parent class.
00090         */
00091         COH_DECLARE_PROXY_CONSTRUCTORS(abstract_spec);
00092 
00093     private:
00094         /**
00095         * @internal
00096         *
00097         * Hide inheirted create methods, as abstract objects cannot be
00098         * instantiated.
00099         */
00100         static void create()
00101             {
00102             }
00103 
00104     public:
00105         /**
00106         * {@inheritDoc}
00107         *
00108         * Pure virtual sizeOf definition ensures that the resulting class is
00109         * abstract.
00110         */
00111         virtual size32_t sizeOf() const = 0;
00112     };
00113 COH_DEFINE_PROXY_CONSTRUCTORS(COH_TEMPLATE_DECLARE3(T, E, I), \
00114         COH_TEMPLATE_DEFINE3(T, E, I), abstract_spec, \
00115         class_spec COH_TEMPLATE_DEFINE3(T, E, I))
00116 
00117 COH_CLOSE_NAMESPACE2
00118 
00119 #endif // COH_ABSTRACT_SPEC_HPP
Copyright (c) 2000-2008 Oracle. All rights reserved.