00001 #ifndef STORAGE_H
00002 #define STORAGE_H
00003
00004 #include <iostream>
00005 #include <list>
00006 #include <map>
00007
00008 #include "y2storage/StorageInterface.h"
00009 #include "y2storage/StorageTypes.h"
00010 #include "y2storage/StorageTmpl.h"
00011 #include "y2storage/Container.h"
00012 #include "y2storage/Volume.h"
00013 #include "y2storage/Disk.h"
00014 #include "y2storage/Partition.h"
00015 #include "y2storage/LvmVg.h"
00016 #include "y2storage/LvmLv.h"
00017 #include "y2storage/EvmsCo.h"
00018 #include "y2storage/Evms.h"
00019 #include "y2storage/DmraidCo.h"
00020 #include "y2storage/Dmraid.h"
00021 #include "y2storage/MdCo.h"
00022 #include "y2storage/Md.h"
00023 #include "y2storage/DmCo.h"
00024 #include "y2storage/LoopCo.h"
00025 #include "y2storage/Loop.h"
00026 #include "y2storage/NfsCo.h"
00027 #include "y2storage/Nfs.h"
00028 #include "y2storage/FilterIterator.h"
00029 #include "y2storage/DerefIterator.h"
00030 #include "y2storage/ListListIterator.h"
00031 #include "y2storage/IterPair.h"
00032
00033 namespace storage
00034 {
00035 template <int Value>
00036 class CheckType
00037 {
00038 public:
00039 bool operator()( const Container& d ) const
00040 {
00041 return( d.type()==Value );
00042 }
00043 };
00044
00045 template< class Iter, int Value, class CastResult >
00046 class CastCheckIterator : public CheckType<Value>,
00047 public FilterIterator< CheckType<Value>, Iter >
00048 {
00049 typedef FilterIterator<CheckType<Value>, Iter> _bclass;
00050 public:
00051 typedef CastResult value_type;
00052 typedef CastResult& reference;
00053 typedef CastResult* pointer;
00054
00055 CastCheckIterator() : _bclass() {}
00056 CastCheckIterator( const Iter& b, const Iter& e, bool atend=false) :
00057 _bclass( b, e, *this, atend ) {}
00058 CastCheckIterator( const IterPair<Iter>& pair, bool atend=false) :
00059 _bclass( pair, *this, atend ) {}
00060 CastCheckIterator( const CastCheckIterator& i) { *this=i;}
00061 CastResult operator*() const
00062 {
00063 return( static_cast<CastResult>(_bclass::operator*()) );
00064 }
00065 CastResult* operator->() const
00066 {
00067 return( static_cast<CastResult*>(_bclass::operator->()) );
00068 }
00069 CastCheckIterator& operator++()
00070 {
00071 _bclass::operator++(); return(*this);
00072 }
00073 CastCheckIterator operator++(int)
00074 {
00075 y2warning( "Expensive ++ CastCheckIterator" );
00076 CastCheckIterator tmp(*this);
00077 _bclass::operator++();
00078 return(tmp);
00079 }
00080 CastCheckIterator& operator--()
00081 {
00082 _bclass::operator--(); return(*this);
00083 }
00084 CastCheckIterator operator--(int)
00085 {
00086 y2warning( "Expensive -- CastCheckIterator" );
00087 CastCheckIterator tmp(*this);
00088 _bclass::operator--();
00089 return(tmp);
00090 }
00091 };
00092
00093 template < bool (* FncP)( const Container& c ) >
00094 class CheckByFnc
00095 {
00096 public:
00097 bool operator()( const Container& d ) const
00098 {
00099 return( (*FncP)(d) );
00100 }
00101 };
00102
00103 template< class Iter, bool (* FncP)( const Container& c ), class CastResult >
00104 class CastCheckFncIterator : public CheckByFnc<FncP>,
00105 public FilterIterator< CheckByFnc<FncP>, Iter >
00106 {
00107 typedef FilterIterator<CheckByFnc<FncP>, Iter> _bclass;
00108 public:
00109 typedef CastResult value_type;
00110 typedef CastResult& reference;
00111 typedef CastResult* pointer;
00112
00113 CastCheckFncIterator() : _bclass() {}
00114 CastCheckFncIterator( const Iter& b, const Iter& e, bool atend=false) :
00115 _bclass( b, e, *this, atend ) {}
00116 CastCheckFncIterator( const IterPair<Iter>& pair, bool atend=false) :
00117 _bclass( pair, *this, atend ) {}
00118 CastCheckFncIterator( const CastCheckFncIterator& i) { *this=i;}
00119 CastResult operator*() const
00120 {
00121 return( static_cast<CastResult>(_bclass::operator*()) );
00122 }
00123 CastResult* operator->() const
00124 {
00125 return( static_cast<CastResult*>(_bclass::operator->()) );
00126 }
00127 CastCheckFncIterator& operator++()
00128 {
00129 _bclass::operator++(); return(*this);
00130 }
00131 CastCheckFncIterator operator++(int)
00132 {
00133 y2warning( "Expensive ++ CastCheckFncIterator" );
00134 CastCheckFncIterator tmp(*this);
00135 _bclass::operator++();
00136 return(tmp);
00137 }
00138 CastCheckFncIterator& operator--()
00139 {
00140 _bclass::operator--(); return(*this);
00141 }
00142 CastCheckFncIterator operator--(int)
00143 {
00144 y2warning( "Expensive -- CastCheckFncIterator" );
00145 CastCheckFncIterator tmp(*this);
00146 _bclass::operator--();
00147 return(tmp);
00148 }
00149 };
00150
00166 class EtcFstab;
00167 class DiskData;
00168
00169 class Storage : public storage::StorageInterface
00170 {
00171 protected:
00172
00173 typedef std::list<Container*> CCont;
00174 typedef CCont::iterator CIter;
00175 typedef CCont::const_iterator CCIter;
00176
00177 static bool isMd( const Container&d )
00178 { return( d.type()==storage::MD ); }
00179 static bool isLoop( const Container&d )
00180 { return( d.type()==storage::LOOP ); }
00181 static bool isNfs( const Container&d )
00182 { return( d.type()==storage::NFSC ); }
00183 static bool isDm( const Container&d )
00184 { return( d.type()==storage::DM ); }
00185 struct FreeInfo
00186 {
00187 unsigned long long resize_free;
00188 unsigned long long df_free;
00189 unsigned long long used;
00190 bool win;
00191 bool efi;
00192 bool rok;
00193 FreeInfo() { resize_free=df_free=used=0; efi=win=rok=false; }
00194 FreeInfo( unsigned long long df,
00195 unsigned long long resize,
00196 unsigned long long usd, bool w=false, bool e=false,
00197 bool r=true )
00198 { resize_free=resize; df_free=df; used=usd; win=w;
00199 efi=e, rok=r; }
00200 };
00201
00202 public:
00203 struct SkipDeleted { bool operator()(const Container&d) const {return( !d.deleted());}};
00204 static SkipDeleted SkipDel;
00205 static bool notDeleted( const Container&d ) { return( !d.deleted() ); };
00206 static bool isDmPart( const Container&d )
00207 { return( d.type()==storage::DMRAID ); }
00208
00209 static void initDefaultLogger ();
00210
00211 Storage( bool ronly=false, bool testmode=false, bool autodetect=true );
00212 bool test() const { return( testmode ); }
00213 bool instsys() const { return( inst_sys ); }
00214 void setCacheChanges( bool val=true ) { cache = val; }
00215 bool isCacheChanges() const { return( cache ); }
00216 void assertInit() { if( !initialized ) initialize(); }
00217 void rescanEverything();
00218 int checkCache();
00219 const string& tDir() const { return( testdir ); }
00220 const string& root() const { return( rootprefix ); }
00221 string prependRoot(const string& mp) const;
00222 const string& tmpDir() const;
00223 static const string& arch() { return( proc_arch ); }
00224 static const string& sysfsDir() { return( sysfs_dir ); }
00225 static bool isPPCMac() { return( is_ppc_mac ); }
00226 static bool isPPCPegasos() { return( is_ppc_pegasos ); }
00227 EtcFstab* getFstab() { return fstab; }
00228 void handleLogFile( const string& name );
00229 static bool testFilesEqual( const string& n1, const string& n2 );
00230 void printInfo( std::ostream& str ) { printInfo( str, "" ); }
00231 void printInfo( std::ostream& str, const string& name );
00232 void printInfoCo( std::ostream& str, const string& name ) { printInfo( str, name ); }
00233 void logCo( Container* c ) const;
00234 void logCo( const string& device );
00235 void logProcData( const string& l="" );
00236 storage::UsedByType usedBy( const string& dev );
00237 bool usedBy( const string& dev, storage::usedBy& ub );
00238 bool setUsedBy( const string& dev, storage::UsedByType typ,
00239 const string& name );
00240 bool canUseDevice( const string& dev, bool disks_allowed=false );
00241 bool knownDevice( const string& dev, bool disks_allowed=false );
00242 bool setDmcryptData( const string& dev, const string& dm,
00243 unsigned dmnum, unsigned long long siz,
00244 storage::EncryptType typ );
00245 bool deletedDevice( const string& dev );
00246 bool isDisk( const string& dev );
00247 const Volume* getVolume( const string& dev );
00248 unsigned long long deviceSize( const string& dev );
00249 string deviceByNumber( const string& majmin );
00250 void rootMounted();
00251 bool isRootMounted() const { return( root_mounted ); }
00252 string findNormalDevice( const string& device );
00253 bool findVolume( const string& device, Volume const* &vol );
00254 bool findDm( const string& device, const Dm*& dm );
00255 bool findDmUsing( const string& device, const Dm*& dm );
00256 bool removeDm( const string& device );
00257
00258 virtual ~Storage();
00259
00260
00261
00262 void getContainers( deque<storage::ContainerInfo>& infos );
00263 int getDiskInfo( const string& disk, storage::DiskInfo& info);
00264 int getLvmVgInfo( const string& name, storage::LvmVgInfo& info);
00265 int getEvmsCoInfo( const string& name, storage::EvmsCoInfo& info);
00266 int getDmraidCoInfo( const string& name, storage::DmraidCoInfo& info);
00267 int getContDiskInfo( const string& disk, storage::ContainerInfo& cinfo,
00268 storage::DiskInfo& info);
00269 int getContLvmVgInfo( const string& name, storage::ContainerInfo& cinfo,
00270 storage::LvmVgInfo& info);
00271 int getContEvmsCoInfo( const string& name,
00272 storage::ContainerInfo& cinfo,
00273 storage::EvmsCoInfo& info );
00274 int getContDmraidCoInfo( const string& name,
00275 storage::ContainerInfo& cinfo,
00276 storage::DmraidCoInfo& info );
00277 void getVolumes (deque<storage::VolumeInfo>& vlist);
00278 int getVolume( const string& device, storage::VolumeInfo& info);
00279 int getPartitionInfo( const string& disk,
00280 deque<storage::PartitionInfo>& plist );
00281 int getLvmLvInfo( const string& name,
00282 deque<storage::LvmLvInfo>& plist );
00283 int getEvmsInfo( const string& name,
00284 deque<storage::EvmsInfo>& plist );
00285 int getMdInfo( deque<storage::MdInfo>& plist );
00286 int getDmInfo( deque<storage::DmInfo>& plist );
00287 int getNfsInfo( deque<storage::NfsInfo>& plist );
00288 int getLoopInfo( deque<storage::LoopInfo>& plist );
00289 int getDmraidInfo( const string& name,
00290 deque<storage::DmraidInfo>& plist );
00291 int getContVolInfo( const string& dev, ContVolInfo& info);
00292
00293 bool getFsCapabilities( storage::FsType fstype,
00294 storage::FsCapabilities& fscapabilities) const;
00295 string getAllUsedFs() const;
00296 void setExtError( const string& txt );
00297 int createPartition( const string& disk, storage::PartitionType type,
00298 unsigned long start, unsigned long size,
00299 string& device );
00300 int resizePartition( const string& device, unsigned long sizeCyl );
00301 int resizePartitionNoFs( const string& device, unsigned long sizeCyl );
00302 int nextFreePartition( const string& disk, storage::PartitionType type,
00303 unsigned &nr, string& device );
00304 int updatePartitionArea( const string& device,
00305 unsigned long start, unsigned long size );
00306 int createPartitionKb( const string& disk, storage::PartitionType type,
00307 unsigned long long start,
00308 unsigned long long sizek, string& device );
00309 int createPartitionAny( const string& disk, unsigned long long size,
00310 string& device );
00311 int createPartitionMax( const string& disk, storage::PartitionType type,
00312 string& device );
00313 unsigned long kbToCylinder( const string& disk, unsigned long long size );
00314 unsigned long long cylinderToKb( const string& disk, unsigned long size );
00315 int removePartition( const string& partition );
00316 int changePartitionId( const string& partition, unsigned id );
00317 int forgetChangePartitionId( const string& partition );
00318 int destroyPartitionTable( const string& disk, const string& label );
00319 int initializeDisk( const string& disk, bool value );
00320 string defaultDiskLabel() const;
00321 string defaultDiskLabelSize( unsigned long long size_k ) const;
00322 unsigned long long maxSizeLabelK( const string& label ) const;
00323
00324 int changeFormatVolume( const string& device, bool format,
00325 storage::FsType fs );
00326 int changeLabelVolume( const string& device, const string& label );
00327 int eraseLabelVolume( const string& device );
00328 int changeMkfsOptVolume( const string& device, const string& opts );
00329 int changeTunefsOptVolume( const string& device, const string& opts );
00330 int changeDescText( const string& device, const string& txt );
00331 int changeMountPoint( const string& device, const string& mount );
00332 int getMountPoint( const string& device, string& mount );
00333 int changeMountBy( const string& device, storage::MountByType mby );
00334 int getMountBy( const string& device, storage::MountByType& mby );
00335 int changeFstabOptions( const string&, const string& options );
00336 int getFstabOptions( const string& device, string& options );
00337 int addFstabOptions( const string&, const string& options );
00338 int removeFstabOptions( const string&, const string& options );
00339 int setCryptPassword( const string& device, const string& pwd );
00340 int forgetCryptPassword( const string& device );
00341 int getCryptPassword( const string& device, string& pwd );
00342 int setCrypt( const string& device, bool val );
00343 int setCryptType( const string& device, bool val, EncryptType typ );
00344 int getCrypt( const string& device, bool& val );
00345 int setIgnoreFstab( const string& device, bool val );
00346 int getIgnoreFstab( const string& device, bool& val );
00347 int addFstabEntry( const string& device, const string& mount,
00348 const string& vfs, const string& options,
00349 unsigned freq, unsigned passno );
00350 int resizeVolume( const string& device, unsigned long long newSizeMb );
00351 int resizeVolumeNoFs( const string& device, unsigned long long newSizeMb );
00352 int forgetResizeVolume( const string& device );
00353 void setRecursiveRemoval( bool val=true );
00354 bool getRecursiveRemoval() const { return recursiveRemove; }
00355 void setZeroNewPartitions( bool val=true );
00356 bool getZeroNewPartitions() const { return zeroNewPartitions; }
00357 void setDefaultMountBy (MountByType mby = MOUNTBY_DEVICE);
00358 MountByType getDefaultMountBy() const { return defaultMountBy; }
00359 void setDetectMountedVolumes( bool val=true );
00360 bool getDetectMountedVolumes() const { return detectMounted; }
00361 void setRootPrefix( const string& root );
00362 int removeVolume( const string& device );
00363 int removeUsing( const string& device, const storage::usedBy& uby );
00364 bool checkDeviceMounted( const string& device, string& mp );
00365 bool umountDevice( const string& device );
00366 bool mountDev( const string& device, const string& mp, bool ro=true,
00367 const string& opts="" );
00368 bool mountDevice( const string& device, const string& mp )
00369 { return( mountDev( device, mp, false )); }
00370 bool mountDeviceOpts( const string& device, const string& mp,
00371 const string& opts )
00372 { return( mountDev( device, mp, false, opts )); }
00373 bool mountDeviceRo( const string& device, const string& mp,
00374 const string& opts )
00375 { return( mountDev( device, mp, true, opts )); }
00376 bool readFstab( const string& dir, deque<storage::VolumeInfo>& infos);
00377 bool getFreeInfo( const string& device, unsigned long long& resize_free,
00378 unsigned long long& df_free,
00379 unsigned long long& used, bool& win, bool& efi,
00380 bool use_cache );
00381 unsigned long long getDfSize( const string& mp );
00382 int createBackupState( const string& name );
00383 int removeBackupState( const string& name );
00384 int restoreBackupState( const string& name );
00385 bool checkBackupState( const string& name );
00386 bool equalBackupStates( const string& lhs, const string& rhs,
00387 bool verbose_log ) const;
00388
00389 int createLvmVg( const string& name, unsigned long long peSizeK,
00390 bool lvm1, const deque<string>& devs );
00391 int removeLvmVg( const string& name );
00392 int extendLvmVg( const string& name, const deque<string>& devs );
00393 int shrinkLvmVg( const string& name, const deque<string>& devs );
00394 int createLvmLv( const string& vg, const string& name,
00395 unsigned long long sizeM, unsigned stripe,
00396 string& device );
00397 int removeLvmLvByDevice( const string& device );
00398 int removeLvmLv( const string& vg, const string& name );
00399 int changeLvStripeCount( const string& vg, const string& name,
00400 unsigned long stripes );
00401 int changeLvStripeSize( const string& vg, const string& name,
00402 unsigned long long stripeSize );
00403
00404 int evmsActivate( bool force );
00405 int createEvmsContainer( const string& name, unsigned long long peSizeK,
00406 bool lvm1, const deque<string>& devs );
00407 int modifyEvmsContainer( const string& old_name, const string& new_name,
00408 unsigned long long peSizeK, bool lvm1 );
00409 int removeEvmsContainer( const string& name );
00410 int extendEvmsContainer( const string& name, const deque<string>& devs );
00411 int shrinkEvmsContainer( const string& name, const deque<string>& devs );
00412 int createEvmsVolume( const string& vg, const string& name,
00413 unsigned long long sizeM, unsigned stripe,
00414 string& device );
00415 int removeEvmsVolumeByDevice( const string& device );
00416 int removeEvmsVolume( const string& vg, const string& name );
00417 int changeEvmsStripeCount( const string& coname, const string& name,
00418 unsigned long stripes );
00419 int changeEvmsStripeSize( const string& coname, const string& name,
00420 unsigned long long stripeSize );
00421 void setNoEvms( bool val );
00422 bool getNoEvms() { return( no_evms ); }
00423 static bool getNoEv() { return( no_evms ); }
00424
00425 int createMd( const string& name, storage::MdType rtype,
00426 const deque<string>& devs );
00427 int createMdAny( storage::MdType rtype, const deque<string>& devs,
00428 string& device );
00429 int removeMd( const string& name, bool destroySb=true );
00430 int extendMd( const string& name, const string& dev );
00431 int shrinkMd( const string& name, const string& dev );
00432 int changeMdType( const string& name, storage::MdType rtype );
00433 int changeMdChunk( const string& name, unsigned long chunk );
00434 int changeMdParity( const string& name, storage::MdParity ptype );
00435 int checkMd( const string& name );
00436
00437 int addNfsDevice( const string& nfsDev, const string& opts,
00438 unsigned long long sizeK, const string& mp );
00439 int checkNfsDevice( const string& nfsDev, const string& opts,
00440 unsigned long long& sizeK );
00441
00442 int createFileLoop( const string& lname, bool reuseExisting,
00443 unsigned long long sizeK, const string& mp,
00444 const string& pwd, string& device );
00445 int modifyFileLoop( const string& device, const string& lname,
00446 bool reuseExisting, unsigned long long sizeK );
00447 int removeFileLoop( const string& lname, bool removeFile );
00448
00449 int removeDmraid( const string& name );
00450
00451 deque<string> getCommitActions( bool mark_destructive );
00452 const string& getLastAction() const { return lastAction; }
00453 const string& getExtendedErrorMessage() const { return extendedError; }
00454 void eraseFreeInfo( const string& device );
00455 int waitForDevice() const;
00456 int waitForDevice( const string& device ) const;
00457 void checkDeviceExclusive( const string& device, unsigned secs );
00458 void getDiskList( bool (* CheckFnc)( const Disk& ),
00459 std::list<Disk*>& dl );
00460 void changeDeviceName( const string& old, const string& nw );
00461
00462 int commit();
00463 void handleHald( bool stop );
00464 void activateHld( bool val=true );
00465 void removeDmTableTo( const Volume& vol );
00466 void removeDmTableTo( const string& device );
00467 bool removeDmTable( const string& table );
00468 bool removeDmMapsTo( const string& dev, bool also_evms=false );
00469 bool checkDmMapsTo( const string& dev );
00470 void updateDmEmptyPeMap();
00471 void dumpObjectList();
00472
00473 void setCallbackProgressBar( storage::CallbackProgressBar pfnc )
00474 { progress_bar_cb=pfnc; }
00475 storage::CallbackProgressBar getCallbackProgressBar() const
00476 { return progress_bar_cb; }
00477 void setCallbackShowInstallInfo( storage::CallbackShowInstallInfo pfnc )
00478 { install_info_cb=pfnc; }
00479 storage::CallbackShowInstallInfo getCallbackShowInstallInfo() const
00480 { return install_info_cb; }
00481 void setCallbackInfoPopup( storage::CallbackInfoPopup pfnc )
00482 { info_popup_cb=pfnc; }
00483 storage::CallbackInfoPopup getCallbackInfoPopup() const
00484 { return info_popup_cb; }
00485 void setCallbackYesNoPopup( storage::CallbackYesNoPopup pfnc )
00486 { yesno_popup_cb=pfnc; }
00487 storage::CallbackYesNoPopup getCallbackYesNoPopup() const
00488 { return yesno_popup_cb; }
00489 void addInfoPopupText( const string& disk, const string txt );
00490
00491 static void setCallbackProgressBarYcp( storage::CallbackProgressBar pfnc )
00492 { progress_bar_cb_ycp=pfnc; }
00493 static storage::CallbackProgressBar getCallbackProgressBarYcp()
00494 { return progress_bar_cb_ycp; }
00495 static void setCallbackShowInstallInfoYcp( storage::CallbackShowInstallInfo pfnc )
00496 { install_info_cb_ycp=pfnc; }
00497 static storage::CallbackShowInstallInfo getCallbackShowInstallInfoYcp()
00498 { return install_info_cb_ycp; }
00499 static void setCallbackInfoPopupYcp( storage::CallbackInfoPopup pfnc )
00500 { info_popup_cb_ycp=pfnc; }
00501 static storage::CallbackInfoPopup getCallbackInfoPopupYcp()
00502 { return info_popup_cb_ycp; }
00503 static void setCallbackYesNoPopupYcp( storage::CallbackYesNoPopup pfnc )
00504 { yesno_popup_cb_ycp=pfnc; }
00505 static storage::CallbackYesNoPopup getCallbackYesNoPopupYcp()
00506 { return yesno_popup_cb_ycp; }
00507
00508 storage::CallbackProgressBar getCallbackProgressBarTheOne() const
00509 { return progress_bar_cb ? progress_bar_cb : progress_bar_cb_ycp; }
00510 storage::CallbackShowInstallInfo getCallbackShowInstallInfoTheOne() const
00511 { return install_info_cb ? install_info_cb : install_info_cb_ycp; }
00512 storage::CallbackInfoPopup getCallbackInfoPopupTheOne() const
00513 { return info_popup_cb ? info_popup_cb : info_popup_cb_ycp; }
00514 storage::CallbackYesNoPopup getCallbackYesNoPopupTheOne() const
00515 { return yesno_popup_cb ? yesno_popup_cb : yesno_popup_cb_ycp; }
00516
00517 void progressBarCb( const string& id, unsigned cur, unsigned max );
00518 void showInfoCb( const string& info );
00519 void infoPopupCb( const string& info );
00520 bool yesnoPopupCb( const string& info );
00521
00522
00523 protected:
00524
00525 template< class Pred >
00526 struct ConstContainerPI { typedef ContainerIter<Pred, CCIter> type; };
00527 typedef CheckFnc<const Container> CheckFncCont;
00528 typedef CheckerIterator< CheckFncCont, ConstContainerPI<CheckFncCont>::type,
00529 CCIter, Container > ConstContPIterator;
00530 template< class Pred >
00531 struct ContainerPI { typedef ContainerIter<Pred, CIter> type; };
00532 template< class Pred >
00533 struct ContainerI
00534 { typedef ContainerDerIter<Pred, typename ContainerPI<Pred>::type,
00535 Container> type; };
00536 typedef CheckerIterator< CheckFncCont, ContainerPI<CheckFncCont>::type,
00537 CIter, Container > ContPIterator;
00538 typedef DerefIterator<ContPIterator,Container> ContIterator;
00539 typedef IterPair<ContIterator> CPair;
00540
00541 public:
00542
00543 template< class Pred >
00544 struct ConstContainerI
00545 { typedef ContainerDerIter<Pred, typename ConstContainerPI<Pred>::type,
00546 const Container> type; };
00547 template< class Pred >
00548 struct ContCondIPair { typedef MakeCondIterPair<Pred,
00549 typename ConstContainerI<Pred>::type> type;};
00550 typedef DerefIterator<ConstContPIterator,const Container> ConstContIterator;
00551 typedef IterPair<ConstContIterator> ConstContPair;
00552
00553
00554 ConstContPair contPair( bool (* CheckFnc)( const Container& )=NULL ) const
00555 {
00556 return( ConstContPair( contBegin( CheckFnc ), contEnd( CheckFnc ) ));
00557 }
00558 ConstContIterator contBegin( bool (* CheckFnc)( const Container& )=NULL ) const
00559 {
00560 return( ConstContIterator( ConstContPIterator( cont.begin(), cont.end(), CheckFnc )) );
00561 }
00562 ConstContIterator contEnd( bool (* CheckFnc)( const Container& )=NULL ) const
00563 {
00564 return( ConstContIterator( ConstContPIterator( cont.begin(), cont.end(), CheckFnc, true )) );
00565 }
00566 template< class Pred > typename ContCondIPair<Pred>::type contCondPair( const Pred& p ) const
00567 {
00568 return( typename ContCondIPair<Pred>::type( contCondBegin( p ), contCondEnd( p ) ) );
00569 }
00570 template< class Pred > typename ConstContainerI<Pred>::type contCondBegin( const Pred& p ) const
00571 {
00572 return( typename ConstContainerI<Pred>::type( typename ConstContainerPI<Pred>::type( cont.begin(), cont.end(), p )) );
00573 }
00574 template< class Pred > typename ConstContainerI<Pred>::type contCondEnd( const Pred& p ) const
00575 {
00576 return( typename ConstContainerI<Pred>::type( typename ConstContainerPI<Pred>::type( cont.begin(), cont.end(), p, true )) );
00577 }
00578 protected:
00579
00580 CPair cPair( bool (* CheckFnc)( const Container& )=NULL )
00581 {
00582 return( CPair( cBegin(CheckFnc), cEnd(CheckFnc) ));
00583 }
00584 ContIterator cBegin( bool (* CheckFnc)( const Container& )=NULL )
00585 {
00586 return( ContIterator( ContPIterator( cont.begin(), cont.end(), CheckFnc )) );
00587 }
00588 ContIterator cEnd( bool (* CheckFnc)( const Container& )=NULL )
00589 {
00590 return( ContIterator( ContPIterator( cont.begin(), cont.end(), CheckFnc, true )) );
00591 }
00592
00593
00594 protected:
00595
00596 typedef CastCheckIterator<CCIter, storage::DISK, const Disk *> ContainerCDiskIter;
00597 template< class Pred >
00598 struct ConstDiskPI { typedef ContainerIter<Pred, ContainerCDiskIter> type; };
00599 typedef CastCheckIterator<CIter, storage::DISK, Disk *> ContainerDiskIter;
00600 template< class Pred >
00601 struct DiskPI { typedef ContainerIter<Pred, ContainerDiskIter> type; };
00602 template< class Pred >
00603 struct DiskI { typedef ContainerDerIter<Pred, typename DiskPI<Pred>::type, Disk> type; };
00604 typedef CheckFnc<const Disk> CheckFncDisk;
00605 typedef CheckerIterator< CheckFncDisk, ConstDiskPI<CheckFncDisk>::type,
00606 ContainerCDiskIter, Disk > ConstDiskPIterator;
00607 typedef CheckerIterator< CheckFncDisk, DiskPI<CheckFncDisk>::type,
00608 ContainerDiskIter, Disk > DiskPIterator;
00609 typedef DerefIterator<DiskPIterator,Disk> DiskIterator;
00610 typedef IterPair<DiskIterator> DiskPair;
00611
00612 public:
00613
00614 typedef DerefIterator<ConstDiskPIterator,const Disk> ConstDiskIterator;
00615 template< class Pred >
00616 struct ConstDiskI
00617 { typedef ContainerDerIter<Pred, typename ConstDiskPI<Pred>::type,
00618 const Disk> type; };
00619 template< class Pred >
00620 struct DiskCondIPair { typedef MakeCondIterPair<Pred, typename ConstDiskI<Pred>::type> type; };
00621 typedef IterPair<ConstDiskIterator> ConstDiskPair;
00622
00623
00624 ConstDiskPair diskPair( bool (* CheckFnc)( const Disk& )=NULL ) const
00625 {
00626 return( ConstDiskPair( diskBegin( CheckFnc ), diskEnd( CheckFnc ) ));
00627 }
00628 ConstDiskIterator diskBegin( bool (* CheckFnc)( const Disk& )=NULL ) const
00629 {
00630 IterPair<ContainerCDiskIter> p( ContainerCDiskIter( cont.begin(), cont.end() ),
00631 ContainerCDiskIter( cont.begin(), cont.end(), true ));
00632 return( ConstDiskIterator( ConstDiskPIterator( p, CheckFnc )) );
00633 }
00634 ConstDiskIterator diskEnd( bool (* CheckFnc)( const Disk& )=NULL ) const
00635 {
00636 IterPair<ContainerCDiskIter> p( ContainerCDiskIter( cont.begin(), cont.end() ),
00637 ContainerCDiskIter( cont.begin(), cont.end(), true ));
00638 return( ConstDiskIterator( ConstDiskPIterator( p, CheckFnc, true )) );
00639 }
00640 template< class Pred > typename DiskCondIPair<Pred>::type diskCondPair( const Pred& p ) const
00641 {
00642 return( typename DiskCondIPair<Pred>::type( diskCondBegin( p ), diskCondEnd( p ) ) );
00643 }
00644 template< class Pred > typename ConstDiskI<Pred>::type diskCondBegin( const Pred& p ) const
00645 {
00646 IterPair<ContainerCDiskIter> pair( ContainerCDiskIter( cont.begin(), cont.end() ),
00647 ContainerCDiskIter( cont.begin(), cont.end(), true ));
00648 return( typename ConstDiskI<Pred>::type( typename ConstDiskPI<Pred>::type( pair, p )) );
00649 }
00650 template< class Pred > typename ConstDiskI<Pred>::type diskCondEnd( const Pred& p ) const
00651 {
00652 IterPair<ContainerCDiskIter> pair( ContainerCDiskIter( cont.begin(), cont.end() ),
00653 ContainerCDiskIter( cont.begin(), cont.end(), true ));
00654 return( typename ConstDiskI<Pred>::type( typename ConstDiskPI<Pred>::type( pair, p, true )) );
00655 }
00656 protected:
00657
00658 DiskPair dPair( bool (* CheckFnc)( const Disk& )=NULL )
00659 {
00660 return( DiskPair( dBegin( CheckFnc ), dEnd( CheckFnc ) ));
00661 }
00662 DiskIterator dBegin( bool (* CheckFnc)( const Disk& )=NULL )
00663 {
00664 IterPair<ContainerDiskIter> p( ContainerDiskIter( cont.begin(), cont.end() ),
00665 ContainerDiskIter( cont.begin(), cont.end(), true ));
00666 return( DiskIterator( DiskPIterator( p, CheckFnc )) );
00667 }
00668 DiskIterator dEnd( bool (* CheckFnc)( const Disk& )=NULL )
00669 {
00670 IterPair<ContainerDiskIter> p( ContainerDiskIter( cont.begin(), cont.end() ),
00671 ContainerDiskIter( cont.begin(), cont.end(), true ));
00672 return( DiskIterator( DiskPIterator( p, CheckFnc, true )) );
00673 }
00674
00675
00676
00677 protected:
00678
00679 typedef CastCheckIterator<CCIter, storage::LVM, const LvmVg *> ContainerCLvmVgIter;
00680 template< class Pred >
00681 struct ConstLvmVgPI { typedef ContainerIter<Pred, ContainerCLvmVgIter> type; };
00682 typedef CastCheckIterator<CIter, storage::LVM, LvmVg *> ContainerLvmVgIter;
00683 template< class Pred >
00684 struct LvmVgPI { typedef ContainerIter<Pred, ContainerLvmVgIter> type; };
00685 template< class Pred >
00686 struct LvmVgI { typedef ContainerDerIter<Pred, typename LvmVgPI<Pred>::type, LvmVg> type; };
00687 typedef CheckFnc<const LvmVg> CheckFncLvmVg;
00688 typedef CheckerIterator< CheckFncLvmVg, ConstLvmVgPI<CheckFncLvmVg>::type,
00689 ContainerCLvmVgIter, LvmVg > ConstLvmVgPIterator;
00690 typedef CheckerIterator< CheckFncLvmVg, LvmVgPI<CheckFncLvmVg>::type,
00691 ContainerLvmVgIter, LvmVg > LvmVgPIterator;
00692 typedef DerefIterator<LvmVgPIterator,LvmVg> LvmVgIterator;
00693 typedef IterPair<LvmVgIterator> LvmVgPair;
00694
00695 public:
00696
00697 typedef DerefIterator<ConstLvmVgPIterator,const LvmVg> ConstLvmVgIterator;
00698 template< class Pred >
00699 struct ConstLvmVgI
00700 { typedef ContainerDerIter<Pred, typename ConstLvmVgPI<Pred>::type,
00701 const LvmVg> type; };
00702 template< class Pred >
00703 struct LvmVgCondIPair { typedef MakeCondIterPair<Pred, typename ConstLvmVgI<Pred>::type> type; };
00704 typedef IterPair<ConstLvmVgIterator> ConstLvmVgPair;
00705
00706
00707 ConstLvmVgPair lvmVgPair( bool (* CheckFnc)( const LvmVg& )=NULL ) const
00708 {
00709 return( ConstLvmVgPair( lvmVgBegin( CheckFnc ), lvmVgEnd( CheckFnc ) ));
00710 }
00711 ConstLvmVgIterator lvmVgBegin( bool (* CheckFnc)( const LvmVg& )=NULL ) const
00712 {
00713 IterPair<ContainerCLvmVgIter> p( ContainerCLvmVgIter( cont.begin(), cont.end() ),
00714 ContainerCLvmVgIter( cont.begin(), cont.end(), true ));
00715 return( ConstLvmVgIterator( ConstLvmVgPIterator( p, CheckFnc )) );
00716 }
00717 ConstLvmVgIterator lvmVgEnd( bool (* CheckFnc)( const LvmVg& )=NULL ) const
00718 {
00719 IterPair<ContainerCLvmVgIter> p( ContainerCLvmVgIter( cont.begin(), cont.end() ),
00720 ContainerCLvmVgIter( cont.begin(), cont.end(), true ));
00721 return( ConstLvmVgIterator( ConstLvmVgPIterator( p, CheckFnc, true )) );
00722 }
00723 template< class Pred > typename LvmVgCondIPair<Pred>::type lvmVgCondPair( const Pred& p ) const
00724 {
00725 return( typename LvmVgCondIPair<Pred>::type( lvmVgCondBegin( p ), lvmVgCondEnd( p ) ) );
00726 }
00727 template< class Pred > typename ConstLvmVgI<Pred>::type lvmVgCondBegin( const Pred& p ) const
00728 {
00729 IterPair<ContainerCLvmVgIter> pair( ContainerCLvmVgIter( cont.begin(), cont.end() ),
00730 ContainerCLvmVgIter( cont.begin(), cont.end(), true ));
00731 return( typename ConstLvmVgI<Pred>::type( typename ConstLvmVgPI<Pred>::type( pair, p )) );
00732 }
00733 template< class Pred > typename ConstLvmVgI<Pred>::type lvmVgCondEnd( const Pred& p ) const
00734 {
00735 IterPair<ContainerCLvmVgIter> pair( ContainerCLvmVgIter( cont.begin(), cont.end() ),
00736 ContainerCLvmVgIter( cont.begin(), cont.end(), true ));
00737 return( typename ConstLvmVgI<Pred>::type( typename ConstLvmVgPI<Pred>::type( pair, p, true )) );
00738 }
00739 protected:
00740
00741 LvmVgPair lvgPair( bool (* CheckFnc)( const LvmVg& )=NULL )
00742 {
00743 return( LvmVgPair( lvgBegin( CheckFnc ), lvgEnd( CheckFnc ) ));
00744 }
00745 LvmVgIterator lvgBegin( bool (* CheckFnc)( const LvmVg& )=NULL )
00746 {
00747 IterPair<ContainerLvmVgIter> p( ContainerLvmVgIter( cont.begin(), cont.end() ),
00748 ContainerLvmVgIter( cont.begin(), cont.end(), true ));
00749 return( LvmVgIterator( LvmVgPIterator( p, CheckFnc )) );
00750 }
00751 LvmVgIterator lvgEnd( bool (* CheckFnc)( const LvmVg& )=NULL )
00752 {
00753 IterPair<ContainerLvmVgIter> p( ContainerLvmVgIter( cont.begin(), cont.end() ),
00754 ContainerLvmVgIter( cont.begin(), cont.end(), true ));
00755 return( LvmVgIterator( LvmVgPIterator( p, CheckFnc, true )) );
00756 }
00757
00758
00759 protected:
00760
00761 typedef CastCheckIterator<CCIter, storage::EVMS, const EvmsCo *> ContainerCEvmsIter;
00762 template< class Pred >
00763 struct ConstEvmsCoPI { typedef ContainerIter<Pred, ContainerCEvmsIter> type; };
00764 typedef CastCheckIterator<CIter, storage::EVMS, EvmsCo *> ContainerEvmsIter;
00765 template< class Pred >
00766 struct EvmsCoPI { typedef ContainerIter<Pred, ContainerEvmsIter> type; };
00767 template< class Pred >
00768 struct EvmsCoI { typedef ContainerDerIter<Pred, typename EvmsCoPI<Pred>::type, EvmsCo> type; };
00769 typedef CheckFnc<const EvmsCo> CheckFncEvmsCo;
00770 typedef CheckerIterator< CheckFncEvmsCo, ConstEvmsCoPI<CheckFncEvmsCo>::type,
00771 ContainerCEvmsIter, EvmsCo > ConstEvmsCoPIterator;
00772 typedef CheckerIterator< CheckFncEvmsCo, EvmsCoPI<CheckFncEvmsCo>::type,
00773 ContainerEvmsIter, EvmsCo > EvmsCoPIterator;
00774 typedef DerefIterator<EvmsCoPIterator,EvmsCo> EvmsCoIterator;
00775 typedef IterPair<EvmsCoIterator> EvmsCoPair;
00776
00777 public:
00778
00779 typedef DerefIterator<ConstEvmsCoPIterator,const EvmsCo> ConstEvmsCoIterator;
00780 template< class Pred >
00781 struct ConstEvmsCoI
00782 { typedef ContainerDerIter<Pred, typename ConstEvmsCoPI<Pred>::type,
00783 const EvmsCo> type; };
00784 template< class Pred >
00785 struct EvmsCoCondIPair { typedef MakeCondIterPair<Pred, typename ConstEvmsCoI<Pred>::type> type; };
00786 typedef IterPair<ConstEvmsCoIterator> ConstEvmsCoPair;
00787
00788
00789 ConstEvmsCoPair evmsCoPair( bool (* CheckFnc)( const EvmsCo& )=NULL ) const
00790 {
00791 return( ConstEvmsCoPair( evmsCoBegin( CheckFnc ), evmsCoEnd( CheckFnc ) ));
00792 }
00793 ConstEvmsCoIterator evmsCoBegin( bool (* CheckFnc)( const EvmsCo& )=NULL ) const
00794 {
00795 IterPair<ContainerCEvmsIter> p( ContainerCEvmsIter( cont.begin(), cont.end() ),
00796 ContainerCEvmsIter( cont.begin(), cont.end(), true ));
00797 return( ConstEvmsCoIterator( ConstEvmsCoPIterator( p, CheckFnc )) );
00798 }
00799 ConstEvmsCoIterator evmsCoEnd( bool (* CheckFnc)( const EvmsCo& )=NULL ) const
00800 {
00801 IterPair<ContainerCEvmsIter> p( ContainerCEvmsIter( cont.begin(), cont.end() ),
00802 ContainerCEvmsIter( cont.begin(), cont.end(), true ));
00803 return( ConstEvmsCoIterator( ConstEvmsCoPIterator( p, CheckFnc, true )) );
00804 }
00805 template< class Pred > typename EvmsCoCondIPair<Pred>::type evmsCoCondPair( const Pred& p ) const
00806 {
00807 return( typename EvmsCoCondIPair<Pred>::type( evmsCoCondBegin( p ), evmsCoCondEnd( p ) ) );
00808 }
00809 template< class Pred > typename ConstEvmsCoI<Pred>::type evmsCoCondBegin( const Pred& p ) const
00810 {
00811 IterPair<ContainerCEvmsIter> pair( ContainerCEvmsIter( cont.begin(), cont.end() ),
00812 ContainerCEvmsIter( cont.begin(), cont.end(), true ));
00813 return( typename ConstEvmsCoI<Pred>::type( typename ConstEvmsCoPI<Pred>::type( pair, p )) );
00814 }
00815 template< class Pred > typename ConstEvmsCoI<Pred>::type evmsCoCondEnd( const Pred& p ) const
00816 {
00817 IterPair<ContainerCEvmsIter> pair( ContainerCEvmsIter( cont.begin(), cont.end() ),
00818 ContainerCEvmsIter( cont.begin(), cont.end(), true ));
00819 return( typename ConstEvmsCoI<Pred>::type( typename ConstEvmsCoPI<Pred>::type( pair, p, true )) );
00820 }
00821 protected:
00822
00823 EvmsCoPair evCoPair( bool (* CheckFnc)( const EvmsCo& )=NULL )
00824 {
00825 return( EvmsCoPair( evCoBegin( CheckFnc ), evCoEnd( CheckFnc ) ));
00826 }
00827 EvmsCoIterator evCoBegin( bool (* CheckFnc)( const EvmsCo& )=NULL )
00828 {
00829 IterPair<ContainerEvmsIter> p( ContainerEvmsIter( cont.begin(), cont.end() ),
00830 ContainerEvmsIter( cont.begin(), cont.end(), true ));
00831 return( EvmsCoIterator( EvmsCoPIterator( p, CheckFnc )) );
00832 }
00833 EvmsCoIterator evCoEnd( bool (* CheckFnc)( const EvmsCo& )=NULL )
00834 {
00835 IterPair<ContainerEvmsIter> p( ContainerEvmsIter( cont.begin(), cont.end() ),
00836 ContainerEvmsIter( cont.begin(), cont.end(), true ));
00837 return( EvmsCoIterator( EvmsCoPIterator( p, CheckFnc, true )) );
00838 }
00839
00840
00841 protected:
00842
00843 typedef CastCheckFncIterator<CCIter, isDmPart, const DmPartCo *> ContainerCDmPartIter;
00844 template< class Pred >
00845 struct ConstDmPartCoPI { typedef ContainerIter<Pred, ContainerCDmPartIter> type; };
00846 typedef CastCheckFncIterator<CIter, isDmPart, DmPartCo *> ContainerDmPartIter;
00847 template< class Pred >
00848 struct DmPartCoPI { typedef ContainerIter<Pred, ContainerDmPartIter> type; };
00849 template< class Pred >
00850 struct DmPartCoI { typedef ContainerDerIter<Pred, typename DmPartCoPI<Pred>::type, DmPartCo> type; };
00851 typedef CheckFnc<const DmPartCo> CheckFncDmPartCo;
00852 typedef CheckerIterator< CheckFncDmPartCo, ConstDmPartCoPI<CheckFncDmPartCo>::type,
00853 ContainerCDmPartIter, DmPartCo > ConstDmPartCoPIterator;
00854 typedef CheckerIterator< CheckFncDmPartCo, DmPartCoPI<CheckFncDmPartCo>::type,
00855 ContainerDmPartIter, DmPartCo > DmPartCoPIterator;
00856 typedef DerefIterator<DmPartCoPIterator,DmPartCo> DmPartCoIterator;
00857 typedef IterPair<DmPartCoIterator> DmPartCoPair;
00858
00859 public:
00860
00861 typedef DerefIterator<ConstDmPartCoPIterator,const DmPartCo> ConstDmPartCoIterator;
00862 template< class Pred >
00863 struct ConstDmPartCoI
00864 { typedef ContainerDerIter<Pred, typename ConstDmPartCoPI<Pred>::type,
00865 const DmPartCo> type; };
00866 template< class Pred >
00867 struct DmPartCoCondIPair { typedef MakeCondIterPair<Pred, typename ConstDmPartCoI<Pred>::type> type; };
00868 typedef IterPair<ConstDmPartCoIterator> ConstDmPartCoPair;
00869
00870
00871 ConstDmPartCoPair dmpartCoPair( bool (* CheckFnc)( const DmPartCo& )=NULL ) const
00872 {
00873 return( ConstDmPartCoPair( dmpartCoBegin( CheckFnc ), dmpartCoEnd( CheckFnc ) ));
00874 }
00875 ConstDmPartCoIterator dmpartCoBegin( bool (* CheckFnc)( const DmPartCo& )=NULL ) const
00876 {
00877 IterPair<ContainerCDmPartIter> p( ContainerCDmPartIter( cont.begin(), cont.end() ),
00878 ContainerCDmPartIter( cont.begin(), cont.end(), true ));
00879 return( ConstDmPartCoIterator( ConstDmPartCoPIterator( p, CheckFnc )) );
00880 }
00881 ConstDmPartCoIterator dmpartCoEnd( bool (* CheckFnc)( const DmPartCo& )=NULL ) const
00882 {
00883 IterPair<ContainerCDmPartIter> p( ContainerCDmPartIter( cont.begin(), cont.end() ),
00884 ContainerCDmPartIter( cont.begin(), cont.end(), true ));
00885 return( ConstDmPartCoIterator( ConstDmPartCoPIterator( p, CheckFnc, true )) );
00886 }
00887 template< class Pred > typename DmPartCoCondIPair<Pred>::type dmPartCoCondPair( const Pred& p ) const
00888 {
00889 return( typename DmPartCoCondIPair<Pred>::type( dmpartCoCondBegin( p ), dmpartCoCondEnd( p ) ) );
00890 }
00891 template< class Pred > typename ConstDmPartCoI<Pred>::type dmpartCoCondBegin( const Pred& p ) const
00892 {
00893 IterPair<ContainerCDmPartIter> pair( ContainerCDmPartIter( cont.begin(), cont.end() ),
00894 ContainerCDmPartIter( cont.begin(), cont.end(), true ));
00895 return( typename ConstDmPartCoI<Pred>::type( typename ConstDmPartCoPI<Pred>::type( pair, p )) );
00896 }
00897 template< class Pred > typename ConstDmPartCoI<Pred>::type dmpartCoCondEnd( const Pred& p ) const
00898 {
00899 IterPair<ContainerCDmPartIter> pair( ContainerCDmPartIter( cont.begin(), cont.end() ),
00900 ContainerCDmPartIter( cont.begin(), cont.end(), true ));
00901 return( typename ConstDmPartCoI<Pred>::type( typename ConstDmPartCoPI<Pred>::type( pair, p, true )) );
00902 }
00903 protected:
00904
00905 DmPartCoPair dmpCoPair( bool (* CheckFnc)( const DmPartCo& )=NULL )
00906 {
00907 return( DmPartCoPair( dmpCoBegin( CheckFnc ), dmpCoEnd( CheckFnc ) ));
00908 }
00909 DmPartCoIterator dmpCoBegin( bool (* CheckFnc)( const DmPartCo& )=NULL )
00910 {
00911 IterPair<ContainerDmPartIter> p( ContainerDmPartIter( cont.begin(), cont.end() ),
00912 ContainerDmPartIter( cont.begin(), cont.end(), true ));
00913 return( DmPartCoIterator( DmPartCoPIterator( p, CheckFnc )) );
00914 }
00915 DmPartCoIterator dmpCoEnd( bool (* CheckFnc)( const DmPartCo& )=NULL )
00916 {
00917 IterPair<ContainerDmPartIter> p( ContainerDmPartIter( cont.begin(), cont.end() ),
00918 ContainerDmPartIter( cont.begin(), cont.end(), true ));
00919 return( DmPartCoIterator( DmPartCoPIterator( p, CheckFnc, true )) );
00920 }
00921
00922
00923 protected:
00924
00925 typedef CastCheckIterator<CCIter, storage::DMRAID, const DmraidCo *> ContainerCDmraidIter;
00926 template< class Pred >
00927 struct ConstDmraidCoPI { typedef ContainerIter<Pred, ContainerCDmraidIter> type; };
00928 typedef CastCheckIterator<CIter, storage::DMRAID, DmraidCo *> ContainerDmraidIter;
00929 template< class Pred >
00930 struct DmraidCoPI { typedef ContainerIter<Pred, ContainerDmraidIter> type; };
00931 template< class Pred >
00932 struct DmraidCoI { typedef ContainerDerIter<Pred, typename DmraidCoPI<Pred>::type, DmraidCo> type; };
00933 typedef CheckFnc<const DmraidCo> CheckFncDmraidCo;
00934 typedef CheckerIterator< CheckFncDmraidCo, ConstDmraidCoPI<CheckFncDmraidCo>::type,
00935 ContainerCDmraidIter, DmraidCo > ConstDmraidCoPIterator;
00936 typedef CheckerIterator< CheckFncDmraidCo, DmraidCoPI<CheckFncDmraidCo>::type,
00937 ContainerDmraidIter, DmraidCo > DmraidCoPIterator;
00938 typedef DerefIterator<DmraidCoPIterator,DmraidCo> DmraidCoIterator;
00939 typedef IterPair<DmraidCoIterator> DmraidCoPair;
00940
00941 public:
00942
00943 typedef DerefIterator<ConstDmraidCoPIterator,const DmraidCo> ConstDmraidCoIterator;
00944 template< class Pred >
00945 struct ConstDmraidCoI
00946 { typedef ContainerDerIter<Pred, typename ConstDmraidCoPI<Pred>::type,
00947 const DmraidCo> type; };
00948 template< class Pred >
00949 struct DmraidCoCondIPair { typedef MakeCondIterPair<Pred, typename ConstDmraidCoI<Pred>::type> type; };
00950 typedef IterPair<ConstDmraidCoIterator> ConstDmraidCoPair;
00951
00952
00953 ConstDmraidCoPair dmraidCoPair( bool (* CheckFnc)( const DmraidCo& )=NULL ) const
00954 {
00955 return( ConstDmraidCoPair( dmraidCoBegin( CheckFnc ), dmraidCoEnd( CheckFnc ) ));
00956 }
00957 ConstDmraidCoIterator dmraidCoBegin( bool (* CheckFnc)( const DmraidCo& )=NULL ) const
00958 {
00959 IterPair<ContainerCDmraidIter> p( ContainerCDmraidIter( cont.begin(), cont.end() ),
00960 ContainerCDmraidIter( cont.begin(), cont.end(), true ));
00961 return( ConstDmraidCoIterator( ConstDmraidCoPIterator( p, CheckFnc )) );
00962 }
00963 ConstDmraidCoIterator dmraidCoEnd( bool (* CheckFnc)( const DmraidCo& )=NULL ) const
00964 {
00965 IterPair<ContainerCDmraidIter> p( ContainerCDmraidIter( cont.begin(), cont.end() ),
00966 ContainerCDmraidIter( cont.begin(), cont.end(), true ));
00967 return( ConstDmraidCoIterator( ConstDmraidCoPIterator( p, CheckFnc, true )) );
00968 }
00969 template< class Pred > typename DmraidCoCondIPair<Pred>::type dmraidCoCondPair( const Pred& p ) const
00970 {
00971 return( typename DmraidCoCondIPair<Pred>::type( dmraidCoCondBegin( p ), dmraidCoCondEnd( p ) ) );
00972 }
00973 template< class Pred > typename ConstDmraidCoI<Pred>::type dmraidCoCondBegin( const Pred& p ) const
00974 {
00975 IterPair<ContainerCDmraidIter> pair( ContainerCDmraidIter( cont.begin(), cont.end() ),
00976 ContainerCDmraidIter( cont.begin(), cont.end(), true ));
00977 return( typename ConstDmraidCoI<Pred>::type( typename ConstDmraidCoPI<Pred>::type( pair, p )) );
00978 }
00979 template< class Pred > typename ConstDmraidCoI<Pred>::type dmraidCoCondEnd( const Pred& p ) const
00980 {
00981 IterPair<ContainerCDmraidIter> pair( ContainerCDmraidIter( cont.begin(), cont.end() ),
00982 ContainerCDmraidIter( cont.begin(), cont.end(), true ));
00983 return( typename ConstDmraidCoI<Pred>::type( typename ConstDmraidCoPI<Pred>::type( pair, p, true )) );
00984 }
00985 protected:
00986
00987 DmraidCoPair dmrCoPair( bool (* CheckFnc)( const DmraidCo& )=NULL )
00988 {
00989 return( DmraidCoPair( dmrCoBegin( CheckFnc ), dmrCoEnd( CheckFnc ) ));
00990 }
00991 DmraidCoIterator dmrCoBegin( bool (* CheckFnc)( const DmraidCo& )=NULL )
00992 {
00993 IterPair<ContainerDmraidIter> p( ContainerDmraidIter( cont.begin(), cont.end() ),
00994 ContainerDmraidIter( cont.begin(), cont.end(), true ));
00995 return( DmraidCoIterator( DmraidCoPIterator( p, CheckFnc )) );
00996 }
00997 DmraidCoIterator dmrCoEnd( bool (* CheckFnc)( const DmraidCo& )=NULL )
00998 {
00999 IterPair<ContainerDmraidIter> p( ContainerDmraidIter( cont.begin(), cont.end() ),
01000 ContainerDmraidIter( cont.begin(), cont.end(), true ));
01001 return( DmraidCoIterator( DmraidCoPIterator( p, CheckFnc, true )) );
01002 }
01003
01004
01005 protected:
01006
01007 typedef ListListIterator<Container::ConstPlainIterator, ConstContIterator> ConstVolInter;
01008 template< class Pred >
01009 struct ConstVolumePI { typedef ContainerIter<Pred, ConstVolInter> type; };
01010 typedef CheckFnc<const Volume> CheckFncVol;
01011 typedef CheckerIterator< CheckFncVol, ConstVolumePI<CheckFncVol>::type,
01012 ConstVolInter, Volume > ConstVolPIterator;
01013 typedef ListListIterator<Container::PlainIterator, ContIterator> VolPart;
01014 template< class Pred >
01015 struct VolumeI { typedef ContainerIter<Pred, VolPart> type; };
01016 typedef CheckerIterator< CheckFncVol, VolumeI<CheckFncVol>::type,
01017 VolPart, Volume > VolPIterator;
01018 typedef DerefIterator<VolPIterator,Volume> VolIterator;
01019 typedef IterPair<VolIterator> VPair;
01020
01021 public:
01022
01023 template< class Pred >
01024 struct ConstVolumeI { typedef ContainerDerIter<Pred, typename ConstVolumePI<Pred>::type, const Volume> type; };
01025 template< class Pred >
01026 struct VolCondIPair { typedef MakeCondIterPair<Pred, typename ConstVolumeI<Pred>::type> type;};
01027 typedef DerefIterator<ConstVolPIterator,const Volume> ConstVolIterator;
01028 typedef IterPair<ConstVolIterator> ConstVolPair;
01029
01030
01031 ConstVolPair volPair( bool (* CheckCnt)( const Container& )) const
01032 {
01033 return( ConstVolPair( volBegin( CheckCnt ), volEnd( CheckCnt ) ));
01034 }
01035 ConstVolPair volPair( bool (* CheckVol)( const Volume& )=NULL,
01036 bool (* CheckCnt)( const Container& )=NULL) const
01037 {
01038 return( ConstVolPair( volBegin( CheckVol, CheckCnt ),
01039 volEnd( CheckVol, CheckCnt ) ));
01040 }
01041 ConstVolIterator volBegin( bool (* CheckCnt)( const Container& )) const
01042 {
01043 return( volBegin( NULL, CheckCnt ) );
01044 }
01045 ConstVolIterator volBegin( bool (* CheckVol)( const Volume& )=NULL,
01046 bool (* CheckCnt)( const Container& )=NULL) const
01047 {
01048 IterPair<ConstVolInter> p( (ConstVolInter( contPair( CheckCnt ))),
01049 (ConstVolInter( contPair( CheckCnt ), true )));
01050 return( ConstVolIterator( ConstVolPIterator(p, CheckVol )));
01051 }
01052 ConstVolIterator volEnd( bool (* CheckCnt)( const Container& )) const
01053 {
01054 return( volEnd( NULL, CheckCnt ) );
01055 }
01056 ConstVolIterator volEnd( bool (* CheckVol)( const Volume& )=NULL,
01057 bool (* CheckCnt)( const Container& )=NULL) const
01058 {
01059 IterPair<ConstVolInter> p( (ConstVolInter( contPair( CheckCnt ))),
01060 (ConstVolInter( contPair( CheckCnt ), true )));
01061 return( ConstVolIterator( ConstVolPIterator(p, CheckVol, true )));
01062 }
01063 template< class Pred > typename VolCondIPair<Pred>::type volCondPair( const Pred& p ) const
01064 {
01065 return( typename VolCondIPair<Pred>::type( volCondBegin( p ), volCondEnd( p ) ) );
01066 }
01067 template< class Pred > typename ConstVolumeI<Pred>::type volCondBegin( const Pred& p ) const
01068 {
01069 IterPair<ConstVolInter> pair( (ConstVolInter( contPair())),
01070 (ConstVolInter( contPair(), true )));
01071 return( typename ConstVolumeI<Pred>::type( typename ConstVolumePI<Pred>::type(pair, p) ) );
01072 }
01073 template< class Pred > typename ConstVolumeI<Pred>::type volCondEnd( const Pred& p ) const
01074 {
01075 IterPair<ConstVolInter> pair( (ConstVolInter( contPair())),
01076 (ConstVolInter( contPair(), true )));
01077 return( typename ConstVolumeI<Pred>::type( typename ConstVolumePI<Pred>::type(pair, p, true )) );
01078 }
01079
01080 protected:
01081
01082 VPair vPair( bool (* CheckCnt)( const Container& ))
01083 {
01084 return( VPair( vBegin( CheckCnt ), vEnd( CheckCnt ) ));
01085 }
01086 VPair vPair( bool (* CheckVol)( const Volume& )=NULL,
01087 bool (* CheckCnt)( const Container& )=NULL)
01088 {
01089 return( VPair( vBegin( CheckVol, CheckCnt ),
01090 vEnd( CheckVol, CheckCnt ) ));
01091 }
01092 VolIterator vBegin( bool (* CheckCnt)( const Container& ))
01093 {
01094 return( vBegin( NULL, CheckCnt ) );
01095 }
01096 VolIterator vBegin( bool (* CheckVol)( const Volume& )=NULL,
01097 bool (* CheckCnt)( const Container& )=NULL)
01098 {
01099 IterPair<VolPart> p( (VolPart( cPair( CheckCnt ))),
01100 (VolPart( cPair( CheckCnt ), true )));
01101 return( VolIterator( VolPIterator( p, CheckVol )));
01102 }
01103 VolIterator vEnd( bool (* CheckCnt)( const Container& ))
01104 {
01105 return( vEnd( NULL, CheckCnt ) );
01106 }
01107 VolIterator vEnd( bool (* CheckVol)( const Volume& )=NULL,
01108 bool (* CheckCnt)( const Container& )=NULL)
01109 {
01110 IterPair<VolPart> p( (VolPart( cPair( CheckCnt ))),
01111 (VolPart( cPair( CheckCnt ), true )));
01112 return( VolIterator( VolPIterator( p, CheckVol, true )));
01113 }
01114
01115
01116 protected:
01117
01118 typedef ListListIterator<Container::ConstPlainIterator, ConstDiskIterator> ConstPartInter;
01119 typedef CastIterator<ConstPartInter, Partition *> ConstPartInter2;
01120 template< class Pred >
01121 struct ConstPartitionPI { typedef ContainerIter<Pred, ConstPartInter2> type; };
01122 typedef CheckFnc<const Partition> CheckFncPartition;
01123 typedef CheckerIterator< CheckFncPartition, ConstPartitionPI<CheckFncPartition>::type,
01124 ConstPartInter2, Partition > ConstPartPIterator;
01125 public:
01126
01127 template< class Pred >
01128 struct ConstPartitionI
01129 { typedef ContainerDerIter<Pred, typename ConstPartitionPI<Pred>::type,
01130 const Partition> type; };
01131 template< class Pred >
01132 struct PartCondIPair
01133 { typedef MakeCondIterPair<Pred, typename ConstPartitionI<Pred>::type> type;};
01134 typedef DerefIterator<ConstPartPIterator, const Partition> ConstPartIterator;
01135 typedef IterPair<ConstPartIterator> ConstPartPair;
01136
01137
01138 ConstPartPair partPair( bool (* CheckCnt)( const Disk& )) const
01139 {
01140 return( ConstPartPair( partBegin( CheckCnt ), partEnd( CheckCnt ) ));
01141 }
01142 ConstPartPair partPair( bool (* CheckPart)( const Partition& )=NULL,
01143 bool (* CheckCnt)( const Disk& )=NULL) const
01144 {
01145 return( ConstPartPair( partBegin( CheckPart, CheckCnt ),
01146 partEnd( CheckPart, CheckCnt ) ));
01147 }
01148 ConstPartIterator partBegin( bool (* CheckDisk)( const Disk& )) const
01149 {
01150 return( partBegin( NULL, CheckDisk ) );
01151 }
01152 ConstPartIterator partBegin( bool (* CheckPart)( const Partition& )=NULL,
01153 bool (* CheckDisk)( const Disk& )=NULL) const
01154 {
01155 IterPair<ConstPartInter2> p( (ConstPartInter(diskPair( CheckDisk ))),
01156 (ConstPartInter(diskPair( CheckDisk ), true )));
01157 return( ConstPartIterator( ConstPartPIterator(p, CheckPart )));
01158 }
01159 ConstPartIterator partEnd( bool (* CheckDisk)( const Disk& )) const
01160 {
01161 return( partEnd( NULL, CheckDisk ) );
01162 }
01163 ConstPartIterator partEnd( bool (* CheckPart)( const Partition& )=NULL,
01164 bool (* CheckDisk)( const Disk& )=NULL) const
01165 {
01166 IterPair<ConstPartInter2> p( (ConstPartInter(diskPair( CheckDisk ))),
01167 (ConstPartInter(diskPair( CheckDisk ), true )));
01168 return( ConstPartIterator( ConstPartPIterator(p, CheckPart, true )));
01169 }
01170 template< class Pred > typename PartCondIPair<Pred>::type partCondPair( const Pred& p ) const
01171 {
01172 return( typename PartCondIPair<Pred>::type( partCondBegin( p ), partCondEnd( p ) ) );
01173 }
01174 template< class Pred > typename ConstPartitionI<Pred>::type partCondBegin( const Pred& p ) const
01175 {
01176 IterPair<ConstPartInter2> pair( (ConstPartInter( diskPair())),
01177 (ConstPartInter( diskPair(), true )));
01178 return( typename ConstPartitionI<Pred>::type( typename ConstPartitionPI<Pred>::type(pair, p) ) );
01179 }
01180 template< class Pred > typename ConstPartitionI<Pred>::type partCondEnd( const Pred& p ) const
01181 {
01182 IterPair<ConstPartInter2> pair( (ConstPartInter( diskPair())),
01183 (ConstPartInter( diskPair(), true )));
01184 return( typename ConstPartitionI<Pred>::type( typename ConstPartitionPI<Pred>::type(pair, p, true )) );
01185 }
01186
01187
01188 protected:
01189
01190 typedef ListListIterator<Container::ConstPlainIterator, ConstLvmVgIterator> ConstLvmLvInter;
01191 typedef CastIterator<ConstLvmLvInter, LvmLv *> ConstLvmLvInter2;
01192 template< class Pred >
01193 struct ConstLvmLvPI { typedef ContainerIter<Pred, ConstLvmLvInter2> type; };
01194 typedef CheckFnc<const LvmLv> CheckFncLvmLv;
01195 typedef CheckerIterator< CheckFncLvmLv, ConstLvmLvPI<CheckFncLvmLv>::type,
01196 ConstLvmLvInter2, LvmLv > ConstLvmLvPIterator;
01197 public:
01198
01199 template< class Pred >
01200 struct ConstLvmLvI
01201 { typedef ContainerDerIter<Pred, typename ConstLvmLvPI<Pred>::type,
01202 const LvmLv> type; };
01203 template< class Pred >
01204 struct LvmLvCondIPair
01205 { typedef MakeCondIterPair<Pred, typename ConstLvmLvI<Pred>::type> type;};
01206 typedef DerefIterator<ConstLvmLvPIterator, const LvmLv> ConstLvmLvIterator;
01207 typedef IterPair<ConstLvmLvIterator> ConstLvmLvPair;
01208
01209
01210 ConstLvmLvPair lvmLvPair( bool (* CheckLvmVg)( const LvmVg& )) const
01211 {
01212 return( ConstLvmLvPair( lvmLvBegin( CheckLvmVg ), lvmLvEnd( CheckLvmVg ) ));
01213 }
01214 ConstLvmLvPair lvmLvPair( bool (* CheckLvmLv)( const LvmLv& )=NULL,
01215 bool (* CheckLvmVg)( const LvmVg& )=NULL) const
01216 {
01217 return( ConstLvmLvPair( lvmLvBegin( CheckLvmLv, CheckLvmVg ),
01218 lvmLvEnd( CheckLvmLv, CheckLvmVg ) ));
01219 }
01220 ConstLvmLvIterator lvmLvBegin( bool (* CheckLvmVg)( const LvmVg& )) const
01221 {
01222 return( lvmLvBegin( NULL, CheckLvmVg ) );
01223 }
01224 ConstLvmLvIterator lvmLvBegin( bool (* CheckLvmLv)( const LvmLv& )=NULL,
01225 bool (* CheckLvmVg)( const LvmVg& )=NULL) const
01226 {
01227 IterPair<ConstLvmLvInter2> p( (ConstLvmLvInter(lvmVgPair( CheckLvmVg ))),
01228 (ConstLvmLvInter(lvmVgPair( CheckLvmVg ), true )));
01229 return( ConstLvmLvIterator( ConstLvmLvPIterator(p, CheckLvmLv )));
01230 }
01231 ConstLvmLvIterator lvmLvEnd( bool (* CheckLvmVg)( const LvmVg& )) const
01232 {
01233 return( lvmLvEnd( NULL, CheckLvmVg ) );
01234 }
01235 ConstLvmLvIterator lvmLvEnd( bool (* CheckLvmLv)( const LvmLv& )=NULL,
01236 bool (* CheckLvmVg)( const LvmVg& )=NULL) const
01237 {
01238 IterPair<ConstLvmLvInter2> p( (ConstLvmLvInter(lvmVgPair( CheckLvmVg ))),
01239 (ConstLvmLvInter(lvmVgPair( CheckLvmVg ), true )));
01240 return( ConstLvmLvIterator( ConstLvmLvPIterator(p, CheckLvmLv, true )));
01241 }
01242 template< class Pred > typename LvmLvCondIPair<Pred>::type lvmLvCondPair( const Pred& p ) const
01243 {
01244 return( typename LvmLvCondIPair<Pred>::type( lvmLvCondBegin( p ), lvmLvCondEnd( p ) ) );
01245 }
01246 template< class Pred > typename ConstLvmLvI<Pred>::type lvmLvCondBegin( const Pred& p ) const
01247 {
01248 IterPair<ConstLvmLvInter2> pair( (ConstLvmLvInter( lvmVgPair())),
01249 (ConstLvmLvInter( lvmVgPair(), true )));
01250 return( typename ConstLvmLvI<Pred>::type( typename ConstLvmLvPI<Pred>::type(pair, p) ) );
01251 }
01252 template< class Pred > typename ConstLvmLvI<Pred>::type lvmLvCondEnd( const Pred& p ) const
01253 {
01254 IterPair<ConstLvmLvInter2> pair( (ConstLvmLvInter( lvmVgPair())),
01255 (ConstLvmLvInter( lvmVgPair(), true )));
01256 return( typename ConstLvmLvI<Pred>::type( typename ConstLvmLvPI<Pred>::type(pair, p, true )) );
01257 }
01258
01259
01260 protected:
01261
01262 typedef ListListIterator<Container::ConstPlainIterator, ConstEvmsCoIterator> ConstEvmsInter;
01263 typedef CastIterator<ConstEvmsInter, Evms *> ConstEvmsInter2;
01264 template< class Pred >
01265 struct ConstEvmsPI { typedef ContainerIter<Pred, ConstEvmsInter2> type; };
01266 typedef CheckFnc<const Evms> CheckFncEvms;
01267 typedef CheckerIterator< CheckFncEvms, ConstEvmsPI<CheckFncEvms>::type,
01268 ConstEvmsInter2, Evms > ConstEvmsPIterator;
01269 public:
01270
01271 template< class Pred >
01272 struct ConstEvmsI
01273 { typedef ContainerDerIter<Pred, typename ConstEvmsPI<Pred>::type,
01274 const Evms> type; };
01275 template< class Pred >
01276 struct EvmsCondIPair
01277 { typedef MakeCondIterPair<Pred, typename ConstEvmsI<Pred>::type> type;};
01278 typedef DerefIterator<ConstEvmsPIterator, const Evms> ConstEvmsIterator;
01279 typedef IterPair<ConstEvmsIterator> ConstEvmsPair;
01280
01281
01282 ConstEvmsPair evmsPair( bool (* CheckEvmsCo)( const EvmsCo& )) const
01283 {
01284 return( ConstEvmsPair( evmsBegin( CheckEvmsCo ), evmsEnd( CheckEvmsCo ) ));
01285 }
01286 ConstEvmsPair evmsPair( bool (* CheckEvms)( const Evms& )=NULL,
01287 bool (* CheckEvmsCo)( const EvmsCo& )=NULL) const
01288 {
01289 return( ConstEvmsPair( evmsBegin( CheckEvms, CheckEvmsCo ),
01290 evmsEnd( CheckEvms, CheckEvmsCo ) ));
01291 }
01292 ConstEvmsIterator evmsBegin( bool (* CheckEvmsCo)( const EvmsCo& )) const
01293 {
01294 return( evmsBegin( NULL, CheckEvmsCo ) );
01295 }
01296 ConstEvmsIterator evmsBegin( bool (* CheckEvms)( const Evms& )=NULL,
01297 bool (* CheckEvmsCo)( const EvmsCo& )=NULL) const
01298 {
01299 IterPair<ConstEvmsInter2> p( (ConstEvmsInter(evmsCoPair( CheckEvmsCo ))),
01300 (ConstEvmsInter(evmsCoPair( CheckEvmsCo ), true )));
01301 return( ConstEvmsIterator( ConstEvmsPIterator(p, CheckEvms )));
01302 }
01303 ConstEvmsIterator evmsEnd( bool (* CheckEvmsCo)( const EvmsCo& )) const
01304 {
01305 return( evmsEnd( NULL, CheckEvmsCo ) );
01306 }
01307 ConstEvmsIterator evmsEnd( bool (* CheckEvms)( const Evms& )=NULL,
01308 bool (* CheckEvmsCo)( const EvmsCo& )=NULL) const
01309 {
01310 IterPair<ConstEvmsInter2> p( (ConstEvmsInter(evmsCoPair( CheckEvmsCo ))),
01311 (ConstEvmsInter(evmsCoPair( CheckEvmsCo ), true )));
01312 return( ConstEvmsIterator( ConstEvmsPIterator(p, CheckEvms, true )));
01313 }
01314 template< class Pred > typename EvmsCondIPair<Pred>::type evmsCondPair( const Pred& p ) const
01315 {
01316 return( typename EvmsCondIPair<Pred>::type( evmsCondBegin( p ), evmsCondEnd( p ) ) );
01317 }
01318 template< class Pred > typename ConstEvmsI<Pred>::type evmsCondBegin( const Pred& p ) const
01319 {
01320 IterPair<ConstEvmsInter2> pair( (ConstEvmsInter( evmsCoPair())),
01321 (ConstEvmsInter( evmsCoPair(), true )));
01322 return( typename ConstEvmsI<Pred>::type( typename ConstEvmsPI<Pred>::type(pair, p) ) );
01323 }
01324 template< class Pred > typename ConstEvmsI<Pred>::type evmsCondEnd( const Pred& p ) const
01325 {
01326 IterPair<ConstEvmsInter2> pair( (ConstEvmsInter( evmsCoPair())),
01327 (ConstEvmsInter( evmsCoPair(), true )));
01328 return( typename ConstEvmsI<Pred>::type( typename ConstEvmsPI<Pred>::type(pair, p, true )) );
01329 }
01330
01331
01332 protected:
01333
01334 typedef CastIterator<ConstVolInter, Md *> ConstMdInter;
01335 template< class Pred >
01336 struct ConstMdPI { typedef ContainerIter<Pred,
01337 ConstMdInter> type; };
01338 typedef CheckFnc<const Md> CheckFncMd;
01339 typedef CheckerIterator< CheckFncMd, ConstMdPI<CheckFncMd>::type,
01340 ConstMdInter, Md > ConstMdPIterator;
01341 public:
01342
01343 template< class Pred >
01344 struct ConstMdI
01345 { typedef ContainerDerIter<Pred, typename ConstMdPI<Pred>::type,
01346 const Md> type; };
01347 template< class Pred >
01348 struct MdCondIPair
01349 { typedef MakeCondIterPair<Pred, typename ConstMdI<Pred>::type> type;};
01350 typedef DerefIterator<ConstMdPIterator, const Md> ConstMdIterator;
01351 typedef IterPair<ConstMdIterator> ConstMdPair;
01352
01353
01354 ConstMdPair mdPair( bool (* CheckMd)( const Md& )=NULL ) const
01355 {
01356 return( ConstMdPair( mdBegin( CheckMd ), mdEnd( CheckMd ) ));
01357 }
01358 ConstMdIterator mdBegin( bool (* CheckMd)( const Md& )=NULL ) const
01359 {
01360 ConstVolInter b( contPair( isMd ) );
01361 ConstVolInter e( contPair( isMd ), true );
01362 IterPair<ConstMdInter> p( (ConstMdInter(b)), (ConstMdInter(e)) );
01363 return( ConstMdIterator( ConstMdPIterator(p, CheckMd )));
01364 }
01365 ConstMdIterator mdEnd( bool (* CheckMd)( const Md& )=NULL ) const
01366 {
01367 ConstVolInter b( contPair( isMd ) );
01368 ConstVolInter e( contPair( isMd ), true );
01369 IterPair<ConstMdInter> p( (ConstMdInter(b)), (ConstMdInter(e)) );
01370 return( ConstMdIterator( ConstMdPIterator(p, CheckMd, true )));
01371 }
01372 template< class Pred > typename MdCondIPair<Pred>::type mdCondPair( const Pred& p ) const
01373 {
01374 return( typename MdCondIPair<Pred>::type( mdCondBegin( p ), mdCondEnd( p ) ) );
01375 }
01376 template< class Pred > typename ConstMdI<Pred>::type mdCondBegin( const Pred& p ) const
01377 {
01378 ConstVolInter b( contPair( isMd ) );
01379 ConstVolInter e( contPair( isMd ), true );
01380 IterPair<ConstMdInter> pair( (ConstMdInter(b)), (ConstMdInter(e)) );
01381 return( typename ConstMdI<Pred>::type( typename ConstMdPI<Pred>::type(pair, p) ) );
01382 }
01383 template< class Pred > typename ConstMdI<Pred>::type mdCondEnd( const Pred& p ) const
01384 {
01385 ConstVolInter b( contPair( isMd ) );
01386 ConstVolInter e( contPair( isMd ), true );
01387 IterPair<ConstMdInter> pair( (ConstMdInter(b)), (ConstMdInter(e)) );
01388 return( typename ConstMdI<Pred>::type( typename ConstMdPI<Pred>::type(pair, p, true )) );
01389 }
01390
01391
01392 protected:
01393
01394 typedef CastIterator<ConstVolInter, Loop *> ConstLoopInter;
01395 template< class Pred >
01396 struct ConstLoopPI { typedef ContainerIter<Pred,
01397 ConstLoopInter> type; };
01398 typedef CheckFnc<const Loop> CheckFncLoop;
01399 typedef CheckerIterator< CheckFncLoop, ConstLoopPI<CheckFncLoop>::type,
01400 ConstLoopInter, Loop > ConstLoopPIterator;
01401 public:
01402
01403 template< class Pred >
01404 struct ConstLoopI
01405 { typedef ContainerDerIter<Pred, typename ConstLoopPI<Pred>::type,
01406 const Loop> type; };
01407 template< class Pred >
01408 struct LoopCondIPair
01409 { typedef MakeCondIterPair<Pred, typename ConstLoopI<Pred>::type> type;};
01410 typedef DerefIterator<ConstLoopPIterator, const Loop> ConstLoopIterator;
01411 typedef IterPair<ConstLoopIterator> ConstLoopPair;
01412
01413
01414 ConstLoopPair loopPair( bool (* CheckLoop)( const Loop& )=NULL ) const
01415 {
01416 return( ConstLoopPair( loopBegin( CheckLoop ), loopEnd( CheckLoop ) ));
01417 }
01418 ConstLoopIterator loopBegin( bool (* CheckLoop)( const Loop& )=NULL ) const
01419 {
01420 ConstVolInter b( contPair( isLoop ) );
01421 ConstVolInter e( contPair( isLoop ), true );
01422 IterPair<ConstLoopInter> p( (ConstLoopInter(b)), (ConstLoopInter(e)) );
01423 return( ConstLoopIterator( ConstLoopPIterator(p, CheckLoop )));
01424 }
01425 ConstLoopIterator loopEnd( bool (* CheckLoop)( const Loop& )=NULL ) const
01426 {
01427 ConstVolInter b( contPair( isLoop ) );
01428 ConstVolInter e( contPair( isLoop ), true );
01429 IterPair<ConstLoopInter> p( (ConstLoopInter(b)), (ConstLoopInter(e)) );
01430 return( ConstLoopIterator( ConstLoopPIterator(p, CheckLoop, true )));
01431 }
01432 template< class Pred > typename LoopCondIPair<Pred>::type loopCondPair( const Pred& p ) const
01433 {
01434 return( typename LoopCondIPair<Pred>::type( loopCondBegin( p ), loopCondEnd( p ) ) );
01435 }
01436 template< class Pred > typename ConstLoopI<Pred>::type loopCondBegin( const Pred& p ) const
01437 {
01438 ConstVolInter b( contPair( isLoop ) );
01439 ConstVolInter e( contPair( isLoop ), true );
01440 IterPair<ConstLoopInter> pair( (ConstLoopInter(b)), (ConstLoopInter(e)) );
01441 return( typename ConstLoopI<Pred>::type( typename ConstLoopPI<Pred>::type(pair, p) ) );
01442 }
01443 template< class Pred > typename ConstLoopI<Pred>::type loopCondEnd( const Pred& p ) const
01444 {
01445 ConstVolInter b( contPair( isLoop ) );
01446 ConstVolInter e( contPair( isLoop ), true );
01447 IterPair<ConstLoopInter> pair( (ConstLoopInter(b)), (ConstLoopInter(e)) );
01448 return( typename ConstLoopI<Pred>::type( typename ConstLoopPI<Pred>::type(pair, p, true )) );
01449 }
01450
01451
01452 protected:
01453
01454 typedef CastIterator<ConstVolInter, Nfs *> ConstNfsInter;
01455 template< class Pred >
01456 struct ConstNfsPI { typedef ContainerIter<Pred,
01457 ConstNfsInter> type; };
01458 typedef CheckFnc<const Nfs> CheckFncNfs;
01459 typedef CheckerIterator< CheckFncNfs, ConstNfsPI<CheckFncNfs>::type,
01460 ConstNfsInter, Nfs > ConstNfsPIterator;
01461 public:
01462
01463 template< class Pred >
01464 struct ConstNfsI
01465 { typedef ContainerDerIter<Pred, typename ConstNfsPI<Pred>::type,
01466 const Nfs> type; };
01467 template< class Pred >
01468 struct NfsCondIPair
01469 { typedef MakeCondIterPair<Pred, typename ConstNfsI<Pred>::type> type;};
01470 typedef DerefIterator<ConstNfsPIterator, const Nfs> ConstNfsIterator;
01471 typedef IterPair<ConstNfsIterator> ConstNfsPair;
01472
01473
01474 ConstNfsPair nfsPair( bool (* CheckNfs)( const Nfs& )=NULL ) const
01475 {
01476 return( ConstNfsPair( nfsBegin( CheckNfs ), nfsEnd( CheckNfs ) ));
01477 }
01478 ConstNfsIterator nfsBegin( bool (* CheckNfs)( const Nfs& )=NULL ) const
01479 {
01480 ConstVolInter b( contPair( isNfs ) );
01481 ConstVolInter e( contPair( isNfs ), true );
01482 IterPair<ConstNfsInter> p( (ConstNfsInter(b)), (ConstNfsInter(e)) );
01483 return( ConstNfsIterator( ConstNfsPIterator(p, CheckNfs )));
01484 }
01485 ConstNfsIterator nfsEnd( bool (* CheckNfs)( const Nfs& )=NULL ) const
01486 {
01487 ConstVolInter b( contPair( isNfs ) );
01488 ConstVolInter e( contPair( isNfs ), true );
01489 IterPair<ConstNfsInter> p( (ConstNfsInter(b)), (ConstNfsInter(e)) );
01490 return( ConstNfsIterator( ConstNfsPIterator(p, CheckNfs, true )));
01491 }
01492 template< class Pred > typename NfsCondIPair<Pred>::type nfsCondPair( const Pred& p ) const
01493 {
01494 return( typename NfsCondIPair<Pred>::type( nfsCondBegin( p ), nfsCondEnd( p ) ) );
01495 }
01496 template< class Pred > typename ConstNfsI<Pred>::type nfsCondBegin( const Pred& p ) const
01497 {
01498 ConstVolInter b( contPair( isNfs ) );
01499 ConstVolInter e( contPair( isNfs ), true );
01500 IterPair<ConstNfsInter> pair( (ConstNfsInter(b)), (ConstNfsInter(e)) );
01501 return( typename ConstNfsI<Pred>::type( typename ConstNfsPI<Pred>::type(pair, p) ) );
01502 }
01503 template< class Pred > typename ConstNfsI<Pred>::type nfsCondEnd( const Pred& p ) const
01504 {
01505 ConstVolInter b( contPair( isNfs ) );
01506 ConstVolInter e( contPair( isNfs ), true );
01507 IterPair<ConstNfsInter> pair( (ConstNfsInter(b)), (ConstNfsInter(e)) );
01508 return( typename ConstNfsI<Pred>::type( typename ConstNfsPI<Pred>::type(pair, p, true )) );
01509 }
01510
01511
01512 protected:
01513
01514 typedef CastIterator<ConstVolInter, Dm *> ConstDmInter;
01515 template< class Pred >
01516 struct ConstDmPI { typedef ContainerIter<Pred,
01517 ConstDmInter> type; };
01518 typedef CheckFnc<const Dm> CheckFncDm;
01519 typedef CheckerIterator< CheckFncDm, ConstDmPI<CheckFncDm>::type,
01520 ConstDmInter, Dm > ConstDmPIterator;
01521 public:
01522
01523 template< class Pred >
01524 struct ConstDmI
01525 { typedef ContainerDerIter<Pred, typename ConstDmPI<Pred>::type,
01526 const Dm> type; };
01527 template< class Pred >
01528 struct DmCondIPair
01529 { typedef MakeCondIterPair<Pred, typename ConstDmI<Pred>::type> type;};
01530 typedef DerefIterator<ConstDmPIterator, const Dm> ConstDmIterator;
01531 typedef IterPair<ConstDmIterator> ConstDmPair;
01532
01533
01534 ConstDmPair dmPair( bool (* CheckDm)( const Dm& )=NULL ) const
01535 {
01536 return( ConstDmPair( dmBegin( CheckDm ), dmEnd( CheckDm ) ));
01537 }
01538 ConstDmIterator dmBegin( bool (* CheckDm)( const Dm& )=NULL ) const
01539 {
01540 ConstVolInter b( contPair( isDm ) );
01541 ConstVolInter e( contPair( isDm ), true );
01542 IterPair<ConstDmInter> p( (ConstDmInter(b)), (ConstDmInter(e)) );
01543 return( ConstDmIterator( ConstDmPIterator(p, CheckDm )));
01544 }
01545 ConstDmIterator dmEnd( bool (* CheckDm)( const Dm& )=NULL ) const
01546 {
01547 ConstVolInter b( contPair( isDm ) );
01548 ConstVolInter e( contPair( isDm ), true );
01549 IterPair<ConstDmInter> p( (ConstDmInter(b)), (ConstDmInter(e)) );
01550 return( ConstDmIterator( ConstDmPIterator(p, CheckDm, true )));
01551 }
01552 template< class Pred > typename DmCondIPair<Pred>::type dmCondPair( const Pred& p ) const
01553 {
01554 return( typename DmCondIPair<Pred>::type( dmCondBegin( p ), dmCondEnd( p ) ) );
01555 }
01556 template< class Pred > typename ConstDmI<Pred>::type dmCondBegin( const Pred& p ) const
01557 {
01558 ConstVolInter b( contPair( isDm ) );
01559 ConstVolInter e( contPair( isDm ), true );
01560 IterPair<ConstDmInter> pair( (ConstDmInter(b)), (ConstDmInter(e)) );
01561 return( typename ConstDmI<Pred>::type( typename ConstDmPI<Pred>::type(pair, p) ) );
01562 }
01563 template< class Pred > typename ConstDmI<Pred>::type dmCondEnd( const Pred& p ) const
01564 {
01565 ConstVolInter b( contPair( isDm ) );
01566 ConstVolInter e( contPair( isDm ), true );
01567 IterPair<ConstDmInter> pair( (ConstDmInter(b)), (ConstDmInter(e)) );
01568 return( typename ConstDmI<Pred>::type( typename ConstDmPI<Pred>::type(pair, p, true )) );
01569 }
01570
01571
01572 protected:
01573
01574 typedef ListListIterator<Container::ConstPlainIterator, ConstDmraidCoIterator> ConstDmraidInter;
01575 typedef CastIterator<ConstDmraidInter, Dmraid *> ConstDmraidInter2;
01576 template< class Pred >
01577 struct ConstDmraidPI { typedef ContainerIter<Pred, ConstDmraidInter2> type; };
01578 typedef CheckFnc<const Dmraid> CheckFncDmraid;
01579 typedef CheckerIterator< CheckFncDmraid, ConstDmraidPI<CheckFncDmraid>::type,
01580 ConstDmraidInter2, Dmraid > ConstDmraidPIterator;
01581 public:
01582
01583 template< class Pred >
01584 struct ConstDmraidI
01585 { typedef ContainerDerIter<Pred, typename ConstDmraidPI<Pred>::type,
01586 const Dmraid> type; };
01587 template< class Pred >
01588 struct DmraidCondIPair
01589 { typedef MakeCondIterPair<Pred, typename ConstDmraidI<Pred>::type> type;};
01590 typedef DerefIterator<ConstDmraidPIterator, const Dmraid> ConstDmraidIterator;
01591 typedef IterPair<ConstDmraidIterator> ConstDmraidPair;
01592
01593
01594 ConstDmraidPair dmrPair( bool (* CheckDmraidCo)( const DmraidCo& )) const
01595 {
01596 return( ConstDmraidPair( dmrBegin( CheckDmraidCo ), dmrEnd( CheckDmraidCo ) ));
01597 }
01598 ConstDmraidPair dmrPair( bool (* CheckDmraid)( const Dmraid& )=NULL,
01599 bool (* CheckDmraidCo)( const DmraidCo& )=NULL) const
01600 {
01601 return( ConstDmraidPair( dmrBegin( CheckDmraid, CheckDmraidCo ),
01602 dmrEnd( CheckDmraid, CheckDmraidCo ) ));
01603 }
01604 ConstDmraidIterator dmrBegin( bool (* CheckDmraidCo)( const DmraidCo& )) const
01605 {
01606 return( dmrBegin( NULL, CheckDmraidCo ) );
01607 }
01608 ConstDmraidIterator dmrBegin( bool (* CheckDmraid)( const Dmraid& )=NULL,
01609 bool (* CheckDmraidCo)( const DmraidCo& )=NULL) const
01610 {
01611 IterPair<ConstDmraidInter2> p( (ConstDmraidInter(dmraidCoPair( CheckDmraidCo ))),
01612 (ConstDmraidInter(dmraidCoPair( CheckDmraidCo ), true )));
01613 return( ConstDmraidIterator( ConstDmraidPIterator(p, CheckDmraid )));
01614 }
01615 ConstDmraidIterator dmrEnd( bool (* CheckDmraidCo)( const DmraidCo& )) const
01616 {
01617 return( dmrEnd( NULL, CheckDmraidCo ) );
01618 }
01619 ConstDmraidIterator dmrEnd( bool (* CheckDmraid)( const Dmraid& )=NULL,
01620 bool (* CheckDmraidCo)( const DmraidCo& )=NULL) const
01621 {
01622 IterPair<ConstDmraidInter2> p( (ConstDmraidInter(dmraidCoPair( CheckDmraidCo ))),
01623 (ConstDmraidInter(dmraidCoPair( CheckDmraidCo ), true )));
01624 return( ConstDmraidIterator( ConstDmraidPIterator(p, CheckDmraid, true )));
01625 }
01626 template< class Pred > typename DmraidCondIPair<Pred>::type dmrCondPair( const Pred& p ) const
01627 {
01628 return( typename DmraidCondIPair<Pred>::type( dmrCondBegin( p ), dmrCondEnd( p ) ) );
01629 }
01630 template< class Pred > typename ConstDmraidI<Pred>::type dmrCondBegin( const Pred& p ) const
01631 {
01632 IterPair<ConstDmraidInter2> pair( (ConstDmraidInter( dmraidCoPair())),
01633 (ConstDmraidInter( dmraidCoPair(), true )));
01634 return( typename ConstDmraidI<Pred>::type( typename ConstDmraidPI<Pred>::type(pair, p) ) );
01635 }
01636 template< class Pred > typename ConstDmraidI<Pred>::type dmrCondEnd( const Pred& p ) const
01637 {
01638 IterPair<ConstDmraidInter2> pair( (ConstDmraidInter( dmrCoPair())),
01639 (ConstDmraidInter( dmrCoPair(), true )));
01640 return( typename ConstDmraidI<Pred>::type( typename ConstDmraidPI<Pred>::type(pair, p, true )) );
01641 }
01642
01643 protected:
01644
01645 void initialize();
01646 void detectDisks( ProcPart& ppart );
01647 void autodetectDisks( ProcPart& ppart );
01648 void detectMultipath();
01649 void detectMds();
01650 void detectLoops( ProcPart& ppart );
01651 void detectNfs( ProcMounts& mounts );
01652 void detectLvmVgs();
01653 void detectEvms();
01654 void detectDmraid( ProcPart& ppart );
01655 void detectDm( ProcPart& ppart );
01656 void initDisk( DiskData& data, ProcPart& pp );
01657 void detectFsData( const VolIterator& begin, const VolIterator& end,
01658 ProcMounts& mounts );
01659 void detectFsDataTestMode( const string& file,
01660 const VolIterator& begin,
01661 const VolIterator& end );
01662 int resizeVolume( const string& device, unsigned long long newSizeMb,
01663 bool ignore_fs );
01664 int resizePartition( const string& device, unsigned long sizeCyl,
01665 bool ignore_fs );
01666 static void detectArch();
01667 void addToList( Container* e )
01668 { pointerIntoSortedList<Container>( cont, e ); }
01669 DiskIterator findDisk( const string& disk );
01670 DiskIterator findDiskId( const string& id );
01671 DiskIterator findDiskPath( const string& path );
01672 LvmVgIterator findLvmVg( const string& name );
01673 EvmsCoIterator findEvmsCo( const string& name );
01674 DmraidCoIterator findDmraidCo( const string& name );
01675 DmPartCoIterator findDmPartCo( const string& name );
01676 bool findVolume( const string& device, ContIterator& c,
01677 VolIterator& v );
01678 bool findVolume( const string& device, VolIterator& v,
01679 bool also_del=false );
01680 bool findContainer( const string& device, ContIterator& c );
01681
01682 bool haveMd( MdCo*& md );
01683 bool haveNfs( NfsCo*& co );
01684 bool haveLoop( LoopCo*& loop );
01685 bool haveEvms();
01686 void handleEvmsRemoveDevice( const Disk* disk, const string& d,
01687 bool rename );
01688 void handleEvmsCreateDevice( const string& disk, const string& dev,
01689 bool extended=false );
01690
01691 int removeContainer( Container* val, bool call_del=true );
01692 void logVolumes( const string& Dir );
01693 int commitPair( CPair& p, bool (* fnc)( const Container& ) );
01694 void sortCommitLists( storage::CommitStage stage,
01695 std::list<Container*>& co,
01696 std::list<Volume*>& vl,
01697 std::list<storage::commitAction*>& todo );
01698 bool ignoreError( std::list<commitAction*>::iterator i,
01699 std::list<commitAction*>& al );
01700 void evmsActivateDevices();
01701 string backupStates() const;
01702 void detectObjects();
01703 void deleteClist( CCont& co );
01704 void deleteBackups();
01705 void setFreeInfo( const string& device, unsigned long long df_free,
01706 unsigned long long resize_free,
01707 unsigned long long used, bool win, bool efi,
01708 bool resize_ok );
01709 bool getFreeInf( const string& device, unsigned long long& df_free,
01710 unsigned long long& resize_free,
01711 unsigned long long& used, bool& win, bool& efi,
01712 bool& resize_ok );
01713
01714
01715 bool readonly;
01716 bool testmode;
01717 bool inst_sys;
01718 bool cache;
01719 bool initialized;
01720 bool autodetect;
01721 bool recursiveRemove;
01722 bool zeroNewPartitions;
01723 MountByType defaultMountBy;
01724 bool detectMounted;
01725 bool root_mounted;
01726 string testdir;
01727 string tempdir;
01728 string rootprefix;
01729 string logdir;
01730 unsigned hald_pid;
01731 static string proc_arch;
01732 static string sysfs_dir;
01733 static bool is_ppc_mac;
01734 static bool is_ppc_pegasos;
01735 static bool no_evms;
01736 CCont cont;
01737 EtcFstab *fstab;
01738
01739 storage::CallbackProgressBar progress_bar_cb;
01740 storage::CallbackShowInstallInfo install_info_cb;
01741 storage::CallbackInfoPopup info_popup_cb;
01742 storage::CallbackYesNoPopup yesno_popup_cb;
01743 static storage::CallbackProgressBar progress_bar_cb_ycp;
01744 static storage::CallbackShowInstallInfo install_info_cb_ycp;
01745 static storage::CallbackInfoPopup info_popup_cb_ycp;
01746 static storage::CallbackYesNoPopup yesno_popup_cb_ycp;
01747 friend std::ostream& operator<< (std::ostream& s, Storage &v );
01748
01749 unsigned max_log_num;
01750 string lastAction;
01751 string extendedError;
01752 std::map<string,CCont> backups;
01753 std::map<string,FreeInfo> freeInfo;
01754 std::list<std::pair<string,string> > infoPopupTxts;
01755 };
01756
01757 inline std::ostream& operator<< (std::ostream& s, commitAction &a )
01758 {
01759 s << "stage:" << a.stage
01760 << " type:" << a.type
01761 << " cont:" << a.container
01762 << " dest:" << a.destructive;
01763 if( a.container && a.co() )
01764 s << " name:" << a.co()->name();
01765 else if( a.vol() )
01766 s << " name:" << a.vol()->name();
01767 if( !a.descr.empty() )
01768 s << " desc:" << a.descr;
01769 return( s );
01770 };
01771
01772 }
01773
01774 #endif