Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/network/network_log.h @ 9549

Last change on this file since 9549 was 7954, checked in by patrick, 19 years ago

trunk: merged the network branche back to trunk.

File size: 2.4 KB
Line 
1/*!
2 * @file network_log.h
3 * @brief Definition of the NetworkLog singleton Class
4 */
5
6#ifndef _NETWORK_LOG_H
7#define _NETWORK_LOG_H
8
9#include "netdefs.h"
10#include "debug.h"
11
12#include <string>
13#include <list>
14
15#define NETWORK_LOG_BUFLEN 1024
16
17/* macro definitions */
18#define NETPRINTF(x) NETPRINTF ## x
19#define NETPRINT(x) NETPRINT ## x
20
21#define NETPRINTFn NetworkLog::getInstance()->printfn("%s:%d:", __FILE__, __LINE__); NetworkLog::getInstance()->printfn
22#define NETPRINTF0 NetworkLog::getInstance()->printf0("%s:%d:", __FILE__, __LINE__); NetworkLog::getInstance()->printf0
23#define NETPRINTF1 NetworkLog::getInstance()->printf1("(EE)::%s:%d:", __FILE__, __LINE__); NetworkLog::getInstance()->printf1
24#define NETPRINTF2 NetworkLog::getInstance()->printf2("(WW)::%s:%d:", __FILE__, __LINE__); NetworkLog::getInstance()->printf2
25#define NETPRINTF3 NetworkLog::getInstance()->printf3("(II)::%s:%d:", __FILE__, __LINE__); NetworkLog::getInstance()->printf3
26#define NETPRINTF4 NetworkLog::getInstance()->printf4("(DD)::%s:%d:", __FILE__, __LINE__); NetworkLog::getInstance()->printf4
27#define NETPRINTF5 NetworkLog::getInstance()->printf5("(VD)::%s:%d:", __FILE__, __LINE__); NetworkLog::getInstance()->printf5
28
29#define NETPRINTn NetworkLog::getInstance()->printfn
30#define NETPRINT0 NetworkLog::getInstance()->printf0
31#define NETPRINT1 NetworkLog::getInstance()->printf1
32#define NETPRINT2 NetworkLog::getInstance()->printf2
33#define NETPRINT3 NetworkLog::getInstance()->printf3
34#define NETPRINT4 NetworkLog::getInstance()->printf4
35#define NETPRINT5 NetworkLog::getInstance()->printf5
36
37//! A default singleton class.
38class NetworkLog
39{
40
41  public:
42    virtual ~NetworkLog(void);
43    /** @returns a Pointer to the only object of this Class */
44    inline static NetworkLog* getInstance(void) { if (!singletonRef) singletonRef = new NetworkLog();  return singletonRef; };
45
46    bool listen( int port );
47
48    void printfnet( );
49
50    void printfn( char * format, ... );
51    void printf0( char * format, ... );
52    void printf1( char * format, ... );
53    void printf2( char * format, ... );
54    void printf3( char * format, ... );
55    void printf4( char * format, ... );
56    void printf5( char * format, ... );
57
58  private:
59    NetworkLog();
60
61    void acceptNewConnections();
62
63    static NetworkLog* singletonRef;
64
65    TCPsocket listensock;
66    std::list<TCPsocket> sockets;
67
68    char buf[NETWORK_LOG_BUFLEN];
69};
70
71#endif /* _NETWORK_LOG_H */
Note: See TracBrowser for help on using the repository browser.