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

#ifndef UHDM_TYPESPEC_MEMBER_H
#define UHDM_TYPESPEC_MEMBER_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 typespec_member final : public BaseClass {
  UHDM_IMPLEMENT_RTTI(typespec_member, BaseClass)
public:
  // Implicit constructor used to initialize all members,
  // comment: typespec_member();
  virtual ~typespec_member() final = default;

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

  bool VpiRandType() const { return vpiRandType_; }
  bool VpiRandType(bool data) {
    vpiRandType_ = data;
    return true;
  }

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

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

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

  int32_t VpiRefLineNo() const { return vpiRefLineNo_; }
  bool VpiRefLineNo(int32_t data) {
    vpiRefLineNo_ = data;
    return true;
  }

  int32_t VpiRefColumnNo() const { return vpiRefColumnNo_; }
  bool VpiRefColumnNo(int32_t data) {
    vpiRefColumnNo_ = data;
    return true;
  }

  int32_t VpiRefEndLineNo() const { return vpiRefEndLineNo_; }
  bool VpiRefEndLineNo(int32_t data) {
    vpiRefEndLineNo_ = data;
    return true;
  }

  int32_t VpiRefEndColumnNo() const { return vpiRefEndColumnNo_; }
  bool VpiRefEndColumnNo(int32_t data) {
    vpiRefEndColumnNo_ = data;
    return true;
  }

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

  virtual typespec_member* 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::uhdmtypespec_member; }

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

private:
  SymbolId vpiName_;

  bool vpiRandType_ = false;

  ref_typespec* typespec_ = nullptr;

  expr* default_value_ = nullptr;

  SymbolId vpiRefFile_;

  int32_t vpiRefLineNo_ = 0;

  int32_t vpiRefColumnNo_ = 0;

  int32_t vpiRefEndLineNo_ = 0;

  int32_t vpiRefEndColumnNo_ = 0;
};


typedef FactoryT<typespec_member> typespec_memberFactory;


typedef FactoryT<std::vector<typespec_member *>> VectorOftypespec_memberFactory;

}  // namespace UHDM

#endif
