Skip to content

Commit

Permalink
Merge pull request #96 from UG4/95-avoid-slicing
Browse files Browse the repository at this point in the history
Member variable  m_passOnBehaviour now moved to abstract base. Menat …
  • Loading branch information
anaegel authored Sep 27, 2024
2 parents ea1bb5f + 40b4341 commit 00fe805
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions ugbase/lib_grid/attachments/attachment_pipe.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,19 +238,24 @@ template <class T> class UG_API AttachmentDataContainer : public IAttachmentData
class UG_API IAttachment : public UID
{
public:
IAttachment() : m_name("undefined") {}
IAttachment(const char* name) : m_name(name)
{assert(m_name);}
IAttachment() : m_name("undefined"), m_passOnBehaviour(false) {}
IAttachment(const char* name) : m_name(name), m_passOnBehaviour(false)
{assert(m_name);}
protected:
IAttachment(bool passOnBehaviour) : m_name("undefined"), m_passOnBehaviour(passOnBehaviour) {}
IAttachment(const char* name, bool passOnBehaviour) : m_name(name), m_passOnBehaviour(passOnBehaviour) {}
public:

virtual ~IAttachment() {}
virtual IAttachment* clone() = 0;
virtual IAttachmentDataContainer* create_container() = 0;
virtual bool default_pass_on_behaviour() const = 0;

bool default_pass_on_behaviour() const {return m_passOnBehaviour;}
const char* get_name() {return m_name;} ///< should only be used for debug purposes.

protected:
const char* m_name; //only for debug
bool m_passOnBehaviour;
};

////////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -265,19 +270,16 @@ template <class T> class UG_API Attachment : public IAttachment
typedef AttachmentDataContainer<T> ContainerType;
typedef T ValueType;

Attachment() : IAttachment(), m_passOnBehaviour(false) {}
Attachment(bool passOnBehaviour) : IAttachment(), m_passOnBehaviour(passOnBehaviour) {}
Attachment(const char* name) : IAttachment(name), m_passOnBehaviour(false) {}
Attachment(const char* name, bool passOnBehaviour) : IAttachment(name), m_passOnBehaviour(passOnBehaviour) {}
Attachment() : IAttachment() {}
Attachment(bool passOnBehaviour) : IAttachment(passOnBehaviour) {}
Attachment(const char* name) : IAttachment(name) {}
Attachment(const char* name, bool passOnBehaviour) : IAttachment(name, passOnBehaviour) {}

virtual ~Attachment() {}
virtual IAttachment* clone() {IAttachment* pA = new Attachment<T>; *pA = *this; return pA;}
virtual IAttachment* clone() {IAttachment* pA = new Attachment<T>(this->m_name, this->m_passOnBehaviour); return pA;}
virtual IAttachmentDataContainer* create_container() {return new ContainerType;}
virtual bool default_pass_on_behaviour() const {return m_passOnBehaviour;}
IAttachmentDataContainer* create_container(const T& defaultValue) {return new ContainerType(defaultValue);}

protected:
bool m_passOnBehaviour;
IAttachmentDataContainer* create_container(const T& defaultValue) {return new ContainerType(defaultValue);}
};

////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 00fe805

Please sign in to comment.