Oracle Coherence for C++ API
Release 3.6.0.0

E15728-01

coherence/lang/TypedBarrenClass.hpp

00001 /*
00002 * TypedBarrenClass.hpp
00003 *
00004 * Copyright (c) 2000, 2010, 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_TYPED_BARREN_CLASS_HPP
00017 #define COH_TYPED_BARREN_CLASS_HPP
00018 
00019 #include "coherence/lang/compatibility.hpp"
00020 
00021 #include "coherence/lang/Class.hpp"
00022 #include "coherence/lang/ClassLoader.hpp"
00023 #include "coherence/lang/UnsupportedOperationException.hpp"
00024 
00025 #include <ostream>
00026 #include <typeinfo>
00027 
00028 COH_OPEN_NAMESPACE2(coherence,lang)
00029 
00030 
00031 /**
00032 * TypedBarrenClass provides a templated extension of Class but does not
00033 * provide a means to instantiate new instances of the class.
00034 *
00035 * This is suitable for use with interfaces, abstract classes, and classes
00036 * which do not have a zero-argument create method.
00037 *
00038 * @author mf/jh  2008.05.02
00039 */
00040 template<class T> class TypedBarrenClass
00041     : public class_spec<TypedBarrenClass<T>,
00042         extends<Class> >
00043     {
00044     friend class factory<TypedBarrenClass<T> >;
00045 
00046     // ----- typedefs -------------------------------------------------------
00047 
00048     public:
00049         /**
00050         * Class type.
00051         */
00052         typedef T Type;
00053 
00054 
00055     // ----- constructors ---------------------------------------------------
00056 
00057     protected:
00058         /**
00059         * Create a new TypedBarrenClass.
00060         *
00061         * @return a new TypedBarrenClass
00062         */
00063         TypedBarrenClass<T>()
00064             : class_spec<TypedBarrenClass<T>, extends<Class> >(typeid(T))
00065             {
00066             }
00067 
00068     private:
00069         /**
00070         * Blocked copy constructor
00071         */
00072         TypedBarrenClass<T>(const TypedBarrenClass<T>&);
00073 
00074 
00075     // ----- TypedBarrenClass interface -------------------------------------
00076 
00077     public:
00078         /**
00079         * {@inheritDoc}
00080         *
00081         * @throws UnsupportedOperationException
00082         */
00083         virtual Object::Handle newInstance(ObjectArray::View /*vaParam*/) const
00084             {
00085             if (true)
00086                 {
00087                 COH_THROW (UnsupportedOperationException::create(Class::getName()));
00088                 }
00089             return NULL;
00090             }
00091 
00092         /**
00093         * {@inheritDoc}
00094         */
00095         virtual const std::type_info& getTypeInfo() const
00096             {
00097             return typeid(T);
00098             }
00099 
00100         /**
00101         * {@inheritDoc}
00102         */
00103         virtual size32_t getSize() const
00104             {
00105             return (size32_t) sizeof(T);
00106             }
00107 
00108 
00109     // ----- Object interface -----------------------------------------------
00110 
00111     public:
00112         /**
00113         * {@inheritDoc}
00114         */
00115         virtual void toStream(std::ostream& out) const
00116             {
00117             out << "TypedBarrenClass<" << Class::getName() << ">";
00118             }
00119     };
00120 
00121 COH_CLOSE_NAMESPACE2
00122 
00123 #endif // COH_TYPED_BARREN_CLASS_HPP
Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.