SST  15.1.0
StructuralSimulationToolkit
pymodel_portmodule.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_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 
20 DISABLE_WARN_DEPRECATED_REGISTER
21 #include <Python.h>
22 REENABLE_WARNING
23 
24 #include <string>
25 #include <vector>
26 
27 namespace SST {
28 class ConfigPortModule;
29 }
30 
31 extern "C" {
32 
33 struct PortModulePy_t;
34 struct PyPortModule;
35 
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 
62 extern PyTypeObject PyModel_PortModuleType;
63 
64 static inline SST::ConfigPortModule*
65 getPortModule(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
Definition: pymodel_portmodule.h:57
Class that represents a PortModule in ConfigGraph.
Definition: configGraph.h:348
Definition: action.cc:18
Definition: pymodel_portmodule.h:36