Fairport  v1.0.38
fairport/pst/task.h
Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 #ifndef FAIRPORT_PST_TASK_H
00009 #define FAIRPORT_PST_TASK_H
00010 
00011 #include <string>
00012 #include <memory>
00013 
00014 #include "fairport/ndb/database_iface.h"
00015 #include "fairport/ndb/node.h"
00016 
00017 #include "fairport/ltp/propbag.h"
00018 #include "fairport/ltp/table.h"
00019 #include "fairport/ltp/nameid.h"
00020 
00021 #include "fairport/pst/pstutil.h"
00022 #include "fairport/pst/message.h"
00023 
00024 namespace fairport 
00025 {
00026 
00029 
00036 class task : public detail::itembase
00037 {
00038 public:
00041     explicit task(const node& n)
00042         : detail::itembase(n) { }
00043 
00044     // property access
00048     std::wstring get_name() const;
00051     bool has_subject() const
00052         { return get_property_bag().prop_exists(0x37); }
00053 
00057     bool is_complete() const
00058         { return get_property_bag().read_prop<bool>(get_name_id_map().lookup(ps_task, 0x811c)); }
00059 
00063     boost::posix_time::ptime get_start_date() const
00064         { return get_property_bag().read_prop<boost::posix_time::ptime>(get_name_id_map().lookup(ps_task, 0x8104)); }
00067     bool has_start_date() const
00068         { return get_property_bag().prop_exists(get_name_id_map().lookup(ps_task, 0x8104)); }
00072     boost::posix_time::ptime get_due_date() const
00073         { return get_property_bag().read_prop<boost::posix_time::ptime>(get_name_id_map().lookup(ps_task, 0x8105)); }
00076     bool has_due_date() const
00077         { return get_property_bag().prop_exists(get_name_id_map().lookup(ps_task, 0x8105)); }
00078 private:
00079     const name_id_map& get_name_id_map() const;
00080 
00081     mutable std::tr1::shared_ptr<name_id_map> m_map;     
00082 };
00083 
00084 typedef detail::item_transform_row<task> task_transform_row;
00085 
00086 } // end namespace fairport
00087 
00088 inline const fairport::name_id_map& fairport::task::get_name_id_map() const
00089 {
00090     if(!m_map)
00091         m_map.reset(new name_id_map(get_property_bag().get_node().get_db()));
00092 
00093     return *m_map;
00094 }
00095 
00096 inline std::wstring fairport::task::get_name() const
00097 {
00098     std::wstring buffer = get_property_bag().read_prop<std::wstring>(0x37);
00099 
00100     if(buffer.size() && buffer[0] == message_subject_prefix_lead_byte)
00101     {
00102         // Skip the second chracter as well
00103         return buffer.substr(2);
00104     }
00105     else
00106     {
00107         return buffer;
00108     }
00109 }
00110 
00111 #endif