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 private:
47 static FastRTTI _fastRTTI;
48 public:
49 static inline const FastRTTI& fastRTTI ();
50 virtual const FastRTTI& vfastRTTI () const;
51 public:
52 enum DBoFlags { ForcedIdMode = (1<<0)
53 , NextIdSet = (1<<1)
54 };
55 public:
56 static void setMemoryLimit ( unsigned int );
57 static void setIdCounterLimit ( unsigned int );
58 static unsigned int getIdCounter ();
59 unsigned int getNextId ();
60 static void setNextId ( unsigned int );
61 static void resetId ();
62 static bool inForcedIdMode ();
63 static void enableForcedIdMode ();
64 static void disableForcedIdMode ();
65 static void useIdCounter2 ();
66 public:
67 virtual void destroy ();
68 inline set<Property*>& _getPropertySet ();
69 void _onDestroyed ( Property* property );
70 inline unsigned int getId () const;
71 Property* getProperty ( const Name& ) const;
73 inline bool hasProperty () const;
74 void setId ( unsigned int );
75 void put ( Property* );
76 void remove ( Property* );
77 void removeProperty ( const Name& );
79 virtual string _getTypeName () const;
80 virtual string _getString () const;
81 virtual Record* _getRecord () const;
82 virtual void _toJson ( JsonWriter* ) const;
83 virtual void _toJsonCollections ( JsonWriter* ) const;
84 virtual void _toJsonSignature ( JsonWriter* ) const;
85 void toJson ( JsonWriter* ) const;
86 void toJsonSignature ( JsonWriter* ) const;
87 protected:
88 DBo ();
89 virtual ~DBo () noexcept(false);
90 virtual void _postCreate ();
91 virtual void _preDestroy ();
92 private:
93 DBo ( const DBo& ) = delete;
94 DBo& operator= ( const DBo& ) = delete;
95 private:
96 static unsigned int _memoryLimit;
97 static unsigned long _flags;
98 static unsigned int _nextId;
99 static unsigned int _idCount;
100 static unsigned int _idCounter;
101 static unsigned int _idCounterLimit;
102 unsigned int _id;
103 mutable set<Property*> _propertySet;
104 public:
105 struct CompareById {
106 template<typename Key>
107 inline bool operator() ( const Key* lhs, const Key* rhs ) const;
108 };
109 };
110
111
112// Inline Functions.
113 inline const FastRTTI& DBo::fastRTTI () { return _fastRTTI; }
114 inline set<Property*>& DBo::_getPropertySet () { return _propertySet; }
115 inline bool DBo::hasProperty () const { return !_propertySet.empty(); }
116 inline unsigned int DBo::getId () const { return _id; }
117
118 template<typename Key>
119 inline bool DBo::CompareById::operator() ( const Key* lhs, const Key* rhs ) const
120 { return ((lhs)?lhs->getId():0) < ((rhs)?rhs->getId():0); }
121
122
123// -------------------------------------------------------------------
124// Class : "Hurricane::JsonDBo".
125
126 class JsonDBo : public JsonObject {
127 public:
128 JsonDBo ( unsigned int flags );
129 template<typename T> inline void update ( JsonStack&, T );
130 };
131
132
133 template<typename T> inline void JsonDBo::update ( JsonStack& stack, T hobject )
134 {
135 JsonObject::update<T>( stack, hobject );
136 stack.push_back_dbo( dynamic_cast<DBo*>(hobject) );
137 }
138
139
140} // Hurricane namespace.
141
142INSPECTOR_P_SUPPORT(Hurricane::DBo);
bool hasProperty() const
Definition DBo.h:115
virtual void destroy()
void clearProperties()
Property * getProperty(const Name &) const
void remove(Property *)
Properties getProperties() const
void put(Property *)
void removeProperty(const Name &)
void update(JsonStack &, T)
Definition JsonObject.h:406
Name description (API)
Definition Name.h:35
Property description (API)
Definition Property.h:56
Contains Almost Everything.
Definition BasicLayer.h:39
GenericCollection< Property * > Properties
Definition Properties.h:35


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