4 commits - c++/lib c++/tests
Christian Mollekopf
mollekopf at kolabsys.com
Wed Feb 29 10:09:06 CET 2012
c++/lib/kolabcontainers.cpp | 6 ------
c++/lib/kolabcontainers.h | 12 ++++++++----
c++/lib/kolabformat.i | 4 ++++
c++/lib/utils.cpp | 22 +++++++++++-----------
c++/lib/xcalconversions.h | 5 ++---
c++/tests/conversiontest.cpp | 38 +++++++++++++++-----------------------
6 files changed, 40 insertions(+), 47 deletions(-)
New commits:
commit 3c3ee425dfcf3b3e26565fd93caec96950fc30ad
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Wed Feb 29 10:08:59 2012 +0100
compile with llvm/clang
diff --git a/c++/lib/xcalconversions.h b/c++/lib/xcalconversions.h
index e0d3412..851871b 100644
--- a/c++/lib/xcalconversions.h
+++ b/c++/lib/xcalconversions.h
@@ -1414,8 +1414,7 @@ template < > struct IncidenceTrait <Kolab::Event>
static void writeIncidence(icalendar_2_0::KolabEvent& vevent, const Kolab::Event &event)
{
-
- typename KolabType::components_type eventComponents;
+ KolabType::components_type eventComponents;
setAlarms<icalendar_2_0::KolabEvent, IncidenceType>(eventComponents, event);
if (!eventComponents.valarm().empty()) {
vevent.components(eventComponents);
@@ -1495,7 +1494,7 @@ template < > struct IncidenceTrait <Kolab::Todo>
static void writeIncidence(icalendar_2_0::KolabTodo& vevent, const Kolab::Todo &todo)
{
- typename KolabType::components_type eventComponents;
+ KolabType::components_type eventComponents;
setAlarms<icalendar_2_0::KolabTodo, IncidenceType>(eventComponents, todo);
if (!eventComponents.valarm().empty()) {
vevent.components(eventComponents);
commit ef8a60eeef04c034b32538d1eec0fd2d4651f510
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Wed Feb 29 10:08:21 2012 +0100
bindings for contacts and journals
diff --git a/c++/lib/kolabformat.i b/c++/lib/kolabformat.i
index 9fb87c0..d4873e1 100644
--- a/c++/lib/kolabformat.i
+++ b/c++/lib/kolabformat.i
@@ -10,6 +10,8 @@
#include "kolabcontainers.h"
#include "kolabevent.h"
#include "kolabtodo.h"
+ #include "kolabjournal.h"
+ #include "kolabcontact.h"
%}
%include "std_string.i"
@@ -28,4 +30,6 @@ namespace std {
%include "kolabcontainers.h"
%include "kolabevent.h"
%include "kolabtodo.h"
+%include "kolabjournal.h"
+%include "kolabcontact.h"
%include "kolabformat.h"
commit 7056f05c08f9bffcee29a674df0d22d682b6b4ea
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Wed Feb 29 10:04:21 2012 +0100
Templated implementation of << operator (so it works for various vectors)
diff --git a/c++/lib/kolabcontainers.cpp b/c++/lib/kolabcontainers.cpp
index f9ca69a..785507c 100644
--- a/c++/lib/kolabcontainers.cpp
+++ b/c++/lib/kolabcontainers.cpp
@@ -477,12 +477,6 @@ bool Attendee::rsvp() const
return d->rsvp;
}
-std::vector<Attendee> operator<<(std::vector<Attendee> v, const Attendee &a)
-{
- v.push_back(a);
- return v;
-}
-
struct Attachment::Private
diff --git a/c++/lib/kolabcontainers.h b/c++/lib/kolabcontainers.h
index 9f5a03f..b8dc630 100644
--- a/c++/lib/kolabcontainers.h
+++ b/c++/lib/kolabcontainers.h
@@ -326,9 +326,6 @@ private:
boost::scoped_ptr<Private> d;
};
-std::vector<Attendee> operator<<(std::vector<Attendee>, const Attendee&);
-
-
struct CustomProperty {
CustomProperty(const std::string &i, const std::string &v)
: identifier(i), value(v) {};
@@ -337,7 +334,14 @@ struct CustomProperty {
std::string identifier;
std::string value;
};
-
+
+template <typename T>
+std::vector<T> operator<< ( std::vector<T> v, const T &s)
+{
+ v.push_back(s);
+ return v;
+}
+
//Prepared Kolab Objects
commit 3515b81aec2775f82dabce52a35184f93e38a6bf
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Fri Feb 24 18:25:34 2012 +0100
Improve multithreading test, disable debug messages.
diff --git a/c++/lib/utils.cpp b/c++/lib/utils.cpp
index c9ed61c..8789f23 100644
--- a/c++/lib/utils.cpp
+++ b/c++/lib/utils.cpp
@@ -44,17 +44,17 @@ boost::thread_specific_ptr<Global> ptr;
class ThreadLocal
{
public:
- static Global &inst()
- {
- Global *t = ptr.get();
- std::cout << "inst " << boost::this_thread::get_id() << std::endl;
- if (!t) {
- std::cout << "initialize Global" << std::endl;
- t = new Global();
- ptr.reset(t);
- }
- return *t;
- }
+ static Global &inst()
+ {
+ Global *t = ptr.get();
+// std::cout << "inst " << boost::this_thread::get_id() << std::endl;
+ if (!t) {
+// std::cout << "initialize Global" << std::endl;
+ t = new Global();
+ ptr.reset(t);
+ }
+ return *t;
+ }
};
void setKolabVersion(const std::string &s)
diff --git a/c++/tests/conversiontest.cpp b/c++/tests/conversiontest.cpp
index 95c4bf1..69352e6 100644
--- a/c++/tests/conversiontest.cpp
+++ b/c++/tests/conversiontest.cpp
@@ -142,35 +142,27 @@ void ConversionTest::uriInlineEncodingTest()
QCOMPARE(d, std::string("data"));
}
-void wait(int seconds)
-{
- boost::this_thread::sleep(boost::posix_time::seconds(seconds));
-}
-
void threadF()
-{
- for (int i = 0; i < 5; ++i)
- {
- std::stringstream s;
- s << boost::this_thread::get_id();
- std::string uid = s.str();//std::string(boost::this_thread::get_id());
- std::cout << uid << std::endl;
- Kolab::Utils::setCreatedUid(uid);
- wait(1);
- if (Kolab::Utils::createdUid() != uid) {
- std::cout << "Error " << uid << std::endl;
- } else {
- std::cout << "ok" << std::endl;
+{
+ for (int i = 0; i < 5; ++i)
+ {
+ std::stringstream s;
+// s << boost::this_thread::get_id();
+ std::string uid = s.str();
+// std::cout << uid << std::endl;
+ Kolab::Utils::setCreatedUid(uid);
+ boost::this_thread::sleep(boost::posix_time::seconds(1));
+ QCOMPARE(Kolab::Utils::createdUid(), uid);
}
- }
-}
+}
void ConversionTest::threadLocalTest()
{
+ //Ensure global variables are not mixed between threads and therefore threadsafe.
boost::thread t(threadF);
- boost::thread t2(threadF);
- t.join();
- t2.join();
+ boost::thread t2(threadF);
+ t.join();
+ t2.join();
}
More information about the commits
mailing list