/*
 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:   instance_array.h
 * Author:
 *
 * Created on December 14, 2019, 10:03 PM
 */

#ifndef UHDM_INSTANCE_ARRAY_H
#define UHDM_INSTANCE_ARRAY_H

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

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




namespace UHDM {
class expr;
class ref_typespec;

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

  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;

  int32_t VpiSize() const { return vpiSize_; }
  bool VpiSize(int32_t data) {
    vpiSize_ = 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_expr()  { return left_expr_; }
  const expr* Left_expr() const { return left_expr_; }
  template <typename T>
  T* Left_expr() {
    return (left_expr_ == nullptr) ? nullptr : any_cast<T*>(left_expr_);
  }
  template <typename T>
  const T* Left_expr() const {
    return (left_expr_ == nullptr) ? nullptr : any_cast<const T*>(left_expr_);
  }
  bool Left_expr(expr* data) {
    left_expr_ = data;
    return true;
  }

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

  VectorOfinstance* Instances() const { return instances_; }
  bool Instances(VectorOfinstance* data) {
    instances_ = data;
    return true;
  }

  VectorOfmodule_inst* Modules() const { return modules_; }
  bool Modules(VectorOfmodule_inst* data) {
    modules_ = data;
    return true;
  }

  ref_typespec* Elem_typespec()  { return elem_typespec_; }
  const ref_typespec* Elem_typespec() const { return elem_typespec_; }
  template <typename T>
  T* Elem_typespec() {
    return (elem_typespec_ == nullptr) ? nullptr : any_cast<T*>(elem_typespec_);
  }
  template <typename T>
  const T* Elem_typespec() const {
    return (elem_typespec_ == nullptr) ? nullptr : any_cast<const T*>(elem_typespec_);
  }
  bool Elem_typespec(ref_typespec* data) {
    elem_typespec_ = data;
    return true;
  }

  VectorOfport* Ports() const { return ports_; }
  bool Ports(VectorOfport* data) {
    ports_ = data;
    return true;
  }

  virtual instance_array* DeepClone(BaseClass* parent, CloneContext* context) const override = 0;

  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 override { return UHDM_OBJECT_TYPE::uhdminstance_array; }

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

private:
  SymbolId vpiName_;

  SymbolId vpiFullName_;

  int32_t vpiSize_ = 0;

  expr* expr_ = nullptr;

  VectorOfrange* ranges_ = nullptr;

  expr* left_expr_ = nullptr;

  expr* right_expr_ = nullptr;

  VectorOfinstance* instances_ = nullptr;

  VectorOfmodule_inst* modules_ = nullptr;

  ref_typespec* elem_typespec_ = nullptr;

  VectorOfport* ports_ = nullptr;
};

#if 0 // This class cannot be instantiated
typedef FactoryT<instance_array> instance_arrayFactory;
#endif

typedef FactoryT<std::vector<instance_array *>> VectorOfinstance_arrayFactory;

}  // namespace UHDM

#endif
