<commit_before>/*!
    \file spsc_ring_buffer.inl
    \brief Single producer / single consumer wait-free ring buffer inline implementation
    \author Ivan Shynkarenka
    \date 16.01.2016
    \copyright MIT License
*/

#include <windows.h>
#include <debugapi.h>
#include <string>

namespace CppCommon {

inline SPSCRingBuffer::SPSCRingBuffer(size_t capacity) : _capacity(capacity), _mask(capacity - 1), _buffer(new uint8_t[capacity]), _head(0), _tail(0)
{
    assert((capacity > 1) && "Ring buffer capacity must be greater than one!");
    assert(((capacity & (capacity - 1)) == 0) && "Ring buffer capacity must be a power of two!");
}

inline size_t SPSCRingBuffer::size() const noexcept
{
    const size_t head = _head.load(std::memory_order_acquire);
    const size_t tail = _tail.load(std::memory_order_acquire);

    return head - tail;
}

inline bool SPSCRingBuffer::Enqueue(const void* chunk, size_t size)
{
    assert((chunk != nullptr) && "Pointer to the chunk should not be equal to 'nullptr'!");
    assert((size > 0) && "Chunk size should be greater than zero!");
    assert((size <= _capacity) && "Chunk size should not be greater than ring buffer capacity!");

    if ((chunk == nullptr) || (size == 0) || (size > _capacity))
        return false;

    const size_t head = _head.load(std::memory_order_relaxed);
    const size_t tail = _tail.load(std::memory_order_acquire);

    // Check if there is required free space in the ring buffer
    if ((size + head - tail) > _capacity)
        return false;

    // Copy chunk of bytes into the ring buffer
    size_t head_index = head & _mask;
    size_t tail_index = tail & _mask;
    size_t remain = (tail_index > head_index) ? (tail_index - head_index) : (_capacity - head_index);
    size_t first = (size > remain) ? remain : size;
    size_t last = (size > remain) ? size - remain : 0;
    memcpy(&_buffer[head_index], (uint8_t*)chunk, first);
    memcpy(_buffer, (uint8_t*)chunk + first, last);

    // Increase the head cursor
    _head.store(head + size, std::memory_order_release);

    return true;
}

inline bool SPSCRingBuffer::Dequeue(void* chunk, size_t& size)
{
    assert((chunk != nullptr) && "Pointer to the chunk should not be equal to 'nullptr'!");
    assert((size > 0) && "Chunk size should be greater than zero!");

    if ((chunk == nullptr) || (size == 0))
        return false;

    const size_t tail = _tail.load(std::memory_order_relaxed);
    const size_t head = _head.load(std::memory_order_acquire);

    // Get the ring buffer size
    size_t available = head - tail;
    if (size > available)
        size = available;

    // Check if the ring buffer is empty
    if (size == 0)
        return false;

    // Copy chunk of bytes from the ring buffer
    size_t head_index = head & _mask;
    size_t tail_index = tail & _mask;
    size_t remain = (head_index > tail_index) ? (head_index - tail_index) : (_capacity - tail_index);
    size_t first = (size > remain) ? remain : size;
    size_t last = (size > remain) ? size - remain : 0;
    memcpy((uint8_t*)chunk, &_buffer[tail_index], first);
    memcpy((uint8_t*)chunk + first, _buffer, last);

    // Increase the tail cursor
    _tail.store(tail + size, std::memory_order_release);

    return true;
}

} // namespace CppCommon
<commit_msg>Bugfixing<commit_after>/*!
    \file spsc_ring_buffer.inl
    \brief Single producer / single consumer wait-free ring buffer inline implementation
    \author Ivan Shynkarenka
    \date 16.01.2016
    \copyright MIT License
*/

namespace CppCommon {

inline SPSCRingBuffer::SPSCRingBuffer(size_t capacity) : _capacity(capacity), _mask(capacity - 1), _buffer(new uint8_t[capacity]), _head(0), _tail(0)
{
    assert((capacity > 1) && "Ring buffer capacity must be greater than one!");
    assert(((capacity & (capacity - 1)) == 0) && "Ring buffer capacity must be a power of two!");
}

inline size_t SPSCRingBuffer::size() const noexcept
{
    const size_t head = _head.load(std::memory_order_acquire);
    const size_t tail = _tail.load(std::memory_order_acquire);

    return head - tail;
}

inline bool SPSCRingBuffer::Enqueue(const void* chunk, size_t size)
{
    assert((chunk != nullptr) && "Pointer to the chunk should not be equal to 'nullptr'!");
    assert((size > 0) && "Chunk size should be greater than zero!");
    assert((size <= _capacity) && "Chunk size should not be greater than ring buffer capacity!");

    if ((chunk == nullptr) || (size == 0) || (size > _capacity))
        return false;

    const size_t head = _head.load(std::memory_order_relaxed);
    const size_t tail = _tail.load(std::memory_order_acquire);

    // Check if there is required free space in the ring buffer
    if ((size + head - tail) > _capacity)
        return false;

    // Copy chunk of bytes into the ring buffer
    size_t head_index = head & _mask;
    size_t tail_index = tail & _mask;
    size_t remain = (tail_index > head_index) ? (tail_index - head_index) : (_capacity - head_index);
    size_t first = (size > remain) ? remain : size;
    size_t last = (size > remain) ? size - remain : 0;
    memcpy(&_buffer[head_index], (uint8_t*)chunk, first);
    memcpy(_buffer, (uint8_t*)chunk + first, last);

    // Increase the head cursor
    _head.store(head + size, std::memory_order_release);

    return true;
}

inline bool SPSCRingBuffer::Dequeue(void* chunk, size_t& size)
{
    assert((chunk != nullptr) && "Pointer to the chunk should not be equal to 'nullptr'!");
    assert((size > 0) && "Chunk size should be greater than zero!");

    if ((chunk == nullptr) || (size == 0))
        return false;

    const size_t tail = _tail.load(std::memory_order_relaxed);
    const size_t head = _head.load(std::memory_order_acquire);

    // Get the ring buffer size
    size_t available = head - tail;
    if (size > available)
        size = available;

    // Check if the ring buffer is empty
    if (size == 0)
        return false;

    // Copy chunk of bytes from the ring buffer
    size_t head_index = head & _mask;
    size_t tail_index = tail & _mask;
    size_t remain = (head_index > tail_index) ? (head_index - tail_index) : (_capacity - tail_index);
    size_t first = (size > remain) ? remain : size;
    size_t last = (size > remain) ? size - remain : 0;
    memcpy((uint8_t*)chunk, &_buffer[tail_index], first);
    memcpy((uint8_t*)chunk + first, _buffer, last);

    // Increase the tail cursor
    _tail.store(tail + size, std::memory_order_release);

    return true;
}

} // namespace CppCommon
<|endoftext|>


<commit_before>#pragma once

#include "zmsg_types.hpp"
#include "zmsg_record_offset.hpp"

namespace zmsg {

template<>
struct zmsg<mid_t::shrinkage_test_start> {
public:
	fs_pattern_t FSPattern;
	UINT32 FibreType;
	UINT32 FibreAlignment;
	BOOL XImageFocus;
	BOOL YImageFocus;
	BOOL FibreShift;
	BOOL DischargeStrengthAdjustment;
	BOOL TensionSet;
	FLOAT CutAngleLimit;
	FLOAT LossLimit;
	FLOAT FibreAngleLimit;
	ULONG CleanDischargeTime;
	ULONG FibreIntervalSetup;
	LONG  FSPosSetup;
	DOUBLE FibrePreFSStrength;
	ULONG FibrePreFSTime;
	ULONG FibreOverlapSetup;
	DOUBLE Discharge1Strength;
	ULONG Discharge1Time;
	DOUBLE Discharge2Strength;
	ULONG Discharge2LastTime;
	ULONG Discharge2StartTime;
	ULONG Discharge2StopTime;
	ULONG ExtraManualDischargeTime;

	BOOL ConeFS;
	ULONG ConeFSWaitTime;
	DOUBLE ConeFSSpeed;
	ULONG ConeFSStretchLength;
	loss_estimate_mode_t LossEstimationMode;
	FLOAT LeftFibreMFD;
	FLOAT RightFibreMFD;
	FLOAT LeastLoss;
	FLOAT RateOfSyntropyBending;
	FLOAT RateOfReverseBending;
	FLOAT RateOfMFDDeviation;

	BOOL AutoStart;
	BOOL Stop1;
	BOOL Stop2;
	/*data dispaly*/
	BOOL CutAngle;
	BOOL OffsetData;
	/*omitted choice*/
	BOOL Cut;
	BOOL Loss;
	BOOL FibreCoreAngle;
	BOOL Bubble;
	BOOL Thick;
	BOOL Thin;
	/*dischargesupplement*/
	BOOL AirPressure;
	BOOL Temperature;
	/*fiber_image_display*/
	UINT32 ImgGap;
	UINT32 ImgStop1;
	UINT32 ImgAlign;
	UINT32 ImgStop2;
	UINT32 ImgDischarge;
	UINT32 ImgLossEstimation;
	/*else*/
	BOOL FibreAutoFeed;
	BOOL BadCutSurface;
	BOOL AutoAlignAfterStop;
	ULONG ManualDischargeTimes;
public:
	ZMSG_PU(
		FSPattern,
		FibreType,
		FibreAlignment,
		XImageFocus,
		YImageFocus,
		FibreShift,
		DischargeStrengthAdjustment,
		TensionSet,
		CutAngleLimit,
		LossLimit,
		FibreAngleLimit,
		CleanDischargeTime,
		FibreIntervalSetup,
		FSPosSetup,
		FibrePreFSStrength,
		FibrePreFSTime,
		FibreOverlapSetup,
		Discharge1Strength,
		Discharge1Time,
		Discharge2Strength,
		Discharge2LastTime,
		Discharge2StartTime,
		Discharge2StopTime,
		ExtraManualDischargeTime,

		ConeFS,
		ConeFSWaitTime,
		ConeFSSpeed,
		ConeFSStretchLength,
		LossEstimationMode,
		LeftFibreMFD,
		RightFibreMFD,
		LeastLoss,
		RateOfSyntropyBending,
		RateOfReverseBending,
		RateOfMFDDeviation,

		AutoStart,
		Stop1,
		Stop2,
		CutAngle,
		OffsetData,
		Cut,
		Loss,
		FibreCoreAngle,
		Bubble,
		Thick,
		Thin,
		AirPressure,
		Temperature,
		ImgGap,
		ImgStop1,
		ImgAlign,
		ImgStop2,
		ImgDischarge,
		ImgLossEstimation,
		FibreAutoFeed,
		BadCutSurface,
		AutoAlignAfterStop,
		ManualDischargeTimes)
};

template<>
struct zmsg<mid_t::shrinkage_test_result> {
	fs_err_t code;

	zmsg<mid_t::shrinkage_test_start> z_cfg;

	fiber_rec_info_t rec_info;

	img_defects_t defect_data;

	zmsg<mid_t::record_off_set> z_record_offset;

	double shrinkage;		/// unit: um
public:
	ZMSG_PU(code, z_cfg, rec_info, defect_data, z_record_offset, shrinkage)
};

}

<commit_msg>zmsg: shrink_test_result: add real_gap<commit_after>#pragma once

#include "zmsg_types.hpp"
#include "zmsg_record_offset.hpp"

