RInside Version 0.2.12
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Callbacks.h
Go to the documentation of this file.
1 // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
2 //
3 // Callbacks.h: R/C++ interface class library -- Easier R embedding into C++
4 //
5 // Copyright (C) 2010 Dirk Eddelbuettel and Romain Francois
6 //
7 // This file is part of RInside.
8 //
9 // RInside is free software: you can redistribute it and/or modify it
10 // under the terms of the GNU General Public License as published by
11 // the Free Software Foundation, either version 2 of the License, or
12 // (at your option) any later version.
13 //
14 // RInside is distributed in the hope that it will be useful, but
15 // WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with RInside. If not, see <http://www.gnu.org/licenses/>.
21 
22 #ifndef RINSIDE_CALLBACKS_H
23 #define RINSIDE_CALLBACKS_H
24 
25 #include <RInsideCommon.h>
26 
27 #ifdef RINSIDE_CALLBACKS
28 
29 class Callbacks {
30 public:
31 
32  Callbacks() : R_is_busy(false), buffer() {} ;
33  virtual ~Callbacks(){} ;
34 
35  virtual void ShowMessage(const char* message) {} ;
36  virtual void Suicide(const char* message) {};
37  virtual std::string ReadConsole( const char* prompt, bool addtohistory ) { return ""; };
38  virtual void WriteConsole( const std::string& line, int type ) {};
39  virtual void FlushConsole() {};
40  virtual void ResetConsole() {};
41  virtual void CleanerrConsole(){} ;
42  virtual void Busy( bool is_busy ) {} ;
43 
44  void Busy_( int which ) ;
45  int ReadConsole_( const char* prompt, unsigned char* buf, int len, int addtohistory ) ;
46  void WriteConsole_( const char* buf, int len, int oType ) ;
47 
48  // TODO: ShowFiles
49  // TODO: ChooseFile
50  // TODO: loadHistory
51  // TODO: SaveHistory
52 
53  virtual bool has_ShowMessage() { return false ; } ;
54  virtual bool has_Suicide() { return false ; } ;
55  virtual bool has_ReadConsole() { return false ; } ;
56  virtual bool has_WriteConsole() { return false ; } ;
57  virtual bool has_ResetConsole() { return false ; } ;
58  virtual bool has_CleanerrConsole() { return false ; } ;
59  virtual bool has_Busy() { return false ; } ;
60  virtual bool has_FlushConsole(){ return false; } ;
61 
62 private:
63  bool R_is_busy ;
64  std::string buffer ;
65 
66 } ;
67 
68 #endif
69 
70 #endif