diff options
Diffstat (limited to '')
-rw-r--r-- | sca-cpp/trunk/kernel/Makefile.am | 16 | ||||
-rw-r--r-- | sca-cpp/trunk/kernel/cache-test.cpp (renamed from sca-cpp/trunk/modules/cache/diskcache-test.cpp) | 8 | ||||
-rw-r--r-- | sca-cpp/trunk/kernel/cache.hpp (renamed from sca-cpp/trunk/modules/cache/cache.hpp) | 16 | ||||
-rwxr-xr-x | sca-cpp/trunk/kernel/diskcache-test (renamed from sca-cpp/trunk/modules/cache/diskcached-test) | 2 |
4 files changed, 26 insertions, 16 deletions
diff --git a/sca-cpp/trunk/kernel/Makefile.am b/sca-cpp/trunk/kernel/Makefile.am index 0bbfa195c7..1a9d5c8533 100644 --- a/sca-cpp/trunk/kernel/Makefile.am +++ b/sca-cpp/trunk/kernel/Makefile.am @@ -15,17 +15,27 @@ # specific language governing permissions and limitations # under the License. -noinst_PROGRAMS = kernel-test xsd-test +noinst_PROGRAMS = kernel-test cache-test xsd-test -nobase_include_HEADERS = *.hpp +testdir=$(prefix)/test +test_LTLIBRARIES = libdynlib-test.la + +includedir = $(prefix)/include/kernel +include_HEADERS = *.hpp INCLUDES = -I. -I$(top_builddir)/kernel -I${LIBXML2_INCLUDE} -I${APR_INCLUDE} kernel_test_SOURCES = kernel-test.cpp kernel_test_LDADD = -lpthread -L${LIBXML2_LIB} -lxml2 -L${APR_LIB} -lapr-1 -laprutil-1 +libdynlib_test_la_SOURCES = dynlib-test.cpp +libdynlib_test_la_LIBADD = -lpthread -L${LIBXML2_LIB} -lxml2 -L${APR_LIB} -lapr-1 -laprutil-1 + +cache_test_SOURCES = cache-test.cpp +cache_test_LDADD = -lpthread -L${LIBXML2_LIB} -lxml2 -L${APR_LIB} -lapr-1 -laprutil-1 + xsd_test_SOURCES = xsd-test.cpp xsd_test_LDADD = -lpthread -L${LIBXML2_LIB} -lxml2 -L${APR_LIB} -lapr-1 -laprutil-1 -TESTS = kernel-test +TESTS = kernel-test diskcache-test diff --git a/sca-cpp/trunk/modules/cache/diskcache-test.cpp b/sca-cpp/trunk/kernel/cache-test.cpp index 3b21de7b9e..5391d38cf6 100644 --- a/sca-cpp/trunk/modules/cache/diskcache-test.cpp +++ b/sca-cpp/trunk/kernel/cache-test.cpp @@ -33,7 +33,6 @@ #include "cache.hpp" namespace tuscany { -namespace cache { const std::string fileRead(const std::string path) { std::ifstream is(path); @@ -51,7 +50,7 @@ bool testCache() { std::ofstream os(p); os << "initial"; os.close(); - assert(std::string(latest(c)) == std::string("initial")); + assert(content(latest(c)) == std::string("initial")); } usleep(1000000); @@ -61,19 +60,18 @@ bool testCache() { os << "updated"; os.close(); assert(latest(c) != c); - assert(std::string(latest(c)) == std::string("updated")); + assert(content(latest(c)) == std::string("updated")); assert(latest(c) == latest(c)); } return true; } } -} int main() { std::cout << "Testing..." << std::endl; - tuscany::cache::testCache(); + tuscany::testCache(); std::cout << "OK" << std::endl; diff --git a/sca-cpp/trunk/modules/cache/cache.hpp b/sca-cpp/trunk/kernel/cache.hpp index ba66021f3d..28ab38c76f 100644 --- a/sca-cpp/trunk/modules/cache/cache.hpp +++ b/sca-cpp/trunk/kernel/cache.hpp @@ -23,7 +23,7 @@ #define tuscany_cache_hpp /** - * Simple cache monad implementation. + * Simple local cache monad implementation. */ #include <sys/stat.h> @@ -33,7 +33,6 @@ #include "monad.hpp" namespace tuscany { -namespace cache { /** * Cached monad. Used to represent a value that can be cached. @@ -53,10 +52,6 @@ public: cached(const cached<V>& c) : lvalue(c.lvalue), ltime(c.ltime), mtime(c.mtime), v(c.v) { } - operator const V() const { - return v; - } - const cached<V>& operator=(const cached<V>& c) { if(this == &c) return *this; @@ -84,6 +79,7 @@ private: V v; template<typename X> friend const cached<X> latest(const cached<X>& c); + template<typename X> friend const X content(const cached<X>& c); template<typename X> friend std::ostream& operator<<(std::ostream& out, const cached<X>& c); }; @@ -106,6 +102,13 @@ template<typename V> const cached<V> latest(const cached<V>& c) { } /** + * Returns the content of a cached monad. + */ +template<typename V> const V content(const cached<V>& c) { + return c.v; +} + +/** * Returns the latest modification time of a file. */ const unsigned long latestFileTime(const std::string& path) { @@ -117,6 +120,5 @@ const unsigned long latestFileTime(const std::string& path) { } } -} #endif /* tuscany_cache_hpp */ diff --git a/sca-cpp/trunk/modules/cache/diskcached-test b/sca-cpp/trunk/kernel/diskcache-test index 4c10abeceb..dfcc177496 100755 --- a/sca-cpp/trunk/modules/cache/diskcached-test +++ b/sca-cpp/trunk/kernel/diskcache-test @@ -21,7 +21,7 @@ mkdir -p tmp # Test -./diskcache-test +./cache-test rc=$? return $rc |