00001
00025 #ifndef CORE_DB_H
00026 #define CORE_DB_H 1
00027
00028 #include <dmn/dmn.h>
00029 #include <dmn/module.h>
00030 #include <dmn/core.h>
00031 #include <dmn/tournament.h>
00032 #include <dmn/match.h>
00033 #include <dmn/game.h>
00034 #include <dmn/hand.h>
00035 #include <dmn/player.h>
00036 #include <dmn/display.h>
00037 #include <dmn/sound.h>
00038
00039 namespace dmn
00040 {
00046 class Team: public Module
00047 {
00048 };
00049
00055 class Couple: public Module
00056 {
00057 };
00058
00059
00063 class DBTournament
00064 {
00065 private:
00066 Tournament* module_;
00067
00068 std::list<ID> matches_;
00069 std::list<ID> teams_;
00070 std::list<ID> displays_;
00071
00072 public:
00078 DBTournament(Tournament* module);
00079
00080 Tournament* module() const;
00081 void matches(std::list<ID>* matches) const;
00082 void teams(std::list<ID>* teams) const;
00083 void displays(std::list<ID>* displays) const;
00084 bool insert_match(ID match);
00085 bool insert_team(ID team);
00086 bool insert_display(ID display);
00087 bool delete_match(ID match);
00088 bool delete_team(ID team);
00089 bool delete_display(ID display);
00090 };
00091
00095 class DBMatch
00096 {
00097 private:
00098 Match* module_;
00099 ID tournament_;
00100
00101 std::list<ID> games_;
00102 std::list<ID> couples_;
00103 std::list<ID> displays_;
00104
00105 public:
00112 DBMatch(Match* module, ID tournament);
00113
00114 Match* module() const;
00115 ID tournament() const;
00116 void games(std::list<ID>* games) const;
00117 void couples(std::list<ID>* couples) const;
00118 void displays(std::list<ID>* couples) const;
00119 bool insert_game(ID game);
00120 bool insert_couple(ID couple);
00121 bool insert_display(ID display);
00122 bool delete_game(ID game);
00123 bool delete_couple(ID couple);
00124 bool delete_display(ID display);
00125 };
00126
00130 class DBGame
00131 {
00132 private:
00133 Game* module_;
00134 ID match_;
00135
00136 std::list<ID> hands_;
00137 std::list<ID> couples_;
00138 std::list<ID> displays_;
00139
00140 public:
00147 DBGame(Game* module, ID match);
00148
00149 Game* module() const;
00150 ID match() const;
00151 void hands(std::list<ID>* hands) const;
00152 void couples(std::list<ID>* couples) const;
00153 void displays(std::list<ID>* displays) const;
00154 bool insert_hand(ID hand);
00155 bool insert_couple(ID couple);
00156 bool insert_display(ID display);
00157 bool delete_hand(ID hand);
00158 bool delete_couple(ID couple);
00159 bool delete_display(ID display);
00160 };
00161
00165 class DBHand
00166 {
00167 private:
00168 Hand* module_;
00169 ID game_;
00170
00171 std::list<ID> players_;
00172 std::list<ID> displays_;
00173 std::list<ID> sounds_;
00174
00175 public:
00182 DBHand(Hand* module, ID game);
00183
00184 Hand* module() const;
00185 ID game() const;
00186 void players(std::list<ID>* players) const;
00187 void displays(std::list<ID>* displays) const;
00188 void sounds(std::list<ID>* sounds) const;
00189 bool insert_player(ID player);
00190 bool insert_display(ID display);
00191 bool insert_sound(ID sound);
00192 bool delete_player(ID player);
00193 bool delete_display(ID display);
00194 bool delete_sound(ID sound);
00195 };
00196
00200 class DBTeam
00201 {
00202 private:
00203 Team* module_;
00204
00205 ID tournament_;
00206 std::list<ID> couples_;
00207
00208 public:
00214 DBTeam(Team* module);
00215
00216 Team* module() const;
00217 ID tournament() const;
00218 void set_tournament(ID tournament);
00219 void couples(std::list<ID>* couples) const;
00220 bool insert_couple(ID couple);
00221 bool delete_couple(ID couple);
00222 };
00223
00227 class DBCouple
00228 {
00229 private:
00230 Couple* module_;
00231 ID team_;
00232
00233 ID match_;
00234 ID game_;
00235 std::list<ID> players_;
00236
00237 public:
00244 DBCouple(Couple* module, ID team);
00245
00246 Couple* module() const;
00247 ID team() const;
00248 ID match() const;
00249 void set_match(ID match);
00250 ID game() const;
00251 void set_game(ID game);
00252 void players(std::list<ID>* players) const;
00253 bool insert_player(ID player);
00254 bool delete_player(ID player);
00255 };
00256
00260 class DBPlayer
00261 {
00262 private:
00263 Player* module_;
00264 ID couple_;
00265
00266 ID hand_;
00267
00268 public:
00275 DBPlayer(Player* module, ID couple);
00276
00277 Player* module() const;
00278 ID couple() const;
00279 ID hand() const;
00280 void set_hand(ID hand);
00281 };
00282
00286 class DBDisplay
00287 {
00288 private:
00289 Display* module_;
00290
00291 ID tournament_;
00292 ID match_;
00293 ID game_;
00294 ID hand_;
00295
00296 public:
00302 DBDisplay(Display* module);
00303
00304 Display* module() const;
00305 ID tournament() const;
00306 void set_tournament(ID tournament);
00307 ID match() const;
00308 void set_match(ID match);
00309 ID game() const;
00310 void set_game(ID game);
00311 ID hand() const;
00312 void set_hand(ID hand);
00313 };
00314
00318 class DBSound
00319 {
00320 private:
00321 Sound* module_;
00322
00323 ID hand_;
00324
00325 public:
00331 DBSound(Sound* module);
00332
00333 Sound* module() const;
00334 ID hand() const;
00335 void set_hand(ID hand);
00336 };
00337
00343 class DB: public Core
00344 {
00345 private:
00346 std::list<DBTournament> Tournaments_;
00347 std::list<DBMatch> Matches_;
00348 std::list<DBGame> Games_;
00349 std::list<DBHand> Hands_;
00350 std::list<DBTeam> Teams_;
00351 std::list<DBCouple> Couples_;
00352 std::list<DBPlayer> Players_;
00353 std::list<DBDisplay> Displays_;
00354 std::list<DBSound> Sounds_;
00355
00356 DBTournament* search_tournament(ID tournament);
00357 DBMatch* search_match(ID match);
00358 DBGame* search_game(ID game);
00359 DBHand* search_hand(ID hand);
00360 DBTeam* search_team(ID team);
00361 DBCouple* search_couple(ID couple);
00362 DBPlayer* search_player(ID player);
00363 DBDisplay* search_display(ID display);
00364 DBSound* search_sound(ID sound);
00365
00366 protected:
00367 Tournament* tournament(ID tournament);
00368 Match* match(ID match);
00369 Game* game(ID game);
00370 Hand* hand(ID hand);
00371 Player* player(ID player);
00372 Display* display(ID display);
00373 Sound* sound(ID sound);
00374
00375 bool new_tournament(Tournament* module);
00376 bool new_match(Match* module, ID tournament);
00377 bool new_game(Game* module, ID match);
00378 bool new_hand(Hand* module, ID game);
00379 bool new_team(Team* module);
00380 bool new_couple(Couple* module, ID team);
00381 bool new_player(Player* module, ID couple);
00382 bool new_display(Display* module);
00383 bool new_sound(Sound* module);
00384
00385 bool delete_tournament(ID tournament);
00386 bool delete_match(ID match);
00387 bool delete_game(ID game);
00388 bool delete_hand(ID hand);
00389 bool delete_team(ID team);
00390 bool delete_couple(ID couple);
00391 bool delete_player(ID player);
00392 bool delete_display(ID display);
00393 bool delete_sound(ID sound);
00394
00395 bool insert_team_in_tournament(ID team, ID tournament);
00396 bool insert_display_in_tournament(ID display, ID tournament);
00397 bool insert_couple_in_match(ID couple, ID match);
00398 bool insert_display_in_match(ID display, ID match);
00399 bool insert_couple_in_game(ID couple, ID game);
00400 bool insert_display_in_game(ID display, ID game);
00401 bool insert_player_in_hand(ID player, ID hand);
00402 bool insert_display_in_hand(ID display, ID hand);
00403 bool insert_sound_in_hand(ID sound, ID hand);
00404
00405 bool delete_team_from_tournament(ID team, ID tournament);
00406 bool delete_display_from_tournament(ID display, ID tournament);
00407 bool delete_couple_from_match(ID couple, ID match);
00408 bool delete_display_from_match(ID display, ID match);
00409 bool delete_couple_from_game(ID couple, ID game);
00410 bool delete_display_from_game(ID display, ID game);
00411 bool delete_player_from_hand(ID player, ID hand);
00412 bool delete_display_from_hand(ID display, ID hand);
00413 bool delete_sound_from_hand(ID sound, ID hand);
00414
00415 bool teams(std::list<ID>* teams);
00416
00417 public:
00418 bool tournaments(std::list<ID>* tournaments);
00419 bool matches_in_tournament(ID tournament, std::list<ID>* matches);
00420 ID tournament_of_match(ID match);
00421 bool teams_in_tournament(ID tournament, std::list<ID>* teams);
00422 ID tournament_of_team(ID team);
00423 bool displays_in_tournament(ID tournament, std::list<ID>* displays);
00424 ID tournament_of_display(ID display);
00425 bool games_in_match(ID match, std::list<ID>* games);
00426 ID match_of_game(ID game);
00427 bool couples_in_match(ID match, std::list<ID>* couples);
00428 ID match_of_couple(ID couple);
00429 bool displays_in_match(ID match, std::list<ID>* displays);
00430 ID match_of_display(ID display);
00431 bool hands_in_game(ID game, std::list<ID>* hands);
00432 ID game_of_hand(ID hand);
00433 bool couples_in_game(ID game, std::list<ID>* couples);
00434 ID game_of_couple(ID couple);
00435 bool displays_in_game(ID game, std::list<ID>* displays);
00436 ID game_of_display(ID display);
00437 bool players_in_hand(ID hand, std::list<ID>* players);
00438 ID hand_of_player(ID player);
00439 bool displays_in_hand(ID hand, std::list<ID>* displays);
00440 ID hand_of_display(ID display);
00441 bool sounds_in_hand(ID hand, std::list<ID>* sound);
00442 ID hand_of_sound(ID sound);
00443 bool couples_in_team(ID team, std::list<ID>* couples);
00444 ID team_of_couple(ID couple);
00445 bool players_in_couple(ID couple, std::list<ID>* players);
00446 ID couple_of_player(ID player);
00447 };
00448 };
00449
00450 #endif // CORE_DB_H