| 50 | const string& type, int id); |
| 51 | |
| 52 | struct ParsedName { |
| 53 | void Clear() { |
| 54 | has_job = false; |
| 55 | has_replica = false; |
| 56 | has_task = false; |
| 57 | has_type = false; |
| 58 | has_id = false; |
| 59 | job.clear(); |
| 60 | replica = 0; |
| 61 | task = 0; |
| 62 | type.clear(); |
| 63 | id = 0; |
| 64 | } |
| 65 | |
| 66 | bool operator==(const ParsedName& other) const { |
| 67 | return (has_job ? (other.has_job && job == other.job) : !other.has_job) && |
| 68 | (has_replica ? (other.has_replica && replica == other.replica) |
| 69 | : !other.has_replica) && |
| 70 | (has_task ? (other.has_task && task == other.task) |
| 71 | : !other.has_task) && |
| 72 | (has_type ? (other.has_type && type == other.type) |
| 73 | : !other.has_type) && |
| 74 | (has_id ? (other.has_id && id == other.id) : !other.has_id); |
| 75 | } |
| 76 | |
| 77 | bool has_job = false; |
| 78 | string job; |
| 79 | bool has_replica = false; |
| 80 | int replica = 0; |
| 81 | bool has_task = false; |
| 82 | int task = 0; |
| 83 | bool has_type = false; |
| 84 | string type; |
| 85 | bool has_id = false; |
| 86 | int id = 0; |
| 87 | }; |
| 88 | // Parses "fullname" into "*parsed". Returns true iff succeeds. |
| 89 | // Legacy names like "/cpu:0" that don't contain "device", |
| 90 | // are parsed to mean their current counterparts "/device:CPU:0". More |