SST 12.1.0
Structural Simulation Toolkit
pymodel_comp.h
1// -*- c++ -*-
2
3// Copyright 2009-2022 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-2022, 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_COMP_H
15#define SST_CORE_MODEL_PYTHON_PYMODEL_COMP_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
26namespace SST {
27class ConfigComponent;
28} // namespace SST
29
30extern "C" {
31
32struct ComponentPy_t;
33struct PyComponent;
34
36{
37 ComponentPy_t* pobj;
38 SST::ComponentId_t id;
39
40 ComponentHolder(ComponentPy_t* pobj, SST::ComponentId_t id) : pobj(pobj), id(id) {}
41 virtual ~ComponentHolder() {}
42 virtual SST::ConfigComponent* getComp();
43 virtual int compare(ComponentHolder* other);
44 virtual std::string getName();
45 SST::ComponentId_t getID();
46 SST::ConfigComponent* getSubComp(const std::string& name, int slot_num);
47};
48
50{
51 uint16_t subCompId;
52
53 PyComponent(ComponentPy_t* pobj, SST::ComponentId_t id) : ComponentHolder(pobj, id), subCompId(0) {}
54 ~PyComponent() {}
55};
56
58{
59 PySubComponent(ComponentPy_t* pobj, SST::ComponentId_t id) : ComponentHolder(pobj, id) {}
61 int getSlot();
62};
63
65{
66 PyObject_HEAD ComponentHolder* obj;
67};
68
69extern PyTypeObject PyModel_ComponentType;
70extern PyTypeObject PyModel_SubComponentType;
71
72static inline SST::ConfigComponent*
73getComp(PyObject* pobj)
74{
75 SST::ConfigComponent* c = ((ComponentPy_t*)pobj)->obj->getComp();
76 if ( c == nullptr ) { PyErr_SetString(PyExc_RuntimeError, "Failed to find ConfigComponent"); }
77 return c;
78}
79
80} /* extern C */
81
82#endif // SST_CORE_MODEL_PYTHON_PYMODEL_COMP_H
Represents the configuration of a generic component.
Definition: configGraph.h:218
Definition: pymodel_comp.h:36
Definition: pymodel_comp.h:65
Definition: pymodel_comp.h:50
Definition: pymodel_comp.h:58