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