Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r81718 - in sandbox/icl: boost/icl libs/icl/test/test_casual_ libs/validate/example/labat_multi_ libs/validate/example/labat_single_ libs/validate/test libs/xplore/br1/sqlbrowser
From: afojgo_at_[hidden]
Date: 2012-12-05 02:18:45


Author: jofaber
Date: 2012-12-05 02:18:42 EST (Wed, 05 Dec 2012)
New Revision: 81718
URL: http://svn.boost.org/trac/boost/changeset/81718

Log:
Streaming string into posix time.
Text files modified:
   sandbox/icl/boost/icl/map.hpp | 2
   sandbox/icl/libs/icl/test/test_casual_/test_casual.cpp | 35 ++++++
   sandbox/icl/libs/icl/test/test_casual_/vc10_test_casual.vcxproj | 2
   sandbox/icl/libs/validate/example/labat_multi_/labat_multi.cpp | 220 ++++++++++++++++++++++++++++++++++++---
   sandbox/icl/libs/validate/example/labat_multi_/vc9_labat_multi.vcproj | 5
   sandbox/icl/libs/validate/example/labat_single_/vc9_labat_single.vcproj | 4
   sandbox/icl/libs/validate/test/Jamfile.v2 | 7
   sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser4.pro | 5
   8 files changed, 251 insertions(+), 29 deletions(-)

Modified: sandbox/icl/boost/icl/map.hpp
==============================================================================
--- sandbox/icl/boost/icl/map.hpp (original)
+++ sandbox/icl/boost/icl/map.hpp 2012-12-05 02:18:42 EST (Wed, 05 Dec 2012)
@@ -192,7 +192,7 @@
         insert(key_value_pair);
     }
 
