From: Arvin Schnell Date: Wed, 14 Sep 2011 13:42:08 +0000 (+0200) Subject: - added one example program X-Git-Tag: v0.1.3~296 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=0d3ccea026b248f14328f82ea41a76644ec60dd0;p=thirdparty%2Fsnapper.git - added one example program --- diff --git a/examples/.gitignore b/examples/.gitignore index 6f5b1b86..8b24cf1c 100644 --- a/examples/.gitignore +++ b/examples/.gitignore @@ -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 index 00000000..140bb74f --- /dev/null +++ b/examples/ListAll.cc @@ -0,0 +1,29 @@ + +#include +#include + +#include +#include + +using namespace snapper; +using namespace std; + +int +main(int argc, char** argv) +{ + list c = Snapper::getConfigs(); + + list sh; + + for (list::const_iterator it = c.begin(); it != c.end(); ++it) + sh.push_back(new Snapper(it->config_name)); + + for (list::const_iterator it = sh.begin(); it != sh.end(); ++it) + cout << (*it)->configName() << " " << (*it)->subvolumeDir() << " " + << (*it)->getSnapshots().size() << endl; + + for (list::const_iterator it = sh.begin(); it != sh.end(); ++it) + delete *it; + + exit(EXIT_SUCCESS); +} diff --git a/examples/Makefile.am b/examples/Makefile.am index f7e7b6bd..0fdbf16e 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -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 diff --git a/snapper/Factory.h b/snapper/Factory.h index 64e3270e..ff2bb6d4 100644 --- a/snapper/Factory.h +++ b/snapper/Factory.h @@ -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); diff --git a/snapper/Snapper.h b/snapper/Snapper.h index 6ed9a080..503d4f87 100644 --- a/snapper/Snapper.h +++ b/snapper/Snapper.h @@ -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; diff --git a/snapper/Snapshot.h b/snapper/Snapshot.h index 59a74134..237f45f6 100644 --- a/snapper/Snapshot.h +++ b/snapper/Snapshot.h @@ -145,6 +145,7 @@ namespace snapper typedef list::iterator iterator; typedef list::const_iterator const_iterator; + typedef list::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;