~FeatureObject();
private:
+ void get(ObjectInfo **) const override;
void get(const PtrLink<Bag, BagInfo> **out) const override;
public:
#ifndef __COCO_IR_FEATURE_OBJECT_INFO_H__
#define __COCO_IR_FEATURE_OBJECT_INFO_H__
+#include "coco/IR/ObjectInfo.h"
+
#include <nncc/core/ADT/feature/Shape.h>
namespace coco
{
-class FeatureObjectInfo final
+class FeatureObjectInfo final : public ObjectInfo
{
public:
FeatureObjectInfo(const nncc::core::ADT::feature::Shape &shape) : _shape{shape}
virtual ~KernelObject();
private:
+ void get(ObjectInfo **) const override;
void get(const PtrLink<Bag, BagInfo> **out) const override;
public:
#ifndef __COCO_IR_KERNEL_OBJECT_INFO_H__
#define __COCO_IR_KERNEL_OBJECT_INFO_H__
+#include "coco/IR/ObjectInfo.h"
+
#include <nncc/core/ADT/kernel/Shape.h>
namespace coco
{
-class KernelObjectInfo final
+class KernelObjectInfo final : public ObjectInfo
{
public:
KernelObjectInfo(const nncc::core::ADT::kernel::Shape &shape) : _shape{shape}
#define __COCO_IR_OBJECT_H__
#include "coco/IR/Bag.h"
+#include "coco/IR/ObjectInfo.forward.h"
#include "coco/IR/FeatureObject.forward.h"
#include "coco/IR/KernelObject.forward.h"
virtual ~Object() = default;
protected:
+ virtual void get(ObjectInfo **) const = 0;
virtual void get(const PtrLink<Bag, BagInfo> **) const = 0;
protected:
namespace coco
{
-class ObjectInfo final
+class ObjectInfo
{
public:
ObjectInfo() = default;
+
+public:
+ virtual ~ObjectInfo() = default;
};
} // namespace coco
// DO NOTHING
}
+void FeatureObject::get(ObjectInfo **out) const { *out = _info.get(); }
void FeatureObject::get(const PtrLink<Bag, BagInfo> **out) const { *out = _link; }
const nncc::core::ADT::feature::Shape &FeatureObject::shape(void) const { return _info->shape(); }
// DO NOTHING
}
+void KernelObject::get(ObjectInfo **out) const { *out = _info.get(); }
void KernelObject::get(const PtrLink<Bag, BagInfo> **out) const { *out = _link; }
const nncc::core::ADT::kernel::Shape &KernelObject::shape(void) const { return _info->shape(); }
#include "coco/IR/Object.h"
+#include "coco/IR/ObjectInfo.h"
#include "coco/IR/BagManager.h"
#include "coco/IR/BagInfo.h"
+#include <nncc/foundation/Memory.h>
+
#include <vector>
#include <gtest/gtest.h>
+using nncc::foundation::make_unique;
+
namespace
{
class ObjectTest : public ::testing::Test
virtual ~Object() = default;
public:
+ std::unique_ptr<coco::ObjectInfo> info;
const coco::PtrLink<coco::Bag, coco::BagInfo> *link;
private:
+ void get(coco::ObjectInfo **out) const override { *out = info.get(); }
void get(const coco::PtrLink<coco::Bag, coco::BagInfo> **out) const override { *out = link; }
};
} // namespace mock
std::vector<coco::Bag *> updates;
DummyObject obj{updates};
+ obj.info = make_unique<coco::ObjectInfo>();
obj.link = &link;
obj.bag(bag);