<commit_before>#include <stingray/toolkit/Factory.h>

#include <stingray/toolkit/any.h>

#include <stingray/app/PushVideoOnDemand.h>
#include <stingray/app/activation_manager/ActivationIntent.h>
#include <stingray/app/application_context/AppChannel.h>
#include <stingray/app/application_context/ChannelList.h>
#include <stingray/app/scheduler/ScheduledEvents.h>
#include <stingray/app/tests/AutoFilter.h>
#include <stingray/app/zapper/User.h>
#include <stingray/ca/BasicSubscription.h>
#include <stingray/crypto/PlainCipherKey.h>
#include <stingray/details/IReceiverTrait.h>
#include <stingray/hdmi/IHDMI.h>
#include <stingray/media/ImageFileMediaData.h>
#include <stingray/media/MediaInfoBase.h>
#include <stingray/media/Mp3MediaInfo.h>
#include <stingray/media/formats/flv/MediaInfo.h>
#include <stingray/media/formats/mp4/MediaInfo.h>
#include <stingray/media/formats/mp4/Stream.h>
#include <stingray/media/formats/mp4/SubstreamDescriptors.h>
#include <stingray/mpeg/Stream.h>
#include <stingray/net/DHCPInterfaceConfiguration.h>
#include <stingray/net/IgnoredInterfaceConfiguration.h>
#include <stingray/net/LinkLocalInterfaceConfiguration.h>
#include <stingray/net/ManualInterfaceConfiguration.h>
#include <stingray/parentalcontrol/AgeRating.h>
#ifdef PLATFORM_EMU
#	include <stingray/platform/emu/scanner/Channel.h>
#endif
#ifdef PLATFORM_MSTAR
#	include <stingray/platform/mstar/crypto/HardwareCipherKey.h>
#endif
#ifdef PLATFORM_OPENSSL
#	include <stingray/platform/openssl/crypto/Certificate.h>
#endif
#ifdef PLATFORM_OPENSSL
#	include <stingray/platform/openssl/crypto/EvpKey.h>
#endif
#ifdef PLATFORM_STAPI
#	include <stingray/platform/stapi/crypto/HardwareCipherKey.h>
#endif
#include <stingray/records/FileSystemRecord.h>
#include <stingray/rpc/UrlObjectId.h>
#include <stingray/scanner/DVBServiceId.h>
#include <stingray/scanner/DefaultDVBTBandInfo.h>
#include <stingray/scanner/DefaultMpegService.h>
#include <stingray/scanner/DefaultMpegSubstreamDescriptor.h>
#include <stingray/scanner/DefaultScanParams.h>
#include <stingray/scanner/DreCasGeographicRegion.h>
#include <stingray/scanner/LybidScanParams.h>
#include <stingray/scanner/TerrestrialScanParams.h>
#include <stingray/scanner/TricolorGeographicRegion.h>
#include <stingray/scanner/TricolorScanParams.h>
#include <stingray/scanner/lybid/LybidServiceMetaInfo.h>
#include <stingray/scanner/terrestrial/TerrestrialServiceMetaInfo.h>
#include <stingray/scanner/tricolor/TricolorServiceMetaInfo.h>
#include <stingray/stats/ChannelViewingEventInfo.h>
#include <stingray/streams/PlaybackStreamContent.h>
#include <stingray/streams/RecordStreamContent.h>
#include <stingray/streams/RecordStreamMetaInfo.h>
#include <stingray/tuners/TunerState.h>
#include <stingray/tuners/dvbs/Antenna.h>
#include <stingray/tuners/dvbs/DefaultDVBSTransport.h>
#include <stingray/tuners/dvbs/Satellite.h>
#include <stingray/tuners/dvbt/DVBTTransport.h>
#include <stingray/tuners/ip/TsOverIpTransport.h>
#include <stingray/update/VersionRequirement.h>
#include <stingray/update/system/CopyFile.h>
#include <stingray/update/system/EraseFlashPartition.h>
#include <stingray/update/system/MountFilesystem.h>
#include <stingray/update/system/MoveFile.h>
#include <stingray/update/system/RemoveFile.h>
#include <stingray/update/system/UnmountFilesystem.h>
#include <stingray/update/system/WriteFlashPartition.h>

/* WARNING! This is autogenerated file, DO NOT EDIT! */

namespace stingray { namespace Detail
{
	void Factory::RegisterTypes()
	{
#ifdef BUILD_SHARED_LIB
		/*nothing*/
#else
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::PVODVideoInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::ActivationKeyIntent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::PersonalCodeIntent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::PlatformNameIntent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::ReceiverTraitIntent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::AppChannel);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::ChannelList);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::CinemaHallScheduledViewing);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::ContinuousScheduledEvent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::DeferredStandby);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::InfiniteScheduledEvent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::ScheduledEvent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::ScheduledRecord);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::ScheduledViewing);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::AutoFilter);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::User);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(BasicSubscription);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(BasicSubscriptionProvider);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(PlainCipherKey);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DVBCReceiverTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DVBSReceiverTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DVBTReceiverTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(HouseholdClientTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(HouseholdServerTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(LybidOperatorTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TricolorOperatorTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(HDMIConfig);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(ImageFileMediaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(ImageFileMediaPreview);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(InMemoryImageMediaPreview);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MediaInfoBase);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(Mp3MediaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(flv::MediaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(mp4::MediaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(mp4::Stream);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(mp4::Mp4MediaAudioSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(mp4::Mp4MediaVideoSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(mpeg::Stream);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DHCPInterfaceConfiguration);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(IgnoredInterfaceConfiguration);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(LinkLocalInterfaceConfiguration);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(ManualInterfaceConfiguration);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(AgeRating);
#ifdef PLATFORM_EMU
		TOOLKIT_REGISTER_CLASS_EXPLICIT(emu::EmuServiceId);
#endif
#ifdef PLATFORM_EMU
		TOOLKIT_REGISTER_CLASS_EXPLICIT(emu::RadioChannel);
#endif
#ifdef PLATFORM_EMU
		TOOLKIT_REGISTER_CLASS_EXPLICIT(emu::SubstreamDescriptor);
#endif
#ifdef PLATFORM_EMU
		TOOLKIT_REGISTER_CLASS_EXPLICIT(emu::TVChannel);
#endif
#ifdef PLATFORM_MSTAR
		TOOLKIT_REGISTER_CLASS_EXPLICIT(mstar::HardwareCipherKey);
#endif
#ifdef PLATFORM_OPENSSL
		TOOLKIT_REGISTER_CLASS_EXPLICIT(openssl::Certificate);
#endif
#ifdef PLATFORM_OPENSSL
		TOOLKIT_REGISTER_CLASS_EXPLICIT(openssl::EvpKey);
#endif
#ifdef PLATFORM_STAPI
		TOOLKIT_REGISTER_CLASS_EXPLICIT(stapi::HardwareCipherKey);
#endif
		TOOLKIT_REGISTER_CLASS_EXPLICIT(FileSystemRecord);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(rpc::UrlObjectId);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DVBServiceId);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DefaultDVBTBandInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DefaultMpegRadioChannel);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DefaultMpegService);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DefaultMpegTVChannel);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MpegAudioSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MpegDataCarouselSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MpegPcrSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MpegSubtitlesSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MpegTeletextBasedSubtitlesSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MpegTeletextSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MpegVideoSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DefaultScanParams);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DreCasGeographicRegion);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(LybidScanParams);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TerrestrialScanParams);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TricolorGeographicRegion);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TricolorScanParams);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(LybidServiceMetaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TerrestrialServiceMetaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TricolorServiceMetaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(::stingray::Detail::any::ObjectHolder<stingray::ChannelViewingEventInfo>);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(PlaybackStreamContent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(RecordStreamContent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(RecordStreamMetaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(CircuitedTunerState);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(LockedTunerState);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(UnlockedTunerState);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(Antenna);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DefaultDVBSTransport);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(Satellite);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DVBTTransport);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TsOverIpTransport);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(VersionRequirement);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(CopyFile);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(EraseFlashPartition);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MountFilesystem);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MoveFile);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(RemoveFile);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(UnmountFilesystem);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(WriteFlashPartition);
#endif
	}
}}
<commit_msg>update factory classes<commit_after>#include <stingray/toolkit/Factory.h>

#include <stingray/toolkit/any.h>

#include <stingray/app/PushVideoOnDemand.h>
#include <stingray/app/activation_manager/ActivationIntent.h>
#include <stingray/app/application_context/AppChannel.h>
#include <stingray/app/application_context/ChannelList.h>
#include <stingray/app/scheduler/ScheduledEvents.h>
#include <stingray/app/tests/AutoFilter.h>
#include <stingray/app/zapper/User.h>
#include <stingray/ca/BasicSubscription.h>
#include <stingray/crypto/PlainCipherKey.h>
#include <stingray/details/IReceiverTrait.h>
#include <stingray/hdmi/IHDMI.h>
#include <stingray/media/ImageFileMediaData.h>
#include <stingray/media/MediaInfoBase.h>
#include <stingray/media/Mp3MediaInfo.h>
#include <stingray/media/formats/flv/MediaInfo.h>
#include <stingray/media/formats/mp4/MediaInfo.h>
#include <stingray/media/formats/mp4/Stream.h>
#include <stingray/media/formats/mp4/SubstreamDescriptors.h>
#include <stingray/mpeg/Stream.h>
#include <stingray/net/DHCPInterfaceConfiguration.h>
#include <stingray/net/IgnoredInterfaceConfiguration.h>
#include <stingray/net/LinkLocalInterfaceConfiguration.h>
#include <stingray/net/ManualInterfaceConfiguration.h>
#include <stingray/parentalcontrol/AgeRating.h>
#ifdef PLATFORM_EMU
#	include <stingray/platform/emu/scanner/Channel.h>
#endif
#ifdef PLATFORM_MSTAR
#	include <stingray/platform/mstar/crypto/HardwareCipherKey.h>
#endif
#ifdef PLATFORM_OPENSSL
#	include <stingray/platform/openssl/crypto/Certificate.h>
#endif
#ifdef PLATFORM_OPENSSL
#	include <stingray/platform/openssl/crypto/EvpKey.h>
#endif
#ifdef PLATFORM_STAPI
#	include <stingray/platform/stapi/crypto/HardwareCipherKey.h>
#endif
#include <stingray/records/FileSystemRecord.h>
#include <stingray/rpc/UrlObjectId.h>
#include <stingray/scanner/DVBServiceId.h>
#include <stingray/scanner/DefaultDVBTBandInfo.h>
#include <stingray/scanner/DefaultMpegService.h>
#include <stingray/scanner/DefaultMpegSubstreamDescriptor.h>
#include <stingray/scanner/DefaultScanParams.h>
#include <stingray/scanner/DreCasGeographicRegion.h>
#include <stingray/scanner/LybidScanParams.h>
#include <stingray/scanner/TerrestrialScanParams.h>
#include <stingray/scanner/TricolorGeographicRegion.h>
#include <stingray/scanner/TricolorScanParams.h>
#include <stingray/scanner/lybid/LybidServiceMetaInfo.h>
#include <stingray/scanner/terrestrial/TerrestrialServiceMetaInfo.h>
#include <stingray/scanner/tricolor/TricolorServiceMetaInfo.h>
#include <stingray/stats/ChannelViewingEventInfo.h>
#include <stingray/streams/PlaybackStreamContent.h>
#include <stingray/streams/RecordStreamContent.h>
#include <stingray/streams/RecordStreamMetaInfo.h>
#include <stingray/tuners/TunerState.h>
#include <stingray/tuners/dvbs/Antenna.h>
#include <stingray/tuners/dvbs/DefaultDVBSTransport.h>
#include <stingray/tuners/dvbs/Satellite.h>
#include <stingray/tuners/dvbt/DVBTTransport.h>
#include <stingray/tuners/ip/TsOverIpTransport.h>
#include <stingray/update/VersionRequirement.h>
#include <stingray/update/system/CopyFile.h>
#include <stingray/update/system/EraseFlashPartition.h>
#include <stingray/update/system/MountFilesystem.h>
#include <stingray/update/system/MoveFile.h>
#include <stingray/update/system/RemoveFile.h>
#include <stingray/update/system/UnmountFilesystem.h>
#include <stingray/update/system/WriteFlashPartition.h>

