File: tictactoe.idl

package info (click to toggle)
python-omniorb 3.6-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch, wheezy
  • size: 3,128 kB
  • ctags: 3,321
  • sloc: cpp: 13,969; python: 8,883; sh: 2,576; xml: 107; makefile: 95; ansic: 35
file content (98 lines) | stat: -rw-r--r-- 3,010 bytes parent folder | download | duplicates (5)
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// IDL for a rather over-engineered distributed noughts and crosses game

module TicTacToe {

  // State of a game.
  enum PlayerType { Nobody, Nought, Cross };
  typedef PlayerType GameState[3][3];

  // Forward declaration of all interfaces.
  interface GameFactory;
  interface GameIterator;
  interface Game;
  interface GameController;
  interface Player;
  interface Spectator;

  struct GameInfo {
    string name;
    Game   obj;
  };
  typedef sequence <GameInfo> GameInfoSeq;

  interface GameFactory {
    exception NameInUse {};

    Game newGame(in string name) raises (NameInUse);
    // Create a new game

    GameInfoSeq listGames(in unsigned long how_many, out GameIterator iter);
    // List the currently active games, returning a sequence with at
    // most how_many elements. If there are more active games than
    // that, the iterator is non-nil, permitting the rest of the games
    // to be retrieved.
  };

  interface GameIterator {
    GameInfoSeq next_n(in unsigned long how_many, out boolean more);
    // Return the next sequence of games, up to a maximum of
    // how_many. If more is true, there are more games to list.

    void destroy();
    // Destroy the iterator object.
  };

  interface Game {
    readonly attribute string    name;    // Name of this game.
    readonly attribute short     players; // Number of players registered.
    readonly attribute GameState state;   // Current state of the game.

    exception CannotJoin {};

    GameController joinGame(in Player p, out PlayerType t)
      raises (CannotJoin);
    // Join a new game, passing in a Player object reference. Returns
    // a GameController object reference used to play the game. The
    // out argument lets the player know whether they are noughts or
    // crosses.

    unsigned long watchGame  (in Spectator s, out GameState state);
    void          unwatchGame(in unsigned long cookie);
    // Register or unregister a spectator for the game. watchGame()
    // returns a cookie to be used to unregister. Note the potential
    // for unregistering other spectators. This should really use an
    // event or notification service.

    void kill();
    // Kill the game prematurely.
  };

  interface GameController {
    exception SquareOccupied {};
    exception InvalidCoordinates {};
    exception NotYourGo {};

    GameState play(in short x, in short y)
      raises (SquareOccupied, InvalidCoordinates, NotYourGo);
    // Place a piece at the specified coordinates. Returns the new
    // game state.
  };

  interface Player {
    void yourGo(in GameState state);
    // Tell the player it is their go, giving the current game state.

    void end(in GameState state, in PlayerType winner);
    // End of game. winner is Nobody if the game is tied.

    void gameAborted();
  };

  interface Spectator {
    void update(in GameState state);
    // Update the current state of the game.

    void end(in GameState state, in PlayerType winner);
    void gameAborted();
  };
};