00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef TORC_GENERIC_OM_ROOT_HPP
00017 #define TORC_GENERIC_OM_ROOT_HPP
00018
00019 #include "torc/generic/om/PointerTypes.hpp"
00020 #include "torc/generic/om/DumpRestoreConfig.hpp"
00021
00022 #include <list>
00023 #include <string>
00024
00025
00026 #include <boost/shared_ptr.hpp>
00027 #ifdef GENOM_SERIALIZATION
00028 #include <boost/serialization/access.hpp>
00029 #include <boost/serialization/split_member.hpp>
00030 #endif //GENOM_SERIALIZATION
00031
00032 #include "torc/generic/om/Commentable.hpp"
00033 #include "torc/generic/om/EdifVersion.hpp"
00034 #include "torc/generic/om/EdifLevel.hpp"
00035 #include "torc/generic/util/Error.hpp"
00036 #include "torc/generic/om/FactoryType.hpp"
00037 #include "torc/generic/om/Nameable.hpp"
00038 #include "torc/generic/om/Renamable.hpp"
00039 #include "torc/generic/om/SelfReferencing.hpp"
00040 #include "torc/generic/om/SymTab.hpp"
00041 #include "torc/generic/om/Visitable.hpp"
00042 #include "torc/generic/om/VisitorType.hpp"
00043 #include "torc/generic/om/UserDataContainer.hpp"
00044 #include "torc/generic/om/StatusContainer.hpp"
00045
00046 #ifdef GENOM_SERIALIZATION
00047 #include "torc/generic/om/DumpRestoreData.hpp"
00048 #endif //GENOM_SERIALIZATION
00049
00050 namespace torc { namespace generic { class Library; } }
00051 namespace torc { namespace generic { class BaseVisitor; } }
00052
00053 namespace torc {
00054
00055 namespace generic {
00056
00057
00058
00059
00060
00061
00062
00063
00064 class Root
00065 : public Commentable,
00066 public Nameable,
00067 public Renamable,
00068 public Visitable,
00069 public SelfReferencing<Root>,
00070 public UserDataContainer,
00071 public StatusContainer {
00072
00073 #ifdef GENOM_SERIALIZATION
00074 friend class boost::serialization::access;
00075 #endif //GENOM_SERIALIZATION
00076
00077 friend class FactoryType<Root>;
00078
00079 public:
00080
00081
00082
00083 typedef VisitorType<Root> Visitor;
00084
00085
00086
00087
00088 class Factory: public FactoryType<Root>
00089 {
00090 public:
00091 using FactoryType<Root>::create;
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101 virtual RootSharedPtr
00102 newRootPtr( const std::string &inName,
00103 const EdifLevel &inEdifLevel = eEdifLevel0,
00104 const std::string &inOriginalName = std::string() ) throw(Error);
00105 };
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137 virtual void
00138 addLibrary(const LibrarySharedPtr &inLibrary) throw(Error);
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170 virtual void
00171 removeLibrary(const std::string &inName) throw(Error);
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181 virtual LibrarySharedPtr
00182 findLibrary(const std::string &inName) throw();
00183
00184
00185
00186
00187
00188
00189
00190 virtual void
00191 getLibraries(
00192 std::vector< LibrarySharedPtr > &outLibraries) throw();
00193
00194
00195
00196
00197
00198
00199
00200 template<typename _Action>
00201 inline void
00202 applyOnAllLibraries( const _Action &action ) throw(Error);
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226 virtual void
00227 addDesign(const DesignSharedPtr &inDesign) throw(Error);
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249 virtual void
00250 removeDesign(const std::string &inName) throw(Error);
00251
00252
00253
00254
00255
00256
00257
00258
00259 virtual DesignSharedPtr
00260 findDesign(const std::string &inName) throw();
00261
00262
00263
00264
00265
00266
00267 virtual void
00268 getDesigns(
00269 std::vector< DesignSharedPtr > &outDesigns) throw();
00270
00271
00272
00273
00274
00275
00276 template<typename _Action>
00277 inline void
00278 applyOnAllDesigns( const _Action &action ) throw(Error);
00279
00280
00281 virtual void
00282 accept(BaseVisitor & inoutVisitor) throw(Error);
00283
00284
00285
00286
00287
00288
00289 inline const EdifVersion
00290 getVersion() const throw();
00291
00292
00293
00294
00295
00296
00297 void
00298 setVersion(const EdifVersion & inSource) throw();
00299
00300
00301
00302
00303
00304
00305 inline const EdifLevel
00306 getLevel() const throw();
00307
00308
00309
00310
00311
00312
00313
00314
00315 void
00316 setLevel(const EdifLevel & inSource) throw();
00317
00318 #ifdef GENOM_SERIALIZATION
00319 inline const DumpRestoreData &
00320 getDumpRestoreData() const throw();
00321
00322 void
00323 setDumpRestoreData(
00324 const DumpRestoreData &inDumpRestoreData ) throw();
00325 void
00326 handleNewDumpRestoreData(
00327 const DumpRestoreData &inDumpRestoreData ) throw(Error);
00328 #endif //GENOM_SERIALIZATION
00329
00330 virtual
00331 ~Root() throw();
00332
00333 protected:
00334 Root();
00335
00336 private:
00337
00338 #ifdef GENOM_SERIALIZATION
00339 template<class Archive> void
00340 load( Archive &ar, unsigned int );
00341
00342 template<class Archive> void
00343 save( Archive &ar, unsigned int ) const;
00344
00345 LibrarySharedPtr
00346 restoreSingleLibrary( const std::string &inName ) throw(Error);
00347
00348 void
00349 restoreAllLibraries() throw(Error);
00350
00351 BOOST_SERIALIZATION_SPLIT_MEMBER()
00352 #endif //GENOM_SERIALIZATION
00353
00354 Root(const Root & source) throw();
00355
00356 Root &
00357 operator=(const Root & source) throw();
00358
00359 EdifLevel mLevel;
00360 SymTab< std::string, LibrarySharedPtr > mLibraries;
00361 SymTab< std::string, DesignSharedPtr > mDesignSymTab;
00362 EdifVersion mVersion;
00363 #ifdef GENOM_SERIALIZATION
00364 DumpRestoreData mDumpRestoreData;
00365 mutable std::list< std::string > mDumpedLibraries;
00366 #endif //GENOM_SERIALIZATION
00367
00368 };
00369
00370
00371
00372
00373
00374
00375 template<typename _Action>
00376 inline void
00377 Root::applyOnAllLibraries( const _Action &action ) throw(Error)
00378 {
00379 try
00380 {
00381 #ifdef GENOM_SERIALIZATION
00382 restoreAllLibraries();
00383 #endif //GENOM_SERIALIZATION
00384 mLibraries.applyOnAll( action );
00385 }
00386 catch(Error &e)
00387 {
00388 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
00389 throw;
00390 }
00391 }
00392
00393
00394
00395
00396
00397
00398 template<typename _Action>
00399 inline void
00400 Root::applyOnAllDesigns( const _Action &action ) throw(Error)
00401 {
00402 try
00403 {
00404 mDesignSymTab.applyOnAll( action );
00405 }
00406 catch(Error &e)
00407 {
00408 e.setCurrentLocation( __FUNCTION__, __FILE__, __LINE__ );
00409 throw;
00410 }
00411 }
00412
00413
00414
00415
00416
00417
00418 inline const EdifVersion
00419 Root::getVersion() const throw() {
00420 return mVersion;
00421 }
00422
00423
00424
00425
00426
00427
00428 inline const EdifLevel
00429 Root::getLevel() const throw() {
00430 return mLevel;
00431 }
00432
00433 #ifdef GENOM_SERIALIZATION
00434 inline const DumpRestoreData &
00435 Root::getDumpRestoreData() const throw() {
00436 return mDumpRestoreData;
00437 }
00438
00439 void
00440 dump( const RootSharedPtr &inRoot ) throw(Error);
00441
00442 void
00443 dump( const RootSharedPtr &inRoot,
00444 const DumpRestoreData &inData ) throw(Error);
00445
00446 RootSharedPtr
00447 restore( const std::string &inName,
00448 const DumpRestoreData &inData ) throw(Error);
00449
00450 #endif //GENOM_SERIALIZATION
00451
00452 }
00453
00454 }
00455
00456 #endif // TORC_GENERIC_OM_ROOT_HPP