From 04fb190243442e83349f129b523ab747e58100bf Mon Sep 17 00:00:00 2001 From: Michael Krelin Date: Sat, 05 Apr 2008 11:17:33 +0000 Subject: Initial commit into public repository Signed-off-by: Michael Krelin --- (limited to 'include') diff --git a/include/Makefile.am b/include/Makefile.am new file mode 100644 index 0000000..f37e4d7 --- a/dev/null +++ b/include/Makefile.am @@ -0,0 +1,4 @@ +include_HEADERS = $(addprefix napkin/,\ + exception.h types.h util.h \ + st/decode.h st/download.h \ + ) 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 @@ +#ifndef __NAPKIN_EXCEPTION_H +#define __NAPKIN_EXCEPTION_H + +#include +#include + +#define NAPKIN_E_SUBCLASS(derived,base) \ + class derived : public base { \ + public: \ + explicit derived(const string& w) \ + : base(w) { } \ + } + +namespace napkin { + using std::string; + + class exception : public std::runtime_error { + public: + explicit exception(const string& w) + : std::runtime_error(w) { } + ~exception() throw() { } + }; + + NAPKIN_E_SUBCLASS(exception_sleeptracker,exception); + NAPKIN_E_SUBCLASS(exception_st_port,exception_sleeptracker); + NAPKIN_E_SUBCLASS(exception_st_data,exception_sleeptracker); + NAPKIN_E_SUBCLASS(exception_st_data_envelope,exception_st_data); + NAPKIN_E_SUBCLASS(exception_st_data_integrity,exception_st_data_envelope); + + NAPKIN_E_SUBCLASS(exception_db,exception); + NAPKIN_E_SUBCLASS(exception_db_already,exception_db); +} + +#undef NAPKIN_E_SUBCLASS + +#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 @@ +#ifndef __NAPKIN_ST_DECODE_H +#define __NAPKIN_ST_DECODE_H + +#include + +namespace napkin { + namespace sleeptracker { + + hypnodata_t& decode(hypnodata_t& rv,const void *data,size_t data_length); + hypnodata_ptr_t decode(const void *data,size_t data_length); + + } +} + +#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 @@ +#ifndef __NAPKIN_ST_DOWNLOAD_H +#define __NAPKIN_ST_DOWNLOAD_H + +#include + +namespace napkin { + namespace sleeptracker { + + int download_initiate(const char *port=0); + size_t download_finish(int fd,void *buffer,size_t buffer_size); + + size_t download( + void *buffer,size_t buffer_size, + const char *port=0); + hypnodata_ptr_t download(const char *port=0); + + } +} + +#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 @@ +#ifndef __NAPKIN_TYPES_H +#define __NAPKIN_TYPES_H + +#include +#include +#include +#include + +namespace napkin { + using std::vector; + using std::tr1::shared_ptr; + using std::string; + + class hypnodata_t { + public: + time_t to_bed; + time_t alarm; + int window; + vector almost_awakes; + int data_a; + + void clear(); + + void set_to_bed(const string& w3c); + void set_alarm(const string& w3c); + void set_window(const string& str); + void set_data_a(const string& str); + void set_almost_awakes(const string& str); + + const string w3c_to_bed() const; + const string w3c_alarm() const; + const string w3c_almostawakes() const; + + const string str_to_bed() const; + const string str_alarm() const; + const string str_date() const; + const string str_data_a() const; + + time_t aligned_start() const; + }; + + typedef shared_ptr hypnodata_ptr_t; + +} + +#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 @@ +#ifndef __NAPKIN_UTIL_H +#define __NAPKIN_UTIL_H + +#include +#include + +namespace napkin { + using std::string; + + string strftime(const char *fmt,time_t t); + +} + +#endif /* __NAPKIN_UTIL_H */ -- cgit v0.9.0.2