Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 1 | /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2012 University of California, Los Angeles |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation; |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | * |
| 18 | * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu> |
| 19 | * Chaoyi Bian <bcy@pku.edu.cn> |
| 20 | * Alexander Afanasyev <alexander.afanasyev@ucla.edu> |
| 21 | */ |
| 22 | |
| 23 | #include "sqlite-helper.h" |
Alexander Afanasyev | ae43c50 | 2012-12-29 17:26:37 -0800 | [diff] [blame] | 24 | #include <iostream> |
| 25 | |
| 26 | using namespace std; |
| 27 | using namespace boost; |
| 28 | |
| 29 | typedef boost::error_info<struct tag_errmsg, std::string> errmsg_info_str; |
| 30 | |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 31 | |
| 32 | int |
| 33 | main (int argc, char **argv) |
| 34 | { |
Alexander Afanasyev | ae43c50 | 2012-12-29 17:26:37 -0800 | [diff] [blame] | 35 | try |
| 36 | { |
| 37 | DbHelper db ("./"); |
| 38 | |
| 39 | HashPtr hash = db.RememberStateInStateLog (); |
| 40 | // should be empty |
| 41 | cout << "Hash: [" << *hash << "]" << endl; |
| 42 | |
| 43 | // |
| 44 | db.UpdateDeviceSeqno ("Alex", 1); |
| 45 | hash = db.RememberStateInStateLog (); |
| 46 | cout << "Hash: [" << *hash << "]" << endl; |
| 47 | |
| 48 | db.UpdateDeviceSeqno ("Alex", 2); |
| 49 | hash = db.RememberStateInStateLog (); |
| 50 | cout << "Hash: [" << *hash << "]" << endl; |
| 51 | |
| 52 | db.UpdateDeviceSeqno ("Alex", 2); |
| 53 | hash = db.RememberStateInStateLog (); |
| 54 | cout << "Hash: [" << *hash << "]" << endl; |
| 55 | |
| 56 | db.UpdateDeviceSeqno ("Alex", 1); |
| 57 | hash = db.RememberStateInStateLog (); |
| 58 | cout << "Hash: [" << *hash << "]" << endl; |
| 59 | |
| 60 | db.FindStateDifferences ("00", "ec0a9941fa726e1fb8f34ecdbd8e3faa75dc9dba22e6a2ea1d8482aae5fdfb52"); |
| 61 | db.FindStateDifferences ("ec0a9941fa726e1fb8f34ecdbd8e3faa75dc9dba22e6a2ea1d8482aae5fdfb52", "00"); |
| 62 | db.FindStateDifferences ("869c38c6dffe8911ced320aecc6d9244904d13d3e8cd21081311f2129b4557ce", |
| 63 | "ec0a9941fa726e1fb8f34ecdbd8e3faa75dc9dba22e6a2ea1d8482aae5fdfb52"); |
| 64 | db.FindStateDifferences ("ec0a9941fa726e1fb8f34ecdbd8e3faa75dc9dba22e6a2ea1d8482aae5fdfb52", |
| 65 | "869c38c6dffe8911ced320aecc6d9244904d13d3e8cd21081311f2129b4557ce"); |
| 66 | |
| 67 | db.UpdateDeviceSeqno ("Bob", 1); |
| 68 | hash = db.RememberStateInStateLog (); |
| 69 | cout << "Hash: [" << *hash << "]" << endl; |
| 70 | |
| 71 | db.FindStateDifferences ("00", "48f4d95b503b9a79c2d5939fa67722b13fc01db861fc501d09efd0a38dbafab8"); |
| 72 | db.FindStateDifferences ("ec0a9941fa726e1fb8f34ecdbd8e3faa75dc9dba22e6a2ea1d8482aae5fdfb52", |
| 73 | "48f4d95b503b9a79c2d5939fa67722b13fc01db861fc501d09efd0a38dbafab8"); |
| 74 | } |
| 75 | catch (const boost::exception &e) |
| 76 | { |
| 77 | cout << "ERRORR: " << *get_error_info<errmsg_info_str> (e) << endl; |
| 78 | } |
| 79 | |
Alexander Afanasyev | 71b43e7 | 2012-12-27 01:03:43 -0800 | [diff] [blame] | 80 | return 0; |
| 81 | } |