00001 /* 00002 * ReferenceLibrary.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_REFERENCE_LIBRARY_HPP 00017 #define COH_REFERENCE_LIBRARY_HPP 00018 00019 #include "coherence/lang.ns" 00020 00021 #include "coherence/util/IdentityHashMap.hpp" 00022 00023 COH_OPEN_NAMESPACE3(coherence,io,pof) 00024 00025 using coherence::util::IdentityHashMap; 00026 00027 00028 /** 00029 * A "library" of object references and their corresponding identities in 00030 * the POF stream. 00031 * @author wl 2010.09.21 00032 */ 00033 class COH_EXPORT ReferenceLibrary 00034 : public class_spec<ReferenceLibrary, 00035 extends <Object> > 00036 { 00037 friend class factory<ReferenceLibrary>; 00038 00039 // ----- constructors --------------------------------------------------- 00040 00041 protected: 00042 /** 00043 * @internal 00044 */ 00045 ReferenceLibrary(); 00046 00047 00048 // ----- member methods ------------------------------------------------- 00049 00050 public: 00051 /** 00052 * Look up an identity for an object. 00053 * 00054 * @param v the object 00055 * 00056 * @return the identity, or -1 if the object is not registered 00057 */ 00058 virtual int32_t getIdentity(Object::View v) const; 00059 00060 /** 00061 * Register an object. 00062 * 00063 * @param v the object 00064 * 00065 * @return the assigned identity for the object 00066 * 00067 * @throws IllegalStateException if the object is already registered 00068 */ 00069 virtual int32_t registerReference(Object::View v); 00070 00071 00072 // ----- data members --------------------------------------------------- 00073 00074 protected: 00075 /** 00076 * The reference counter. 00077 */ 00078 int32_t m_cRefs; 00079 00080 /** 00081 * A map from objects that can be referenced to their Integer 00082 * identities. 00083 */ 00084 FinalHandle<IdentityHashMap> f_hMapIdentities; 00085 }; 00086 00087 COH_CLOSE_NAMESPACE3 00088 00089 #endif // COH_REFERENCE_LIBRARY_HPP 00090