Line data Source code
1 :
2 : /* Copyright (c) 2010-2013, Stefan Eilemann <eile@eyescale.ch>
3 : *
4 : * This library is free software; you can redistribute it and/or modify it under
5 : * the terms of the GNU Lesser General Public License version 2.1 as published
6 : * by the Free Software Foundation.
7 : *
8 : * This library is distributed in the hope that it will be useful, but WITHOUT
9 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 : * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11 : * details.
12 : *
13 : * You should have received a copy of the GNU Lesser General Public License
14 : * along with this library; if not, write to the Free Software Foundation, Inc.,
15 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 : */
17 :
18 : #ifndef EQSERVER_STATE_H
19 : #define EQSERVER_STATE_H
20 :
21 : #include <lunchbox/log.h>
22 : #include <lunchbox/types.h>
23 :
24 : namespace eq
25 : {
26 : namespace server
27 : {
28 : /**
29 : * Running state of a resource entity.
30 : * <img
31 : * src="http://www.equalizergraphics.com/documents/design/images/serverState.png">
32 : */
33 : enum State
34 : {
35 : STATE_UNUSED = LB_BIT1, //!< next: STOPPED
36 : STATE_STOPPED = LB_BIT2, //!< next: INITIALIZING or UNUSED
37 : STATE_INITIALIZING = LB_BIT3, //!< next: INIT_FAILED or INIT_SUCCESS
38 : STATE_INIT_SUCCESS = LB_BIT4, //!< next: RUNNING
39 : STATE_INIT_FAILED = LB_BIT5, //!< next: EXITING
40 : STATE_RUNNING = LB_BIT6, //!< next: EXITING
41 : STATE_EXITING = LB_BIT7, //!< next: EXIT_FAILED or EXIT_SUCCESS
42 : STATE_EXIT_SUCCESS = LB_BIT8, //!< next: STOPPED or FAILED
43 : STATE_EXIT_FAILED = LB_BIT9, //!< next: STOPPED or FAILED
44 : STATE_FAILED = LB_BIT10, //!< next: STOPPED
45 : STATE_DELETE = LB_BIT16 //!< additional modifier
46 : };
47 :
48 0 : inline std::ostream& operator<<(std::ostream& os, const State& state)
49 : {
50 0 : if (state & STATE_UNUSED)
51 0 : os << "unused";
52 0 : if (state & STATE_STOPPED)
53 0 : os << "stopped";
54 0 : if (state & STATE_INITIALIZING)
55 0 : os << "initializing";
56 0 : if (state & STATE_INIT_SUCCESS)
57 0 : os << "init successful";
58 0 : if (state & STATE_INIT_FAILED)
59 0 : os << "failed";
60 0 : if (state & STATE_RUNNING)
61 0 : os << "running";
62 0 : if (state & STATE_EXITING)
63 0 : os << "exiting";
64 0 : if (state & STATE_EXIT_SUCCESS)
65 0 : os << "exit successful";
66 0 : if (state & STATE_EXIT_FAILED)
67 0 : os << "exit failed";
68 0 : if (state & STATE_FAILED)
69 0 : os << "failed";
70 0 : if (state & STATE_DELETE)
71 0 : os << "scheduled for deletion";
72 :
73 0 : return os;
74 : }
75 : }
76 : }
77 : #endif // EQ_STATE_H
|