/* WARNING! This is autogenerated file, DO NOT EDIT! */

namespace stingray { namespace Detail
{
	void Factory::RegisterTypes()
	{
#ifdef BUILD_SHARED_LIB
		/*nothing*/
#else
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::PVODVideoInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::ActivationKeyIntent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::PersonalCodeIntent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::PlatformNameIntent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::ReceiverTraitIntent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::AppChannel);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::ChannelList);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::CinemaHallScheduledViewing);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::ContinuousScheduledEvent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::DeferredStandby);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::InfiniteScheduledEvent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::ScheduledEvent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::ScheduledRecord);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::ScheduledViewing);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::AutoFilter);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(app::User);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(BasicSubscription);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(BasicSubscriptionProvider);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(PlainCipherKey);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DVBCReceiverTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DVBSReceiverTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DVBTReceiverTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(HouseholdClientTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(HouseholdServerTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(LybidOperatorTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TricolorOperatorTrait);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(HDMIConfig);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(ImageFileMediaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(ImageFileMediaPreview);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(InMemoryImageMediaPreview);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MediaInfoBase);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(Mp3MediaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(flv::MediaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(mp4::MediaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(mp4::Stream);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(mp4::Mp4MediaAudioSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(mp4::Mp4MediaVideoSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(mpeg::Stream);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DHCPInterfaceConfiguration);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(IgnoredInterfaceConfiguration);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(LinkLocalInterfaceConfiguration);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(ManualInterfaceConfiguration);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(AgeRating);
#ifdef PLATFORM_EMU
		TOOLKIT_REGISTER_CLASS_EXPLICIT(emu::EmuServiceId);
#endif
#ifdef PLATFORM_EMU
		TOOLKIT_REGISTER_CLASS_EXPLICIT(emu::RadioChannel);
#endif
#ifdef PLATFORM_EMU
		TOOLKIT_REGISTER_CLASS_EXPLICIT(emu::SubstreamDescriptor);
#endif
#ifdef PLATFORM_EMU
		TOOLKIT_REGISTER_CLASS_EXPLICIT(emu::TVChannel);
#endif
#ifdef PLATFORM_MSTAR
		TOOLKIT_REGISTER_CLASS_EXPLICIT(mstar::HardwareCipherKey);
#endif
#ifdef PLATFORM_OPENSSL
		TOOLKIT_REGISTER_CLASS_EXPLICIT(openssl::Certificate);
#endif
#ifdef PLATFORM_OPENSSL
		TOOLKIT_REGISTER_CLASS_EXPLICIT(openssl::EvpKey);
#endif
#ifdef PLATFORM_STAPI
		TOOLKIT_REGISTER_CLASS_EXPLICIT(stapi::HardwareCipherKey);
#endif
		TOOLKIT_REGISTER_CLASS_EXPLICIT(FileSystemRecord);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(rpc::UrlObjectId);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DVBServiceId);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DefaultDVBTBandInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DefaultMpegRadioChannel);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DefaultMpegService);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DefaultMpegTVChannel);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MpegAudioSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MpegDataCarouselSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MpegPcrSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MpegSubtitlesSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MpegTeletextBasedSubtitlesSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MpegTeletextSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MpegVideoSubstreamDescriptor);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DefaultScanParams);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DreCasGeographicRegion);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(LybidScanParams);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TerrestrialScanParams);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TricolorGeographicRegion);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TricolorScanParams);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(LybidServiceMetaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TerrestrialServiceMetaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TricolorServiceMetaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(Detail::any::ObjectHolder<stingray::ChannelViewingEventInfo>);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(PlaybackStreamContent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(RecordStreamContent);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(RecordStreamMetaInfo);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(CircuitedTunerState);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(LockedTunerState);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(UnlockedTunerState);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(Antenna);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DefaultDVBSTransport);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(Satellite);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(DVBTTransport);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(TsOverIpTransport);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(VersionRequirement);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(CopyFile);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(EraseFlashPartition);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MountFilesystem);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(MoveFile);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(RemoveFile);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(UnmountFilesystem);
		TOOLKIT_REGISTER_CLASS_EXPLICIT(WriteFlashPartition);
#endif
	}
}}
<|endoftext|>


<commit_before>#include <SFML/Graphics.hpp>

int main() {
	sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
	sf::CircleShape shape(100.f);
	shape.setFillColor(sf::Color::Green);

	while (window.isOpen()) {
		sf::Event event;
		while (window.pollEvent(event)) {
			if (event.type == sf::Event::Closed)
				window.close();
		}

		window.clear();
		window.draw(shape);
		window.display();
	}

	return EXIT_SUCCESS;
}<commit_msg>Define initial window dimensions<commit_after>#include <SFML/Graphics.hpp>

#define WINDOW_WIDTH 400
#define WINDOW_HEIGHT 400

int main() {
	sf::RenderWindow window(sf::VideoMode(WINDOW_WIDTH, WINDOW_HEIGHT), "Ninja Chess");
	sf::CircleShape shape(100.f);
	shape.setFillColor(sf::Color::Green);

	while (window.isOpen()) {
		sf::Event event;
		while (window.pollEvent(event)) {
			if (event.type == sf::Event::Closed)
				window.close();
		}

		window.clear();
		window.draw(shape);
		window.display();
	}

	return EXIT_SUCCESS;
}<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: wrtswtbl.hxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: cmc $ $Date: 2002-11-18 15:17:35 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 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
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#ifndef  _WRTSWTBL_HXX
#define  _WRTSWTBL_HXX

#ifndef _SOLAR_H
#include <tools/solar.h>
#endif
#ifndef _TOOLS_COLOR_HXX
#include <tools/color.hxx>
#endif
#ifndef _SVARRAY_HXX
#include <svtools/svarray.hxx>
#endif

#ifndef _ORNTENUM_HXX
#include <orntenum.hxx>
#endif
#ifndef _HORIORNT_HXX
#include <horiornt.hxx>
#endif

class Color;
class SwTableBox;
class SwTableBoxes;
class SwTableLine;
class SwTableLines;
class SwTable;
class SwFrmFmt;
class SwHTMLTableLayout;
class SvxBrushItem;
class SvxBoxItem;
class SvxBorderLine;

//---------------------------------------------------------------------------
//       Code aus dem HTML-Filter fuers schreiben von Tabellen
//---------------------------------------------------------------------------

#define COLFUZZY 20
#define ROWFUZZY 20
#define COL_DFLT_WIDTH ((2*COLFUZZY)+1)
#define ROW_DFLT_HEIGHT (2*ROWFUZZY)+1

//-----------------------------------------------------------------------

class SwWriteTableCell
{
    const SwTableBox *pBox;     // SwTableBox der Zelle
    const SvxBrushItem *pBackground;    // geerbter Hintergrund einer Zeile

    long nHeight;               // fixe/Mindest-Hoehe der Zeile

    USHORT nWidthOpt;           // Breite aus Option;

    USHORT nRow;                // Start-Zeile
    USHORT nCol;                // Start-Spalte

    USHORT nRowSpan;            // ueberspannte Zeilen
    USHORT nColSpan;            // ueberspannte Spalten

    BOOL bPrcWidthOpt;

public:

    SwWriteTableCell(const SwTableBox *pB, USHORT nR, USHORT nC, USHORT nRSpan,
        USHORT nCSpan, long nHght, const SvxBrushItem *pBGround)
    : pBox( pB ), pBackground( pBGround ), nHeight( nHght ), nWidthOpt( 0 ),
    nRow( nR ), nCol( nC ), nRowSpan( nRSpan ), nColSpan( nCSpan ),
    bPrcWidthOpt( FALSE )
    {}

    const SwTableBox *GetBox() const { return pBox; }

    USHORT GetRow() const { return nRow; }
    USHORT GetCol() const { return nCol; }

    USHORT GetRowSpan() const { return nRowSpan; }
    USHORT GetColSpan() const { return nColSpan; }

    long GetHeight() const { return nHeight; }
    SwVertOrient GetVertOri() const;

    const SvxBrushItem *GetBackground() const { return pBackground; }

    void SetWidthOpt( USHORT nWidth, BOOL bPrc )
    {
        nWidthOpt = nWidth; bPrcWidthOpt = bPrc;
    }

    USHORT GetWidthOpt() const { return nWidthOpt; }
    BOOL HasPrcWidthOpt() const { return bPrcWidthOpt; }
};

typedef SwWriteTableCell *SwWriteTableCellPtr;
SV_DECL_PTRARR_DEL( SwWriteTableCells, SwWriteTableCellPtr, 5, 5 )

//-----------------------------------------------------------------------

class SwWriteTableRow
{
    SwWriteTableCells aCells;       // Alle Zellen der Rows
    const SvxBrushItem *pBackground;// Hintergrund

    long nPos;                  // End-Position (twips) der Zeile
    BOOL mbUseLayoutHeights;
public:

    USHORT nTopBorder;              // Dicke der oberen/unteren Umrandugen
    USHORT nBottomBorder;

    BOOL bTopBorder : 1;            // Welche Umrandungen sind da?
    BOOL bBottomBorder : 1;

    SwWriteTableRow( long nPos, BOOL bUseLayoutHeights );

    SwWriteTableCell *AddCell( const SwTableBox *pBox,
                                 USHORT nRow, USHORT nCol,
                                 USHORT nRowSpan, USHORT nColSpan,
                                 long nHeight,
                                 const SvxBrushItem *pBackground );

    void SetBackground( const SvxBrushItem *pBGround )
    {
        pBackground = pBGround;
    }
    const SvxBrushItem *GetBackground() const { return pBackground; }

    BOOL HasTopBorder() const                   { return bTopBorder; }
    BOOL HasBottomBorder() const                { return bBottomBorder; }

    long GetPos() const                         { return nPos; }
    const SwWriteTableCells& GetCells() const   { return aCells; }

    inline int operator==( const SwWriteTableRow& rRow ) const;
    inline int operator<( const SwWriteTableRow& rRow2 ) const;
};