namespace zmsg {

template<>
struct zmsg<mid_t::shrinkage_test_start> {
public:
	fs_pattern_t FSPattern;
	UINT32 FibreType;
	UINT32 FibreAlignment;
	BOOL XImageFocus;
	BOOL YImageFocus;
	BOOL FibreShift;
	BOOL DischargeStrengthAdjustment;
	BOOL TensionSet;
	FLOAT CutAngleLimit;
	FLOAT LossLimit;
	FLOAT FibreAngleLimit;
	ULONG CleanDischargeTime;
	ULONG FibreIntervalSetup;
	LONG  FSPosSetup;
	DOUBLE FibrePreFSStrength;
	ULONG FibrePreFSTime;
	ULONG FibreOverlapSetup;
	DOUBLE Discharge1Strength;
	ULONG Discharge1Time;
	DOUBLE Discharge2Strength;
	ULONG Discharge2LastTime;
	ULONG Discharge2StartTime;
	ULONG Discharge2StopTime;
	ULONG ExtraManualDischargeTime;

	BOOL ConeFS;
	ULONG ConeFSWaitTime;
	DOUBLE ConeFSSpeed;
	ULONG ConeFSStretchLength;
	loss_estimate_mode_t LossEstimationMode;
	FLOAT LeftFibreMFD;
	FLOAT RightFibreMFD;
	FLOAT LeastLoss;
	FLOAT RateOfSyntropyBending;
	FLOAT RateOfReverseBending;
	FLOAT RateOfMFDDeviation;

	BOOL AutoStart;
	BOOL Stop1;
	BOOL Stop2;
	/*data dispaly*/
	BOOL CutAngle;
	BOOL OffsetData;
	/*omitted choice*/
	BOOL Cut;
	BOOL Loss;
	BOOL FibreCoreAngle;
	BOOL Bubble;
	BOOL Thick;
	BOOL Thin;
	/*dischargesupplement*/
	BOOL AirPressure;
	BOOL Temperature;
	/*fiber_image_display*/
	UINT32 ImgGap;
	UINT32 ImgStop1;
	UINT32 ImgAlign;
	UINT32 ImgStop2;
	UINT32 ImgDischarge;
	UINT32 ImgLossEstimation;
	/*else*/
	BOOL FibreAutoFeed;
	BOOL BadCutSurface;
	BOOL AutoAlignAfterStop;
	ULONG ManualDischargeTimes;
public:
	ZMSG_PU(
		FSPattern,
		FibreType,
		FibreAlignment,
		XImageFocus,
		YImageFocus,
		FibreShift,
		DischargeStrengthAdjustment,
		TensionSet,
		CutAngleLimit,
		LossLimit,
		FibreAngleLimit,
		CleanDischargeTime,
		FibreIntervalSetup,
		FSPosSetup,
		FibrePreFSStrength,
		FibrePreFSTime,
		FibreOverlapSetup,
		Discharge1Strength,
		Discharge1Time,
		Discharge2Strength,
		Discharge2LastTime,
		Discharge2StartTime,
		Discharge2StopTime,
		ExtraManualDischargeTime,

		ConeFS,
		ConeFSWaitTime,
		ConeFSSpeed,
		ConeFSStretchLength,
		LossEstimationMode,
		LeftFibreMFD,
		RightFibreMFD,
		LeastLoss,
		RateOfSyntropyBending,
		RateOfReverseBending,
		RateOfMFDDeviation,

		AutoStart,
		Stop1,
		Stop2,
		CutAngle,
		OffsetData,
		Cut,
		Loss,
		FibreCoreAngle,
		Bubble,
		Thick,
		Thin,
		AirPressure,
		Temperature,
		ImgGap,
		ImgStop1,
		ImgAlign,
		ImgStop2,
		ImgDischarge,
		ImgLossEstimation,
		FibreAutoFeed,
		BadCutSurface,
		AutoAlignAfterStop,
		ManualDischargeTimes)
};

template<>
struct zmsg<mid_t::shrinkage_test_result> {
	fs_err_t code;

	zmsg<mid_t::shrinkage_test_start> z_cfg;

	fiber_rec_info_t rec_info;

	img_defects_t defect_data;

	zmsg<mid_t::record_off_set> z_record_offset;

	double real_gap;		/// unit: um
	double shrinkage;		/// unit: um
public:
	ZMSG_PU(code, z_cfg, rec_info, defect_data, z_record_offset, real_gap, shrinkage)
};

}

<|endoftext|>


<commit_before>/**
 * @file llurlmatch_test.cpp
 * @author Martin Reddy
 * @brief Unit tests for LLUrlMatch
 *
 * $LicenseInfo:firstyear=2009&license=viewergpl$
 *
 * Copyright (c) 2009, Linden Research, Inc.
 *
 * The following source code is PROPRIETARY AND CONFIDENTIAL. Use of
 * this source code is governed by the Linden Lab Source Code Disclosure
 * Agreement ("Agreement") previously entered between you and Linden
 * Lab. By accessing, using, copying, modifying or distributing this
 * software, you acknowledge that you have been informed of your
 * obligations under the Agreement and agree to abide by those obligations.
 *
 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
 * COMPLETENESS OR PERFORMANCE.
 * $/LicenseInfo$
 */

#include "../llurlmatch.h"
#include "lltut.h"

// link seams

LLUIColor::LLUIColor()
	: mColorPtr(NULL)
{}

LLStyle::Params::Params()
{
}

namespace LLInitParam
{
	BaseBlock::BaseBlock() {}
	BaseBlock::~BaseBlock() {}

	void BaseBlock::setLastChangedParam(const Param& last_param, bool user_provided) {}

	void BaseBlock::addParam(BlockDescriptor& block_data, const ParamDescriptor& in_param, const char* char_name){}
	param_handle_t BaseBlock::getHandleFromParam(const Param* param) const {return 0;}

	void BaseBlock::init(BlockDescriptor& descriptor, BlockDescriptor& base_descriptor, size_t block_size)
	{
		mBlockDescriptor = &descriptor;
		descriptor.mCurrentBlockPtr = this;
	}

	Param::Param(BaseBlock* enclosing_block)
	:	mIsProvided(false)
	{
		const U8* my_addr = reinterpret_cast<const U8*>(this);
		const U8* block_addr = reinterpret_cast<const U8*>(enclosing_block);
		mEnclosingBlockOffset = (U16)(my_addr - block_addr);
	}

	bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack){ return true; }
	bool BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t name_stack, const LLInitParam::BaseBlock* diff_block) const { return true; }
	bool BaseBlock::inspectBlock(Parser& parser, Parser::name_stack_t name_stack) const { return true; }
	bool BaseBlock::merge(BlockDescriptor& block_data, const BaseBlock& other, bool overwrite) { return true; }
	bool BaseBlock::validateBlock(bool emit_errors) const { return true; }

	TypedParam<LLUIColor >::TypedParam(BlockDescriptor& descriptor, const char* name, const LLUIColor& value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count)
	:	super_t(descriptor, name, value, func, min_count, max_count)
	{}

	void TypedParam<LLUIColor>::setValueFromBlock() const
	{}

	void TypedParam<LLUIColor>::setBlockFromValue()
	{}

	void TypeValues<LLUIColor>::declareValues()
	{}

	bool ParamCompare<const LLFontGL*, false>::equals(const LLFontGL* a, const LLFontGL* b)
	{
		return false;
	}

	TypedParam<const LLFontGL*>::TypedParam(BlockDescriptor& descriptor, const char* _name, const LLFontGL*const value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count)
	:	super_t(descriptor, _name, value, func, min_count, max_count)
	{}

	void TypedParam<const LLFontGL*>::setValueFromBlock() const
	{}

	void TypedParam<const LLFontGL*>::setBlockFromValue()
	{}

	void TypeValues<LLFontGL::HAlign>::declareValues()
	{}

	void TypeValues<LLFontGL::VAlign>::declareValues()
	{}

	void TypeValues<LLFontGL::ShadowType>::declareValues()
	{}

	void TypedParam<LLUIImage*>::setValueFromBlock() const
	{}

	void TypedParam<LLUIImage*>::setBlockFromValue()
	{}

	bool ParamCompare<LLUIImage*, false>::equals(
		LLUIImage* const &a,
		LLUIImage* const &b)
	{
		return false;
	}

	bool ParamCompare<LLUIColor, false>::equals(const LLUIColor &a, const LLUIColor &b)
	{
		return false;
	}

}

//static
LLFontGL* LLFontGL::getFontDefault()
{
	return NULL;
}

namespace tut
{
	struct LLUrlMatchData
	{
	};

	typedef test_group<LLUrlMatchData> factory;
	typedef factory::object object;
}

namespace
{
	tut::factory tf("LLUrlMatch");
}

namespace tut
{
	template<> template<>
	void object::test<1>()
	{
		//
		// test the empty() method
		//
		LLUrlMatch match;
		ensure("empty()", match.empty());

		match.setValues(0, 1, "http://secondlife.com", "Second Life", "", "", LLStyle::Params(), "", "", false);
		ensure("! empty()", ! match.empty());
	}

	template<> template<>
	void object::test<2>()
	{
		//
		// test the getStart() method
		//
		LLUrlMatch match;
		ensure_equals("getStart() == 0", match.getStart(), 0);

		match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
		ensure_equals("getStart() == 10", match.getStart(), 10);
	}

	template<> template<>
	void object::test<3>()
	{
		//
		// test the getEnd() method
		//
		LLUrlMatch match;
		ensure_equals("getEnd() == 0", match.getEnd(), 0);

		match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
		ensure_equals("getEnd() == 20", match.getEnd(), 20);
	}

	template<> template<>
	void object::test<4>()
	{
		//
		// test the getUrl() method
		//
		LLUrlMatch match;
		ensure_equals("getUrl() == ''", match.getUrl(), "");

		match.setValues(10, 20, "http://slurl.com/", "", "", "", LLStyle::Params(), "", "", false);
		ensure_equals("getUrl() == 'http://slurl.com/'", match.getUrl(), "http://slurl.com/");

		match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
		ensure_equals("getUrl() == '' (2)", match.getUrl(), "");
	}

	template<> template<>
	void object::test<5>()
	{
		//
		// test the getLabel() method
		//
		LLUrlMatch match;
		ensure_equals("getLabel() == ''", match.getLabel(), "");

		match.setValues(10, 20, "", "Label", "", "", LLStyle::Params(), "", "", false);
		ensure_equals("getLabel() == 'Label'", match.getLabel(), "Label");

		match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
		ensure_equals("getLabel() == '' (2)", match.getLabel(), "");
	}

	template<> template<>
	void object::test<6>()
	{
		//
		// test the getTooltip() method
		//
		LLUrlMatch match;
		ensure_equals("getTooltip() == ''", match.getTooltip(), "");

		match.setValues(10, 20, "", "", "Info", "", LLStyle::Params(), "", "", false);
		ensure_equals("getTooltip() == 'Info'", match.getTooltip(), "Info");

		match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
		ensure_equals("getTooltip() == '' (2)", match.getTooltip(), "");
	}

	template<> template<>
	void object::test<7>()
	{
		//
		// test the getIcon() method
		//
		LLUrlMatch match;
		ensure_equals("getIcon() == ''", match.getIcon(), "");

		match.setValues(10, 20, "", "", "", "Icon", LLStyle::Params(), "", "", false);
		ensure_equals("getIcon() == 'Icon'", match.getIcon(), "Icon");

		match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
		ensure_equals("getIcon() == '' (2)", match.getIcon(), "");
	}

	template<> template<>
	void object::test<8>()
	{
		//
		// test the getMenuName() method
		//
		LLUrlMatch match;
		ensure("getMenuName() empty", match.getMenuName().empty());

		match.setValues(10, 20, "", "", "", "Icon", LLStyle::Params(), "xui_file.xml", "", false);
		ensure_equals("getMenuName() == \"xui_file.xml\"", match.getMenuName(), "xui_file.xml");

		match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
		ensure("getMenuName() empty (2)", match.getMenuName().empty());
	}

