Oracle Fusion Middleware C++ API Reference for Oracle Coherence
12c (12.1.2)

E26041-01

coherence/lang/TypedClass.hpp

00001 /*
00002 * TypedClass.hpp
00003 *
00004 * Copyright (c) 2000, 2013, 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_CLASS_HPP
00017 #define COH_TYPED_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/IllegalArgumentException.hpp"
00024 #include "coherence/lang/Object.hpp"
00025 
00026 #include <ostream>
00027 #include <typeinfo>
00028 
00029 COH_OPEN_NAMESPACE2(coherence,lang)
00030 
00031 
00032 /**
00033 * TypedClass extends AbstractTypedClass supporting classes which
00034 * include a no-argument create method.
00035 *
00036 * @author mf  2008.04.03
00037 */
00038 template<class T> class TypedClass
00039     : public class_spec<TypedClass<T>,
00040         extends<AbstractTypedClass<T> > >
00041     {
00042     friend class factory<TypedClass<T> >;
00043 
00044     // ----- typedefs -------------------------------------------------------
00045 
00046     public:
00047         /**
00048         * Class type.
00049         */
00050         typedef T Type;
00051 
00052 
00053     // ----- constructors ---------------------------------------------------
00054 
00055     protected:
00056         /**
00057         * Create a new TypedClass.
00058         */
00059         TypedClass<T>()
00060             {
00061             }
00062 
00063     private:
00064         /**
00065         * Blocked copy constructor
00066         */
00067         TypedClass<T>(const TypedClass<T>&);
00068 
00069 
00070     // ----- TypedClass interface -------------------------------------------
00071 
00072     public:
00073         /**
00074         * {@inheritDoc}
00075         */
00076         virtual Object::Handle newInstance(ObjectArray::View vaParam) const
00077             {
00078             if (vaParam == NULL || vaParam->length == 0)
00079                 {
00080                 return T::create();
00081                 }
00082             return AbstractTypedClass<T>::newInstance(vaParam);
00083             }
00084 
00085 
00086     // ----- Object interface -----------------------------------------------
00087 
00088     public:
00089         /**
00090         * {@inheritDoc}
00091         */
00092         virtual void toStream(std::ostream& out) const
00093             {
00094             out << "TypedClass<" << Class::getName() << ">";
00095             }
00096     };
00097 
00098 COH_CLOSE_NAMESPACE2
00099 
00100 #endif // COH_TYPED_CLASS_HPP
Copyright © 2000, 2013, Oracle and/or its affiliates. All rights reserved.