inline int SwWriteTableRow::operator==( const SwWriteTableRow& rRow ) const
{
    // etwas Unschaerfe zulassen
    return (nPos >= rRow.nPos ?  nPos - rRow.nPos : rRow.nPos - nPos ) <=
        (mbUseLayoutHeights ? 0 : ROWFUZZY);
}

inline int SwWriteTableRow::operator<( const SwWriteTableRow& rRow ) const
{
    // Da wir hier nur die Wahrheits-Grade 0 und 1 kennen, lassen wir lieber
    // auch nicht zu, dass x==y und x<y gleichzeitig gilt ;-)
    return nPos < rRow.nPos - (mbUseLayoutHeights ? 0 : ROWFUZZY);
}

typedef SwWriteTableRow *SwWriteTableRowPtr;
SV_DECL_PTRARR_SORT_DEL( SwWriteTableRows, SwWriteTableRowPtr, 5, 5 )

//-----------------------------------------------------------------------

class SwWriteTableCol
{
    USHORT nPos;                        // End Position der Spalte

    USHORT nWidthOpt;

    BOOL bRelWidthOpt : 1;
    BOOL bOutWidth : 1;                 // Spaltenbreite ausgeben?

public:
    BOOL bLeftBorder : 1;               // Welche Umrandungen sind da?
    BOOL bRightBorder : 1;

    SwWriteTableCol( USHORT nPosition );

    USHORT GetPos() const                       { return nPos; }

    void SetLeftBorder( BOOL bBorder )          { bLeftBorder = bBorder; }
    BOOL HasLeftBorder() const                  { return bLeftBorder; }

    void SetRightBorder( BOOL bBorder )         { bRightBorder = bBorder; }
    BOOL HasRightBorder() const                 { return bRightBorder; }

    void SetOutWidth( BOOL bSet )               { bOutWidth = bSet; }
    BOOL GetOutWidth() const                    { return bOutWidth; }

    inline int operator==( const SwWriteTableCol& rCol ) const;
    inline int operator<( const SwWriteTableCol& rCol ) const;

    void SetWidthOpt( USHORT nWidth, BOOL bRel )
    {
        nWidthOpt = nWidth; bRelWidthOpt = bRel;
    }
    USHORT GetWidthOpt() const                  { return nWidthOpt; }
    BOOL HasRelWidthOpt() const                 { return bRelWidthOpt; }
};

inline int SwWriteTableCol::operator==( const SwWriteTableCol& rCol ) const
{
    // etwas Unschaerfe zulassen
    return (nPos >= rCol.nPos ? nPos - rCol.nPos
                                     : rCol.nPos - nPos ) <= COLFUZZY;
}

inline int SwWriteTableCol::operator<( const SwWriteTableCol& rCol ) const
{
    // Da wir hier nur die Wahrheits-Grade 0 und 1 kennen, lassen wir lieber
    // auch nicht zu, dass x==y und x<y gleichzeitig gilt ;-)
    return nPos < rCol.nPos - COLFUZZY;
}

typedef SwWriteTableCol *SwWriteTableColPtr;
SV_DECL_PTRARR_SORT_DEL( SwWriteTableCols, SwWriteTableColPtr, 5, 5 )

//-----------------------------------------------------------------------

class SwWriteTable
{
protected:
    SwWriteTableCols aCols; // alle Spalten
    SwWriteTableRows aRows; // alle Zellen

    UINT32 nBorderColor;        // Umrandungsfarbe

    USHORT nCellSpacing;        // Dicke der inneren Umrandung
    USHORT nCellPadding;        // Absatnd Umrandung-Inhalt

    USHORT nBorder;             // Dicke der ausseren Umrandung
    USHORT nInnerBorder;        // Dicke der inneren Umrandung
    USHORT nBaseWidth;          // Bezugsgroesse fur Breiten SwFmtFrmSize

    USHORT nHeadEndRow;         // letzte Zeile des Tabellen-Kopfes

    USHORT nLeftSub;
    USHORT nRightSub;

    long nTabWidth;             // Absolute/Relative Breite der Tabelle

    BOOL bRelWidths : 1;        // Breiten relativ ausgeben?
    BOOL bUseLayoutHeights : 1; // Layout zur Hoehenbestimmung nehmen?
#ifndef PRODUCT
    BOOL bGetLineHeightCalled : 1;
#endif

    BOOL bColsOption : 1;
    BOOL bColTags : 1;
    BOOL bLayoutExport : 1;
    BOOL bCollectBorderWidth : 1;

    virtual BOOL ShouldExpandSub( const SwTableBox *pBox,
                                BOOL bExpandedBefore, USHORT nDepth ) const;

    void CollectTableRowsCols( long nStartRPos, USHORT nStartCPos,
                               long nParentLineHeight,
                               USHORT nParentLineWidth,
                               const SwTableLines& rLines,
                               USHORT nDepth );

    void FillTableRowsCols( long nStartRPos, USHORT nStartRow,
                            USHORT nStartCPos, USHORT nStartCol,
                            long nParentLineHeight,
                            USHORT nParentLineWidth,
                            const SwTableLines& rLines,
                            const SvxBrushItem* pLineBrush,
                            USHORT nDepth );

    void MergeBorders( const SvxBorderLine* pBorderLine, BOOL bTable );

    USHORT MergeBoxBorders( const SwTableBox *pBox, USHORT nRow, USHORT nCol,
                            USHORT nRowSpan, USHORT nColSpan,
                            USHORT &rTopBorder, USHORT &rBottomBorder );

    USHORT GetBaseWidth() const { return nBaseWidth; }

    BOOL HasRelWidths() const { return bRelWidths; }

public:
    static long GetBoxWidth( const SwTableBox *pBox );
protected:

    long GetLineHeight( const SwTableLine *pLine );
    long GetLineHeight( const SwTableBox *pBox ) const;
    const SvxBrushItem *GetLineBrush( const SwTableBox *pBox,
                                      SwWriteTableRow *pRow );

    USHORT GetLeftSpace( USHORT nCol ) const;
    USHORT GetRightSpace( USHORT nCol, USHORT nColSpan ) const;

    USHORT GetRawWidth( USHORT nCol, USHORT nColSpan ) const;
    USHORT GetAbsWidth( USHORT nCol, USHORT nColSpan ) const;
    USHORT GetRelWidth( USHORT nCol, USHORT nColSpan ) const;
    USHORT GetPrcWidth( USHORT nCol, USHORT nColSpan ) const;

    long GetAbsHeight( long nRawWidth, USHORT nRow, USHORT nRowSpan ) const;

public:
    SwWriteTable( const SwTableLines& rLines, long nWidth, USHORT nBWidth,
                    BOOL bRel, USHORT nMaxDepth = USHRT_MAX,
                    USHORT nLeftSub=0, USHORT nRightSub=0 );
    SwWriteTable( const SwHTMLTableLayout *pLayoutInfo );

    const SwWriteTableCols& GetCols() const { return aCols; }
    const SwWriteTableRows& GetRows() const { return aRows; }
};

#endif

<commit_msg>INTEGRATION: CWS mullingarfilterteam18 (1.3.444); FILE MERGED 2003/11/17 13:59:26 cmc 1.3.444.1: #i9055# add dtor to SwWriteTable<commit_after>/*************************************************************************
 *
 *  $RCSfile: wrtswtbl.hxx,v $
 *
 *  $Revision: 1.4 $
 *
 *  last change: $Author: obo $ $Date: 2004-01-13 16:46:57 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 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
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/

#ifndef  _WRTSWTBL_HXX
#define  _WRTSWTBL_HXX

#ifndef _SOLAR_H
#include <tools/solar.h>
#endif
#ifndef _TOOLS_COLOR_HXX
#include <tools/color.hxx>
#endif
#ifndef _SVARRAY_HXX
#include <svtools/svarray.hxx>
#endif

#ifndef _ORNTENUM_HXX
#include <orntenum.hxx>
#endif
#ifndef _HORIORNT_HXX
#include <horiornt.hxx>
#endif

class Color;
class SwTableBox;
class SwTableBoxes;
class SwTableLine;
class SwTableLines;
class SwTable;
class SwFrmFmt;
class SwHTMLTableLayout;
class SvxBrushItem;
class SvxBoxItem;
class SvxBorderLine;

//---------------------------------------------------------------------------
//       Code aus dem HTML-Filter fuers schreiben von Tabellen
//---------------------------------------------------------------------------

#define COLFUZZY 20
#define ROWFUZZY 20
#define COL_DFLT_WIDTH ((2*COLFUZZY)+1)
#define ROW_DFLT_HEIGHT (2*ROWFUZZY)+1

//-----------------------------------------------------------------------

class SwWriteTableCell
{
    const SwTableBox *pBox;     // SwTableBox der Zelle
    const SvxBrushItem *pBackground;    // geerbter Hintergrund einer Zeile

    long nHeight;               // fixe/Mindest-Hoehe der Zeile

    USHORT nWidthOpt;           // Breite aus Option;

    USHORT nRow;                // Start-Zeile
    USHORT nCol;                // Start-Spalte

    USHORT nRowSpan;            // ueberspannte Zeilen
    USHORT nColSpan;            // ueberspannte Spalten

    BOOL bPrcWidthOpt;

public:

    SwWriteTableCell(const SwTableBox *pB, USHORT nR, USHORT nC, USHORT nRSpan,
        USHORT nCSpan, long nHght, const SvxBrushItem *pBGround)
    : pBox( pB ), pBackground( pBGround ), nHeight( nHght ), nWidthOpt( 0 ),
    nRow( nR ), nCol( nC ), nRowSpan( nRSpan ), nColSpan( nCSpan ),
    bPrcWidthOpt( FALSE )
    {}

    const SwTableBox *GetBox() const { return pBox; }

    USHORT GetRow() const { return nRow; }
    USHORT GetCol() const { return nCol; }

    USHORT GetRowSpan() const { return nRowSpan; }
    USHORT GetColSpan() const { return nColSpan; }

    long GetHeight() const { return nHeight; }
    SwVertOrient GetVertOri() const;

    const SvxBrushItem *GetBackground() const { return pBackground; }

    void SetWidthOpt( USHORT nWidth, BOOL bPrc )
    {
        nWidthOpt = nWidth; bPrcWidthOpt = bPrc;
    }

    USHORT GetWidthOpt() const { return nWidthOpt; }
    BOOL HasPrcWidthOpt() const { return bPrcWidthOpt; }
};

typedef SwWriteTableCell *SwWriteTableCellPtr;
SV_DECL_PTRARR_DEL( SwWriteTableCells, SwWriteTableCellPtr, 5, 5 )

//-----------------------------------------------------------------------

class SwWriteTableRow
{
    SwWriteTableCells aCells;       // Alle Zellen der Rows
    const SvxBrushItem *pBackground;// Hintergrund

    long nPos;                  // End-Position (twips) der Zeile
    BOOL mbUseLayoutHeights;
public:

    USHORT nTopBorder;              // Dicke der oberen/unteren Umrandugen
    USHORT nBottomBorder;

    BOOL bTopBorder : 1;            // Welche Umrandungen sind da?
    BOOL bBottomBorder : 1;

