SST  10.1.0
StructuralSimulationToolkit
pymodel_comp.h
1 // -*- c++ -*-
2 
3 // Copyright 2009-2020 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-2020, 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_PYMODEL_COMP_H
15 #define SST_CORE_MODEL_PYMODEL_COMP_H
16 
17 #include "sst/core/sst_types.h"
18 
19 extern "C" {
20 
21 
22 struct ComponentPy_t;
23 struct PyComponent;
24 
26  ComponentPy_t *pobj;
27  // ConfigComponent* config;
28  ComponentId_t id;
29 
30  ComponentHolder(ComponentPy_t *pobj, ComponentId_t id) : pobj(pobj), id(id) { }
31  virtual ~ComponentHolder() { }
32  virtual ConfigComponent* getComp();
33  virtual int compare(ComponentHolder *other);
34  virtual std::string getName();
35  ComponentId_t getID();
36  ConfigComponent* getSubComp(const std::string& name, int slot_num);
37 };
38 
40  uint16_t subCompId;
41 
42  PyComponent(ComponentPy_t *pobj, ComponentId_t id) : ComponentHolder(pobj,id), subCompId(0) { }
43  ~PyComponent() {}
44 };
45 
47  PySubComponent(ComponentPy_t *pobj, ComponentId_t id) : ComponentHolder(pobj,id) { }
48  ~PySubComponent() {}
49  int getSlot();
50 };
51 
52 
53 struct ComponentPy_t {
54  PyObject_HEAD
55  ComponentHolder *obj;
56 };
57 
58 extern PyTypeObject PyModel_ComponentType;
59 extern PyTypeObject PyModel_SubComponentType;
60 
61 static inline ConfigComponent* getComp(PyObject *pobj) {
62  ConfigComponent *c = ((ComponentPy_t*)pobj)->obj->getComp();
63  if ( c == nullptr ) {
64  PyErr_SetString(PyExc_RuntimeError, "Failed to find ConfigComponent");
65  }
66  return c;
67 }
68 
69 
70 } /* extern C */
71 
72 
73 #endif
Definition: pymodel_comp.h:53
Definition: pymodel_comp.h:39
Definition: pymodel_comp.h:46
Definition: pymodel_comp.h:25