All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Client.h
1 /*
2  Copyright (c) 2014 by Elvis Angelaccio
3 
4  Permission is hereby granted, free of charge, to any person obtaining a copy
5  of this software and associated documentation files (the "Software"), to deal
6  in the Software without restriction, including without limitation the rights
7  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  copies of the Software, and to permit persons to whom the Software is
9  furnished to do so, subject to the following conditions:
10 
11  The above copyright notice and this permission notice shall be included in
12  all copies or substantial portions of the Software.
13 
14  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  THE SOFTWARE.
21 */
22 
23 #ifndef CLIENT_H
24 #define CLIENT_H
25 
26 #include <string>
27 #include <map>
28 
29 #include "simdb.h"
30 #include "../net/net.h"
31 #include "../net/client_protocol.h"
32 
33 namespace simdb
34 {
35 
40  class Client
41  {
42 
43  public:
44 
45  Client();
46 
54  bool insertDataSet(const std::string& dssName, std::map<std::string, std::string>& sdFields, const std::map<std::string, std::string>& dataItems);
55 
62  bool removeDataSet(const std::string& sequenceNumber, const std::string& dssName);
63 
70  bool getDataSet(const std::string& sequenceNumber, const std::string& dssName);
71 
78  bool searchDataSet(const std::string& dssName, std::map<std::string, std::string>& sdQueryFields);
79 
84  bool listDss();
85 
91  bool sendExtendedCommand(const std::string& command);
92 
93 
98  void setServerAddress(const std::string& address);
99 
106  bool setServerPort(const std::string& port);
107 
113  void setDataDirectory(const std::string& dataDir);
114 
115  private:
116 
117  static const net::Port DEFAULT_PORT = 4444;
118 
119  std::string serverAddress;
120  net::Port serverPort;
121  std::string dataDirectory;
122  net::ProtocolHandler protocolHandler;
123 
124 
125  bool insertDataSet(const std::string& message, const std::map<std::string, std::string>& dataItems);
126  bool removeDataSet(const std::string& command);
127  bool getDataSet(const std::string& command);
128  bool searchDataSet(const std::string& message);
129 
131  void printInitialMessage();
132  };
133 }
134 
135 
136 
137 
138 
139 #endif
bool setServerPort(const std::string &port)
Definition: Client.cpp:211
API for external clients. This class provides a client-side API for the SimDB system. It provides functions that a generic C++ program can use to comunicate as a client with a SimDB server.
Definition: Client.h:40
bool searchDataSet(const std::string &dssName, std::map< std::string, std::string > &sdQueryFields)
Definition: Client.h:33
void setServerAddress(const std::string &address)
Definition: Client.cpp:205
bool removeDataSet(const std::string &sequenceNumber, const std::string &dssName)
Convenience class to simplify the protocol messages handling. This class is useful to parse the "raw"...
Definition: client_protocol.h:157
bool getDataSet(const std::string &sequenceNumber, const std::string &dssName)
bool listDss()
Definition: Client.cpp:116
bool sendExtendedCommand(const std::string &command)
Definition: Client.cpp:150
bool insertDataSet(const std::string &dssName, std::map< std::string, std::string > &sdFields, const std::map< std::string, std::string > &dataItems)
void setDataDirectory(const std::string &dataDir)
Definition: Client.cpp:224