On 01/30/2012 01:14 PM, bls wrote:
Hi Philippe,

slightly better ..
class PersonStack
{
        private string name;
        private int age;
        
        // Our Mixins
        mixin MIStack;
        mixin MIPublisher;
                
        this()
        {
                // Register some subscribers (MIPublisher register function)
                // I have used free functions to show the useful toDelegate()
                register( toDelegate(&DrawPersonBarChart) );        
                register( toDelegate(&DrawPersonPieChart) );        
        }
        
        // Push
        void add(string name, int age)
        {
                auto p = new PersonStack();
                p.name = name;
                p.age = age;
                // Add Person (MIStack push function.)
                push(p);
                
                // Notify all subscribers               
                notify("Push");
                        
        }
        void remove()
        {
                auto el = pop();
                notify("Pop " ~ el.name );
        }
}

Reply via email to