Oracle Coherence for C++ API
Release 3.7.0.0

E18684-01

coherence/lang/TypedBarrenClass.hpp

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