	template<> template<>
	void object::test<9>()
	{
		//
		// test the getLocation() method
		//
		LLUrlMatch match;
		ensure("getLocation() empty", match.getLocation().empty());

		match.setValues(10, 20, "", "", "", "Icon", LLStyle::Params(), "xui_file.xml", "Paris", false);
		ensure_equals("getLocation() == \"Paris\"", match.getLocation(), "Paris");

		match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
		ensure("getLocation() empty (2)", match.getLocation().empty());
	}
}
<commit_msg>Fix broken Mac build on llurlmatch_test.cpp<commit_after>/**
 * @file llurlmatch_test.cpp
 * @author Martin Reddy
 * @brief Unit tests for LLUrlMatch
 *
 * $LicenseInfo:firstyear=2009&license=viewergpl$
 *
 * Copyright (c) 2009, Linden Research, Inc.
 *
 * The following source code is PROPRIETARY AND CONFIDENTIAL. Use of
 * this source code is governed by the Linden Lab Source Code Disclosure
 * Agreement ("Agreement") previously entered between you and Linden
 * Lab. By accessing, using, copying, modifying or distributing this
 * software, you acknowledge that you have been informed of your
 * obligations under the Agreement and agree to abide by those obligations.
 *
 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
 * COMPLETENESS OR PERFORMANCE.
 * $/LicenseInfo$
 */

#include "../llurlmatch.h"
//#include "../lluiimage.h"
#include "lltut.h"

// link seams

LLUIColor::LLUIColor()
	: mColorPtr(NULL)
{}

LLStyle::Params::Params()
{
}

LLUIImage::LLUIImage(const std::string& name, LLPointer<LLTexture> image)
{
}

LLUIImage::~LLUIImage()
{
}

//virtual
S32 LLUIImage::getWidth() const
{
	return 0;
}

//virtual
S32 LLUIImage::getHeight() const
{
	return 0;
}

namespace LLInitParam
{
	BaseBlock::BaseBlock() {}
	BaseBlock::~BaseBlock() {}

	void BaseBlock::setLastChangedParam(const Param& last_param, bool user_provided) {}

	void BaseBlock::addParam(BlockDescriptor& block_data, const ParamDescriptor& in_param, const char* char_name){}
	param_handle_t BaseBlock::getHandleFromParam(const Param* param) const {return 0;}

	void BaseBlock::init(BlockDescriptor& descriptor, BlockDescriptor& base_descriptor, size_t block_size)
	{
		mBlockDescriptor = &descriptor;
		descriptor.mCurrentBlockPtr = this;
	}

	Param::Param(BaseBlock* enclosing_block)
	:	mIsProvided(false)
	{
		const U8* my_addr = reinterpret_cast<const U8*>(this);
		const U8* block_addr = reinterpret_cast<const U8*>(enclosing_block);
		mEnclosingBlockOffset = (U16)(my_addr - block_addr);
	}

	bool BaseBlock::deserializeBlock(Parser& p, Parser::name_stack_range_t name_stack){ return true; }
	bool BaseBlock::serializeBlock(Parser& parser, Parser::name_stack_t name_stack, const LLInitParam::BaseBlock* diff_block) const { return true; }
	bool BaseBlock::inspectBlock(Parser& parser, Parser::name_stack_t name_stack) const { return true; }
	bool BaseBlock::merge(BlockDescriptor& block_data, const BaseBlock& other, bool overwrite) { return true; }
	bool BaseBlock::validateBlock(bool emit_errors) const { return true; }

	TypedParam<LLUIColor >::TypedParam(BlockDescriptor& descriptor, const char* name, const LLUIColor& value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count)
	:	super_t(descriptor, name, value, func, min_count, max_count)
	{}

	void TypedParam<LLUIColor>::setValueFromBlock() const
	{}

	void TypedParam<LLUIColor>::setBlockFromValue()
	{}

	void TypeValues<LLUIColor>::declareValues()
	{}

	bool ParamCompare<const LLFontGL*, false>::equals(const LLFontGL* a, const LLFontGL* b)
	{
		return false;
	}

	TypedParam<const LLFontGL*>::TypedParam(BlockDescriptor& descriptor, const char* _name, const LLFontGL*const value, ParamDescriptor::validation_func_t func, S32 min_count, S32 max_count)
	:	super_t(descriptor, _name, value, func, min_count, max_count)
	{}

	void TypedParam<const LLFontGL*>::setValueFromBlock() const
	{}

	void TypedParam<const LLFontGL*>::setBlockFromValue()
	{}

	void TypeValues<LLFontGL::HAlign>::declareValues()
	{}

	void TypeValues<LLFontGL::VAlign>::declareValues()
	{}

	void TypeValues<LLFontGL::ShadowType>::declareValues()
	{}

	void TypedParam<LLUIImage*>::setValueFromBlock() const
	{}

	void TypedParam<LLUIImage*>::setBlockFromValue()
	{}

	bool ParamCompare<LLUIImage*, false>::equals(
		LLUIImage* const &a,
		LLUIImage* const &b)
	{
		return false;
	}

	bool ParamCompare<LLUIColor, false>::equals(const LLUIColor &a, const LLUIColor &b)
	{
		return false;
	}

}

//static
LLFontGL* LLFontGL::getFontDefault()
{
	return NULL;
}

namespace tut
{
	struct LLUrlMatchData
	{
	};

	typedef test_group<LLUrlMatchData> factory;
	typedef factory::object object;
}

namespace
{
	tut::factory tf("LLUrlMatch");
}

namespace tut
{
	template<> template<>
	void object::test<1>()
	{
		//
		// test the empty() method
		//
		LLUrlMatch match;
		ensure("empty()", match.empty());

		match.setValues(0, 1, "http://secondlife.com", "Second Life", "", "", LLStyle::Params(), "", "", false);
		ensure("! empty()", ! match.empty());
	}

	template<> template<>
	void object::test<2>()
	{
		//
		// test the getStart() method
		//
		LLUrlMatch match;
		ensure_equals("getStart() == 0", match.getStart(), 0);

		match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
		ensure_equals("getStart() == 10", match.getStart(), 10);
	}

	template<> template<>
	void object::test<3>()
	{
		//
		// test the getEnd() method
		//
		LLUrlMatch match;
		ensure_equals("getEnd() == 0", match.getEnd(), 0);

		match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
		ensure_equals("getEnd() == 20", match.getEnd(), 20);
	}

	template<> template<>
	void object::test<4>()
	{
		//
		// test the getUrl() method
		//
		LLUrlMatch match;
		ensure_equals("getUrl() == ''", match.getUrl(), "");

		match.setValues(10, 20, "http://slurl.com/", "", "", "", LLStyle::Params(), "", "", false);
		ensure_equals("getUrl() == 'http://slurl.com/'", match.getUrl(), "http://slurl.com/");

		match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
		ensure_equals("getUrl() == '' (2)", match.getUrl(), "");
	}

	template<> template<>
	void object::test<5>()
	{
		//
		// test the getLabel() method
		//
		LLUrlMatch match;
		ensure_equals("getLabel() == ''", match.getLabel(), "");

		match.setValues(10, 20, "", "Label", "", "", LLStyle::Params(), "", "", false);
		ensure_equals("getLabel() == 'Label'", match.getLabel(), "Label");

		match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
		ensure_equals("getLabel() == '' (2)", match.getLabel(), "");
	}

	template<> template<>
	void object::test<6>()
	{
		//
		// test the getTooltip() method
		//
		LLUrlMatch match;
		ensure_equals("getTooltip() == ''", match.getTooltip(), "");

		match.setValues(10, 20, "", "", "Info", "", LLStyle::Params(), "", "", false);
		ensure_equals("getTooltip() == 'Info'", match.getTooltip(), "Info");

		match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
		ensure_equals("getTooltip() == '' (2)", match.getTooltip(), "");
	}

	template<> template<>
	void object::test<7>()
	{
		//
		// test the getIcon() method
		//
		LLUrlMatch match;
		ensure_equals("getIcon() == ''", match.getIcon(), "");

		match.setValues(10, 20, "", "", "", "Icon", LLStyle::Params(), "", "", false);
		ensure_equals("getIcon() == 'Icon'", match.getIcon(), "Icon");

		match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
		ensure_equals("getIcon() == '' (2)", match.getIcon(), "");
	}

	template<> template<>
	void object::test<8>()
	{
		//
		// test the getMenuName() method
		//
		LLUrlMatch match;
		ensure("getMenuName() empty", match.getMenuName().empty());

		match.setValues(10, 20, "", "", "", "Icon", LLStyle::Params(), "xui_file.xml", "", false);
		ensure_equals("getMenuName() == \"xui_file.xml\"", match.getMenuName(), "xui_file.xml");

		match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
		ensure("getMenuName() empty (2)", match.getMenuName().empty());
	}

	template<> template<>
	void object::test<9>()
	{
		//
		// test the getLocation() method
		//
		LLUrlMatch match;
		ensure("getLocation() empty", match.getLocation().empty());

		match.setValues(10, 20, "", "", "", "Icon", LLStyle::Params(), "xui_file.xml", "Paris", false);
		ensure_equals("getLocation() == \"Paris\"", match.getLocation(), "Paris");

		match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
		ensure("getLocation() empty (2)", match.getLocation().empty());
	}
}
<|endoftext|>


<commit_before><commit_msg>fixed bug EXT-1768	 Unable to store landmark attached to notecard into Landmarks<commit_after><|endoftext|>


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

  Program:   Insight Segmentation & Registration Toolkit
  Module:    itkCannySegmentationLevelSetImageFilterTest.cxx
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) Insight Software Consortium. All rights reserved.
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm 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.

=========================================================================*/
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif
#include "itkCannySegmentationLevelSetImageFilter.h"
//#include "itkImageFileWriter.h"
//#include "itkRawImageIO.h"
#include "itkCastImageFilter.h"
#include "itkCommand.h"
#include "itkEventObject.h"

namespace CSIFTN {

typedef itk::Image<float, 3> ImageType;
typedef itk::Image<char, 3> SeedImageType;

const int V_WIDTH  = 64;
const int V_HEIGHT = 64;
const int V_DEPTH  = 64;

float sphere(float x, float y, float z)
{
    float dis;
    dis = (x - (float)V_WIDTH/2.0)*(x - (float)V_WIDTH/2.0)
      /((0.2f*V_WIDTH)*(0.2f*V_WIDTH)) +
      (y - (float)V_HEIGHT/2.0)*(y - (float)V_HEIGHT/2.0)
      /((0.2f*V_HEIGHT)*(0.2f*V_HEIGHT)) +
      (z - (float)V_DEPTH/2.0)*(z - (float)V_DEPTH/2.0)
      /((0.2f*V_DEPTH)*(0.2f*V_DEPTH));
    return(1.0f-dis);
}

float sphere2(float x, float y, float z)
{
    float dis;
    dis = (x - (float)V_WIDTH/2.1)*(x - (float)V_WIDTH/2.1)
      /((0.2f*V_WIDTH)*(0.2f*V_WIDTH)) +
      (y - (float)V_HEIGHT/2.0)*(y - (float)V_HEIGHT/2.0)
      /((0.2f*V_HEIGHT)*(0.2f*V_HEIGHT)) +
      (z - (float)V_DEPTH/2.0)*(z - (float)V_DEPTH/2.0)
      /((0.2f*V_DEPTH)*(0.2f*V_DEPTH));
    return(1.0f-dis);
}

void evaluate_float_function(itk::Image<float, 3> *im,
          float (*f)(float, float, float) )
{
  itk::Image<float, 3>::IndexType idx;

  for(int z = 0; z < V_DEPTH; ++z)
    {
      idx[2] = z;
      for (int y = 0; y < V_HEIGHT; ++y)
        {
          idx[1] = y;
          for (int x = 0; x < V_WIDTH; ++x)
            {
              idx[0] = x;
              float val = f((float)x,(float)y,(float)z);
              //im->SetPixel(idx, -1.0 * f((float)x,(float)y,(float)z));
              if ( val >= 0.0 )
                {  im->SetPixel(idx, (64 - val)); }
              else
                {  im->SetPixel(idx, 64 + val ); }
            }
        }
    }
}

void evaluate_function(itk::Image<char, 3> *im,
          float (*f)(float, float, float) )
{
  itk::Image<char, 3>::IndexType idx;

  for(int z = 0; z < V_DEPTH; ++z)
    {
      idx[2] = z;
      for (int y = 0; y < V_HEIGHT; ++y)
        {
          idx[1] = y;
          for (int x = 0; x < V_WIDTH; ++x)
            {
              idx[0] = x;
              if ( f((float)x,(float)y,(float)z) >= 0.0 )
                {  im->SetPixel(idx, 1 ); }
              else
                {  im->SetPixel(idx, 0 ); }
            }
        }
    }
}

} // end namespace

