PyNE C++
rxname.h
1 
3 #ifndef PYNE_7DOEB2PKSBEFFIA3Q2NARI3KFY
4 #define PYNE_7DOEB2PKSBEFFIA3Q2NARI3KFY
5 #include <utility>
6 #include <iostream>
7 #include <string>
8 #include <map>
9 #include <set>
10 #include <exception>
11 #include <stdlib.h>
12 #include <stdio.h>
13 
14 #ifndef PYNE_IS_AMALGAMATED
15 #include "utils.h"
16 #include "nucname.h"
17 #endif
18 
20 #define NUM_RX_NAMES 574
21 
22 namespace pyne
23 {
25 namespace rxname
26 {
27  extern std::string _names[NUM_RX_NAMES];
28  extern std::set<std::string> names;
31  extern std::map<unsigned int, std::string> id_name;
33  extern std::map<std::string, unsigned int> name_id;
35  extern std::map<std::string, unsigned int> altnames;
37  extern std::map<unsigned int, unsigned int> id_mt;
39  extern std::map<unsigned int, unsigned int> mt_id;
41  extern std::map<unsigned int, std::string> labels;
43  extern std::map<unsigned int, std::string> docs;
46  extern std::map<std::pair<std::string, int>, unsigned int> offset_id;
49  extern std::map<std::pair<std::string, unsigned int>, int> id_offset;
50 
52  void * _fill_maps();
53  extern void * _;
54 
56  inline int offset(int dz, int da, int ds=0) {return dz*10000000 + da*10000 + ds;}
57 
63  unsigned int hash(std::string s);
64  unsigned int hash(const char * s);
66 
78  std::string name(int n);
79  std::string name(unsigned int n);
80  std::string name(char * s);
81  std::string name(std::string s);
82  std::string name(int from_nuc, int to_nuc, std::string z="n");
83  std::string name(int from_nuc, std::string to_nuc, std::string z="n");
84  std::string name(std::string from_nuc, int to_nuc, std::string z="n");
85  std::string name(std::string from_nuc, std::string to_nuc, std::string z="n");
87 
100  unsigned int id(int x);
101  unsigned int id(unsigned int x);
102  unsigned int id(const char * x);
103  unsigned int id(std::string x);
104  unsigned int id(int from_nuc, int to_nuc, std::string z="n");
105  unsigned int id(int from_nuc, std::string to_nuc, std::string z="n");
106  unsigned int id(std::string from_nuc, int to_nuc, std::string z="n");
107  unsigned int id(std::string from_nuc, std::string to_nuc, std::string z="n");
109 
121  unsigned int mt(int x);
122  unsigned int mt(unsigned int x);
123  unsigned int mt(char * x);
124  unsigned int mt(std::string x);
125  unsigned int mt(int from_nuc, int to_nuc, std::string z="n");
126  unsigned int mt(int from_nuc, std::string to_nuc, std::string z="n");
127  unsigned int mt(std::string from_nuc, int to_nuc, std::string z="n");
128  unsigned int mt(std::string from_nuc, std::string to_nuc, std::string z="n");
130 
142  std::string label(int x);
143  std::string label(unsigned int x);
144  std::string label(char * x);
145  std::string label(std::string x);
146  std::string label(int from_nuc, int to_nuc, std::string z="n");
147  std::string label(int from_nuc, std::string to_nuc, std::string z="n");
148  std::string label(std::string from_nuc, int to_nuc, std::string z="n");
149  std::string label(std::string from_nuc, std::string to_nuc, std::string z="n");
151 
163  std::string doc(int x);
164  std::string doc(unsigned int x);
165  std::string doc(char * x);
166  std::string doc(std::string x);
167  std::string doc(int from_nuc, int to_nuc, std::string z="n");
168  std::string doc(int from_nuc, std::string to_nuc, std::string z="n");
169  std::string doc(std::string from_nuc, int to_nuc, std::string z="n");
170  std::string doc(std::string from_nuc, std::string to_nuc, std::string z="n");
172 
182  int parent(int nuc, unsigned int rx, std::string z="n");
183  int parent(int nuc, std::string rx, std::string z="n");
184  int parent(std::string nuc, unsigned int rx, std::string z="n");
185  int parent(std::string nuc, std::string rx, std::string z="n");
187 
197  int child(int nuc, unsigned int rx, std::string z="n");
198  int child(int nuc, std::string rx, std::string z="n");
199  int child(std::string nuc, unsigned int rx, std::string z="n");
200  int child(std::string nuc, std::string rx, std::string z="n");
202 
204  class NotAReaction : public std::exception
205  {
206  public:
207 
210 
212  ~NotAReaction () throw () {};
213 
216  NotAReaction(std::string wasptr, std::string nowptr)
217  {
218  rxwas = wasptr;
219  rxnow = nowptr;
220  };
221 
224  NotAReaction(std::string wasptr, int nowptr)
225  {
226  rxwas = wasptr;
227  rxnow = pyne::to_str(nowptr);
228  };
229 
232  NotAReaction(int wasptr, std::string nowptr)
233  {
234  rxwas = pyne::to_str(wasptr);
235  rxnow = nowptr;
236  };
237 
240  NotAReaction(int wasptr, int nowptr)
241  {
242  rxwas = pyne::to_str(wasptr);
243  rxnow = pyne::to_str(nowptr);
244  };
245 
248  NotAReaction(std::string wasptr, unsigned int nowptr)
249  {
250  rxwas = wasptr;
251  rxnow = pyne::to_str(nowptr);
252  };
253 
256  NotAReaction(unsigned int wasptr, std::string nowptr)
257  {
258  rxwas = pyne::to_str(wasptr);
259  rxnow = nowptr;
260  };
261 
264  NotAReaction(unsigned int wasptr, unsigned int nowptr)
265  {
266  rxwas = pyne::to_str(wasptr);
267  rxnow = pyne::to_str(nowptr);
268  };
269 
271  virtual const char* what() const throw()
272  {
273  std::string narxstr ("Not a reaction! ");
274  if (!rxwas.empty())
275  narxstr += rxwas;
276 
277  if (!rxnow.empty())
278  {
279  narxstr += " --> ";
280  narxstr += rxnow;
281  }
282  const char* narxstr_rtn = narxstr.c_str();
283  return narxstr_rtn;
284  };
285 
286  private:
287  std::string rxwas;
288  std::string rxnow;
289  };
290 
291 
292 
294  class IndeterminateReactionForm : public std::exception
295  {
296  public:
297 
300 
303 
306  IndeterminateReactionForm(std::string wasptr, std::string nowptr)
307  {
308  rxwas = wasptr;
309  rxnow = nowptr;
310  };
311 
314  IndeterminateReactionForm(std::string wasptr, int nowptr)
315  {
316  rxwas = wasptr;
317  rxnow = pyne::to_str(nowptr);
318  };
319 
322  IndeterminateReactionForm(int wasptr, std::string nowptr)
323  {
324  rxwas = pyne::to_str(wasptr);
325  rxnow = nowptr;
326  };
327 
330  IndeterminateReactionForm(int wasptr, int nowptr)
331  {
332  rxwas = pyne::to_str(wasptr);
333  rxnow = pyne::to_str(nowptr);
334  };
335 
337  virtual const char* what() const throw()
338  {
339  std::string INFEstr ("Indeterminate reaction form: ");
340  if (!rxwas.empty())
341  INFEstr += rxwas;
342 
343  if (!rxnow.empty())
344  {
345  INFEstr += " --> ";
346  INFEstr += rxnow;
347  }
348  const char* INFEstr_rtn = INFEstr.c_str();
349  return INFEstr_rtn;
350  }
351 
352  private:
353  std::string rxwas;
354  std::string rxnow;
355  };
356 }
357 }
358 
359 #endif // PYNE_7DOEB2PKSBEFFIA3Q2NARI3KFY
std::map< std::string, unsigned int > altnames
Mapping between alternative names for reactions and the reaction id.
Definition: rxname.cpp:585
std::map< unsigned int, std::string > id_name
Mapping from reaction ids to reaction names.
Definition: rxname.cpp:586
NotAReaction(std::string wasptr, unsigned int nowptr)
Definition: rxname.h:248
virtual const char * what() const
Returns a helpful error message containing prior and current reaction state.
Definition: rxname.h:271
~IndeterminateReactionForm()
default destructor
Definition: rxname.h:302
NotAReaction(std::string wasptr, int nowptr)
Definition: rxname.h:224
void * _fill_maps()
A helper function to set the contents of the variables in this library.
Definition: rxname.cpp:595
std::map< std::string, unsigned int > name_id
Mapping from reaction names to reaction ids.
Definition: rxname.cpp:587
std::map< unsigned int, unsigned int > mt_id
Mapping from MT numbers to reaction names.
Definition: rxname.cpp:589
IndeterminateReactionForm()
default constructor
Definition: rxname.h:299
~NotAReaction()
default destructor
Definition: rxname.h:212
std::map< std::pair< std::string, int >, unsigned int > offset_id
Definition: rxname.cpp:592
NotAReaction(unsigned int wasptr, unsigned int nowptr)
Definition: rxname.h:264
std::map< std::pair< std::string, unsigned int >, int > id_offset
Definition: rxname.cpp:593
IndeterminateReactionForm(int wasptr, int nowptr)
Definition: rxname.h:330
virtual const char * what() const
Returns a helpful error message containing prior and current reaction state.
Definition: rxname.h:337
Custom exception for declaring a value not to be of ambiquous reaction form.
Definition: rxname.h:294
NotAReaction()
default constructor
Definition: rxname.h:209
NotAReaction(int wasptr, std::string nowptr)
Definition: rxname.h:232
std::map< unsigned int, std::string > labels
Mapping from reaction ids to labels (short descriptions).
Definition: rxname.cpp:590
std::set< std::string > names
Set of reaction names, must be valid variable names.
std::map< unsigned int, unsigned int > id_mt
Mapping from reaction ids to MT numbers.
Definition: rxname.cpp:588
NotAReaction(std::string wasptr, std::string nowptr)
Definition: rxname.h:216
IndeterminateReactionForm(std::string wasptr, int nowptr)
Definition: rxname.h:314
IndeterminateReactionForm(int wasptr, std::string nowptr)
Definition: rxname.h:322
std::map< unsigned int, std::string > docs
Mapping from reaction ids to documentation strings (long descriptions).
Definition: rxname.cpp:591
NotAReaction(int wasptr, int nowptr)
Definition: rxname.h:240
NotAReaction(unsigned int wasptr, std::string nowptr)
Definition: rxname.h:256
IndeterminateReactionForm(std::string wasptr, std::string nowptr)
Definition: rxname.h:306
A container representing enrichment cascades.
Definition: _atomic_data.h:16
std::string _names[NUM_RX_NAMES]
Definition: rxname.cpp:5
Custom exception for declaring a value not to be a valid reaction.
Definition: rxname.h:204
int offset(int dz, int da, int ds=0)
A helper function to compute nuclide id offsets from z-, a-, and s- deltas.
Definition: rxname.h:56
void * _
A dummy variable used when calling _fill_maps().
Definition: rxname.cpp:2570