Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Priority::Low and Priority::High
Change-Id: Ia6a8e2adb9671ab585264e0b56871d9324056464 Reviewed-on: http://review.northscale.com:8080/45 Reviewed-by: Dustin Sallings <dustin@spy.net> Tested-by: Dustin Sallings <dustin@spy.net>
- Loading branch information
Showing
5 changed files
with
66 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ | |
/m4/ltsugar.m4 | ||
/m4/ltversion.m4 | ||
/m4/version.m4 | ||
/priority_test | ||
/stamp-h1 | ||
Makefile | ||
Makefile.in |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ | ||
#include "priority.hh" | ||
|
||
const Priority Priority::Low("low"); | ||
const Priority Priority::High("high"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ | ||
#ifndef PRIORITY_HH | ||
#define PRIORITY_HH | ||
|
||
#include "common.hh" | ||
|
||
#include <string> | ||
|
||
class Priority { | ||
public: | ||
static const Priority Low; | ||
static const Priority High; | ||
|
||
bool operator==(const Priority &other) const { | ||
return (&other == this); | ||
} | ||
|
||
bool operator<(const Priority &other) const { | ||
return this == &Low; | ||
} | ||
|
||
bool operator>(const Priority &other) const { | ||
return this == &High; | ||
} | ||
|
||
const std::string &toString() const { | ||
return name; | ||
} | ||
|
||
private: | ||
Priority(const char *nm) : name(nm) { }; | ||
std::string name; | ||
DISALLOW_COPY_AND_ASSIGN(Priority); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ | ||
#include "priority.hh" | ||
#undef NDEBUG | ||
#include <assert.h> | ||
|
||
int main(int argc, char **argv) { | ||
(void)argc; (void)argv; | ||
|
||
assert(Priority::Low < Priority::High); | ||
assert(!(Priority::High < Priority::Low)); | ||
assert(Priority::High > Priority::Low); | ||
assert(!(Priority::Low > Priority::High)); | ||
assert(!(Priority::Low == Priority::High)); | ||
assert(!(Priority::High == Priority::Low)); | ||
assert(Priority::Low == Priority::Low); | ||
assert(Priority::High == Priority::High); | ||
|
||
return 0; | ||
} |