/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef __TYPE_UTILS_HPP__ #define __TYPE_UTILS_HPP__ #include #include #include #include #include "common/attributes.hpp" #include "common/resources.hpp" #include "messages/messages.hpp" // This file includes definitions for operators on protobuf classes // that don't have these operators generated by the protobuf compiler. namespace mesos { inline std::ostream& operator << ( std::ostream& stream, const FrameworkID& frameworkId) { return stream << frameworkId.value(); } inline std::ostream& operator << (std::ostream& stream, const OfferID& offerId) { return stream << offerId.value(); } inline std::ostream& operator << (std::ostream& stream, const SlaveID& slaveId) { return stream << slaveId.value(); } inline std::ostream& operator << (std::ostream& stream, const TaskID& taskId) { return stream << taskId.value(); } inline std::ostream& operator << ( std::ostream& stream, const ExecutorID& executorId) { return stream << executorId.value(); } inline std::ostream& operator << (std::ostream& stream, const TaskState& state) { return stream << TaskState_descriptor()->FindValueByNumber(state)->name(); } inline std::ostream& operator << (std::ostream& stream, const TaskInfo& task) { return stream << task.DebugString(); } inline std::ostream& operator << (std::ostream& stream, const SlaveInfo& slave) { return stream << slave.DebugString(); } inline bool operator == (const FrameworkID& left, const FrameworkID& right) { return left.value() == right.value(); } inline bool operator == (const FrameworkInfo& left, const FrameworkInfo& right) { return (left.name() == right.name()) && (left.user() == right.user()); } inline bool operator == (const OfferID& left, const OfferID& right) { return left.value() == right.value(); } inline bool operator == (const SlaveID& left, const SlaveID& right) { return left.value() == right.value(); } inline bool operator == (const TaskID& left, const TaskID& right) { return left.value() == right.value(); } inline bool operator == (const ExecutorID& left, const ExecutorID& right) { return left.value() == right.value(); } inline bool operator == (const FrameworkID& left, const std::string& right) { return left.value() == right; } inline bool operator == (const OfferID& left, const std::string& right) { return left.value() == right; } inline bool operator == (const SlaveID& left, const std::string& right) { return left.value() == right; } inline bool operator == (const TaskID& left, const std::string& right) { return left.value() == right; } inline bool operator == (const ExecutorID& left, const std::string& right) { return left.value() == right; } inline bool operator < (const FrameworkID& left, const FrameworkID& right) { return left.value() < right.value(); } inline bool operator < (const OfferID& left, const OfferID& right) { return left.value() < right.value(); } inline bool operator < (const SlaveID& left, const SlaveID& right) { return left.value() < right.value(); } inline bool operator < (const TaskID& left, const TaskID& right) { return left.value() < right.value(); } inline bool operator < (const ExecutorID& left, const ExecutorID& right) { return left.value() < right.value(); } inline bool operator == (const Environment& left, const Environment& right) { if (left.variables().size() != right.variables().size()) { return false; } for (int i = 0; i < left.variables().size(); i++) { const std::string& name = left.variables().Get(i).name(); const std::string& value = left.variables().Get(i).value(); bool found = false; for (int j = 0; j < right.variables().size(); j++) { if (name == right.variables().Get(j).name() && value == right.variables().Get(j).value()) { found = true; break; } } if (!found) { return false; } } return true; } inline bool operator == ( const CommandInfo::URI& left, const CommandInfo::URI& right) { return left.has_executable() == right.has_executable() && (!left.has_executable() || (left.executable() == right.executable())) && left.value() == right.value(); } inline bool operator == (const CommandInfo& left, const CommandInfo& right) { if (left.uris().size() != right.uris().size()) { return false; } for (int i=0; iFindValueByNumber(type)->name(); } }} // namespace mesos { namespace internal { #endif // __TYPE_UTILS_HPP__