field.h 1.3 KB
Newer Older
羽飞's avatar
羽飞 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/* Copyright (c) 2021 Xie Meiyi(xiemeiyi@hust.edu.cn) and OceanBase and/or its affiliates. All rights reserved.
miniob is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
         http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details. */

//
// Created by Wangyunlai on 2022/07/05.
//

羽飞's avatar
羽飞 已提交
15 16 17 18 19
#pragma once

#include "storage/common/table.h"
#include "storage/common/field_meta.h"

羽飞's avatar
羽飞 已提交
20
class Field
羽飞's avatar
羽飞 已提交
21
{
羽飞's avatar
羽飞 已提交
22 23 24
public:
  Field() = default;
  Field(const Table *table, const FieldMeta *field) : table_(table), field_(field)
羽飞's avatar
羽飞 已提交
25 26
  {}

羽飞's avatar
羽飞 已提交
27 28
  const Table *table() const { return table_; }
  const FieldMeta *meta() const { return field_; }
羽飞's avatar
羽飞 已提交
29

羽飞's avatar
羽飞 已提交
30 31 32 33
  AttrType attr_type() const
  {
    return field_->type();
  }
羽飞's avatar
羽飞 已提交
34

羽飞's avatar
羽飞 已提交
35 36
  const char *table_name() const { return table_->name(); }
  const char *field_name() const { return field_->name(); }
羽飞's avatar
羽飞 已提交
37

羽飞's avatar
羽飞 已提交
38 39 40 41 42 43 44 45
  void set_table(const Table *table)
  {
    this->table_ = table;
  }
  void set_field(const FieldMeta *field)
  {
    this->field_ = field;
  }
羽飞's avatar
羽飞 已提交
46
private:
羽飞's avatar
羽飞 已提交
47 48
  const Table *table_ = nullptr;
  const FieldMeta *field_ = nullptr;
羽飞's avatar
羽飞 已提交
49
};