    SwWriteTableRow( long nPos, BOOL bUseLayoutHeights );

    SwWriteTableCell *AddCell( const SwTableBox *pBox,
                                 USHORT nRow, USHORT nCol,
                                 USHORT nRowSpan, USHORT nColSpan,
                                 long nHeight,
                                 const SvxBrushItem *pBackground );

    void SetBackground( const SvxBrushItem *pBGround )
    {
        pBackground = pBGround;
    }
    const SvxBrushItem *GetBackground() const { return pBackground; }

    BOOL HasTopBorder() const                   { return bTopBorder; }
    BOOL HasBottomBorder() const                { return bBottomBorder; }

    long GetPos() const                         { return nPos; }
    const SwWriteTableCells& GetCells() const   { return aCells; }

    inline int operator==( const SwWriteTableRow& rRow ) const;
    inline int operator<( const SwWriteTableRow& rRow2 ) const;
};

inline int SwWriteTableRow::operator==( const SwWriteTableRow& rRow ) const
{
    // etwas Unschaerfe zulassen
    return (nPos >= rRow.nPos ?  nPos - rRow.nPos : rRow.nPos - nPos ) <=
        (mbUseLayoutHeights ? 0 : ROWFUZZY);
}

inline int SwWriteTableRow::operator<( const SwWriteTableRow& rRow ) const
{
    // Da wir hier nur die Wahrheits-Grade 0 und 1 kennen, lassen wir lieber
    // auch nicht zu, dass x==y und x<y gleichzeitig gilt ;-)
    return nPos < rRow.nPos - (mbUseLayoutHeights ? 0 : ROWFUZZY);
}

typedef SwWriteTableRow *SwWriteTableRowPtr;
SV_DECL_PTRARR_SORT_DEL( SwWriteTableRows, SwWriteTableRowPtr, 5, 5 )

//-----------------------------------------------------------------------

class SwWriteTableCol
{
    USHORT nPos;                        // End Position der Spalte

    USHORT nWidthOpt;

    BOOL bRelWidthOpt : 1;
    BOOL bOutWidth : 1;                 // Spaltenbreite ausgeben?

public:
    BOOL bLeftBorder : 1;               // Welche Umrandungen sind da?
    BOOL bRightBorder : 1;

    SwWriteTableCol( USHORT nPosition );

    USHORT GetPos() const                       { return nPos; }

    void SetLeftBorder( BOOL bBorder )          { bLeftBorder = bBorder; }
    BOOL HasLeftBorder() const                  { return bLeftBorder; }

    void SetRightBorder( BOOL bBorder )         { bRightBorder = bBorder; }
    BOOL HasRightBorder() const                 { return bRightBorder; }

    void SetOutWidth( BOOL bSet )               { bOutWidth = bSet; }
    BOOL GetOutWidth() const                    { return bOutWidth; }

    inline int operator==( const SwWriteTableCol& rCol ) const;
    inline int operator<( const SwWriteTableCol& rCol ) const;

    void SetWidthOpt( USHORT nWidth, BOOL bRel )
    {
        nWidthOpt = nWidth; bRelWidthOpt = bRel;
    }
    USHORT GetWidthOpt() const                  { return nWidthOpt; }
    BOOL HasRelWidthOpt() const                 { return bRelWidthOpt; }
};

inline int SwWriteTableCol::operator==( const SwWriteTableCol& rCol ) const
{
    // etwas Unschaerfe zulassen
    return (nPos >= rCol.nPos ? nPos - rCol.nPos
                                     : rCol.nPos - nPos ) <= COLFUZZY;
}

inline int SwWriteTableCol::operator<( const SwWriteTableCol& rCol ) const
{
    // Da wir hier nur die Wahrheits-Grade 0 und 1 kennen, lassen wir lieber
    // auch nicht zu, dass x==y und x<y gleichzeitig gilt ;-)
    return nPos < rCol.nPos - COLFUZZY;
}

typedef SwWriteTableCol *SwWriteTableColPtr;
SV_DECL_PTRARR_SORT_DEL( SwWriteTableCols, SwWriteTableColPtr, 5, 5 )

//-----------------------------------------------------------------------

class SwWriteTable
{
protected:
    SwWriteTableCols aCols; // alle Spalten
    SwWriteTableRows aRows; // alle Zellen

    UINT32 nBorderColor;        // Umrandungsfarbe

    USHORT nCellSpacing;        // Dicke der inneren Umrandung
    USHORT nCellPadding;        // Absatnd Umrandung-Inhalt

    USHORT nBorder;             // Dicke der ausseren Umrandung
    USHORT nInnerBorder;        // Dicke der inneren Umrandung
    USHORT nBaseWidth;          // Bezugsgroesse fur Breiten SwFmtFrmSize

    USHORT nHeadEndRow;         // letzte Zeile des Tabellen-Kopfes

    USHORT nLeftSub;
    USHORT nRightSub;

    long nTabWidth;             // Absolute/Relative Breite der Tabelle

    BOOL bRelWidths : 1;        // Breiten relativ ausgeben?
    BOOL bUseLayoutHeights : 1; // Layout zur Hoehenbestimmung nehmen?
#ifndef PRODUCT
    BOOL bGetLineHeightCalled : 1;
#endif

    BOOL bColsOption : 1;
    BOOL bColTags : 1;
    BOOL bLayoutExport : 1;
    BOOL bCollectBorderWidth : 1;

    virtual BOOL ShouldExpandSub( const SwTableBox *pBox,
                                BOOL bExpandedBefore, USHORT nDepth ) const;

    void CollectTableRowsCols( long nStartRPos, USHORT nStartCPos,
                               long nParentLineHeight,
                               USHORT nParentLineWidth,
                               const SwTableLines& rLines,
                               USHORT nDepth );

    void FillTableRowsCols( long nStartRPos, USHORT nStartRow,
                            USHORT nStartCPos, USHORT nStartCol,
                            long nParentLineHeight,
                            USHORT nParentLineWidth,
                            const SwTableLines& rLines,
                            const SvxBrushItem* pLineBrush,
                            USHORT nDepth );

    void MergeBorders( const SvxBorderLine* pBorderLine, BOOL bTable );

    USHORT MergeBoxBorders( const SwTableBox *pBox, USHORT nRow, USHORT nCol,
                            USHORT nRowSpan, USHORT nColSpan,
                            USHORT &rTopBorder, USHORT &rBottomBorder );

    USHORT GetBaseWidth() const { return nBaseWidth; }

    BOOL HasRelWidths() const { return bRelWidths; }

public:
    static long GetBoxWidth( const SwTableBox *pBox );
protected:

    long GetLineHeight( const SwTableLine *pLine );
    long GetLineHeight( const SwTableBox *pBox ) const;
    const SvxBrushItem *GetLineBrush( const SwTableBox *pBox,
                                      SwWriteTableRow *pRow );

    USHORT GetLeftSpace( USHORT nCol ) const;
    USHORT GetRightSpace( USHORT nCol, USHORT nColSpan ) const;

    USHORT GetRawWidth( USHORT nCol, USHORT nColSpan ) const;
    USHORT GetAbsWidth( USHORT nCol, USHORT nColSpan ) const;
    USHORT GetRelWidth( USHORT nCol, USHORT nColSpan ) const;
    USHORT GetPrcWidth( USHORT nCol, USHORT nColSpan ) const;

    long GetAbsHeight( long nRawWidth, USHORT nRow, USHORT nRowSpan ) const;

public:
    SwWriteTable( const SwTableLines& rLines, long nWidth, USHORT nBWidth,
                    BOOL bRel, USHORT nMaxDepth = USHRT_MAX,
                    USHORT nLeftSub=0, USHORT nRightSub=0 );
    SwWriteTable( const SwHTMLTableLayout *pLayoutInfo );
    virtual ~SwWriteTable();

    const SwWriteTableCols& GetCols() const { return aCols; }
    const SwWriteTableRows& GetRows() const { return aRows; }
};

#endif

<|endoftext|>


<commit_before>/*
 * Copyright 2011-2017 Branimir Karadzic. All rights reserved.
 * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
 */

#include <string>
#include <vector>

#include <bx/commandline.h>
#include <bx/crtimpl.h>
#include <bx/string.h>

class Bin2cWriter : public bx::WriterI
{
public:
	Bin2cWriter(bx::WriterI* _writer, const char* _name)
		: m_writer(_writer)
		, m_name(_name)
	{
	}

	virtual ~Bin2cWriter()
	{
	}

	virtual int32_t write(const void* _data, int32_t _size, bx::Error* /*_err*/ = NULL) override
	{
		const char* data = (const char*)_data;
		m_buffer.insert(m_buffer.end(), data, data+_size);
		return _size;
	}

	void finish()
	{
#define HEX_DUMP_WIDTH 16
#define HEX_DUMP_SPACE_WIDTH 96
#define HEX_DUMP_FORMAT "%-" BX_STRINGIZE(HEX_DUMP_SPACE_WIDTH) "." BX_STRINGIZE(HEX_DUMP_SPACE_WIDTH) "s"
		const uint8_t* data = &m_buffer[0];
		uint32_t size = (uint32_t)m_buffer.size();

		bx::writePrintf(m_writer, "static const uint8_t %s[%d] =\n{\n", m_name.c_str(), size);

		if (NULL != data)
		{
			char hex[HEX_DUMP_SPACE_WIDTH+1];
			char ascii[HEX_DUMP_WIDTH+1];
			uint32_t hexPos = 0;
			uint32_t asciiPos = 0;
			for (uint32_t ii = 0; ii < size; ++ii)
			{
				bx::snprintf(&hex[hexPos], sizeof(hex)-hexPos, "0x%02x, ", data[asciiPos]);
				hexPos += 6;

				ascii[asciiPos] = isprint(data[asciiPos]) && data[asciiPos] != '\\' ? data[asciiPos] : '.';
				asciiPos++;

				if (HEX_DUMP_WIDTH == asciiPos)
				{
					ascii[asciiPos] = '\0';
					bx::writePrintf(m_writer, "\t" HEX_DUMP_FORMAT "// %s\n", hex, ascii);
					data += asciiPos;
					hexPos = 0;
					asciiPos = 0;
				}
			}

			if (0 != asciiPos)
			{
				ascii[asciiPos] = '\0';
				bx::writePrintf(m_writer, "\t" HEX_DUMP_FORMAT "// %s\n", hex, ascii);
			}
		}

		bx::writePrintf(m_writer, "};\n");
#undef HEX_DUMP_WIDTH
#undef HEX_DUMP_SPACE_WIDTH
#undef HEX_DUMP_FORMAT

		m_buffer.clear();
	}

	bx::WriterI* m_writer;
	std::string m_filePath;
	std::string m_name;
	typedef std::vector<uint8_t> Buffer;
	Buffer m_buffer;
};

