HTGS  v2.0
The Hybrid Task Graph Scheduler
IData.hpp
Go to the documentation of this file.
1 
2 // NIST-developed software is provided by NIST as a public service. You may use, copy and distribute copies of the software in any medium, provided that you keep intact this entire notice. You may improve, modify and create derivative works of the software or any portion of the software, and you may copy and distribute such modifications or works. Modified works should carry a notice stating that you changed the software and should note the date and nature of any such change. Please explicitly acknowledge the National Institute of Standards and Technology as the source of the software.
3 // NIST-developed software is expressly provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED, IN FACT OR ARISING BY OPERATION OF LAW, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT AND DATA ACCURACY. NIST NEITHER REPRESENTS NOR WARRANTS THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR-FREE, OR THAT ANY DEFECTS WILL BE CORRECTED. NIST DOES NOT WARRANT OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF THE SOFTWARE OR THE RESULTS THEREOF, INCLUDING BUT NOT LIMITED TO THE CORRECTNESS, ACCURACY, RELIABILITY, OR USEFULNESS OF THE SOFTWARE.
4 // You are solely responsible for determining the appropriateness of using and distributing the software and you assume all risks associated with its use, including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and the unavailability or interruption of operation. This software is not intended to be used in any situation where a failure could cause risk of injury or damage to property. The software developed by NIST employees is not subject to copyright protection within the United States.
5 
14 #ifndef HTGS_IDATA_HPP
15 #define HTGS_IDATA_HPP
16 
17 #include <memory>
18 #include <iostream>
19 
20 namespace htgs {
60 class IData {
61 
62  public:
63 
67  IData() {
68  this->order = 0;
69  }
70 
76  IData(size_t order) {
77  this->order = order;
78  }
79 
83  virtual ~IData() {}
84 
93  bool operator()(const std::shared_ptr<IData> p1, const std::shared_ptr<IData> p2) const {
94  if (p1 && !p2)
95  return false;
96 
97  if (!p1 && p2)
98  return true;
99 
100  if (!p1 && !p2)
101  return true;
102 
103  return p1->compare(p2);
104  }
105 
119  virtual bool compare(const std::shared_ptr<IData> p2) const {
120  return this->getOrder() > p2->getOrder();
121  }
122 
127  size_t getOrder() const {
128  return order;
129  }
130 
131  private:
132  size_t order;
133 
134 };
135 }
136 
137 #endif //HTGS_IDATA_HPP
size_t order
The ordering of the data (lowest first)
Definition: IData.hpp:132
Class to hold any type of data.
Definition: IData.hpp:60
IData()
Constructs an IData with default ordering = 0.
Definition: IData.hpp:67
virtual bool compare(const std::shared_ptr< IData > p2) const
Virtual IData comparison function, can be used for custom ordering.
Definition: IData.hpp:119
IData(size_t order)
Constructs IData with integer ordering.
Definition: IData.hpp:76
bool operator()(const std::shared_ptr< IData > p1, const std::shared_ptr< IData > p2) const
Compares two IData pointers for ordering.
Definition: IData.hpp:93
Definition: Bookkeeper.hpp:23
virtual ~IData()
Destructor.
Definition: IData.hpp:83
size_t getOrder() const
Gets the order of this IData.
Definition: IData.hpp:127