<commit_before>// Copyright (c) 2003 Daniel Wallin and Arvid Norberg

// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
// OR OTHER DEALINGS IN THE SOFTWARE.

#ifndef LUABIND_OBJECT_REP_HPP_INCLUDED
#define LUABIND_OBJECT_REP_HPP_INCLUDED

#include <boost/aligned_storage.hpp>
#include <luabind/config.hpp>
#include <luabind/detail/class_rep.hpp>
#include <luabind/detail/instance_holder.hpp>
#include <luabind/detail/ref.hpp>

namespace luabind { namespace detail
{
	void finalize(lua_State* L, class_rep* crep);

	// this class is allocated inside lua for each pointer.
	// it contains the actual c++ object-pointer.
	// it also tells if it is const or not.
	class LUABIND_API object_rep
	{
	public:
		object_rep(instance_holder* instance, class_rep* crep);
		~object_rep();

		const class_rep* crep() const { return m_classrep; }
		class_rep* crep() { return m_classrep; }

		void set_instance(instance_holder* instance) { m_instance = instance; }

		void add_dependency(lua_State* L, int index);
        void release_dependency_refs(lua_State* L);

		std::pair<void*, int> get_instance(class_id target) const
		{
			if (m_instance == 0)
				return std::pair<void*, int>((void*)0, -1);
			return m_instance->get(m_classrep->casts(), target);
		}

		bool is_const() const
		{
			return m_instance && m_instance->pointee_const();
		}

        void release()
        {
            if (m_instance)
                m_instance->release();
        }

		void* allocate(std::size_t size)
		{
			if (size <= 32)
				return &m_instance_buffer;
			return std::malloc(size);
		}

		void deallocate(void* storage)
		{
			if (storage == &m_instance_buffer)
				return;
			std::free(storage);
		}

	private:

	object_rep(object_rep const&)
	{}

	void operator=(object_rep const&)
	{}

        instance_holder* m_instance;
        boost::aligned_storage<32> m_instance_buffer;
		class_rep* m_classrep; // the class information about this object's type
        std::size_t m_dependency_cnt; // counts dependencies
	};

	template<class T>
	struct delete_s
	{
		static void apply(void* ptr)
		{
			delete static_cast<T*>(ptr);
		}
	};

	template<class T>
	struct destruct_only_s
	{
		static void apply(void* ptr)
		{
			// Removes unreferenced formal parameter warning on VC7.
			(void)ptr;
#ifndef NDEBUG
			int completeness_check[sizeof(T)];
			(void)completeness_check;
#endif
			static_cast<T*>(ptr)->~T();
		}
	};

    LUABIND_API object_rep* get_instance(lua_State* L, int index);
    LUABIND_API void push_instance_metatable(lua_State* L);
    LUABIND_API object_rep* push_new_instance(lua_State* L, class_rep* cls);

}}

#endif // LUABIND_OBJECT_REP_HPP_INCLUDED

<commit_msg>OS X 10.9 compile fix<commit_after>// Copyright (c) 2003 Daniel Wallin and Arvid Norberg

// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
// ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
// TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
// SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
// OR OTHER DEALINGS IN THE SOFTWARE.

#ifndef LUABIND_OBJECT_REP_HPP_INCLUDED
#define LUABIND_OBJECT_REP_HPP_INCLUDED

#include <cstdlib>

#include <boost/aligned_storage.hpp>
#include <luabind/config.hpp>
#include <luabind/detail/class_rep.hpp>
#include <luabind/detail/instance_holder.hpp>
#include <luabind/detail/ref.hpp>

namespace luabind { namespace detail
{
	void finalize(lua_State* L, class_rep* crep);

	// this class is allocated inside lua for each pointer.
	// it contains the actual c++ object-pointer.
	// it also tells if it is const or not.
	class LUABIND_API object_rep
	{
	public:
		object_rep(instance_holder* instance, class_rep* crep);
		~object_rep();

		const class_rep* crep() const { return m_classrep; }
		class_rep* crep() { return m_classrep; }

		void set_instance(instance_holder* instance) { m_instance = instance; }

		void add_dependency(lua_State* L, int index);
        void release_dependency_refs(lua_State* L);

		std::pair<void*, int> get_instance(class_id target) const
		{
			if (m_instance == 0)
				return std::pair<void*, int>((void*)0, -1);
			return m_instance->get(m_classrep->casts(), target);
		}

		bool is_const() const
		{
			return m_instance && m_instance->pointee_const();
		}

        void release()
        {
            if (m_instance)
                m_instance->release();
        }

		void* allocate(std::size_t size)
		{
			if (size <= 32)
				return &m_instance_buffer;
			return std::malloc(size);
		}

		void deallocate(void* storage)
		{
			if (storage == &m_instance_buffer)
				return;
			std::free(storage);
		}

	private:

	object_rep(object_rep const&)
	{}

	void operator=(object_rep const&)
	{}

        instance_holder* m_instance;
        boost::aligned_storage<32> m_instance_buffer;
		class_rep* m_classrep; // the class information about this object's type
        std::size_t m_dependency_cnt; // counts dependencies
	};

	template<class T>
	struct delete_s
	{
		static void apply(void* ptr)
		{
			delete static_cast<T*>(ptr);
		}
	};

	template<class T>
	struct destruct_only_s
	{
		static void apply(void* ptr)
		{
			// Removes unreferenced formal parameter warning on VC7.
			(void)ptr;
#ifndef NDEBUG
			int completeness_check[sizeof(T)];
			(void)completeness_check;
#endif
			static_cast<T*>(ptr)->~T();
		}
	};

    LUABIND_API object_rep* get_instance(lua_State* L, int index);
    LUABIND_API void push_instance_metatable(lua_State* L);
    LUABIND_API object_rep* push_new_instance(lua_State* L, class_rep* cls);

}}

#endif // LUABIND_OBJECT_REP_HPP_INCLUDED

<|endoftext|>


<commit_before>#include "test.hpp"
#include "setup_transfer.hpp"
#include "libtorrent/socket.hpp"
#include "libtorrent/io.hpp"
#include <cstring>
#include <asio/read.hpp>
#include <asio/write.hpp>
#include <boost/bind.hpp>

using namespace libtorrent;

int read_message(stream_socket& s, char* buffer)
{
	using namespace libtorrent::detail;
	asio::error_code ec;
	asio::read(s, asio::buffer(buffer, 4), asio::transfer_all(), ec);
	TEST_CHECK(!ec);
	char* ptr = buffer;
	int length = read_int32(ptr);

	asio::read(s, asio::buffer(buffer, length), asio::transfer_all(), ec);
	TEST_CHECK(!ec);
	return length;
}

char const* message_name[] = {"choke", "unchoke", "interested", "not_interested"
	, "have", "bitfield", "request", "piece", "cancel", "dht_port", "", "", ""
	, "suggest_piece", "have_all", "have_none", "reject_request", "allowed_fast"};

void send_allow_fast(stream_socket& s, int piece)
{
	using namespace libtorrent::detail;
	char msg[] = "\0\0\0\x05\x11\0\0\0\0";
	char* ptr = msg + 5;
	write_int32(piece, ptr);
	asio::error_code ec;
	asio::write(s, asio::buffer(msg, 9), asio::transfer_all(), ec);
	TEST_CHECK(!ec);
}

void send_suggest_piece(stream_socket& s, int piece)
{
	using namespace libtorrent::detail;
	char msg[] = "\0\0\0\x05\x0d\0\0\0\0";
	char* ptr = msg + 5;
	write_int32(piece, ptr);
	asio::error_code ec;
	asio::write(s, asio::buffer(msg, 9), asio::transfer_all(), ec);
	TEST_CHECK(!ec);
}

void send_unchoke(stream_socket& s)
{
	char msg[] = "\0\0\0\x01\x01";
	asio::error_code ec;
	asio::write(s, asio::buffer(msg, 5), asio::transfer_all(), ec);
	TEST_CHECK(!ec);
}

void do_handshake(stream_socket& s, sha1_hash const& ih, char* buffer)
{
	char handshake[] = "\x13" "BitTorrent protocol\0\0\0\0\0\0\0\x04"
		"                    " // space for info-hash
		"aaaaaaaaaaaaaaaaaaaa" // peer-id
		"\0\0\0\x01\x0e"; // have_all
	asio::error_code ec;
	std::memcpy(handshake + 28, ih.begin(), 20);
	asio::write(s, asio::buffer(handshake, sizeof(handshake) - 1), asio::transfer_all(), ec);
	TEST_CHECK(!ec);

	// read handshake
	asio::read(s, asio::buffer(buffer, 68), asio::transfer_all(), ec);
	TEST_CHECK(!ec);

	TEST_CHECK(buffer[0] == 19);
	TEST_CHECK(std::memcmp(buffer + 1, "BitTorrent protocol", 19) == 0);

	char* extensions = buffer + 20;
	// check for fast extension support
	TEST_CHECK(extensions[7] & 0x4);

#ifndef TORRENT_DISABLE_EXTENSIONS
	// check for extension protocol support
	TEST_CHECK(extensions[5] & 0x10);
#endif

#ifndef TORRENT_DISABLE_DHT
	// check for DHT support
	TEST_CHECK(extensions[7] & 0x1);
#endif

	TEST_CHECK(std::memcmp(buffer + 28, ih.begin(), 20) == 0);
}

// makes sure that pieces that are allowed and then
// rejected aren't requested again
void test_reject_fast()
{
	boost::intrusive_ptr<torrent_info> t = create_torrent();
	sha1_hash ih = t->info_hash();
	session ses1(fingerprint("LT", 0, 1, 0, 0), std::make_pair(48900, 49000));
	ses1.add_torrent(t, "./tmp1");

	test_sleep(2000);

	io_service ios;
	stream_socket s(ios);
	s.connect(tcp::endpoint(address::from_string("127.0.0.1"), ses1.listen_port()));

	char recv_buffer[1000];
	do_handshake(s, ih, recv_buffer);

	std::vector<int> allowed_fast;
	allowed_fast.push_back(0);
	allowed_fast.push_back(1);
	allowed_fast.push_back(2);
	allowed_fast.push_back(3);

	std::for_each(allowed_fast.begin(), allowed_fast.end()
		, bind(&send_allow_fast, boost::ref(s), _1));

	while (!allowed_fast.empty())
	{
		read_message(s, recv_buffer);
		int msg = recv_buffer[0];
		if (msg >= 0 && msg < int(sizeof(message_name)/sizeof(message_name[0])))
			std::cerr << message_name[msg] << std::endl;
		else
			std::cerr << msg << std::endl;
		if (recv_buffer[0] != 0x6) continue;

		using namespace libtorrent::detail;
		char* ptr = recv_buffer + 1;
		int piece = read_int32(ptr);

		std::vector<int>::iterator i = std::find(allowed_fast.begin()
			, allowed_fast.end(), piece);
		TEST_CHECK(i != allowed_fast.end());
		if (i != allowed_fast.end())
			allowed_fast.erase(i);
		// send reject request
		recv_buffer[0] = 0x10;
		asio::error_code ec;
		asio::write(s, asio::buffer("\0\0\0\x0d", 4), asio::transfer_all(), ec);
		TEST_CHECK(!ec);
		asio::write(s, asio::buffer(recv_buffer, 13), asio::transfer_all(), ec);
		TEST_CHECK(!ec);
	}
}

