Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/chat/src/orxonox/ChatHistory.h @ 6688

Last change on this file since 6688 was 6688, checked in by smerkli, 15 years ago

Completed and tested the code as far as I could, now preparing questions.

  • Property svn:eol-style set to native
File size: 3.2 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Sandro 'smerkli' Merkli
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include <deque>
30#include <string>
31#include <fstream>
32#include <iostream>
33
34#define TEST 0
35
36#ifndef TEST
37#include <core/BaseObject.h>
38#endif
39
40#ifndef _ChatHistory_H__
41#define _ChatHistory_H__
42
43
44/* Class to implement chat history */
45#ifndef TEST
46namespace orxonox
47{
48#endif
49
50  /* constructor */
51  #ifndef TEST
52  class _OrxonoxExport ChatHistory : public BaseObject, public ChatListener
53  #else
54  class ChatHistory
55  #endif
56  {
57    public:
58      /* constructors, destructors */
59      #ifndef TEST
60      ChatHistory(BaseObject* creator);
61      #else
62      ChatHistory();
63      #endif
64      virtual ~ChatHistory();
65
66 
67    //protected:
68      /** what to do with incoming chat
69       *
70       * \param message The incoming message
71       * \param senderID Identification number of the sender
72       */
73      virtual void incomingChat(const std::string& message, 
74        unsigned int senderID);
75     
76      /** Synchronize logfile onto the hard drive
77       *
78       * \return 0 for success, other for error
79       */
80      int syncLog();
81
82      /** debug-print */
83      void debug_printhist();
84     
85    private:
86      /* FIELDS */
87      /** Vector to store the history in */
88      std::deque<std::string> hist_buffer;
89
90      /** Maximum number of lines stored in this history */
91      unsigned int hist_maxlines;
92
93      /** is logging enabled? */
94      bool hist_log_enabled;
95
96      /** path of logfile on the file system */
97      std::string hist_logfile_path;
98
99      /** Output file stream for logfile */
100      std::ofstream hist_logfile;
101
102
103
104
105      /* METHODS */
106      /** Append line to chat history
107       *
108       * \param toadd The line to add to the history
109       * \return 0 for success, other for error TODO: Throw exception
110       */
111      int chat_hist_addline( const std::string& toadd );
112
113      /** Append line to logfile
114       *
115       * \param toadd The line to add to the logfile
116       * \return 0 for success, other for error TODO: Throw exception
117       */
118      int chat_hist_logline( const std::string& toadd );
119
120      /** open logfile to log to
121       *
122       * \return 0 for success,s other for error
123       */
124      int chat_hist_openlog();
125
126
127      /** close logfile */
128      void chat_hist_closelog();
129  };
130
131#ifndef TEST
132}
133#endif
134
135
136#endif /* _ChatHistory_H__ */
Note: See TracBrowser for help on using the repository browser.