Menu

#26 Decorator design pattern

open
nobody
None
7
2009-02-25
2007-05-26
Omer Katz
No

template <class Decorated, class TList, bool isDynamic = false>
class DecorateClass;

template <class Decorated, class Head>
class DecorateClass<Decorated, Typelist<Head, NullType>, false>
{
public:
static Head *Decorate() { return new Head(new Decorated); }
};

template <class Decorated, class Head, class Tail>
class DecorateClass<Decorated, Typelist<Head, Tail>, false>
{
public:
static Head *Decorate() { return new Head(DecorateClass<Decorated, Tail>::Decorate()); }
};

For now there is only the static implementation for it.
When I will have time I'll make the dynamic one.

Omer

Discussion

  • Omer Katz

    Omer Katz - 2009-02-01

    Hi, can someone write a test case for this?
    Alternatively can someone please explain how should I wrtie a test case?

     
  • Omer Katz

    Omer Katz - 2009-02-01
    • assigned_to: nobody --> rich_sposato
     
  • Richard Sposato

    Richard Sposato - 2009-02-01

    Hi Omer,

    It seems that by assigning this feature request to me, you would like me to write the tests for it. Thanks for the endorsement, but I encourage people who contribute to Loki to write their own unit tests. (Hint: Please don't make a feature request and assign it to somebody without checking with them first.)

    In order to add your Decorator implementation to Loki, I'd like to see documentation comments, unit tests, and usage cases.

    If you need help writing a test case, then I suggest you start with some real world uses of this Decorator implementation. Do you have some real world uses that you can adapt into test cases?

    If you're asking how to create a test project, like the test projects for various parts of Loki, then I suggest looking at many of the test projects which come with Loki. You can use one or more of those as an example for creating your own.

    I hope that answers your questions. If not, please clarify.

    Cheers,

    Rich

     
  • Richard Sposato

    Richard Sposato - 2009-02-01
    • assigned_to: rich_sposato --> nobody
     
  • Omer Katz

    Omer Katz - 2009-02-25

    test case main.cpp

     
  • Omer Katz

    Omer Katz - 2009-02-25

    test case here :)
    File Added: main.cpp

     
  • Omer Katz

    Omer Katz - 2009-02-25

    test case Decorator.hpp

     
  • Omer Katz

    Omer Katz - 2009-02-25

    File Added: Decorator.hpp

     
  • Omer Katz

    Omer Katz - 2009-02-25
    • priority: 5 --> 7
     

Log in to post a comment.