void help(const char* _error = NULL)
{
	bx::WriterI* stdOut = bx::getStdOut();

	if (NULL != _error)
	{
		bx::writePrintf(stdOut, "Error:\n%s\n\n", _error);
	}

	bx::writePrintf(stdOut
		, "bin2c, binary to C\n"
		  "Copyright 2011-2017 Branimir Karadzic. All rights reserved.\n"
		  "License: https://github.com/bkaradzic/bx#license-bsd-2-clause\n\n"
		);

	bx::writePrintf(stdOut
		, "Usage: bin2c -f <in> -o <out> -n <name>\n"

		  "\n"
		  "Options:\n"
		  "  -f <file path>    Input file path.\n"
		  "  -o <file path>    Output file path.\n"
		  "  -n <name>         Array name.\n"

		  "\n"
		  "For additional information, see https://github.com/bkaradzic/bx\n"
		);
}

int main(int _argc, const char* _argv[])
{
	bx::CommandLine cmdLine(_argc, _argv);

	if (cmdLine.hasArg('h', "help") )
	{
		help();
		return bx::kExitFailure;
	}

	const char* filePath = cmdLine.findOption('f');
	if (NULL == filePath)
	{
		help("Input file name must be specified.");
		return bx::kExitFailure;
	}

	const char* outFilePath = cmdLine.findOption('o');
	if (NULL == outFilePath)
	{
		help("Output file name must be specified.");
		return bx::kExitFailure;
	}

	const char* name = cmdLine.findOption('n');
	if (NULL == name)
	{
		name = "data";
	}

	void* data = NULL;
	uint32_t size = 0;

	bx::FileReader fr;
	if (bx::open(&fr, filePath) )
	{
		size = uint32_t(bx::getSize(&fr) );

		bx::DefaultAllocator allocator;
		data = BX_ALLOC(&allocator, size);
		bx::read(&fr, data, size);

		bx::FileWriter fw;
		if (bx::open(&fw, outFilePath) )
		{
			Bin2cWriter writer(&fw, name);
			bx::write(&writer, data, size);
			writer.finish();
			bx::close(&fw);
		}

		BX_FREE(&allocator, data);
	}

	return 0;
}
<commit_msg>Fixed build.<commit_after>/*
 * Copyright 2011-2017 Branimir Karadzic. All rights reserved.
 * License: https://github.com/bkaradzic/bx#license-bsd-2-clause
 */

#include <string>
#include <vector>

#include <bx/commandline.h>
#include <bx/file.h>
#include <bx/string.h>

class Bin2cWriter : public bx::WriterI
{
public:
	Bin2cWriter(bx::WriterI* _writer, const char* _name)
		: m_writer(_writer)
		, m_name(_name)
	{
	}

	virtual ~Bin2cWriter()
	{
	}

	virtual int32_t write(const void* _data, int32_t _size, bx::Error* /*_err*/ = NULL) override
	{
		const char* data = (const char*)_data;
		m_buffer.insert(m_buffer.end(), data, data+_size);
		return _size;
	}

	void finish()
	{
#define HEX_DUMP_WIDTH 16
#define HEX_DUMP_SPACE_WIDTH 96
#define HEX_DUMP_FORMAT "%-" BX_STRINGIZE(HEX_DUMP_SPACE_WIDTH) "." BX_STRINGIZE(HEX_DUMP_SPACE_WIDTH) "s"
		const uint8_t* data = &m_buffer[0];
		uint32_t size = (uint32_t)m_buffer.size();

		bx::writePrintf(m_writer, "static const uint8_t %s[%d] =\n{\n", m_name.c_str(), size);

		if (NULL != data)
		{
			char hex[HEX_DUMP_SPACE_WIDTH+1];
			char ascii[HEX_DUMP_WIDTH+1];
			uint32_t hexPos = 0;
			uint32_t asciiPos = 0;
			for (uint32_t ii = 0; ii < size; ++ii)
			{
				bx::snprintf(&hex[hexPos], sizeof(hex)-hexPos, "0x%02x, ", data[asciiPos]);
				hexPos += 6;

				ascii[asciiPos] = isprint(data[asciiPos]) && data[asciiPos] != '\\' ? data[asciiPos] : '.';
				asciiPos++;

				if (HEX_DUMP_WIDTH == asciiPos)
				{
					ascii[asciiPos] = '\0';
					bx::writePrintf(m_writer, "\t" HEX_DUMP_FORMAT "// %s\n", hex, ascii);
					data += asciiPos;
					hexPos = 0;
					asciiPos = 0;
				}
			}

			if (0 != asciiPos)
			{
				ascii[asciiPos] = '\0';
				bx::writePrintf(m_writer, "\t" HEX_DUMP_FORMAT "// %s\n", hex, ascii);
			}
		}

		bx::writePrintf(m_writer, "};\n");
#undef HEX_DUMP_WIDTH
#undef HEX_DUMP_SPACE_WIDTH
#undef HEX_DUMP_FORMAT

		m_buffer.clear();
	}

	bx::WriterI* m_writer;
	std::string m_filePath;
	std::string m_name;
	typedef std::vector<uint8_t> Buffer;
	Buffer m_buffer;
};

void help(const char* _error = NULL)
{
	bx::WriterI* stdOut = bx::getStdOut();

	if (NULL != _error)
	{
		bx::writePrintf(stdOut, "Error:\n%s\n\n", _error);
	}

	bx::writePrintf(stdOut
		, "bin2c, binary to C\n"
		  "Copyright 2011-2017 Branimir Karadzic. All rights reserved.\n"
		  "License: https://github.com/bkaradzic/bx#license-bsd-2-clause\n\n"
		);

	bx::writePrintf(stdOut
		, "Usage: bin2c -f <in> -o <out> -n <name>\n"

		  "\n"
		  "Options:\n"
		  "  -f <file path>    Input file path.\n"
		  "  -o <file path>    Output file path.\n"
		  "  -n <name>         Array name.\n"

		  "\n"
		  "For additional information, see https://github.com/bkaradzic/bx\n"
		);
}

int main(int _argc, const char* _argv[])
{
	bx::CommandLine cmdLine(_argc, _argv);

	if (cmdLine.hasArg('h', "help") )
	{
		help();
		return bx::kExitFailure;
	}

	const char* filePath = cmdLine.findOption('f');
	if (NULL == filePath)
	{
		help("Input file name must be specified.");
		return bx::kExitFailure;
	}

	const char* outFilePath = cmdLine.findOption('o');
	if (NULL == outFilePath)
	{
		help("Output file name must be specified.");
		return bx::kExitFailure;
	}

	const char* name = cmdLine.findOption('n');
	if (NULL == name)
	{
		name = "data";
	}

	void* data = NULL;
	uint32_t size = 0;

	bx::FileReader fr;
	if (bx::open(&fr, filePath) )
	{
		size = uint32_t(bx::getSize(&fr) );

		bx::DefaultAllocator allocator;
		data = BX_ALLOC(&allocator, size);
		bx::read(&fr, data, size);

		bx::FileWriter fw;
		if (bx::open(&fw, outFilePath) )
		{
			Bin2cWriter writer(&fw, name);
			bx::write(&writer, data, size);
			writer.finish();
			bx::close(&fw);
		}

		BX_FREE(&allocator, data);
	}

	return 0;
}
<|endoftext|>


<commit_before>//
// $Id$
//

#include "AVGSDLFontManager.h"
#include "AVGException.h"
#include "AVGPlayer.h"
#include "AVGLogger.h"
#include "AVGSDLFont.h"

#include <SDL/SDL_ttf.h>

#include <iostream>
#include <sstream>
#include <stdlib.h>

using namespace std;

AVGSDLFontManager::AVGSDLFontManager (const string& sFontPath)
    : AVGFontManager(sFontPath)
{
    if (!TTF_WasInit()) {
        int err = TTF_Init();
        if (err == -1) {
            AVG_TRACE(AVGPlayer::DEBUG_ERROR,
                    "Could not initialize SDL_ttf. Font support is broken.");
        }
    }
}

AVGSDLFontManager::~AVGSDLFontManager ()
{
    TTF_Quit();
}

IAVGFont * AVGSDLFontManager::loadFont(const string& Filename, int Size)
{
    return new AVGSDLFont(Filename, Size);
}

<commit_msg>Fixed init for some sdl_ttf versions<commit_after>//
// $Id$
//

#include "AVGSDLFontManager.h"
#include "AVGException.h"
#include "AVGPlayer.h"
#include "AVGLogger.h"
#include "AVGSDLFont.h"

#include <SDL/SDL_ttf.h>

#include <iostream>
#include <sstream>
#include <stdlib.h>

using namespace std;

AVGSDLFontManager::AVGSDLFontManager (const string& sFontPath)
    : AVGFontManager(sFontPath)
{
//    if (!TTF_WasInit()) {
        int err = TTF_Init();
        if (err == -1) {
            AVG_TRACE(AVGPlayer::DEBUG_ERROR,
                    "Could not initialize SDL_ttf. Font support is broken.");
        }
//    }
}

AVGSDLFontManager::~AVGSDLFontManager ()
{
    TTF_Quit();
}

IAVGFont * AVGSDLFontManager::loadFont(const string& Filename, int Size)
{
    return new AVGSDLFont(Filename, Size);
}

<|endoftext|>


<commit_before>#include <iostream>
#include <malloc.h>
#include <cstdlib>
#include "stxxl/bits/common/utils.h"

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

void print_malloc_stats()
{
    struct mallinfo info = mallinfo();
    STXXL_MSG("MALLOC statistics BEGIN");
    STXXL_MSG("===============================================================");
    STXXL_MSG("non-mmapped space allocated from system (bytes): " << info.arena);
    STXXL_MSG("number of free chunks                          : " << info.ordblks);
    STXXL_MSG("number of fastbin blocks                       : " << info.smblks);
    STXXL_MSG("number of chunks allocated via mmap()          : " << info.hblks);
    STXXL_MSG("total number of bytes allocated via mmap()     : " << info.hblkhd);
    STXXL_MSG("maximum total allocated space (bytes)          : " << info.usmblks);
    STXXL_MSG("space available in freed fastbin blocks (bytes): " << info.fsmblks);
    STXXL_MSG("number of bytes allocated and in use           : " << info.uordblks);
    STXXL_MSG("number of bytes allocated but not in use       : " << info.fordblks);
    STXXL_MSG("top-most, releasable (via malloc_trim) space   : " << info.keepcost);
    STXXL_MSG("================================================================");
}

int main(int argc, char * argv[])
{
    if (argc < 2)
    {
        cerr << "Usage: " << argv[0] << " bytes_to_allocate" << endl;
        return -1;
    }
    sbrk(128 * 1024 * 1024);
    cout << "Nothing allocated" << endl;
    print_malloc_stats();
    char tmp;
    cin >> tmp;
    const unsigned bytes = atoi(argv[1]);
    char * ptr = new char[bytes];
    cout << "Allocated " << bytes << " bytes" << endl;
    print_malloc_stats();
    delete[] ptr;
    cout << "Deallocated " << endl;
    print_malloc_stats();
}
<commit_msg>struct mallinfo is not available on macosx<commit_after>#include <iostream>
#ifndef __APPLE__
#include <malloc.h>
#endif
#include <cstdlib>
#include "stxxl/bits/common/utils.h"

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

