From 9cd3ccffd5372dfde3af478e3f832f18db4be3f1 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 6 Apr 2013 13:14:41 +0200 Subject: tagging tags --- ychat-0.7.9.2/src/memb/memb.h | 23 +++++++++++++++++++++++ ychat-0.7.9.2/src/memb/memb.tmpl | 17 +++++++++++++++++ ychat-0.7.9.2/src/memb/tupel.h | 26 ++++++++++++++++++++++++++ ychat-0.7.9.2/src/memb/tupel.tmpl | 37 +++++++++++++++++++++++++++++++++++++ 4 files changed, 103 insertions(+) create mode 100644 ychat-0.7.9.2/src/memb/memb.h create mode 100644 ychat-0.7.9.2/src/memb/memb.tmpl create mode 100644 ychat-0.7.9.2/src/memb/tupel.h create mode 100644 ychat-0.7.9.2/src/memb/tupel.tmpl (limited to 'ychat-0.7.9.2/src/memb') diff --git a/ychat-0.7.9.2/src/memb/memb.h b/ychat-0.7.9.2/src/memb/memb.h new file mode 100644 index 0000000..9c398ec --- /dev/null +++ b/ychat-0.7.9.2/src/memb/memb.h @@ -0,0 +1,23 @@ +#ifndef MEMB_H +#define MEMB_H + +#include "../incl.h" +#include "../maps/nhashmap.h" +#include "tupel.h" + +using namespace std; + +template +class memb +{ +private: + nhashmap< mutexed_tupel* > map_elems; + +public: + inline obj_type get_elem(string s_key); + inline void set_elem(obj_type t_obj, string s_key); + +}; + +#include "memb.tmpl" +#endif diff --git a/ychat-0.7.9.2/src/memb/memb.tmpl b/ychat-0.7.9.2/src/memb/memb.tmpl new file mode 100644 index 0000000..0b4da0e --- /dev/null +++ b/ychat-0.7.9.2/src/memb/memb.tmpl @@ -0,0 +1,17 @@ +template +obj_type +memb::get_elem(string s_key) +{ + mutexed_tupel *p_tupel = map_elems.get_elem(s_key); + if ( p_tupel ) + return p_tupel->get_elem(); + + return obj_type(); +} + +template +void +memb::set_elem(obj_type t_obj, string s_key) +{ + // mutexed_tupel *p_tupel = map_elems +} diff --git a/ychat-0.7.9.2/src/memb/tupel.h b/ychat-0.7.9.2/src/memb/tupel.h new file mode 100644 index 0000000..bb1939e --- /dev/null +++ b/ychat-0.7.9.2/src/memb/tupel.h @@ -0,0 +1,26 @@ +#ifndef TUPEL_H +#define TUPEL_H + +#include "../incl.h" + +#define mutexed_tupel tupel + +using namespace std; + +template +class tupel +{ +private: + pthread_mutex_t mut_tupel; + obj_type t_obj; +public: + tupel(); + tupel(obj_type t_obj); + ~tupel(); + + inline obj_type get_elem(); + inline void set_elem(obj_type t_obj); +}; + +#include "tupel.tmpl" +#endif diff --git a/ychat-0.7.9.2/src/memb/tupel.tmpl b/ychat-0.7.9.2/src/memb/tupel.tmpl new file mode 100644 index 0000000..bdde516 --- /dev/null +++ b/ychat-0.7.9.2/src/memb/tupel.tmpl @@ -0,0 +1,37 @@ +template +tupel::tupel() +{ + pthread_mutex_init( &mut_tupel, NULL ); +} + +template +tupel::tupel(obj_type t_obj) +{ + this->t_obj = t_obj; + pthread_mutex_init( &mut_tupel, NULL ); +} + +template +tupel::~tupel() +{ + pthread_mutex_destroy( &mut_tupel ); +} + +template +obj_type +tupel::get_elem() +{ + pthread_mutex_lock( &mut_tupel ); + obj_type t_ret = t_obj; + pthread_mutex_unlock( &mut_tupel ); + return t_ret; +} + +template +void +tupel::set_elem(obj_type t_obj) +{ + pthread_mutex_lock( &mut_tupel ); + this->t_obj = t_obj; + pthread_mutex_unlock( &mut_tupel ); +} -- cgit v1.2.3