void test_respect_suggest()
{
	boost::intrusive_ptr<torrent_info> t = create_torrent();
	sha1_hash ih = t->info_hash();
	session ses1(fingerprint("LT", 0, 1, 0, 0), std::make_pair(48900, 49000));
	ses1.add_torrent(t, "./tmp1");

	test_sleep(2000);

	io_service ios;
	stream_socket s(ios);
	s.connect(tcp::endpoint(address::from_string("127.0.0.1"), ses1.listen_port()));

	char recv_buffer[1000];
	do_handshake(s, ih, recv_buffer);

	std::vector<int> suggested;
	suggested.push_back(0);
	suggested.push_back(1);
	suggested.push_back(2);
	suggested.push_back(3);

	std::for_each(suggested.begin(), suggested.end()
		, bind(&send_suggest_piece, boost::ref(s), _1));

	send_unchoke(s);

	int fail_counter = 100;
	while (!suggested.empty() && fail_counter > 0)
	{
		read_message(s, recv_buffer);
		std::cerr << "msg: ";
		int msg = recv_buffer[0];
		if (msg >= 0 && msg < int(sizeof(message_name)/sizeof(message_name[0])))
			std::cerr << message_name[msg] << std::endl;
		else
			std::cerr << msg << std::endl;
		fail_counter--;
		if (recv_buffer[0] != 0x6) continue;

		using namespace libtorrent::detail;
		char* ptr = recv_buffer + 1;
		int piece = read_int32(ptr);

		std::vector<int>::iterator i = std::find(suggested.begin()
			, suggested.end(), piece);
		TEST_CHECK(i != suggested.end());
		if (i != suggested.end())
			suggested.erase(i);
		// send reject request
		recv_buffer[0] = 0x10;
		asio::error_code ec;
		asio::write(s, asio::buffer("\0\0\0\x0d", 4), asio::transfer_all(), ec);
		TEST_CHECK(!ec);
		asio::write(s, asio::buffer(recv_buffer, 13), asio::transfer_all(), ec);
		TEST_CHECK(!ec);
	}
	TEST_CHECK(fail_counter > 0);
}

int test_main()
{
	test_reject_fast();
	test_respect_suggest();
	return 0;
}

<commit_msg>more verbose logging in test_fast_extension and avoids infinite loops in case of failures<commit_after>#include "test.hpp"
#include "setup_transfer.hpp"
#include "libtorrent/socket.hpp"
#include "libtorrent/io.hpp"
#include <cstring>
#include <asio/read.hpp>
#include <asio/write.hpp>
#include <boost/bind.hpp>

using namespace libtorrent;

int read_message(stream_socket& s, char* buffer)
{
	using namespace libtorrent::detail;
	asio::error_code ec;
	asio::read(s, asio::buffer(buffer, 4), asio::transfer_all(), ec);
	if (ec)
	{
		std::cout << ec.message() << std::endl;
		exit(1);
	}
	char* ptr = buffer;
	int length = read_int32(ptr);

	asio::read(s, asio::buffer(buffer, length), asio::transfer_all(), ec);
	if (ec)
	{
		std::cout << ec.message() << std::endl;
		exit(1);
	}
	return length;
}

char const* message_name[] = {"choke", "unchoke", "interested", "not_interested"
	, "have", "bitfield", "request", "piece", "cancel", "dht_port", "", "", ""
	, "suggest_piece", "have_all", "have_none", "reject_request", "allowed_fast"};

void send_allow_fast(stream_socket& s, int piece)
{
	std::cout << "send allow fast: " << piece << std::endl;
	using namespace libtorrent::detail;
	char msg[] = "\0\0\0\x05\x11\0\0\0\0";
	char* ptr = msg + 5;
	write_int32(piece, ptr);
	asio::error_code ec;
	asio::write(s, asio::buffer(msg, 9), asio::transfer_all(), ec);
	if (ec)
	{
		std::cout << ec.message() << std::endl;
		exit(1);
	}
}

void send_suggest_piece(stream_socket& s, int piece)
{
	std::cout << "send suggest piece: " << piece << std::endl;
	using namespace libtorrent::detail;
	char msg[] = "\0\0\0\x05\x0d\0\0\0\0";
	char* ptr = msg + 5;
	write_int32(piece, ptr);
	asio::error_code ec;
	asio::write(s, asio::buffer(msg, 9), asio::transfer_all(), ec);
	if (ec)
	{
		std::cout << ec.message() << std::endl;
		exit(1);
	}
}

void send_unchoke(stream_socket& s)
{
	std::cout << "send unchoke" << std::endl;
	char msg[] = "\0\0\0\x01\x01";
	asio::error_code ec;
	asio::write(s, asio::buffer(msg, 5), asio::transfer_all(), ec);
	if (ec)
	{
		std::cout << ec.message() << std::endl;
		exit(1);
	}
}

void do_handshake(stream_socket& s, sha1_hash const& ih, char* buffer)
{
	char handshake[] = "\x13" "BitTorrent protocol\0\0\0\0\0\0\0\x04"
		"                    " // space for info-hash
		"aaaaaaaaaaaaaaaaaaaa" // peer-id
		"\0\0\0\x01\x0e"; // have_all
	std::cout << "send handshake" << std::endl;
	asio::error_code ec;
	std::memcpy(handshake + 28, ih.begin(), 20);
	asio::write(s, asio::buffer(handshake, sizeof(handshake) - 1), asio::transfer_all(), ec);
	if (ec)
	{
		std::cout << ec.message() << std::endl;
		exit(1);
	}

	// read handshake
	asio::read(s, asio::buffer(buffer, 68), asio::transfer_all(), ec);
	if (ec)
	{
		std::cout << ec.message() << std::endl;
		exit(1);
	}
	std::cout << "received handshake" << std::endl;

	TEST_CHECK(buffer[0] == 19);
	TEST_CHECK(std::memcmp(buffer + 1, "BitTorrent protocol", 19) == 0);

	char* extensions = buffer + 20;
	// check for fast extension support
	TEST_CHECK(extensions[7] & 0x4);

#ifndef TORRENT_DISABLE_EXTENSIONS
	// check for extension protocol support
	TEST_CHECK(extensions[5] & 0x10);
#endif

#ifndef TORRENT_DISABLE_DHT
	// check for DHT support
	TEST_CHECK(extensions[7] & 0x1);
#endif

	TEST_CHECK(std::memcmp(buffer + 28, ih.begin(), 20) == 0);
}

// makes sure that pieces that are allowed and then
// rejected aren't requested again
void test_reject_fast()
{
	boost::intrusive_ptr<torrent_info> t = create_torrent();
	sha1_hash ih = t->info_hash();
	session ses1(fingerprint("LT", 0, 1, 0, 0), std::make_pair(48900, 49000));
	ses1.add_torrent(t, "./tmp1");

	test_sleep(1000000);

	io_service ios;
	stream_socket s(ios);
	s.connect(tcp::endpoint(address::from_string("127.0.0.1"), ses1.listen_port()));

	char recv_buffer[1000];
	do_handshake(s, ih, recv_buffer);

	std::vector<int> allowed_fast;
	allowed_fast.push_back(0);
	allowed_fast.push_back(1);
	allowed_fast.push_back(2);
	allowed_fast.push_back(3);

	std::for_each(allowed_fast.begin(), allowed_fast.end()
		, bind(&send_allow_fast, boost::ref(s), _1));

	while (!allowed_fast.empty())
	{
		read_message(s, recv_buffer);
		int msg = recv_buffer[0];
		if (msg >= 0 && msg < int(sizeof(message_name)/sizeof(message_name[0])))
			std::cerr << message_name[msg] << std::endl;
		else
			std::cerr << msg << std::endl;
		if (recv_buffer[0] != 0x6) continue;

		using namespace libtorrent::detail;
		char* ptr = recv_buffer + 1;
		int piece = read_int32(ptr);

		std::vector<int>::iterator i = std::find(allowed_fast.begin()
			, allowed_fast.end(), piece);
		TEST_CHECK(i != allowed_fast.end());
		if (i != allowed_fast.end())
			allowed_fast.erase(i);
		// send reject request
		recv_buffer[0] = 0x10;
		asio::error_code ec;
		asio::write(s, asio::buffer("\0\0\0\x0d", 4), asio::transfer_all(), ec);
		if (ec)
		{
			std::cout << ec.message() << std::endl;
			exit(1);
		}
		asio::write(s, asio::buffer(recv_buffer, 13), asio::transfer_all(), ec);
		std::cout << ec.message() << std::endl;
		if (ec)
		{
			std::cout << ec.message() << std::endl;
			exit(1);
		}
	}
}

void test_respect_suggest()
{
	boost::intrusive_ptr<torrent_info> t = create_torrent();
	sha1_hash ih = t->info_hash();
	session ses1(fingerprint("LT", 0, 1, 0, 0), std::make_pair(48900, 49000));
	ses1.add_torrent(t, "./tmp1");

	test_sleep(2000);

	io_service ios;
	stream_socket s(ios);
	s.connect(tcp::endpoint(address::from_string("127.0.0.1"), ses1.listen_port()));

	char recv_buffer[1000];
	do_handshake(s, ih, recv_buffer);

	std::vector<int> suggested;
	suggested.push_back(0);
	suggested.push_back(1);
	suggested.push_back(2);
	suggested.push_back(3);

	std::for_each(suggested.begin(), suggested.end()
		, bind(&send_suggest_piece, boost::ref(s), _1));

	send_unchoke(s);

	int fail_counter = 100;
	while (!suggested.empty() && fail_counter > 0)
	{
		read_message(s, recv_buffer);
		std::cerr << "msg: ";
		int msg = recv_buffer[0];
		if (msg >= 0 && msg < int(sizeof(message_name)/sizeof(message_name[0])))
			std::cerr << message_name[msg] << std::endl;
		else
			std::cerr << msg << std::endl;
		fail_counter--;
		if (recv_buffer[0] != 0x6) continue;

		using namespace libtorrent::detail;
		char* ptr = recv_buffer + 1;
		int piece = read_int32(ptr);

		std::vector<int>::iterator i = std::find(suggested.begin()
			, suggested.end(), piece);
		TEST_CHECK(i != suggested.end());
		if (i != suggested.end())
			suggested.erase(i);
		// send reject request
		recv_buffer[0] = 0x10;
		asio::error_code ec;
		asio::write(s, asio::buffer("\0\0\0\x0d", 4), asio::transfer_all(), ec);
		if (ec)
		{
			std::cout << ec.message() << std::endl;
			exit(1);
		}
		asio::write(s, asio::buffer(recv_buffer, 13), asio::transfer_all(), ec);
		if (ec)
		{
			std::cout << ec.message() << std::endl;
			exit(1);
		}
	}
	TEST_CHECK(fail_counter > 0);
}

int test_main()
{
	test_reject_fast();
	test_respect_suggest();
	return 0;
}

<|endoftext|>


<commit_before>/*=========================================================================

 Program:   ORFEO Toolbox
 Language:  C++
 Date:      $Date$
 Version:   $Revision$

 Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
 See OTBCopyright.txt for details.

 This software is distributed WITHOUT ANY WARRANTY; without even
 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 PURPOSE.  See the above copyright notices for more information.

 =========================================================================*/
#include "otbWrapperApplication.h"
#include "otbWrapperApplicationFactory.h"

#include "otbObjectList.h"

#include "otbBandMathImageFilterX.h"

namespace otb
{

namespace Wrapper
{

class BandMathX : public Application
{

public:
  /** Standard class typedefs. */
  typedef BandMathX                      Self;
  typedef Application                    Superclass;
  typedef itk::SmartPointer<Self>        Pointer;
  typedef itk::SmartPointer<const Self> ConstPointer;

  /** Standard macro */
  itkNewMacro(Self);

  itkTypeMacro(BandMathX, otb::Application);

