// Copyright (c) 2015 Noah Lopez
// Use, modification, and distribution is subject to the Boost Software
// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)

#ifndef EXCLUDE_MSETL_EXAMPLE3

#include "msetl_example_defs.h"

#include "msetl_example3.h"

#include "mseasyncshared.h"
#include "msepoly.h"
#include "msemsearray.h"
#include "msemsevector.h"
#include "msemsestring.h"
#include "msestaticimmutable.h"
#include "msescopeatomic.h"

#include <list>
#include <iostream>
#include <ctime>
#include <ratio>
#include <chrono>
#include <sstream>

#ifdef _MSC_VER
#pragma warning( push )
#pragma warning( disable : 4100 4456 4189 4702 )
#endif /*_MSC_VER*/

#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-braces"
#pragma clang diagnostic ignored "-Wtautological-compare"
#pragma clang diagnostic ignored "-Wunused-variable"
#pragma clang diagnostic ignored "-Wunused-function"
#pragma clang diagnostic ignored "-Wunused-local-typedefs"
//pragma clang diagnostic ignored "-Wunused-but-set-variable"
#else /*__clang__*/
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-function"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
#endif /*__GNUC__*/
#endif /*__clang__*/

class K {
public:
	template<class _TAsyncSharedReadWriteAccessRequester>
	static double foo7(_TAsyncSharedReadWriteAccessRequester A_ashar) {
		auto t1 = std::chrono::high_resolution_clock::now();
		/* A_ashar.readlock_ptr() will block until it can obtain a read lock. */
		auto ptr1 = A_ashar.readlock_ptr(); // while ptr1 exists it holds a (read) lock on the shared object
		auto t2 = std::chrono::high_resolution_clock::now();
		std::this_thread::sleep_for(std::chrono::seconds(1));
		auto time_span = std::chrono::duration_cast<std::chrono::duration<double>>(t2 - t1);
		auto timespan_in_seconds = time_span.count();
		auto thread_id = std::this_thread::get_id();
		//std::cout << "thread_id: " << thread_id << ", time to acquire read pointer: " << timespan_in_seconds << " seconds.";
		//std::cout << std::endl;
		return timespan_in_seconds;
	}
	/* This function takes a "random access section" (which is like an "array_view" or gsl::span) as its parameter. */
	template<class _TStringRASection>
	static void foo8(_TStringRASection ra_section) {
		size_t delay_in_milliseconds = 3000/*arbitrary*/;
		if (1 <= ra_section.size()) {
			delay_in_milliseconds /= mse::as_a_size_t(ra_section.size());
		}
		for (size_t i = 0; i < ra_section.size(); i += 1) {
			auto now1 = std::chrono::system_clock::now();
			auto tt = std::chrono::system_clock::to_time_t(now1);

			/* Just trying to obtain a string with the current time and date. The standard library doesn't yet
			seem to provide a safe, portable way to do this. */
#ifdef _MSC_VER
			static const size_t buffer_size = 64;
			char buffer[buffer_size];
			buffer[0] = '\0';
			ctime_s(buffer, buffer_size, &tt);
#else /*_MSC_VER*/
			const auto buffer = ctime(&tt);
#endif /*_MSC_VER*/

			std::string now_str(buffer);
			ra_section[i] = now_str;

			std::this_thread::sleep_for(std::chrono::milliseconds(delay_in_milliseconds));
		}
	}
	/* This function just obtains a writelock_ra_section from the given "splitter access requester" and calls the given
	function with the writelock_ra_section as the first argument. */
	template<class TAsyncSplitterRASectionReadWriteAccessRequester, class TFunction, class... Args>
	static void invoke_with_writelock_ra_section1(TAsyncSplitterRASectionReadWriteAccessRequester ar, const TFunction function1, Args&&... args) {
		function1(ar.writelock_ra_section(), args...);
	}
	/* This function just obtains an xscope_random_access_section from the given access controlled pointer and calls the given
	function with the xscope_random_access_section as the first argument. */
	template<class Ty, class TFunction, class... Args>
	static void invoke_with_ra_section(mse::TXScopeExclusiveStrongPointerStoreForAccessControl<Ty> xs_ac_store, const TFunction function1, Args&&... args) {
		auto xscope_ra_section = mse::make_xscope_random_access_section(xs_ac_store.xscope_pointer());
		function1(xscope_ra_section, args...);
	}

	template<class _TAPointer>
	static void foo17(_TAPointer a_ptr) {
		{
			auto now1 = std::chrono::system_clock::now();
			auto tt = std::chrono::system_clock::to_time_t(now1);

			/* Just trying to obtain a string with the current time and date. The standard library doesn't yet
			seem to provide a safe, portable way to do this. */
#ifdef _MSC_VER
			static const size_t buffer_size = 64;
			char buffer[buffer_size];
			buffer[0] = '\0';
			ctime_s(buffer, buffer_size, &tt);
#else /*_MSC_VER*/
			const auto buffer = ctime(&tt);
#endif /*_MSC_VER*/

			std::string now_str(buffer);
			a_ptr->s = now_str;

			std::this_thread::sleep_for(std::chrono::milliseconds(10));
		}
	}
	template<class _TAPointer>
	static void foo17b(_TAPointer a_ptr) {
		static std::atomic<int> s_count(0);
		s_count += 1;
		a_ptr->s = std::to_string(s_count);

		std::this_thread::sleep_for(std::chrono::milliseconds(10));
	}
	template<class _TConstPointer, class _TPointer>
	static void foo18(_TConstPointer src_ptr, _TPointer dst_ptr) {
		std::this_thread::sleep_for(std::chrono::milliseconds(10));
		dst_ptr->s = src_ptr->s;
		std::this_thread::sleep_for(std::chrono::milliseconds(10));
	}

};

