virtual ~FeatureObject() = default;
public:
+ FeatureObject *asFeature(void) override { return this; }
+ const FeatureObject *asFeature(void) const override { return this; }
+
+public:
const nncc::core::ADT::feature::Shape &shape(void) const { return _shape; }
private:
#include "coco/IR/Bag.h"
+#include "coco/IR/FeatureObject.forward.h"
+
namespace coco
{
public:
coco::Bag *bag(void) const { return _bag; }
void bag(coco::Bag *bag);
+
+public:
+ virtual FeatureObject *asFeature(void) { return nullptr; }
+ virtual const FeatureObject *asFeature(void) const { return nullptr; }
};
} // namespace coco
ASSERT_EQ(o.shape(), shape);
}
+
+TEST(IR_FEATURE_OBJECT, asFeature)
+{
+ const nncc::core::ADT::feature::Shape shape{1, 3, 3};
+ coco::FeatureObject o{shape};
+
+ coco::Object *mutable_object = &o;
+ const coco::Object *immutable_object = &o;
+
+ ASSERT_NE(mutable_object->asFeature(), nullptr);
+ ASSERT_EQ(mutable_object->asFeature(), immutable_object->asFeature());
+}