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

E90870-01

coherence/lang/IllegalStateException.hpp

00001 /*
00002 * IllegalStateException.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_ILLEGAL_STATE_EXCEPTION_HPP
00017 #define COH_ILLEGAL_STATE_EXCEPTION_HPP
00018 
00019 #include "coherence/lang/compatibility.hpp"
00020 
00021 #include "coherence/lang/RuntimeException.hpp"
00022 #include "coherence/lang/String.hpp"
00023 
00024 COH_OPEN_NAMESPACE2(coherence,lang)
00025 
00026 
00027 /**
00028 * Signals that a function has been called at an illegal or inappropriate
00029 * time. In other words, the environment or application is not in an
00030 * appropriate state for the requested operation.
00031 */
00032 class COH_EXPORT IllegalStateException
00033     : public throwable_spec<IllegalStateException,
00034         extends<RuntimeException> >
00035     {
00036     friend class factory<IllegalStateException>;
00037 
00038     // ----- constructors ---------------------------------------------------
00039 
00040     protected:
00041         /**
00042         * Create an IllegalStateException.
00043         *
00044         * @param vsMsg   the detail message
00045         * @param vCause  the underlying cause of the exception
00046         *
00047         * @return a new IllegalStateException
00048         */
00049         IllegalStateException(String::View vsMsg = String::null_string,
00050                 Exception::View vCause = NULL);
00051     };
00052 
00053 
00054 // ----- helper macros ------------------------------------------------------
00055 
00056 /**
00057 * Ensure the relation between two expressions.
00058 *
00059 * @param TYPE  the result type of the expressions
00060 * @param EXPL  the left expression
00061 * @param OP    the expected relation, i.e. ==, <, >, ...
00062 * @param EXPR  the right expression
00063 *
00064 * @throw IllegalStateException if an unexpected result is returned
00065 */
00066 #define COH_ENSURE_RELATION(TYPE, EXPL, OP, EXPR) \
00067     { \
00068     TYPE expl = (EXPL); \
00069     TYPE expr = (EXPR); \
00070     if (!(expl OP expr)) \
00071         { \
00072         COH_THROW_STREAM (coherence::lang::IllegalStateException, \
00073             "ensuring: '" << #EXPL << ' ' << #OP << ' ' << \
00074             #EXPR << "'; result " << expl << " not " #OP << \
00075             ' ' << expr); \
00076         } \
00077     }
00078 
00079 /**
00080 * Ensure that the expression returns the expected result.
00081 *
00082 * @param EXPRESSION       the expression to evaluate, must return a result
00083 *                         which is castable to size32_t
00084 * @param EXPECTED_RESULT  the expected result, which is castable to size32_t
00085 *
00086 * @throw IllegalStateException if an unexpected result is returned
00087 */
00088 #define COH_ENSURE_EQUALITY(EXPRESSION, EXPECTED_RESULT) \
00089     COH_ENSURE_RELATION(size32_t, EXPRESSION, ==, EXPECTED_RESULT)
00090 
00091 /**
00092 * Ensure that the expression evaluates to true.
00093 *
00094 * @param EXPRESSION      the expression to evaluate, must return a result
00095 *                        which is castable to size32_t
00096 *
00097 * @throw IllegalStateException if an unexpected result is returned
00098 */
00099 #define COH_ENSURE(EXPRESSION) \
00100     COH_ENSURE_RELATION(bool, EXPRESSION, ==, true)
00101 
00102 COH_CLOSE_NAMESPACE2
00103 
00104 #endif // COH_ILLEGAL_STATE_EXCEPTION_HPP
Copyright © 2000, 2019, Oracle and/or its affiliates. All rights reserved.