void msetl_example3() {
	{
		/********************/
		/*  TAsyncSharedV2  */
		/********************/

		/* The TAsyncSharedV2 data types are used to safely share objects between asynchronous threads. */

		class A {
		public:
			A(int x) : b(x) {}
			virtual ~A() {}

			int b = 3;
			mse::mtnii_string s = "some text ";
		};
		/* User-defined classes need to be declared as (safely) shareable in order to be accepted by the access requesters. */
		typedef mse::rsv::TAsyncShareableAndPassableObj<A> ShareableA;

		/* trivially copyable class */
		class D {
		public:
			D(int x) : b(x) {}

			int b = 3;
		};
		/* User-defined classes need to be declared as (safely) shareable in order to be used with the atomic templates. */
		typedef mse::rsv::TAsyncShareableAndPassableObj<D> ShareableD;

		class B {
		public:
			static double foo1(mse::TAsyncSharedV2ReadWriteAccessRequester<ShareableA> A_ashar) {
				auto t1 = std::chrono::high_resolution_clock::now();
				/* mse::TAsyncSharedV2ReadWriteAccessRequester<ShareableA>::writelock_ptr() will block until it can obtain a write lock. */
				auto ptr1 = A_ashar.writelock_ptr(); // while ptr1 exists it holds a (write) lock on the shared object
				auto t2 = std::chrono::high_resolution_clock::now();
				std::this_thread::sleep_for(std::chrono::seconds(1));
				auto time_span = std::chrono::duration_cast<std::chrono::duration<double>>(t2 - t1);
				auto timespan_in_seconds = time_span.count();
				auto thread_id = std::this_thread::get_id();
				//std::cout << "thread_id: " << thread_id << ", time to acquire write pointer: " << timespan_in_seconds << " seconds.";
				//std::cout << std::endl;

				ptr1->s = std::to_string(timespan_in_seconds);
				return timespan_in_seconds;
			}
			static int foo2(mse::TAsyncSharedV2ImmutableFixedPointer<ShareableA> A_immptr) {
				return A_immptr->b;
			}
			static int foo3(mse::TAsyncSharedV2AtomicFixedPointer<ShareableD> D_atomic_ptr) {
				auto d = (*D_atomic_ptr).load();
				d.b += 1;
				(*D_atomic_ptr).store(d);
				std::this_thread::sleep_for(std::chrono::milliseconds(10));
				return (*D_atomic_ptr).load().b;
			}
			static int foo4(mse::TXScopeAtomicFixedPointer<ShareableD> xs_D_atomic_ptr) {
				auto d = (*xs_D_atomic_ptr).load();
				d.b += 1;
				(*xs_D_atomic_ptr).store(d);
				std::this_thread::sleep_for(std::chrono::milliseconds(10));
				return (*xs_D_atomic_ptr).load().b;
			}
		protected:
			~B() {}
		};

		std::cout << std::endl;
		std::cout << "AsyncSharedV2 test output:";
		std::cout << std::endl;

		{
			/* This block contains a simple example demonstrating the use of mse::TAsyncSharedV2ReadWriteAccessRequester
			to safely share an object between threads. */

			std::cout << "TAsyncSharedV2ReadWriteAccessRequester:";
			std::cout << std::endl;
			auto ash_access_requester = mse::make_asyncsharedv2readwrite<ShareableA>(7);
			ash_access_requester.writelock_ptr()->b = 11;
			int res1 = ash_access_requester.readlock_ptr()->b;

			{
				auto ptr3 = ash_access_requester.readlock_ptr();
				auto ptr1 = ash_access_requester.writelock_ptr();
				auto ptr2 = ash_access_requester.writelock_ptr();
			}

			std::list<mse::mstd::future<double>> futures;
			for (size_t i = 0; i < 3; i += 1) {
				futures.emplace_back(mse::mstd::async(B::foo1, ash_access_requester));
			}
			int count = 1;
			for (auto it = futures.begin(); futures.end() != it; it++, count++) {
				std::cout << "thread: " << count << ", time to acquire read pointer: " << (*it).get() << " seconds.";
				std::cout << std::endl;
			}
			std::cout << std::endl;
		}
		{
			std::cout << "TAsyncSharedV2ReadOnlyAccessRequester:";
			std::cout << std::endl;
			auto ash_access_requester = mse::make_asyncsharedv2readonly<ShareableA>(7);
			int res1 = ash_access_requester.readlock_ptr()->b;

			std::list<mse::mstd::future<double>> futures;
			for (size_t i = 0; i < 3; i += 1) {
				futures.emplace_back(mse::mstd::async(K::foo7<mse::TAsyncSharedV2ReadOnlyAccessRequester<ShareableA>>, ash_access_requester));
			}
			int count = 1;
			for (auto it = futures.begin(); futures.end() != it; it++, count++) {
				std::cout << "thread: " << count << ", time to acquire read pointer: " << (*it).get() << " seconds.";
				std::cout << std::endl;
			}
			std::cout << std::endl;
		}
#ifndef EXCLUDE_DUE_TO_MSVC2019_INTELLISENSE_BUGS1
		{
			/* Just demonstrating the existence of the "try" versions. */
			auto access_requester = mse::make_asyncsharedv2readwrite<mse::mtnii_string>("some text");
			auto writelock_ptr1 = access_requester.try_writelock_ptr();
			if (writelock_ptr1) {
				// lock request succeeded
				int q = 5;
			}
			auto readlock_ptr2 = access_requester.try_readlock_ptr_for(std::chrono::seconds(1));
			auto writelock_ptr3 = access_requester.try_writelock_ptr_until(std::chrono::steady_clock::now() + std::chrono::seconds(1));
		}
#endif // !EXCLUDE_DUE_TO_MSVC2019_INTELLISENSE_BUGS1
		{
			/* TAsyncSharedV2WeakReadWriteAccessRequester<> is the weak counterpart to TAsyncSharedV2ReadWriteAccessRequester<>
			analogous to how std::weak_ptr<> is the weak counterpart to std::shared_ptr<>. */

			typedef decltype(mse::make_asyncsharedv2readwrite<mse::mtnii_string>("abc")) access_requester_t;
			auto vec1 = mse::mstd::vector<access_requester_t>();
			vec1.push_back(mse::make_asyncsharedv2readwrite<mse::mtnii_string>("abc"));

			mse::TAsyncSharedV2WeakReadWriteAccessRequester<mse::mtnii_string> weak_ar1(vec1.at(0));

			/* Here we're obtaining a (strong) access requester from the weak access requester, then appending it the
			vector of access requesters. */
			vec1.push_back(weak_ar1.try_strong_access_requester().value());

			assert((*(vec1.at(1).readlock_ptr())) == "abc");

			vec1.clear();

			/* All the (strong) access requesters have just been destroyed so attempting to obtain a (strong) access requester
			from our weak one will result in an empty optional being returned. */
			assert(!(weak_ar1.try_strong_access_requester().has_value()));
		}
		{
			/* For scenarios where the shared object is immutable (i.e. is never modified), you can get away without using locks
			or access requesters. */
			auto A_immptr = mse::make_asyncsharedv2immutable<ShareableA>(5);
			int res1 = A_immptr->b;
			std::shared_ptr<const ShareableA> A_shptr(A_immptr);

			std::list<mse::mstd::future<int>> futures;
			for (size_t i = 0; i < 3; i += 1) {
				futures.emplace_back(mse::mstd::async(B::foo2, A_immptr));
			}
			int count = 1;
			for (auto it = futures.begin(); futures.end() != it; it++, count++) {
				int res2 = (*it).get();
			}

			auto A_b_safe_cptr = mse::make_const_pointer_to_member_v2(A_immptr, &A::b);
		}
		{
			/* For scenarios where the shared object is atomic, you can get away without using locks
			or access requesters. */
			auto D_atomic_ptr = mse::make_asyncsharedv2atomic<ShareableD>(5);
			int res1 = (*D_atomic_ptr).load().b;

			std::list<mse::mstd::future<int>> futures;
			for (size_t i = 0; i < 3; i += 1) {
				futures.emplace_back(mse::mstd::async(B::foo3, D_atomic_ptr));
			}
			int count = 1;
			for (auto it = futures.begin(); futures.end() != it; it++, count++) {
				int res2 = (*it).get();
			}
		}
		{
			/* mse::TAsyncSharedV2ReadWriteAccessRequester's flexibilty in allowing coexisting read and write lock
			pointers in the same thread introduces new ways to produce logical deadlocks. This block (likely)
			demonstrates the access requester's ability to detect these potential deadlocks (and throw an exception
			when they would occur). */

			std::cout << "TAsyncSharedV2ReadWriteAccessRequester deadlock detection:";
			std::cout << std::endl;

			class CC {
			public:
				static void foo1(mse::TAsyncSharedV2ReadWriteAccessRequester<ShareableA> A_ashar, int id) {
					auto readlock_ptr = A_ashar.readlock_ptr();
					std::this_thread::sleep_for(std::chrono::seconds(1));
					MSE_TRY {
						auto writelock_ptr = A_ashar.writelock_ptr();
						std::this_thread::sleep_for(std::chrono::seconds(1));
					}
					MSE_CATCH_ANY {
						// likely exception due to potential deadlock
						std::cout << "deadlock detected ";
						std::cout << std::endl;
					}
				}
			};

			auto ash_access_requester = mse::make_asyncsharedv2readwrite<ShareableA>(7);

			{
				auto thread1 = mse::mstd::thread(CC::foo1, ash_access_requester, 1);
				auto thread2 = mse::mstd::thread(CC::foo1, ash_access_requester, 2);
				thread1.join();
				thread2.join();
			}

			std::cout << std::endl;
		}
		{
			/* This block demonstrates safely allowing different threads to (simultaneously) modify different
			sections of a vector. (We use vectors in this example, but it works just as well with arrays.) */

			MSE_DECLARE_STATIC_IMMUTABLE(size_t) num_sections = 10;
			MSE_DECLARE_STATIC_IMMUTABLE(size_t) section_size = 5;
			const size_t num_elements = num_sections * section_size;

			typedef mse::mtnii_vector<mse::mtnii_string> async_shareable_vector1_t;
			typedef mse::mstd::vector<mse::mtnii_string> nonshareable_vector1_t;
			/* Let's say we have a vector. */
			nonshareable_vector1_t vector1;
			vector1.resize(num_elements);
			{
				size_t count = 0;
				for (auto iter = vector1.begin(); vector1.end() != iter; iter++) {
					count += 1;
					*iter = "text" + std::to_string(count);
				}
			}

			/* Only access controlled objects can be shared with other threads, so we'll make an access controlled vector and
			(temporarily) swap it with our original one. */
			auto ash_access_requester = mse::make_asyncsharedv2readwrite<async_shareable_vector1_t>();
			std::swap(vector1, (*(ash_access_requester.writelock_ptr())));

			std::cout << "mse::TAsyncRASectionSplitter<>, part 1: " << std::endl;

			{
				/* Now, we're going to use the access requester to obtain two new access requesters that provide access to
				(newly created) "random access section" objects which are used to access (disjoint) sections of the vector.
				We need to specify the position where we want to split the vector. Here we specify that it be split at index
				"num_elements / 2", right down the middle. */
				mse::TAsyncRASectionSplitter<decltype(ash_access_requester)> ra_section_split1(ash_access_requester, num_elements / 2);
				auto ar1 = ra_section_split1.first_ra_section_access_requester();
				auto ar2 = ra_section_split1.second_ra_section_access_requester();

				/* The K::foo8 template function is just an example function that operates on containers of strings. In our case the
				containers will be the random access sections we just created. We'll create an instance of the function here. */
				const auto my_foo8_function = K::foo8<decltype(ar1.writelock_ra_section())>;

				/* We want to execute the my_foo8 function in a separate thread. The function takes a "random access section"
				as an argument. But as we're not allowed to pass random access sections between threads, we must pass an
				access requester instead. The "K::invoke_with_writelock_ra_section1" template function is just a helper
				function that will obtain a (writelock) random access section from the access requester, then call the given
				function, in this case my_foo8, with that random access section. So here we'll use it to create a proxy
				function that we can execute directly in a separate thread and will accept an access requester as a
				parameter. */
				const auto my_foo8_proxy_function = K::invoke_with_writelock_ra_section1<decltype(ar1), decltype(my_foo8_function)>;

				std::list<mse::mstd::thread> threads;
				/* So this thread will modify the first section of the vector. */
				threads.emplace_back(mse::mstd::thread(my_foo8_proxy_function, ar1, my_foo8_function));
				/* While this thread modifies the other section. */
				threads.emplace_back(mse::mstd::thread(my_foo8_proxy_function, ar2, my_foo8_function));

				{
					int count = 1;
					for (auto it = threads.begin(); threads.end() != it; it++, count++) {
						(*it).join();
					}
				}
				int q = 5;
			}
			std::cout << "mse::TAsyncRASectionSplitter<>, part 2: " << std::endl;
			{
				/* Ok, now let's do it again, but instead of splitting the vector into two sections, let's split it into more sections: */
				/* First we create a list of a the sizes of each section. We'll use a vector here, but any iteratable container will work. */
				mse::mstd::vector<size_t> section_sizes;
				for (size_t i = 0; i < num_sections; i += 1) {
					section_sizes.push_back(section_size);
				}

				/* Just as before, TAsyncRASectionSplitter<> will generate a new access requester for each section. */
				mse::TAsyncRASectionSplitter<decltype(ash_access_requester)> ra_section_split1(ash_access_requester, section_sizes);
				auto ar0 = ra_section_split1.ra_section_access_requester(0);

				const auto my_foo8_function = K::foo8<decltype(ar0.writelock_ra_section())>;
				const auto my_foo8_proxy_function = K::invoke_with_writelock_ra_section1<decltype(ar0), decltype(my_foo8_function)>;

				{
					/* Here we demonstrate scope threads. Scope threads don't support being copied or moved. Unlike mstd::thread,
					scope threads can share objects declared on the stack (which is not utilized here), and in their destructor,
					scope thread objects will wait until their thread finishes its execution (i.e "join" the thread), blocking if
					necessary. Often rather than declaring scope thread objects directly, you'll create and manage multiple scope
					threads with an "xscope_thread_carrier". An xscope_thread_carrier is just a container that holds scope
					threads. */
					mse::xscope_thread_carrier xscope_threads;
					for (size_t i = 0; i < num_sections; i += 1) {
						auto ar = ra_section_split1.ra_section_access_requester(i);
						xscope_threads.new_thread(my_foo8_proxy_function, ar, my_foo8_function);
					}
					/* The scope will not end until all the scope threads have finished executing. */
				}
			}

			/* Now that we're done sharing the (controlled access) vector, we can swap it back to our original vector. */
			std::swap(vector1, (*(ash_access_requester.writelock_ptr())));
			auto first_element_value = vector1[0];
			auto last_element_value = vector1.back();

			int q = 5;
		}
		{
			/* Here we demonstrate safely sharing an existing stack allocated object among threads. */

			std::cout << "xscope_future_carrier<>: " << std::endl;

			/* (Mutable) objects can be shared between threads only if they are "access controlled". You can make an
			object "access controlled" by wrapping its type with the mse::TXScopeAccessControlledObj<> template wrapper. */
			mse::TXScopeObj<mse::TXScopeAccessControlledObj<ShareableA> > a_xscpacobj(7);

			/* Here we obtain a scope access requester for the access controlled object. */
			auto xscope_access_requester = mse::make_xscope_asyncsharedv2acoreadwrite(&a_xscpacobj);

			/* xscope_future_carrier<> is just a container that holds and manages scope futures. */
			mse::xscope_future_carrier<double> xscope_futures;

			std::list<mse::xscope_future_carrier<double>::handle_t> future_handles;
			for (size_t i = 0; i < 3; i += 1) {
				/* You add a future by specifying the async() function and parameters that will return the future value. */
				auto handle = xscope_futures.new_future(K::foo7<decltype(xscope_access_requester)>, xscope_access_requester);

				/* You need to store the handle of the added future in order to later retrieve its value. */
				future_handles.emplace_back(handle);
			}
			int count = 1;
			for (auto it = future_handles.begin(); future_handles.end() != it; it++, count++) {
				std::cout << "thread: " << count << ", time to acquire read pointer: " << xscope_futures.xscope_ptr_at(*it)->get() << " seconds.";
				std::cout << std::endl;
			}
			std::cout << std::endl;
		}

		{
			mse::TXScopeObj<mse::TXScopeAccessControlledObj<ShareableA> > a_xscpacobj1(3);
			mse::TXScopeObj<mse::TXScopeAccessControlledObj<ShareableA> > a_xscpacobj2(5);
			mse::TXScopeObj<mse::TXScopeAccessControlledObj<ShareableA> > a_xscpacobj3(7);

			{
				std::cout << "mse::make_xscope_aco_locker_for_sharing(): " << std::endl;

				/* The mse::make_xscope_aco_locker_for_sharing() function takes a scope pointer to an "access controlled object"
				and returns a "locker" object which then holds an exclusive reference to the given access controlled
				object. From this locker object, you can obtain either one "scope passable" (non-const) pointer, or
				any number of "scope passable" const pointers. These scope passable pointers can then be safely
				passed directly as arguments to scope threads. This is a (little) more cumbersome, more restrictive
				way of sharing an object than, say, using the library's "access requesters". So generally using
				access requesters would be preferred. But you might choose to do it this way in certain cases where
				performance is critical. When using access requesters, each thread obtains the desired lock on a
				thread-safe mutex. Here we're obtaining the lock before launching the thread(s), so the mutex does
				not need to be thread-safe, thus saving a little overhead. */
				auto xscope_aco_locker1 = mse::make_xscope_aco_locker_for_sharing(&a_xscpacobj1);

				typedef decltype(xscope_aco_locker1.xscope_passable_pointer()) passable_exclusive_pointer_t;
				mse::xscope_thread xscp_thread1(K::foo17b<passable_exclusive_pointer_t>, xscope_aco_locker1.xscope_passable_pointer());
			}
			{
				auto xscope_aco_locker1 = mse::make_xscope_aco_locker_for_sharing(&a_xscpacobj1);
				auto xscope_aco_locker2 = mse::make_xscope_aco_locker_for_sharing(&a_xscpacobj2);
				auto xscope_aco_locker3 = mse::make_xscope_aco_locker_for_sharing(&a_xscpacobj3);

				typedef decltype(xscope_aco_locker1.xscope_passable_const_pointer()) passable_const_pointer_t;
				typedef decltype(xscope_aco_locker2.xscope_passable_pointer()) passable_exclusive_pointer_t;

				mse::xscope_thread xscp_thread1(K::foo18<passable_const_pointer_t, passable_exclusive_pointer_t>
					, xscope_aco_locker1.xscope_passable_const_pointer()
					, xscope_aco_locker2.xscope_passable_pointer());

				mse::xscope_thread xscp_thread2(K::foo18<passable_const_pointer_t, passable_exclusive_pointer_t>
					, xscope_aco_locker1.xscope_passable_const_pointer()
					, xscope_aco_locker3.xscope_passable_pointer());
			}
			{
				auto xscope_aco_locker1 = mse::make_xscope_aco_locker_for_sharing(&a_xscpacobj1);

				/* The mse::make_xscope_exclusive_strong_pointer_store_for_sharing() function returns the same kind of "locker" object that
				mse::make_xscope_aco_locker_for_sharing() does, but instead of taking a scope pointer to an "access controlled object", it
				accepts any recognized "exclusive" pointer. That is, a pointer that, while it exists, holds exclusive access to
				its target object. */
				auto xscope_strong_ptr_store1 = mse::make_xscope_exclusive_strong_pointer_store_for_sharing(xscope_aco_locker1.xscope_passable_pointer());

				auto xscope_aco_locker2 = mse::make_xscope_aco_locker_for_sharing(&a_xscpacobj2);
				auto xscope_aco_locker3 = mse::make_xscope_aco_locker_for_sharing(&a_xscpacobj3);

				typedef decltype(xscope_aco_locker1.xscope_passable_const_pointer()) passable_const_pointer_t;
				typedef decltype(xscope_aco_locker2.xscope_passable_pointer()) passable_exclusive_pointer_t;

				mse::xscope_thread xscp_thread1(K::foo18<passable_const_pointer_t, passable_exclusive_pointer_t>
					, xscope_strong_ptr_store1.xscope_passable_const_pointer()
					, xscope_aco_locker2.xscope_passable_pointer());

				mse::xscope_thread xscp_thread2(K::foo18<passable_const_pointer_t, passable_exclusive_pointer_t>
					, xscope_strong_ptr_store1.xscope_passable_const_pointer()
					, xscope_aco_locker3.xscope_passable_pointer());
			}
			{
				/* In this block we demonstrate obtaining various types of (const and non-const) pointers you might need from
				an exclusive pointer that might be passed to a thread. */

				std::cout << "mse::TXScopeExclusiveStrongPointerStoreForAccessControl<>: " << std::endl;

				a_xscpacobj1.pointer()->s = "";

				auto xscope_aco_locker1 = mse::make_xscope_aco_locker_for_sharing(&a_xscpacobj1);

				typedef decltype(xscope_aco_locker1.xscope_passable_pointer()) passable_exclusive_pointer_t;
				typedef decltype(xscope_aco_locker1.xscope_passable_const_pointer()) passable_const_pointer_t;

				class CD {
				public:
					/* mse::TXScopeExclusiveStrongPointerStoreForAccessControl<> is a data type that stores an exclusive strong
					pointer. From this data type you can obtain const, non-const and exclusive pointers.
					So this function expects to be passed an (rvlaue) pointer of type passable_exclusive_pointer_t. */
					static void foo1(mse::TXScopeExclusiveStrongPointerStoreForAccessControl<passable_exclusive_pointer_t> xscope_store, int count) {
						{
							auto xsptr = xscope_store.xscope_pointer();
							xsptr->s.append(std::to_string(count));
						}
						{
							/* Here, from the exclusive (non-const) pointer passed to this function, we're going to obtain a couple
							of const pointers that we can pass to different (scope) threads. */
							auto xscope_strong_ptr_store1 = mse::make_xscope_exclusive_strong_pointer_store_for_sharing(xscope_store.xscope_exclusive_pointer());

							mse::xscope_thread xscp_thread1(CD::foo2, xscope_strong_ptr_store1.xscope_passable_const_pointer());
							mse::xscope_thread xscp_thread2(CD::foo2, xscope_strong_ptr_store1.xscope_passable_const_pointer());
						}
						if (1 <= count) {
							/* And here we're going to (re)obtain an exclusive strong pointer like the one that was passed to this
							function, then we're going to use it to recursively call this function again in another (scope) thread. */
							auto xscope_strong_ptr_store1 = mse::make_xscope_exclusive_strong_pointer_store_for_sharing(xscope_store.xscope_exclusive_pointer());
							mse::xscope_thread xscp_thread1(CD::foo1, xscope_strong_ptr_store1.xscope_passable_pointer(), count - 1);
						}
					}
					static void foo2(passable_const_pointer_t xscope_A_cptr) {
						std::cout << xscope_A_cptr->s << std::endl;
					}
				};

				mse::xscope_thread xscp_thread1(CD::foo1, xscope_aco_locker1.xscope_passable_pointer(), 3);

				std::cout << std::endl;
			}
		}

		{
			/* TExclusiveWriterObj<> is a specialization of TAccessControlledObj<> for which all non-const pointers are
			exclusive. That is, when a non-const pointer exists, no other pointer may exist. */
			mse::TXScopeObj<mse::TExclusiveWriterObj<ShareableA> > a_xscpxwobj1(3);
			mse::TXScopeObj<mse::TExclusiveWriterObj<ShareableA> > a_xscpxwobj2(5);
			mse::TXScopeObj<mse::TExclusiveWriterObj<ShareableA> > a_xscpxwobj3(7);

			{
				/* A (non-const) pointer of an "exclusive writer object" qualifies as an "exclusive strong" pointer, and
				thus you can obtain an xscope shareable pointer from it in the standard way. */
				auto xscope_xwo_pointer_store1 = mse::make_xscope_exclusive_strong_pointer_store_for_sharing(a_xscpxwobj1.pointer());

				typedef decltype(xscope_xwo_pointer_store1.xscope_passable_pointer()) passable_exclusive_pointer_t;
				mse::xscope_thread xscp_thread1(K::foo17b<passable_exclusive_pointer_t>, xscope_xwo_pointer_store1.xscope_passable_pointer());
			}
			{
				/* But uniquely, you can obtain an xscope shareable const pointer from a (non-exclusive) const pointer of an
				"exclusive writer object". There is a special function for this purpose: */
				auto xscope_xwo_const_pointer_store1 = mse::make_xscope_exclusive_write_obj_const_pointer_store_for_sharing(a_xscpxwobj1.const_pointer());

				auto xscope_xwo_pointer_store2 = mse::make_xscope_exclusive_strong_pointer_store_for_sharing(a_xscpxwobj2.pointer());
				auto xscope_xwo_pointer_store3 = mse::make_xscope_exclusive_strong_pointer_store_for_sharing(a_xscpxwobj3.pointer());

				typedef decltype(xscope_xwo_const_pointer_store1.xscope_passable_const_pointer()) passable_const_pointer_t;
				typedef decltype(xscope_xwo_pointer_store2.xscope_passable_pointer()) passable_exclusive_pointer_t;

				mse::xscope_thread xscp_thread1(K::foo18<passable_const_pointer_t, passable_exclusive_pointer_t>
					, xscope_xwo_const_pointer_store1.xscope_passable_const_pointer()
					, xscope_xwo_pointer_store2.xscope_passable_pointer());

				mse::xscope_thread xscp_thread2(K::foo18<passable_const_pointer_t, passable_exclusive_pointer_t>
					, xscope_xwo_const_pointer_store1.xscope_passable_const_pointer()
					, xscope_xwo_pointer_store3.xscope_passable_pointer());
			}
		}

		{
			/* For scenarios where the shared object is atomic, you can get away without using locks
			or access requesters. */
			mse::TXScopeAtomicObj<ShareableD> xscope_D_atomic_obj(7);
			int res1 = xscope_D_atomic_obj.load().b;

			auto xscope_D_atomic_ptr = &xscope_D_atomic_obj;

			mse::xscope_thread xscp_thread1(B::foo4, xscope_D_atomic_ptr);
			mse::xscope_thread xscp_thread2(B::foo4, xscope_D_atomic_ptr);

			int res2 = (*xscope_D_atomic_ptr).load().b;
		}

#ifndef EXCLUDE_DUE_TO_MSVC2019_INTELLISENSE_BUGS1
		{
			/* This block is similar to a previous one that demonstrates safely allowing different threads to (simultaneously)
			modify different sections of a vector. The difference is just that here the shared vector is a pre-existing one
			declared as a local variable. */

			MSE_DECLARE_STATIC_IMMUTABLE(size_t) num_sections = 10;
			MSE_DECLARE_STATIC_IMMUTABLE(size_t) section_size = 5;
			const size_t num_elements = num_sections * section_size;

			typedef mse::mtnii_vector<mse::mtnii_string> async_shareable_vector1_t;
			typedef mse::mstd::vector<mse::mtnii_string> nonshareable_vector1_t;
			/* Let's say we have a vector. */
			nonshareable_vector1_t vector1;
			vector1.resize(num_elements);
			{
				size_t count = 0;
				for (auto iter = vector1.begin(); vector1.end() != iter; iter++) {
					count += 1;
					*iter = "text" + std::to_string(count);
				}
			}

			/* Only access controlled objects can be shared with other threads, so we'll make an access controlled vector and
			(temporarily) swap it with our original one. */
			mse::TXScopeObj<mse::TXScopeAccessControlledObj<async_shareable_vector1_t> > xscope_acobj;
			std::swap(vector1, *(xscope_acobj.xscope_pointer()));

			std::cout << "mse::TXScopeACORASectionSplitter<>: " << std::endl;

			{
				/* From the access controlled vector we're going to obtain scope pointers to two access controlled
				"random access section" objects which are used to access (disjoint) sections of the vector. Then we're
				going to use "locker" objects to obtain pointers that are designated as safe to pass to other threads.
				We need to specify the position  where we want to split the vector. Here we specify that it be split
				at index "num_elements / 2", right down the middle. */
				mse::TXScopeACORASectionSplitter<async_shareable_vector1_t> xscope_ra_section_split2(&xscope_acobj, num_elements / 2);

				/* Here we obtain scope pointers to the access controlled sections. */
				auto first_ra_section_aco_xsptr = xscope_ra_section_split2.xscope_ptr_to_first_ra_section_aco();
				auto second_ra_section_aco_xsptr = xscope_ra_section_split2.xscope_ptr_to_second_ra_section_aco();

				/* Access controlled object pointers aren't themselves passable to other threads, but we can obtain
				corresponding pointers that are passable via a "locker" object that takes exclusive control over
				the access controlled object. */
#ifndef _MSC_VER
				auto xscope_section_access_owner1 = mse::make_xscope_aco_locker_for_sharing(first_ra_section_aco_xsptr);
				auto xscope_section_access_owner2 = mse::make_xscope_aco_locker_for_sharing(second_ra_section_aco_xsptr);
#else // !_MSC_VER
				/* An apparent bug in msvc2017 and msvc2019preview (March 2019) prevents the other branch from compiling.
				This presents an opportunity to demonstrate an alternative solution. Instead of a "locker" object that
				takes a scope pointer to the access controlled object, we can use an "exclusive strong pointer store"
				which takes any recognized exclusive pointer. */
				auto xscope_section_access_owner1 = mse::make_xscope_exclusive_strong_pointer_store_for_sharing(
					(*first_ra_section_aco_xsptr).xscope_exclusive_pointer());
				auto xscope_section_access_owner2 = mse::make_xscope_exclusive_strong_pointer_store_for_sharing(
					(*second_ra_section_aco_xsptr).xscope_exclusive_pointer());
#endif // !_MSC_VER

				/* The K::foo8 template function is just an example function that operates on containers of strings. In this case the
				containers will be the random access sections we just created. We'll create an instance of the function here. */
				const auto my_foo8_function = K::foo8<mse::TXScopeAnyRandomAccessSection<mse::mtnii_string> >;
				typedef decltype(my_foo8_function) my_foo8_function_type;

				mse::xscope_thread_carrier threads;
				/* So this thread will modify the first section of the vector. */
				threads.new_thread(K::invoke_with_ra_section<decltype(xscope_section_access_owner1.xscope_passable_pointer()), my_foo8_function_type>
					, xscope_section_access_owner1.xscope_passable_pointer(), my_foo8_function);
				/* While this thread modifies the other section. */
				threads.new_thread(K::invoke_with_ra_section<decltype(xscope_section_access_owner2.xscope_passable_pointer()), my_foo8_function_type>
					, xscope_section_access_owner2.xscope_passable_pointer(), my_foo8_function);

				/* Note that in this particular scenario we didn't need to use any access requesters (or (thread safe) locks). */
			}

			std::cout << "mse::TXScopeAsyncACORASectionSplitter<>: " << std::endl;

			{
				/* Ok, now let's do it again, but instead of splitting the vector into two sections, let's split it into more sections: */
				/* First we create a list of a the sizes of each section. We'll use a vector here, but any iteratable container will work. */
				mse::mstd::vector<size_t> section_sizes;
				for (size_t i = 0; i < num_sections; i += 1) {
					section_sizes.push_back(section_size);
				}

				/* This time (for demonstration purposes) we'll use TXScopeAsyncACORASectionSplitter<> to generate a new
				access requester for each section. */
				mse::TXScopeAsyncACORASectionSplitter<async_shareable_vector1_t> xscope_ra_section_split1(&xscope_acobj, section_sizes);
				auto ar0 = xscope_ra_section_split1.ra_section_access_requester(0);

				const auto my_foo8_function = K::foo8<decltype(ar0.writelock_ra_section())>;
				typedef decltype(my_foo8_function) my_foo8_function_type;
				const auto my_foo8_proxy_function = K::invoke_with_writelock_ra_section1<decltype(ar0), my_foo8_function_type>;

				{
					mse::xscope_thread_carrier xscope_threads;
					for (size_t i = 0; i < num_sections; i += 1) {
						auto ar = xscope_ra_section_split1.ra_section_access_requester(i);
						xscope_threads.new_thread(my_foo8_proxy_function, ar, my_foo8_function);
					}
					/* The scope will not end until all the scope threads have finished executing. */
				}
			}

			/* Now that we're done sharing the (controlled access) vector, we can swap it back to our original vector. */
			std::swap(vector1, *(xscope_acobj.xscope_pointer()));
			auto first_element_value = vector1[0];
			auto last_element_value = vector1.back();

			int q = 5;
		}
#endif // !EXCLUDE_DUE_TO_MSVC2019_INTELLISENSE_BUGS1
	}
}