  typedef otb::BandMathImageFilterX<FloatVectorImageType>                             BandMathImageFilterType;

private:
  void DoInit()
  {
    SetName("BandMathX");
    SetDescription("This application performs mathematical operations on multiband images.\n"
      "Mathematical formula interpretation is done via muParserX libraries https://code.google.com/p/muparserx/");

    SetDocName("Band Math X");
    SetDocLongDescription("The goal of this documentation is to give the user some hints about the syntax used in this application.\n"
      "The syntax is mainly constrained by the muparserx library, which can be considered as the core of the application.\n"
      "\n\n"
      "- Fundamentals:\n\n"
      "The default prefix name for variables related to the ith input is « im(i+1) » (note the indexing from 1 to N, for N inputs). \n"
      "The following list summaries the available variables for input #0 (and so on for every input): \n"
      "\n"
      "im1                  -->   a pixel from first input, made of n components (n bands)\n"
      "im1bj                -->   jth component of a pixel from first input (first band is indexed by 1)\n"
      "im1bjNkxp            -->   a neighbourhood (“N”) of pixels of the jth component from first input, of size kxp\n"
      "im1PhyX and im1PhyY  --> spacing of first input in X and Y directions (horizontal and vertical)\n"
      "\nMoreover, we also have the following generic variables:\n"
      "idxX and idxY        -->   indices of the current pixel\n"
      "\n"
      "Always keep in mind that this application only addresses mathematically well-defined formulas.\n"
      "For instance, it is not possible to add vectors of different dimensions (this implies the addition of a row vector with a column vector),\n"
      "or add a scalar to a vector or a matrix, or divide two vectors, and so on...\n"
      "Thus, it is important to remember that a pixel of n components is always represented as a row vector.\n"
      "\n"
      "Example :\n\n"
      "                   im1 + im2 \n"
      "\nrepresents the addition of pixels from first and second inputs. This expression is consistent only if\n"
      "both inputs have the same number of bands.\n"
      "Note that it is also possible to use the following expressions to obtain the same result:\n"
      "\n"
      "                   im1b1 + im2b1 \n"
      "                   im1b2 + im2b2 \n"
      "                         ...."
      "\n\nNevertheless, the first expression is by far much pleaseant. We call this new functionnality the 'batch mode'\n"
      "(performing the same operation in a band-to-band fashion).\n"

      "\n\n"
      "- Operations involving neighborhoods of pixels:\n\n"
      "Another new fonctionnality is the possibility to perform operations that involve neighborhoods of pixels.\n"
      "Variable related to such neighborhoods are always defined following the pattern imIbJNKxP, where: \n"
      "- I is an number identifying the image input (rememeber, input #0 <=> im1, and so on)\n"
      "- J is an number identifying the band (remember, first band is indexed by 1)\n"
      "- KxP are two numbers that represent the size of the neighborhood (first one is related to the horizontal direction)\n"
      "All neighborhood are centred, thus K and P must be odd numbers.\n"
      "Many operators come with this new functionnality: conv, mean var median min max...\n"
      "For instance, if im1 represents the pixel of 3 bands image:\n\n"
      "               im1 - mean(im1b1N5x5,im1b2N5x5,im1b3N5x5)\n"
      "\ncould represent a high pass filter (Note that by implying three neighborhoods, the operator returned a row vector of three components.\n"
      "It is a typical behaviour for several operators of this application).\n"

      "\n\n"
      "- Operators:\n\n"
      "In addition to the previous operators, other operators are available:\n"
      "- existing operators/functions from muParserX, that were not originally defined for vectors and\n"
      "matrices (for instance cos, sin, ...). These new operators/ functions keep the original names to\n"
      "which we add the prefix ”v” for vector (vcos, vsin, ...).\n"
      "- mult and div operators, that perform element-wise multiplication or division of vector/matrices (for instance im1 div im2)\n"
      "- bands, which is a very usefull operator. It allows to select specific bands from an image, and/or to rearrange them in a new vector;\n"
      "for instance bands(im1,{1,2,1,1}) produces a vector of 4 components made of band 1, band 2, band 1 and band 1 values from the first input.\n"
      "Note that curly brackets must be used in order to select the desired band indices.\n"

      "\n\n"
      "- Application itself:\n\n"
      "Setting the list of inputs can be done with the 'il' parameter.\n"
      "Setting an expression can be done with the 'exp' parameter.\n"
      "Setting the output image can be done with the 'out' parameter.\n"
      "\n\n"
      "Finally, we strongly recommend that the reader takes a look at the cookbook, where additional information can be found.\n"

);

    SetDocLimitations("Only one output is possible (to be improved)");
    SetDocAuthors("OTB-Team");
    SetDocSeeAlso(" ");
    AddDocTag("Util");

    AddParameter(ParameterType_InputImageList,  "il",   "Input image list");
    SetParameterDescription("il", "Image list to perform computation on.");

    AddParameter(ParameterType_OutputImage, "out", "Output Image");
    SetParameterDescription("out","Output image.");

    AddRAMParameter();

    AddParameter(ParameterType_StringList, "exp", "Expression");
    SetParameterDescription("exp",
                            "The mathematical expression to apply.");
    MandatoryOff("exp");

    AddParameter(ParameterType_String, "incontext", "Import context");
    SetParameterDescription("incontext",
                            "A txt file containing user's constants and expressions.");
    MandatoryOff("incontext");

    AddParameter(ParameterType_String, "outcontext", "Export context");
    SetParameterDescription("outcontext",
                            "A txt file containing user's constants and expressions.");
    MandatoryOff("outcontext");

    // Doc example parameter settings
    SetDocExampleParameterValue("il", "verySmallFSATSW_r.tif verySmallFSATSW_nir.tif verySmallFSATSW.tif");
    SetDocExampleParameterValue("out", "apTvUtBandMathOutput.tif");
    SetDocExampleParameterValue("exp", "\"cos(im1b1)+im2b1*im3b1-im3b2+ndvi(im3b3, im3b4)\"");
  }

  void DoUpdateParameters()
  {

  }

  void DoExecute()
  {
    // Get the input image list
    FloatVectorImageListType::Pointer inList = GetParameterImageList("il");

    // checking the input images list validity
    const unsigned int nbImages = inList->Size();

    if (nbImages == 0)
    {
     itkExceptionMacro("No input Image set...; please set at least one input image");
    }

    if ( (!HasUserValue("exp")) && (!HasUserValue("incontext")) )
    {
     itkExceptionMacro("No expression set...; please set at least one one expression");
    }

    m_Filter               = BandMathImageFilterType::New();

    for (unsigned int i = 0; i < nbImages; i++)
      {
        FloatVectorImageType::Pointer currentImage = inList->GetNthElement(i);
        currentImage->UpdateOutputInformation();

        otbAppLogINFO( << "Image #" << i + 1 << " has "
                       << currentImage->GetNumberOfComponentsPerPixel()
                       << " components" << std::endl );

        m_Filter->SetNthInput(i,currentImage);

      }

    if ( (HasUserValue("exp")) && (IsParameterEnabled("exp")) )
    {
      std::vector<std::string> stringList = GetParameterStringList("exp");
      for(int s=0; s<stringList.size(); s++)
        m_Filter->SetExpression(stringList[s]);
    }

    if ( (HasUserValue("incontext")) && (IsParameterEnabled("incontext")) )
      m_Filter->importContext(GetParameterString("incontext"));

    // Set the output image
    SetParameterOutputImage("out", m_Filter->GetOutput());

    if ( (HasUserValue("outcontext")) && (IsParameterEnabled("outcontext")) )
      m_Filter->exportContext(GetParameterString("outcontext"));
  }

  BandMathImageFilterType::Pointer  m_Filter;
};

} // namespace Wrapper
} // namespace otb

OTB_APPLICATION_EXPORT(otb::Wrapper::BandMathX)

<commit_msg>BandMathX app: documentation improved<commit_after>/*=========================================================================

 Program:   ORFEO Toolbox
 Language:  C++
 Date:      $Date$
 Version:   $Revision$

 Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
 See OTBCopyright.txt for details.

 This software is distributed WITHOUT ANY WARRANTY; without even
 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 PURPOSE.  See the above copyright notices for more information.

 =========================================================================*/
#include "otbWrapperApplication.h"
#include "otbWrapperApplicationFactory.h"

#include "otbObjectList.h"

#include "otbBandMathImageFilterX.h"

namespace otb
{

namespace Wrapper
{

class BandMathX : public Application
{

public:
  /** Standard class typedefs. */
  typedef BandMathX                      Self;
  typedef Application                    Superclass;
  typedef itk::SmartPointer<Self>        Pointer;
  typedef itk::SmartPointer<const Self> ConstPointer;

  /** Standard macro */
  itkNewMacro(Self);

  itkTypeMacro(BandMathX, otb::Application);