namespace itk {

class RMSCommand : public Command
{
public:
  /** Smart pointer declaration methods */
  typedef RMSCommand Self;
  typedef Command Superclass;
  typedef itk::SmartPointer<Self>  Pointer;
  typedef itk::SmartPointer<const Self>  ConstPointer;
  itkTypeMacro( RMSCommand, Command );
  itkNewMacro(Self);

  /** Standard Command virtual methods */
  void Execute(Object *caller, const EventObject &)
  {
    std::cout <<
      (dynamic_cast<SparseFieldLevelSetImageFilter< ::CSIFTN::SeedImageType, ::CSIFTN::ImageType> *>(caller))->GetRMSChange()
              << std::endl;
    std::cout <<
      (dynamic_cast<SegmentationLevelSetImageFilter< ::CSIFTN::SeedImageType, ::CSIFTN::ImageType> *>(caller))->GetSegmentationFunction()->GetPropagationWeight()
              << std::endl;

  }
  void Execute(const Object *, const EventObject &)
  {
    std::cout << "ack" << std::endl;

  }

protected:
  RMSCommand()  {}
  virtual ~RMSCommand() {}
};

}

int itkCannySegmentationLevelSetImageFilterTest(int, char * [] )
{
  std::cout << "Last modified 11/08/02" << std::endl;

  CSIFTN::ImageType::RegionType reg;
  CSIFTN::ImageType::RegionType::SizeType sz;
  CSIFTN::ImageType::RegionType::IndexType idx;
  idx[0] = idx[1] = idx[2] = 0;
  sz[0] = sz[1] = sz[2] = 64;
  reg.SetSize(sz);
  reg.SetIndex(idx);

  CSIFTN::ImageType::Pointer     inputImage = CSIFTN::ImageType::New();
  CSIFTN::SeedImageType::Pointer seedImage = CSIFTN::SeedImageType::New();
  inputImage->SetRegions(reg);
  seedImage->SetRegions(reg);
  inputImage->Allocate();
  seedImage->Allocate();

  // Starting surface is a sphere in the center of the image.
  CSIFTN::evaluate_function(seedImage, CSIFTN::sphere);

  // Target surface is a sphere VERY NEAR to the starting surface.
  CSIFTN::evaluate_float_function(inputImage, CSIFTN::sphere2);

  itk::CannySegmentationLevelSetImageFilter< ::CSIFTN::SeedImageType, ::CSIFTN::ImageType>::Pointer
    filter = itk::CannySegmentationLevelSetImageFilter< ::CSIFTN::SeedImageType, ::CSIFTN::ImageType>::New();
  filter->SetInput(seedImage);
  filter->SetFeatureImage(inputImage);

  filter->SetMaximumRMSError(0.009);
  filter->SetMaximumIterations(10);
  //    filter->SetUseNegativeFeaturesOn(); // Change the default behavior of the speed
                                      // function so that negative values result in
                                      // surface growth.

  itk::RMSCommand::Pointer c = itk::RMSCommand::New();
  filter->AddObserver(itk::IterationEvent(), c);
  filter->SetIsoSurfaceValue(0.5);  //<--- IMPORTANT!  Default is zero.
  filter->SetPropagationScaling(0.5);
  filter->SetCurvatureScaling(1.0);
  filter->SetAdvectionScaling(1.0);
  filter->SetThreshold(10);
  filter->SetVariance(1.0);

  try {
    filter->Update();
    std::cout << "Done first trial" << std::endl;
    // Repeat to make sure that the filter is reinitialized properly
        filter->SetMaximumIterations(5);
        filter->Update();
        std::cout << "Done second trial" << std::endl;

    // Write the output for debugging purposes
    //        itk::ImageFileWriter<CSIFTN::ImageType>::Pointer writer
    //          = itk::ImageFileWriter<CSIFTN::ImageType>::New();
    //        itk::RawImageIO<float, 3>::Pointer io = itk::RawImageIO<float, 3>::New();
    //        io->SetFileTypeToBinary();
    //        io->SetFileDimensionality(3);
    //        io->SetByteOrderToLittleEndian();
    //        writer->SetImageIO(io);

    //        itk::CastImageFilter<CSIFTN::SeedImageType, CSIFTN::ImageType>::Pointer
    //         caster = itk::CastImageFilter<CSIFTN::SeedImageType, CSIFTN::ImageType>::New();
    //        caster->SetInput(seedImage);
    //        caster->Update();

        // writer->SetInput(caster->GetOutput());
        // writer->SetInput(filter->GetSpeedImage());
        //    writer->SetInput(filter->GetFeatureImage());
        //     writer->SetInput(inputImage);
        //    writer->SetInput(filter->GetOutput());
        //        writer->SetFileName("featureimage.raw");
        //        writer->Write();

        //        writer->SetInput(caster->GetOutput());
        //        writer->SetFileName("seedimage.raw");
        //        writer->Write();

        //        writer->SetInput(filter->GetOutput());
        //        writer->SetFileName("outputimage.raw");
        //        writer->Write();

        //        writer->SetInput(filter->GetSpeedImage());
        //        writer->SetFileName("speedimage.raw");
        //        writer->Write();

  }
  catch (itk::ExceptionObject &e)
    {
      std::cerr << e << std::endl;
    }

  return 0;
}
<commit_msg>BUG: Fixed threshold parameter.  Submitted by Bill Lorensen.<commit_after>/*=========================================================================

  Program:   Insight Segmentation & Registration Toolkit
  Module:    itkCannySegmentationLevelSetImageFilterTest.cxx
  Language:  C++
  Date:      $Date$
  Version:   $Revision$

  Copyright (c) Insight Software Consortium. All rights reserved.
  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm 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.

=========================================================================*/
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif
#include "itkCannySegmentationLevelSetImageFilter.h"
//#include "itkImageFileWriter.h"
//#include "itkRawImageIO.h"
#include "itkCastImageFilter.h"
#include "itkCommand.h"
#include "itkEventObject.h"

namespace CSIFTN {

typedef itk::Image<float, 3> ImageType;
typedef itk::Image<char, 3> SeedImageType;

const int V_WIDTH  = 64;
const int V_HEIGHT = 64;
const int V_DEPTH  = 64;

float sphere(float x, float y, float z)
{
    float dis;
    dis = (x - (float)V_WIDTH/2.0)*(x - (float)V_WIDTH/2.0)
      /((0.2f*V_WIDTH)*(0.2f*V_WIDTH)) +
      (y - (float)V_HEIGHT/2.0)*(y - (float)V_HEIGHT/2.0)
      /((0.2f*V_HEIGHT)*(0.2f*V_HEIGHT)) +
      (z - (float)V_DEPTH/2.0)*(z - (float)V_DEPTH/2.0)
      /((0.2f*V_DEPTH)*(0.2f*V_DEPTH));
    return(1.0f-dis);
}

float sphere2(float x, float y, float z)
{
    float dis;
    dis = (x - (float)V_WIDTH/2.1)*(x - (float)V_WIDTH/2.1)
      /((0.2f*V_WIDTH)*(0.2f*V_WIDTH)) +
      (y - (float)V_HEIGHT/2.0)*(y - (float)V_HEIGHT/2.0)
      /((0.2f*V_HEIGHT)*(0.2f*V_HEIGHT)) +
      (z - (float)V_DEPTH/2.0)*(z - (float)V_DEPTH/2.0)
      /((0.2f*V_DEPTH)*(0.2f*V_DEPTH));
    return(1.0f-dis);
}

void evaluate_float_function(itk::Image<float, 3> *im,
          float (*f)(float, float, float) )
{
  itk::Image<float, 3>::IndexType idx;

  for(int z = 0; z < V_DEPTH; ++z)
    {
      idx[2] = z;
      for (int y = 0; y < V_HEIGHT; ++y)
        {
          idx[1] = y;
          for (int x = 0; x < V_WIDTH; ++x)
            {
              idx[0] = x;
              float val = f((float)x,(float)y,(float)z);
              //im->SetPixel(idx, -1.0 * f((float)x,(float)y,(float)z));
              if ( val >= 0.0 )
                {  im->SetPixel(idx, (64 - val)); }
              else
                {  im->SetPixel(idx, 64 + val ); }
            }
        }
    }
}

void evaluate_function(itk::Image<char, 3> *im,
          float (*f)(float, float, float) )
{
  itk::Image<char, 3>::IndexType idx;

  for(int z = 0; z < V_DEPTH; ++z)
    {
      idx[2] = z;
      for (int y = 0; y < V_HEIGHT; ++y)
        {
          idx[1] = y;
          for (int x = 0; x < V_WIDTH; ++x)
            {
              idx[0] = x;
              if ( f((float)x,(float)y,(float)z) >= 0.0 )
                {  im->SetPixel(idx, 1 ); }
              else
                {  im->SetPixel(idx, 0 ); }
            }
        }
    }
}

} // end namespace

namespace itk {

class RMSCommand : public Command
{
public:
  /** Smart pointer declaration methods */
  typedef RMSCommand Self;
  typedef Command Superclass;
  typedef itk::SmartPointer<Self>  Pointer;
  typedef itk::SmartPointer<const Self>  ConstPointer;
  itkTypeMacro( RMSCommand, Command );
  itkNewMacro(Self);

  /** Standard Command virtual methods */
  void Execute(Object *caller, const EventObject &)
  {
    std::cout <<
      (dynamic_cast<SparseFieldLevelSetImageFilter< ::CSIFTN::SeedImageType, ::CSIFTN::ImageType> *>(caller))->GetRMSChange()
              << std::endl;
    std::cout <<
      (dynamic_cast<SegmentationLevelSetImageFilter< ::CSIFTN::SeedImageType, ::CSIFTN::ImageType> *>(caller))->GetSegmentationFunction()->GetPropagationWeight()
              << std::endl;

  }
  void Execute(const Object *, const EventObject &)
  {
    std::cout << "ack" << std::endl;

  }

protected:
  RMSCommand()  {}
  virtual ~RMSCommand() {}
};

}

