-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSubscription.cpp
62 lines (49 loc) · 1.34 KB
/
Subscription.cpp
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
// Copyright 2006-12 HumaNature Studios Inc.
#include "LoggingPch.h"
namespace core {
Subscription::Subscription()
: mIsSubscribedToAll(false)
{
}
void Subscription::SubscribeTo(const CompactStringRelease& categoryName)
{
mSubscriptionMap[categoryName] = true;
}
void Subscription::SubscribeToAll()
{
mIsSubscribedToAll = true;
}
void Subscription::UnsubscribeFrom(const CompactStringRelease& categoryName)
{
mSubscriptionMap[categoryName] = false;
}
bool Subscription::IsSubscribedTo(const CompactStringRelease& categoryName)
{
bool isSubscribed = false;
if(mIsSubscribedToAll)
{
isSubscribed = true;
}
else
{
SubscriptionMap::iterator i = mSubscriptionMap.find(categoryName);
if(i == mSubscriptionMap.end())
{
isSubscribed = false;
}
else
{
isSubscribed = i->second;
}
}
return isSubscribed;
}
void Subscription::ToggleCategory(const CompactStringRelease& categoryName)
{
SubscriptionMap::iterator i = mSubscriptionMap.find(categoryName);
if(i != mSubscriptionMap.end())
{
i->second = !i->second;
}
}
} // namespace core