  typedef otb::BandMathImageFilterX<FloatVectorImageType>                             BandMathImageFilterType;

private:
  void DoInit()
  {
    SetName("BandMathX");
    SetDescription("This application performs mathematical operations on multiband images.\n"
      "Mathematical formula interpretation is done via muParserX libraries https://code.google.com/p/muparserx/");

    SetDocName("Band Math X");
    SetDocLongDescription("The goal of this documentation is to give the user some hints about the syntax used in this application.\n"
      "The syntax is mainly constrained by the muparserx library, which can be considered as the core of the application.\n"
      "\n\n"
      "- Fundamentals:\n\n"
      "The default prefix name for variables related to the ith input is « im(i+1) » (note the indexing from 1 to N, for N inputs). \n"
      "The following list summaries the available variables for input #0 (and so on for every input): \n"
      "\n"
      "im1                  -->   a pixel from first input, made of n components (n bands)\n"
      "im1bj                -->   jth component of a pixel from first input (first band is indexed by 1)\n"
      "im1bjNkxp            -->   a neighbourhood (“N”) of pixels of the jth component from first input, of size kxp\n"
      "im1PhyX and im1PhyY  --> spacing of first input in X and Y directions (horizontal and vertical)\n"
      "\nMoreover, we also have the following generic variables:\n"
      "idxX and idxY        -->   indices of the current pixel\n"
      "\n"
      "Always keep in mind that this application only addresses mathematically well-defined formulas.\n"
      "For instance, it is not possible to add vectors of different dimensions (this implies the addition of a row vector with a column vector),\n"
      "or add a scalar to a vector or a matrix, or divide two vectors, and so on...\n"
      "Thus, it is important to remember that a pixel of n components is always represented as a row vector.\n"
      "\n"
      "Example :\n\n"
      "                   im1 + im2 \n"
      "\nrepresents the addition of pixels from first and second inputs. This expression is consistent only if\n"
      "both inputs have the same number of bands.\n"
      "Note that it is also possible to use the following expressions to obtain the same result:\n"
      "\n"
      "                   im1b1 + im2b1 \n"
      "                   im1b2 + im2b2 \n"
      "                         ...."
      "\n\nNevertheless, the first expression is by far much pleaseant. We call this new functionnality the 'batch mode'\n"
      "(performing the same operation in a band-to-band fashion).\n"

      "\n\n"
      "- Operations involving neighborhoods of pixels:\n\n"
      "Another new fonctionnality is the possibility to perform operations that involve neighborhoods of pixels.\n"
      "Variable related to such neighborhoods are always defined following the pattern imIbJNKxP, where: \n"
      "- I is an number identifying the image input (rememeber, input #0 <=> im1, and so on)\n"
      "- J is an number identifying the band (remember, first band is indexed by 1)\n"
      "- KxP are two numbers that represent the size of the neighborhood (first one is related to the horizontal direction)\n"
      "All neighborhood are centred, thus K and P must be odd numbers.\n"
      "Many operators come with this new functionnality: conv, mean var median min max...\n"
      "For instance, if im1 represents the pixel of 3 bands image:\n\n"
      "               im1 - mean(im1b1N5x5,im1b2N5x5,im1b3N5x5)\n"
      "\ncould represent a high pass filter (Note that by implying three neighborhoods, the operator returned a row vector of three components.\n"
      "It is a typical behaviour for several operators of this application).\n"

      "\n\n"
      "- Operators:\n\n"
      "In addition to the previous operators, other operators are available:\n"
      "- existing operators/functions from muParserX, that were not originally defined for vectors and\n"
      "matrices (for instance cos, sin, ...). These new operators/ functions keep the original names to\n"
      "which we add the prefix ”v” for vector (vcos, vsin, ...).\n"
      "- mult and div operators, that perform element-wise multiplication or division of vector/matrices (for instance im1 div im2)\n"
      "- bands, which is a very usefull operator. It allows to select specific bands from an image, and/or to rearrange them in a new vector;\n"
      "for instance bands(im1,{1,2,1,1}) produces a vector of 4 components made of band 1, band 2, band 1 and band 1 values from the first input.\n"
      "Note that curly brackets must be used in order to select the desired band indices.\n"

      "\n\n"
      "- Application itself:\n\n"
      "The application takes the following parameters :"
      "- Setting the list of inputs can be done with the 'il' parameter.\n"
      "- Setting expressions can be done with the 'exp' parameter. Separating expressions by semi-colons (;) will concatenate their results into one multiband output image.\n"
      "Adding expressions without the use of semi-colons will produce additional output images (not implemented yet).\n"
      "- Setting constants can be done with the 'incontext' parameter. User must provide a txt file with a specific syntax: #type name value\n"
      "An example of such a file is given below:\n\n"
      "#F expo 1.1\n"
      "#M kernel1 { 0.1 , 0.2 , 0.3 ; 0.4 , 0.5 , 0.6 ; 0.7 , 0.8 , 0.9 ; 1 , 1.1 , 1.2 ; 1.3 , 1.4 , 1.5 }\n"
      "\nAs we can see,  #I/#F allows the definition of an integer/float constant, whereas #M allows the definition of a vector/matrix.\n"
      "In the latter case, elements of a row must be separated by comma, and rows must be separated by semicolons.\n"
      "It is also possible to define expressions within the same txt file, with the pattern #E expr; they will be added to the list of expressions to be applied. For instance:\n\n"
      "#E conv(kernel1,im1b1N3x5) ; im2b1^expo\n"
      "\n- The 'outcontext' parameter allows to save user's constants and expressions (context).\n"
      "- Setting the output image can be done with the 'out' parameter (multi-outputs is not implemented yet).\n"
      "\n\n"
      "Finally, we strongly recommend that the reader takes a look at the cookbook, where additional information can be found (http://www.orfeo-toolbox.org/packages/OTBCookBook.pdf).\n"

);

    SetDocLimitations("Only one output is possible (to be improved)");
    SetDocAuthors("OTB-Team");
    SetDocSeeAlso(" ");
    AddDocTag("Util");

    AddParameter(ParameterType_InputImageList,  "il",   "Input image list");
    SetParameterDescription("il", "Image list to perform computation on.");

    AddParameter(ParameterType_OutputImage, "out", "Output Image");
    SetParameterDescription("out","Output image.");

    AddRAMParameter();

    AddParameter(ParameterType_StringList, "exp", "Expressions");
    SetParameterDescription("exp",
                            "Mathematical expressions to apply.");
    MandatoryOff("exp");

    AddParameter(ParameterType_String, "incontext", "Import context");
    SetParameterDescription("incontext",
                            "A txt file containing user's constants and expressions.");
    MandatoryOff("incontext");

    AddParameter(ParameterType_String, "outcontext", "Export context");
    SetParameterDescription("outcontext",
                            "A txt file where to save user's constants and expressions.");
    MandatoryOff("outcontext");

    // Doc example parameter settings
    SetDocExampleParameterValue("il", "verySmallFSATSW_r.tif verySmallFSATSW_nir.tif verySmallFSATSW.tif");
    SetDocExampleParameterValue("out", "apTvUtBandMathOutput.tif");
    SetDocExampleParameterValue("exp", "\"cos(im1b1)+im2b1*im3b1-im3b2+ndvi(im3b3, im3b4)\"");
  }

  void DoUpdateParameters()
  {

  }

  void DoExecute()
  {
    // Get the input image list
    FloatVectorImageListType::Pointer inList = GetParameterImageList("il");

    // checking the input images list validity
    const unsigned int nbImages = inList->Size();

    if (nbImages == 0)
    {
     itkExceptionMacro("No input Image set...; please set at least one input image");
    }

    if ( (!HasUserValue("exp")) && (!HasUserValue("incontext")) )
    {
     itkExceptionMacro("No expression set...; please set at least one one expression");
    }

    m_Filter               = BandMathImageFilterType::New();

    for (unsigned int i = 0; i < nbImages; i++)
      {
        FloatVectorImageType::Pointer currentImage = inList->GetNthElement(i);
        currentImage->UpdateOutputInformation();

        otbAppLogINFO( << "Image #" << i + 1 << " has "
                       << currentImage->GetNumberOfComponentsPerPixel()
                       << " components" << std::endl );

        m_Filter->SetNthInput(i,currentImage);

      }

    if ( (HasUserValue("exp")) && (IsParameterEnabled("exp")) )
    {
      std::vector<std::string> stringList = GetParameterStringList("exp");
      for(int s=0; s<stringList.size(); s++)
        m_Filter->SetExpression(stringList[s]);
    }

    if ( (HasUserValue("incontext")) && (IsParameterEnabled("incontext")) )
      m_Filter->importContext(GetParameterString("incontext"));

    // Set the output image
    SetParameterOutputImage("out", m_Filter->GetOutput());

    if ( (HasUserValue("outcontext")) && (IsParameterEnabled("outcontext")) )
      m_Filter->exportContext(GetParameterString("outcontext"));
  }

  BandMathImageFilterType::Pointer  m_Filter;
};

} // namespace Wrapper
} // namespace otb

OTB_APPLICATION_EXPORT(otb::Wrapper::BandMathX)

<|endoftext|>


<commit_before><commit_msg>ENH: handle cleaning of temporary files<commit_after><|endoftext|>


<commit_before>/*
 * #%L
 * %%
 * Copyright (C) 2011 - 2017 BMW Car IT GmbH
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include <chrono>

#include "joynr/JoynrClusterControllerRuntime.h"
#include "joynr/Settings.h"
#include "joynr/SystemServicesSettings.h"
#include "joynr/system/ProviderReregistrationControllerProxy.h"
#include "utils/TestLibJoynrWebSocketRuntime.h"

using namespace ::testing;
using namespace joynr;

TEST(ProviderReregistrationControllerTest, queryProviderReregistrationControllerSucceedsOnCCRuntime)
{
    auto integrationSettings = std::make_unique<Settings>("test-resources/MqttSystemIntegrationTest1.settings");
    joynr::SystemServicesSettings systemServiceSettings(*integrationSettings);
    const std::string domain(systemServiceSettings.getDomain());

    auto runtime = std::make_shared<JoynrClusterControllerRuntime>(std::move(integrationSettings));
    runtime->init();
    runtime->start();

    auto providerReregistrationControllerProxyBuilder = runtime->createProxyBuilder<joynr::system::ProviderReregistrationControllerProxy>(domain);
    auto providerReregistrationControllerProxy = providerReregistrationControllerProxyBuilder->build();

    Semaphore finishedSemaphore;
    providerReregistrationControllerProxy->triggerGlobalProviderReregistrationAsync([&finishedSemaphore]() { finishedSemaphore.notify(); }, nullptr);
    EXPECT_TRUE(finishedSemaphore.waitFor(std::chrono::seconds(10)));

    runtime->stop();
    runtime = nullptr;
}

TEST(ProviderReregistrationControllerTest, queryProviderReregistrationControllerSucceedsOnWsRuntime)
{
    auto integrationSettings = std::make_unique<Settings>("test-resources/MqttSystemIntegrationTest1.settings");
    joynr::SystemServicesSettings systemServiceSettings(*integrationSettings);
    const std::string domain(systemServiceSettings.getDomain());

    auto ccRuntime = std::make_shared<JoynrClusterControllerRuntime>(std::move(integrationSettings));
    ccRuntime->init();
    ccRuntime->start();

    auto wsRuntimeSettings = std::make_unique<Settings>("test-resources/libjoynrSystemIntegration1.settings");
    auto wsRuntime = std::make_shared<TestLibJoynrWebSocketRuntime>(std::move(wsRuntimeSettings), nullptr);
    ASSERT_TRUE(wsRuntime->connect(std::chrono::seconds(2)));

    auto providerReregistrationControllerProxyBuilder = wsRuntime->createProxyBuilder<joynr::system::ProviderReregistrationControllerProxy>(domain);
    auto providerReregistrationControllerProxy = providerReregistrationControllerProxyBuilder->build();

    Semaphore finishedSemaphore;
    providerReregistrationControllerProxy->triggerGlobalProviderReregistrationAsync([&finishedSemaphore]() { finishedSemaphore.notify(); }, [](const joynr::exceptions::JoynrRuntimeException&) { FAIL(); });
    EXPECT_TRUE(finishedSemaphore.waitFor(std::chrono::seconds(10)));

    wsRuntime = nullptr;
    ccRuntime->stop();
    ccRuntime = nullptr;
}
<commit_msg>[C++] Increase discovery timeouts in ProviderReregistrationControllerTest<commit_after>/*
 * #%L
 * %%
 * Copyright (C) 2011 - 2017 BMW Car IT GmbH
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include <chrono>

#include "joynr/JoynrClusterControllerRuntime.h"
#include "joynr/Settings.h"
#include "joynr/SystemServicesSettings.h"
#include "joynr/system/ProviderReregistrationControllerProxy.h"
#include "joynr/DiscoveryQos.h"
#include "utils/TestLibJoynrWebSocketRuntime.h"

using namespace ::testing;
using namespace joynr;

TEST(ProviderReregistrationControllerTest, queryProviderReregistrationControllerSucceedsOnCCRuntime)
{
    auto integrationSettings = std::make_unique<Settings>("test-resources/MqttSystemIntegrationTest1.settings");
    joynr::SystemServicesSettings systemServiceSettings(*integrationSettings);
    const std::string domain(systemServiceSettings.getDomain());

    auto runtime = std::make_shared<JoynrClusterControllerRuntime>(std::move(integrationSettings));
    runtime->init();
    runtime->start();

    DiscoveryQos discoveryQos;
    discoveryQos.setDiscoveryTimeoutMs(3000);

    auto providerReregistrationControllerProxyBuilder = runtime->createProxyBuilder<joynr::system::ProviderReregistrationControllerProxy>(domain);
    auto providerReregistrationControllerProxy = providerReregistrationControllerProxyBuilder->setDiscoveryQos(discoveryQos)->build();

    Semaphore finishedSemaphore;
    providerReregistrationControllerProxy->triggerGlobalProviderReregistrationAsync([&finishedSemaphore]() { finishedSemaphore.notify(); }, nullptr);
    EXPECT_TRUE(finishedSemaphore.waitFor(std::chrono::seconds(10)));

    runtime->stop();
    runtime = nullptr;
}

TEST(ProviderReregistrationControllerTest, queryProviderReregistrationControllerSucceedsOnWsRuntime)
{
    auto integrationSettings = std::make_unique<Settings>("test-resources/MqttSystemIntegrationTest1.settings");
    joynr::SystemServicesSettings systemServiceSettings(*integrationSettings);
    const std::string domain(systemServiceSettings.getDomain());

    auto ccRuntime = std::make_shared<JoynrClusterControllerRuntime>(std::move(integrationSettings));
    ccRuntime->init();
    ccRuntime->start();

    DiscoveryQos discoveryQos;
    discoveryQos.setDiscoveryTimeoutMs(3000);

    auto wsRuntimeSettings = std::make_unique<Settings>("test-resources/libjoynrSystemIntegration1.settings");
    auto wsRuntime = std::make_shared<TestLibJoynrWebSocketRuntime>(std::move(wsRuntimeSettings), nullptr);
    ASSERT_TRUE(wsRuntime->connect(std::chrono::seconds(2)));

    auto providerReregistrationControllerProxyBuilder = wsRuntime->createProxyBuilder<joynr::system::ProviderReregistrationControllerProxy>(domain);
    auto providerReregistrationControllerProxy = providerReregistrationControllerProxyBuilder->setDiscoveryQos(discoveryQos)->build();

    Semaphore finishedSemaphore;
    providerReregistrationControllerProxy->triggerGlobalProviderReregistrationAsync([&finishedSemaphore]() { finishedSemaphore.notify(); }, [](const joynr::exceptions::JoynrRuntimeException&) { FAIL(); });
    EXPECT_TRUE(finishedSemaphore.waitFor(std::chrono::seconds(10)));

    wsRuntime = nullptr;
    ccRuntime->stop();
    ccRuntime = nullptr;
}
<|endoftext|>


<commit_before>/*************** <auto-copyright.pl BEGIN do not edit this line> **************
 *
 * VR Juggler is (C) Copyright 1998-2003 by Iowa State University
 *
 * Original Authors:
 *   Allen Bierbaum, Christopher Just,
 *   Patrick Hartling, Kevin Meinert,
 *   Carolina Cruz-Neira, Albert Baker
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 * -----------------------------------------------------------------
 * File:          $RCSfile$
 * Date modified: $Date$
 * Version:       $Revision$
 * -----------------------------------------------------------------
 *
 *************** <auto-copyright.pl END do not edit this line> ***************/

