#include <JobId.h>
Public Member Functions | |
JobId () | |
Create default (null ID). | |
JobId (const std::string &uuid) | |
Create JobId based on UUID string. | |
virtual | ~JobId () |
Destructor. | |
JobId (const DayaBay::JobId &jobId) | |
Copy Constructor. | |
DayaBay::JobId & | operator= (const DayaBay::JobId &jobId) |
Assignment Operator. | |
void | set (const std::string &uuid) |
Set JobId based on UUID string. | |
std::string | uuid () const |
Get UUID formatted Job ID. | |
bool | operator== (const DayaBay::JobId &rhs) const |
Comparison Operators. | |
bool | operator!= (const DayaBay::JobId &rhs) const |
Private Attributes | |
unsigned int | m_data [4] |
Unique ID data. |
Definition at line 15 of file JobId.h.
DayaBay::JobId::JobId | ( | ) |
DayaBay::JobId::JobId | ( | const std::string & | uuid | ) |
DayaBay::JobId::JobId | ( | const DayaBay::JobId & | jobId | ) |
DayaBay::JobId & DayaBay::JobId::operator= | ( | const DayaBay::JobId & | jobId | ) |
void DayaBay::JobId::set | ( | const std::string & | uuid | ) |
Set JobId based on UUID string.
Definition at line 56 of file JobId.cc.
00057 { 00058 // Convert job ID string to data vector 00059 // Currently expects a UUID-structured string 00060 m_data[0]=0; 00061 m_data[1]=0; 00062 m_data[2]=0; 00063 m_data[3]=0; 00064 if(uuid.size()!=36 || uuid[8]!='-' || uuid[13]!='-' 00065 || uuid[18]!='-' || uuid[23]!='-'){ 00066 // Invalid uuid 00067 return; 00068 } 00069 std::string a,b,c,d; 00070 a = std::string(&uuid[0],8); 00071 b = std::string(&uuid[9],4); 00072 b.append(&uuid[14],4); 00073 c = std::string(&uuid[19],4); 00074 c.append(&uuid[24],4); 00075 d = std::string(&uuid[28],8); 00076 char buffer[16]; 00077 char hexTokens[] = "0123456789ABCDEFabcdef"; 00078 if(strtok(strcpy(buffer,&a[0]),hexTokens)!=NULL 00079 || strtok(strcpy(buffer,&b[0]),hexTokens)!=NULL 00080 || strtok(strcpy(buffer,&c[0]),hexTokens)!=NULL 00081 || strtok(strcpy(buffer,&d[0]),hexTokens)!=NULL){ 00082 // Invalid uuid 00083 return; 00084 } 00085 m_data[0] = strtoul(&a[0],NULL,16); 00086 m_data[1] = strtoul(&b[0],NULL,16); 00087 m_data[2] = strtoul(&c[0],NULL,16); 00088 m_data[3] = strtoul(&d[0],NULL,16); 00089 }
std::string DayaBay::JobId::uuid | ( | ) | const |
Get UUID formatted Job ID.
Definition at line 91 of file JobId.cc.
00092 { 00093 // Return a string UUID representation of the job ID 00094 std::ostringstream jobIdHex; 00095 jobIdHex 00096 << std::hex << std::setw(8) << std::setfill('0') 00097 << m_data[0] 00098 << std::hex << std::setw(8) << std::setfill('0') 00099 << m_data[1] 00100 << std::hex << std::setw(8) << std::setfill('0') 00101 << m_data[2] 00102 << std::hex << std::setw(8) << std::setfill('0') 00103 << m_data[3]; 00104 std::string jobIdStr = jobIdHex.str(); 00105 jobIdStr.insert(8,"-"); 00106 jobIdStr.insert(13,"-"); 00107 jobIdStr.insert(18,"-"); 00108 jobIdStr.insert(23,"-"); 00109 return jobIdStr; 00110 }
bool DayaBay::JobId::operator== | ( | const DayaBay::JobId & | rhs | ) | const |
bool DayaBay::JobId::operator!= | ( | const DayaBay::JobId & | rhs | ) | const |
unsigned int DayaBay::JobId::m_data[4] [private] |