void print_malloc_stats()
{
#ifndef __APPLE__
    struct mallinfo info = mallinfo();
    STXXL_MSG("MALLOC statistics BEGIN");
    STXXL_MSG("===============================================================");
    STXXL_MSG("non-mmapped space allocated from system (bytes): " << info.arena);
    STXXL_MSG("number of free chunks                          : " << info.ordblks);
    STXXL_MSG("number of fastbin blocks                       : " << info.smblks);
    STXXL_MSG("number of chunks allocated via mmap()          : " << info.hblks);
    STXXL_MSG("total number of bytes allocated via mmap()     : " << info.hblkhd);
    STXXL_MSG("maximum total allocated space (bytes)          : " << info.usmblks);
    STXXL_MSG("space available in freed fastbin blocks (bytes): " << info.fsmblks);
    STXXL_MSG("number of bytes allocated and in use           : " << info.uordblks);
    STXXL_MSG("number of bytes allocated but not in use       : " << info.fordblks);
    STXXL_MSG("top-most, releasable (via malloc_trim) space   : " << info.keepcost);
    STXXL_MSG("================================================================");
#else
    STXXL_MSG("MALLOC statistics are not supported on this platform");
#endif
}

int main(int argc, char * argv[])
{
    if (argc < 2)
    {
        cerr << "Usage: " << argv[0] << " bytes_to_allocate" << endl;
        return -1;
    }
    sbrk(128 * 1024 * 1024);
    cout << "Nothing allocated" << endl;
    print_malloc_stats();
    char tmp;
    cin >> tmp;
    const unsigned bytes = atoi(argv[1]);
    char * ptr = new char[bytes];
    cout << "Allocated " << bytes << " bytes" << endl;
    print_malloc_stats();
    delete[] ptr;
    cout << "Deallocated " << endl;
    print_malloc_stats();
}
<|endoftext|>


<commit_before>#include "Arduino.h"
#include <EBot.h>

#define IN1	6
#define IN2	7
#define IN3	8
#define IN4	9
#define ENA	5
#define ENB	11

#define	ServoPin	3

#define Echo	A4
#define Trig	A5

#define receiverpin	12

#define LS1 10
#define LS2 4
#define LS3 2

EBot::EBot() {
}

EBot::~EBot() {
}

void EBot::begin() {
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);
  pinMode(ENA, OUTPUT);
  pinMode(ENB, OUTPUT);
  pinMode(Echo, INPUT);
  pinMode(Trig, OUTPUT);
  servo.attach(ServoPin);
  servo.write(90);
}

