00001 /* 00002 * OutOfMemoryError.hpp 00003 * 00004 * Copyright (c) 2000, 2013, 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_OUT_OF_MEMORY_ERROR 00017 #define COH_OUT_OF_MEMORY_ERROR 00018 00019 #include "coherence/lang/compatibility.hpp" 00020 00021 #include "coherence/lang/Exception.hpp" 00022 #include "coherence/lang/RuntimeException.hpp" 00023 #include "coherence/lang/String.hpp" 00024 00025 COH_OPEN_NAMESPACE2(coherence,lang) 00026 00027 00028 /** 00029 * Thrown to indicate that an attempt to allocate an object failed due to 00030 * resource constraints. 00031 */ 00032 class COH_EXPORT OutOfMemoryError 00033 : public throwable_spec<OutOfMemoryError, 00034 extends<RuntimeException, std::bad_alloc> > 00035 { 00036 friend class factory<OutOfMemoryError>; 00037 00038 // ----- constructors --------------------------------------------------- 00039 00040 protected: 00041 /** 00042 * Create a OutOfMemoryError. 00043 * 00044 * @param vsMsg the detail message 00045 * @param vCause the underlying cause of the exception 00046 */ 00047 OutOfMemoryError(String::View vsMsg = String::null_string, 00048 Exception::View vCause = NULL); 00049 00050 00051 // ----- static helpers ------------------------------------------------- 00052 00053 public: 00054 /** 00055 * Ensure that the supplied pointer is non-NULL. If NULL then an 00056 * OutOfMemoryErrorWill be thrown. 00057 * 00058 * @param pAlloc the pointer to validate 00059 * @param cb the size of the allocation request 00060 */ 00061 static void ensure(void* pAlloc, size_t cb = 0); 00062 }; 00063 00064 00065 COH_CLOSE_NAMESPACE2 00066 00067 #endif // COH_OUT_OF_MEMORY_ERROR