1

(0 replies, posted in Gossip)

Hello,

I just discovered Maratis, and I am really impressed. You did a really great work.
I'll try to use it in a really near futur.

One suggestion: wouldn't it be better if you implement your singleton in a more secured way ?
I mean:
- Have the constructor private.
- Have a static instance set to null and instantiate it if needed.

A short sample:

In
class SingleObject
{
private:
  static SingleObject*_instance;

private:
    // Constructor/Destructor
    SingleObject();
    ~SingleObject();

public:
    static SingleObject* getInstance ()
    {
        if (NULL == _instance)
           _instance =  new SingleObject;

        return _instance;
    }

    static void kill ()
    {
        if (NULL != _instance)
        {
            delete _instance;
            _instance = NULL;
        }
    }
};

In the .cpp file
SingleObject *SingleObject::_instance = NULL;

I think it's a better way to implement the singleton pattern, but it's just my opinion.

Great work, and best regards.