#ifdef __clang__
#pragma clang diagnostic pop
#else /*__clang__*/
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif /*__GNUC__*/
#endif /*__clang__*/

#ifdef _MSC_VER
#pragma warning( pop )
#endif /*_MSC_VER*/

#else // !EXCLUDE_MSETL_EXAMPLE3
void msetl_example3() {}
#endif // !EXCLUDE_MSETL_EXAMPLE3


Legislation in Place to Ban Animal Sales

In their reports of December 3, 2009 and September 10, 2010, city staff raised the issue of whether or not a ban on the sale of animals has been imposed in other jurisdictions. This is an issue which is, of course, of interest to Council. That is the topic I intend to address in the few minutes that I have with you- what has been done and what is in the process of being done in other jurisdictions.

Beginning with those jurisdictions which currently have by-laws in place—

Hermosa Beach, California banned the sale of dogs and cats in pet stores on March 23, 2010, following unanimous vote by council. The ban went into effect on April 13, 2010. (no pet stores then selling live animals).

The sale of cats and dogs in retail outlets is also banned in South Lake Tahoe, California. That ban takes effect next year.

West Hollywood, California banned the sale of dogs and cats Feb 16, 2010. The ban was imposed after counsel was presented with evidence that retailers got dogs from a USDA licensed breeding operation in Minnesota that crammed sick and wounded dogs into wire cages, exposed them to freezing temperatures and caused them to live in their own waste.

