/*
 Do not modify, auto-generated by classes.py

 Copyright 2019 Alain Dargelas

 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.
 */

/*
 * File:   parameter.h
 * Author:
 *
 * Created on December 14, 2019, 10:03 PM
 */

#ifndef UHDM_PARAMETER_H
#define UHDM_PARAMETER_H

#include <uhdm/sv_vpi_user.h>
#include <uhdm/uhdm_vpi_user.h>

#include <uhdm/containers.h>
#include <uhdm/simple_expr.h>




namespace UHDM {
class expr;

class parameter final : public simple_expr {
  UHDM_IMPLEMENT_RTTI(parameter, simple_expr)
public:
  // Implicit constructor used to initialize all members,
  // comment: parameter();
  virtual ~parameter() final = default;

  int32_t VpiConstType() const { return vpiConstType_; }
  bool VpiConstType(int32_t data) {
    vpiConstType_ = data;
    return true;
  }

  bool VpiSigned() const { return vpiSigned_; }
  bool VpiSigned(bool data) {
    vpiSigned_ = data;
    return true;
  }

  expr* Expr()  { return expr_; }
  const expr* Expr() const { return expr_; }
  template <typename T>
  T* Expr() {
    return (expr_ == nullptr) ? nullptr : any_cast<T*>(expr_);
  }
  template <typename T>
  const T* Expr() const {
    return (expr_ == nullptr) ? nullptr : any_cast<const T*>(expr_);
  }
  bool Expr(expr* data) {
    expr_ = data;
    return true;
  }

  VectorOfrange* Ranges() const { return ranges_; }
  bool Ranges(VectorOfrange* data) {
    ranges_ = data;
    return true;
  }

  expr* Left_range()  { return left_range_; }
  const expr* Left_range() const { return left_range_; }
  template <typename T>
  T* Left_range() {
    return (left_range_ == nullptr) ? nullptr : any_cast<T*>(left_range_);
  }
  template <typename T>
  const T* Left_range() const {
    return (left_range_ == nullptr) ? nullptr : any_cast<const T*>(left_range_);
  }
  bool Left_range(expr* data) {
    left_range_ = data;
    return true;
  }

  expr* Right_range()  { return right_range_; }
  const expr* Right_range() const { return right_range_; }
  template <typename T>
  T* Right_range() {
    return (right_range_ == nullptr) ? nullptr : any_cast<T*>(right_range_);
  }
  template <typename T>
  const T* Right_range() const {
    return (right_range_ == nullptr) ? nullptr : any_cast<const T*>(right_range_);
  }
  bool Right_range(expr* data) {
    right_range_ = data;
    return true;
  }

  bool VpiLocalParam() const { return vpiLocalParam_; }
  bool VpiLocalParam(bool data) {
    vpiLocalParam_ = data;
    return true;
  }

  virtual bool VpiName(std::string_view data) final;
  virtual std::string_view VpiName() const final;

  bool VpiFullName(std::string_view data);
  std::string_view VpiFullName() const;

  bool VpiImported(std::string_view data);
  std::string_view VpiImported() const;

  virtual uint32_t VpiType() const final { return vpiParameter; }

  virtual parameter* DeepClone(BaseClass* parent, CloneContext* context) const override;

  virtual const BaseClass* GetByVpiName(std::string_view name) const override;

  virtual std::tuple<const BaseClass*, UHDM_OBJECT_TYPE, const std::vector<const BaseClass*>*> GetByVpiType(int32_t type) const override;

  virtual vpi_property_value_t GetVpiPropertyValue(int32_t property) const override;

  virtual int32_t Compare(const BaseClass* other, CompareContext* context) const override;

  virtual  UHDM_OBJECT_TYPE UhdmType() const final { return UHDM_OBJECT_TYPE::uhdmparameter; }

protected:
  void DeepCopy(parameter* clone, BaseClass* parent, CloneContext* context) const;

private:
  int32_t vpiConstType_ = 0;

  bool vpiSigned_ = false;

  expr* expr_ = nullptr;

  VectorOfrange* ranges_ = nullptr;

  expr* left_range_ = nullptr;

  expr* right_range_ = nullptr;

  bool vpiLocalParam_ = false;

  SymbolId vpiName_;

  SymbolId vpiFullName_;

  SymbolId vpiImported_;
};


typedef FactoryT<parameter> parameterFactory;


typedef FactoryT<std::vector<parameter *>> VectorOfparameterFactory;

}  // namespace UHDM

#endif
