00001 /******************************************************************************* 00002 Copyright (c) 2011, Yahoo! Inc. 00003 All rights reserved. 00004 00005 Redistribution and use of this software in source and binary forms, 00006 with or without modification, are permitted provided that the following 00007 conditions are met: 00008 00009 * Redistributions of source code must retain the above 00010 copyright notice, this list of conditions and the 00011 following disclaimer. 00012 00013 * Redistributions in binary form must reproduce the above 00014 copyright notice, this list of conditions and the 00015 following disclaimer in the documentation and/or other 00016 materials provided with the distribution. 00017 00018 * Neither the name of Yahoo! Inc. nor the names of its 00019 contributors may be used to endorse or promote products 00020 derived from this software without specific prior 00021 written permission of Yahoo! Inc. 00022 00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 00024 IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 00025 TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 00026 PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00027 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00028 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00029 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00030 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00031 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00032 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 00035 The Initial Developer of the Original Code is Shravan Narayanamurthy. 00036 ******************************************************************************/ 00037 /* 00038 * Client.h 00039 * 00040 * 00041 * 00042 * Created on: 07-Jan-2011 00043 * 00044 */ 00045 00046 #ifndef CLIENT_H_ 00047 #define CLIENT_H_ 00048 00049 #include <string> 00050 00051 using namespace std; 00052 00053 /** 00054 * The interface to be implemented by any client for the 00055 * Distributed Map service 00056 */ 00057 class Client { 00058 public: 00059 //!Gets the serialized val stored for the key in 00060 //!the Distributed Map. Returns true if key exists 00061 //!and false otherwise 00062 virtual bool get(const string& key, string& val) = 0; 00063 00064 //!Sets val as the serialized value for the key in 00065 //!the Distributed Map. This has replace semantics 00066 virtual void set(const string& key, const string& val) = 0; 00067 00068 //!Adds delta to the serialized value for the key in 00069 //!the Distributed Map. This has accumulator semantics. 00070 //!The accumulator logic is provided by the Server_Helper. 00071 virtual void put(const string& key, const string& delta) = 0; 00072 00073 //!Asynchronous put and get operation. It begins with 00074 //!a put. The call back in Synchronizer_Helper is called 00075 //!which creates the effect of a get 00076 virtual void begin_putNget(const string& key, const string& val) = 0; 00077 00078 //!Remove the key from the Distributed Map returning 00079 //!the serialized value stored as val. Returns true if key exists 00080 //!and false otherwise 00081 virtual bool remove(const string& key, string& val) = 0; 00082 00083 //!Provides barrier functionality 00084 virtual void wait_for_all() = 0; 00085 00086 //!Provides functionality to wait for any asynchronous communication 00087 //!to end 00088 virtual void wait_till_done() = 0; 00089 }; 00090 00091 #endif /* CLIENT_H_ */