CYCLUS
pyhooks.h
Go to the documentation of this file.
1 #ifndef CYCLUS_SRC_PYHOOKS_H_
2 #define CYCLUS_SRC_PYHOOKS_H_
3 
4 #include <string>
5 
6 #include "any.hpp"
7 
8 namespace cyclus {
9 class Agent;
10 /// Because of NumPy #7595, we can only initialize & finalize the Python
11 /// interpreter once. This variable keeps a count of how many times we have
12 /// initialized so that we can know when to really stop the interpreter.
13 /// When Python binding are not installed, this will always remain zero.
14 extern int PY_INTERP_COUNT;
15 
16 /// Whether or not the Python interpreter has been initilized.
17 extern bool PY_INTERP_INIT;
18 
19 /// Convience function for appending to import table for initialization
20 void PyAppendInitTab(void);
21 
22 /// Convience function for import initialization
23 void PyImportInit(void);
24 
25 /// Convience function for imports when Python has already been started
26 void PyImportCallInit(void);
27 
28 /// Initialize Python functionality, this is a no-op if Python was not
29 /// installed along with Cyclus. This may be called many times and safely
30 /// initializes the Python interpreter only once.
31 void PyStart(void);
32 
33 /// Closes the current Python session. This is a no-op if Python was
34 /// not installed with Cyclus. This may safely be called many times.
35 void PyStop(void);
36 
37 // Add some simple shims that attach C++ to Python C hooks
38 void EventLoop(void);
39 
40 /// Finds a Python module and returns its filename.
42 
43 /// Finds a Python module and returns an agent pointer from it.
44 Agent* MakePyAgent(std::string, std::string, void*);
45 
46 /// Initializes a Python agent fron another agent
47 void InitFromPyAgent(Agent*, Agent*, void*);
48 
49 /// Removes all Python agents from the internal cache. There is usually
50 /// no need for a user to call this.
51 void ClearPyAgentRefs(void);
52 
53 /// Removes a single Python agent from the reference cache.
54 void PyDelAgent(int);
55 
56 namespace toolkit {
57 enum TimeSeriesType : int;
58 /// Convert Python simulation string to JSON
60 
61 /// Convert JSON string to Python simulation string
63 
64 /// Calls the Python listeners
65 void PyCallListeners(std::string tsname, Agent* agent, void* cpp_ctx, int time, boost::spirit::hold_any value);
66 
67 } // ends namespace toolkit
68 } // ends namespace cyclus
69 #endif // ends CYCLUS_SRC_PYHOOKS_H_
void EventLoop(void)
Definition: pyhooks.cc:119
void PyImportInit(void)
Convience function for import initialization.
Definition: pyhooks.cc:111
std::string PyFindModule(std::string lib)
Finds a Python module and returns its filename.
Definition: pyhooks.cc:121
void ClearPyAgentRefs(void)
Removes all Python agents from the internal cache.
Definition: pyhooks.cc:127
void PyImportCallInit(void)
Convience function for imports when Python has already been started.
Definition: pyhooks.cc:113
Agent * MakePyAgent(std::string lib, std::string agent, void *ctx)
Finds a Python module and returns an agent pointer from it.
Definition: pyhooks.cc:123
void PyAppendInitTab(void)
Convience function for appending to import table for initialization.
Definition: pyhooks.cc:109
std::string JsonToPy(std::string infile)
Convert JSON string to Python simulation string.
Definition: pyhooks.cc:138
std::string PyToJson(std::string infile)
Convert Python simulation string to JSON.
Definition: pyhooks.cc:132
void PyStop(void)
Closes the current Python session.
Definition: pyhooks.cc:117
TimeSeriesType
Time series types to be used in the RecordTimeSeries() functions.
Definition: timeseries.h:24
void PyStart(void)
Initialize Python functionality, this is a no-op if Python was not installed along with Cyclus...
Definition: pyhooks.cc:115
taken directly from OsiSolverInterface.cpp on 2/17/14 from https://projects.coin-or.org/Osi/browser/trunk.
Definition: agent.cc:14
void PyDelAgent(int i)
Removes a single Python agent from the reference cache.
Definition: pyhooks.cc:129
void InitFromPyAgent(Agent *src, Agent *dst, void *ctx)
Initializes a Python agent fron another agent.
Definition: pyhooks.cc:125
void PyCallListeners(std::string tsname, Agent *agent, void *cpp_ctx, int time, boost::spirit::hold_any value)
Calls the Python listeners.
Definition: pyhooks.cc:144
bool PY_INTERP_INIT
Whether or not the Python interpreter has been initilized.
Definition: pyhooks.cc:107
int PY_INTERP_COUNT
Because of NumPy #7595, we can only initialize & finalize the Python interpreter once.
Definition: pyhooks.cc:106