C++ Client API Reference for Oracle Coherence
14c (14.1.2.0.0)

F79659-03

coherence/lang/ClassLoader.hpp

00001 /*
00002  * Copyright (c) 2000, 2020, Oracle and/or its affiliates.
00003  *
00004  * Licensed under the Universal Permissive License v 1.0 as shown at
00005  * http://oss.oracle.com/licenses/upl.
00006  */
00007 #ifndef COH_CLASS_LOADER_HPP
00008 #define COH_CLASS_LOADER_HPP
00009 
00010 #include "coherence/lang/compatibility.hpp"
00011 
00012 #include "coherence/lang/interface_spec.hpp"
00013 #include "coherence/lang/Class.hpp"
00014 #include "coherence/lang/Object.hpp"
00015 #include "coherence/lang/String.hpp"
00016 
00017 #include <typeinfo>
00018 
00019 COH_OPEN_NAMESPACE2(coherence,lang)
00020 
00021 
00022 /**
00023 * ClassLoader provides a mechanism for obtaining a Class object.  Classes
00024 * may be manually registered with a loader, or the loader may search out
00025 * classes using custom search and load mechanisms.
00026 *
00027 * Not all classes are required to have a corresponding Class representation.
00028 *
00029 * The simplest way to enable a Class to be looked up by name, is to register
00030 * it with the system ClassLoader, which can be obtained by calling
00031 * ClassLoader::getSystemClassLoader().  For classes which include a no
00032 * parameter static create method, a utility macro can be used to generate
00033 * and register a Class automatically.  For example, given the class Foo:
00034 *
00035 * COH_REGISTER_TYPED_CLASS(Foo)
00036 *
00037 * Will register a Class for Foo. This registration would normally occur in
00038 * Foo.cpp, outside of any method.
00039 *
00040 * @author mf  2008.04.02
00041 */
00042 class COH_EXPORT ClassLoader
00043     : public interface_spec<ClassLoader>
00044     {
00045     // ----- ClassLoader interface ------------------------------------------
00046 
00047     public:
00048         /**
00049         * Loads the class for the specified name.
00050         *
00051         * @param vsName  the fully qualified name of the desired class
00052         *
00053         * @return the resulting {@link Class} object
00054         *
00055         * @throws ClassNotFoundException if the class was not found
00056         */
00057         virtual Class::View loadByName(String::View vsName) const = 0;
00058 
00059         /**
00060         * Loads the class for the specified RTTI typeid.
00061         *
00062         * @param info  the class's type_info
00063         *
00064         * @return the resulting {@link Class} object
00065         *
00066         * @throws ClassNotFoundException if the class was not found
00067         */
00068         virtual Class::View loadByType(const std::type_info& info) const = 0;
00069 
00070         /**
00071         * Returns the parent class loader for delegation.
00072         *
00073         * @return the parent class loader for delegation; NULL indicates the
00074         *         system ClassLoader has been reached
00075         */
00076         virtual ClassLoader::Handle getParent() const = 0;
00077     };
00078 
00079 COH_CLOSE_NAMESPACE2
00080 
00081 #endif // COH_CLASS_LOADER_HPP
Copyright © 2000, 2025, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.