about summary refs log tree commit diff stats
path: root/src/notification.h
blob: a6dd6f42deeeea130beb29a3ef05a062920b2f3e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#ifndef NOTIFICATION_H_69AEF4CC
#define NOTIFICATION_H_69AEF4CC

#include <string>
#include <vector>
#include <set>
#include "tweet.h"
#include "user.h"
#include "list.h"
#include "direct_message.h"

namespace twitter {
  
  class client;
  
  enum class disconnect_code
  {
    shutdown,
    duplicate,
    stall,
    normal,
    token_revoked,
    admin_logout,
    limit,
    exception,
    broker,
    load,
    unknown
  };
  
  class notification {
  public:
    enum class type {
      // Tweet object
      tweet,
      
      // User object
      update_user,
      block,
      unblock,
      follow,
      followed,
      unfollow,
      
      // User and tweet
      favorite,
      favorited,
      unfavorite,
      unfavorited,
      quoted,
      
      // List
      list_created,
      list_destroyed,
      list_updated,
      
      // User and list
      list_add,
      list_added,
      list_remove,
      list_removed,
      list_subscribe,
      list_subscribed,
      list_unsubscribe,
      list_unsubscribed,
      
      // Warning
      stall,
      follow_limit,
      unknown_warning,
      
      // User ID and tweet ID
      deletion,
      scrub_location,
      
      // Special
      limit,
      withhold_status,
      withhold_user,
      disconnect,
      friends,
      direct,
      
      // Nothing
      unknown,
      invalid
    };
    
    type getType() const;
    
    notification() {}
    notification(const client& tclient, std::string data);
    
    notification(const notification& other);
    notification(notification&& other);
    notification& operator=(notification other);
    ~notification();
    
    friend void swap(notification& first, notification& second);
    
    const tweet& getTweet() const;
    tweet& getTweet()
    {
      return const_cast<tweet&>(static_cast<const notification&>(*this).getTweet());
    }
    
    const user& getUser() const;
    user& getUser()
    {
      return const_cast<user&>(static_cast<const notification&>(*this).getUser());
    }
    
    const list& getList() const;
    list& getList()
    {
      return const_cast<list&>(static_cast<const notification&>(*this).getList());
    }
    
    tweet_id getTweetID() const;
    void setTweetID(tweet_id _arg);
    
    user_id getUserID() const;
    void setUserID(user_id _arg);
    
    const std::vector<std::string>& getCountries() const;
    std::vector<std::string>& getCountries()
    {
      return const_cast<std::vector<std::string>&>(static_cast<const notification&>(*this).getCountries());
    }
    
    disconnect_code getDisconnectCode() const;
    void setDisconnectCode(disconnect_code _arg);
    
    const std::set<user_id>& getFriends() const;
    std::set<user_id>& getFriends()
    {
      return const_cast<std::set<user_id>&>(static_cast<const notification&>(*this).getFriends());
    }
    
    const direct_message& getDirectMessage() const;
    direct_message& getDirectMessage()
    {
      return const_cast<direct_message&>(static_cast<const notification&>(*this).getDirectMessage());
    }
    
    int getLimit() const;
    void setLimit(int _arg);
    
    const std::string& getWarning() const;
    std::string& getWarning()
    {
      return const_cast<std::string&>(static_cast<const notification&>(*this).getWarning());
    }
    
  private:
    union {
      tweet _tweet;
      user _user;
      list _list;
      struct {
        user _user;
        tweet _tweet;
      } _user_and_tweet;
      struct {
        user _user;
        list _list;
      } _user_and_list;
      std::string _warning;
      struct {
        user_id _user_id;
        tweet_id _tweet_id;
      } _user_id_and_tweet_id;
      int _limit;
      struct {
        user_id _user_id;
        tweet_id _tweet_id;
        std::vector<std::string> _countries;
      } _withhold_status;
      struct {
        user_id _user_id;
        std::vector<std::string> _countries;
      } _withhold_user;
      disconnect_code _disconnect;
      std::set<user_id> _friends;
      direct_message _direct_message;
    };
    type _type = type::invalid;
  };
  
};

#endif /* end of include guard: NOTIFICATION_H_69AEF4CC */