Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 10109 was 9869, checked in by bensch, 18 years ago

orxonox/trunk: merged the new_class_id branche back to the trunk.
merged with command:
svn merge https://svn.orxonox.net/orxonox/branches/new_class_id trunk -r9683:HEAD
no conflicts… puh..

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  public:
41    virtual ~NetworkLog(void);
42    /** @returns a Pointer to the only object of this Class */
43    inline static NetworkLog* getInstance(void) { if (!singletonRef) singletonRef = new NetworkLog();  return singletonRef; };
44
45    bool listen( int port );
46
47    void printfnet( );
48
49    void printfn( char * format, ... );
50    void printf0( char * format, ... );
51    void printf1( char * format, ... );
52    void printf2( char * format, ... );
53    void printf3( char * format, ... );
54    void printf4( char * format, ... );
55    void printf5( char * format, ... );
56
57  private:
58    NetworkLog();
59
60    void acceptNewConnections();
61
62    static NetworkLog* singletonRef;
63
64    TCPsocket listensock;
65    std::list<TCPsocket> sockets;
66
67    char buf[NETWORK_LOG_BUFLEN];
68};
69
70#endif /* _NETWORK_LOG_H */
Note: See TracBrowser for help on using the repository browser.