int itkCannySegmentationLevelSetImageFilterTest(int, char * [] )
{
  std::cout << "Last modified 11/08/02" << std::endl;

  CSIFTN::ImageType::RegionType reg;
  CSIFTN::ImageType::RegionType::SizeType sz;
  CSIFTN::ImageType::RegionType::IndexType idx;
  idx[0] = idx[1] = idx[2] = 0;
  sz[0] = sz[1] = sz[2] = 64;
  reg.SetSize(sz);
  reg.SetIndex(idx);

  CSIFTN::ImageType::Pointer     inputImage = CSIFTN::ImageType::New();
  CSIFTN::SeedImageType::Pointer seedImage = CSIFTN::SeedImageType::New();
  inputImage->SetRegions(reg);
  seedImage->SetRegions(reg);
  inputImage->Allocate();
  seedImage->Allocate();

  // Starting surface is a sphere in the center of the image.
  CSIFTN::evaluate_function(seedImage, CSIFTN::sphere);

  // Target surface is a sphere VERY NEAR to the starting surface.
  CSIFTN::evaluate_float_function(inputImage, CSIFTN::sphere2);

  itk::CannySegmentationLevelSetImageFilter< ::CSIFTN::SeedImageType, ::CSIFTN::ImageType>::Pointer
    filter = itk::CannySegmentationLevelSetImageFilter< ::CSIFTN::SeedImageType, ::CSIFTN::ImageType>::New();
  filter->SetInput(seedImage);
  filter->SetFeatureImage(inputImage);

  filter->SetMaximumRMSError(0.009);
  filter->SetMaximumIterations(10);
  //    filter->SetUseNegativeFeaturesOn(); // Change the default behavior of the speed
                                      // function so that negative values result in
                                      // surface growth.

  itk::RMSCommand::Pointer c = itk::RMSCommand::New();
  filter->AddObserver(itk::IterationEvent(), c);
  filter->SetIsoSurfaceValue(0.5);  //<--- IMPORTANT!  Default is zero.
  filter->SetPropagationScaling(0.5);
  filter->SetCurvatureScaling(1.0);
  filter->SetAdvectionScaling(1.0);
  filter->SetThreshold(.4);
  filter->SetVariance(1.0);

  try {
    filter->Update();
    std::cout << "Done first trial" << std::endl;
    // Repeat to make sure that the filter is reinitialized properly
        filter->SetMaximumIterations(5);
        filter->Update();
        std::cout << "Done second trial" << std::endl;

    // Write the output for debugging purposes
    //        itk::ImageFileWriter<CSIFTN::ImageType>::Pointer writer
    //          = itk::ImageFileWriter<CSIFTN::ImageType>::New();
    //        itk::RawImageIO<float, 3>::Pointer io = itk::RawImageIO<float, 3>::New();
    //        io->SetFileTypeToBinary();
    //        io->SetFileDimensionality(3);
    //        io->SetByteOrderToLittleEndian();
    //        writer->SetImageIO(io);

    //        itk::CastImageFilter<CSIFTN::SeedImageType, CSIFTN::ImageType>::Pointer
    //         caster = itk::CastImageFilter<CSIFTN::SeedImageType, CSIFTN::ImageType>::New();
    //        caster->SetInput(seedImage);
    //        caster->Update();

        // writer->SetInput(caster->GetOutput());
        // writer->SetInput(filter->GetSpeedImage());
        //    writer->SetInput(filter->GetFeatureImage());
        //     writer->SetInput(inputImage);
        //    writer->SetInput(filter->GetOutput());
        //        writer->SetFileName("featureimage.raw");
        //        writer->Write();

        //        writer->SetInput(caster->GetOutput());
        //        writer->SetFileName("seedimage.raw");
        //        writer->Write();

        //        writer->SetInput(filter->GetOutput());
        //        writer->SetFileName("outputimage.raw");
        //        writer->Write();

        //        writer->SetInput(filter->GetSpeedImage());
        //        writer->SetFileName("speedimage.raw");
        //        writer->Write();

  }
  catch (itk::ExceptionObject &e)
    {
      std::cerr << e << std::endl;
    }

  return 0;
}
<|endoftext|>


<commit_before><commit_msg>shader_material_tiles_scene.cpp : correct issue in shader code<commit_after><|endoftext|>


<commit_before>
#include <iostream>
#include "window.h"
#include "application.h"
#include "style.h"
#include <platform/window.h>

namespace gui
{

////////////////////////////////////////

window::window( const std::shared_ptr<platform::window> &w )
	: _window( w )
{
	precondition( bool(_window), "null window" );
	_window->exposed.callback( [=] { this->paint(); } );
	_window->resized.callback( [=]( double w, double h ) { this->resize( w, h ); } );
	_window->mouse_pressed.callback( [=]( const std::shared_ptr<platform::mouse> &, const draw::point &p, int b ) { this->mouse_press( p, b ); } );
	_window->mouse_released.callback( [=]( const std::shared_ptr<platform::mouse> &, const draw::point &p, int b ) { this->mouse_release( p, b ); } );
	_window->mouse_moved.callback( [=]( const std::shared_ptr<platform::mouse> &, const draw::point &p ) { this->mouse_moved( p ); } );
}

////////////////////////////////////////

window::~window( void )
{
}

////////////////////////////////////////

void window::set_title( const std::string &t )
{
	_window->set_title( t );
}

////////////////////////////////////////

void window::show( void )
{
	_window->show();
}

////////////////////////////////////////

void window::set_widget( const std::shared_ptr<widget> &w )
{
	_widget = w;
	_widget->set_horizontal( 0.0, _window->width() - 1.0 );
	_widget->set_vertical( 0.0, _window->height() - 1.0 );
	_widget->set_minimum( _window->width(), _window->height() );
	_widget->set_delegate( this );
}

////////////////////////////////////////

void window::invalidate( const draw::rect &r )
{
	_window->invalidate( r );
}

////////////////////////////////////////

void window::paint( void )
{
	auto canvas = _window->canvas();
	auto style = application::current()->get_style();
	if ( style )
		style->background( canvas );
	if ( _widget )
		_widget->paint( canvas );
}

////////////////////////////////////////

void window::resize( double w, double h )
{
	if ( _widget )
	{
		_widget->set_horizontal( 0.0, w - 1.0 );
		_widget->set_vertical( 0.0, h - 1.0 );
		_widget->compute_layout();
	}
}

////////////////////////////////////////

void window::mouse_press( const draw::point &p, int b )
{
	if ( _widget )
		_widget->mouse_press( p, b );
}

////////////////////////////////////////

void window::mouse_release( const draw::point &p, int b )
{
	if ( _widget )
		_widget->mouse_release( p, b );
}

////////////////////////////////////////

void window::mouse_moved( const draw::point &p )
{
	if ( _widget )
		_widget->mouse_move( p );
}

////////////////////////////////////////

}

<commit_msg>Fixed bug with window never calling compute_minimum.<commit_after>
#include <iostream>
#include "window.h"
#include "application.h"
#include "style.h"
#include <platform/window.h>

namespace gui
{

////////////////////////////////////////

window::window( const std::shared_ptr<platform::window> &w )
	: _window( w )
{
	precondition( bool(_window), "null window" );
	_window->exposed.callback( [=] { this->paint(); } );
	_window->resized.callback( [=]( double w, double h ) { this->resize( w, h ); } );
	_window->mouse_pressed.callback( [=]( const std::shared_ptr<platform::mouse> &, const draw::point &p, int b ) { this->mouse_press( p, b ); } );
	_window->mouse_released.callback( [=]( const std::shared_ptr<platform::mouse> &, const draw::point &p, int b ) { this->mouse_release( p, b ); } );
	_window->mouse_moved.callback( [=]( const std::shared_ptr<platform::mouse> &, const draw::point &p ) { this->mouse_moved( p ); } );
}

////////////////////////////////////////

window::~window( void )
{
}

////////////////////////////////////////

void window::set_title( const std::string &t )
{
	_window->set_title( t );
}

////////////////////////////////////////

void window::show( void )
{
	_window->show();
}

////////////////////////////////////////

void window::set_widget( const std::shared_ptr<widget> &w )
{
	_widget = w;
	_widget->set_horizontal( 0.0, _window->width() - 1.0 );
	_widget->set_vertical( 0.0, _window->height() - 1.0 );
	_widget->compute_minimum();
	_widget->set_delegate( this );
}

////////////////////////////////////////

void window::invalidate( const draw::rect &r )
{
	_window->invalidate( r );
}

////////////////////////////////////////

void window::paint( void )
{
	auto canvas = _window->canvas();
	auto style = application::current()->get_style();
	if ( style )
		style->background( canvas );
	if ( _widget )
		_widget->paint( canvas );
}

////////////////////////////////////////

void window::resize( double w, double h )
{
	if ( _widget )
	{
		_widget->set_horizontal( 0.0, w - 1.0 );
		_widget->set_vertical( 0.0, h - 1.0 );
		_widget->compute_layout();
	}
}

////////////////////////////////////////

void window::mouse_press( const draw::point &p, int b )
{
	if ( _widget )
		_widget->mouse_press( p, b );
}

////////////////////////////////////////

void window::mouse_release( const draw::point &p, int b )
{
	if ( _widget )
		_widget->mouse_release( p, b );
}

////////////////////////////////////////

void window::mouse_moved( const draw::point &p )
{
	if ( _widget )
		_widget->mouse_move( p );
}

////////////////////////////////////////

}

<|endoftext|>


<commit_before>//===--------------------- Instruction.cpp ----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file defines abstractions used by the Pipeline to model register reads,
// register writes and instructions.
//
//===----------------------------------------------------------------------===//

#include "llvm/MCA/Instruction.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"

namespace llvm {
namespace mca {

void ReadState::writeStartEvent(unsigned Cycles) {
  assert(DependentWrites);
  assert(CyclesLeft == UNKNOWN_CYCLES);

  // This read may be dependent on more than one write. This typically occurs
  // when a definition is the result of multiple writes where at least one
  // write does a partial register update.
  // The HW is forced to do some extra bookkeeping to track of all the
  // dependent writes, and implement a merging scheme for the partial writes.
  --DependentWrites;
  TotalCycles = std::max(TotalCycles, Cycles);

  if (!DependentWrites) {
    CyclesLeft = TotalCycles;
    IsReady = !CyclesLeft;
  }
}

void WriteState::onInstructionIssued() {
  assert(CyclesLeft == UNKNOWN_CYCLES);
  // Update the number of cycles left based on the WriteDescriptor info.
  CyclesLeft = getLatency();

  // Now that the time left before write-back is known, notify
  // all the users.
  for (const std::pair<ReadState *, int> &User : Users) {
    ReadState *RS = User.first;
    unsigned ReadCycles = std::max(0, CyclesLeft - User.second);
    RS->writeStartEvent(ReadCycles);
  }

  // Notify any writes that are in a false dependency with this write.
  if (PartialWrite)
    PartialWrite->writeStartEvent(CyclesLeft);
}

void WriteState::addUser(ReadState *User, int ReadAdvance) {
  // If CyclesLeft is different than -1, then we don't need to
  // update the list of users. We can just notify the user with
  // the actual number of cycles left (which may be zero).
  if (CyclesLeft != UNKNOWN_CYCLES) {
    unsigned ReadCycles = std::max(0, CyclesLeft - ReadAdvance);
    User->writeStartEvent(ReadCycles);
    return;
  }

  if (llvm::find_if(Users, [&User](const std::pair<ReadState *, int> &Use) {
        return Use.first == User;
      }) == Users.end()) {
    Users.emplace_back(User, ReadAdvance);
  }
}

void WriteState::addUser(WriteState *User) {
  if (CyclesLeft != UNKNOWN_CYCLES) {
    User->writeStartEvent(std::max(0, CyclesLeft));
    return;
  }

  assert(!PartialWrite && "PartialWrite already set!");
  PartialWrite = User;
  User->setDependentWrite(this);
}

void WriteState::cycleEvent() {
  // Note: CyclesLeft can be a negative number. It is an error to
  // make it an unsigned quantity because users of this write may
  // specify a negative ReadAdvance.
  if (CyclesLeft != UNKNOWN_CYCLES)
    CyclesLeft--;

  if (DependentWriteCyclesLeft)
    DependentWriteCyclesLeft--;
}

void ReadState::cycleEvent() {
  // Update the total number of cycles.
  if (DependentWrites && TotalCycles) {
    --TotalCycles;
    return;
  }

  // Bail out immediately if we don't know how many cycles are left.
  if (CyclesLeft == UNKNOWN_CYCLES)
    return;

  if (CyclesLeft) {
    --CyclesLeft;
    IsReady = !CyclesLeft;
  }
}

#ifndef NDEBUG
void WriteState::dump() const {
  dbgs() << "{ OpIdx=" << WD->OpIndex << ", Lat=" << getLatency() << ", RegID "
         << getRegisterID() << ", Cycles Left=" << getCyclesLeft() << " }";
}

void WriteRef::dump() const {
  dbgs() << "IID=" << getSourceIndex() << ' ';
  if (isValid())
    getWriteState()->dump();
  else
    dbgs() << "(null)";
}
#endif

void Instruction::dispatch(unsigned RCUToken) {
  assert(Stage == IS_INVALID);
  Stage = IS_AVAILABLE;
  RCUTokenID = RCUToken;

  // Check if input operands are already available.
  update();
}

void Instruction::execute() {
  assert(Stage == IS_READY);
  Stage = IS_EXECUTING;

  // Set the cycles left before the write-back stage.
  CyclesLeft = getLatency();

  for (WriteState &WS : getDefs())
    WS.onInstructionIssued();

  // Transition to the "executed" stage if this is a zero-latency instruction.
  if (!CyclesLeft)
    Stage = IS_EXECUTED;
}

void Instruction::forceExecuted() {
  assert(Stage == IS_READY && "Invalid internal state!");
  CyclesLeft = 0;
  Stage = IS_EXECUTED;
}

void Instruction::update() {
  assert(isDispatched() && "Unexpected instruction stage found!");

  if (!all_of(getUses(), [](const ReadState &Use) { return Use.isReady(); }))
    return;

  // A partial register write cannot complete before a dependent write.
  auto IsDefReady = [&](const WriteState &Def) {
    if (!Def.getDependentWrite()) {
      unsigned CyclesLeft = Def.getDependentWriteCyclesLeft();
      return !CyclesLeft || CyclesLeft < getLatency();
    }
    return false;
  };

  if (all_of(getDefs(), IsDefReady))
    Stage = IS_READY;
}

void Instruction::cycleEvent() {
  if (isReady())
    return;

  if (isDispatched()) {
    for (ReadState &Use : getUses())
      Use.cycleEvent();

    for (WriteState &Def : getDefs())
      Def.cycleEvent();

    update();
    return;
  }

  assert(isExecuting() && "Instruction not in-flight?");
  assert(CyclesLeft && "Instruction already executed?");
  for (WriteState &Def : getDefs())
    Def.cycleEvent();
  CyclesLeft--;
  if (!CyclesLeft)
    Stage = IS_EXECUTED;
}

const unsigned WriteRef::INVALID_IID = std::numeric_limits<unsigned>::max();

} // namespace mca
} // namespace llvm
<commit_msg>[MCA] Simplify the logic in method WriteState::addUser. NFCI<commit_after>//===--------------------- Instruction.cpp ----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file defines abstractions used by the Pipeline to model register reads,
// register writes and instructions.
//
//===----------------------------------------------------------------------===//