void EBot::stop() {
  digitalWrite(ENA, LOW);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  digitalWrite(ENB, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
}

void EBot::rightWheelForward() {
  digitalWrite(ENA, HIGH);
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
}

void EBot::rightWheelForward(int speed) {
  analogWrite(ENA, speed);
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
}

void EBot::rightWheelBackward() {
  digitalWrite(ENA, HIGH);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
}

void EBot::rightWheelBackward(int speed) {
  analogWrite(ENA, speed);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
}

void EBot::rightWheelStop() {
  digitalWrite(ENA, LOW);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
}

void EBot::leftWheelForward() {
  digitalWrite(ENB, HIGH);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
}

void EBot::leftWheelForward(int speed) {
  analogWrite(ENB, speed);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
}

void EBot::leftWheelBackward() {
  digitalWrite(ENB, HIGH);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
}

void EBot::leftWheelBackward(int speed) {
  analogWrite(ENB, speed);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
}

void EBot::leftWheelStop() {
  digitalWrite(ENB, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
}

void EBot::forward() {
  digitalWrite(ENA, HIGH);
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(ENB, HIGH);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
}

void EBot::forward(int speed) {
  analogWrite(ENA, speed);
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  analogWrite(ENB, speed);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
}

void EBot::backward() {
  digitalWrite(ENA, HIGH);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  digitalWrite(ENB, HIGH);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
}

void EBot::backward(int speed) {
  analogWrite(ENA, speed);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  analogWrite(ENB, speed);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
}

void EBot::rotateRight() {
  digitalWrite(ENA, HIGH);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  digitalWrite(ENB, HIGH);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
}

void EBot::rotateRight(int speed) {
  analogWrite(ENA, speed);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  analogWrite(ENB, speed);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
}

void EBot::rotateLeft() {
  digitalWrite(ENA, HIGH);
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(ENB, HIGH);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
}

void EBot::rotateLeft(int speed) {
  analogWrite(ENA, speed);
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  analogWrite(ENB, speed);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
}

void EBot::write(int angle) {
  angle = angle < 0 ? 0 : angle;
  angle = angle > 180 ? 180 : angle;

  servo.write(angle);
}

unsigned long EBot::distance() {
  unsigned long duration;

  digitalWrite(Trig, LOW);
  delayMicroseconds(2);
  digitalWrite(Trig, HIGH);
  delayMicroseconds(5);
  digitalWrite(Trig, LOW);
  duration = pulseIn(Echo, HIGH);

  return duration / 29 / 2;
}

bool EBot::readLS1() {
  return digitalRead(LS1);
}

bool EBot::readLS2() {
  return digitalRead(LS2);
}

bool EBot::readLS3() {
  return digitalRead(LS3);
}
<commit_msg>added security checks<commit_after>#include "Arduino.h"
#include <EBot.h>

#define IN1	6
#define IN2	7
#define IN3	8
#define IN4	9
#define ENA	5
#define ENB	11

#define	ServoPin	3

#define Echo	A4
#define Trig	A5

#define receiverpin	12

#define LS1 10
#define LS2 4
#define LS3 2

EBot::EBot() {
}

EBot::~EBot() {
}

void EBot::begin() {
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);
  pinMode(ENA, OUTPUT);
  pinMode(ENB, OUTPUT);
  pinMode(Echo, INPUT);
  pinMode(Trig, OUTPUT);
  servo.attach(ServoPin);
  servo.write(90);
}

void EBot::stop() {
  digitalWrite(ENA, LOW);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  digitalWrite(ENB, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
}

void EBot::rightWheelForward() {
  digitalWrite(ENA, HIGH);
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
}

void EBot::rightWheelForward(int speed) {
  speed = boundaries(speed, 0, 255);
  analogWrite(ENA, speed);
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
}

void EBot::rightWheelBackward() {
  digitalWrite(ENA, HIGH);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
}

void EBot::rightWheelBackward(int speed) {
  speed = boundaries(speed, 0, 255);

  analogWrite(ENA, speed);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
}

void EBot::rightWheelStop() {
  digitalWrite(ENA, LOW);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
}

void EBot::leftWheelForward() {
  digitalWrite(ENB, HIGH);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
}

void EBot::leftWheelForward(int speed) {
  speed = boundaries(speed, 0, 255);

  analogWrite(ENB, speed);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
}

void EBot::leftWheelBackward() {
  digitalWrite(ENB, HIGH);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
}

void EBot::leftWheelBackward(int speed) {
  speed = boundaries(speed, 0, 255);

  analogWrite(ENB, speed);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
}

void EBot::leftWheelStop() {
  digitalWrite(ENB, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
}

void EBot::forward() {
  digitalWrite(ENA, HIGH);
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(ENB, HIGH);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
}

void EBot::forward(int speed) {
  speed = boundaries(speed, 0, 255);

  analogWrite(ENA, speed);
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  analogWrite(ENB, speed);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
}

void EBot::backward() {
  digitalWrite(ENA, HIGH);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  digitalWrite(ENB, HIGH);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
}

void EBot::backward(int speed) {
  speed = boundaries(speed, 0, 255);

  analogWrite(ENA, speed);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  analogWrite(ENB, speed);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
}

void EBot::rotateRight() {
  digitalWrite(ENA, HIGH);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  digitalWrite(ENB, HIGH);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
}

void EBot::rotateRight(int speed) {
  speed = boundaries(speed, 0, 255);

  analogWrite(ENA, speed);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  analogWrite(ENB, speed);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
}

void EBot::rotateLeft() {
  digitalWrite(ENA, HIGH);
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(ENB, HIGH);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
}

void EBot::rotateLeft(int speed) {
  speed = boundaries(speed, 0, 255);

  analogWrite(ENA, speed);
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  analogWrite(ENB, speed);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
}

void EBot::write(int angle) {
  angle = boundaries(angle, 0, 180);

  servo.write(angle);
}

unsigned long EBot::distance() {
  unsigned long duration;

  digitalWrite(Trig, LOW);
  delayMicroseconds(2);
  digitalWrite(Trig, HIGH);
  delayMicroseconds(5);
  digitalWrite(Trig, LOW);
  duration = pulseIn(Echo, HIGH);

  return duration / 29 / 2;
}

bool EBot::readLS1() {
  return digitalRead(LS1);
}

bool EBot::readLS2() {
  return digitalRead(LS2);
}

bool EBot::readLS3() {
  return digitalRead(LS3);
}

int EBot::boundaries(int value, int min, int max) {
  value = value < min ? min : value;
  value = value > max ? max : value;

  return value;
}
<|endoftext|>


<commit_before>/**
 * Project
 * #    #     #     ######   ######
 * #   #     # #    #     #  #     #
 * #  #     #   #   #     #  #     #
 * ###     #     #  ######   ######
 * #  #    #######  #   #    #   #
 * #   #   #     #  #    #   #    #
 * #    #  #     #  #     #  #     #
 *
 * Copyright (c) 2014, Project KARR
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#include "AngularInstrument.h"

AngularInstrument::AngularInstrument() : Instrument() {
}

AngularInstrument::~AngularInstrument() {
}

void AngularInstrument::draw() {
}

bool AngularInstrument::parseFromTree(boost::property_tree::ptree &) {
    return false;
}
<commit_msg>Add implementation for update.<commit_after>/**
 * Project
 * #    #     #     ######   ######
 * #   #     # #    #     #  #     #
 * #  #     #   #   #     #  #     #
 * ###     #     #  ######   ######
 * #  #    #######  #   #    #   #
 * #   #   #     #  #    #   #    #
 * #    #  #     #  #     #  #     #
 *
 * Copyright (c) 2014, Project KARR
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#include "AngularInstrument.h"

AngularInstrument::AngularInstrument() : Instrument() {
}

AngularInstrument::~AngularInstrument() {
}

void AngularInstrument::draw() {
}

void AngularInstrument::update(float newVal) {
}

bool AngularInstrument::parseFromTree(boost::property_tree::ptree &) {
    return false;
}
<|endoftext|>


<commit_before>
/* Jim Viebke
Oct 21, 2015*/

#include "utilities.h"

// string utilities
unsigned U::to_unsigned(const std::string & word)
{
	// "a1b2c3" will return 123. "abc" will return 0.

	unsigned count = 0;
	for (const char & digit : word) // for each character in the second command
	{
		if (digit >= '0' && digit <= '9') // if the character is a digit
		{
			count *= 10; // shift digits to the left
			count += digit - '0'; // add newest digit
		}
	}
	return count;
}
void U::to_lower_case(std::string & word)
{
	// convert a vector of strings passed by reference to a vector of lowercase strings
	if (word.length() > 0)
	{
		std::transform(word.begin(), word.end(), word.begin(), ::tolower);
	}
}
std::string U::capitalize(std::string & word)
{
	// immediately return the string if it is empty
	if (word.size() == 0) return word;

	// if the first letter is in the range a-z, convert the letter to capital by subtracting 32
	if (word[0] >= 'a' && word[0] <= 'z')
		word[0] -= 32;

	return word;
}
std::string U::capitalize(const std::string & word)
{
	// immediately return the string if it is empty
	if (word.size() == 0) return word;

	// copy 'word' to a string that can be modified
	std::string result = word;

	// if the first letter is in the range a-z, convert the letter to capital by subtracting 32
	if (result[0] >= 'a' && result[0] <= 'z')
		result[0] -= 32;

	return result;
}

// grammar
std::string U::get_article_for(const std::string & noun)
{
	// get an iterator to the <key, value> pair for <noun, article>
	const std::map<std::string, std::string>::const_iterator it = C::articles.find(noun);

	// return the article if the key exists, else return generic "a(n)".
	return ((it != C::articles.cend()) ? it->second : "a(n)");
}
std::string U::get_plural_for(const std::string & noun)
{
	// get an iterator to the <key, value> pair for <noun, article>
	const std::map<std::string, std::string>::const_iterator it = C::plurals.find(noun);

	// return the article if the key exists, else return the original noun
	return ((it != C::plurals.cend()) ? it->second : noun);
}
std::string U::get_singular_for(const std::string & noun)
{
	for (const auto & pair : C::articles)
	{
		if (pair.second == noun) return pair.first;
	}

	return noun; // return the original word if the singular form could not be found
}

// math
int U::euclidean_distance(const int & x1, const int & y1, const int & x2, const int & y2)
{
	int x_diff = difference(x1, x2);
	int y_diff = difference(y1, y2);
	return static_cast<int>(sqrt( // use Pythagoras' theorem
		(x_diff * x_diff) +
		(y_diff * y_diff)
		));
}
int U::diagonal_distance(const int & x1, const int & y1, const int & x2, const int & y2)
{
	return std::max(difference(x1, x2), difference(x2, y2));
}

// pathfinding
int U::diagonal_movement_cost(const int & x1, const int & y1, const int & x2, const int & y2)
{
	// Because this uses different movement costs, this works for AI pathfinding, but
	// not so much for determining if a coordinate is visible from another coordinate.

	// a diagonal move = (sqrt(2) * straight move)
	int dx = abs(x1 - x2);
	int dy = abs(y1 - y2);
	return C::AI_MOVEMENT_COST * (dx + dy) + (C::AI_MOVEMENT_COST_DIAGONAL - 2 * C::AI_MOVEMENT_COST) * std::min(dx, dy);
}

// random utils
int U::random_int_from(const int & min, const int & max)
{
	return min + (rand() % (max - min + 1));
}
unsigned U::random_int_from(const unsigned & min, const unsigned & max)
{
	return min + (rand() % (max - min + 1));
}
<commit_msg>documentation<commit_after>
/* Jim Viebke
Oct 21, 2015*/

#include "utilities.h"

// string utilities
unsigned U::to_unsigned(const std::string & word)
{
	// "a1b2c3" will return 123. "abc" will return 0.

	unsigned count = 0;
	for (const char & digit : word) // for each character in the second command
	{
		if (digit >= '0' && digit <= '9') // if the character is a digit
		{
			count *= 10; // shift digits to the left
			count += digit - '0'; // add newest digit
		}
	}
	return count;
}
void U::to_lower_case(std::string & word)
{
	// convert a vector of strings passed by reference to a vector of lowercase strings
	if (word.length() > 0)
	{
		std::transform(word.begin(), word.end(), word.begin(), ::tolower);
	}
}
std::string U::capitalize(std::string & word)
{
	// immediately return the string if it is empty
	if (word.size() == 0) return word;

	// if the first letter is in the range a-z, convert the letter to capital by subtracting 32
	if (word[0] >= 'a' && word[0] <= 'z')
		word[0] -= 32;

	return word;
}
std::string U::capitalize(const std::string & word)
{
	// immediately return the string if it is empty
	if (word.size() == 0) return word;

	// copy 'word' to a string that can be modified
	std::string result = word;

	// if the first letter is in the range a-z, convert the letter to capital by subtracting 32
	if (result[0] >= 'a' && result[0] <= 'z')
		result[0] -= 32;

	return result;
}

// grammar
std::string U::get_article_for(const std::string & noun)
{
	// get an iterator to the <key, value> pair for <noun, article>
	const std::map<std::string, std::string>::const_iterator it = C::articles.find(noun);

	// return the article if the key exists, else return generic "a(n)".
	return ((it != C::articles.cend()) ? it->second : "a(n)");
}
std::string U::get_plural_for(const std::string & noun)
{
	// get an iterator to the <key, value> pair for <noun, article>
	const std::map<std::string, std::string>::const_iterator it = C::plurals.find(noun);

	// return the article if the key exists, else return the original noun
	return ((it != C::plurals.cend()) ? it->second : noun);
}
std::string U::get_singular_for(const std::string & noun)
{
	// We're doing a reverse-lookup here. Not very efficient, but oh well.

	// for each singular/plural pair
	for (const auto & pair : C::articles)
	{
		// if the plural matches the passed noun
		if (pair.second == noun) return pair.first; // return the singular form of the passed plural
	}

	return noun; // return the original word if the singular form could not be found
}

// math
int U::euclidean_distance(const int & x1, const int & y1, const int & x2, const int & y2)
{
	int x_diff = difference(x1, x2);
	int y_diff = difference(y1, y2);
	return static_cast<int>(sqrt( // use Pythagoras' theorem
		(x_diff * x_diff) +
		(y_diff * y_diff)
		));
}
int U::diagonal_distance(const int & x1, const int & y1, const int & x2, const int & y2)
{
	return std::max(difference(x1, x2), difference(x2, y2));
}

// pathfinding
int U::diagonal_movement_cost(const int & x1, const int & y1, const int & x2, const int & y2)
{
	// Because this uses different movement costs, this works for AI pathfinding, but
	// not so much for determining if a coordinate is visible from another coordinate.

	// a diagonal move = (sqrt(2) * straight move)
	int dx = abs(x1 - x2);
	int dy = abs(y1 - y2);
	return C::AI_MOVEMENT_COST * (dx + dy) + (C::AI_MOVEMENT_COST_DIAGONAL - 2 * C::AI_MOVEMENT_COST) * std::min(dx, dy);
}

// random utils
int U::random_int_from(const int & min, const int & max)
{
	return min + (rand() % (max - min + 1));
}
unsigned U::random_int_from(const unsigned & min, const unsigned & max)
{
	return min + (rand() % (max - min + 1));
}
<|endoftext|>


<commit_before>
#include "CaptureDeviceImpl.h"

#include "Error.h"

#include "logging.h"
#include "utils.h"
#include "serialization.h"

using namespace tcam;

CaptureDeviceImpl::CaptureDeviceImpl ()
    : pipeline(nullptr), property_handler(nullptr), device(nullptr)
{}

CaptureDeviceImpl::CaptureDeviceImpl (const DeviceInfo& device)
    : pipeline(nullptr), property_handler(nullptr), device(nullptr)
{
    if (!openDevice(device))
    {
        tcam_log(TCAM_LOG_ERROR, "Unable to open device");
    }
}

CaptureDeviceImpl::~CaptureDeviceImpl ()
{}

bool CaptureDeviceImpl::load_configuration (const std::string& filename)
{
    resetError();

    if (!isDeviceOpen())
    {
        return false;
    }

    auto vec = property_handler->get_properties();

    return load_xml_description(filename,
                                open_device,
                                active_format,
                                vec);
}

bool CaptureDeviceImpl::save_configuration (const std::string& filename)
{
    resetError();

    if (!isDeviceOpen())
    {
        return false;
    }

    return save_xml_description(filename,
                                open_device,
                                device->get_active_video_format(),
                                property_handler->get_properties());
}

bool CaptureDeviceImpl::openDevice (const DeviceInfo& device_desc)
{
    resetError();

    if (isDeviceOpen())
    {
        bool ret = closeDevice();
        if (ret == false)
        {
            tcam_log(TCAM_LOG_ERROR, "Unable to close previous device.");
            // setError(Error("A device is already open", EPERM));
            return false;
        }
    }

    open_device = device_desc;

    device = openDeviceInterface(open_device);

    if (device == nullptr)
    {
        return false;
    }

    pipeline = std::make_shared<PipelineManager>();
    pipeline->setSource(device);

    property_handler = std::make_shared<PropertyHandler>();

    property_handler->set_properties(device->getProperties(), pipeline->getFilterProperties());

    return true;
}

bool CaptureDeviceImpl::isDeviceOpen () const
{
    resetError();
    if (device != nullptr)
    {
        return true;
    }

    return false;
}

DeviceInfo CaptureDeviceImpl::getDevice () const
{
    return this->open_device;
}

bool CaptureDeviceImpl::closeDevice ()
{
    if (!isDeviceOpen())
    {
        return true;
    }

    std::string name = open_device.get_name();

    pipeline->destroyPipeline();

    open_device = DeviceInfo ();
    device.reset();
    property_handler = nullptr;

    tcam_log(TCAM_LOG_INFO, "Closed device %s.", name.c_str());

    return true;
}

std::vector<Property*> CaptureDeviceImpl::getAvailableProperties ()
{
    resetError();
    if (!isDeviceOpen())
    {
        return std::vector<Property*>();
    }

    std::vector<Property*> props;

    for ( const auto& p : property_handler->get_properties())
    {
        props.push_back(&*p);
    }

    return props;
}

std::vector<VideoFormatDescription> CaptureDeviceImpl::getAvailableVideoFormats () const
{
    resetError();
    if (!isDeviceOpen())
    {
        return std::vector<VideoFormatDescription>();
    }

    return pipeline->getAvailableVideoFormats();
}

bool CaptureDeviceImpl::setVideoFormat (const VideoFormat& new_format)
{
    resetError();
    if (!isDeviceOpen())
    {
        return false;
    }

    pipeline->setVideoFormat(new_format);

    return this->device->set_video_format(new_format);
}

VideoFormat CaptureDeviceImpl::getActiveVideoFormat () const
{
    resetError();
    if(!isDeviceOpen())
    {
        return VideoFormat();
    }

    return device->get_active_video_format();
}

bool CaptureDeviceImpl::startStream (std::shared_ptr<SinkInterface> sink)
{
    resetError();
    if (!isDeviceOpen())
    {
        return false;
    }
    pipeline->setSink(sink);

    return pipeline->set_status(TCAM_PIPELINE_PLAYING);
}

bool CaptureDeviceImpl::stopStream ()
{
    resetError();
    if (!isDeviceOpen())
    {
        return false;
    }

    return pipeline->set_status(TCAM_PIPELINE_STOPPED);
}
<commit_msg>Add security checks<commit_after>
#include "CaptureDeviceImpl.h"

#include "Error.h"

#include "logging.h"
#include "utils.h"
#include "serialization.h"

using namespace tcam;

CaptureDeviceImpl::CaptureDeviceImpl ()
    : pipeline(nullptr), property_handler(nullptr), device(nullptr)
{}

CaptureDeviceImpl::CaptureDeviceImpl (const DeviceInfo& device)
    : pipeline(nullptr), property_handler(nullptr), device(nullptr)
{
    if (!openDevice(device))
    {
        tcam_log(TCAM_LOG_ERROR, "Unable to open device");
    }
}

CaptureDeviceImpl::~CaptureDeviceImpl ()
{}

bool CaptureDeviceImpl::load_configuration (const std::string& filename)
{
    resetError();

    if (!isDeviceOpen())
    {
        return false;
    }

    auto vec = property_handler->get_properties();

    return load_xml_description(filename,
                                open_device,
                                active_format,
                                vec);
}

bool CaptureDeviceImpl::save_configuration (const std::string& filename)
{
    resetError();

    if (!isDeviceOpen())
    {
        return false;
    }

    return save_xml_description(filename,
                                open_device,
                                device->get_active_video_format(),
                                property_handler->get_properties());
}

bool CaptureDeviceImpl::openDevice (const DeviceInfo& device_desc)
{
    resetError();

    if (isDeviceOpen())
    {
        bool ret = closeDevice();
        if (ret == false)
        {
            tcam_log(TCAM_LOG_ERROR, "Unable to close previous device.");
            // setError(Error("A device is already open", EPERM));
            return false;
        }
    }

    open_device = device_desc;

    device = openDeviceInterface(open_device);

    if (device == nullptr)
    {
        return false;
    }

    pipeline = std::make_shared<PipelineManager>();
    pipeline->setSource(device);

    property_handler = std::make_shared<PropertyHandler>();

    property_handler->set_properties(device->getProperties(), pipeline->getFilterProperties());

    return true;
}

bool CaptureDeviceImpl::isDeviceOpen () const
{
    resetError();
    if (device != nullptr)
    {
        return true;
    }

    return false;
}

DeviceInfo CaptureDeviceImpl::getDevice () const
{
    return this->open_device;
}

bool CaptureDeviceImpl::closeDevice ()
{
    if (!isDeviceOpen())
    {
        return true;
    }

    std::string name = open_device.get_name();

    pipeline->destroyPipeline();

    open_device = DeviceInfo ();
    device.reset();
    property_handler = nullptr;

    tcam_log(TCAM_LOG_INFO, "Closed device %s.", name.c_str());

    return true;
}

std::vector<Property*> CaptureDeviceImpl::getAvailableProperties ()
{
    resetError();
    if (!isDeviceOpen())
    {
        return std::vector<Property*>();
    }

    std::vector<Property*> props;

    for ( const auto& p : property_handler->get_properties())
    {
        props.push_back(&*p);
    }

    return props;
}

std::vector<VideoFormatDescription> CaptureDeviceImpl::getAvailableVideoFormats () const
{
    resetError();
    if (!isDeviceOpen())
    {
        return std::vector<VideoFormatDescription>();
    }

    return pipeline->getAvailableVideoFormats();
}

bool CaptureDeviceImpl::setVideoFormat (const VideoFormat& new_format)
{
    resetError();
    if (!isDeviceOpen())
    {
        return false;
    }

    pipeline->setVideoFormat(new_format);

    return this->device->set_video_format(new_format);
}

VideoFormat CaptureDeviceImpl::getActiveVideoFormat () const
{
    resetError();
    if(!isDeviceOpen())
    {
        return VideoFormat();
    }

    return device->get_active_video_format();
}

bool CaptureDeviceImpl::startStream (std::shared_ptr<SinkInterface> sink)
{
    resetError();
    if (!isDeviceOpen())
    {
        tcam_log(TCAM_LOG_ERROR, "Device is not open");
        return false;
    }

    if (!pipeline->setSink(sink))
    {
        return false;
    }

    return pipeline->set_status(TCAM_PIPELINE_PLAYING);
}

bool CaptureDeviceImpl::stopStream ()
{
    resetError();
    if (!isDeviceOpen())
    {
        return false;
    }

    return pipeline->set_status(TCAM_PIPELINE_STOPPED);
}
<|endoftext|>


<commit_before>
#include "Gfdi.h"

#include <array>
#include <cassert>
#include <cmath>

// helper functions and data
namespace {

  // numerous constants used in the analytic approximations
  const std::array<double, 5> x = {{
    7.265351e-2, 0.2694608, 0.533122, 0.7868801, 0.9569313}};

  const std::array<double, 5> xi = {{
    0.26356032, 1.4134031, 3.5964258, 7.0858100, 12.640801}};

  const std::array<double, 5> h = {{
    3.818735e-2, 0.1256732, 0.1986308, 0.1976334, 0.1065420}};

  const std::array<double, 5> v = {{
    0.29505869, 0.32064856, 7.3915570e-2, 3.6087389e-3, 2.3369894e-5}};

  const std::array<std::array<double, 5>, 3> c = {{
    {{0.37045057, 0.41258437, 9.777982e-2, 5.3734153e-3, 3.8746281e-5}},
    {{0.39603109, 0.69468795, 0.22322760, 1.5262934e-2, 1.3081939e-4}},
    {{0.76934619, 1.7891437, 0.70754974, 5.6755672e-2, 5.5571480e-4}}}};

  const std::array<std::array<double, 5>, 3> khi = {{
    {{0.43139881, 1.7597537, 4.1044654, 7.7467038, 13.457678}},
    {{0.81763176, 2.4723339, 5.1160061, 9.0441465, 15.049882}},
    {{1.2558461, 3.2070406, 6.1239082, 10.316126, 16.597079}}}};

  double cube(const double x) {
    return x*x*x;
  }

  // helper function for GFDI work
  double gfdi_helper(const int k, const double chi, const double tau,
      const double r) {
    if (chi*tau < 1.e-4 && chi > 0) {
      return pow(chi, k+3./2)/(k+3./2);
    }
    else if (k==0) {
      return (chi + 1/tau)*r/2
        - pow(2*tau, -3./2) * log(1 + tau*chi + sqrt(2*tau)*r);
    }
    else if (k==1) {
      return (2./3*cube(r) - gfdi_helper(0, chi, tau, r)) / tau;
    }
    else if (k==2) {
      return (2*chi*cube(r) - 5*gfdi_helper(1, chi, tau, r)) / (4*tau);
    }
    else {
      return 0.0;
    }
  }

} // end anonymous namespace

double gfdi(const GFDI order, const double chi, const double tau) {
  // TODO: something more like a SpEC require?
  assert(tau <= 100. && "GFDI: outside of known convergence region");

  const int k = static_cast<int>(order);

  if (chi <= 0.6) {
    double value = 0;
    for (int i=1; i<=5; i++) {
      value += c[k][i-1] * sqrt(1 + khi[k][i-1]*tau/2) /
        (exp(-khi[k][i-1]) + exp(-chi));
    }
    return value;
  }
  else if (chi < 14) {
    double value = 0;
    for (int i=1; i<=5; i++) {
      value += h[i-1] * pow(x[i-1], k) * pow(chi, k+3./2)
        * sqrt(1 + chi*x[i-1]*tau/2) / (1 + exp(chi*(x[i-1] - 1)))
        + v[i-1] * pow(xi[i-1] + chi, k+1./2) * sqrt(1 + (xi[i-1] + chi)*tau/2);
    }
    return value;
  }
  else {
    const double r = sqrt(chi*(1 + chi*tau/2));
    return gfdi_helper(k, chi, tau, r)
      + M_PI*M_PI/6. * pow(chi, k) * (k + 1./2 + (k+1)*chi*tau/2) / r;
  }
}
<commit_msg>Gfdi: Cleanup and c++11-ify<commit_after>
#include "Gfdi.h"

#include <array>
#include <cassert>
#include <cmath>

// helper functions and data
namespace {

  // numerous constants used in the analytic approximations
  //const std::array<double, 5> x = {{
  const auto x = std::array<double, 5> {{
    7.265351e-2, 0.2694608, 0.533122, 0.7868801, 0.9569313}};

  const auto xi = std::array<double, 5> {{
    0.26356032, 1.4134031, 3.5964258, 7.0858100, 12.640801}};

  const auto h = std::array<double, 5> {{
    3.818735e-2, 0.1256732, 0.1986308, 0.1976334, 0.1065420}};

  const auto v = std::array<double, 5> {{
    0.29505869, 0.32064856, 7.3915570e-2, 3.6087389e-3, 2.3369894e-5}};

  const auto c = std::array<std::array<double, 5>, 3> {{
    {{0.37045057, 0.41258437, 9.777982e-2, 5.3734153e-3, 3.8746281e-5}},
    {{0.39603109, 0.69468795, 0.22322760, 1.5262934e-2, 1.3081939e-4}},
    {{0.76934619, 1.7891437, 0.70754974, 5.6755672e-2, 5.5571480e-4}}}};

  const auto khi = std::array<std::array<double, 5>, 3> {{
    {{0.43139881, 1.7597537, 4.1044654, 7.7467038, 13.457678}},
    {{0.81763176, 2.4723339, 5.1160061, 9.0441465, 15.049882}},
    {{1.2558461, 3.2070406, 6.1239082, 10.316126, 16.597079}}}};

  inline double cube(const double x) {
    return x*x*x;
  }

  // helper function for GFDI work
  double gfdi_helper(const int k, const double chi, const double tau,
      const double r) {
    if (chi*tau < 1.e-4 && chi > 0.0) {
      return pow(chi, k+3./2)/(k+3./2);
    }
    else if (k==0) {
      return (chi + 1/tau)*r/2
        - pow(2*tau, -3./2) * log(1 + tau*chi + sqrt(2*tau)*r);
    }
    else if (k==1) {
      return (2./3*cube(r) - gfdi_helper(0, chi, tau, r)) / tau;
    }
    else if (k==2) {
      return (2*chi*cube(r) - 5*gfdi_helper(1, chi, tau, r)) / (4*tau);
    }
    else {
      return 0.0;
    }
  }

} // end anonymous namespace

double gfdi(const GFDI order, const double chi, const double tau) {
  // TODO: something more like a SpEC require?
  assert(tau <= 100. && "GFDI: outside of known convergence region");

  const int k = static_cast<int>(order);

  if (chi <= 0.6) {
    double value = 0;
    for (int i=1; i<=5; i++) {
      value += c[k][i-1] * sqrt(1 + khi[k][i-1]*tau/2) /
        (exp(-khi[k][i-1]) + exp(-chi));
    }
    return value;
  }
  else if (chi < 14.0) {
    double value = 0;
    for (int i=1; i<=5; i++) {
      value += h[i-1] * pow(x[i-1], k) * pow(chi, k+3./2)
        * sqrt(1 + chi*x[i-1]*tau/2) / (1 + exp(chi*(x[i-1] - 1)))
        + v[i-1] * pow(xi[i-1] + chi, k+1./2) * sqrt(1 + (xi[i-1] + chi)*tau/2);
    }
    return value;
  }
  else {
    const double r = sqrt(chi*(1 + chi*tau/2));
    return gfdi_helper(k, chi, tau, r)
      + M_PI*M_PI/6. * pow(chi, k) * (k + 1./2 + (k+1)*chi*tau/2) / r;
  }
}
<|endoftext|>