]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- added one example program
authorArvin Schnell <aschnell@suse.de>
Wed, 14 Sep 2011 13:42:08 +0000 (15:42 +0200)
committerArvin Schnell <aschnell@suse.de>
Wed, 14 Sep 2011 13:42:08 +0000 (15:42 +0200)
examples/.gitignore
examples/ListAll.cc [new file with mode: 0644]
examples/Makefile.am
snapper/Factory.h
snapper/Snapper.h
snapper/Snapshot.h

index 6f5b1b863388435aea2ac921c68122b92ed9afa2..8b24cf1c5f7c8c72dfad5fe5d0fdaaf3d7113f9d 100644 (file)
@@ -1,5 +1,7 @@
 List.o
 List
+ListAll.o
+ListAll
 Create.o
 Create
 CmpDirs.o
diff --git a/examples/ListAll.cc b/examples/ListAll.cc
new file mode 100644 (file)
index 0000000..140bb74
--- /dev/null
@@ -0,0 +1,29 @@
+
+#include <stdlib.h>
+#include <iostream>
+
+#include <snapper/Factory.h>
+#include <snapper/Snapper.h>
+
+using namespace snapper;
+using namespace std;
+
+int
+main(int argc, char** argv)
+{
+    list<ConfigInfo> c = Snapper::getConfigs();
+
+    list<Snapper*> sh;
+
+    for (list<ConfigInfo>::const_iterator it = c.begin(); it != c.end(); ++it)
+       sh.push_back(new Snapper(it->config_name));
+
+    for (list<Snapper*>::const_iterator it = sh.begin(); it != sh.end(); ++it)
+       cout << (*it)->configName() << " " << (*it)->subvolumeDir() << " "
+            << (*it)->getSnapshots().size() << endl;
+
+    for (list<Snapper*>::const_iterator it = sh.begin(); it != sh.end(); ++it)
+       delete *it;
+
+    exit(EXIT_SUCCESS);
+}
index f7e7b6bd77533442f290dc3ff3550f6f6217de4d..0fdbf16e81ea486f973e1cf7ab89fb7975f3eade 100644 (file)
@@ -6,10 +6,12 @@ INCLUDES = -I$(top_srcdir)
 
 LDADD = ../snapper/libsnapper.la
 
-noinst_PROGRAMS = List Create CmpDirs CreateTimeline
+noinst_PROGRAMS = List ListAll Create CmpDirs CreateTimeline
 
 List_SOURCES = List.cc
 
+ListAll_SOURCES = ListAll.cc
+
 Create_SOURCES = Create.cc
 
 CmpDirs_SOURCES = CmpDirs.cc
index 64e3270ef33b76a12b8bf33e0404d819604dd155..ff2bb6d4d63ec01b241bf2359bf068271739c05c 100644 (file)
@@ -35,7 +35,7 @@ namespace snapper
     class Snapper;
 
 
-    // Only one Snapper can be created at a time.
+    // Using the factory functions only one Snapper can exist at a time.
 
     Snapper* createSnapper(const string& config_name = "root", bool disable_filters = false);
 
index 6ed9a080b3c43a07cfdf93372ad23202a9d42392..503d4f87ade775d445e267ea0f03b3341fc7991b 100644 (file)
@@ -109,6 +109,8 @@ namespace snapper
        Snapper(const string& config_name = "root", bool disable_filters = false);
        ~Snapper();
 
+       string configName() const { return config_name; }
+
        string subvolumeDir() const;
        string infosDir() const;
 
index 59a741349f5183ea40fc86cb52942b369a7486ff..237f45f67f80ecb094eadd4a9887898caf5da329 100644 (file)
@@ -145,6 +145,7 @@ namespace snapper
 
        typedef list<Snapshot>::iterator iterator;
        typedef list<Snapshot>::const_iterator const_iterator;
+       typedef list<Snapshot>::size_type size_type;
 
        iterator begin() { return entries.begin(); }
        const_iterator begin() const { return entries.begin(); }
@@ -152,6 +153,8 @@ namespace snapper
        iterator end() { return entries.end(); }
        const_iterator end() const { return entries.end(); }
 
+       size_type size() const { return entries.size(); }
+
        iterator find(unsigned int num);
        const_iterator find(unsigned int num) const;