Oracle Coherence for C++ API
Release 3.6.1.0
E18813-01

- Main Page
- Namespaces
- Classes
- Files

# coherence/lang/Class.hpp

    00001 /*
    00002 * Class.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_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     // ----- Object interface -----------------------------------------------
    00096
    00097     public:
    00098         /**
    00099         * {@inheritDoc}
    00100         */
    00101         virtual bool equals(Object::View that) const;
    00102
    00103         /**
    00104         * {@inheritDoc}
    00105         */
    00106         virtual size32_t hashCode() const;
    00107
    00108
    00109     // ----- static helpers -------------------------------------------------
    00110
    00111     public:
    00112         /**
    00113         * Return the class name of the supplied Object.
    00114         *
    00115         * @param v  the object instance for which to obtain the class name
    00116         *
    00117         * @return the class name of the supplied Object
    00118         */
    00119         static String::View getClassName(Object::View v);
    00120
    00121         /**
    00122         * Return the type name of the supplied Object.
    00123         *
    00124         * @param info  the type id for which to obtain the type name
    00125         *
    00126         * @return the type name of the supplied type
    00127         */
    00128         static String::View getTypeName(const std::type_info& info);
    00129
    00130
    00131     // ----- data members ---------------------------------------------------
    00132
    00133     private:
    00134         /**
    00135         * The class name.
    00136         */
    00137         FinalView<String> m_vsName;
    00138     };
    00139
    00140 COH_CLOSE_NAMESPACE2
    00141
    00142 #endif // COH_CLASS_HPP

Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.