Austin, Texas passed their ban on retail sales of cats and dogs on July 29, 2010. (Petland sold cats and dogs at the time the ban was being discussed, but closed in anticipation of the ban coming into effect.)

In the last few years, the following cities in the state of Florida have imposed a by-law that prohibits the keeping of dogs for any “commercial purpose”: Fort Lauderdale, Coral Gables, Lauderdale Lakes, Flagler Beach, North Bay Village and Opa-Locka.

Most significantly, from our perspective, is that ban on the retail sale of all companion animals that was imposed in Albuquerque, New Mexico in 2006. Because the ban has been in place for 4 years, there has been an opportunity to begin to evaluate the effects of the ban. Statistic confirm that in that jurisdiction, animal adoptions have increased by 23% and euthanasia at city shelters has decreased by 35%.

I note that while it is true that a couple of these jurisdictions did not have any pet stores that were selling live animals at the time that the bans came into force, most did—and further, of those that did not, a number had moved to a new business model that did not involve the sale of live animals by the tie the by-law came into effect— they stopped selling cats and dogs, in anticipation of a ban coming into effect. They knew what was coming and they adjusted.

Cities Considering Legislation

That is just what has already been done. There are numerous jurisdictions which are currently considering the imposition of by-laws or ordinances. In the US, those jurisdictions include San Francisco and Glendale, California, where a ban on the sale of most pets, including dogs, cats, birds, hamsters, rats and other small animals is being considered. Rio Rancho, New Mexico, and El Paso, Texas are considering banning the sale of all animals. Also considering similar by-laws are Wentzville, Missouri, Baltimore, Maryland and Jacksonville, Hallandale Beach and West Palm Beach, Florida. (CORRECTION: (July 18, 2012) – the only city in Florida with a pet sale ban is Lake Worth, Florida).

The American experience and the example being set in the States is relevant. We know that pet stores in Canada source dogs from both Canadian and American puppy mills. Indeed, as you heard last time, at least one pet store operating in Richmond sources their puppies from a notorious puppy broker who in turns sources their puppies from puppy mills- Hunte Corporation.

