summaryrefslogtreecommitdiff
path: root/ychat-0.7.9.2/src/memb
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2013-04-06 13:14:41 +0200
committerPaul Buetow <paul@buetow.org>2013-04-06 13:14:41 +0200
commit9cd3ccffd5372dfde3af478e3f832f18db4be3f1 (patch)
tree631c295a4a4a16b57502b847626763a279bf6df7 /ychat-0.7.9.2/src/memb
parent13aaf70af703748fe096e0664c305cd202637ad2 (diff)
tagging tags
Diffstat (limited to 'ychat-0.7.9.2/src/memb')
-rw-r--r--ychat-0.7.9.2/src/memb/memb.h23
-rw-r--r--ychat-0.7.9.2/src/memb/memb.tmpl17
-rw-r--r--ychat-0.7.9.2/src/memb/tupel.h26
-rw-r--r--ychat-0.7.9.2/src/memb/tupel.tmpl37
4 files changed, 103 insertions, 0 deletions
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 obj_type>
+class memb
+{
+private:
+ nhashmap< mutexed_tupel<obj_type>* > 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<class obj_type>
+obj_type
+memb<obj_type>::get_elem(string s_key)
+{
+ mutexed_tupel<obj_type> *p_tupel = map_elems.get_elem(s_key);
+ if ( p_tupel )
+ return p_tupel->get_elem();
+
+ return obj_type();
+}
+
+template<class obj_type>
+void
+memb<obj_type>::set_elem(obj_type t_obj, string s_key)
+{
+ // mutexed_tupel<obj_type> *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 obj_type>
+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<class obj_type>
+tupel<obj_type>::tupel()
+{
+ pthread_mutex_init( &mut_tupel, NULL );
+}
+
+template<class obj_type>
+tupel<obj_type>::tupel(obj_type t_obj)
+{
+ this->t_obj = t_obj;
+ pthread_mutex_init( &mut_tupel, NULL );
+}
+
+template<class obj_type>
+tupel<obj_type>::~tupel()
+{
+ pthread_mutex_destroy( &mut_tupel );
+}
+
+template<class obj_type>
+obj_type
+tupel<obj_type>::get_elem()
+{
+ pthread_mutex_lock( &mut_tupel );
+ obj_type t_ret = t_obj;
+ pthread_mutex_unlock( &mut_tupel );
+ return t_ret;
+}
+
+template<class obj_type>
+void
+tupel<obj_type>::set_elem(obj_type t_obj)
+{
+ pthread_mutex_lock( &mut_tupel );
+ this->t_obj = t_obj;
+ pthread_mutex_unlock( &mut_tupel );
+}