#include <cluster/PluginConfig.h>

#include <boost/concept_check.hpp>

#include <jccl/Config/ConfigElement.h>
#include <plugins/StartBarrierPlugin/StartBarrierPlugin.h>

#include <gadget/Util/Debug.h>
#include <cluster/ClusterDepChecker.h>

#include <cluster/ClusterManager.h>
#include <cluster/ClusterNetwork.h>
#include <gadget/Node.h>

#include <cluster/Packets/StartBlock.h>

extern "C"
{
   GADGET_CLUSTER_PLUGIN_EXPORT(void) initPlugin(cluster::ClusterManager* mgr)
   {
      mgr->addPlugin(new cluster::StartBarrierPlugin());
   }
}

namespace cluster
{

StartBarrierPlugin::StartBarrierPlugin()
   : mBarrierMaster(false)
   , mComplete(false)
   , mHandlerGUID("566a50ff-5e73-43e0-a9a9-0fb62b76731a")
{;}

StartBarrierPlugin::~StartBarrierPlugin()
{

}

void StartBarrierPlugin::handlePacket(Packet* packet, gadget::Node* node)
{
   // On Barrier Recv
   // -If Master
   //   -Remove Pending slave
   //   -If all recved
   //     -Send responce to all nodes
   //     -Set Running TRUE
   // -Else
   //   -Set Running TRUE
   if ( NULL != packet && NULL != node )
   {

      if(packet->getPacketType() == cluster::Header::RIM_START_BLOCK)
      {
         //We are not actually using any data in this packet for now.

         //StartBlock* temp_start_block = dynamic_cast<StartBlock*>(packet);
         //vprASSERT(NULL != temp_start_block && "Dynamic cast failed!");
         if (isBarrierMaster())
         {
            removePendingBarrierSlave(node->getHostname());
            vprDEBUG(gadgetDBG_RIM,vprDBG_VERB_LVL) << clrOutBOLD(clrCYAN,"[StartBarrierPlugin] ")
               << "handlePacket() Master has received a START signal.\n" << vprDEBUG_FLUSH;
         }
         else
         {
            vprDEBUG(gadgetDBG_RIM,vprDBG_VERB_LVL) << clrOutBOLD(clrCYAN,"[StartBarrierPlugin] ")
               << "handlePacket() Slave has finished start barrier\n" << vprDEBUG_FLUSH;
            mComplete = true;
            ClusterManager::instance()->setClusterReady(true);
         }
      }
      else
      {
         vprDEBUG(gadgetDBG_RIM,vprDBG_CRITICAL_LVL) << clrOutBOLD(clrRED,"StartBarrierPlugin::handlePacket() ERROR: ")
            << "We do not handle this type of packet.\n" << vprDEBUG_FLUSH;
      }
   }
}

/** Add the pending element to the configuration.
*  @pre configCanHandle (element) == true.
*  @return true iff element was successfully added to configuration.
*/
bool StartBarrierPlugin::configAdd(jccl::ConfigElementPtr element)
{
   // -If the cluster manager has been configured.

   if(!ClusterManager::instance()->isClusterActive())
   {
      // XXX: This could be made into a dependancy also.
      return false;
   }

   mPendingSlaves = ClusterManager::instance()->getNodes();
   mSlaves = ClusterManager::instance()->getNodes();

   /////////////////////////////////////////
   //  Starting Barrier Stuff
   //
   // -Set flag we have started configuring the cluster
   // -Get Sync Machine element Name
   // -Get ElementPtr to this element
   // -Get the Hostname of this node

   mBarrierMachineElementName = element->getProperty<std::string>(std::string("start_master"));
   jccl::ConfigElementPtr barrier_machine_element =
      ClusterManager::instance()->getConfigElementPointer(mBarrierMachineElementName);
   vprASSERT(NULL != barrier_machine_element.get() && "StartBarrierPlugin element must have a start_master.");
   mBarrierMasterHostname = barrier_machine_element->getProperty<std::string>(std::string("host_name"));

   vprDEBUG(gadgetDBG_RIM,vprDBG_CONFIG_LVL)
      << clrOutBOLD(clrCYAN,"[StartBarrierPlugin] ")
      << "Start Master element Name is: "
      << mBarrierMachineElementName << std::endl << vprDEBUG_FLUSH;
   vprDEBUG(gadgetDBG_RIM,vprDBG_CONFIG_LVL)
      << clrOutBOLD(clrCYAN,"[StartBarrierPlugin] ")
      << "Start Master Hostname is: " << mBarrierMasterHostname
      << std::endl << vprDEBUG_FLUSH;

   // Starting Barrier Stuff
   /////////////////////////////////////

   if (ClusterNetwork::isLocalHost(mBarrierMasterHostname))
   {
      mBarrierMaster = true;
   }
   else
   {
      mBarrierMaster = false;
   }

   return true;
}

/** Remove the pending element from the current configuration.
*  @pre configCanHandle (element) == true.
*  @return true iff the element (and any objects it represented)
*          were successfully removed.
*/
bool StartBarrierPlugin::configRemove(jccl::ConfigElementPtr element)
{
   boost::ignore_unused_variable_warning(element);
   return false;
}

/** Checks if this handler can process element.
*  Typically, an implementation of handler will check the element's
*  description name/token to decide if it knows how to deal with
*  it.
*  @return true iff this handler can process element.
*/
bool StartBarrierPlugin::configCanHandle(jccl::ConfigElementPtr element)
{
   return recognizeStartBarrierPluginConfig(element);
}

bool StartBarrierPlugin::recognizeStartBarrierPluginConfig(jccl::ConfigElementPtr element)
{
   return element->getID() == getElementType();
}

void StartBarrierPlugin::preDraw()
{;
}
void StartBarrierPlugin::postPostFrame()
{
   // -If we are not complete
   //   -If all other plugins are ready
   //     -If Slave
   //       -Find the barrier master
   //       -If connected
   //         -Send a start block
   //       -Else
   //         -Add barrier node to pending list
   // -Else
   //   -If number of pending start nodes is 0
   //     -Send a start block to all of them

   //This is where all the real work gets done
   if (!mComplete)
   {
      if (ClusterManager::instance()->pluginsReady() &&
          0 == ClusterManager::instance()->getNetwork()->getNumPendingNodes())
      {
         if (!mBarrierMaster)
         {
            gadget::Node* start_master = ClusterManager::instance()->getNetwork()->getNodeByName(mBarrierMachineElementName);
            if (NULL == start_master)
            {
               vprDEBUG(gadgetDBG_RIM,vprDBG_CRITICAL_LVL)
                  << clrOutBOLD(clrRED,"[StartBarrierPlugin] Barrier machine configuration element not yet loaded.")
                  << std::endl << vprDEBUG_FLUSH;
            }
            else if (start_master->isConnected())
            {
               //Send packet to server machine
               StartBlock temp_start_block(getHandlerGUID(), 0);
               start_master->send(&temp_start_block);
               vprDEBUG(gadgetDBG_RIM,vprDBG_VERB_LVL) << clrOutBOLD(clrCYAN,"[StartBarrierPlugin] ")
                  << "Sending signal to start master: " << mBarrierMasterHostname << std::endl << vprDEBUG_FLUSH;
            }
            else
            {
               //If we are not connected and we are not in pending list, add to the pending list
               if (gadget::Node::PENDING != start_master->getStatus())
               {
                  start_master->setStatus(gadget::Node::PENDING);
               }
            }
         }
         else
         {
            vprDEBUG(gadgetDBG_RIM,vprDBG_VERB_LVL) << clrOutBOLD(clrCYAN,"[StartBarrierPlugin] ")
               << "Barrier Master waiting...\n" << vprDEBUG_FLUSH;
            int num_pending_nodes = getPendingBarrierSlaves().size();
            if (0 == num_pending_nodes)
            {
               mComplete = true;
               ClusterManager::instance()->setClusterReady(true);
               std::cout << "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX DONE - list=0 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" << std::endl;

               StartBlock temp_start_block(getHandlerGUID(), 0);

               //Send responce to all nodes
               for (std::vector<std::string>::iterator i = mSlaves.begin();
                    i != mSlaves.end() ; i++)
               {
                  vprDEBUG(gadgetDBG_RIM,vprDBG_CONFIG_STATUS_LVL) << clrOutBOLD(clrCYAN,"[StartBarrierPlugin] ")
                     << "Sending start signal to slave: " << (*i) << std::endl << vprDEBUG_FLUSH;
                  // Dead lock since we are actually in a recursion of Nodes
                  gadget::Node* node = ClusterManager::instance()->getNetwork()->getNodeByHostname(*i);
                  if(NULL == node)
                  {
                     vprDEBUG(gadgetDBG_RIM,vprDBG_CRITICAL_LVL) << clrOutBOLD(clrCYAN,"[StartBarrierPlugin] ")
                        << "Error, could not find a Node by the name of: " << (*i) << std::endl << vprDEBUG_FLUSH;
                  }
                  else
                  {
                     node->send(&temp_start_block);
                  }
               }
            }//End (0==num_pending_nodes)
         }//End (mBarrierMaster)
      }//End (Plugins Ready)
   }//End (!mComplete)
}

bool StartBarrierPlugin::isPluginReady()
{
   return true;
}

} // End of gadget namespace
<commit_msg>Bug fixed: Fixed the StartBarrierPlugin to work with the new and improved ClusterNetwork.<commit_after>/*************** <auto-copyright.pl BEGIN do not edit this line> **************
 *
 * VR Juggler is (C) Copyright 1998-2003 by Iowa State University
 *
 * Original Authors:
 *   Allen Bierbaum, Christopher Just,
 *   Patrick Hartling, Kevin Meinert,
 *   Carolina Cruz-Neira, Albert Baker
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 * -----------------------------------------------------------------
 * File:          $RCSfile$
 * Date modified: $Date$
 * Version:       $Revision$
 * -----------------------------------------------------------------
 *
 *************** <auto-copyright.pl END do not edit this line> ***************/

#include <cluster/PluginConfig.h>

#include <boost/concept_check.hpp>

#include <jccl/Config/ConfigElement.h>
#include <plugins/StartBarrierPlugin/StartBarrierPlugin.h>

#include <gadget/Util/Debug.h>
#include <cluster/ClusterDepChecker.h>

#include <cluster/ClusterManager.h>
#include <cluster/ClusterNetwork.h>
#include <gadget/Node.h>

#include <cluster/Packets/StartBlock.h>

