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

#ifndef UHDM_DIST_ITEM_H
#define UHDM_DIST_ITEM_H

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

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

#include "expr_range_group.h"


namespace UHDM {
class expr;

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

  int32_t VpiDistType() const { return vpiDistType_; }
  bool VpiDistType(int32_t data) {
    vpiDistType_ = data;
    return true;
  }

  any* Value_range()  { return value_range_; }
  const any* Value_range() const { return value_range_; }
  template <typename T>
  T* Value_range() {
    return (value_range_ == nullptr) ? nullptr : any_cast<T*>(value_range_);
  }
  template <typename T>
  const T* Value_range() const {
    return (value_range_ == nullptr) ? nullptr : any_cast<const T*>(value_range_);
  }
  bool Value_range(any* data) {
    if (!expr_range_groupGroupCompliant(data)) return false;
    value_range_ = data;
    return true;
  }

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

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

  virtual dist_item* 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::uhdmdist_item; }

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

private:
  int32_t vpiDistType_ = 0;

  any* value_range_ = nullptr;

  expr* weight_ = nullptr;
};


typedef FactoryT<dist_item> dist_itemFactory;


typedef FactoryT<std::vector<dist_item *>> VectorOfdist_itemFactory;

}  // namespace UHDM

#endif
