|
From: <den...@us...> - 2010-01-29 15:59:39
|
Revision: 57
http://dsim.svn.sourceforge.net/dsim/?rev=57&view=rev
Author: denis_arnaud
Date: 2010-01-29 15:59:32 +0000 (Fri, 29 Jan 2010)
Log Message:
-----------
[Test] Added test on Boost.SmartPointers.
Modified Paths:
--------------
trunk/dsim/configure.ac
trunk/dsim/test/boost/Makefile.am
Added Paths:
-----------
trunk/dsim/test/boost/smart_pointers/
trunk/dsim/test/boost/smart_pointers/Makefile.am
trunk/dsim/test/boost/smart_pointers/reference_lost.cpp
Modified: trunk/dsim/configure.ac
===================================================================
--- trunk/dsim/configure.ac 2010-01-28 19:38:14 UTC (rev 56)
+++ trunk/dsim/configure.ac 2010-01-29 15:59:32 UTC (rev 57)
@@ -507,6 +507,7 @@
test/boost/spirit/Makefile
test/boost/serialization/Makefile
test/boost/signals/Makefile
+ test/boost/smart_pointers/Makefile
test/stdair/Makefile
test/trademgen/Makefile
test/airsched/Makefile
Modified: trunk/dsim/test/boost/Makefile.am
===================================================================
--- trunk/dsim/test/boost/Makefile.am 2010-01-28 19:38:14 UTC (rev 56)
+++ trunk/dsim/test/boost/Makefile.am 2010-01-29 15:59:32 UTC (rev 57)
@@ -5,6 +5,7 @@
MAINTAINERCLEANFILES = Makefile.in
##
-SUBDIRS = accumulators asio filesystem mpi mpl serialization signals spirit
+SUBDIRS = accumulators asio filesystem mpi mpl serialization signals spirit \
+ smart_pointers
EXTRA_DIST =
Property changes on: trunk/dsim/test/boost/smart_pointers
___________________________________________________________________
Added: svn:ignore
+ .deps
.libs
Makefile.in
Makefile
reference_lost
Copied: trunk/dsim/test/boost/smart_pointers/Makefile.am (from rev 56, trunk/dsim/test/boost/filesystem/Makefile.am)
===================================================================
--- trunk/dsim/test/boost/smart_pointers/Makefile.am (rev 0)
+++ trunk/dsim/test/boost/smart_pointers/Makefile.am 2010-01-29 15:59:32 UTC (rev 57)
@@ -0,0 +1,19 @@
+## test/boost/smart_pointers sub-directory
+include $(top_srcdir)/Makefile.common
+
+#
+MAINTAINERCLEANFILES = Makefile.in
+
+#
+SUBDIRS =
+
+EXTRA_DIST =
+
+#
+check_PROGRAMS = reference_lost
+
+#
+reference_lost_SOURCES = reference_lost.cpp
+reference_lost_CXXFLAGS = $(BOOST_CFLAGS)
+reference_lost_LDADD =
+reference_lost_LDFLAGS = $(BOOST_LIBS)
Copied: trunk/dsim/test/boost/smart_pointers/reference_lost.cpp (from rev 56, trunk/dsim/test/boost/filesystem/simple_ls.cpp)
===================================================================
--- trunk/dsim/test/boost/smart_pointers/reference_lost.cpp (rev 0)
+++ trunk/dsim/test/boost/smart_pointers/reference_lost.cpp 2010-01-29 15:59:32 UTC (rev 57)
@@ -0,0 +1,53 @@
+// STL
+#include <cassert>
+#include <iostream>
+// Boost
+#include <boost/shared_ptr.hpp>
+
+/** Simple object. */
+class Object {
+public:
+ Object() {
+ std::cout << "Object constructor" << std::endl;
+ }
+ Object(const Object&) {
+ std::cout << "Object copy constructor" << std::endl;
+ }
+ ~Object() {
+ std::cout << "Object destructor" << std::endl;
+ }
+ void display() const {
+ std::cout << "Description: " << _description << std::endl;
+ }
+
+private:
+ /** Description. */
+ std::string _description;
+};
+
+
+/** Pointer on the STDAIR Service handler. */
+typedef boost::shared_ptr<Object> ObjectPtr_T;
+
+
+// ////////////////////// M A I N ///////////////////////
+int main (int argc, char* argv[]) {
+
+ Object* lObject_ptr = new Object;
+ assert (lObject_ptr != NULL);
+ Object& lObject = *lObject_ptr;
+
+ std::cout << "The reference is good?" << std::endl;
+ lObject.display();
+ std::cout << "Yes, the reference is good!" << std::endl;
+
+ {
+ ObjectPtr_T lObjectSmartPtr = ObjectPtr_T (lObject_ptr);
+ }
+
+ std::cout << "The reference is still good?" << std::endl;
+ lObject.display();
+ std::cout << "Yes, the reference is still good!" << std::endl;
+
+ return 0;
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|