1 /* Copyright (C) 2014 InfiniDB, Inc. 2 3 This program is free software; you can redistribute it and/or 4 modify it under the terms of the GNU General Public License 5 as published by the Free Software Foundation; version 2 of 6 the License. 7 8 This program is distributed in the hope that it will be useful, 9 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 GNU General Public License for more details. 12 13 You should have received a copy of the GNU General Public License 14 along with this program; if not, write to the Free Software 15 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 16 MA 02110-1301, USA. */ 17 18 /****************************************************************************** 19 * $Id: logicalpartition.h 1823 2013-01-21 14:13:09Z rdempsey $ 20 * 21 *****************************************************************************/ 22 23 /** @file 24 * Put LogicalPartition define here to avoid header file include confilct. 25 * This struct will be used in connector, brm and writeengine 26 */ 27 28 #ifndef LOGICALPARTITION_H_ 29 #define LOGICALPARTITION_H_ 30 31 #include "bytestream.h" 32 33 namespace BRM 34 { 35 // Logical partition number descriptor 36 struct LogicalPartition 37 { 38 uint16_t dbroot; // dbroot # 39 uint32_t pp; // physical partition # 40 uint16_t seg; // segment # 41 LogicalPartitionLogicalPartition42 LogicalPartition() : dbroot ((uint16_t) - 1), 43 pp ((uint32_t) - 1), 44 seg ((uint16_t) - 1) {} 45 LogicalPartitionLogicalPartition46 LogicalPartition(uint16_t d, uint32_t p, uint16_t s) : dbroot(d), 47 pp(p), 48 seg(s) 49 {} 50 51 bool operator<( const LogicalPartition& n ) const 52 { 53 return ((pp < n.pp) || 54 (pp == n.pp && seg < n.seg) || 55 (pp == n.pp && seg == n.seg && dbroot < n.dbroot)); 56 } 57 serializeLogicalPartition58 void serialize(messageqcpp::ByteStream& b) const 59 { 60 b << (uint16_t)dbroot; 61 b << (uint32_t)pp; 62 b << (uint16_t)seg; 63 } 64 unserializeLogicalPartition65 void unserialize(messageqcpp::ByteStream& b) 66 { 67 b >> (uint16_t&)dbroot; 68 b >> (uint32_t&)pp; 69 b >> (uint16_t&)seg; 70 } 71 72 /** @bug4816. For output to user purpose */ 73 std::string toString() const; 74 }; 75 76 /** 77 * ostream operator 78 */ 79 std::ostream& operator<<(std::ostream& output, const LogicalPartition& rhs); 80 std::istream& operator>>(std::istream& input, LogicalPartition& rhs); 81 82 /** 83 * bytestream operator 84 */ 85 messageqcpp::ByteStream& operator<<(messageqcpp::ByteStream& bs, const LogicalPartition& rhs); 86 87 messageqcpp::ByteStream& operator>>(messageqcpp::ByteStream& bs, LogicalPartition& rhs); 88 89 } 90 #endif 91