1*b9216114SAxel Dörfler /* 2*b9216114SAxel Dörfler * Copyright 2005-2008, Haiku, Inc. All Rights Reserved. 3*b9216114SAxel Dörfler * Distributed under the terms of the MIT License. 4*b9216114SAxel Dörfler */ 5338b8dc3SIngo Weinhold #ifndef NODE_REF_H 6338b8dc3SIngo Weinhold #define NODE_REF_H 7338b8dc3SIngo Weinhold 8338b8dc3SIngo Weinhold #include <sys/stat.h> 9338b8dc3SIngo Weinhold 10338b8dc3SIngo Weinhold namespace BPrivate { 11338b8dc3SIngo Weinhold 12338b8dc3SIngo Weinhold struct NodeRef { 13338b8dc3SIngo Weinhold dev_t device; 14338b8dc3SIngo Weinhold ino_t node; 15338b8dc3SIngo Weinhold 16338b8dc3SIngo Weinhold NodeRef(dev_t device = 0, ino_t node = 0) deviceNodeRef17338b8dc3SIngo Weinhold : device(device), 18338b8dc3SIngo Weinhold node(node) 19338b8dc3SIngo Weinhold { 20338b8dc3SIngo Weinhold } 21338b8dc3SIngo Weinhold NodeRefNodeRef22338b8dc3SIngo Weinhold NodeRef(const struct stat &st) 23338b8dc3SIngo Weinhold : device(st.st_dev), 24338b8dc3SIngo Weinhold node(st.st_ino) 25338b8dc3SIngo Weinhold { 26338b8dc3SIngo Weinhold } 27338b8dc3SIngo Weinhold NodeRefNodeRef28338b8dc3SIngo Weinhold NodeRef(const NodeRef &other) 29338b8dc3SIngo Weinhold { 30338b8dc3SIngo Weinhold device = other.device; 31338b8dc3SIngo Weinhold node = other.node; 32338b8dc3SIngo Weinhold } 33338b8dc3SIngo Weinhold 34338b8dc3SIngo Weinhold NodeRef &operator=(const NodeRef &other) 35338b8dc3SIngo Weinhold { 36338b8dc3SIngo Weinhold device = other.device; 37338b8dc3SIngo Weinhold node = other.node; 38338b8dc3SIngo Weinhold return *this; 39338b8dc3SIngo Weinhold } 40338b8dc3SIngo Weinhold 41338b8dc3SIngo Weinhold bool operator==(const NodeRef &other) const 42338b8dc3SIngo Weinhold { 43338b8dc3SIngo Weinhold return (device == other.device && node == other.node); 44338b8dc3SIngo Weinhold } 45338b8dc3SIngo Weinhold 46338b8dc3SIngo Weinhold bool operator!=(const NodeRef &other) const 47338b8dc3SIngo Weinhold { 48338b8dc3SIngo Weinhold return !(*this == other); 49338b8dc3SIngo Weinhold } 50338b8dc3SIngo Weinhold 51338b8dc3SIngo Weinhold bool operator<(const NodeRef &other) const 52338b8dc3SIngo Weinhold { 53338b8dc3SIngo Weinhold return (device < other.device 54*b9216114SAxel Dörfler || (device == other.device && node < other.node)); 55338b8dc3SIngo Weinhold } 56338b8dc3SIngo Weinhold 57338b8dc3SIngo Weinhold }; 58338b8dc3SIngo Weinhold 59338b8dc3SIngo Weinhold } // namespace BPrivate 60338b8dc3SIngo Weinhold 61338b8dc3SIngo Weinhold #endif // NODE_REF_H 62