- map& operator = (map& src)
+ map& operator = (const map& src)
     {
         base_type::operator=(src);
         return *this;

Modified: sandbox/icl/libs/icl/test/test_casual_/test_casual.cpp
==============================================================================
--- sandbox/icl/libs/icl/test/test_casual_/test_casual.cpp (original)
+++ sandbox/icl/libs/icl/test/test_casual_/test_casual.cpp 2012-12-05 02:18:42 EST (Wed, 05 Dec 2012)
@@ -7,7 +7,7 @@
 +-----------------------------------------------------------------------------*/
 #define BOOST_TEST_MODULE icl::casual unit test
 
-#define BOOST_ICL_TEST_CHRONO
+//#define BOOST_ICL_TEST_CHRONO
 
 #include <libs/icl/test/disable_test_warnings.hpp>
 
@@ -25,6 +25,8 @@
 
 #include <boost/type_traits/is_same.hpp>
 
+#include <boost/algorithm/string.hpp>
+
 #include <boost/icl/gregorian.hpp>
 #include <boost/icl/ptime.hpp>
 
@@ -42,6 +44,34 @@
 using namespace boost::posix_time;
 using namespace boost::gregorian;
 
+namespace times
+{
+ //http://stackoverflow.com/questions/10732518/converting-stdstring-to-boostposix-timeptime
+
+ boost::posix_time::ptime create_iso(const std::string& timeString)
+ {
+ static time_input_facet* facet = NULL;
+ static std::stringstream timeStream;
+ if(!facet)
+ {
+ facet = new time_input_facet("%Y-%m-%dT%H:%M:%S");
+ timeStream.imbue(std::locale(std::locale::classic(), facet));
+ }
+
+ if (boost::iequals(timeString, "not-a-data-time"))
+ return boost::posix_time::ptime(boost::posix_time::min_date_time);
+ else
+ {
+ boost::posix_time::ptime time;
+ timeStream.clear();
+ timeStream.str(timeString);
+ //timeStream << timeString;
+ timeStream >> time;
+ return time;
+ }
+ }
+}
+
 
 BOOST_AUTO_TEST_CASE(casual)
 {
@@ -70,6 +100,9 @@
     add_interval( m3, make_pair(interval<int>::right_open(0,6), 1) );
 
     new_show(m3);
+ cout << "-----------------------------\n";
+ cout << times::create_iso("2012-12-04T20:03:00") << endl;
+ cout << "-----------------------------\n";
 
     BOOST_CHECK_EQUAL(true, true);
 }

Modified: sandbox/icl/libs/icl/test/test_casual_/vc10_test_casual.vcxproj
==============================================================================
--- sandbox/icl/libs/icl/test/test_casual_/vc10_test_casual.vcxproj (original)
+++ sandbox/icl/libs/icl/test/test_casual_/vc10_test_casual.vcxproj 2012-12-05 02:18:42 EST (Wed, 05 Dec 2012)
@@ -48,7 +48,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>../../../../; ../../../../boost_1_35_0;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>../../../../; %(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>

Modified: sandbox/icl/libs/validate/example/labat_multi_/labat_multi.cpp
==============================================================================
--- sandbox/icl/libs/validate/example/labat_multi_/labat_multi.cpp (original)
+++ sandbox/icl/libs/validate/example/labat_multi_/labat_multi.cpp 2012-12-05 02:18:42 EST (Wed, 05 Dec 2012)
@@ -13,6 +13,8 @@
 #include <boost/thread.hpp>
 #include <boost/validate/driver/abelian_monoid_driver.hpp>
 
+#include <omp.h>
+
 using namespace std;
 using namespace boost;
 using namespace boost::icl;
@@ -23,12 +25,12 @@
   boost::this_thread::sleep(boost::posix_time::seconds(seconds));
 }
 
-boost::mutex g_Mutex;
+boost::mutex g_io_Mutex;
 
 void test_abelian_monoid(int size)
 {
     abelian_monoid_driver model_tester;
- g_Mutex.lock();
+ g_io_Mutex.lock();
     cout <<
     ">> ------------------------------------------------------ <<\n"
     ">> -------- Law based test automaton 'LaBatea' ---------- <<\n"
@@ -37,7 +39,7 @@
     ">> ------------------------------------------------------ <<\n";
     GentorProfileSgl::it()->set_std_profile(size,1);
     GentorProfileSgl::it()->report_profile();
- g_Mutex.unlock();
+ g_io_Mutex.unlock();
     wait(1);
 
     model_tester.terminate_at_law_count(18, 100);
@@ -45,11 +47,15 @@
     model_tester.validate();
 }
 
+// tread_abelian_monoid_1() runs the monoid validation for smaller containers
+// so it will run faster.
 void tread_abelian_monoid_1()
 {
     test_abelian_monoid(16);
 }
 
+// tread_abelian_monoid_2() runs the monoid validation for smaller containers
+// so it will run slower.
 void tread_abelian_monoid_2()
 {
     test_abelian_monoid(77);
@@ -60,36 +66,216 @@
   for (int i = 0; i < 5; ++i)
   {
     wait(1);
- g_Mutex.lock();
+ g_io_Mutex.lock();
     std::cout << "Thread " << boost::this_thread::get_id() << ": " << i << std::endl;
- g_Mutex.unlock();
+ g_io_Mutex.unlock();
   }
 }
 
-int main()
+void treaded_abelian_monoid_test()
 {
   boost::thread t1(tread_abelian_monoid_1);
+ thread::id t1_id = t1.get_id();
+ wait(1);
+ cout << "tread_abelian_monoid_1.get_id() = " << t1_id << " started." << endl;
   wait(2);
   boost::thread t2(tread_abelian_monoid_2);
   t1.join();
   t2.join();
 }
 
+class Counter
+{
+public:
+ static const int max = 1000000;
+
+ Counter(int val, int max = 1000000): _value(val), _max(max){}
+
+ int getMax()const { return _max; }
+
+ int getAndIncrement()
+ {
+ lock_guard<mutex> scope_lock(_mutex);
+ int prior = _value;
+ _value = prior + 1;
+ return prior;
+ }
+
+private:
+ // The mutex accountable to lock critial sections of code of
+ // an object shall be encapsulated in that object
+ boost::mutex _mutex; // Class local mutex.
+ // If no such object exists like for io streams, the mutex that
+ // sychrnoizes access has to be global.
+ int _value;
+ int _max;
+
+};
+
+bool is_prim(int number)
+{
+ int half = number/2;
+ for(int frac=2; frac <= half; frac++)
+ if(number % frac == 0)
+ return false;
+
+ return true;
+}
+
+void print_prim(int max)
+{
+ for(int number=1; number <= max; number++)
+ if(is_prim(number))
+ cout << number << " ";
+}
+
+
+Counter g_count(1000000, 10000000);
+std::map<thread::id, int> thread_ids;
+
+class PrimeChecker
+{
+public:
+ PrimeChecker(boost::mutex* mutx): p_io_Mutex(mutx) {}
+
+ void operator()()
+ {
+ int cur = 1;
+ p_io_Mutex->lock();
+ cout << "collecting " << boost::this_thread::get_id() << endl;
+ thread_ids[boost::this_thread::get_id()] = thread_ids.size();
+ cout << "added: " << boost::this_thread::get_id() << " -> "
+ << thread_ids[boost::this_thread::get_id()] << endl;
+ p_io_Mutex->unlock();
+
+ while(cur < g_count.getMax())
+ {
+ cur = g_count.getAndIncrement();
+ if(is_prim(cur))
+ {
+ lock_guard<mutex> lock(*p_io_Mutex);
+ //cout << "Thread " << boost::this_thread::get_id() << " count " << cur << endl;
+ cout << thread_ids[boost::this_thread::get_id()] << ":" << cur << " ";
+ //p_io_Mutex->unlock();
+ //this_thread::sleep(posix_time::milliseconds(1));
+ }
+ }
+ }
+private:
+ boost::mutex* p_io_Mutex;
+};
+
+void getNumber()
+{
+ int cur = 1;
+ while(cur < g_count.getMax())
+ {
+ cur = g_count.getAndIncrement();
+ if(is_prim(cur))
+ {
+ g_io_Mutex.lock();
+ //cout << "Thread " << boost::this_thread::get_id() << " count " << cur << endl;
+ cout << cur << " ";
+ g_io_Mutex.unlock();
+ //boost::this_thread::sleep(boost::posix_time::milliseconds(1));
+ }
+ }
+}
+
+void produce_prim()
+{
+ PrimeChecker primes(&g_io_Mutex);
+ boost::thread primeChecker1(primes);
+ boost::thread primeChecker2(primes);
+ boost::thread primeChecker3(primes);
+ boost::thread primeChecker4(primes);
+
+ primeChecker1.join();
+ primeChecker2.join();
+ primeChecker3.join();
+ primeChecker4.join();
+}
 
-/*CL
+//==============================================================================
+#include <boost/signals2/signal.hpp>
+#include <boost/bind.hpp>
+
+using namespace boost::signals2;
+
+struct Observable
+{
+ signal<void ()> f1;
+ signal<void (int)> f2;
+ signal<void (int)> f3;
+};
+
+class Observer // implements the callbacks
+{
+public:
+ Observer(int val) : _value(val) {}
+ void f1(){ cout << "f1()[" << _value << "]\n"; }
+ void f2(int i){ cout << "f2("<< i <<")\n"; }
+ void f3(int i){ cout << "f3("<< i*_value <<")\n"; }
+private:
+ int _value;
+};
+
+class Different // implements the callbacks
+{
+public:
+ void f1(){ cout << "f1()[" << "different" << "]\n"; }
+};
+
+void testObserver()
+{
+ Observable sub;
+ Observer obs1(1);
+ Observer obs2(2);
+ Different diff;
+
+ sub.f1.connect(bind(&Observer::f1, obs1));
+ sub.f1.connect(bind(&Observer::f1, obs2));
+ sub.f1.connect(bind(&Different::f1, Different()));
+
+ sub.f2.connect(bind(&Observer::f2, obs1, _1));
+ sub.f2.connect(bind(&Observer::f3, obs2, _1));
+
+ sub.f1();
+ sub.f2(3);
+}
+
+/*
 int main()
 {
- abelian_monoid_driver model_tester;
- cout <<
- ">> ------------------------------------------------------ <<\n"
- ">> -------- Law based test automaton 'LaBatea' ---------- <<\n"
- ">> Output will be generated in a few seconds\n"
- ">> terminate by typing <CTRL>C\n"
- ">> ------------------------------------------------------ <<\n";
- GentorProfileSgl::it()->set_std_profile(16,1);
- GentorProfileSgl::it()->report_profile();
- model_tester.validate();
+ //treaded_abelian_monoid_test();
+ //print_prim((numeric_limits<int>::max)());
+ //produce_prim();
+ testObserver();
     return 0;
 }
 */
 
+#include <omp.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(void)
+ {
+ int id,i;
+ omp_set_num_threads(4);
+
+ #pragma omp parallel for private(id)
+ for (i = 0; i < 4; ++i)
+ {
+ id = omp_get_thread_num();
+
+ printf("Hello World from thread %d\n", id);
+ //#pragma omp barrier
+ // if (id == 0) {
+ // printf("There are %d threads\n", omp_get_num_threads());
+ // }
+ }
+
+ return EXIT_SUCCESS;
+ }
+

Modified: sandbox/icl/libs/validate/example/labat_multi_/vc9_labat_multi.vcproj
==============================================================================
--- sandbox/icl/libs/validate/example/labat_multi_/vc9_labat_multi.vcproj (original)
+++ sandbox/icl/libs/validate/example/labat_multi_/vc9_labat_multi.vcproj 2012-12-05 02:18:42 EST (Wed, 05 Dec 2012)
@@ -123,6 +123,7 @@
                                 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;ITL_USE_STATIC_INTERVAL_BORDER_DEFAULTS"
                                 ExceptionHandling="1"
                                 RuntimeLibrary="2"
+ OpenMP="true"
                                 UsePrecompiledHeader="0"
                                 WarningLevel="4"
                                 Detect64BitPortabilityProblems="false"
@@ -182,11 +183,11 @@
                         UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
                         <File
- RelativePath="..\labat_multi_\labat_multi.cpp"
+ RelativePath="..\..\src\gentor\gentorprofile.cpp"
>
                         </File>
                         <File
- RelativePath="..\..\src\gentor\gentorprofile.cpp"
+ RelativePath="..\labat_multi_\labat_multi.cpp"
>
                         </File>
                 </Filter>

Modified: sandbox/icl/libs/validate/example/labat_single_/vc9_labat_single.vcproj
==============================================================================
--- sandbox/icl/libs/validate/example/labat_single_/vc9_labat_single.vcproj (original)
+++ sandbox/icl/libs/validate/example/labat_single_/vc9_labat_single.vcproj 2012-12-05 02:18:42 EST (Wed, 05 Dec 2012)
@@ -42,7 +42,7 @@
                                 Name="VCCLCompilerTool"
                                 Optimization="0"
                                 AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
- PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_SECURE_SCL=0;_HAS_ITERATOR_DEBUGGING=0"
                                 MinimalRebuild="true"
                                 BasicRuntimeChecks="3"
                                 RuntimeLibrary="3"
@@ -119,7 +119,7 @@
                                 Name="VCCLCompilerTool"
                                 WholeProgramOptimization="true"
                                 AdditionalIncludeDirectories="../../../../; ../../../../boost_1_35_0"
- PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;ITL_USE_STATIC_INTERVAL_BORDER_DEFAULTS"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;ITL_USE_STATIC_INTERVAL_BORDER_DEFAULTS; _SECURE_SCL=0"
                                 ExceptionHandling="1"
                                 RuntimeLibrary="2"
                                 UsePrecompiledHeader="0"

Modified: sandbox/icl/libs/validate/test/Jamfile.v2
==============================================================================
--- sandbox/icl/libs/validate/test/Jamfile.v2 (original)
+++ sandbox/icl/libs/validate/test/Jamfile.v2 2012-12-05 02:18:42 EST (Wed, 05 Dec 2012)
@@ -122,10 +122,9 @@
         : : : <define>BOOST_ICL_USE_COMPARE_STD_GREATER
         : test_set_order_gt ]
     
