Oracle Coherence for C++ API
Release 3.7.0.0

E18684-01

coherence/lang/Class.hpp

00001 /*
00002 * Class.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_CLASS_HPP
00017 #define COH_CLASS_HPP
00018 
00019 #include "coherence/lang/compatibility.hpp"
00020 
00021 #include "coherence/lang/abstract_spec.hpp"
00022 #include "coherence/lang/FinalView.hpp"
00023 #include "coherence/lang/Object.hpp"
00024 #include "coherence/lang/ObjectArray.hpp"
00025 #include "coherence/lang/String.hpp"
00026 
00027 #include <ostream>
00028 #include <typeinfo>
00029 
00030 COH_OPEN_NAMESPACE2(coherence,lang)
00031 
00032 
00033 /**
00034 * A Class represents a managed object implementation.
00035 *
00036 * Not all managed classes may have a corresponding Class representation.
00037 * Classes are referred to via their demangled RTTI name, for example
00038 * coherence::lang::Object.
00039 *
00040 * Classes can be loaded by name via a ClassLoader.
00041 *
00042 * @see ClassLoader
00043 *
00044 * @author mf  2008.04.03
00045 */
00046 class COH_EXPORT Class
00047     : public abstract_spec<Class>
00048     {
00049     // ----- constructors ---------------------------------------------------
00050 
00051     protected:
00052         /**
00053         * Construct a class based on a C++ type_info.
00054         *
00055         * @param info the type_info for the class represented by this Class.
00056         */
00057         Class(const std::type_info& info);
00058 
00059 
00060     // ----- Class interface ------------------------------------------------
00061 
00062     public:
00063         /**
00064         * Return the name of the class.
00065         *
00066         * @return the class name
00067         */
00068         String::View getName() const;
00069 
00070         /**
00071         * Create a new instance of the corresponding type.
00072         *
00073         * @param vaParam the object's initialization parameters
00074         *
00075         * @return a new instance of the corresponding type
00076         */
00077         virtual Object::Handle newInstance(ObjectArray::View vaParam = NULL) const = 0;
00078 
00079         /**
00080         * Return the typeinfo for the corresponding type.
00081         *
00082         * @return the typeinfo for the corresponding type
00083         */
00084         virtual const std::type_info& getTypeInfo() const = 0;
00085 
00086         /**
00087         * Return the shallow size for an instance of the class represented
00088         * by this Class.
00089         *
00090         * @return the shallow size of an instance of the represented class.
00091         */
00092         virtual size32_t getSize() const = 0;
00093 
00094         /**
00095         * Return whether the passed in Object is an instance of class represented
00096         * by this Class.
00097         *
00098         * @return whether the passed in Object is an instance of class represented
00099         * by this Class.
00100         *
00101         * @since Coherence 3.7
00102         */
00103         virtual bool isInstance(Object::View v) const = 0;
00104 
00105 
00106     // ----- Object interface -----------------------------------------------
00107 
00108     public:
00109         /**
00110         * {@inheritDoc}
00111         */
00112         virtual bool equals(Object::View that) const;
00113 
00114         /**
00115         * {@inheritDoc}
00116         */
00117         virtual size32_t hashCode() const;
00118 
00119 
00120     // ----- static helpers -------------------------------------------------
00121 
00122     public:
00123         /**
00124         * Return the class name of the supplied Object.
00125         *
00126         * @param v  the object instance for which to obtain the class name
00127         *
00128         * @return the class name of the supplied Object
00129         */
00130         static String::View getClassName(Object::View v);
00131 
00132         /**
00133         * Return the type name of the supplied Object.
00134         *
00135         * @param info  the type id for which to obtain the type name
00136         *
00137         * @return the type name of the supplied type
00138         */
00139         static String::View getTypeName(const std::type_info& info);
00140 
00141 
00142     // ----- data members ---------------------------------------------------
00143 
00144     private:
00145         /**
00146         * The class name.
00147         */
00148         FinalView<String> m_vsName;
00149     };
00150 
00151 COH_CLOSE_NAMESPACE2
00152 
00153 #endif // COH_CLASS_HPP
Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.