summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/kernel/debug.hpp
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2009-11-30 08:36:07 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2009-11-30 08:36:07 +0000
commitcd7dae28b034deebc9c2c2469ed9d8f1f3dab1ed (patch)
tree80cead86cff364718c968849e1c185121a79892d /sca-cpp/trunk/kernel/debug.hpp
parenta9941f3ba6624b88ef62a2a7bf260f50761ffbf9 (diff)
Added debug macros and cleaned up debug logging. Added locking macros used when compiling for multithreading. Fixed value conversions to numbers. Fixed compile warnings.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@885348 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--sca-cpp/trunk/kernel/debug.hpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/sca-cpp/trunk/kernel/debug.hpp b/sca-cpp/trunk/kernel/debug.hpp
new file mode 100644
index 0000000000..8dad5fdd3c
--- /dev/null
+++ b/sca-cpp/trunk/kernel/debug.hpp
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef tuscany_debug_hpp
+#define tuscany_debug_hpp
+
+/**
+ * Functions to help log and debug.
+ */
+
+namespace tuscany
+{
+
+#ifdef _DEBUG
+
+/**
+ * Debug log.
+ */
+template<typename V> const bool debug(const V& v, const std::string& msg) {
+ std::cerr<< msg << ": " << v << std::endl;
+ return true;
+}
+
+/**
+ * Increment / decrement a debug counter.
+ */
+bool debug_inc(long int& c) {
+ c++;
+ return true;
+}
+
+bool debug_dec(long int& c) {
+ c--;
+ return true;
+}
+
+#define unused __attribute__ ((unused))
+
+#else
+
+#define debug(v, msg)
+
+#define debug_inc(c)
+#define debug_dec(c)
+#define unused
+
+#endif
+
+}
+#endif /* tuscany_debug_hpp */