Cadabra
Computer algebra system for field theory problems
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DocumentThread.hh
Go to the documentation of this file.
1 
2 #pragma once
3 
4 #include <queue>
5 #include <mutex>
6 #include <stack>
7 
8 #include "DataCell.hh"
9 #include "tree.hh"
10 
11 namespace cadabra {
12 
13  class ActionBase;
14  class ActionAddCell;
15  class ActionPositionCursor;
16  class ActionRemoveCell;
17  class ActionSetRunStatus;
18  class ActionSplitCell;
19  class ActionInsertText;
20  class ActionEraseText;
21  class ComputeThread;
22  class GUIBase;
23 
36 
37 
39  public:
41 
45 
46  DocumentThread(const DocumentThread&)=delete;
47 
51 
53 
58 
60 
66 
67  void queue_action(std::shared_ptr<ActionBase>);
68 
70 
71  void new_document();
72 
76 
77  void load_from_string(const std::string&);
78 
80  void undo();
81 
82  friend ActionBase;
83  friend ActionAddCell;
90 
93 
94  bool is_registered() const;
95 
98 
99  void set_user_details(const std::string& name, const std::string& email, const std::string& affiliation);
100 
101  protected:
104 
110 
112 
118 
119  std::mutex stack_mutex;
120  typedef std::stack<std::shared_ptr<ActionBase> > ActionStack;
122  std::queue<std::shared_ptr<ActionBase> > pending_actions;
124 
127 
128  void process_action_queue();
129 
130 
133 
135  enum class help_t { algorithm, property, latex, none };
136  bool help_type_and_topic(const std::string& before, const std::string& after,
137  help_t& help_type, std::string& help_topic) const;
138 
139  };
140 
141 }
ActionStack undo_stack
Definition: DocumentThread.hh:121
friend ActionInsertText
Definition: DocumentThread.hh:88
ComputeThread * compute
Definition: DocumentThread.hh:103
A base class with all the logic to manipulate a Cadabra notebook document.
Definition: DocumentThread.hh:38
void new_document()
Setup an empty new document with a single Python input cell.
Definition: DocumentThread.cc:64
std::mutex stack_mutex
The action undo/redo/todo stacks and logic to execute.
Definition: DocumentThread.hh:119
std::stack< std::shared_ptr< ActionBase > > ActionStack
Definition: DocumentThread.hh:120
friend ActionBase
Definition: DocumentThread.hh:82
const char email[]
Definition: Snoop.hh:158
friend ActionSetRunStatus
Definition: DocumentThread.hh:87
friend ActionAddCell
Definition: DocumentThread.hh:83
DocumentThread(GUIBase *)
Definition: DocumentThread.cc:25
Abstract base class with methods that need to be implemented by any GUI.
Definition: GUIBase.hh:16
void queue_action(std::shared_ptr< ActionBase >)
All changes to the document should be made by submitting ActionBase derived objects to the 'queue_act...
Definition: DocumentThread.cc:136
std::queue< std::shared_ptr< ActionBase > > pending_actions
Definition: DocumentThread.hh:122
friend ActionRemoveCell
Definition: DocumentThread.hh:85
friend ActionEraseText
Definition: DocumentThread.hh:89
void load_from_string(const std::string &)
Load a new notebook from a JSON string.
Definition: DocumentThread.cc:87
friend ActionPositionCursor
Definition: DocumentThread.hh:84
void set_user_details(const std::string &name, const std::string &email, const std::string &affiliation)
Set user details which will be sent to the Cadabra log server.
Definition: DocumentThread.cc:177
void undo()
One undo step.
Definition: DocumentThread.cc:97
bool is_registered() const
Determine if a user has been registered with the Cadabra log server.
Definition: DocumentThread.cc:172
void set_compute_thread(ComputeThread *)
Let the notebook know about the ComputeThread so that it can send cells for evaluation.
Definition: DocumentThread.cc:59
tree< DataCell > DTree
Definition: DataCell.hh:106
bool registered
Configuration options read from ~/.config/cadabra.conf.
Definition: DocumentThread.hh:132
bool help_type_and_topic(const std::string &before, const std::string &after, help_t &help_type, std::string &help_topic) const
Definition: DocumentThread.cc:189
void process_action_queue()
Process the action queue.
Definition: DocumentThread.cc:143
bool disable_stacks
Definition: DocumentThread.hh:123
help_t
Help system.
Definition: DocumentThread.hh:135
DTree doc
The actual document tree.
Definition: DocumentThread.hh:111
Base class which talks to the server and sends Action objects back to the DocumentThread.
Definition: ComputeThread.hh:34
ActionStack redo_stack
Definition: DocumentThread.hh:121
GUIBase * gui
Definition: DocumentThread.hh:102
void build_visual_representation()
Ensure that the gui has an up-to-date representation of the dtree.
Definition: DocumentThread.cc:118
friend ActionSplitCell
Definition: DocumentThread.hh:86