#include <stdlib.h>
#include <iostream>
+#include <snapper/Factory.h>
#include <snapper/Snapper.h>
using namespace snapper;
int
main(int argc, char** argv)
{
- getSnapper()->createSingleSnapshot("test");
+ Snapper* sh = createSnapper();
+
+ sh->createSingleSnapshot("test");
exit(EXIT_SUCCESS);
}
#include <stdlib.h>
#include <iostream>
+#include <snapper/Factory.h>
#include <snapper/Snapper.h>
using namespace snapper;
int
main(int argc, char** argv)
{
- const Snapshots& snapshots = getSnapper()->getSnapshots();
+ Snapper* sh = createSnapper();
+
+ const Snapshots& snapshots = sh->getSnapshots();
for (Snapshots::const_iterator it = snapshots.begin(); it != snapshots.end(); ++it)
{
cout << *it << endl;
--- /dev/null
+/*
+ * Copyright (c) 2011 Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#include "assert.h"
+#include "auto_ptr.h"
+
+#include "snapper/Snapper.h"
+
+
+namespace snapper
+{
+
+ std::auto_ptr<Snapper> haha;
+
+
+ Snapper*
+ createSnapper()
+ {
+ assert(!haha.get());
+ haha.reset(new Snapper);
+ return haha.get();
+ }
+
+
+ Snapper*
+ getSnapper()
+ {
+ assert(haha.get());
+ return haha.get();
+ }
+
+
+ void
+ deleteSnapper(Snapper* s)
+ {
+ assert(haha.get());
+ assert(s == haha.get());
+ haha.reset();
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2011 Novell, Inc.
+ *
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, contact Novell, Inc.
+ *
+ * To contact Novell about this file by physical or electronic mail, you may
+ * find current contact information at www.novell.com.
+ */
+
+
+#include "snapper/Snapper.h"
+
+
+namespace snapper
+{
+
+ // Only one Snapper can be created at a time.
+
+ Snapper* createSnapper();
+
+ Snapper* getSnapper();
+
+ void deleteSnapper(Snapper*);
+
+}
#include "snapper/File.h"
#include "snapper/Snapper.h"
+#include "snapper/Factory.h"
#include "snapper/AppUtil.h"
#include "snapper/XmlFile.h"
#include "snapper/Enum.h"
libsnapper_la_SOURCES = \
Snapper.cc Snapper.h \
+ Factory.cc Factory.h \
Snapshot.cc Snapshot.h \
File.cc File.h \
XmlFile.cc XmlFile.h \
AppUtil.cc AppUtil.h \
Compare.cc Compare.h \
SystemCmd.cc SystemCmd.h \
- SnapperTmpl.h SnapperDefines.h
+ SnapperTmpl.h \
+ SnapperDefines.h
libsnapper_la_LDFLAGS = -version-info 2:0
libsnapper_la_LIBADD = -lblocxx -lxml2
pkginclude_HEADERS = \
Snapper.h \
+ Factory.h \
Snapshot.h \
File.h
using namespace std;
- Snapper* snapper_singleton = NULL;
-
-
- Snapper*
- getSnapper()
- {
- if (!snapper_singleton)
- snapper_singleton = new Snapper();
-
- return snapper_singleton;
- }
-
-
Snapper::Snapper()
: compare_callback(NULL)
{
};
-
- Snapper* getSnapper();
-
};
#include <getopt.h>
#include <iostream>
+#include <snapper/Factory.h>
#include <snapper/Snapper.h>
#include <snapper/Snapshot.h>
#include <snapper/File.h>
cmds["diff"] = showDifference;
cmds["rollback"] = doRollback;
- sh = getSnapper();
+ sh = createSnapper();
sh->setCompareCallback(&compare_callback_impl);
++cnt;
}
}
+
+ deleteSnapper(sh);
+
exit(EXIT_SUCCESS);
}