[nvemftp-commit] nvemftp/include hostprofiles.h,1.1,1.2
Status: Beta
Brought to you by:
ndiin
|
From: <nd...@us...> - 2003-10-13 21:01:40
|
Update of /cvsroot/nvemftp/nvemftp/include
In directory sc8-pr-cvs1:/tmp/cvs-serv4364/include
Modified Files:
hostprofiles.h
Log Message:
Change HostProfileManager to use the same singleton construct as nvemSettings.
Index: hostprofiles.h
===================================================================
RCS file: /cvsroot/nvemftp/nvemftp/include/hostprofiles.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- hostprofiles.h 1 Oct 2003 19:54:16 -0000 1.1
+++ hostprofiles.h 13 Oct 2003 21:01:36 -0000 1.2
@@ -11,6 +11,8 @@
#ifndef HOSTPROFILES_H
#define HOSTPROFILES_H
+#include <memory>
+
#include <qmap.h>
#include <qstringlist.h>
#include "nhostinfo.h"
@@ -25,10 +27,15 @@
class HostProfileManager
{
public:
- /// Initialize the host profile manager.
- HostProfileManager();
- /// Destructor.
- ~HostProfileManager();
+ /**
+ * Returns a reference to the host profile manager object.
+ */
+ static HostProfileManager& instance() { return *getInstance(); }
+
+ /**
+ * Returns a const reference to the host profile manager object.
+ */
+ static const HostProfileManager& const_instance() { return *getInstance(); }
/**
* Load host profiles from disk.
@@ -80,13 +87,27 @@
void dumpProfiles() const;
#endif
+protected:
+ /// Initialize the host profile manager.
+ HostProfileManager();
+ /// Destructor.
+ ~HostProfileManager();
+
private:
+ typedef std::auto_ptr<HostProfileManager> HostProfileManagerPtr;
+ /// Return the singleton instance.
+ static HostProfileManagerPtr& getInstance();
+ /// Gives auto_ptr<nvemSettings> access to our destructor.
+ friend class std::auto_ptr<HostProfileManager>;
+
+ /// Copy constructor to prevent creation of a default copy constructor.
+ HostProfileManager(const HostProfileManager&);
+ /// Prevent creation of default assignment operator.
+ HostProfileManager& operator=(const HostProfileManager&);
/// Maps the host profiles to their respective names.
QMap<QString, NHostInfo> hp_map;
};
-
-extern HostProfileManager *nHostMan;
#endif // HOSTPROFILES_H
|