SST  15.1.0
StructuralSimulationToolkit
pymodel_stat.h
1 // -*- c++ -*-
2 
3 // Copyright 2009-2025 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-2025, 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_PYTHON_PYMODEL_STAT_H
15 #define SST_CORE_MODEL_PYTHON_PYMODEL_STAT_H
16 
17 #include "sst/core/sst_types.h"
18 #include "sst/core/warnmacros.h"
19 
20 DISABLE_WARN_DEPRECATED_REGISTER
21 #include <Python.h>
22 REENABLE_WARNING
23 
24 namespace SST {
25 class ConfigStatistic;
26 
27 extern "C" {
28 
29 struct StatisticPy_t;
30 struct PyStatistic;
31 
33 {
34  StatisticId_t id;
35 
36  explicit PyStatistic(StatisticId_t id) :
37  id(id)
38  {}
39  virtual ~PyStatistic() {}
40  ConfigStatistic* getStat();
41  int compare(PyStatistic* other);
42  StatisticId_t getID();
43 };
44 
46 {
47  PyObject_HEAD PyStatistic* obj;
48 };
49 
50 extern PyTypeObject PyModel_StatType;
51 
52 static inline ConfigStatistic*
53 getStat(PyObject* pobj)
54 {
55  ConfigStatistic* c = ((StatisticPy_t*)pobj)->obj->getStat();
56  if ( c == nullptr ) {
57  PyErr_SetString(PyExc_RuntimeError, "Failed to find ConfigStatistic");
58  }
59  return c;
60 }
61 
62 } /* extern C */
63 
64 } // namespace SST
65 
66 #endif // SST_CORE_MODEL_PYTHON_PYMODEL_STAT_H
Definition: configGraph.h:241
Definition: action.cc:18
Definition: pymodel_stat.h:45
Definition: pymodel_stat.h:32