According to the Humane Society of the US, 3-4 million unwanted companion animals are killed in shelters every year. There are more than 10,000 puppy mills in operation. Between 2 and 4 million dogs are born into puppy mills every year. It costs US taxpayers $2 billion/yr to house and euthanize all unwanted animals. In the US, they are doing something about it, beginning with imposing a ban the sale of animals in pet stores.

And they have not stopped there. The majority of states have introduced and in some cases already passed bills aimed at establishing inspection or licensing programs for high volume puppy producers. State bills include protective measures that restrict abuse, implement minimum standards of care, mandate exercise, inspections, seizure for non-compliance and, in some cases, mandate sterilization. Some bills limit the number of unaltered dogs a breeder is allowed to have, targeting mass volume puppy producers.

We at the BC SPCA also recognize that a multi-faceted approach to the problem is required in order to eliminate puppy mills- and these are some of the other areas for us to tackle; however, all involved in this issue recognize that the most effective way to slow production of any “product” is to decrease the demand for that product. It is no answer to those that are in favor of a ban to say—well banning the sale of animals in pet stores is not going to solve the problem. Of course not. It takes many pieces to make a puzzle. The imposition of a ban would be a significant one.

Here in Canada, we are just getting started. Thus far, only Toronto is considering the imposition of a by-law. The proposal before Toronto City Council includes the following quote from a prominent Canadian veterinarian: “The demand on the market results in puppy/kitten mills whereby animals are kept solely for breeding purposes to make profits with little or no concern for their well-being. Offspring produced can suffer from an array of breed specific genetic conditions because of poorly regulated breeding programs. Shutting down the sale of puppies/kittens through pet stores will have an impact on eliminating these often cruel practices which are required to meet the demand for the supply of pets through the retail market.”

Advertisements

Like this:

Hallandale Beach, Florida is now behind Lake Worth as the second Florida city to pass the ban.
Point of Information. You can still open a retail store in all of these cities.
“In the last few years, the following cities in the state of Florida have imposed a by-law that prohibits the keeping of dogs for any “commercial purpose”: Fort Lauderdale, Coral Gables, Lauderdale Lakes, Flagler Beach, North Bay Village and Opa-Locka.”


High Level Architecture (HLA) is a communication standard used during a computer simulation by software applications to communicate with one another. The HLA communication standards and initial infrastructure were developed by the United States Defense Modeling and Simulation Office (DMSO). As the standards matured, DMSO turned over infrastructure development to industry. In a war game simulation HLA may be used to manage the flow of data between the various hardware and software component that may be used to simulate various real-world counterparts (e.g., troops, vehicles, ships, etc.) during the war game. This may allow, for example, a tank to be simulated separately from a jeep, while still allowing the tank and jeep simulations to interact with one another.
An Enterprise Service Bus (ESB) may allow ESB clients to communicate with one another. The ESB clients may communicate via extensible Markup Language (XML). XML provides a way for structured data to be shared across different information systems, such as different ESB clients. Schemas may be used to define what an XML document should look like. XML messages may have a different format than HLA messages. One messaging service that may be used to transport XML documents is Java Messaging Service (JMS). JMS is commonly used to facilitate communication between Java implemented applications.
Traditionally, communication between an XML or JMS component and an HLA component required the use of a bridge to translate between the two services. Unfortunately, whenever a new type of message needed to be translated, new Java code had to be created. The Java code provided instructions on how the bridge was to map the fields of one message type to the other.


; Author: Anonymous
;

; General
allRunningHint = "Alla tjänster körs"
someRunningHint = "%n av %t tjänster körs"
noneRunningHint = "Ingen av %t tjänster körs"

; Single
about = "Om"
administration = "#Administration"
aliases = "Alias"
apps = "Applikationer"
bins = "Binärer"
changelog = "Förändringslogg"
console = "Trösta"
debug = "Debug"
disabled = "#Disabled"
donate = "Donera"
donateVia = "Donera via %s"
download = "Hämta"
downloadMore = "#Download more..."
enabled = "#Enabled"
error = "Fel"
executable = "Körbar"
extensions = "Tilläggsprogram"
gitConsole = "#Git console"
github = "Github"
help = "Hjälp"
hostseditor = "HostsEditor"
lang = "Språk"
license = "#License"
logs = "Logs"
logsVerbose = "Logs verbose"
modules = "Moduler"
name = "#Name"
paypal = "Paypal"
pythonConsole = "#Python console"
pythonCp = "#Python control panel"
quit = "Avsluta"
readChangelog = "Läs den %ssenaste förändringloggen%s."
reload = "Uppdatera"
repos = "Repositories"
restart = "Starta om"
service = "Tjänst"
settings = "Inställningar"
ssl = "SSL"
startup = "Starta upp"
status = "Status"
statusPage = "#Status page"
svnConsole = "#SVN console"
target = "#Target"
tools = "Verktyg"
verboseDebug = "Debug"
verboseReport = "Report"
verboseSimple = "Simple"
verboseTrace = "#Trace"
version = "Version"
versions = "Versioner"
virtualHosts = "Virtuella Värdar"
website = "Webbsajt"

; Menu
menuAbout = "Om..."
menuAccessLogs = "Åtkomstloggar"
menuAddAlias = "Lägg till ett alias"
menuAddVhost = "Lägg till en virtuell värd"
menuChangePort = "Ändra port"
menuChangeRootPwd = "#Change root password"
menuCheckPort = "Kontrollera port %s"
menuCheckUpdate = "Sök efter uppdatering"
menuClearFolders = "Radera temporära filer"
menuEditAlias = "Redigera %s"
menuEditVhost = "Redigera %s"
menuEnable = "#Enable / Disable"
menuErrorLogs = "Felloggar"
menuGenSslCertificate = "#Generate SSL certificate"
menuInstallService = "Installera Tjänst"
menuLaunchStartup = "Kör när Windows startar"
menuLocalhost = "Localhost"
menuLogs = "Loggar"
menuPutOffline = "Sätt Offline"
menuPutOnline = "Sätt Online"
menuRefreshRepos = "Refresh repositories"
menuRemoveService = "Ta bort Tjänst"
menuRestartService = "Starta om tjänst"
menuRestartServices = "Starta om alla tjänster"
menuRewriteLogs = "Skriv om loggar"
menuScanReposStartup = "#Scan repos on startup"
menuSessionLogs = "Sessionsloggar"
menuStartService = "Starta tjänst"
menuStartServices = "Starta alla tjänster"
menuStatsLogs = "Statistikloggar"
menuStopService = "Stoppa tjänst"
menuStopServices = "Stoppa alla tjänster"
menuTransferLogs = "Överföringsloggar"
menuUpdateEnvPath = "#Update env. PATH"
menuWwwDirectory = "www filkatalog"

; Bins
apache = "Apache"
filezilla = "Filezilla"
mailhog = "MailHog"
mariadb = "MariaDB"
memcached = "Memcached"
mongodb = "MongoDB"
mysql = "MySQL"
nodejs = "Node.js"
pear = "PEAR"
php = "PHP"
postgresql = "PostgreSQL"
svn = "SVN"

; Apps
adminer = "Adminer"
gitlist = "GitList"
phpmemadmin = "phpMemAdmin"
phpmyadmin = "phpMyAdmin"
phppgadmin = "phpPgAdmin"
webgrind = "Webgrind"
websvn = "WebSVN"

; Tools
composer = "Composer"
consolez = "ConsoleZ"
ghostscript = "Ghostscript"
git = "Git"
ngrok = "ngrok"
perl = "Perl"
python = "Python"
ruby = "Ruby"
xdc = "XDebugClient"
yarn = "Yarn"

; Errors
errorConfNotFound = "%s konfigurationsfil hittades inte i %s"
errorExeNotFound = "%s .exe-fil hittades inte i %s"
errorFileNotFound = "%s hittades inte i %s"
errorInvalidParameter = "#Invalid parameter '%s' : %s"

; Action Switch version
switchVersionTitle = "Byt %s version %s"
switchVersionReloadConfig = "Uppdatera konfig"
switchVersionReloadBins = "Reload bins"
switchVersionRegistry = "Återställ %s registernyckel"
switchVersionResetServices = "Återställ alla tjänster"
switchVersionSameError = "Du befinner dig redan på %s %s."
switchVersionOk = "%s version har bytts till %s"
switchVersionOkRestart = "%s version har ändrats till %s"
apacheIncpt = "Apache %s verkar inte vara kompatibelt med PHP %s."
phpIncpt = "PHP %s verkar inte vara kompatibelt med Apache %s."
neardConfNotFoundError = "Neard konfig-filer hittades inte för %s."
neardConfMalformedError = "Neard konfig-filer felbildades för %s."

; Action Switch PHP setting
switchPhpSettingTitle = "Ändra PHP-inställningar"
switchPhpSettingNotFound = "PHP-inställningen %s hittades inte i konfigurationsfilen PHP %s."

; Action Check port
checkPortTitle = "Kontrollera %s port %s"
portUsedBy = "Port %s används av %s."
portNotUsed = "Port %s är inte i bruk."
portNotUsedBy = "Port %s av en annan applikation."
portUsedByAnotherDbms = "Port %s används av en annan DBMS."
portChanged = "%s port ändrades framgångsrikt till %s"

; Action Install service
installServiceTitle = "Installerar tjänsten %s"
serviceAlreadyInstalled = "Tjänsten %s är redan installerad."
serviceInstalled = "Tjänsten %s installerades framgångsrikt.@nl@Namn: %s@nl@Port: %s"
serviceInstallError = "Fel vid installation av tjänsten %s."

; Action Remove service
removeServiceTitle = "Ta bort tjänsten %s"
serviceNotExist = "Tjänsten %s finns inte."
serviceRemoved = "Tjänsten %s har framgångsrikt tagits bort."
serviceRemoveError = "Fel vid installation av tjänsten %s."

; Action Start service
startServiceTitle = "#Start %s service"
startServiceError = "#Error while starting the %s service."

; Action Stop service
stopServiceTitle = "#Stop %s service"
stopServiceError = "#Error while stopping %s service."

; Action Restart service
restartServiceTitle = "#Restart %s service"
restartServiceError = "#Error while restarting the %s service."

; Action Delete alias
deleteAliasTitle = "Ta bort alias"
deleteAlias = "Vill du verkligen ta bort alias '%s' ?"
aliasRemoved = "Alias '%s' har framgångsrikt tagits bort."
aliasRemoveError = "Det går inte att ta bort aliasets konfigurations-fil i:@nl@%s"

