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

E90870-01

coherence/lang/TypedClass.hpp

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