|
yast2-storage
|
00001 /* 00002 * Copyright (c) [2004-2009] Novell, Inc. 00003 * 00004 * All Rights Reserved. 00005 * 00006 * This program is free software; you can redistribute it and/or modify it 00007 * under the terms of version 2 of the GNU General Public License as published 00008 * by the Free Software Foundation. 00009 * 00010 * This program is distributed in the hope that it will be useful, but WITHOUT 00011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 00013 * more details. 00014 * 00015 * You should have received a copy of the GNU General Public License along 00016 * with this program; if not, contact Novell, Inc. 00017 * 00018 * To contact Novell about this file by physical or electronic mail, you may 00019 * find current contact information at www.novell.com. 00020 */ 00021 00022 00023 #ifndef DMRAID_CO_H 00024 #define DMRAID_CO_H 00025 00026 #include <list> 00027 00028 #include "storage/DmPartCo.h" 00029 #include "storage/Dmraid.h" 00030 00031 namespace storage 00032 { 00033 class Storage; 00034 class SystemInfo; 00035 00036 00037 class CmdDmraid 00038 { 00039 00040 public: 00041 00042 CmdDmraid(); 00043 00044 struct Entry 00045 { 00046 string raidtype; 00047 string controller; 00048 list<string> devices; 00049 }; 00050 00051 list<string> getEntries() const; 00052 00053 bool getEntry(const string& name, Entry& entry) const; 00054 00055 private: 00056 00057 typedef map<string, Entry>::const_iterator const_iterator; 00058 00059 map<string, Entry> data; 00060 00061 }; 00062 00063 00064 class DmraidCo : public DmPartCo 00065 { 00066 friend class Storage; 00067 00068 public: 00069 00070 DmraidCo(Storage* s, const string& name, const string& device, SystemInfo& systeminfo); 00071 DmraidCo(const DmraidCo& c); 00072 virtual ~DmraidCo(); 00073 00074 static storage::CType staticType() { return storage::DMRAID; } 00075 friend std::ostream& operator<< (std::ostream&, const DmraidCo& ); 00076 void getInfo( storage::DmraidCoInfo& info ) const; 00077 void setUdevData(const list<string>& id); 00078 00079 bool equalContent( const Container& rhs ) const; 00080 00081 void logDifference(std::ostream& log, const DmraidCo& rhs) const; 00082 virtual void logDifferenceWithVolumes(std::ostream& log, const Container& rhs) const; 00083 00084 protected: 00085 00086 // iterators over partitions 00087 // protected typedefs for iterators over partitions 00088 typedef CastIterator<VIter, Dmraid *> DmraidInter; 00089 typedef CastIterator<CVIter, const Dmraid *> DmraidCInter; 00090 template< class Pred > 00091 struct DmraidPI { typedef ContainerIter<Pred, DmraidInter> type; }; 00092 template< class Pred > 00093 struct DmraidCPI { typedef ContainerIter<Pred, DmraidCInter> type; }; 00094 typedef CheckFnc<const Dmraid> CheckFncDmraid; 00095 typedef CheckerIterator< CheckFncDmraid, DmraidPI<CheckFncDmraid>::type, 00096 DmraidInter, Dmraid > DmraidPIterator; 00097 typedef CheckerIterator< CheckFncDmraid, DmraidCPI<CheckFncDmraid>::type, 00098 DmraidCInter, const Dmraid > DmraidCPIterator; 00099 typedef DerefIterator<DmraidPIterator,Dmraid> DmraidIter; 00100 typedef DerefIterator<DmraidCPIterator,const Dmraid> ConstDmraidIter; 00101 typedef IterPair<DmraidIter> DmraidPair; 00102 typedef IterPair<ConstDmraidIter> ConstDmraidPair; 00103 00104 DmraidPair dmraidPair( bool (* CheckDmraid)( const Dmraid& )=NULL) 00105 { 00106 return( DmraidPair( dmraidBegin( CheckDmraid ), dmraidEnd( CheckDmraid ) )); 00107 } 00108 DmraidIter dmraidBegin( bool (* CheckDmraid)( const Dmraid& )=NULL) 00109 { 00110 IterPair<DmraidInter> p( (DmraidInter(begin())), (DmraidInter(end())) ); 00111 return( DmraidIter( DmraidPIterator( p, CheckDmraid )) ); 00112 } 00113 DmraidIter dmraidEnd( bool (* CheckDmraid)( const Dmraid& )=NULL) 00114 { 00115 IterPair<DmraidInter> p( (DmraidInter(begin())), (DmraidInter(end())) ); 00116 return( DmraidIter( DmraidPIterator( p, CheckDmraid, true )) ); 00117 } 00118 00119 ConstDmraidPair dmraidPair( bool (* CheckDmraid)( const Dmraid& )=NULL) const 00120 { 00121 return( ConstDmraidPair( dmraidBegin( CheckDmraid ), dmraidEnd( CheckDmraid ) )); 00122 } 00123 ConstDmraidIter dmraidBegin( bool (* CheckDmraid)( const Dmraid& )=NULL) const 00124 { 00125 IterPair<DmraidCInter> p( (DmraidCInter(begin())), (DmraidCInter(end())) ); 00126 return( ConstDmraidIter( DmraidCPIterator( p, CheckDmraid )) ); 00127 } 00128 ConstDmraidIter dmraidEnd( bool (* CheckDmraid)( const Dmraid& )=NULL) const 00129 { 00130 IterPair<DmraidCInter> p( (DmraidCInter(begin())), (DmraidCInter(end())) ); 00131 return( ConstDmraidIter( DmraidCPIterator( p, CheckDmraid, true )) ); 00132 } 00133 00134 virtual void print( std::ostream& s ) const { s << *this; } 00135 virtual Container* getCopy() const { return( new DmraidCo( *this ) ); } 00136 static void activate(bool val); 00137 void getRaidData(const string& name, SystemInfo& systeminfo); 00138 void addPv(const Pv& pv); 00139 void newP( DmPart*& dm, unsigned num, Partition* p ); 00140 void newP( DmPart*& dm, unsigned num, Partition* p, SystemInfo& si ); 00141 00142 Text removeText( bool doing ) const; 00143 00144 static list<string> getRaids(SystemInfo& systeminfo); 00145 00146 int doRemove(); 00147 00148 string raidtype; 00149 string controller; 00150 00151 static bool active; 00152 00153 private: 00154 00155 DmraidCo& operator=(const DmraidCo&); // disallow 00156 00157 }; 00158 00159 } 00160 00161 #endif
1.7.3