34 #include <Base/Image/UUID.hh>
41 void Check(
const std::vector<BIAS::UUID> &uuids);
42 void ResetFromString(std::vector<BIAS::UUID> &uuids);
43 void ResetFromLong(std::vector<BIAS::UUID> &uuids);
44 void ResetFromRaw(std::vector<BIAS::UUID> &uuids);
46 int main(
int argc,
char *argv[])
48 std::vector<BIAS::UUID> uuids_consecutive, uuids_global;
49 const unsigned num = 100;
51 for (
unsigned i=0; i<num; i++){
53 if (!uuids_consecutive.back().IsConsecutive()){
63 Check(uuids_consecutive);
66 ResetFromString(uuids_consecutive);
67 ResetFromString(uuids_global);
69 Check(uuids_consecutive);
73 ResetFromLong(uuids_consecutive);
74 Check(uuids_consecutive);
76 ResetFromRaw(uuids_consecutive);
77 ResetFromRaw(uuids_global);
79 Check(uuids_consecutive);
82 for (
unsigned i=0; i<num; i++){
83 uuids_consecutive[i].clear();
84 if ( !uuids_consecutive[i].IsNil() || uuids_consecutive[i].IsValid() ){
87 uuids_global[i].Invalidate();
88 if ( !uuids_global[i].IsNil() || uuids_global[i].IsValid() ){
103 void Check(
const std::vector<BIAS::UUID> &uuids)
106 const unsigned num = uuids.size();
107 for (
unsigned i=0; i<num; i++){
108 if (uuids[i].IsNil()){
109 cerr <<
"uuid is nil: "<<uuids[i]<<endl;
112 if (!uuids[i].IsValid()){
113 cerr <<
"uuid is not valid: "<<uuids[i]<<endl;
116 for (
unsigned k=0; k<num; k++){
118 if (uuids[i]==uuids[k]){
119 cerr <<
"uids are not unique: \n "<<uuids[i]<<
"\n "<<uuids[k]<<endl;
127 void ResetFromString(std::vector<BIAS::UUID> &uuids)
131 const unsigned num = uuids.size();
132 for (
unsigned i=0; i<num; i++){
133 tmp = uuids[i].GetString();
137 if (tmpuid!=uuids[i]){
144 void ResetFromLong(std::vector<BIAS::UUID> &uuids)
148 const unsigned num = uuids.size();
149 for (
unsigned i=0; i<num; i++){
150 tmp = uuids[i].GetLong();
154 if (tmpuid!=uuids[i]){
155 cerr <<
"re-setting uuis from long does not work: "<<tmp
156 <<
"\n "<<uuids[i]<<
"\n "<<tmpuid<<endl;
164 void ResetFromRaw(std::vector<BIAS::UUID> &uuids)
167 const unsigned num = uuids.size();
169 for (
unsigned i=0; i<num; i++){
170 const unsigned char *tmp = uuids[i].GetUUIDRaw();
172 if (tmpuid!=uuids[i]){
bool SetFromString(const std::string &sID)
construct from string containing ascii uuid.
bool SetFromLong(const unsigned long &n)
construct from a unique long.
interface class for producing/storing Universally Unique IDentifiers
static UUID GenerateUUID(const bool &consecutively=DEFAULT_UUID_CONSECUTIVELY)
static function which simply produces a uuid and returns
bool IsValid() const
checks whether this uuid is valid(true) or unitialized(false)
void SetUUIDRaw(const unsigned char *rawid)