# Hurricane VLSI Database

DBo.h
1 // -*- C++ -*-
2 //
3 // Copyright (c) BULL S.A. 2000-2018, 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 #ifndef HURRICANE_DBO_H
33 #define HURRICANE_DBO_H
34
35 #include "hurricane/Error.h"
36 #include "hurricane/DBos.h"
37 #include "hurricane/Name.h"
38 #include "hurricane/Properties.h"
39
40
41 namespace Hurricane {
42
43
44 // -------------------------------------------------------------------
45 // Class : "Hurricane::DBo".
46
47 class DBo {
48 public:
49 enum DBoFlags { ForcedIdMode = (1<<0)
50 , NextIdSet = (1<<1)
51 };
52 public:
53 static void setMemoryLimit ( unsigned int );
54 static void setIdCounterLimit ( unsigned int );
55 static unsigned int getIdCounter ();
56 unsigned int getNextId ();
57 static void setNextId ( unsigned int );
58 static void resetId ();
59 static bool inForcedIdMode ();
60 static void enableForcedIdMode ();
61 static void disableForcedIdMode ();
62 static void useIdCounter2 ();
63 public:
64 virtual void destroy ();
65 inline set<Property*>& _getPropertySet ();
66 void _onDestroyed ( Property* property );
67 inline unsigned int getId () const;
68 Property* getProperty ( const Name& ) const;
69 Properties getProperties () const;
70 inline bool hasProperty () const;
71 void setId ( unsigned int );
72 void put ( Property* );
73 void remove ( Property* );
74 void removeProperty ( const Name& );
75 void clearProperties ();
76 virtual string _getTypeName () const;
77 virtual string _getString () const;
78 virtual Record* _getRecord () const;
79 virtual void _toJson ( JsonWriter* ) const;
80 virtual void _toJsonCollections ( JsonWriter* ) const;
81 virtual void _toJsonSignature ( JsonWriter* ) const;
82 void toJson ( JsonWriter* ) const;
83 void toJsonSignature ( JsonWriter* ) const;
84 protected:
85 DBo ();
86 virtual ~DBo () throw(Error);
87 virtual void _postCreate ();
88 virtual void _preDestroy ();
89 private:
90 DBo ( const DBo& ) = delete;
91 DBo& operator= ( const DBo& ) = delete;
92 private:
93 static unsigned int _memoryLimit;
94 static unsigned long _flags;
95 static unsigned int _nextId;
96 static unsigned int _idCount;
97 static unsigned int _idCounter;
98 static unsigned int _idCounterLimit;
99 unsigned int _id;
100 mutable set<Property*> _propertySet;
101 public:
102 struct CompareById : public std::binary_function<const DBo*,const DBo*,bool> {
103 template<typename Key>
104 inline bool operator() ( const Key* lhs, const Key* rhs ) const;
105 };
106 };
107
108
109 // Inline Functions.
110 inline set<Property*>& DBo::_getPropertySet () { return _propertySet; }
111 inline bool DBo::hasProperty () const { return !_propertySet.empty(); }
112 inline unsigned int DBo::getId () const { return _id; }
113
114 template<typename Key>
115 inline bool DBo::CompareById::operator() ( const Key* lhs, const Key* rhs ) const
116 { return ((lhs)?lhs->getId():0) < ((rhs)?rhs->getId():0); }
117
118
119 // -------------------------------------------------------------------
120 // Class : "Hurricane::JsonDBo".
121
122 class JsonDBo : public JsonObject {
123 public:
124 JsonDBo ( unsigned int flags );
125 template<typename T> inline void update ( JsonStack&, T );
126 };
127
128
129 template<typename T> inline void JsonDBo::update ( JsonStack& stack, T hobject )
130 {
131 JsonObject::update<T>( stack, hobject );
132 stack.push_back_dbo( dynamic_cast<DBo*>(hobject) );
133 }
134
135
136 } // Hurricane namespace.
137
138 INSPECTOR_P_SUPPORT(Hurricane::DBo);
139
140 #endif // HURRICANE_DBO_H
Hurricane::Error
Error description (API)
Definition: Error.h:43
Hurricane::DBo::removeProperty
void removeProperty(const Name &)
Hurricane::Name
Name description (API)
Definition: Name.h:36
Hurricane::DBo
DataBase object root class (API).
Definition: DBo.h:47
Hurricane::DBo::clearProperties
void clearProperties()
Hurricane::DBo::hasProperty
bool hasProperty() const
Definition: DBo.h:111
Hurricane::GenericCollection
Generic Collection auto-pointer.
Definition: Collection.h:28
Hurricane::DBo::destroy
virtual void destroy()
Hurricane::Property
Property description (API)
Definition: Property.h:58
Hurricane::DBo::getProperty
Property * getProperty(const Name &) const
Hurricane::DBo::put
void put(Property *)
Hurricane::DBo::getProperties
Properties getProperties() const
Hurricane
The namespace dedicated to Hurricane.
Definition: Generalities.dox:5

Generated by doxygen 1.8.14 on Sun Mar 8 2020 | Return to top of page

Hurricane VLSI Database | Copyright © 2000-2016 Bull S.A. All rights reserved