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

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

  bool VpiArrayMember() const { return vpiArrayMember_; }
  bool VpiArrayMember(bool data) {
    vpiArrayMember_ = data;
    return true;
  }

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

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

  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 VpiPrimType() const { return vpiPrimType_; }
  bool VpiPrimType(int32_t data) {
    vpiPrimType_ = data;
    return true;
  }

  int32_t VpiStrength0() const { return vpiStrength0_; }
  bool VpiStrength0(int32_t data) {
    vpiStrength0_ = data;
    return true;
  }

  int32_t VpiStrength1() const { return vpiStrength1_; }
  bool VpiStrength1(int32_t data) {
    vpiStrength1_ = data;
    return true;
  }

  VectorOfattribute* Attributes() const { return attributes_; }
  bool Attributes(VectorOfattribute* data) {
    attributes_ = data;
    return true;
  }

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

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

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

  VectorOfprim_term* Prim_terms() const { return prim_terms_; }
  bool Prim_terms(VectorOfprim_term* data) {
    prim_terms_ = data;
    return true;
  }

  virtual primitive* 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::uhdmprimitive; }

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

private:
  bool vpiArrayMember_ = false;

  SymbolId vpiDefName_;

  SymbolId vpiDelay_;

  SymbolId vpiName_;

  SymbolId vpiFullName_;

  int32_t vpiPrimType_ = 0;

  int32_t vpiStrength0_ = 0;

  int32_t vpiStrength1_ = 0;

  VectorOfattribute* attributes_ = nullptr;

  SymbolId vpiValue_;

  expr* delay_ = nullptr;

  expr* index_ = nullptr;

  VectorOfprim_term* prim_terms_ = nullptr;
};

#if 0 // This class cannot be instantiated
typedef FactoryT<primitive> primitiveFactory;
#endif

typedef FactoryT<std::vector<primitive *>> VectorOfprimitiveFactory;

}  // namespace UHDM

#endif