#include "llvm/MCA/Instruction.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/raw_ostream.h"

namespace llvm {
namespace mca {

void ReadState::writeStartEvent(unsigned Cycles) {
  assert(DependentWrites);
  assert(CyclesLeft == UNKNOWN_CYCLES);

  // This read may be dependent on more than one write. This typically occurs
  // when a definition is the result of multiple writes where at least one
  // write does a partial register update.
  // The HW is forced to do some extra bookkeeping to track of all the
  // dependent writes, and implement a merging scheme for the partial writes.
  --DependentWrites;
  TotalCycles = std::max(TotalCycles, Cycles);

  if (!DependentWrites) {
    CyclesLeft = TotalCycles;
    IsReady = !CyclesLeft;
  }
}

void WriteState::onInstructionIssued() {
  assert(CyclesLeft == UNKNOWN_CYCLES);
  // Update the number of cycles left based on the WriteDescriptor info.
  CyclesLeft = getLatency();

  // Now that the time left before write-back is known, notify
  // all the users.
  for (const std::pair<ReadState *, int> &User : Users) {
    ReadState *RS = User.first;
    unsigned ReadCycles = std::max(0, CyclesLeft - User.second);
    RS->writeStartEvent(ReadCycles);
  }

  // Notify any writes that are in a false dependency with this write.
  if (PartialWrite)
    PartialWrite->writeStartEvent(CyclesLeft);
}

void WriteState::addUser(ReadState *User, int ReadAdvance) {
  // If CyclesLeft is different than -1, then we don't need to
  // update the list of users. We can just notify the user with
  // the actual number of cycles left (which may be zero).
  if (CyclesLeft != UNKNOWN_CYCLES) {
    unsigned ReadCycles = std::max(0, CyclesLeft - ReadAdvance);
    User->writeStartEvent(ReadCycles);
    return;
  }

  Users.emplace_back(User, ReadAdvance);
}

void WriteState::addUser(WriteState *User) {
  if (CyclesLeft != UNKNOWN_CYCLES) {
    User->writeStartEvent(std::max(0, CyclesLeft));
    return;
  }

  assert(!PartialWrite && "PartialWrite already set!");
  PartialWrite = User;
  User->setDependentWrite(this);
}

void WriteState::cycleEvent() {
  // Note: CyclesLeft can be a negative number. It is an error to
  // make it an unsigned quantity because users of this write may
  // specify a negative ReadAdvance.
  if (CyclesLeft != UNKNOWN_CYCLES)
    CyclesLeft--;

  if (DependentWriteCyclesLeft)
    DependentWriteCyclesLeft--;
}

void ReadState::cycleEvent() {
  // Update the total number of cycles.
  if (DependentWrites && TotalCycles) {
    --TotalCycles;
    return;
  }

  // Bail out immediately if we don't know how many cycles are left.
  if (CyclesLeft == UNKNOWN_CYCLES)
    return;

  if (CyclesLeft) {
    --CyclesLeft;
    IsReady = !CyclesLeft;
  }
}

#ifndef NDEBUG
void WriteState::dump() const {
  dbgs() << "{ OpIdx=" << WD->OpIndex << ", Lat=" << getLatency() << ", RegID "
         << getRegisterID() << ", Cycles Left=" << getCyclesLeft() << " }";
}

void WriteRef::dump() const {
  dbgs() << "IID=" << getSourceIndex() << ' ';
  if (isValid())
    getWriteState()->dump();
  else
    dbgs() << "(null)";
}
#endif

void Instruction::dispatch(unsigned RCUToken) {
  assert(Stage == IS_INVALID);
  Stage = IS_AVAILABLE;
  RCUTokenID = RCUToken;

  // Check if input operands are already available.
  update();
}

void Instruction::execute() {
  assert(Stage == IS_READY);
  Stage = IS_EXECUTING;

  // Set the cycles left before the write-back stage.
  CyclesLeft = getLatency();

  for (WriteState &WS : getDefs())
    WS.onInstructionIssued();

  // Transition to the "executed" stage if this is a zero-latency instruction.
  if (!CyclesLeft)
    Stage = IS_EXECUTED;
}

void Instruction::forceExecuted() {
  assert(Stage == IS_READY && "Invalid internal state!");
  CyclesLeft = 0;
  Stage = IS_EXECUTED;
}

void Instruction::update() {
  assert(isDispatched() && "Unexpected instruction stage found!");

  if (!all_of(getUses(), [](const ReadState &Use) { return Use.isReady(); }))
    return;

  // A partial register write cannot complete before a dependent write.
  auto IsDefReady = [&](const WriteState &Def) {
    if (!Def.getDependentWrite()) {
      unsigned CyclesLeft = Def.getDependentWriteCyclesLeft();
      return !CyclesLeft || CyclesLeft < getLatency();
    }
    return false;
  };

  if (all_of(getDefs(), IsDefReady))
    Stage = IS_READY;
}

void Instruction::cycleEvent() {
  if (isReady())
    return;

  if (isDispatched()) {
    for (ReadState &Use : getUses())
      Use.cycleEvent();

    for (WriteState &Def : getDefs())
      Def.cycleEvent();

    update();
    return;
  }

  assert(isExecuting() && "Instruction not in-flight?");
  assert(CyclesLeft && "Instruction already executed?");
  for (WriteState &Def : getDefs())
    Def.cycleEvent();
  CyclesLeft--;
  if (!CyclesLeft)
    Stage = IS_EXECUTED;
}

const unsigned WriteRef::INVALID_IID = std::numeric_limits<unsigned>::max();

} // namespace mca
} // namespace llvm
<|endoftext|>


<commit_before>#include "io_utar.h"
#include "logger.h"
#include <fstream>
#include <cmath>
#include <cstdint>
#include <boost/iostreams/device/file.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/gzip.hpp>
#include <boost/iostreams/filter/bzip2.hpp>
#include <boost/iostreams/stream.hpp>
#include <boost/iostreams/device/array.hpp>
#include <boost/algorithm/string.hpp>

namespace ncv
{
        // http://techoverflow.net/blog/2013/03/29/reading-tar-files-in-c/

        namespace
        {
                using std::int64_t;
                using std::uint64_t;

                ///
                /// \brief convert an ascii digit to the corresponding number (assuming it is an ASCII digit)
                ///
                uint64_t ascii_to_number(unsigned char num)
                {
                        return ((num) - 48);
                }

                ///
                /// \brief decode a TAR octal number. ignores everything after the first NUL or space character.
                ///
                uint64_t decode_tar_octal(const char* data, size_t size = 12)
                {
                        const unsigned char* currentPtr = (const unsigned char*)data + size;

                        const unsigned char* checkPtr = currentPtr;
                        for (; checkPtr >= (const unsigned char*) data; checkPtr --)
                        {
                                if ((*checkPtr) == 0 || (*checkPtr) == ' ')
                                {
                                        currentPtr = checkPtr - 1;
                                }
                        }

                        uint64_t sum = 0;
                        uint64_t currentMultiplier = 1;
                        for (; currentPtr >= (const unsigned char*)data; currentPtr --)
                        {
                                sum += ascii_to_number(*currentPtr) * currentMultiplier;
                                currentMultiplier *= 8;
                        }

                        return sum;
                }

                struct TARFileHeader
                {
                        char filename[100];
                        char mode[8];
                        char uid[8];
                        char gid[8];
                        char fileSize[12];
                        char lastModification[12];
                        char checksum[8];
                        char typeFlag;
                        char linkedFileName[100];
                        char ustarIndicator[6];
                        char ustarVersion[2];
                        char ownerUserName[32];
                        char ownerGroupName[32];
                        char deviceMajorNumber[8];
                        char deviceMinorNumber[8];
                        char filenamePrefix[155];
                        char padding[12];

                        size_t filesize() const
                        {
                                return decode_tar_octal(fileSize);
                        }
                };
        }

