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