SST 16.0.0
Structural Simulation Toolkit
pymodel_portmodule.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_PORTMODULE_H
15#define SST_CORE_MODEL_PYTHON_PYMODEL_PORTMODULE_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
24#include <string>
25#include <vector>
26
27namespace SST {
29}
30
31extern "C" {
32
33struct PortModulePy_t;
34struct PyPortModule;
35
36struct PyPortModule
37{
38 PortModulePy_t* pobj;
39 SST::ComponentId_t id; // ID of component this port module is loaded at
40 unsigned lkup; // Index of this port module at port
41 std::string port; // Port name
42
43 PyPortModule(PortModulePy_t* pobj, SST::ComponentId_t id, unsigned lkup, const char* port) :
44 pobj(pobj),
45 id(id),
46 lkup(lkup),
47 port(port)
48 {}
49 ~PyPortModule() = default;
50 int compare(PyPortModule* other);
51 SST::ConfigPortModule* getPortModule();
52
53 PyPortModule(const PyPortModule&) = delete;
54 PyPortModule& operator=(const PyPortModule&) = delete;
55};
56
58{
59 PyObject_HEAD PyPortModule* obj;
60};
61
62extern PyTypeObject PyModel_PortModuleType;
63
64static inline SST::ConfigPortModule*
65getPortModule(PyObject* pobj)
66{
67 SST::ConfigPortModule* pm = ((PortModulePy_t*)pobj)->obj->getPortModule();
68 if ( pm == nullptr ) {
69 PyErr_SetString(PyExc_RuntimeError, "Failed to find ConfigPortModule");
70 }
71 return pm;
72}
73
74} /* extern C */
75
76#endif // SST_CORE_MODEL_PYTHON_PYMODEL_PORTMODULE_H
Class that represents a PortModule in ConfigGraph.
Definition configComponent.h:50
Definition pymodel_portmodule.h:58
Definition pymodel_portmodule.h:37