TheChess

model/Object.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_MODEL_OBJECT_HPP_
00011 #define THECHESS_MODEL_OBJECT_HPP_
00012 
00013 #include <vector>
00014 
00015 #include <Wt/Dbo/Session>
00016 #include <Wt/WDateTime>
00017 
00018 namespace dbo = Wt::Dbo;
00019 
00020 namespace thechess {
00021 namespace model {
00022 
00023 struct Object;
00024 typedef std::vector<Object> Objects;
00025 
00026 enum ObjectType {
00027     NoEvent,
00028     GameObject,
00029     UserObject,
00030     CompetitionObject
00031 }; // change Object::reread() after changing this
00032 
00033 struct Object {
00034     Object(ObjectType ot, int i);
00035 
00036     ObjectType type;
00037     int id;
00038 
00039     bool operator<(const Object& b) const {
00040         return id<b.id || (id==b.id && type<b.type);
00041     }
00042 
00043     bool operator==(const Object& b) const {
00044         return id == b.id && type == b.type;
00045     }
00046 
00047     void reread(dbo::Session& session) const;
00048     Wt::WDateTime process(Objects& objects, dbo::Session& session) const;
00049 };
00050 
00051 }
00052 }
00053 
00054 #endif
00055 
 All Classes Functions Enumerations Enumerator