SST 16.0.0
Structural Simulation Toolkit
pymodel_stat.h
1// -*- c++ -*-
2
3// Copyright 2009-2026 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-2026, 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
20DISABLE_WARN_DEPRECATED_REGISTER
21#include <Python.h>
22REENABLE_WARNING
23
24namespace SST {
25class ConfigStatistic;
26
27extern "C" {
28
29struct StatisticPy_t;
30struct PyStatistic;
31
32struct PyStatistic
33{
34 ComponentId_t comp_id;
35 StatisticId_t stat_id;
36
37 explicit PyStatistic(ComponentId_t cid, StatisticId_t sid) :
38 comp_id(cid),
39 stat_id(sid)
40 {}
41 virtual ~PyStatistic() {}
42 ConfigStatistic* getStat();
43 int compare(PyStatistic* other);
44 StatisticId_t getID();
45};
46
48{
49 PyObject_HEAD PyStatistic* obj;
50};
51
52extern PyTypeObject PyModel_StatType;
53
54static inline ConfigStatistic*
55getStat(PyObject* pobj)
56{
57 ConfigStatistic* c = ((StatisticPy_t*)pobj)->obj->getStat();
58 if ( c == nullptr ) {
59 PyErr_SetString(PyExc_RuntimeError, "Failed to find ConfigStatistic");
60 }
61 return c;
62}
63
64} /* extern C */
65
66} // namespace SST
67
68#endif // SST_CORE_MODEL_PYTHON_PYMODEL_STAT_H
Definition configStatistic.h:41
Definition pymodel_stat.h:33
Definition pymodel_stat.h:48