extern "C"
{
   GADGET_CLUSTER_PLUGIN_EXPORT(void) initPlugin(cluster::ClusterManager* mgr)
   {
      mgr->addPlugin(new cluster::StartBarrierPlugin());
   }
}

namespace cluster
{

StartBarrierPlugin::StartBarrierPlugin()
   : mBarrierMaster(false)
   , mComplete(false)
   , mHandlerGUID("566a50ff-5e73-43e0-a9a9-0fb62b76731a")
{;}

StartBarrierPlugin::~StartBarrierPlugin()
{

}

void StartBarrierPlugin::handlePacket(Packet* packet, gadget::Node* node)
{
   // On Barrier Recv
   // -If Master
   //   -Remove Pending slave
   //   -If all recved
   //     -Send responce to all nodes
   //     -Set Running TRUE
   // -Else
   //   -Set Running TRUE
   if ( NULL != packet && NULL != node )
   {

      if(packet->getPacketType() == cluster::Header::RIM_START_BLOCK)
      {
         //We are not actually using any data in this packet for now.

         //StartBlock* temp_start_block = dynamic_cast<StartBlock*>(packet);
         //vprASSERT(NULL != temp_start_block && "Dynamic cast failed!");
         if (isBarrierMaster())
         {
            removePendingBarrierSlave(node->getHostname());
            vprDEBUG(gadgetDBG_RIM,vprDBG_VERB_LVL) << clrOutBOLD(clrCYAN,"[StartBarrierPlugin] ")
               << "handlePacket() Master has received a START signal.\n" << vprDEBUG_FLUSH;
         }
         else
         {
            vprDEBUG(gadgetDBG_RIM,vprDBG_VERB_LVL) << clrOutBOLD(clrCYAN,"[StartBarrierPlugin] ")
               << "handlePacket() Slave has finished start barrier\n" << vprDEBUG_FLUSH;
            mComplete = true;
            ClusterManager::instance()->setClusterReady(true);

            vprDEBUG(gadgetDBG_RIM,vprDBG_CONFIG_STATUS_LVL) << clrOutBOLD(clrCYAN,"[StartBarrierPlugin] ")
               << "Received signal from master, barrier released."
               << std::endl << vprDEBUG_FLUSH;
         }
      }
      else
      {
         vprDEBUG(gadgetDBG_RIM,vprDBG_CRITICAL_LVL) << clrOutBOLD(clrRED,"StartBarrierPlugin::handlePacket() ERROR: ")
            << "We do not handle this type of packet.\n" << vprDEBUG_FLUSH;
      }
   }
}

/** Add the pending element to the configuration.
*  @pre configCanHandle (element) == true.
*  @return true iff element was successfully added to configuration.
*/
bool StartBarrierPlugin::configAdd(jccl::ConfigElementPtr element)
{
   // -If the cluster manager has been configured.

   if(!ClusterManager::instance()->isClusterActive())
   {
      // XXX: This could be made into a dependancy also.
      return false;
   }

   mPendingSlaves = ClusterManager::instance()->getNodes();
   mSlaves = ClusterManager::instance()->getNodes();

   /////////////////////////////////////////
   //  Starting Barrier Stuff
   //
   // -Set flag we have started configuring the cluster
   // -Get Sync Machine element Name
   // -Get ElementPtr to this element
   // -Get the Hostname of this node

   mBarrierMachineElementName = element->getProperty<std::string>(std::string("start_master"));
   jccl::ConfigElementPtr barrier_machine_element =
      ClusterManager::instance()->getConfigElementPointer(mBarrierMachineElementName);
   vprASSERT(NULL != barrier_machine_element.get() && "StartBarrierPlugin element must have a start_master.");
   mBarrierMasterHostname = barrier_machine_element->getProperty<std::string>(std::string("host_name"));

   vprDEBUG(gadgetDBG_RIM,vprDBG_CONFIG_LVL)
      << clrOutBOLD(clrCYAN,"[StartBarrierPlugin] ")
      << "Start Master element Name is: "
      << mBarrierMachineElementName << std::endl << vprDEBUG_FLUSH;
   vprDEBUG(gadgetDBG_RIM,vprDBG_CONFIG_LVL)
      << clrOutBOLD(clrCYAN,"[StartBarrierPlugin] ")
      << "Start Master Hostname is: " << mBarrierMasterHostname
      << std::endl << vprDEBUG_FLUSH;

   // Starting Barrier Stuff
   /////////////////////////////////////

   if (ClusterNetwork::isLocalHost(mBarrierMasterHostname))
   {
      mBarrierMaster = true;
   }
   else
   {
      mBarrierMaster = false;
   }

   return true;
}

/** Remove the pending element from the current configuration.
*  @pre configCanHandle (element) == true.
*  @return true iff the element (and any objects it represented)
*          were successfully removed.
*/
bool StartBarrierPlugin::configRemove(jccl::ConfigElementPtr element)
{
   boost::ignore_unused_variable_warning(element);
   return false;
}

/** Checks if this handler can process element.
*  Typically, an implementation of handler will check the element's
*  description name/token to decide if it knows how to deal with
*  it.
*  @return true iff this handler can process element.
*/
bool StartBarrierPlugin::configCanHandle(jccl::ConfigElementPtr element)
{
   return recognizeStartBarrierPluginConfig(element);
}

bool StartBarrierPlugin::recognizeStartBarrierPluginConfig(jccl::ConfigElementPtr element)
{
   return element->getID() == getElementType();
}

void StartBarrierPlugin::preDraw()
{;
}
void StartBarrierPlugin::postPostFrame()
{
   // -If we are not complete
   //   -If all other plugins are ready
   //     -If Slave
   //       -Find the barrier master
   //       -If connected
   //         -Send a start block
   //       -Else
   //         -Add barrier node to pending list
   // -Else
   //   -If number of pending start nodes is 0
   //     -Send a start block to all of them

   //This is where all the real work gets done
   if (!mComplete)
   {
      if (ClusterManager::instance()->pluginsReady() &&
          0 == ClusterManager::instance()->getNetwork()->getNumPendingNodes())
      {
         if (!mBarrierMaster)
         {
            gadget::Node* start_master = ClusterManager::instance()->getNetwork()->getNodeByName(mBarrierMachineElementName);
            if (NULL == start_master)
            {
               vprDEBUG(gadgetDBG_RIM,vprDBG_CRITICAL_LVL)
                  << clrOutBOLD(clrRED,"[StartBarrierPlugin] Barrier machine configuration element not yet loaded.")
                  << std::endl << vprDEBUG_FLUSH;
            }
            else if (start_master->isConnected())
            {
               //Send packet to server machine
               StartBlock temp_start_block(getHandlerGUID(), 0);
               start_master->send(&temp_start_block);
               vprDEBUG(gadgetDBG_RIM,vprDBG_VERB_LVL) << clrOutBOLD(clrCYAN,"[StartBarrierPlugin] ")
                  << "Sending signal to start master: " << mBarrierMasterHostname << std::endl << vprDEBUG_FLUSH;
            }
            else
            {
               //If we are not connected and we are not in pending list, add to the pending list
               if (gadget::Node::DISCONNECTED == start_master->getStatus())
               {
                  vprDEBUG(gadgetDBG_RIM,vprDBG_CONFIG_LVL) << clrOutBOLD(clrCYAN,"[StartBarrierPlugin] ")
                     << "Moving node: " << start_master->getName() << " to pending state because we need to connect to it."
                     << std::endl << vprDEBUG_FLUSH;
                  start_master->setStatus(gadget::Node::PENDING);
               }
            }
         }
         else
         {
            vprDEBUG(gadgetDBG_RIM,vprDBG_VERB_LVL) << clrOutBOLD(clrCYAN,"[StartBarrierPlugin] ")
               << "Barrier Master waiting...\n" << vprDEBUG_FLUSH;
            int num_pending_nodes = getPendingBarrierSlaves().size();
            if (0 == num_pending_nodes)
            {
               mComplete = true;
               ClusterManager::instance()->setClusterReady(true);

               vprDEBUG(gadgetDBG_RIM,vprDBG_CONFIG_STATUS_LVL) << clrOutBOLD(clrCYAN,"[StartBarrierPlugin] ")
                  << "Pending nodes list empty, releasing all slave nodes."
                  << std::endl << vprDEBUG_FLUSH;

               StartBlock temp_start_block(getHandlerGUID(), 0);

               //Send responce to all nodes
               for (std::vector<std::string>::iterator i = mSlaves.begin();
                    i != mSlaves.end() ; i++)
               {
                  vprDEBUG(gadgetDBG_RIM,vprDBG_CONFIG_STATUS_LVL) << clrOutBOLD(clrCYAN,"[StartBarrierPlugin] ")
                     << "Sending start signal to slave: " << (*i) << std::endl << vprDEBUG_FLUSH;
                  // Dead lock since we are actually in a recursion of Nodes
                  gadget::Node* node = ClusterManager::instance()->getNetwork()->getNodeByHostname(*i);
                  if(NULL == node)
                  {
                     vprDEBUG(gadgetDBG_RIM,vprDBG_CRITICAL_LVL) << clrOutBOLD(clrCYAN,"[StartBarrierPlugin] ")
                        << "Error, could not find a Node by the name of: " << (*i) << std::endl << vprDEBUG_FLUSH;
                  }
                  else
                  {
                     node->send(&temp_start_block);
                  }
               }
            }//End (0==num_pending_nodes)
         }//End (mBarrierMaster)
      }//End (Plugins Ready)
   }//End (!mComplete)
}

bool StartBarrierPlugin::isPluginReady()
{
   return true;
}

} // End of gadget namespace
<|endoftext|>


<commit_before>// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

#define EIGEN_DEBUG_ASSIGN
#include "main.h"
#include <typeinfo>

std::string demangle_traversal(int t)
{
  if(t==DefaultTraversal) return "DefaultTraversal";
  if(t==LinearTraversal) return "LinearTraversal";
  if(t==InnerVectorizedTraversal) return "InnerVectorizedTraversal";
  if(t==LinearVectorizedTraversal) return "LinearVectorizedTraversal";
  if(t==SliceVectorizedTraversal) return "SliceVectorizedTraversal";
  return "?";
}
std::string demangle_unrolling(int t)
{
  if(t==NoUnrolling) return "NoUnrolling";
  if(t==InnerUnrolling) return "InnerUnrolling";
  if(t==CompleteUnrolling) return "CompleteUnrolling";
  return "?";
}

template<typename Dst, typename Src>
bool test_assign(const Dst&, const Src&, int traversal, int unrolling)
{
  internal::assign_traits<Dst,Src>::debug();
  bool res = internal::assign_traits<Dst,Src>::Traversal==traversal
          && internal::assign_traits<Dst,Src>::Unrolling==unrolling;
  if(!res)
  {
    std::cerr << " Expected Traversal == " << demangle_traversal(traversal)
              << " got " << demangle_traversal(internal::assign_traits<Dst,Src>::Traversal) << "\n";
    std::cerr << " Expected Unrolling == " << demangle_unrolling(unrolling)
              << " got " << demangle_unrolling(internal::assign_traits<Dst,Src>::Unrolling) << "\n";
  }
  return res;
}

template<typename Dst, typename Src>
bool test_assign(int traversal, int unrolling)
{
  internal::assign_traits<Dst,Src>::debug();
  bool res = internal::assign_traits<Dst,Src>::Traversal==traversal
          && internal::assign_traits<Dst,Src>::Unrolling==unrolling;
  if(!res)
  {
    std::cerr << " Expected Traversal == " << demangle_traversal(traversal)
              << " got " << demangle_traversal(internal::assign_traits<Dst,Src>::Traversal) << "\n";
    std::cerr << " Expected Unrolling == " << demangle_unrolling(unrolling)
              << " got " << demangle_unrolling(internal::assign_traits<Dst,Src>::Unrolling) << "\n";
  }
  return res;
}