        namespace
        {
                bool io_untar(
                        boost::iostreams::filtering_istream& in, const io::untar_callback_t& callback,
                        const std::string& info_header, const std::string& error_header)
                {
                        char zeroBlock[512];
                        memset(zeroBlock, 0, 512);

                        bool nextEntryHasLongName = false;
                        while (in)
                        {
                                TARFileHeader header;
                                in.read((char*)&header, 512);
                                if (memcmp(&header, zeroBlock, 512) == 0)
                                {
                                        log_info() << info_header << "found TAR end.";
                                        break;
                                }

                                // compose the filename
                                std::string filename(header.filename, std::min((size_t)100, strlen(header.filename)));
                                const size_t prefixLength = strlen(header.filenamePrefix);
                                if (prefixLength > 0)
                                {
                                        filename =
                                        std::string(header.filenamePrefix, std::min((size_t)155, prefixLength)) +
                                        "/" +
                                        filename;
                                }

                                if (header.typeFlag == '0' || header.typeFlag == 0)
                                {
                                        // handle GNU TAR long filenames
                                        if (nextEntryHasLongName)
                                        {
                                                filename = std::string(header.filename);
                                                in.read((char*) &header, 512);
                                                nextEntryHasLongName = false;
                                        }

                                        const size_t size = header.filesize();
                                        log_info() << info_header << "found file <" << filename << "> (" << size << " bytes).";

                                        //Read the file into memory
                                        //  This won't work for very large files -- use streaming methods there!
                                        {
                                                std::vector<unsigned char> filedata(size);

                                                char* const pdata = reinterpret_cast<char*>(filedata.data());
                                                in.read(pdata, size);

                                                // decode archive type
                                                if (boost::algorithm::iends_with(filename, ".gz"))
                                                {
                                                        boost::iostreams::filtering_istream in_;
                                                        in_.push(boost::iostreams::gzip_decompressor());
                                                        in_.push(boost::iostreams::basic_array_source<char>(pdata, filedata.size()));
                                                        if (!io_untar(in_, callback, info_header, error_header))
                                                        {
                                                                return false;
                                                        }
                                                }
                                                else if (boost::algorithm::iends_with(filename, ".bz2"))
                                                {
                                                        boost::iostreams::filtering_istream in_;
                                                        in_.push(boost::iostreams::bzip2_decompressor());
                                                        in_.push(boost::iostreams::basic_array_source<char>(pdata, filedata.size()));
                                                        if (!io_untar(in_, callback, info_header, error_header))
                                                        {
                                                                return false;
                                                        }
                                                }
                                                else if (boost::algorithm::iends_with(filename, ".tar"))
                                                {
                                                        // no decompression filter needed
                                                        boost::iostreams::filtering_istream in_;
                                                        in_.push(boost::iostreams::basic_array_source<char>(pdata, filedata.size()));
                                                        if (!io_untar(in_, callback, info_header, error_header))
                                                        {
                                                                return false;
                                                        }
                                                }
                                                else
                                                {
                                                        callback(filename, filedata);
                                                }
                                        }

                                        // ignore padding
                                        const size_t paddingBytes = (512 - (size % 512)) % 512;
                                        in.ignore(paddingBytes);
                                }

                                else if (header.typeFlag == '5')
                                {
                                        log_info() << info_header << "found directory <" << filename << ">.";
                                }

                                else if(header.typeFlag == 'L')
                                {
                                        nextEntryHasLongName = true;
                                }

                                else
                                {
                                        log_info() << info_header << "found unhandled TAR entry type <" << header.typeFlag << ">.";
                                }
                        }

                        // OK
                        return true;
                }
        }

        bool io::untar(
                const std::string& path, const untar_callback_t& callback,
                const std::string& info_header, const std::string& error_header)
        {
                std::ifstream fin(path.c_str(), std::ios_base::in | std::ios_base::binary);
                if (!fin.is_open())
                {
                        log_error() << error_header << "failed to open file <" << path << ">!";
                        return false;
                }

                boost::iostreams::filtering_istream in;

                // decode archive type
                if (boost::algorithm::iends_with(path, ".gz"))
                {
                        in.push(boost::iostreams::gzip_decompressor());
                }
                else if (boost::algorithm::iends_with(path, ".bz2"))
                {
                        in.push(boost::iostreams::bzip2_decompressor());
                }
                else if (boost::algorithm::iends_with(path, ".tar"))
                {
                        // no decompression filter needed
                }
                else
                {
                        log_error() << error_header << "unknown file suffix <" << path << ">!";
                        return false;
                }

                in.push(fin);

                return io_untar(in, callback, info_header, error_header);
        }
}
<commit_msg>handle .gz differently from .tar<commit_after>#include "io_utar.h"
#include "logger.h"
#include <fstream>
#include <cmath>
#include <cstdint>
#include <boost/iostreams/device/file.hpp>
#include <boost/iostreams/filtering_stream.hpp>
#include <boost/iostreams/filter/gzip.hpp>
#include <boost/iostreams/filter/bzip2.hpp>
#include <boost/iostreams/stream.hpp>
#include <boost/iostreams/device/array.hpp>
#include <boost/algorithm/string.hpp>

namespace ncv
{
        // http://techoverflow.net/blog/2013/03/29/reading-tar-files-in-c/

        namespace
        {
                using std::int64_t;
                using std::uint64_t;

                ///
                /// \brief convert an ascii digit to the corresponding number (assuming it is an ASCII digit)
                ///
                uint64_t ascii_to_number(unsigned char num)
                {
                        return ((num) - 48);
                }

                ///
                /// \brief decode a TAR octal number. ignores everything after the first NUL or space character.
                ///
                uint64_t decode_tar_octal(const char* data, size_t size = 12)
                {
                        const unsigned char* currentPtr = (const unsigned char*)data + size;

                        const unsigned char* checkPtr = currentPtr;
                        for (; checkPtr >= (const unsigned char*) data; checkPtr --)
                        {
                                if ((*checkPtr) == 0 || (*checkPtr) == ' ')
                                {
                                        currentPtr = checkPtr - 1;
                                }
                        }

                        uint64_t sum = 0;
                        uint64_t currentMultiplier = 1;
                        for (; currentPtr >= (const unsigned char*)data; currentPtr --)
                        {
                                sum += ascii_to_number(*currentPtr) * currentMultiplier;
                                currentMultiplier *= 8;
                        }

                        return sum;
                }

                struct TARFileHeader
                {
                        char filename[100];
                        char mode[8];
                        char uid[8];
                        char gid[8];
                        char fileSize[12];
                        char lastModification[12];
                        char checksum[8];
                        char typeFlag;
                        char linkedFileName[100];
                        char ustarIndicator[6];
                        char ustarVersion[2];
                        char ownerUserName[32];
                        char ownerGroupName[32];
                        char deviceMajorNumber[8];
                        char deviceMinorNumber[8];
                        char filenamePrefix[155];
                        char padding[12];

                        size_t filesize() const
                        {
                                return decode_tar_octal(fileSize);
                        }
                };
        }

        namespace
        {
                bool io_untar(
                        boost::iostreams::filtering_istream& in, const io::untar_callback_t& callback,
                        const std::string& info_header, const std::string& error_header)
                {
                        char zeroBlock[512];
                        memset(zeroBlock, 0, 512);

                        bool nextEntryHasLongName = false;
                        while (in)
                        {
                                TARFileHeader header;
                                in.read((char*)&header, 512);
                                if (memcmp(&header, zeroBlock, 512) == 0)
                                {
                                        log_info() << info_header << "found TAR end.";
                                        break;
                                }

                                // compose the filename
                                std::string filename(header.filename, std::min((size_t)100, strlen(header.filename)));
                                const size_t prefixLength = strlen(header.filenamePrefix);
                                if (prefixLength > 0)
                                {
                                        filename =
                                        std::string(header.filenamePrefix, std::min((size_t)155, prefixLength)) +
                                        "/" +
                                        filename;
                                }

                                if (header.typeFlag == '0' || header.typeFlag == 0)
                                {
                                        // handle GNU TAR long filenames
                                        if (nextEntryHasLongName)
                                        {
                                                filename = std::string(header.filename);
                                                in.read((char*) &header, 512);
                                                nextEntryHasLongName = false;
                                        }

                                        const size_t size = header.filesize();
                                        log_info() << info_header << "found file <" << filename << "> (" << size << " bytes).";

                                        //Read the file into memory
                                        //  This won't work for very large files -- use streaming methods there!
                                        {
                                                std::vector<unsigned char> filedata(size);

                                                char* const pdata = reinterpret_cast<char*>(filedata.data());
                                                in.read(pdata, size);

                                                // decode archive type
                                                if (boost::algorithm::iends_with(filename, ".gz"))
                                                {
                                                        boost::iostreams::filtering_istream in_;
                                                        in_.push(boost::iostreams::gzip_decompressor());
                                                        in_.push(boost::iostreams::basic_array_source<char>(pdata, filedata.size()));
                                                        if (!io_untar(in_, callback, info_header, error_header))
                                                        {
                                                                return false;
                                                        }
                                                }
                                                else if (boost::algorithm::iends_with(filename, ".bz2"))
                                                {
                                                        boost::iostreams::filtering_istream in_;
                                                        in_.push(boost::iostreams::bzip2_decompressor());
                                                        in_.push(boost::iostreams::basic_array_source<char>(pdata, filedata.size()));
                                                        if (!io_untar(in_, callback, info_header, error_header))
                                                        {
                                                                return false;
                                                        }
                                                }
                                                else if (boost::algorithm::iends_with(filename, ".tar"))
                                                {
                                                        // no decompression filter needed
                                                        boost::iostreams::filtering_istream in_;
                                                        in_.push(boost::iostreams::basic_array_source<char>(pdata, filedata.size()));
                                                        if (!io_untar(in_, callback, info_header, error_header))
                                                        {
                                                                return false;
                                                        }
                                                }
                                                else
                                                {
                                                        callback(filename, filedata);
                                                }
                                        }

                                        // ignore padding
                                        const size_t paddingBytes = (512 - (size % 512)) % 512;
                                        in.ignore(paddingBytes);
                                }

                                else if (header.typeFlag == '5')
                                {
                                        log_info() << info_header << "found directory <" << filename << ">.";
                                }

                                else if(header.typeFlag == 'L')
                                {
                                        nextEntryHasLongName = true;
                                }

                                else
                                {
                                        log_info() << info_header << "found unhandled TAR entry type <" << header.typeFlag << ">.";
                                }
                        }

                        // OK
                        return true;
                }
        }

        bool io::untar(
                const std::string& path, const untar_callback_t& callback,
                const std::string& info_header, const std::string& error_header)
        {
                std::ifstream fin(path.c_str(), std::ios_base::in | std::ios_base::binary);
                if (!fin.is_open())
                {
                        log_error() << error_header << "failed to open file <" << path << ">!";
                        return false;
                }

                boost::iostreams::filtering_istream in;

                // decode archive type
                if (boost::algorithm::iends_with(path, ".tar.gz"))
                {
                        in.push(boost::iostreams::gzip_decompressor());
                }
                else if (boost::algorithm::iends_with(path, ".tar.bz2"))
                {
                        in.push(boost::iostreams::bzip2_decompressor());
                }
                else if (boost::algorithm::iends_with(path, ".tar"))
                {
                        // no decompression filter needed
                }
                else if (boost::algorithm::iends_with(path, ".gz"))
                {
                        in.push(boost::iostreams::gzip_decompressor());
                        in.push(fin);

                        std::vector<unsigned char> filedata;

                        const size_t chunk = 4096;
                        char data[chunk];

                        std::streamsize read_size;
                        while ((read_size = boost::iostreams::read(in, data, chunk)) > 0)
                        {
                                filedata.insert(filedata.end(),
                                                reinterpret_cast<const unsigned char*>(data),
                                                reinterpret_cast<const unsigned char*>(data) + read_size);
                        }

                        callback(path, filedata);
                        return true;
                }
                else
                {
                        log_error() << error_header << "unknown file suffix <" << path << ">!";
                        return false;
                }

                in.push(fin);

                return io_untar(in, callback, info_header, error_header);
        }
}
<|endoftext|>


<commit_before>#include "DataBaseWriter.h"
#include "sqlite3.h"
#include "DBWrapper.h"

void CreateTables(DBWrapper &db)
{
	db.ExecuteStatement(NULL, NULL, CREATE_ONE_LOCATION_INFO_TABLE_STATEMENT);
	db.ExecuteStatement(NULL, NULL, CREATE_ONE_LOCATION_INFO_TABLE_FUNCTION_ADDRESS_INDEX_STATEMENT);
	db.ExecuteStatement(NULL, NULL, CREATE_ONE_LOCATION_INFO_TABLE_START_ADDRESS_INDEX_STATEMENT);
	db.ExecuteStatement(NULL, NULL, CREATE_ONE_LOCATION_INFO_TABLE_END_ADDRESS_INDEX_STATEMENT);
	db.ExecuteStatement(NULL, NULL, CREATE_MAP_INFO_TABLE_STATEMENT);
	db.ExecuteStatement(NULL, NULL, CREATE_MAP_INFO_TABLE_SRCBLOCK_INDEX_STATEMENT);
	db.ExecuteStatement(NULL, NULL, CREATE_FILE_INFO_TABLE_STATEMENT);
}

