Hurricane VLSI Database


PythonAttributes.h
1 // -*- C++ -*-
2 //
3 // This file is part of the Coriolis Software.
4 // Copyright (c) Sorbonne Université 2022-2022, All Rights Reserved
5 //
6 // +-----------------------------------------------------------------+
7 // | C O R I O L I S |
8 // | I s o b a r - Hurricane / Python Interface |
9 // | |
10 // | Author : Jean-Paul Chaput |
11 // | E-mail : Jean-Paul.Chaput@lip6.fr |
12 // | =============================================================== |
13 // | C++ Header : "./hurricane/isobar/PythonAttributes.h" |
14 // +-----------------------------------------------------------------+
15 
16 
17 #pragma once
18 #include <Python.h>
19 #include <string>
20 #include "hurricane/Name.h"
21 #include "hurricane/Property.h"
22 #include "hurricane/Slot.h"
23 #include "hurricane/DBo.h"
24 
25 
26 namespace Isobar {
27 
28  using Hurricane::Record;
29  using Hurricane::Name;
30  using Hurricane::DBo;
32  class PyHolderProperty;
33 
34 
35  extern "C" {
36 
37 // -------------------------------------------------------------------
38 // Python Object : "PyAttributesHolder".
39 
40  typedef struct {
41  PyObject_HEAD
42  PyObject* dict;
44 
45 
46  extern PyTypeObject PyTypeAttributesHolder;
47 
48  } // extern "C".
49 
50 
51 // -------------------------------------------------------------------
52 // Class : "Isobar::PyHolderProperty".
53 
55  friend class PythonAttributes;
56  public:
58  static Name _name;
59  public:
60  static PyHolderProperty* create ( DBo* );
61  static Name getPropertyName ();
62  virtual Name getName () const;
63  inline PyAttributesHolder* getHolder ();
64  inline int32_t getDictSize ();
65  int32_t delattr ( std::string );
66  virtual void onReleasedBy ( DBo* owner );
67  virtual std::string _getTypeName () const;
68  virtual std::string _getString () const;
69  virtual Record* _getRecord () const;
70  protected:
71  virtual void _preDestroy ();
72  protected:
73  // Attributes.
74  PyAttributesHolder* _holder;
75 
76  protected:
77  // Constructor.
78  inline PyHolderProperty ();
79  };
80 
81 
82  inline PyHolderProperty::PyHolderProperty ()
83  : PrivateProperty(), _holder(NULL)
84  { }
85 
86 
87  inline PyAttributesHolder* PyHolderProperty::getHolder () { return _holder; }
88  inline int32_t PyHolderProperty::getDictSize () { return PyDict_Size( _holder->dict ); }
89 
90 
91 // -------------------------------------------------------------------
92 // Class : "Isobar::PythonAttributes".
93 
95  public:
96  static PyAttributesHolder* get ( const DBo* );
97  static int32_t delattr ( DBo*, std::string );
98  static void enable ( DBo* );
99  static void disable ( DBo* );
100  static void disableAll ();
101  static void disableAll ( std::string );
102  static int32_t count ();
103  };
104 
105 
106 } // Isobar Namespace.
107 
108 
109 INSPECTOR_P_SUPPORT(Isobar::PyHolderProperty);
DataBase object root class (API).
Definition: DBo.h:45
Name description (API)
Definition: Name.h:35
PrivateProperty description (API)
Definition: Property.h:132
A Property to contain PyAttributesHolder.
Definition: PythonAttributes.h:54
A Property to store Python objects (API).
Definition: PythonAttributes.h:94
static void enable(DBo *)
static void disableAll()
static int32_t delattr(DBo *, std::string)
static void disable(DBo *)
static void disableAll(std::string)
static PyAttributesHolder * get(const DBo *)
A simple Python object to store attributes.
Definition: PythonAttributes.h:40


Generated by doxygen 1.9.1 on Wed Nov 20 2024 Return to top of page
Hurricane VLSI Database Copyright © 2000-2020 Bull S.A. All rights reserved