G
Guest
Hi,
I have an public interface ILocal, and a private class (Local) derived from
this interface. The interface have 2 functions (GetValue() and SetValue()).
My object must be a singleton! How can i get a pointer to the unique instance
of my class!? I can't add a static function in the interface.. I can't add
global function.. I found a way.. (as describe later) but it have a better
way!??
----
The solution is to set my class "Local" public, and add a static function to
my class. I set the contructor private, to prevent anyone to instance my
class. But with this, others modules can call directly the other public
function (ex: GetValue() and SetValue() derived from ILocal). Someone tell me
that i can prevent this if i declare function like this :
public __gc class Local : public ILocal
{
///Get the singleton
static ILocalPersistence* GetLocalPersistence();
Object * ILocal::GetValue(String* _Name);
Void ILocal::SetValue(String* _Name, Object * _Value);
}
But i wasnt able to found how to implement this functions in the .cpp! All
the patterns i tried doent work!
Object * Local::ILocal::GetValue(String* _Name)
Object * Local::GetValue(String* _Name)
Object * ILocal::Local::GetValue(String* _Name)
Tell me if there are a better way to do that.. If not, what i did wrong!?
Thanks
I have an public interface ILocal, and a private class (Local) derived from
this interface. The interface have 2 functions (GetValue() and SetValue()).
My object must be a singleton! How can i get a pointer to the unique instance
of my class!? I can't add a static function in the interface.. I can't add
global function.. I found a way.. (as describe later) but it have a better
way!??
----
The solution is to set my class "Local" public, and add a static function to
my class. I set the contructor private, to prevent anyone to instance my
class. But with this, others modules can call directly the other public
function (ex: GetValue() and SetValue() derived from ILocal). Someone tell me
that i can prevent this if i declare function like this :
public __gc class Local : public ILocal
{
///Get the singleton
static ILocalPersistence* GetLocalPersistence();
Object * ILocal::GetValue(String* _Name);
Void ILocal::SetValue(String* _Name, Object * _Value);
}
But i wasnt able to found how to implement this functions in the .cpp! All
the patterns i tried doent work!
Object * Local::ILocal::GetValue(String* _Name)
Object * Local::GetValue(String* _Name)
Object * ILocal::Local::GetValue(String* _Name)
Tell me if there are a better way to do that.. If not, what i did wrong!?
Thanks