Oracle Coherence for C++ API
Release 3.7.1.0
E22845-01
00001 /* 00002 * VersionedPut.hpp 00003 * 00004 * Copyright (c) 2000, 2011, 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_VERSIONED_PUT_HPP 00017 #define COH_VERSIONED_PUT_HPP 00018 00019 #include "coherence/lang.ns" 00020 00021 #include "coherence/io/pof/PofReader.hpp" 00022 #include "coherence/io/pof/PofWriter.hpp" 00023 #include "coherence/io/pof/PortableObject.hpp" 00024 #include "coherence/util/InvocableMap.hpp" 00025 #include "coherence/util/Versionable.hpp" 00026 #include "coherence/util/processor/AbstractProcessor.hpp" 00027 00028 COH_OPEN_NAMESPACE3(coherence,util, processor) 00029 00030 using coherence::io::pof::PofReader; 00031 using coherence::io::pof::PofWriter; 00032 using coherence::io::pof::PortableObject; 00033 using coherence::util::InvocableMap; 00034 using coherence::util::Versionable; 00035 00036 00037 /** 00038 * VersionedPut is an EntryProcessor that assumes that entry values implement 00039 * Versionable interface and performs an InvocableMap::Entry#setValue 00040 * operation if and only if the version of the specified value matches to the 00041 * version of the current value. In case of the match, the VersionedPut will 00042 * increment the version indicator before the value is updated. 00043 * 00044 * @author tb 2008.04.28 00045 */ 00046 class COH_EXPORT VersionedPut 00047 : public class_spec<VersionedPut, 00048 extends<AbstractProcessor>, 00049 implements<PortableObject> > 00050 { 00051 friend class factory<VersionedPut>; 00052 00053 // ----- constructors --------------------------------------------------- 00054 00055 protected: 00056 /** 00057 * Construct a VersionedPut. 00058 */ 00059 VersionedPut(); 00060 00061 /** 00062 * Construct a VersionedPut that updates an entry with a new value if 00063 * and only if the version of the new value matches to the version of 00064 * the current entry's value. This processor optionally returns the 00065 * current value as a result of the invocation if it has not been 00066 * updated (the versions did not match). 00067 * 00068 * @param hValue a value to update an entry with 00069 * @param fAllowInsert specifies whether or not an insert should be 00070 * allowed (no currently existing value) 00071 * @param fReturn specifies whether or not the processor should 00072 * return the current value in case it has not 00073 * been updated 00074 */ 00075 VersionedPut(Versionable::Handle hValue, bool fAllowInsert = false, 00076 bool fReturn = false); 00077 00078 00079 // ----- InvocableMap::EntryProcessor interface ------------------------- 00080 00081 public: 00082 /** 00083 * {@inheritDoc} 00084 */ 00085 virtual Object::Holder process(InvocableMap::Entry::Handle hEntry) const; 00086 00087 /** 00088 * {@inheritDoc} 00089 */ 00090 virtual Map::View processAll(Set::View vsetEntries) const; 00091 00092 00093 // ----- PortableObject interface --------------------------------------- 00094 00095 public: 00096 /** 00097 * {@inheritDoc} 00098 */ 00099 virtual void readExternal(PofReader::Handle hIn); 00100 00101 /** 00102 * {@inheritDoc} 00103 */ 00104 virtual void writeExternal(PofWriter::Handle hOut) const; 00105 00106 00107 // ----- Object interface ----------------------------------------------- 00108 00109 public: 00110 /** 00111 * {@inheritDoc} 00112 */ 00113 virtual bool equals(Object::View v) const; 00114 00115 /** 00116 * {@inheritDoc} 00117 */ 00118 virtual size32_t hashCode() const; 00119 00120 00121 // ----- helper functions ----------------------------------------------- 00122 00123 protected: 00124 /** 00125 * Process the given entry. 00126 */ 00127 virtual Object::Holder processEntry( 00128 InvocableMap::Entry::Handle hEntry, 00129 Versionable::Holder ohValueNew, 00130 bool fInsert, 00131 bool fReturn) const; 00132 00133 00134 // ----- data members --------------------------------------------------- 00135 00136 protected: 00137 /** 00138 * Specifies the new value to update an entry with. 00139 */ 00140 mutable MemberHandle<Versionable> m_hValue; 00141 00142 /** 00143 * Specifies whether or not an insert is allowed. 00144 */ 00145 bool m_fInsert; 00146 00147 /** 00148 * Specifies whether or not a return value is required. 00149 */ 00150 bool m_fReturn; 00151 }; 00152 00153 COH_CLOSE_NAMESPACE3 00154 00155 #endif // COH_VERSIONED_PUT_HPP