; Action Add/Edit alias
addAliasTitle = "Lägg till alias"
aliasNameLabel = "Namn"
aliasDestLabel = "Destination"
aliasExpLabel = "Aliaset skulle vara till http://localhost%s/%s/@nl@och skulle peka till %s"
aliasDestPath = "Välj destinationsmapp för ditt alias :"
aliasNotValidAlpha = "#Alias name '%s' is not a valid alphanumeric string."
aliasAlreadyExists = "Alias '%s' finns redan."
aliasCreated = "Alias '%s' skapades framgångsrikt.@nl@@nl@Url: http://localhost%s/%s/@nl@Sökväg: %s"
aliasCreatedError = "Det går inte att skapa aliasets konfigurationsfil."
editAliasTitle = "Redigera alias %s"

; Action Delete vhost
deleteVhostTitle = "Ta bort virtuell värd"
deleteVhost = "Vill du verkligen ta bort den virtuella värden '%s' ?"
vhostRemoved = "Virtuell värd '%s' har framgångsrikt tagits bort."
vhostRemoveError = "Det går inte att ta bort den virtuella värdens konfigurationsfil i:@nl@%s"

; Action Add/Edit vhost
addVhostTitle = "Lägg till virtuell värd"
vhostServerNameLabel = "Servernamn"
vhostDocumentRootLabel = "Rotdokument"
vhostExpLabel = "Virtuell värd skulle vara till http://%s/@nl@och skulle peka till %s"
vhostDocRootPath = "Välj rotdokumentet för din virtuella värd :"
vhostNotValidDomain = "#The server name '%s' is not a valid domain name."
vhostAlreadyExists = "Virtuell värd '%s' finns redan."
vhostCreated = "#Virtual host '%s' successfully created.@nl@Do not forget to add the domain name to your hosts file (via HostsEditor tool).@nl@@nl@Url: http://%s/@nl@Path: %s"
vhostCreatedError = "Det går inte att skapa den virtuella värdens konfigurationsfil."
editVhostTitle = "Redigera virtuell värd %s"

: Action Change port
changePortTitle = "Ändrar port för %s"
changePortCurrentLabel = "Faktisk port som används av %s : %s"
changePortNewLabel = "Ny port"
changePortSameError = "Detta är samma port som faktiskt används."

; Action Change database root password
changeDbRootPwdTitle = "#Change %s root password"
changeDbRootPwdCurrentpwdLabel = "#Current password"
changeDbRootPwdNewpwd1Label = "#New password"
changeDbRootPwdNewpwd2Label = "#Confirm new password"
changeDbRootPwdNotsameError = "#Passwords that you entered are not identical to each other"
changeDbRootPwdIncorrectError = "#%s error: %s"
changeDbRootPwdText = "#Root password changed successfully!"

; Action Startup
startupStartingText = "Startar %s. Var vänlig vänta"
startupRotationLogsText = "#Log archiving"
startupKillOldProcsText = "#Stop old instances"
startupRefreshHostnameText = "Uppdaterar värdnamn"
startupCheckBrowserText = "Kontrollerar webbläsare"
startupSysInfos = "#Get system infos"
startupCleanTmpText = "#Deleting temporary files"
startupCleanOldBehaviorsText = "#Remove deprecated features"
startupRefreshAliasText = "Uppdatera alias"
startupRefreshVhostsText = "Uppdatera virtual hosts"
startupCheckPathText = "Kontrollerar nuvarande sökväg"
startupScanFoldersText = "Skannar filkataloger"
startupChangePathText = "#Change path with %s"
startupRegistryText = "Kontrollerar registernyckeln %s"
startupRegistryErrorText = "Felinställning %s registernyckel :"
startupUpdateConfigText = "#Update configuration"
startupCheckServiceText = "#Checking %s service"
startupInstallServiceText = "Installerar tjänsten %s"
startupStartServiceText = "Startar tjänsten %s"
startupPrepareRestartText = "Förbered omstart av %s"
startupRestartingText = "Omstartar %s. Var vänlig vänta"
startupErrorTitle = "Fel vid uppstart"
startupServiceError = "Tjänsten %s kan inte installeras :"
startupServiceCreateError = "- Kan inte skapa tjänsten : Fel %s"
startupServiceStartError = "- Kan inte starta tjänsten : Fel %s"
startupServiceSyntaxError = "- Konf-fel upptäckta : %s"
startupServicePortError = "- Port %s används av en annan applikation : %s."
startupRefreshGitReposText = "Refresh Git repositories"
startupGenSslCrtText = "#Generate %s SSL certificate"

; Action Quit
exitLeavingText = "Lämnar %s"
exitRemoveServiceText = "Tar bort tjänsten %s"
exitStopOtherProcessText = "#Stop third parties process"

; Action Change browser
changeBrowserTitle = "Byt webbläsare"
changeBrowserExpLabel = "Välj en webbläsare :"
changeBrowserOtherLabel = "Annan :"
changeBrowserOk = "Webbläsare byttes framgångsrikt till:@nl@%s"

; Action About
aboutTitle = "Om..."
aboutText = "%s@nl@Copyright(C) 2014-%s %s@nl@@nl@Neard is free software; you can redistribute it and/or modify it@nl@under the terms of the GNU LESSER GENERAL PUBLIC LICENSE."

; Action Debug Apache
debugApacheVersionNumber = "Versions-nummer"
debugApacheCompileSettings = "Sammanställ inställningar"
debugApacheCompiledModules = "Sammanställda moduler"
debugApacheConfigDirectives = "Konfig-direktiv"
debugApacheVhostsSettings = "Virtuell värds inställningar"
debugApacheLoadedModules = "Inlästa moduler"
debugApacheSyntaxCheck = "Konfig syntaxkontroll"

; Action Debug MySQL
debugMysqlVersion = "Version"
debugMysqlVariables = "Variabler"
debugMysqlSyntaxCheck = "Konfig syntax-verifiering"

; Action Debug MariaDB
debugMariadbVersion = "Version"
debugMariadbVariables = "Variabler"
debugMariadbSyntaxCheck = "Konfig syntax-verifiering"

; Action Debug MongoDB
debugMongodbVersion = "Version"

; Action Debug PostgreSQL
debugPostgresqlVersion = "Version"

; Action Debug SVN
debugSvnVersion = "Version"

; Action others...
registrySetErrorText = "Registreringsvärde inkorrekt : %s"

; Action check version
checkVersionTitle = "Kontrollerar version"
checkVersionAvailableText = "Ny version tillgänglig!"
checkVersionChangelogText = "#Before updating please read the changelog : "
checkVersionLatestText = "Du har hämtat den senaste versionen av Neard..."

; Action gen SSL certificate
genSslTitle = "#Generate SSL certificate"
genSslPath = "#Select the target folder :"
genSslCreated = "#SSL certificate '%s' successfully created."
genSslCreatedError = "#Unable to create SSL certificate."

; Action Restart
restartTitle = "#Restart"
restartText = "#Please restart %s to apply new settings..."

; Action enable
enableTitle = "#Enable / Disable %s"
enableBundleNotExist = "#%s cannot be enabled because bundle %s does not exist in %s"

; Windows forms
buttonOk = "OK"
buttonDelete = "Ta bort"
buttonSave = "Spara"
buttonFinish = "Slutför"
buttonCancel = "Avbryt"
buttonNext = "Nästa >"
buttonBack = "< Tillbaka"
buttonBrowse = "Sök..."
loading = "Laddar..."

; Homepage
homepageOfficialWebsite = "Officiell Webbplats"
homepageServiceStarted = "startad på port %s"
homepageServiceStopped = "stoppad"
homepageAboutHtml = "#
Neard is a portable WAMP software stack involving useful binaries, tools and applications for your web development.
For those who wish to contribute, have an issue or questions, read the Documentation.
To be notified of new releases you can star the repository on Github.
"
homepageLicenseText = "Neard är en kostnadsfri mjukvara; du får återdistribuera den och/eller modifiera den under villkoren av GNU Lesser General Public License som publicerats av Free Software Foundation, antingen version 3 av Licensen, eller (ut efter ditt val) någon senare version."
homepageQuestionsTitle = "Frågor ?"
homepageQuestionsText = "Om du upptäcker problem eller om du har idéer kring utvecklandet av Neard, publicera då frågan på GitHub!"
homepagePostIssue = "Publicera ett problem"
homepagePhpinfoText = "Visa phpinfo()"
homepageMailhogText = "#View received emails"
homepageApcText = "#APC Manager"
homepageBackText = "Tillbaka till webbplats"


Detoxification of 1,1,2-trichloroethane to ethene in a bioreactor co-culture of Dehalogenimonas and Dehalococcoides mccartyi strains.
1,1,2-Trichloroethane (1,1,2-TCA) is a non-flammable organic solvent and common environmental contaminant in groundwater. Organohalide-respiring bacteria are key microorganisms to remediate 1,1,2-TCA because they can gain metabolic energy during its dechlorination under anaerobic conditions. However, all current isolates produce hazardous end products such as vinyl chloride, monochloroethane or 1,2-dichloroethane that accumulate in the medium. Here, we constructed a syntrophic co-culture of Dehalogenimonas and Dehalococcoides mccartyi strains to achieve complete detoxification of 1,1,2-TCA to ethene. In this co-culture, Dehalogenimonas transformed 1,1,2-TCA via dihaloelimination to vinyl chloride, whereas Dehalococcoides reduced vinyl chloride via hydrogenolysis to ethene. Molasses, pyruvate, and lactate supported full dechlorination of 1,1,2-TCA in serum bottle co-cultures. Scale up of the cultivation to a 5-L bioreactor operating for 76d in fed-batch mode was successful with pyruvate as substrate. This synthetic combination of bacteria with known complementary metabolic capabilities demonstrates the potential environmental relevance of microbial cooperation to detoxify 1,1,2-TCA.


Q:

binary search doesn't work in C

I have the following binary search algorithmn:
int search_binary(int* tab,int size, int a)
{
    int lower=0,upper=size-1,middle=(lower + upper)/2;
    while(lower < upper)
    {
        if(tab[middle] == a)
            break;
        else if(tab[middle] < a)
        {
            upper = middle - 1;
            middle = (lower + upper)/2;
        } else {
            lower = middle + 1;
            middle = (lower + upper)/2;
        }

    }

    if(tab[middle] == a)
        return middle;
    else
        return -1;

}

It either return -1 if I insert a number, that exists or it returns the wrong index.
exampledata:
table:
2
2
4
5
7
7
8
8
8
9
searched number:
7
result:
The index is: 4
table:
1
2
3
4
6
6
6
7
8
9
searched number:
4
result:
The index is: -1

