GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/net/ipc.h Lines: 0 2 0.0 %
Date: 2017-11-29 Branches: 0 0 0.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2014-2017  The ManaPlus Developers
4
 *
5
 *  This file is part of The ManaPlus Client.
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License
18
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
#ifndef NET_IPC_H
22
#define NET_IPC_H
23
24
#include "localconsts.h"
25
26
PRAGMACLANG6GCC(GCC diagnostic push)
27
PRAGMACLANG6GCC(GCC diagnostic ignored "-Wold-style-cast")
28
#include "net/sdltcpnet.h"
29
PRAGMACLANG6GCC(GCC diagnostic pop)
30
31
#include "utils/vector.h"
32
33
#include <string>
34
35
class IPC final
36
{
37
    public:
38
        /**
39
         * Constructor.
40
         */
41
        IPC();
42
43
        A_DELETE_COPY(IPC)
44
45
        /**
46
         * Destructor.
47
         */
48
        ~IPC();
49
50
        bool init();
51
52
        unsigned short getPort() const A_WARN_UNUSED
53
        { return mPort; }
54
55
        void flush();
56
57
        static int acceptLoop(void *ptr);
58
59
        static void start();
60
61
        static void stop();
62
63
    private:
64
        void setPort(const unsigned short port)
65
        { mPort = port; }
66
67
        unsigned int mNumReqs;
68
        TcpNet::Socket mSocket;
69
        STD_VECTOR<std::string> mDelayedCommands;
70
        SDL_Thread *mThread;
71
        SDL_mutex *mMutex;
72
        unsigned short mPort;
73
        volatile bool mThreadLocked;
74
        bool mListen;
75
};
76
77
extern IPC *ipc;
78
79
#endif  // NET_IPC_H