template<typename Xpr>
bool test_redux(const Xpr&, int traversal, int unrolling)
{
  typedef internal::redux_traits<internal::scalar_sum_op<typename Xpr::Scalar>,Xpr> traits;
  bool res = traits::Traversal==traversal && traits::Unrolling==unrolling;
  if(!res)
  {
    std::cerr << " Expected Traversal == " << demangle_traversal(traversal)
              << " got " << demangle_traversal(traits::Traversal) << "\n";
    std::cerr << " Expected Unrolling == " << demangle_unrolling(unrolling)
              << " got " << demangle_unrolling(traits::Unrolling) << "\n";
  }
  return res;
}

template<typename Scalar, bool Enable = internal::packet_traits<Scalar>::Vectorizable> struct vectorization_logic
{
  enum {
    PacketSize = internal::packet_traits<Scalar>::size
  };
  static void run()
  {

    typedef Matrix<Scalar,PacketSize,1> Vector1;
    typedef Matrix<Scalar,Dynamic,1> VectorX;
    typedef Matrix<Scalar,Dynamic,Dynamic> MatrixXX;
    typedef Matrix<Scalar,PacketSize,PacketSize> Matrix11;
    typedef Matrix<Scalar,2*PacketSize,2*PacketSize> Matrix22;
    typedef Matrix<Scalar,(Matrix11::Flags&RowMajorBit)?16:4*PacketSize,(Matrix11::Flags&RowMajorBit)?4*PacketSize:16> Matrix44;
    typedef Matrix<Scalar,(Matrix11::Flags&RowMajorBit)?16:4*PacketSize,(Matrix11::Flags&RowMajorBit)?4*PacketSize:16,DontAlign|EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION> Matrix44u;
    typedef Matrix<Scalar,4*PacketSize,4*PacketSize,ColMajor> Matrix44c;
    typedef Matrix<Scalar,4*PacketSize,4*PacketSize,RowMajor> Matrix44r;

    typedef Matrix<Scalar,
        (PacketSize==8 ? 4 : PacketSize==4 ? 2 : PacketSize==2 ? 1 : /*PacketSize==1 ?*/ 1),
        (PacketSize==8 ? 2 : PacketSize==4 ? 2 : PacketSize==2 ? 2 : /*PacketSize==1 ?*/ 1)
      > Matrix1;

    typedef Matrix<Scalar,
        (PacketSize==8 ? 4 : PacketSize==4 ? 2 : PacketSize==2 ? 1 : /*PacketSize==1 ?*/ 1),
        (PacketSize==8 ? 2 : PacketSize==4 ? 2 : PacketSize==2 ? 2 : /*PacketSize==1 ?*/ 1),
      DontAlign|((Matrix1::Flags&RowMajorBit)?RowMajor:ColMajor)> Matrix1u;

    // this type is made such that it can only be vectorized when viewed as a linear 1D vector
    typedef Matrix<Scalar,
        (PacketSize==8 ? 4 : PacketSize==4 ? 6 : PacketSize==2 ? ((Matrix11::Flags&RowMajorBit)?2:3) : /*PacketSize==1 ?*/ 1),
        (PacketSize==8 ? 6 : PacketSize==4 ? 2 : PacketSize==2 ? ((Matrix11::Flags&RowMajorBit)?3:2) : /*PacketSize==1 ?*/ 3)
      > Matrix3;

    #if !EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT
    VERIFY(test_assign(Vector1(),Vector1(),
      InnerVectorizedTraversal,CompleteUnrolling));
    VERIFY(test_assign(Vector1(),Vector1()+Vector1(),
      InnerVectorizedTraversal,CompleteUnrolling));
    VERIFY(test_assign(Vector1(),Vector1().cwiseProduct(Vector1()),
      InnerVectorizedTraversal,CompleteUnrolling));
    VERIFY(test_assign(Vector1(),Vector1().template cast<Scalar>(),
      InnerVectorizedTraversal,CompleteUnrolling));

    VERIFY(test_assign(Vector1(),Vector1(),
      InnerVectorizedTraversal,CompleteUnrolling));
    VERIFY(test_assign(Vector1(),Vector1()+Vector1(),
      InnerVectorizedTraversal,CompleteUnrolling));
    VERIFY(test_assign(Vector1(),Vector1().cwiseProduct(Vector1()),
      InnerVectorizedTraversal,CompleteUnrolling));

    VERIFY(test_assign(Matrix44(),Matrix44()+Matrix44(),
      InnerVectorizedTraversal,InnerUnrolling));

    VERIFY(test_assign(Matrix44u(),Matrix44()+Matrix44(),
      LinearTraversal,NoUnrolling));

    VERIFY(test_assign(Matrix1u(),Matrix1()+Matrix1(),
      LinearTraversal,CompleteUnrolling));

    VERIFY(test_assign(Matrix44c().col(1),Matrix44c().col(2)+Matrix44c().col(3),
      InnerVectorizedTraversal,CompleteUnrolling));

    VERIFY(test_assign(Matrix44r().row(2),Matrix44r().row(1)+Matrix44r().row(1),
      InnerVectorizedTraversal,CompleteUnrolling));

    if(PacketSize>1)
    {
      typedef Matrix<Scalar,3,3,ColMajor> Matrix33c;
      VERIFY(test_assign(Matrix33c().row(2),Matrix33c().row(1)+Matrix33c().row(1),
        LinearTraversal,CompleteUnrolling));
      VERIFY(test_assign(Matrix33c().col(0),Matrix33c().col(1)+Matrix33c().col(1),
        LinearTraversal,CompleteUnrolling));

      VERIFY(test_assign(Matrix3(),Matrix3().cwiseQuotient(Matrix3()),
        LinearVectorizedTraversal,CompleteUnrolling));

      VERIFY(test_assign(Matrix<Scalar,17,17>(),Matrix<Scalar,17,17>()+Matrix<Scalar,17,17>(),
        LinearTraversal,NoUnrolling));

      VERIFY(test_assign(Matrix11(),Matrix<Scalar,17,17>().template block<PacketSize,PacketSize>(2,3)+Matrix<Scalar,17,17>().template block<PacketSize,PacketSize>(8,4),
        DefaultTraversal,PacketSize>4?InnerUnrolling:CompleteUnrolling));
    }

    VERIFY(test_redux(Matrix3(),
      LinearVectorizedTraversal,CompleteUnrolling));

    VERIFY(test_redux(Matrix44(),
      LinearVectorizedTraversal,NoUnrolling));

    VERIFY(test_redux(Matrix44().template block<(Matrix1::Flags&RowMajorBit)?4:PacketSize,(Matrix1::Flags&RowMajorBit)?PacketSize:4>(1,2),
      DefaultTraversal,CompleteUnrolling));

    VERIFY(test_redux(Matrix44c().template block<2*PacketSize,1>(1,2),
      LinearVectorizedTraversal,CompleteUnrolling));

    VERIFY(test_redux(Matrix44r().template block<1,2*PacketSize>(2,1),
      LinearVectorizedTraversal,CompleteUnrolling));

    VERIFY((test_assign<
            Map<Matrix22, Aligned, OuterStride<3*PacketSize> >,
            Matrix22
            >(InnerVectorizedTraversal,CompleteUnrolling)));

    VERIFY((test_assign<
            Map<Matrix<Scalar,EIGEN_PLAIN_ENUM_MAX(2,PacketSize),EIGEN_PLAIN_ENUM_MAX(2,PacketSize)>, Aligned, InnerStride<3*PacketSize> >,
            Matrix<Scalar,EIGEN_PLAIN_ENUM_MAX(2,PacketSize),EIGEN_PLAIN_ENUM_MAX(2,PacketSize)>
            >(DefaultTraversal,CompleteUnrolling)));

    VERIFY((test_assign(Matrix11(), Matrix<Scalar,PacketSize,EIGEN_PLAIN_ENUM_MIN(2,PacketSize)>()*Matrix<Scalar,EIGEN_PLAIN_ENUM_MIN(2,PacketSize),PacketSize>(),
                        PacketSize>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD?DefaultTraversal:InnerVectorizedTraversal, CompleteUnrolling)));
    #endif

    VERIFY(test_assign(MatrixXX(10,10),MatrixXX(20,20).block(10,10,2,3),
      SliceVectorizedTraversal,NoUnrolling));

    VERIFY(test_redux(VectorX(10),
      LinearVectorizedTraversal,NoUnrolling));

  }
};

template<typename Scalar> struct vectorization_logic<Scalar,false>
{
  static void run() {}
};

void test_vectorization_logic()
{

#ifdef EIGEN_VECTORIZE

  CALL_SUBTEST( vectorization_logic<float>::run() );
  CALL_SUBTEST( vectorization_logic<double>::run() );
  CALL_SUBTEST( vectorization_logic<std::complex<float> >::run() );
  CALL_SUBTEST( vectorization_logic<std::complex<double> >::run() );

  if(internal::packet_traits<float>::Vectorizable)
  {
    VERIFY(test_assign(Matrix<float,3,3>(),Matrix<float,3,3>()+Matrix<float,3,3>(),
      LinearTraversal,CompleteUnrolling));

    VERIFY(test_redux(Matrix<float,5,2>(),
      DefaultTraversal,CompleteUnrolling));
  }

  if(internal::packet_traits<double>::Vectorizable)
  {
    VERIFY(test_assign(Matrix<double,3,3>(),Matrix<double,3,3>()+Matrix<double,3,3>(),
      LinearTraversal,CompleteUnrolling));

    VERIFY(test_redux(Matrix<double,7,3>(),
      DefaultTraversal,CompleteUnrolling));
  }
#endif // EIGEN_VECTORIZE

}
<commit_msg>Test vectorization logic for int<commit_after>// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

#define EIGEN_DEBUG_ASSIGN
#include "main.h"
#include <typeinfo>

std::string demangle_traversal(int t)
{
  if(t==DefaultTraversal) return "DefaultTraversal";
  if(t==LinearTraversal) return "LinearTraversal";
  if(t==InnerVectorizedTraversal) return "InnerVectorizedTraversal";
  if(t==LinearVectorizedTraversal) return "LinearVectorizedTraversal";
  if(t==SliceVectorizedTraversal) return "SliceVectorizedTraversal";
  return "?";
}
std::string demangle_unrolling(int t)
{
  if(t==NoUnrolling) return "NoUnrolling";
  if(t==InnerUnrolling) return "InnerUnrolling";
  if(t==CompleteUnrolling) return "CompleteUnrolling";
  return "?";
}

template<typename Dst, typename Src>
bool test_assign(const Dst&, const Src&, int traversal, int unrolling)
{
  internal::assign_traits<Dst,Src>::debug();
  bool res = internal::assign_traits<Dst,Src>::Traversal==traversal
          && internal::assign_traits<Dst,Src>::Unrolling==unrolling;
  if(!res)
  {
    std::cerr << " Expected Traversal == " << demangle_traversal(traversal)
              << " got " << demangle_traversal(internal::assign_traits<Dst,Src>::Traversal) << "\n";
    std::cerr << " Expected Unrolling == " << demangle_unrolling(unrolling)
              << " got " << demangle_unrolling(internal::assign_traits<Dst,Src>::Unrolling) << "\n";
  }
  return res;
}

template<typename Dst, typename Src>
bool test_assign(int traversal, int unrolling)
{
  internal::assign_traits<Dst,Src>::debug();
  bool res = internal::assign_traits<Dst,Src>::Traversal==traversal
          && internal::assign_traits<Dst,Src>::Unrolling==unrolling;
  if(!res)
  {
    std::cerr << " Expected Traversal == " << demangle_traversal(traversal)
              << " got " << demangle_traversal(internal::assign_traits<Dst,Src>::Traversal) << "\n";
    std::cerr << " Expected Unrolling == " << demangle_unrolling(unrolling)
              << " got " << demangle_unrolling(internal::assign_traits<Dst,Src>::Unrolling) << "\n";
  }
  return res;
}