- #[ run test_map_order_/test_map_order.cpp ../src/gentor/gentorprofile.cpp
- # : : : <define>BOOST_ICL_USE_COMPARE_STD_GREATER
- # : test_map_order_gt ]
- #JODO compiler err: op > ambiguous
+ [ run test_map_order_/test_map_order.cpp ../src/gentor/gentorprofile.cpp
+ : : : <define>BOOST_ICL_USE_COMPARE_STD_GREATER
+ : test_map_order_gt ]
         
     #[ run test_icl_morphic_/test_icl_morphic.cpp ../src/gentor/gentorprofile.cpp
     # : : : <define>BOOST_ICL_USE_COMPARE_STD_GREATER

Modified: sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser4.pro
==============================================================================
--- sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser4.pro (original)
+++ sandbox/icl/libs/xplore/br1/sqlbrowser/sqlbrowser4.pro 2012-12-05 02:18:42 EST (Wed, 05 Dec 2012)
@@ -3,8 +3,10 @@
 
 QT += sql
 
+INCLUDEPATH += /cygwin/home/jofa/dev/boost/vsn/boost_1_47_0
 #INCLUDEPATH += /cygwin/home/jofa/dev/boost/branches/release
-INCLUDEPATH += C:\NIBuild\3rdparty\boost-1.48.0
+#INCLUDEPATH += /cygwin/home/jofa/dev/boost_sandbox/icl
+#INCLUDEPATH += C:\NIBuild\3rdparty\boost-1.48.0
 
 HEADERS = browser.h connectionwidget.h qsqlconnectiondialog.h \
     exttableview.h \
@@ -80,3 +82,4 @@
 
 
 
+


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk