text: // 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 __INTERNAL_EVOLVE_HPP__
  #define __INTERNAL_EVOLVE_HPP__
  
  #include <google/protobuf/message.h>
  
  #include <mesos/agent/agent.hpp>
  
  #include <mesos/mesos.hpp>
  
  #include <mesos/master/master.hpp>
  
  #include <mesos/executor/executor.hpp>
  
  #include <mesos/master/master.hpp>
  
  #include <mesos/maintenance/maintenance.hpp>
  
  #include <mesos/scheduler/scheduler.hpp>
  
  #include <mesos/v1/mesos.hpp>
  
  #include <mesos/v1/agent/agent.hpp>
  
  #include <mesos/v1/executor/executor.hpp>
  
  #include <mesos/v1/master/master.hpp>
  
  #include <mesos/v1/maintenance/maintenance.hpp>
  
  #include <mesos/v1/scheduler/scheduler.hpp>
  
  #include <stout/foreach.hpp>
  #include <stout/json.hpp>
  
  #include "messages/messages.hpp"
  
  namespace mesos {
  namespace internal {
  
  // Helpers for evolving types between versions. Please add as necessary!
  v1::AgentID evolve(const SlaveID& slaveId);
  v1::AgentInfo evolve(const SlaveInfo& slaveInfo);
  v1::FrameworkID evolve(const FrameworkID& frameworkId);
  v1::FrameworkInfo evolve(const FrameworkInfo& frameworkInfo);
  v1::KillPolicy evolve(const KillPolicy& killPolicy);
  v1::ExecutorID evolve(const ExecutorID& executorId);
  v1::ExecutorInfo evolve(const ExecutorInfo& executorInfo);
  v1::Offer evolve(const Offer& offer);
  v1::InverseOffer evolve(const InverseOffer& inverseOffer);
  v1::OfferID evolve(const OfferID& offerId);
  v1::TaskID evolve(const TaskID& taskId);
  v1::TaskInfo evolve(const TaskInfo& taskInfo);
  v1::TaskStatus evolve(const TaskStatus& status);
  v1::Task evolve(const Task& task);
  v1::MasterInfo evolve(const MasterInfo& masterInfo);
  v1::Resource evolve(const Resource& resource);
  
  v1::agent::Response evolve(const mesos::agent::Response& response);
  
  v1::master::Response evolve(const mesos::master::Response& response);
  
  v1::scheduler::Call evolve(const scheduler::Call& call);
  
  
  // Helper for repeated field evolving to 'T1' from 'T2'.
  template <typename T1, typename T2>
  google::protobuf::RepeatedPtrField<T1> evolve(
      google::protobuf::RepeatedPtrField<T2> t2s)
  {
    google::protobuf::RepeatedPtrField<T1> t1s;
  
    foreach (const T2& t2, t2s) {
      t1s.Add()->CopyFrom(evolve(t2));
    }
  
    return t1s;
  }
  
  
  v1::scheduler::Event evolve(const scheduler::Event& event);
  
  
  // Helper functions that evolve old style internal messages to a
  // v1::scheduler::Event.
  v1::scheduler::Event evolve(const FrameworkRegisteredMessage& message);
  v1::scheduler::Event evolve(const FrameworkReregisteredMessage& message);
  v1::scheduler::Event evolve(const ResourceOffersMessage& message);
  v1::scheduler::Event evolve(const InverseOffersMessage& message);
  v1::scheduler::Event evolve(const RescindResourceOfferMessage& message);
  v1::scheduler::Event evolve(const RescindInverseOfferMessage& message);
  v1::scheduler::Event evolve(const StatusUpdateMessage& message);
  v1::scheduler::Event evolve(const LostSlaveMessage& message);
  v1::scheduler::Event evolve(const ExitedExecutorMessage& message);
  v1::scheduler::Event evolve(const ExecutorToFrameworkMessage& message);
  v1::scheduler::Event evolve(const FrameworkErrorMessage& message);
  
  v1::scheduler::Event evolve(const CloudInfoMessage& message) ;
  v1::scheduler::Event evolve(const TerminationWarningMessage& message) ;
  
  v1::executor::Event evolve(const mesos::executor::Event& event);
  
  
  // Helper functions that evolve old style internal messages to a
  // v1::Executor::Event.
  v1::executor::Event evolve(const ExecutorRegisteredMessage& message);
  v1::executor::Event evolve(const FrameworkToExecutorMessage& message);
  v1::executor::Event evolve(const KillTaskMessage& message);
  v1::executor::Event evolve(const RunTaskMessage& message);
  v1::executor::Event evolve(const StatusUpdateAcknowledgementMessage& message);
  v1::executor::Event evolve(const ShutdownExecutorMessage& message);
  
  
  v1::master::Event evolve(const mesos::master::Event& event);
  
  
  // Before the v1 API we had REST endpoints that returned JSON. The JSON was not
  // specified in any formal way, i.e., there were no protobufs which captured the
  // structure. As part of the v1 API we introduced the Call/Response protobufs
  // (see v1/master.proto and v1/agent.proto). This evolve variant transforms a
  // JSON object that would have been returned from a particular REST endpoint to
  // a `Response` protobuf suitable for returning from the new v1 API endpoints.
  
  // Declaration of helper functions for evolving JSON objects used in master's
  // REST endpoints pre v1 API.
  template <v1::master::Response::Type T>
  v1::master::Response evolve(const JSON::Object& object);
  
  
  // Helper functions that evolve old style internal messages to a
  // v1::master::Response.
  v1::master::Response evolve(const mesos::maintenance::ClusterStatus& status);
  v1::master::Response evolve(const mesos::maintenance::Schedule& schedule);
  
  
  // Declaration of helper functions for evolving JSON objects used in agent's
  // REST endpoints pre v1 API.
  template <v1::agent::Response::Type T>
  v1::agent::Response evolve(const JSON::Object& object);
  
  } // namespace internal {
  } // namespace mesos {
  
  #endif // __INTERNAL_EVOLVE_HPP__
  