1 /*
2   Copyright (c) DataStax, Inc.
3 
4   Licensed under the Apache License, Version 2.0 (the "License");
5   you may not use this file except in compliance with the License.
6   You may obtain a copy of the License at
7 
8   http://www.apache.org/licenses/LICENSE-2.0
9 
10   Unless required by applicable law or agreed to in writing, software
11   distributed under the License is distributed on an "AS IS" BASIS,
12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   See the License for the specific language governing permissions and
14   limitations under the License.
15 */
16 
17 #ifndef DATASTAX_INTERNAL_EVENT_RESPONSE_HPP
18 #define DATASTAX_INTERNAL_EVENT_RESPONSE_HPP
19 
20 #include "address.hpp"
21 #include "constants.hpp"
22 #include "response.hpp"
23 #include "scoped_ptr.hpp"
24 #include "string_ref.hpp"
25 #include "vector.hpp"
26 
27 namespace datastax { namespace internal { namespace core {
28 
29 class EventResponse : public Response {
30 public:
31   typedef SharedRefPtr<EventResponse> Ptr;
32   typedef Vector<Ptr> Vec;
33 
34   enum TopologyChange { NEW_NODE = 1, REMOVED_NODE, MOVED_NODE };
35 
36   enum StatusChange { UP = 1, DOWN };
37 
38   enum SchemaChange { CREATED = 1, UPDATED, DROPPED };
39 
40   enum SchemaChangeTarget { KEYSPACE = 1, TABLE, TYPE, FUNCTION, AGGREGATE };
41 
EventResponse()42   EventResponse()
43       : Response(CQL_OPCODE_EVENT)
44       , event_type_(0)
45       , topology_change_(0)
46       , status_change_(0)
47       , schema_change_(0)
48       , schema_change_target_(0) {}
49 
50   virtual bool decode(Decoder& decoder);
51 
event_type() const52   int event_type() const { return event_type_; }
topology_change() const53   int topology_change() const { return topology_change_; }
status_change() const54   int status_change() const { return status_change_; }
affected_node() const55   const Address& affected_node() const { return affected_node_; }
schema_change() const56   int schema_change() const { return schema_change_; }
schema_change_target() const57   int schema_change_target() const { return schema_change_target_; }
keyspace() const58   StringRef keyspace() const { return keyspace_; }
target() const59   StringRef target() const { return target_; }
arg_types() const60   const StringRefVec& arg_types() const { return arg_types_; }
61 
62 private:
63   int event_type_;
64 
65   int topology_change_;
66   int status_change_;
67   Address affected_node_;
68 
69   int schema_change_;
70   int schema_change_target_;
71   StringRef keyspace_;
72   StringRef target_;
73   StringRefVec arg_types_;
74 };
75 
76 }}} // namespace datastax::internal::core
77 
78 #endif
79