Hurricane VLSI Database


DBo.h
1// -*- C++ -*-
2//
3// Copyright (c) BULL S.A. 2000-2021, All Rights Reserved
4//
5// This file is part of Hurricane.
6//
7// Hurricane is free software: you can redistribute it and/or modify
8// it under the terms of the GNU Lesser General Public License as
9// published by the Free Software Foundation, either version 3 of the
10// License, or (at your option) any later version.
11//
12// Hurricane is distributed in the hope that it will be useful, but
13// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-
14// TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU
15// General Public License for more details.
16//
17// You should have received a copy of the Lesser GNU General Public
18// License along with Hurricane. If not, see
19// <http://www.gnu.org/licenses/>.
20//
21// +-----------------------------------------------------------------+
22// | H U R R I C A N E |
23// | V L S I B a c k e n d D a t a - B a s e |
24// | |
25// | Author : Remy Escassut |
26// | E-mail : Jean-Paul.Chaput@lip6.fr |
27// | =============================================================== |
28// | C++ Header : "./hurricane/DBo.h" |
29// +-----------------------------------------------------------------+
30
31
32#pragma once
33#include "hurricane/Error.h"
34#include "hurricane/DBos.h"
35#include "hurricane/Name.h"
36#include "hurricane/Properties.h"
37
38
39namespace Hurricane {
40
41
42// -------------------------------------------------------------------
43// Class : "Hurricane::DBo".
44
45 class DBo {
46 public:
47 enum DBoFlags { ForcedIdMode = (1<<0)
48 , NextIdSet = (1<<1)
49 };
50 public:
51 static void setMemoryLimit ( unsigned int );
52 static void setIdCounterLimit ( unsigned int );
53 static unsigned int getIdCounter ();
54 unsigned int getNextId ();
55 static void setNextId ( unsigned int );
56 static void resetId ();
57 static bool inForcedIdMode ();
58 static void enableForcedIdMode ();
59 static void disableForcedIdMode ();
60 static void useIdCounter2 ();
61 public:
62 virtual void destroy ();
63 inline set<Property*>& _getPropertySet ();
64 void _onDestroyed ( Property* property );
65 inline unsigned int getId () const;
66 Property* getProperty ( const Name& ) const;
68 inline bool hasProperty () const;
69 void setId ( unsigned int );
70 void put ( Property* );
71 void remove ( Property* );
72 void removeProperty ( const Name& );
74 virtual string _getTypeName () const;
75 virtual string _getString () const;
76 virtual Record* _getRecord () const;
77 virtual void _toJson ( JsonWriter* ) const;
78 virtual void _toJsonCollections ( JsonWriter* ) const;
79 virtual void _toJsonSignature ( JsonWriter* ) const;
80 void toJson ( JsonWriter* ) const;
81 void toJsonSignature ( JsonWriter* ) const;
82 protected:
83 DBo ();
84 virtual ~DBo () noexcept(false);
85 virtual void _postCreate ();
86 virtual void _preDestroy ();
87 private:
88 DBo ( const DBo& ) = delete;
89 DBo& operator= ( const DBo& ) = delete;
90 private:
91 static unsigned int _memoryLimit;
92 static unsigned long _flags;
93 static unsigned int _nextId;
94 static unsigned int _idCount;
95 static unsigned int _idCounter;
96 static unsigned int _idCounterLimit;
97 unsigned int _id;
98 mutable set<Property*> _propertySet;
99 public:
100 struct CompareById {
101 template<typename Key>
102 inline bool operator() ( const Key* lhs, const Key* rhs ) const;
103 };
104 };
105
106
107// Inline Functions.
108 inline set<Property*>& DBo::_getPropertySet () { return _propertySet; }
109 inline bool DBo::hasProperty () const { return !_propertySet.empty(); }
110 inline unsigned int DBo::getId () const { return _id; }
111
112 template<typename Key>
113 inline bool DBo::CompareById::operator() ( const Key* lhs, const Key* rhs ) const
114 { return ((lhs)?lhs->getId():0) < ((rhs)?rhs->getId():0); }
115
116
117// -------------------------------------------------------------------
118// Class : "Hurricane::JsonDBo".
119
120 class JsonDBo : public JsonObject {
121 public:
122 JsonDBo ( unsigned int flags );
123 template<typename T> inline void update ( JsonStack&, T );
124 };
125
126
127 template<typename T> inline void JsonDBo::update ( JsonStack& stack, T hobject )
128 {
129 JsonObject::update<T>( stack, hobject );
130 stack.push_back_dbo( dynamic_cast<DBo*>(hobject) );
131 }
132
133
134} // Hurricane namespace.
135
136INSPECTOR_P_SUPPORT(Hurricane::DBo);
DataBase object root class (API).
Definition DBo.h:45
bool hasProperty() const
Definition DBo.h:109
void clearProperties()
Property * getProperty(const Name &) const
virtual void destroy()
void remove(Property *)
void put(Property *)
void removeProperty(const Name &)
Properties getProperties() const
Generic Collection auto-pointer.
Definition Collection.h:235
Name description (API)
Definition Name.h:35
Property description (API)
Definition Property.h:56
Contains Almost Everything.
Definition BasicLayer.h:39


Generated by doxygen 1.9.7 on Fri Sep 27 2024 Return to top of page
Hurricane VLSI Database Copyright © 2000-2020 Bull S.A. All rights reserved