Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: experimental/c_salt/notification.h

Issue 10928195: First round of dead file removal (Closed) Base URL: https://github.com/samclegg/nativeclient-sdk.git@master
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « experimental/c_salt/module.cc ('k') | experimental/c_salt/notification_center.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2010 The Ginsu Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can
3 // be found in the LICENSE file.
4
5 #ifndef C_SALT_NOTIFICATION_H_
6 #define C_SALT_NOTIFICATION_H_
7
8 #include <map>
9 #include <string>
10
11 #include "boost/any.hpp"
12 #include "boost/shared_ptr.hpp"
13
14 namespace c_salt {
15
16 // A Notification encapsulates information so that it can be sent to observers
17 // by the NotificationCenter. A Notification holds a name, a reference to the
18 // payload and the publisher name. The payload is copied in the accessor. Note
19 // that the payload data object has to implement a thread-safe copy ctor.
20 class Notification {
21 public:
22 typedef boost::any NotificationValue;
23 typedef boost::shared_ptr<NotificationValue> SharedNotificationValue;
24
25 // Creates a Notification with an empty payload and an anonymous publisher.
26 explicit Notification(const std::string& name)
27 : name_(name),
28 data_(new NotificationValue()),
29 publisher_name_("") {}
30
31 // Create a Notification with |data| as the payload and |publisher_name| as
32 // the named publisher (set this to the empty string for the anonynmous
33 // publisher). This copies |data| into local storage.
34 // Note: DataType must implement a thread-safe copy ctor. For example, an
35 // object that has STL containers in it might want to implement a deep-copy
36 // in the copy ctor.
37 Notification(const std::string& name,
38 SharedNotificationValue data,
39 const std::string& publisher_name)
40 : name_(name),
41 data_(data),
42 publisher_name_(publisher_name) {}
43
44 virtual ~Notification() {}
45
46 const std::string& name() const {
47 return name_;
48 }
49
50 // Return a copy of the internal payload. This copy is made here so that no
51 // other copies are needed when publishing this Notification.
52 SharedNotificationValue data() const {
53 return SharedNotificationValue(new NotificationValue(*data_));
54 }
55 void set_data(SharedNotificationValue data) {
56 data_ = data;
57 }
58
59 const std::string& publisher_name() const {
60 return publisher_name_;
61 }
62 void set_publisher_name(const std::string& publisher_name) {
63 publisher_name_ = publisher_name;
64 }
65
66 private:
67 std::string name_;
68 SharedNotificationValue data_;
69 std::string publisher_name_;
70
71 Notification(); // Not implemented, do not use.
72 };
73 } // namespace c_salt
74 #endif // C_SALT_NOTIFICATION_H_
OLDNEW
« no previous file with comments | « experimental/c_salt/module.cc ('k') | experimental/c_salt/notification_center.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698