CPN
Computational Process Networks
D4RTag.h
Go to the documentation of this file.
1 //=============================================================================
2 // Computational Process Networks class library
3 // Copyright (C) 1997-2006 Gregory E. Allen and The University of Texas
4 //
5 // This library is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU Library General Public License as published
7 // by the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Library General Public License for more details.
14 //
15 // The GNU Public License is available in the file LICENSE, or you
16 // can write to the Free Software Foundation, Inc., 59 Temple Place -
17 // Suite 330, Boston, MA 02111-1307, USA, or you can find it on the
18 // World Wide Web at http://www.fsf.org.
19 //=============================================================================
23 #ifndef D4R_TAG_H
24 #define D4R_TAG_H
25 #pragma once
26 #include <cpn/common.h>
27 #include <cpn/utils/uint128_t.h>
32 namespace D4R {
33 
42  class Tag {
43  public:
44  Tag(uint64_t k) : label(0, k), priority(uint64_t(-1), k) {}
45  Tag() : label(), priority() {}
50  bool operator<(const Tag &t) const;
51  bool operator>=(const Tag &t) const { return !(*this < t); }
52  bool operator<=(const Tag &t) const { return !(t < *this); }
53  bool operator>(const Tag &t) const { return (t < *this); }
54  bool operator==(const Tag &t) const;
55  bool operator!=(const Tag &t) const { return !(*this == t); }
56 
58  uint64_t Count() const { return label.high; }
59  uint64_t Count(uint64_t c) { return label.high = c; }
62  uint64_t Key() const { return label.low; }
63  uint64_t Key(uint64_t k) { return label.low = k; }
66  uint64_t QueueSize() const { return priority.high; }
67  uint64_t QueueSize(uint64_t qs) { return priority.high = qs; }
71  uint64_t QueueKey() const { return priority.low; }
72  uint64_t QueueKey(uint64_t k) { return priority.low = k; }
74  const uint128_t &Label() const { return label; }
75  const uint128_t &Label(const uint128_t &l) { return label = l; }
76  const uint128_t &Priority() const { return priority; }
77  const uint128_t &Priority(const uint128_t &p) { return priority = p; }
78  private:
81  };
82 
83 }
84 #endif
bool operator<(const Tag &t) const
Definition: D4RTag.cc:28
bool operator!=(const Tag &t) const
Definition: D4RTag.h:55
uint64_t QueueKey(uint64_t k)
Definition: D4RTag.h:72
bool operator>=(const Tag &t) const
Definition: D4RTag.h:51
This is a very simple implementation of a 128 bit number.
uint64_t Count(uint64_t c)
Definition: D4RTag.h:59
uint64_t high
Definition: uint128_t.h:35
Tag(uint64_t k)
Definition: D4RTag.h:44
uint64_t QueueKey() const
Definition: D4RTag.h:71
uint64_t QueueSize(uint64_t qs)
Definition: D4RTag.h:67
uint64_t Key() const
Definition: D4RTag.h:62
Tag()
Definition: D4RTag.h:45
const uint128_t & Label(const uint128_t &l)
Definition: D4RTag.h:75
bool operator<=(const Tag &t) const
Definition: D4RTag.h:52
uint128_t priority
Definition: D4RTag.h:80
uint64_t low
Definition: uint128_t.h:35
uint128_t label
Definition: D4RTag.h:79
const uint128_t & Priority() const
Definition: D4RTag.h:76
const uint128_t & Priority(const uint128_t &p)
Definition: D4RTag.h:77
bool operator>(const Tag &t) const
Definition: D4RTag.h:53
uint64_t QueueSize() const
Definition: D4RTag.h:66
bool operator==(const Tag &t) const
Definition: D4RTag.cc:36
uint64_t Key(uint64_t k)
Definition: D4RTag.h:63
uint64_t Count() const
Definition: D4RTag.h:58
const uint128_t & Label() const
Definition: D4RTag.h:74