int DatabaseWriterWrapper(DBWrapper *db,BYTE Type,PBYTE Data,DWORD Length)
{
	static int FileID=0;
	bool Status=FALSE;
	static DWORD CurrentAddress=0L;

	switch(Type)
	{
		case ONE_LOCATION_INFO:
			if(sizeof(OneLocationInfo)<=Length)
			{
				POneLocationInfo pOneLocationInfo=(POneLocationInfo)Data;
				char *FingerprintHexStringBuffer=NULL;
				if(pOneLocationInfo->FingerprintLen>0)
				{
					FingerprintHexStringBuffer=(char *)malloc(pOneLocationInfo->FingerprintLen*2+10);
					if(FingerprintHexStringBuffer)
					{
						memset(FingerprintHexStringBuffer,0,pOneLocationInfo->FingerprintLen*2+10);
						char tmp_buffer[10];
						for(DWORD i=0;i<pOneLocationInfo->FingerprintLen;i++)
						{
							_snprintf(tmp_buffer,sizeof(tmp_buffer)-1,"%.2x",pOneLocationInfo->Data[pOneLocationInfo->NameLen+pOneLocationInfo->DisasmLinesLen+i]&0xff);
							tmp_buffer[sizeof(tmp_buffer)-1]=NULL;
							strncat(FingerprintHexStringBuffer,tmp_buffer,sizeof(tmp_buffer));
						}
					}
				}
				CurrentAddress=pOneLocationInfo->StartAddress;
				Status=db->ExecuteStatement(NULL,NULL,INSERT_ONE_LOCATION_INFO_TABLE_STATEMENT,
					FileID,
					pOneLocationInfo->StartAddress,
					pOneLocationInfo->EndAddress,
					pOneLocationInfo->Flag,
					pOneLocationInfo->FunctionAddress,
					pOneLocationInfo->BlockType,
					pOneLocationInfo->Data,
					pOneLocationInfo->Data+pOneLocationInfo->NameLen,
					FingerprintHexStringBuffer?FingerprintHexStringBuffer:""
					);
				if(FingerprintHexStringBuffer)
					free(FingerprintHexStringBuffer);
			}
			break;
		case MAP_INFO:
			if(sizeof(MapInfo)<=Length)
			{
				PMapInfo pMapInfo=(PMapInfo)Data;
				Status=db->ExecuteStatement(NULL,NULL,INSERT_MAP_INFO_TABLE_STATEMENT,
					FileID,
					pMapInfo->Type,
					pMapInfo->SrcBlock,
					pMapInfo->SrcBlockEnd,
					pMapInfo->Dst
					);
			}
			break;
		case FILE_INFO:
			if(sizeof(FileInfo)<=Length)
			{
				PFileInfo pFileInfo=(PFileInfo)Data;
				Status=db->ExecuteStatement(NULL,NULL,INSERT_FILE_INFO_TABLE_STATEMENT,
					pFileInfo->OriginalFilePath,
					pFileInfo->ComputerName,
					pFileInfo->UserName,
					pFileInfo->CompanyName,
					pFileInfo->FileVersion,
					pFileInfo->FileDescription,
					pFileInfo->InternalName,
					pFileInfo->ProductName,
					pFileInfo->ModifiedTime,
					pFileInfo->MD5Sum
					);
				FileID=db->GetLastInsertRowID();
			}
			break;
	}
	Status=TRUE;
	return FileID;
}

<commit_msg>Put new lines in code for readability<commit_after>#include "DataBaseWriter.h"
#include "sqlite3.h"
#include "DBWrapper.h"

void CreateTables(DBWrapper &db)
{
	db.ExecuteStatement(NULL, NULL, CREATE_ONE_LOCATION_INFO_TABLE_STATEMENT);
	db.ExecuteStatement(NULL, NULL, CREATE_ONE_LOCATION_INFO_TABLE_FUNCTION_ADDRESS_INDEX_STATEMENT);
	db.ExecuteStatement(NULL, NULL, CREATE_ONE_LOCATION_INFO_TABLE_START_ADDRESS_INDEX_STATEMENT);
	db.ExecuteStatement(NULL, NULL, CREATE_ONE_LOCATION_INFO_TABLE_END_ADDRESS_INDEX_STATEMENT);
	db.ExecuteStatement(NULL, NULL, CREATE_MAP_INFO_TABLE_STATEMENT);
	db.ExecuteStatement(NULL, NULL, CREATE_MAP_INFO_TABLE_SRCBLOCK_INDEX_STATEMENT);
	db.ExecuteStatement(NULL, NULL, CREATE_FILE_INFO_TABLE_STATEMENT);
}

int DatabaseWriterWrapper(DBWrapper *db,BYTE Type,PBYTE Data,DWORD Length)
{
	static int FileID=0;
	bool Status=FALSE;
	static DWORD CurrentAddress=0L;

	switch(Type)
	{
		case ONE_LOCATION_INFO:
			if(sizeof(OneLocationInfo)<=Length)
			{
				POneLocationInfo pOneLocationInfo=(POneLocationInfo)Data;
				char *FingerprintHexStringBuffer=NULL;
				if(pOneLocationInfo->FingerprintLen>0)
				{
					FingerprintHexStringBuffer=(char *)malloc(pOneLocationInfo->FingerprintLen*2+10);
					if(FingerprintHexStringBuffer)
					{
						memset(FingerprintHexStringBuffer,0,pOneLocationInfo->FingerprintLen*2+10);
						char tmp_buffer[10];
						for(DWORD i=0;i<pOneLocationInfo->FingerprintLen;i++)
						{
							_snprintf(tmp_buffer,sizeof(tmp_buffer)-1,"%.2x",pOneLocationInfo->Data[pOneLocationInfo->NameLen+pOneLocationInfo->DisasmLinesLen+i]&0xff);
							tmp_buffer[sizeof(tmp_buffer)-1]=NULL;
							strncat(FingerprintHexStringBuffer,tmp_buffer,sizeof(tmp_buffer));
						}
					}
				}

				CurrentAddress=pOneLocationInfo->StartAddress;
				Status=db->ExecuteStatement(NULL,NULL,INSERT_ONE_LOCATION_INFO_TABLE_STATEMENT,
					FileID,
					pOneLocationInfo->StartAddress,
					pOneLocationInfo->EndAddress,
					pOneLocationInfo->Flag,
					pOneLocationInfo->FunctionAddress,
					pOneLocationInfo->BlockType,
					pOneLocationInfo->Data,
					pOneLocationInfo->Data+pOneLocationInfo->NameLen,
					FingerprintHexStringBuffer?FingerprintHexStringBuffer:""
					);

				if(FingerprintHexStringBuffer)
					free(FingerprintHexStringBuffer);
			}
			break;

		case MAP_INFO:
			if(sizeof(MapInfo)<=Length)
			{
				PMapInfo pMapInfo=(PMapInfo)Data;
				Status=db->ExecuteStatement(NULL,NULL,INSERT_MAP_INFO_TABLE_STATEMENT,
					FileID,
					pMapInfo->Type,
					pMapInfo->SrcBlock,
					pMapInfo->SrcBlockEnd,
					pMapInfo->Dst
					);
			}
			break;

		case FILE_INFO:
			if(sizeof(FileInfo)<=Length)
			{
				PFileInfo pFileInfo=(PFileInfo)Data;
				Status=db->ExecuteStatement(NULL,NULL,INSERT_FILE_INFO_TABLE_STATEMENT,
					pFileInfo->OriginalFilePath,
					pFileInfo->ComputerName,
					pFileInfo->UserName,
					pFileInfo->CompanyName,
					pFileInfo->FileVersion,
					pFileInfo->FileDescription,
					pFileInfo->InternalName,
					pFileInfo->ProductName,
					pFileInfo->ModifiedTime,
					pFileInfo->MD5Sum
					);
				FileID=db->GetLastInsertRowID();
			}
			break;

	}
	Status=TRUE;
	return FileID;
}

<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: smplmailsuppl.hxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-07 20:10:29 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    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
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser 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
 *
 ************************************************************************/

#ifndef _SMPLMAILSUPPL_HXX_
#define _SMPLMAILSUPPL_HXX_

#ifndef _CPPUHELPER_COMPBASE2_HXX_
#include <cppuhelper/compbase2.hxx>
#endif

#ifndef _OSL_MUTEX_HXX_
#include <osl/mutex.hxx>
#endif

#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
#include <com/sun/star/lang/XServiceInfo.hpp>
#endif

#ifndef _COM_SUN_STAR_SYS_SHELL_XSYSTEMSHELLEXECUTE_HPP_
#include <com/sun/star/system/XSimpleMailClientSupplier.hpp>
#endif

#ifndef _SIMPLEMAPI_HXX_
#include "simplemapi.hxx"
#endif

class CSmplMailSupplBase
{
protected:
    osl::Mutex  m_aMutex;
};

class CSmplMailSuppl :
    public CSmplMailSupplBase,
    public  cppu::WeakComponentImplHelper2<
            com::sun::star::system::XSimpleMailClientSupplier,
            com::sun::star::lang::XServiceInfo >
{
public:
    CSmplMailSuppl( );
    ~CSmplMailSuppl( );

    // XSimpleMailClientSupplier
    virtual ::com::sun::star::uno::Reference< ::com::sun::star::system::XSimpleMailClient > SAL_CALL querySimpleMailClient(  )
        throw (::com::sun::star::uno::RuntimeException);

    // XServiceInfo
    virtual ::rtl::OUString SAL_CALL getImplementationName(  )
        throw(::com::sun::star::uno::RuntimeException);

    virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
        throw(::com::sun::star::uno::RuntimeException);

    virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  )
        throw(::com::sun::star::uno::RuntimeException);
};

#endif
<commit_msg>INTEGRATION: CWS changefileheader (1.3.216); FILE MERGED 2008/04/01 15:40:28 thb 1.3.216.3: #i85898# Stripping all external header guards 2008/04/01 12:41:17 thb 1.3.216.2: #i85898# Stripping all external header guards 2008/03/31 13:17:15 rt 1.3.216.1: #i87441# Change license header to LPGL v3.<commit_after>/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: smplmailsuppl.hxx,v $
 * $Revision: 1.4 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org 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 Lesser General Public License version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

#ifndef _SMPLMAILSUPPL_HXX_
#define _SMPLMAILSUPPL_HXX_

#include <cppuhelper/compbase2.hxx>
#include <osl/mutex.hxx>
#include <com/sun/star/lang/XServiceInfo.hpp>

#ifndef _COM_SUN_STAR_SYS_SHELL_XSYSTEMSHELLEXECUTE_HPP_
#include <com/sun/star/system/XSimpleMailClientSupplier.hpp>
#endif

#ifndef _SIMPLEMAPI_HXX_
#include "simplemapi.hxx"
#endif

class CSmplMailSupplBase
{
protected:
    osl::Mutex  m_aMutex;
};

class CSmplMailSuppl :
    public CSmplMailSupplBase,
    public  cppu::WeakComponentImplHelper2<
            com::sun::star::system::XSimpleMailClientSupplier,
            com::sun::star::lang::XServiceInfo >
{
public:
    CSmplMailSuppl( );
    ~CSmplMailSuppl( );

    // XSimpleMailClientSupplier
    virtual ::com::sun::star::uno::Reference< ::com::sun::star::system::XSimpleMailClient > SAL_CALL querySimpleMailClient(  )
        throw (::com::sun::star::uno::RuntimeException);

    // XServiceInfo
    virtual ::rtl::OUString SAL_CALL getImplementationName(  )
        throw(::com::sun::star::uno::RuntimeException);

    virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName )
        throw(::com::sun::star::uno::RuntimeException);

    virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  )
        throw(::com::sun::star::uno::RuntimeException);
};

#endif
<|endoftext|>