A:

else if(tab[middle] < a)
    {
        upper = middle - 1;
        middle = (lower + upper)/2;
    }

From here it seems that you expect the array to be ordered in decreasing order. In fact, giving it an array ordered that way, it works for me.
just change the if to:
if(tab[middle] > a)

To have it working for an array ordered in increasing order


Obama strikes a business tone with the U.S. Chamber of Commerce

Since Barack Obama became President of the United States, one of the biggest complaints from his critics has been that his policies and measures have been far from “business friendly.” Maybe that is your opinion and maybe it isn’t, but, either way, it is worth taking a look at comments made during his speech at the United States Chamber of Commerce earlier today.

Since Barack Obama became President of the United States, one of the biggest complaints from his critics has been that his policies and measures have been far from “business friendly.”

Maybe that is your opinion and maybe it isn’t, but, either way, it is worth taking a look at comments made during his speech at the United States Chamber of Commerce earlier today. Before I dig into what Obama said, it is worth noting that the U.S. Chamber has made itself very clear about how this Administration has come up short on several initiatives, including job creation, cap and trade i.e. energy legislation, and healthcare legislation to name a few.

Regardless of your political party affiliation, it is clear that Obama did a good job of making his case to U.S. businesses, noting that now is the time to make required and necessary investments to help the economy grow.

According to media reports, U.S. Chamber CEO Tom Donohue, in his introduction of Obama, said some areas where U.S. businesses and the White House can get on the same page are increasing free trade and exports and infrastructure investment, two ideas which the President holds dearly when it comes to jump-starting the economy.

And in what could be seen as an extension of a theme touted in the recent State of the Union address, Obama stressed the importance of U.S. business to get back in the game:

“Right now, businesses across this country are proving that America can compete,” said the President. “Caterpillar is opening a new plant to build excavators in Texas that used to be shipped from Japan. In Tennessee, Whirlpool is opening their first new US factory in more than a decade. Dow is building a new plant in Michigan to manufacture batteries for electric vehicles…Now is the time to invest in America. Today, American companies have nearly $2 trillion sitting on their balance sheets. I know that many of you have told me that you are waiting for demand to rise before you get off the sidelines and expand, and that with millions of Americans out of work, demand has risen more slowly than any of us would like.”

But even with business demand still relatively low, Obama noted how economists and sales forecasts are indicating a healthy increase in demand is on the way, adding that the recently-concluded bipartisan tax cut deal enables U.S. businesses to expense 100 percent of capital investments, which can, in turn, lead to greater demand and higher profits along with more American jobs.

In his comments on infrastructure, Obama said that the U.S. has a responsibility as a nation to provide our people and our businesses with the fastest, most reliable way to move goods and information.

“The costs to business from the outdated and inadequate infrastructure we currently have are enormous,” he said. “That’s why I want to put more people to work rebuilding crumbling roads and bridges. And that’s why I’ve proposed connecting 80 percent of the country to high-speed rail, and making it possible for companies to put high-speed internet coverage in reach of virtually all Americans.

And as he has in the past, Obama stressed the need to build a 21st century infrastructure and in doing so he thanked the Chamber for pushing Congress to make more infrastructure investments, and to do so in the most cost-effective way possible: with tax dollars that leverage private capital, and with projects determined not by politics, but by what’s best for our economy.

With the goal of doubling U.S. exports by 2015 always top of mind for the President, he mentioned that when it comes to exports, it essentially translates into seeking new opportunities and opening new markets for U.S. goods

“I’ll go anywhere to be a booster for American businesses, American workers, and American products,” said Obama. “We recently signed export deals with India and China that will support more than 250,000 jobs here in the United States. And we finalized a trade agreement with South Korea that will support at least 70,000 American jobs – a deal that has unprecedented support from business and labor; Democrats and Republicans. That’s the kind of deal I’ll be looking for as we pursue trade agreements with Panama and Columbia and work to bring Russia into the international trading system.”

If these types of things come to fruition, the future economic outlook could very well be promising even in light of our relatively slow and gradual recovery. There is obviously a long way to go, but the potential is there. If President Barack Obama and the U.S. Chamber of Commerce can work together, can’t everyone else?

February 7, 2011

About the Author

Jeff Berman, Group News Editor

Jeff Berman is Group News Editor for Logistics Management, Modern Materials Handling, and Supply Chain Management Review. Jeff works and lives in Cape Elizabeth, Maine, where he covers all aspects of the supply chain, logistics, freight transportation, and materials handling sectors on a daily basis. Contact Jeff Berman

While Amazon’s recent bid to purchase Whole Foods made mainstream headlines, the e-commerce giant will still need to adhere to time-tested realities. Any way you slice it, the integrated U.S. cold chain requires optimized service from existing ports, 3PLs, cold storage warehousing, transportation providers and high-value vendors.


Snow Bunting on the beach at Findhorn

I must admit my birding skills are not that good, but luckily the North Scotland RSPB office in Inverness came to the rescue and identified this as a male Snow Bunting in its autumn colours.


Just after 2 p.m. Wednesday, a person in Corpus Christi, Tex., had just completed a transaction at a Bank of America A.T.M. when a surprise slid through the receipt slot.

“Please help,” read a handwritten note on a thin strip of paper. “I’m stuck in here, and I don’t have my phone.”

The person, whose age and gender the authorities did not provide, did not know quite what to do. But it so happened that a Corpus Christi police officer was driving by, so the person went a step beyond what other A.T.M. users had been willing to do and flagged down the officer.

The officer, like previous bank patrons, initially thought the note was a joke — some sort of “Candid Camera”-type prank that no one wanted to fall for.


Q:

Retrieve the name of the key in a pgfkeys .code macro

Just to focus the problem, I am thinking of reducing the numbers of parameters of the circuitikz package into a reasonable ballpark; now for example each one of the 30+ generators have a different key for setting the width, which I find it's not reasonable; the same happens to transistors etc etc.
I want to warn the user about the change, so I am thinking to change
\tikzset{/one/two/four/.initial=0.5}

into
\def\deprecationwarning{\PackageWarning{circuitikz}{%
Please look at the manual: the key /one/two/four is deprecated}}

\tikzset{/one/two/four/.code=\deprecationwarning}

(which will be easy done, with a search and replace of .initial=.*} on a region).
The question is: it is possible to retrieve the name of the key in the macro \deprecationwarning? So that I can just substitute the .initial=blah} with a fixed string?
Extra points if a subsequent \pgfkeysvalueof use of the key can throw an error...
This is the MWE for playing with the idea...
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tikz}

\def\deprecationwarning{\PackageWarning{circuitikz}{%
Please look at the manual: the key /one/two/four is deprecated}}

\tikzset{/one/two/three/.initial=0.5}
% \ctikzset{one/two/four/.initial=0.5}
\tikzset{/one/two/four/.code=\deprecationwarning}

\begin{document}
\tikzset{/one/two/three=3}
\tikzset{/one/two/four=4}
\Huge
*\pgfkeysvalueof{/one/two/three}*\quad *\pgfkeysvalueof{/one/two/four}*
\end{document}

A:

Sorry for the confusion, I think you are looking for \pgfkeyscurrentpath.
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tikz}

\def\deprecationwarning{\PackageWarning{circuitikz}{%
Please look at the manual: the key \pgfkeyscurrentpath\space is deprecated}}

\tikzset{/one/two/three/.initial=0.5}
% \ctikzset{one/two/four/.initial=0.5}
\tikzset{/one/two/four/.code=\deprecationwarning}

\begin{document}
\tikzset{/one/two/three=3}
\tikzset{/one/two/four=4}
\Huge
*\pgfkeysvalueof{/one/two/three}*\quad *\pgfkeysvalueof{/one/two/four}*
\end{document}


1. Field of the Invention
The present invention relates to a propulsion assembly having elongate members. It relates to a propulsion assembly having elongate members in particular as used in bicycles.
2. Description of the Related Art
The idea of using reciprocating elongate members for propelling a bicycle is known. For example, U.S. Pat. No. 5,335,927 to Islas shows a drive mechanism for a bicycle that employs elongate members in the form of foot levers mounted on the frame. The foot levers are mounted close to rear sprocket and are connected to a rotary drive mechanism which, in turn, is connected to the rear wheel.
While Islas provides foot levers, their purpose is defeated: Islas effectively splits the levers so that only a portion of each lever is used for the rider to generate torque. The portions of levers used are not much longer than that of the cranks on a conventional bicycle. As a result, Islas fails to enable the generation of noticeably more torque than that of the conventional bicycle. Also, Islas has a number of exposed parts and cables which may be prone to entanglement and failure.
Another example is U.S. Pat. No. 3,881,747 to Abbott which shows a bicycle foot pedal that is movable through an adjustable linkage of elongate members. The elongate members are in the form of levers for transmitting one-way rotational power to an elevated drive sprocket. The assembly is configured to enable a bicycle rider to vary the path of the pedal to simulate running, walking, or other desirable movement. However, Abbott also splits the levers and as a result the propulsion system provides a diminished leverage or torque. Abbott also requires for its propulsion system a bicycle that is completely re-modified.


Q:

Android - large data json download

I'm facing a problem in my app Android that consists in a failure to recover large json data from web service. The JSON data is large because contains images which are recovered from a table in my database.
Some days ago everything was working fine, but the number of registers in this table grew up fastly and then the problem rises.
This problem is not happening on iOS or on Android emulator, just on real Android device.
The code is stopping the download suddenly and throwing the error
org.json.JSONException: Unterminated string at character <cccc> of <json data>

That is, the code is not downloading the entire JSON data. Besides, the download stops in a different point always I run the code.
Someone know why that is happening?
This is the function which tries to recover the data from web service:
protected static JSONObject executeJSONQuery(ContentValues values,
          WebServiceResolverCode code, Context context)
            throws ContratoInativoException, JSONException {

    URL url;
    HttpURLConnection conn;
    JSONObject jArray = null;

    // build the string to store the response text from the server
    String response = "";

    try {
        url = new URL(WebServiceResolver.getWebServiceSufix(code, context));

        String param = "";
        for (String key : values.keySet()) {
            Object value = values.get(key);
            param += key+"="+ URLEncoder.encode(value!=null?values.getAsString(key):"", "UTF-8")+"&";
        }

        conn = (HttpURLConnection) url.openConnection();
        conn.setDoOutput(true);
        conn.setRequestMethod("POST");

        conn.setFixedLengthStreamingMode(param.getBytes().length);
        conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

        // send the POST out
        OutputStreamWriter out = new OutputStreamWriter(conn.getOutputStream());
        out.write(param);
        out.flush();
        out.close();

        // start listening to the stream
        Scanner inStream = new Scanner(conn.getInputStream());
        while (inStream.hasNextLine()){
            response += (inStream.nextLine());
        }
        inStream.close();
        // process the stream and store it in StringBuilder
        jArray = new JSONObject(response);

    } catch (IOException ex) {
        ex.printStackTrace();
        Log.d("ERROR JSON STRING", response);
    }
    return jArray;
}

