T
Torsten Wiebesiek
Hi,
I am currently working on a computer vision system. At the moment I'm adding
support for firewire cameras. Since there is only one firewire system on a
computer, I have writen a firewire manager class as Singleton.
User access to firewire camera objects should only be accessable via
refereces obtained from this manager class. I want to avoid the creation of
more than one camera object accessing the same physical camera.
One solution might be making the constuctor (and the copy constructor) of
the camera class private and declaring the manager class a 'friend' to the
camera class:
class FwCamera {
private:
FwCamera ();
public:
...
friend class FwManager;
}
class FwManager {
public:
FwCamera& getCamera(int number_of_camera);
...
}
Now only FwManger can control the construction and destruction of FwCamera
objects. The user can only get access to camera objects via the manager
class.
What I don't like is the keyword 'friend'. Is there a better way, to achieve
my my goals?
Thanks in advance,
Torsten
I am currently working on a computer vision system. At the moment I'm adding
support for firewire cameras. Since there is only one firewire system on a
computer, I have writen a firewire manager class as Singleton.
User access to firewire camera objects should only be accessable via
refereces obtained from this manager class. I want to avoid the creation of
more than one camera object accessing the same physical camera.
One solution might be making the constuctor (and the copy constructor) of
the camera class private and declaring the manager class a 'friend' to the
camera class:
class FwCamera {
private:
FwCamera ();
public:
...
friend class FwManager;
}
class FwManager {
public:
FwCamera& getCamera(int number_of_camera);
...
}
Now only FwManger can control the construction and destruction of FwCamera
objects. The user can only get access to camera objects via the manager
class.
What I don't like is the keyword 'friend'. Is there a better way, to achieve
my my goals?
Thanks in advance,
Torsten