SST  11.0.0
StructuralSimulationToolkit
pymodel_stat.h
1 // -*- c++ -*-
2 
3 // Copyright 2009-2020 NTESS. Under the terms
4 // of Contract DE-NA0003525 with NTESS, the U.S.
5 // Government retains certain rights in this software.
6 //
7 // Copyright (c) 2009-2020, NTESS
8 // All rights reserved.
9 //
10 // This file is part of the SST software package. For license
11 // information, see the LICENSE file in the top level directory of the
12 // distribution.
13 
14 #ifndef SST_CORE_MODEL_PYMODEL_STAT_H
15 #define SST_CORE_MODEL_PYMODEL_STAT_H
16 
17 #include "sst/core/sst_types.h"
18 
19 namespace SST {
20 
21 extern "C" {
22 
23 struct StatisticPy_t;
24 struct PyStatistic;
25 
26 struct PyStatistic {
27  StatisticId_t id;
28 
29  PyStatistic(StatisticId_t id) : id(id) {}
30  virtual ~PyStatistic() {}
31  ConfigStatistic* getStat();
32  int compare(PyStatistic* other);
33  StatisticId_t getID();
34 };
35 
36 struct StatisticPy_t {
37  PyObject_HEAD PyStatistic* obj;
38 };
39 
40 extern PyTypeObject PyModel_StatType;
41 
42 static inline ConfigStatistic*
43 getStat(PyObject* pobj) {
44  ConfigStatistic* c = ((StatisticPy_t*)pobj)->obj->getStat();
45  if (c == nullptr) {
46  PyErr_SetString(PyExc_RuntimeError, "Failed to find ConfigStatistic");
47  }
48  return c;
49 }
50 
51 } /* extern C */
52 
53 } // namespace SST
54 
55 #endif
Definition: configGraph.h:127
Definition: pymodel_stat.h:36
Definition: pymodel_stat.h:26