TheChess

ThechessNotifier.hpp

00001 /*
00002  * thechess, chess game web application written in C++ and based on Wt
00003  * Copyright (C) 2010 Boris Nagaev
00004  *
00005  * thechess is licensed under the GNU GPL Version 2.
00006  * Other versions of the GPL do not apply.
00007  * See the LICENSE file for terms of use.
00008  */
00009 
00010 #ifndef THECHESS_NOTIFIER_HPP_
00011 #define THECHESS_NOTIFIER_HPP_
00012 
00013 #include <map>
00014 #include <set>
00015 #include <boost/thread/mutex.hpp>
00016 
00017 #include "model/Object.hpp"
00018 
00019 namespace thechess {
00020 
00021 class ThechessServer;
00022 
00023 class ThechessNotifier {
00024 public:
00025     ThechessNotifier(ThechessServer& server);
00026 
00027     void start_listenning(const model::Object& object); // by ThechessApplication
00028     void stop_listenning(const model::Object& object); // by ThechessApplication
00029 
00030     // after successful transaction.commit()
00031     void emit(const model::Object& object,
00032               const std::string& this_app=""); // not from WApplication
00033     static void app_emit(const model::Object& object); // from WApplication
00034 
00035 private:
00036     ThechessServer& server_;
00037     typedef std::set<std::string> IdSet;
00038     typedef std::map<model::Object, IdSet*> O2I;
00039     O2I object2ids_;
00040     boost::mutex mutex_;
00041 };
00042 
00043 }
00044 
00045 #endif
00046 
 All Classes Functions Enumerations Enumerator