template<typename Xpr>
bool test_redux(const Xpr&, int traversal, int unrolling)
{
  typedef internal::redux_traits<internal::scalar_sum_op<typename Xpr::Scalar>,Xpr> traits;
  bool res = traits::Traversal==traversal && traits::Unrolling==unrolling;
  if(!res)
  {
    std::cerr << " Expected Traversal == " << demangle_traversal(traversal)
              << " got " << demangle_traversal(traits::Traversal) << "\n";
    std::cerr << " Expected Unrolling == " << demangle_unrolling(unrolling)
              << " got " << demangle_unrolling(traits::Unrolling) << "\n";
  }
  return res;
}

template<typename Scalar, bool Enable = internal::packet_traits<Scalar>::Vectorizable> struct vectorization_logic
{
  typedef internal::packet_traits<Scalar> PacketTraits;
  enum {
    PacketSize = PacketTraits::size
  };
  static void run()
  {

    typedef Matrix<Scalar,PacketSize,1> Vector1;
    typedef Matrix<Scalar,Dynamic,1> VectorX;
    typedef Matrix<Scalar,Dynamic,Dynamic> MatrixXX;
    typedef Matrix<Scalar,PacketSize,PacketSize> Matrix11;
    typedef Matrix<Scalar,2*PacketSize,2*PacketSize> Matrix22;
    typedef Matrix<Scalar,(Matrix11::Flags&RowMajorBit)?16:4*PacketSize,(Matrix11::Flags&RowMajorBit)?4*PacketSize:16> Matrix44;
    typedef Matrix<Scalar,(Matrix11::Flags&RowMajorBit)?16:4*PacketSize,(Matrix11::Flags&RowMajorBit)?4*PacketSize:16,DontAlign|EIGEN_DEFAULT_MATRIX_STORAGE_ORDER_OPTION> Matrix44u;
    typedef Matrix<Scalar,4*PacketSize,4*PacketSize,ColMajor> Matrix44c;
    typedef Matrix<Scalar,4*PacketSize,4*PacketSize,RowMajor> Matrix44r;

    typedef Matrix<Scalar,
        (PacketSize==8 ? 4 : PacketSize==4 ? 2 : PacketSize==2 ? 1 : /*PacketSize==1 ?*/ 1),
        (PacketSize==8 ? 2 : PacketSize==4 ? 2 : PacketSize==2 ? 2 : /*PacketSize==1 ?*/ 1)
      > Matrix1;

    typedef Matrix<Scalar,
        (PacketSize==8 ? 4 : PacketSize==4 ? 2 : PacketSize==2 ? 1 : /*PacketSize==1 ?*/ 1),
        (PacketSize==8 ? 2 : PacketSize==4 ? 2 : PacketSize==2 ? 2 : /*PacketSize==1 ?*/ 1),
      DontAlign|((Matrix1::Flags&RowMajorBit)?RowMajor:ColMajor)> Matrix1u;

    // this type is made such that it can only be vectorized when viewed as a linear 1D vector
    typedef Matrix<Scalar,
        (PacketSize==8 ? 4 : PacketSize==4 ? 6 : PacketSize==2 ? ((Matrix11::Flags&RowMajorBit)?2:3) : /*PacketSize==1 ?*/ 1),
        (PacketSize==8 ? 6 : PacketSize==4 ? 2 : PacketSize==2 ? ((Matrix11::Flags&RowMajorBit)?3:2) : /*PacketSize==1 ?*/ 3)
      > Matrix3;

    #if !EIGEN_GCC_AND_ARCH_DOESNT_WANT_STACK_ALIGNMENT
    VERIFY(test_assign(Vector1(),Vector1(),
      InnerVectorizedTraversal,CompleteUnrolling));
    VERIFY(test_assign(Vector1(),Vector1()+Vector1(),
      InnerVectorizedTraversal,CompleteUnrolling));
    VERIFY(test_assign(Vector1(),Vector1().cwiseProduct(Vector1()),
      InnerVectorizedTraversal,CompleteUnrolling));
    VERIFY(test_assign(Vector1(),Vector1().template cast<Scalar>(),
      InnerVectorizedTraversal,CompleteUnrolling));

    VERIFY(test_assign(Vector1(),Vector1(),
      InnerVectorizedTraversal,CompleteUnrolling));
    VERIFY(test_assign(Vector1(),Vector1()+Vector1(),
      InnerVectorizedTraversal,CompleteUnrolling));
    VERIFY(test_assign(Vector1(),Vector1().cwiseProduct(Vector1()),
      InnerVectorizedTraversal,CompleteUnrolling));

    VERIFY(test_assign(Matrix44(),Matrix44()+Matrix44(),
      InnerVectorizedTraversal,InnerUnrolling));

    VERIFY(test_assign(Matrix44u(),Matrix44()+Matrix44(),
      LinearTraversal,NoUnrolling));

    VERIFY(test_assign(Matrix1u(),Matrix1()+Matrix1(),
      LinearTraversal,CompleteUnrolling));

    VERIFY(test_assign(Matrix44c().col(1),Matrix44c().col(2)+Matrix44c().col(3),
      InnerVectorizedTraversal,CompleteUnrolling));

    VERIFY(test_assign(Matrix44r().row(2),Matrix44r().row(1)+Matrix44r().row(1),
      InnerVectorizedTraversal,CompleteUnrolling));

    if(PacketSize>1)
    {
      typedef Matrix<Scalar,3,3,ColMajor> Matrix33c;
      VERIFY(test_assign(Matrix33c().row(2),Matrix33c().row(1)+Matrix33c().row(1),
        LinearTraversal,CompleteUnrolling));
      VERIFY(test_assign(Matrix33c().col(0),Matrix33c().col(1)+Matrix33c().col(1),
        LinearTraversal,CompleteUnrolling));

      VERIFY(test_assign(Matrix3(),Matrix3().cwiseQuotient(Matrix3()),
        PacketTraits::HasDiv ? LinearVectorizedTraversal : LinearTraversal,CompleteUnrolling));

      VERIFY(test_assign(Matrix<Scalar,17,17>(),Matrix<Scalar,17,17>()+Matrix<Scalar,17,17>(),
        LinearTraversal,NoUnrolling));

      VERIFY(test_assign(Matrix11(),Matrix<Scalar,17,17>().template block<PacketSize,PacketSize>(2,3)+Matrix<Scalar,17,17>().template block<PacketSize,PacketSize>(8,4),
        DefaultTraversal,PacketSize>4?InnerUnrolling:CompleteUnrolling));
    }

    VERIFY(test_redux(Matrix3(),
      LinearVectorizedTraversal,CompleteUnrolling));

    VERIFY(test_redux(Matrix44(),
      LinearVectorizedTraversal,NoUnrolling));

    VERIFY(test_redux(Matrix44().template block<(Matrix1::Flags&RowMajorBit)?4:PacketSize,(Matrix1::Flags&RowMajorBit)?PacketSize:4>(1,2),
      DefaultTraversal,CompleteUnrolling));

    VERIFY(test_redux(Matrix44c().template block<2*PacketSize,1>(1,2),
      LinearVectorizedTraversal,CompleteUnrolling));

    VERIFY(test_redux(Matrix44r().template block<1,2*PacketSize>(2,1),
      LinearVectorizedTraversal,CompleteUnrolling));

    VERIFY((test_assign<
            Map<Matrix22, Aligned, OuterStride<3*PacketSize> >,
            Matrix22
            >(InnerVectorizedTraversal,CompleteUnrolling)));

    VERIFY((test_assign<
            Map<Matrix<Scalar,EIGEN_PLAIN_ENUM_MAX(2,PacketSize),EIGEN_PLAIN_ENUM_MAX(2,PacketSize)>, Aligned, InnerStride<3*PacketSize> >,
            Matrix<Scalar,EIGEN_PLAIN_ENUM_MAX(2,PacketSize),EIGEN_PLAIN_ENUM_MAX(2,PacketSize)>
            >(DefaultTraversal,CompleteUnrolling)));

    VERIFY((test_assign(Matrix11(), Matrix<Scalar,PacketSize,EIGEN_PLAIN_ENUM_MIN(2,PacketSize)>()*Matrix<Scalar,EIGEN_PLAIN_ENUM_MIN(2,PacketSize),PacketSize>(),
                        PacketSize>=EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD?DefaultTraversal:InnerVectorizedTraversal, CompleteUnrolling)));
    #endif

    VERIFY(test_assign(MatrixXX(10,10),MatrixXX(20,20).block(10,10,2,3),
      SliceVectorizedTraversal,NoUnrolling));

    VERIFY(test_redux(VectorX(10),
      LinearVectorizedTraversal,NoUnrolling));

  }
};

template<typename Scalar> struct vectorization_logic<Scalar,false>
{
  static void run() {}
};

void test_vectorization_logic()
{

#ifdef EIGEN_VECTORIZE

  CALL_SUBTEST( vectorization_logic<int>::run() );
  CALL_SUBTEST( vectorization_logic<float>::run() );
  CALL_SUBTEST( vectorization_logic<double>::run() );
  CALL_SUBTEST( vectorization_logic<std::complex<float> >::run() );
  CALL_SUBTEST( vectorization_logic<std::complex<double> >::run() );

  if(internal::packet_traits<float>::Vectorizable)
  {
    VERIFY(test_assign(Matrix<float,3,3>(),Matrix<float,3,3>()+Matrix<float,3,3>(),
      LinearTraversal,CompleteUnrolling));

    VERIFY(test_redux(Matrix<float,5,2>(),
      DefaultTraversal,CompleteUnrolling));
  }

  if(internal::packet_traits<double>::Vectorizable)
  {
    VERIFY(test_assign(Matrix<double,3,3>(),Matrix<double,3,3>()+Matrix<double,3,3>(),
      LinearTraversal,CompleteUnrolling));

    VERIFY(test_redux(Matrix<double,7,3>(),
      DefaultTraversal,CompleteUnrolling));
  }
#endif // EIGEN_VECTORIZE

}
<|endoftext|>


<commit_before><commit_msg>INTEGRATION: CWS pchfix02 (1.5.16); FILE MERGED 2006/09/01 17:30:41 kaib 1.5.16.1: #i68856# Added header markers and pch files<commit_after><|endoftext|>


<commit_before>#include "mitkPropertyList.h"

#include <fstream>
int mitkPropertyListTest(int argc, char* argv[])
{
  mitk::PropertyList::Pointer propList;

  std::cout << "Testing New(): ";
  propList = mitk::PropertyList::New();
  if (propList.IsNull()) {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  std::cout<<"[TEST DONE]"<<std::endl;
  return EXIT_SUCCESS;
}
<commit_msg>extended test<commit_after>#include "mitkPropertyList.h"
#include "mitkProperties.h"

#include <fstream>
int mitkPropertyListTest(int argc, char* argv[])
{
  mitk::PropertyList::Pointer propList;

  std::cout << "Testing mitk::PropertyList::New(): ";
  propList = mitk::PropertyList::New();
  if (propList.IsNull()) {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  std::cout<<"[PASSED]"<<std::endl;

  mitk::BoolProperty::Pointer boolProp = new mitk::BoolProperty(false);

  std::cout << "Testing SetProperty(): ";
  bool propChanged = propList->SetProperty("test",boolProp);
  if (!propChanged) {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  boolProp->SetValue(true);
  propChanged = propList->SetProperty("test",boolProp);
  if (!propChanged) {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }
  propChanged = propList->SetProperty("test",boolProp);
  if (propChanged) {
    std::cout<<"[FAILED]"<<std::endl;
    return EXIT_FAILURE;
  }

  std::cout<<"[TEST DONE]"<<std::endl;
  return EXIT_SUCCESS;
}
<|endoftext|>