summaryrefslogtreecommitdiffabout
path: root/include/napkin
authorMichael Krelin <hacker@klever.net>2008-04-05 11:17:33 (UTC)
committer Michael Krelin <hacker@klever.net>2008-04-05 11:17:33 (UTC)
commit04fb190243442e83349f129b523ab747e58100bf (patch) (unidiff)
treeddc28357fbe78b07fd3a5e0aa8088130bf305829 /include/napkin
downloadnapkin-0.0.zip
napkin-0.0.tar.gz
napkin-0.0.tar.bz2
Initial commit into public repository0.0
Signed-off-by: Michael Krelin <hacker@klever.net>
Diffstat (limited to 'include/napkin') (more/less context) (ignore whitespace changes)
-rw-r--r--include/napkin/exception.h36
-rw-r--r--include/napkin/st/decode.h15
-rw-r--r--include/napkin/st/download.h20
-rw-r--r--include/napkin/types.h46
-rw-r--r--include/napkin/util.h14
5 files changed, 131 insertions, 0 deletions
diff --git a/include/napkin/exception.h b/include/napkin/exception.h
new file mode 100644
index 0000000..b317886
--- a/dev/null
+++ b/include/napkin/exception.h
@@ -0,0 +1,36 @@
1#ifndef __NAPKIN_EXCEPTION_H
2#define __NAPKIN_EXCEPTION_H
3
4#include <stdexcept>
5#include <string>
6
7 #defineNAPKIN_E_SUBCLASS(derived,base) \
8 class derived : public base { \
9 public: \
10 explicit derived(const string& w) \
11 : base(w) { } \
12 }
13
14namespace napkin {
15 using std::string;
16
17 class exception : public std::runtime_error {
18 public:
19 explicit exception(const string& w)
20 : std::runtime_error(w) { }
21 ~exception() throw() { }
22 };
23
24 NAPKIN_E_SUBCLASS(exception_sleeptracker,exception);
25 NAPKIN_E_SUBCLASS(exception_st_port,exception_sleeptracker);
26 NAPKIN_E_SUBCLASS(exception_st_data,exception_sleeptracker);
27 NAPKIN_E_SUBCLASS(exception_st_data_envelope,exception_st_data);
28 NAPKIN_E_SUBCLASS(exception_st_data_integrity,exception_st_data_envelope);
29
30 NAPKIN_E_SUBCLASS(exception_db,exception);
31 NAPKIN_E_SUBCLASS(exception_db_already,exception_db);
32}
33
34#undef NAPKIN_E_SUBCLASS
35
36#endif /* __NAPKIN_EXCEPTION_H */
diff --git a/include/napkin/st/decode.h b/include/napkin/st/decode.h
new file mode 100644
index 0000000..e1f1d07
--- a/dev/null
+++ b/include/napkin/st/decode.h
@@ -0,0 +1,15 @@
1#ifndef __NAPKIN_ST_DECODE_H
2#define __NAPKIN_ST_DECODE_H
3
4#include <napkin/types.h>
5
6namespace napkin {
7 namespace sleeptracker {
8
9 hypnodata_t& decode(hypnodata_t& rv,const void *data,size_t data_length);
10 hypnodata_ptr_t decode(const void *data,size_t data_length);
11
12 }
13}
14
15#endif /* __NAPKIN_ST_DECODE_H */
diff --git a/include/napkin/st/download.h b/include/napkin/st/download.h
new file mode 100644
index 0000000..92d1d9d
--- a/dev/null
+++ b/include/napkin/st/download.h
@@ -0,0 +1,20 @@
1#ifndef __NAPKIN_ST_DOWNLOAD_H
2#define __NAPKIN_ST_DOWNLOAD_H
3
4#include <napkin/types.h>
5
6namespace napkin {
7 namespace sleeptracker {
8
9 int download_initiate(const char *port=0);
10 size_t download_finish(int fd,void *buffer,size_t buffer_size);
11
12 size_t download(
13 void *buffer,size_t buffer_size,
14 const char *port=0);
15 hypnodata_ptr_t download(const char *port=0);
16
17 }
18}
19
20#endif /* __NAPKIN_ST_DOWNLOAD_H */
diff --git a/include/napkin/types.h b/include/napkin/types.h
new file mode 100644
index 0000000..2bc3a0a
--- a/dev/null
+++ b/include/napkin/types.h
@@ -0,0 +1,46 @@
1#ifndef __NAPKIN_TYPES_H
2#define __NAPKIN_TYPES_H
3
4#include <time.h>
5#include <string>
6#include <vector>
7#include <tr1/memory>
8
9namespace napkin {
10 using std::vector;
11 using std::tr1::shared_ptr;
12 using std::string;
13
14 class hypnodata_t {
15 public:
16 time_t to_bed;
17 time_t alarm;
18 int window;
19 vector<time_t> almost_awakes;
20 int data_a;
21
22 void clear();
23
24 void set_to_bed(const string& w3c);
25 void set_alarm(const string& w3c);
26 void set_window(const string& str);
27 void set_data_a(const string& str);
28 void set_almost_awakes(const string& str);
29
30 const string w3c_to_bed() const;
31 const string w3c_alarm() const;
32 const string w3c_almostawakes() const;
33
34 const string str_to_bed() const;
35 const string str_alarm() const;
36 const string str_date() const;
37 const string str_data_a() const;
38
39 time_t aligned_start() const;
40 };
41
42 typedef shared_ptr<hypnodata_t> hypnodata_ptr_t;
43
44}
45
46#endif /* __NAPKIN_TYPES_H */
diff --git a/include/napkin/util.h b/include/napkin/util.h
new file mode 100644
index 0000000..bf7946d
--- a/dev/null
+++ b/include/napkin/util.h
@@ -0,0 +1,14 @@
1#ifndef __NAPKIN_UTIL_H
2#define __NAPKIN_UTIL_H
3
4#include <time.h>
5#include <string>
6
7namespace napkin {
8 using std::string;
9
10 string strftime(const char *fmt,time_t t);
11
12}
13
14#endif /* __NAPKIN_UTIL_H */