// Copyright 2018 The Paddle Authors. All Rights Reserved.
//
// Licensed 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.
// =============================================================================

syntax = "proto3";
option optimize_for = LITE_RUNTIME;

package paddlehub.module.desc;

enum DataType {
  NONE = 0;
  INT = 1;
  FLOAT = 2;
  STRING = 3;
  BOOLEAN = 4;
  LIST = 5;
  MAP = 6;
  SET = 7;
  OBJECT = 8;
}

message KVData {
  map<string, DataType> key_type = 1;
  map<string, ModuleAttr> data = 2;
}

message ModuleAttr {
  // Basic type
  DataType type = 1;
  int64 i = 2;
  double f = 3;
  bool b = 4;
  string s = 5;
  KVData map = 6;
  KVData list = 7;
  KVData set = 8;
  KVData object = 9;
  // 
  string name = 10;
  string info = 11;

}

// Feed Variable Description
message FeedDesc {
  string var_name = 1;
  string alias = 2;
};

// Fetch Variable Description
message FetchDesc {
  string var_name = 1;
  string alias = 2;
};

// Module Variable
message ModuleVar {
  repeated FetchDesc fetch_desc = 1;
  repeated FeedDesc feed_desc = 2;
}

// A Hub Module is stored in a directory with a file 'module_desc.pb'
// containing a serialized protocol message of this type. The further contents
// of the directory depend on the storage format described by the message.
message ModuleDesc {
  // signature to module variable
  map<string, ModuleVar> sign2var = 2;

  ModuleAttr attr = 3;
};

