Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/network/src/lib/network/network_log.h @ 7755

Last change on this file since 7755 was 7755, checked in by rennerc, 18 years ago

NetworkLog: added NETPRINT() macros

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