CXXR (C++ R) API
ProvenanceTracker.h
Go to the documentation of this file.
1 /*CXXR $Id: ProvenanceTracker.h 1400 2013-08-30 12:50:21Z arr $
2  *CXXR
3  *CXXR This file is part of CXXR, a project to refactor the R interpreter
4  *CXXR into C++. It may consist in whole or in part of program code and
5  *CXXR documentation taken from the R project itself, incorporated into
6  *CXXR CXXR (and possibly MODIFIED) under the terms of the GNU General Public
7  *CXXR Licence.
8  *CXXR
9  *CXXR CXXR is Copyright (C) 2008-13 Andrew R. Runnalls, subject to such other
10  *CXXR copyrights and copyright restrictions as may be stated below.
11  *CXXR
12  *CXXR CXXR is not part of the R project, and bugs and other issues should
13  *CXXR not be reported via r-bugs or other R project channels; instead refer
14  *CXXR to the CXXR website.
15  *CXXR */
16 
17 /* This file incorporates material Copyright (C) Chris A. Silles 2009-12.
18  */
19 
20 /*
21  * This program is free software; you can redistribute it and/or modify
22  * it under the terms of the GNU General Public License as published by
23  * the Free Software Foundation; either version 2.1 of the License, or
24  * (at your option) any later version.
25  *
26  * This program is distributed in the hope that it will be useful,
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29  * GNU Lesser General Public License for more details.
30  *
31  * You should have received a copy of the GNU General Public License
32  * along with this program; if not, a copy is available at
33  * http://www.r-project.org/Licenses/
34  */
35 
41 #ifndef PROVENANCETRACKER_H
42 #define PROVENANCETRACKER_H
43 
44 #ifdef __cplusplus
45 
46 #include "CXXR/Frame.hpp"
47 
48 namespace CXXR {
49 
50 #ifndef PROVENANCE_TRACKING
51  // Vestigial implementation of ProvenanceTracker:
52  struct ProvenanceTracker {
53  static void flagXenogenesis()
54  {}
55  };
56 #else
57 
62  class ProvenanceTracker {
63  public:
77  class CommandScope {
78  public:
92  CommandScope(const RObject* command);
93 
94  ~CommandScope();
95 
107  void flagXenogenesis()
108  {
109  m_xenogenetic = true;
110  }
111 
121  void monitorRead(const Frame::Binding& bdg);
122 
132  void monitorWrite(const Frame::Binding& bdg);
133  private:
134  GCStackRoot<CommandChronicle> m_chronicle;
135  bool m_xenogenetic;
136  };
137 
149  static void flagXenogenesis();
150 
158  static void monitorRead(const Frame::Binding& bdg);
159 
167  static void monitorWrite(const Frame::Binding& bdg);
168 
177  static void setMonitors();
178  private:
179  static CommandScope* s_scope; // Pointer to the current scope
180  // or null if none. If scopes are nested, this points to
181  // the outermost scope.
182 
183  // Declared private to prevent instantiation of this class:
184  ProvenanceTracker();
185  };
186 #endif // PROVENANCE_TRACKING
187 } // namespace CXXR
188 
189 extern "C" {
190 #endif // __cplusplus
191 
202  void flagXenogenesis();
203 
204 #ifdef __cplusplus
205 } // extern "C"
206 #endif
207 
208 #endif // PROVENANCETRACKER_H