A:

Firstly, do not keep an image in a table. Keep it in your server space and keep the URL to the image in your table. When you need to load the image, load it with the URL kept in the table.
Secondly, JSON is a light weight data interchange format. You should limit the number of items it carries. Its advisable not to let it carry up to a hundred rows in your table(when converting to JSON). If you have to, then load a little at first, then load another little, till it gets to the end. That's the idea behind infinite scrolling.
That way, it loads your data efficiently.


The right to vote and voting patterns of hospitalized psychiatric patients.
Hospitalized psychiatric patients have traditionally been denied their right to vote. This right was restored in 1972 when the Queens Board of Elections established a registration and polling site on the Creedmore Hospital grounds. A patient education program stimulated interest in current affairs and facilitated informed voting. Gross analysis of patient-voting patterns showed no significant difference from the community at large. However, deeper analysis suggests that the patient vote was independent of the borough of residence, tending to be more Democratic-Liberal and less Republican-Conservative. Furthermore, the patient vote was seen to reflect thoughfulness and awareness of relevant self-interest.


Leicht enttäuschend.--++--As a holliday resort it looked promising from above. But the ocean was disturbingly white.The blue went on strike, we was told by the guide.And we thought it was some weired physical effect or chemical trick to entertain us.

Er beschloß, zu üben, stolz auf sie zu sein.--++--Oh, time flies. Everytime he looked at the photo, he thought that. And that it was a mistake to allow the press to use the flash at the ceremony. It makes is all seem wrong, missplaced, overdone, made up and a lot of other not so nice adjectives. But being famous is trading freedom for being remembered. Which is fair because both fade.Still.The ugly pictures are the remaining ones.

He decided to practice being proud of them.------------------------------Wenig wurde hinzugefügt. Die Bretter bekammen eine Schicht Sienabraun um sie hölzerner erscheinen zu lassen und die Kanten etwas heller.Also.Das Photo wurde (dummerweise) mit Blitz gemacht. Also sind die Lichtverhältnisse auf dem Metall total anders. Der Blickwinkel ist tiefer (scheinbar sitze ich meim Malen aufrechter..).Die Briefumschläge sind größer und dichter am Kelch. Tja, und die Farben sind komplett anders.Wie ich am Anfang sagte, das Photo ist eine Skizze. Während des Malens des Bildes habe ich vielleicht ein oder zweimal darauf geschaut, nicht öfter. Also sind alle Änderungen Ergebnis von Beobachtung (Licht auf dem Metall, Blickwinkel)oder von Kompositionsentscheidungen (Abstand zwischen den Dingen, Änderung des Tons und der Intensität der Farbe).Die Entscheidung ist daher immer: Bei der Beobachtung bleiben, oder ändern, um genauer von der Beobachtung zu erzählen. Da gibt es keine generelle Lösung. Man muß jedes mal neu entscheiden. Aber man MUSS entscheiden! Andernfalls gibt es keinen Fortschritt. Weil man nur durch Entscheidungen Fehler machen kann. Und nur die bringen einen weiter.--++--Very little has been added. The bars got a layer of siena brown to look more wooden and to make the edges lighter.Now.The photo has (stupidly) been made with a flash. So the light on the metal is completely different. The point of view is lower (seems I sit more upright while painting...). The envelopes are bigger and closer to the cup. Well, and the colours are completely different.As I said in the beginning, the photo is a sketch. During the painting of the picture I looked at it once or twice at all, not more often. So all the changes are due to direct observation (light on metal, point of view) or due to compositional decisions (distance between things, change of tone and intensity of colours).So the decision is always: Stick to the observation or change to tell about the observation more precisely. And there is no general solution. You have to decide time and time again. But DO decide! Otherwise you can't improve. Because decision is the only way to make mistakes. And only they make you improve.

Everything looked so energetic, so great, so optimistic, so on the internet, so self-assured, so completely on cocaine, that he immetiately regretted to even have waken up. Why can`t things just be. Why have they always to be so exuberant.A grey life. Just for one day.------------------------------Zuallererst Titanweiß für den Hintergrund (der war zu grau und schattig) sowie für das Regal. Mit einem kleinen Pinsel, so das der Umriss der Bretter genauer wird. Grüne Erde für die Umschläge und Igrazinrot für das Magazin und den großen Umschlag. Schwarz unter dem Regal am unteren Rand des Bildes.Dann: Wieder Schatten. Mit Lampschwarz auf dem Kelch, zwischen den Brettern und um das Magazin und die Umschläge. Des Fuß des Kelches sit asymmetrisch geworden. Wird das nächste mal verbessert.Indischgelb auf dem ganzen Kelch und den Umschlägen. Es erstaunt mich immer wieder, wie dieses Pigment ales zum Glühen bringen kann. Jeder, der an Farbew nteressiert ist, sollte dieses Pigment zumindest mal getestet haben !! (Jeder, der es tut, beschreibe bitte seine Ergebnisse in den Kommentaren!)--++--First of all titanium white for the background (it was too grey and to shady) as well as for the board. With a small brush, so the outline of the bars get more precise. Green earth for the envelopes and igrazine red for the magazine and the big envelope. Black below the board on the lower edge of the picture.Then: Shadows again. With lamp black on the cup, between the wooden bars and around the magazine and the envelopes. The lower part of the cup (what is the english word for that? foot?) went asymmetric. Will be corrected next time.Indian yellow all over the cup and the envelopes. It amazes me time and time again, how this pigment can make everything just glow. Anyone who is interested in colour, should at least try this pigment!! (Anyone who does, please describe the results in the comments!)

Aber du hast recht, ich hätte das fragen sollen.--++--I just like to stress, that I didn't drink it. In fact, it was an alien that materialized here, drank it and dissapeared. It was pink. The alien, that is.

No, I didn't ask it's name.Visa? I guess it had one. I don't know.

But your're right, I should've asked that.------------------------------Titanweiß als Grundierung, und eine Bleistiftzeichnung darauf. Ich werde das nicht nach dem Photo malen. Das Ding ist genau vor meinem Arbeitstisch im Atelier. Mir gefielen die Farben. Mal sehen, wie weit wir kommen...Man bemerke bitte, das die Form des Kelches nicht richtig ist, und die braunen Briefumschläge eine andere Form haben und vom Photo abgeschnitten werden. Aber da ich nicht nach dem Photo malen werde muss man sehen, was und wie das verändert werden wird.--++--Titanium white as gesso, and a pencil drawing on it. I am not going to paint this picture using the photo. That thing is right in front of me at my studios desk. I liked the colours. Lets see how far we can get...Note that the shape of the cup is not drawn correctly and those brown envelopes have a different shape and are cut by the photos edge. But since I won't paint after the photo it remains to be seen, what and how this will be altered.

Als Schlüsselsymbol für die Begrenztheit der Lebenszeit in Vanitas Stilleben.--++--Being a key-symbol for the limited time of life, used in vanitas-still -life painting - he thought - is just not appreciating his abilities.He felt highly underestimated, tragically burning down:

Being a key-symbol for the limited time of life, used in vanitas-still -life painting.------------------------------Ultramarin im Hintergrund. Das gibt dem dunklen Milori ein Glühen, das hilfreich ist, wie ich finde. Hinzugefügt wurde ein helles Grün (Permanentgelb und Ultramarin) auf dem Wachs um das Leuchten der Kerze zu zeigen. Die Flamme ist viel heller (als einzige Lichtquelle hat man gewisse Verpflichtungen...).Nächstes Mal was anderes.--++--Ultramarine over the background. It gives this dark milori a glow, that helps, I think. Added is a light green (permanent yellow and very little ultramarine) on the wax to show the glowing of the candlestick. The flame is much lighter ( being the only light source has some obligations...).Next time something else.

2007-04-10

Since a few days I my back behaves in a way, that I am really proud, when I manage to get out of bed within 10 minutes. It makes you humble, walking around like a question mark. Consequently, painting is slow right now.

Well.

It's not really walking.

Anyway, this is the reason for not posting. I have a picture almost ready. Maybe tomorrow.

Kommentare willkommen!--++--And now for something completely different.The panel is "gessoed" with 1:1 Turpentine and Linseedvarnish (Halböl in geman, half-oil). And no pigments. Rose madder and zinc white is used to paint here.So.What is this?Technically speaking, these are some traces of brush strokes. They are organized in a north-east-south-west kind of composition. The paint is thin, almost like watercolour.This is actually, what it IS.But what does it mean, signify or symbolize? For example, magnolia flower-leaves, or well what else? Or in general: Where is the boundary for interpretation?My answer so far: The boundary is in the imagination and knowledge of the viewer, limited and driven by the intention to understand or misunderstand.

Also nächstes Mal eine Schicht Zinkweiß und einige Korrekturen.--++--Now that looks seriously ill. The reason is, that the colours are too dark and the grey freckles still shine through, more than wished.So.After the usual skin tone with green earth as shadow colour and ocher and zinc white for the freckles it simply shows, that the whole thing is too dark and "colourful".

Das große Problem wird sein, den Eindruck einer Hautkrankheit zu vermeiden. Wir werden sehen. Nächstes mal Farbe.--++--All is kept black and white as long as possible. One problem less so to speak.Things to observe:Where are freckles big and where are they small.Where are they dark, where are thy light.Beeing almost circles, note that the view on the freckles almost always is from an angle making them ovals, varying from fat to slim.Where is the concentration of freckles high, where low.

The big problem will be, to avoid the impression of a skin disease. We will see. Next time colour.

Außer der rechte Teil des Schwarz vielleicht.--++--Pale and grey it seemed to him. Life in general. But that, dear reader was a classical projection. He was pale and grey and nothing else.

Except for the right part of the black, perhaps.------------------------------Zinkweiß ist dein Freund. Die eher expressionistischen Farben (außer der Nasenlöcher und der Lippen) sind durch eine dünne Schicht dieses großartigen Pigments gedämpft. Und der flächige Hintergrund ist jetzt erleuchtet und geräumig.--++--Zinc white is your friend. The rather expressionistic colours are dimmed a bit (except for the nostrils and the lips) by a thin layer of that great pigment. And the flat background is now enlightened and spacious.