<commit_before>//////////////////////////////////////////////////////////////////////////
//
//  Copyright (c) 2007, Image Engine Design Inc. All rights reserved.
//
//  Redistribution and use in source and binary forms, with or without
//  modification, are permitted provided that the following conditions are
//  met:
//
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//
//     * 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.
//
//     * Neither the name of Image Engine Design nor the names of any
//       other contributors to this software may be used to endorse or
//       promote products derived from this software without specific prior
//       written permission.
//
//  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 OWNER 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 "boost/static_assert.hpp"
#include "boost/format.hpp"

#include "IECore/TIFFImageWriter.h"
#include "IECore/MessageHandler.h"
#include "IECore/VectorTypedData.h"
#include "IECore/ByteOrder.h"
#include "IECore/ImagePrimitive.h"
#include "IECore/FileNameParameter.h"
#include "IECore/Parameter.h"
#include "IECore/NumericParameter.h"

#include "IECore/BoxOperators.h"

#include "tiffio.h"

using namespace IECore;
using namespace std;
using namespace boost;
using namespace Imath;

const Writer::WriterDescription<TIFFImageWriter> TIFFImageWriter::m_writerDescription("tiff tif");

TIFFImageWriter::TIFFImageWriter()
	: 	ImageWriter("TIFFImageWriter", "Serializes images to the Tagged Image File Format (TIFF) format")
{
	constructParameters();
}

TIFFImageWriter::TIFFImageWriter(ObjectPtr image, const string & fileName)
	: 	ImageWriter("TIFFImageWriter", "Serializes images to the Tagged Image File Format (TIFF) format")
{
	constructParameters();
	m_objectParameter->setValue( image );
	m_fileNameParameter->setTypedValue( fileName );
}

void TIFFImageWriter::constructParameters( )
{
	// bitdepth parameter
	m_bitdepthParameter = new IntParameter("bitdepth", "output TIFF bit depth, one of 8, 16, 32; defaults to 16");
	parameters()->addParameter(m_bitdepthParameter);

	// compression parameter
	IntParameter::PresetsMap compressionPresets;
	compressionPresets["none"]    = COMPRESSION_NONE;
	compressionPresets["lzw"]     = COMPRESSION_LZW;
	compressionPresets["jpeg"]    = COMPRESSION_JPEG;
	compressionPresets["deflate"] = COMPRESSION_DEFLATE;

	/// Verify min
	BOOST_STATIC_ASSERT( COMPRESSION_NONE < COMPRESSION_LZW );
	BOOST_STATIC_ASSERT( COMPRESSION_NONE < COMPRESSION_JPEG );
	BOOST_STATIC_ASSERT( COMPRESSION_NONE < COMPRESSION_DEFLATE );

	/// Verify max
	BOOST_STATIC_ASSERT( COMPRESSION_DEFLATE > COMPRESSION_NONE );
	BOOST_STATIC_ASSERT( COMPRESSION_DEFLATE > COMPRESSION_LZW );
	BOOST_STATIC_ASSERT( COMPRESSION_DEFLATE > COMPRESSION_JPEG );

	m_compressionParameter = new IntParameter("compression", "image data compression method",
		compressionPresets["lzw"],
		COMPRESSION_NONE,
		COMPRESSION_DEFLATE,
		compressionPresets,
		true);

	parameters()->addParameter(m_compressionParameter);
}

TIFFImageWriter::~TIFFImageWriter()
{
}

void TIFFImageWriter::stripEncode(tiff * tiff_image, char * image_buffer, int image_buffer_size, int strips)
{
	// write the information to the file
	int offset = 0;

	for(int strip = 0; strip < strips; ++strip)
	{
		int tss = TIFFStripSize(tiff_image);
		int remaining = image_buffer_size - offset;
		int lc = TIFFWriteEncodedStrip(tiff_image, strip, image_buffer + offset,
												 tss < remaining ? tss : remaining);
		offset += lc;
	}
}

void TIFFImageWriter::writeImage(vector<string> & names, ConstImagePrimitivePtr image, const Box2i & dw)
{
	// create the tiff file
	TIFF *tiff_image;
	if((tiff_image = TIFFOpen(fileName().c_str(), "w")) == NULL)
	{
		throw IOException("Could not open '" + fileName() + "' for writing.");
	}

	// compute the writebox
	int width  = 1 + dw.max.x - dw.min.x;
	int height = 1 + dw.max.y - dw.min.y;

	// compute the number of channels
	int spp = names.size();

	/// \todo different compression methods have a bearing on other attributes, eg. the strip size
	/// handle these issues a bit better and perhaps more explicitly here.  also, we should probably
	/// warn the user in cases where parameter settings are not permitted (eg 16 bit jpeg)
	int compression = parameters()->parameter<IntParameter>("compression")->getNumericValue();
	TIFFSetField(tiff_image, TIFFTAG_COMPRESSION, compression);

	// read the bitdepth parameter, default to 16 bits
	int bits = compression == COMPRESSION_JPEG ? 8 : parameters()->parameter<IntParameter>("bitdepth")->getNumericValue();
	int bps = bits == 8 || bits == 16 || bits == 32 ? bits : 16;
	//bits = bits;

	/// \todo have the code below handle the various bitdepths
	// hardcode to 16 bits bitdepth
	//int bps = 16;
	int bpc = bps / 8;

	// number of strips to write.  TIFF's JPEG compression requires rps to be a multiple of 8
	int rows_per_strip = 8;

	// now properly compute # of strips
	int strips = height / rows_per_strip + (height % rows_per_strip > 0 ? 1 : 0);

	// set the basic values
	TIFFSetField(tiff_image, TIFFTAG_IMAGEWIDTH, width);
	TIFFSetField(tiff_image, TIFFTAG_IMAGELENGTH, height);
	TIFFSetField(tiff_image, TIFFTAG_BITSPERSAMPLE, bps);
	TIFFSetField(tiff_image, TIFFTAG_SAMPLESPERPIXEL, spp);
	TIFFSetField(tiff_image, TIFFTAG_ROWSPERSTRIP, rows_per_strip);

	TIFFSetField(tiff_image, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
	TIFFSetField(tiff_image, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB);
	TIFFSetField(tiff_image, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);

	/// \todo output float tiffs if desired
	TIFFSetField(tiff_image, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT);

	//PLANARCONFIG_CONTIG    (pixel interlaced)
	//PLANARCONFIG_SEPARATE  (channel-interleave)

	TIFFSetField(tiff_image, TIFFTAG_XRESOLUTION, 1);
	TIFFSetField(tiff_image, TIFFTAG_YRESOLUTION, 1);
	TIFFSetField(tiff_image, TIFFTAG_RESOLUTIONUNIT, RESUNIT_NONE);

	//
	// encode
	//
	switch(bps) {

	case 8:
	{
		unsigned char * v = encodeChannels<unsigned char>(image, names, dw);
		stripEncode(tiff_image, (char *) v, bpc * width * height * spp, strips);
		delete [] v;
	}
	break;

	case 16:
	{
		/// \todo An unsigned short needn't be 16 bits long. Use typedefs from <stdint.h> instead.
		BOOST_STATIC_ASSERT( sizeof( unsigned short ) == 2 );
		unsigned short * v = encodeChannels<unsigned short>(image, names, dw);
		stripEncode(tiff_image, (char *) v, bpc * width * height * spp, strips);
		delete [] v;
	}
	break;

	case 32:
	{
		/// \todo An unsigned int needn't be 32 bits long. Use typedefs from <stdint.h> instead.
		BOOST_STATIC_ASSERT( sizeof( unsigned int ) == 4 );
		unsigned int * v = encodeChannels<unsigned int>(image, names, dw);
		stripEncode(tiff_image, (char *) v, bpc * width * height * spp, strips);
		delete [] v;
	}
	break;

	}

	// close the file
	TIFFClose(tiff_image);
	tiff_image = 0;
}
<commit_msg>Added parameter presets and libtiff error handling.<commit_after>//////////////////////////////////////////////////////////////////////////
//
//  Copyright (c) 2007, Image Engine Design Inc. All rights reserved.
//
//  Redistribution and use in source and binary forms, with or without
//  modification, are permitted provided that the following conditions are
//  met:
//
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//
//     * 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.
//
//     * Neither the name of Image Engine Design nor the names of any
//       other contributors to this software may be used to endorse or
//       promote products derived from this software without specific prior
//       written permission.
//
//  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 OWNER 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 "boost/static_assert.hpp"
#include "boost/format.hpp"

#include "IECore/TIFFImageWriter.h"
#include "IECore/MessageHandler.h"
#include "IECore/VectorTypedData.h"
#include "IECore/ByteOrder.h"
#include "IECore/ImagePrimitive.h"
#include "IECore/FileNameParameter.h"
#include "IECore/Parameter.h"
#include "IECore/NumericParameter.h"
#include "IECore/ScopedTIFFExceptionTranslator.h"

#include "IECore/BoxOperators.h"

#include "tiffio.h"

using namespace IECore;
using namespace std;
using namespace boost;
using namespace Imath;

const Writer::WriterDescription<TIFFImageWriter> TIFFImageWriter::m_writerDescription("tiff tif");

TIFFImageWriter::TIFFImageWriter()
	: 	ImageWriter("TIFFImageWriter", "Serializes images to the Tagged Image File Format (TIFF) format")
{
	constructParameters();
}

TIFFImageWriter::TIFFImageWriter(ObjectPtr image, const string & fileName)
	: 	ImageWriter("TIFFImageWriter", "Serializes images to the Tagged Image File Format (TIFF) format")
{
	constructParameters();
	m_objectParameter->setValue( image );
	m_fileNameParameter->setTypedValue( fileName );
}

void TIFFImageWriter::constructParameters( )
{
	// bitdepth parameter
	IntParameter::PresetsMap bitDepthPresets;
	bitDepthPresets["8"] = 8;
	bitDepthPresets["16"] = 16;
	bitDepthPresets["32"] = 32;

	m_bitdepthParameter = new IntParameter(
		"bitdepth",
		"Output TIFF bit depth",
		16,
		8,
		32,
		bitDepthPresets,
		true);

	parameters()->addParameter(m_bitdepthParameter);

	// compression parameter
	IntParameter::PresetsMap compressionPresets;
	compressionPresets["none"]    = COMPRESSION_NONE;
	compressionPresets["lzw"]     = COMPRESSION_LZW;
	compressionPresets["jpeg"]    = COMPRESSION_JPEG;
	compressionPresets["deflate"] = COMPRESSION_DEFLATE;

	/// Verify min
	BOOST_STATIC_ASSERT( COMPRESSION_NONE < COMPRESSION_LZW );
	BOOST_STATIC_ASSERT( COMPRESSION_NONE < COMPRESSION_JPEG );
	BOOST_STATIC_ASSERT( COMPRESSION_NONE < COMPRESSION_DEFLATE );

	/// Verify max
	BOOST_STATIC_ASSERT( COMPRESSION_DEFLATE > COMPRESSION_NONE );
	BOOST_STATIC_ASSERT( COMPRESSION_DEFLATE > COMPRESSION_LZW );
	BOOST_STATIC_ASSERT( COMPRESSION_DEFLATE > COMPRESSION_JPEG );

	m_compressionParameter = new IntParameter("compression", "image data compression method",
		compressionPresets["lzw"],
		COMPRESSION_NONE,
		COMPRESSION_DEFLATE,
		compressionPresets,
		true);

	parameters()->addParameter(m_compressionParameter);
}

TIFFImageWriter::~TIFFImageWriter()
{
}

void TIFFImageWriter::stripEncode(tiff * tiff_image, char * image_buffer, int image_buffer_size, int strips)
{
	// write the information to the file
	int offset = 0;

	for(int strip = 0; strip < strips; ++strip)
	{
		int tss = TIFFStripSize(tiff_image);
		int remaining = image_buffer_size - offset;
		int lc = TIFFWriteEncodedStrip(tiff_image, strip, image_buffer + offset,
												 tss < remaining ? tss : remaining);
		offset += lc;
	}
}

void TIFFImageWriter::writeImage(vector<string> & names, ConstImagePrimitivePtr image, const Box2i & dw)
{
	ScopedTIFFExceptionTranslator errorHandler( );

	// create the tiff file
	TIFF *tiff_image;
	if((tiff_image = TIFFOpen(fileName().c_str(), "w")) == NULL)
	{
		throw IOException("Could not open '" + fileName() + "' for writing.");
	}

	// compute the writebox
	int width  = 1 + dw.max.x - dw.min.x;
	int height = 1 + dw.max.y - dw.min.y;

	// compute the number of channels
	int spp = names.size();

	/// \todo different compression methods have a bearing on other attributes, eg. the strip size
	/// handle these issues a bit better and perhaps more explicitly here.  also, we should probably
	/// warn the user in cases where parameter settings are not permitted (eg 16 bit jpeg)
	int compression = parameters()->parameter<IntParameter>("compression")->getNumericValue();
	TIFFSetField(tiff_image, TIFFTAG_COMPRESSION, compression);

	// read the bitdepth parameter, default to 16 bits
	int bits = compression == COMPRESSION_JPEG ? 8 : parameters()->parameter<IntParameter>("bitdepth")->getNumericValue();
	int bps = bits == 8 || bits == 16 || bits == 32 ? bits : 16;
	//bits = bits;

	/// \todo have the code below handle the various bitdepths
	// hardcode to 16 bits bitdepth
	//int bps = 16;
	int bpc = bps / 8;

	// number of strips to write.  TIFF's JPEG compression requires rps to be a multiple of 8
	int rows_per_strip = 8;

	// now properly compute # of strips
	int strips = height / rows_per_strip + (height % rows_per_strip > 0 ? 1 : 0);

	// set the basic values
	TIFFSetField(tiff_image, TIFFTAG_IMAGEWIDTH, width);
	TIFFSetField(tiff_image, TIFFTAG_IMAGELENGTH, height);
	TIFFSetField(tiff_image, TIFFTAG_BITSPERSAMPLE, bps);
	TIFFSetField(tiff_image, TIFFTAG_SAMPLESPERPIXEL, spp);
	TIFFSetField(tiff_image, TIFFTAG_ROWSPERSTRIP, rows_per_strip);

	TIFFSetField(tiff_image, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
	TIFFSetField(tiff_image, TIFFTAG_FILLORDER, FILLORDER_MSB2LSB);
	TIFFSetField(tiff_image, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);

	/// \todo output float tiffs if desired
	TIFFSetField(tiff_image, TIFFTAG_SAMPLEFORMAT, SAMPLEFORMAT_UINT);

	//PLANARCONFIG_CONTIG    (pixel interlaced)
	//PLANARCONFIG_SEPARATE  (channel-interleave)

	TIFFSetField(tiff_image, TIFFTAG_XRESOLUTION, 1);
	TIFFSetField(tiff_image, TIFFTAG_YRESOLUTION, 1);
	TIFFSetField(tiff_image, TIFFTAG_RESOLUTIONUNIT, RESUNIT_NONE);

	//
	// encode
	//
	switch(bps) {

	case 8:
	{
		unsigned char * v = encodeChannels<unsigned char>(image, names, dw);
		stripEncode(tiff_image, (char *) v, bpc * width * height * spp, strips);
		delete [] v;
	}
	break;

	case 16:
	{
		/// \todo An unsigned short needn't be 16 bits long. Use typedefs from <stdint.h> instead.
		BOOST_STATIC_ASSERT( sizeof( unsigned short ) == 2 );
		unsigned short * v = encodeChannels<unsigned short>(image, names, dw);
		stripEncode(tiff_image, (char *) v, bpc * width * height * spp, strips);
		delete [] v;
	}
	break;

	case 32:
	{
		/// \todo An unsigned int needn't be 32 bits long. Use typedefs from <stdint.h> instead.
		BOOST_STATIC_ASSERT( sizeof( unsigned int ) == 4 );
		unsigned int * v = encodeChannels<unsigned int>(image, names, dw);
		stripEncode(tiff_image, (char *) v, bpc * width * height * spp, strips);
		delete [] v;
	}
	break;

	}

	// close the file
	TIFFClose(tiff_image);
	tiff_image = 0;
}
<|endoftext|>


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

#include <functional>
#include <iostream>
#include <list>
#include <map>

#include <boost/unordered_map.hpp>

#include "none.hpp"
#include "option.hpp"

// Forward declaration.
template <typename Key, typename Value>
class Cache;

// Outputs the key/value pairs from least to most-recently used.
template <typename Key, typename Value>
std::ostream& operator << (
    std::ostream& stream,
    const Cache<Key, Value>& c);

// Provides a least-recently used (LRU) cache of some predefined
// capacity. A "write" and a "read" both count as uses.
template <typename Key, typename Value>
class Cache
{
public:
  typedef std::list<Key> list;
  typedef boost::unordered_map<
    Key, std::pair<Value, typename list::iterator> > map;

  explicit Cache(int _capacity) : capacity(_capacity) {}

  void put(const Key& key, const Value& value)
  {
    typename map::iterator i = values.find(key);
    if (i == values.end()) {
      insert(key, value);
    } else {
      (*i).second.first = value;
      use(i);
    }
  }

  Option<Value> get(const Key& key)
  {
    typename map::iterator i = values.find(key);

    if (i != values.end()) {
      use(i);
      return (*i).second.first;
    }

    return None();
  }

private:
  // Not copyable, not assignable.
  Cache(const Cache&);
  Cache& operator = (const Cache&);

  // Give the operator access to our internals.
  friend std::ostream& operator << <>(
      std::ostream& stream,
      const Cache<Key, Value>& c);

  // Insert key/value into the cache.
  void insert(const Key& key, const Value& value)
  {
    if (keys.size() == capacity) {
      evict();
    }

    // Get a "pointer" into the lru list for efficient update.
    typename list::iterator i = keys.insert(keys.end(), key);

    // Save key/value and "pointer" into lru list.
    values.insert(std::make_pair(key, std::make_pair(value, i)));
  }

  // Updates the LRU ordering in the cache for the given iterator.
  void use(const typename map::iterator& i)
  {
    // Move the "pointer" to the end of the lru list.
    keys.splice(keys.end(), keys, (*i).second.second);

    // Now update the "pointer" so we can do this again.
    (*i).second.second = --keys.end();
  }

  // Evict the least-recently used element from the cache.
  void evict()
  {
    const typename map::iterator& i = values.find(keys.front());
    CHECK(i != values.end());
    values.erase(i);
    keys.pop_front();
  }

  // Size of the cache.
  int capacity;

  // Cache of values and "pointers" into the least-recently used list.
  map values;

  // Keys ordered by least-recently used.
  list keys;
};

template <typename Key, typename Value>
std::ostream& operator << (
    std::ostream& stream,
    const Cache<Key, Value>& c)
{
  typename Cache<Key, Value>::list::const_iterator i1;
  for (i1 = c.keys.begin(); i1 != c.keys.end(); i1++) {
    stream << *i1 << ": ";
    typename Cache<Key, Value>::map::const_iterator i2;
    i2 = c.values.find(*i1);
    CHECK(i2 != c.values.end());
    stream << *i2 << std::endl;
  }
  return stream;
}

#endif // __STOUT_CACHE_HPP__
<commit_msg>Added cache::erase and cache::size.<commit_after>/**
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#ifndef __STOUT_CACHE_HPP__
#define __STOUT_CACHE_HPP__

#include <functional>
#include <iostream>
#include <list>
#include <map>

#include <boost/unordered_map.hpp>

#include "none.hpp"
#include "option.hpp"

// Forward declaration.
template <typename Key, typename Value>
class Cache;

// Outputs the key/value pairs from least to most-recently used.
template <typename Key, typename Value>
std::ostream& operator << (
    std::ostream& stream,
    const Cache<Key, Value>& c);

// Provides a least-recently used (LRU) cache of some predefined
// capacity. A "write" and a "read" both count as uses.
template <typename Key, typename Value>
class Cache
{
public:
  typedef std::list<Key> list;
  typedef boost::unordered_map<
    Key, std::pair<Value, typename list::iterator> > map;

  explicit Cache(size_t _capacity) : capacity(_capacity) {}

  void put(const Key& key, const Value& value)
  {
    typename map::iterator i = values.find(key);
    if (i == values.end()) {
      insert(key, value);
    } else {
      (*i).second.first = value;
      use(i);
    }
  }

  Option<Value> get(const Key& key)
  {
    typename map::iterator i = values.find(key);

    if (i != values.end()) {
      use(i);
      return (*i).second.first;
    }

    return None();
  }

  Option<Value> erase(const Key& key)
  {
    typename map::iterator i = values.find(key);

    if (i != values.end()) {
      Value value = i->second.first;
      keys.erase(i->second.second);
      values.erase(i);
      return value;
    }

    return None();
  }

  size_t size() const { return keys.size(); }

private:
  // Not copyable, not assignable.
  Cache(const Cache&);
  Cache& operator = (const Cache&);

  // Give the operator access to our internals.
  friend std::ostream& operator << <>(
      std::ostream& stream,
      const Cache<Key, Value>& c);

  // Insert key/value into the cache.
  void insert(const Key& key, const Value& value)
  {
    if (keys.size() == capacity) {
      evict();
    }

    // Get a "pointer" into the lru list for efficient update.
    typename list::iterator i = keys.insert(keys.end(), key);

    // Save key/value and "pointer" into lru list.
    values.insert(std::make_pair(key, std::make_pair(value, i)));
  }

  // Updates the LRU ordering in the cache for the given iterator.
  void use(const typename map::iterator& i)
  {
    // Move the "pointer" to the end of the lru list.
    keys.splice(keys.end(), keys, (*i).second.second);

    // Now update the "pointer" so we can do this again.
    (*i).second.second = --keys.end();
  }

  // Evict the least-recently used element from the cache.
  void evict()
  {
    const typename map::iterator& i = values.find(keys.front());
    CHECK(i != values.end());
    values.erase(i);
    keys.pop_front();
  }

  // Size of the cache.
  const size_t capacity;

  // Cache of values and "pointers" into the least-recently used list.
  map values;

  // Keys ordered by least-recently used.
  list keys;
};

template <typename Key, typename Value>
std::ostream& operator << (
    std::ostream& stream,
    const Cache<Key, Value>& c)
{
  typename Cache<Key, Value>::list::const_iterator i1;
  for (i1 = c.keys.begin(); i1 != c.keys.end(); i1++) {
    stream << *i1 << ": ";
    typename Cache<Key, Value>::map::const_iterator i2;
    i2 = c.values.find(*i1);
    CHECK(i2 != c.values.end());
    stream << *i2 << std::endl;
  }
  return stream;
}

#endif // __STOUT_CACHE_HPP__
<|endoftext|>


<commit_before>/*
 * The Apache Software License, Version 1.1
 *
 *
 * Copyright (c) 1999 The Apache Software Foundation.  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.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Xalan" and "Apache Software Foundation" must
 *    not be used to endorse or promote products derived from this
 *    software without prior written permission. For written
 *    permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache",
 *    nor may "Apache" appear in their name, without prior written
 *    permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 APACHE SOFTWARE FOUNDATION OR
 * ITS 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.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation and was
 * originally based on software copyright (c) 1999, International
 * Business Machines, Inc., http://www.ibm.com.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 */
#if !defined(AIXDEFINITIONS_HEADER_GUARD_1357924680)
#define AIXDEFINITIONS_HEADER_GUARD_1357924680

// ---------------------------------------------------------------------------
//  A define in the build for each project is also used to control whether
//  the export keyword is from the project's viewpoint or the client's.
//  These defines provide the platform specific keywords that they need
//  to do this.
// ---------------------------------------------------------------------------

#define XALAN_PLATFORM_EXPORT
#define XALAN_PLATFORM_IMPORT
#define XALAN_PLATFORM_EXPORT_FUNCTION(T) T XALAN_PLATFORM_EXPORT
#define XALAN_PLATFORM_IMPORT_FUNCTION(T) T XALAN_PLATFORM_IMPORT

#define XALAN_OLD_STYLE_CASTS
#define XALAN_NO_NAMESPACES
#define XALAN_NO_MUTABLE
#define XALAN_SGI_BASED_STL
#define XALAN_NO_MEMBER_TEMPLATES
#define XALAN_AMBIGUOUS_EVEN_IF_NOT_CALLED
#define XALAN_CANNOT_MUTATE_ANONYMOUS_OBJECT
#define XALAN_CANNOT_DELETE_CONST
#define XALAN_BOOL_AS_INT
#define XALAN_NO_STD_ALLOCATORS
#define XALAN_NO_SELECTIVE_TEMPLATE_INSTANTIATION
#define XALAN_NO_ALGORITHMS_WITH_BUILTINS
#define XALAN_AUTO_PTR_NEEDS_DEFINITION
#define XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS
#define XALAN_NO_COVARIANT_RETURN_TYPE
#define XALAN_LSTRSUPPORT
#define XALAN_AUTO_PTR_REQUIRES_DEFINITION
#define XALAN_NEEDS_EXPLICIT_TEMPLATE_INSTANTIATION
#define XALAN_OSTREAM_HAS_WCHAR_T
#define XALAN_BIG_ENDIAN

// STL Port Definitions
#define __STL_NO_SGI_IOSTREAMS
#include <stl/_config.h>

#endif	// AIXDEFINITIONS_HEADER_GUARD_1357924680
<commit_msg>Removed obsolete #define.<commit_after>/*
 * The Apache Software License, Version 1.1
 *
 *
 * Copyright (c) 1999 The Apache Software Foundation.  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.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        Apache Software Foundation (http://www.apache.org/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "Xalan" and "Apache Software Foundation" must
 *    not be used to endorse or promote products derived from this
 *    software without prior written permission. For written
 *    permission, please contact apache@apache.org.
 *
 * 5. Products derived from this software may not be called "Apache",
 *    nor may "Apache" appear in their name, without prior written
 *    permission of the Apache Software Foundation.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 APACHE SOFTWARE FOUNDATION OR
 * ITS 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.
 * ====================================================================
 *
 * This software consists of voluntary contributions made by many
 * individuals on behalf of the Apache Software Foundation and was
 * originally based on software copyright (c) 1999, International
 * Business Machines, Inc., http://www.ibm.com.  For more
 * information on the Apache Software Foundation, please see
 * <http://www.apache.org/>.
 */
#if !defined(AIXDEFINITIONS_HEADER_GUARD_1357924680)
#define AIXDEFINITIONS_HEADER_GUARD_1357924680

// ---------------------------------------------------------------------------
//  A define in the build for each project is also used to control whether
//  the export keyword is from the project's viewpoint or the client's.
//  These defines provide the platform specific keywords that they need
//  to do this.
// ---------------------------------------------------------------------------

#define XALAN_PLATFORM_EXPORT
#define XALAN_PLATFORM_IMPORT
#define XALAN_PLATFORM_EXPORT_FUNCTION(T) T XALAN_PLATFORM_EXPORT
#define XALAN_PLATFORM_IMPORT_FUNCTION(T) T XALAN_PLATFORM_IMPORT

#define XALAN_OLD_STYLE_CASTS
#define XALAN_NO_NAMESPACES
#define XALAN_NO_MUTABLE
#define XALAN_SGI_BASED_STL
#define XALAN_NO_MEMBER_TEMPLATES
#define XALAN_AMBIGUOUS_EVEN_IF_NOT_CALLED
#define XALAN_CANNOT_DELETE_CONST
#define XALAN_BOOL_AS_INT
#define XALAN_NO_STD_ALLOCATORS
#define XALAN_NO_SELECTIVE_TEMPLATE_INSTANTIATION
#define XALAN_NO_ALGORITHMS_WITH_BUILTINS
#define XALAN_AUTO_PTR_NEEDS_DEFINITION
#define XALAN_NO_DEFAULT_TEMPLATE_ARGUMENTS
#define XALAN_NO_COVARIANT_RETURN_TYPE
#define XALAN_LSTRSUPPORT
#define XALAN_AUTO_PTR_REQUIRES_DEFINITION
#define XALAN_NEEDS_EXPLICIT_TEMPLATE_INSTANTIATION
#define XALAN_OSTREAM_HAS_WCHAR_T
#define XALAN_BIG_ENDIAN

// STL Port Definitions
#define __STL_NO_SGI_IOSTREAMS
#include <stl/_config.h>

#endif	// AIXDEFINITIONS_HEADER_GUARD_1357924680
<|endoftext|>


<commit_before>/***************************************************************************
 *   Copyright (c) Yorik van Havre (yorik@uncreated.net) 2014              *
 *                                                                         *
 *   This file is part of the FreeCAD CAx development system.              *
 *                                                                         *
 *   This library is free software; you can redistribute it and/or         *
 *   modify it under the terms of the GNU Library General Public           *
 *   License as published by the Free Software Foundation; either          *
 *   version 2 of the License, or (at your option) any later version.      *
 *                                                                         *
 *   This library  is distributed in the hope that it will be useful,      *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU Library General Public License for more details.                  *
 *                                                                         *
 *   You should have received a copy of the GNU Library General Public     *
 *   License along with this library; see the file COPYING.LIB. If not,    *
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
 *   Suite 330, Boston, MA  02111-1307, USA                                *
 *                                                                         *
 ***************************************************************************/

#include "PreCompiled.h"

#ifndef _PreComp_

#endif
#include <Base/Writer.h>
#include <Base/Reader.h>
#include <Base/Exception.h>
#include "Tooltable.h"

using namespace Base;
using namespace Path;

// TOOL

TYPESYSTEM_SOURCE(Path::Tool , Base::Persistence);

// Constructors & destructors

Tool::Tool(const char* name,
           ToolType type,
           ToolMaterial /*material*/,
           double diameter,
           double lengthoffset,
           double flatradius,
           double cornerradius,
           double cuttingedgeangle,
           double cuttingedgeheight)
:Name(name),Type(type),Material(MATUNDEFINED),Diameter(diameter),LengthOffset(lengthoffset),
FlatRadius(flatradius),CornerRadius(cornerradius),CuttingEdgeAngle(cuttingedgeangle),
CuttingEdgeHeight(cuttingedgeheight)
{
}

Tool::Tool()
{
    Type = UNDEFINED;
    Material = MATUNDEFINED;
    Diameter = 0;
    LengthOffset = 0;
    FlatRadius = 0;
    CornerRadius = 0;
    CuttingEdgeAngle = 0;
    CuttingEdgeHeight = 0;
}

Tool::~Tool()
{
}

// Reimplemented from base class

unsigned int Tool::getMemSize (void) const
{
    return 0;
}

void Tool::Save (Writer &writer) const
{
    writer.Stream() << writer.ind() << "<Tool "
                    << "name=\"" << Name << "\" "
                    << "diameter=\"" << Diameter << "\" "
                    << "length=\"" << LengthOffset << "\" "
                    << "flat=\"" <<  FlatRadius << "\" "
                    << "corner=\"" << CornerRadius << "\" "
                    << "angle=\"" << CuttingEdgeAngle << "\" "
                    << "height=\"" << CuttingEdgeHeight << "\" "
                    << "type=\"" << TypeName(Type) << "\" "
                    << "mat=\"" << MaterialName(Material) << "\" "
                    << "/>" << std::endl;
}

void Tool::Restore(XMLReader &reader)
{
    reader.readElement("Tool");
    Name = reader.getAttribute("name");
    Diameter          = reader.hasAttribute("diameter") ? (double) reader.getAttributeAsFloat("diameter") : 0.0;
    LengthOffset      = reader.hasAttribute("length")   ? (double) reader.getAttributeAsFloat("length")   : 0.0;
    FlatRadius        = reader.hasAttribute("flat")     ? (double) reader.getAttributeAsFloat("flat")     : 0.0;
    CornerRadius      = reader.hasAttribute("corner")   ? (double) reader.getAttributeAsFloat("corner")   : 0.0;
    CuttingEdgeAngle  = reader.hasAttribute("angle")    ? (double) reader.getAttributeAsFloat("angle")    : 0.0;
    CuttingEdgeHeight = reader.hasAttribute("height")   ? (double) reader.getAttributeAsFloat("height")   : 0.0;
    std::string type  = reader.hasAttribute("type")     ? reader.getAttribute("type") : "";
    std::string mat   = reader.hasAttribute("mat")      ? reader.getAttribute("mat")  : "";

    if(type=="EndMill")
        Type = Tool::ENDMILL;
    else if(type=="Drill")
        Type = Tool::DRILL;
    else if(type=="CenterDrill")
        Type = Tool::CENTERDRILL;
    else if(type=="CounterSink")
        Type = Tool::COUNTERSINK;
    else if(type=="CounterBore")
        Type = Tool::COUNTERBORE;
    else if(type=="Reamer")
        Type = Tool::REAMER;
    else if(type=="Tap")
        Type = Tool::TAP;
    else if(type=="SlotCutter")
        Type = Tool::SLOTCUTTER;
    else if(type=="BallEndMill")
        Type = Tool::BALLENDMILL;
    else if(type=="ChamferMill")
        Type = Tool::CHAMFERMILL;
    else if(type=="CornerRound")
        Type = Tool::CORNERROUND;
    else if(type=="Engraver")
        Type = Tool::ENGRAVER;
    else
        Type = Tool::UNDEFINED;

    if(mat=="Carbide")
        Material = Tool::CARBIDE;
    else if(mat=="HighSpeedSteel")
        Material = Tool::HIGHSPEEDSTEEL;
    else if(mat=="HighCarbonToolSteel")
        Material = Tool::HIGHCARBONTOOLSTEEL;
    else if(mat=="CastAlloy")
        Material = Tool::CASTALLOY;
    else if(mat=="Ceramics")
        Material = Tool::CERAMICS;
    else if(mat=="Diamond")
        Material = Tool::DIAMOND;
    else if(mat=="Sialon")
        Material = Tool::SIALON;
    else
        Material = Tool::MATUNDEFINED;
}

const char* Tool::TypeName(Tool::ToolType typ) {
    switch (typ) {
      case Tool::DRILL:
        return "Drill";
      case Tool::CENTERDRILL:
        return "CenterDrill";
      case Tool::COUNTERSINK:
        return "CounterSink";
      case Tool::COUNTERBORE:
        return "CounterBore";
      case Tool::REAMER:
        return "Reamer";
      case Tool::TAP:
        return "Tap";
      case Tool::ENDMILL:
        return "EndMill";
      case Tool::SLOTCUTTER:
        return "SlotCutter";
      case Tool::BALLENDMILL:
        return "BallEndMill";
      case Tool::CHAMFERMILL:
        return "ChamferMill";
      case Tool::CORNERROUND:
        return "CornerRound";
      case Tool::ENGRAVER:
        return "Engraver";
      case Tool::UNDEFINED:
        return "Undefined";
    }
    return "Undefined";
}

const char* Tool::MaterialName(Tool::ToolMaterial mat)
{
  switch (mat) {
    case Tool::HIGHSPEEDSTEEL:
        return "HighSpeedSteel";
    case Tool::CARBIDE:
        return "Carbide";
    case Tool::HIGHCARBONTOOLSTEEL:
        return "HighCarbonToolSteel";
    case Tool::CASTALLOY:
        return "CastAlloy";
    case Tool::CERAMICS:
        return "Ceramics";
    case Tool::DIAMOND:
        return "Diamond";
    case Tool::SIALON:
        return "Sialon";
    case Tool::MATUNDEFINED:
        return "Undefined";
  }
  return "Undefined";
}

// TOOLTABLE

TYPESYSTEM_SOURCE(Path::Tooltable , Base::Persistence);

Tooltable::Tooltable()
{
}

Tooltable::~Tooltable()
{
}

void Tooltable::addTool(const Tool &tool)
{
    Tool *tmp = new Tool(tool);
    if (!Tools.empty()) {
        int max = 0;
        for(std::map<int,Tool*>::const_iterator i = Tools.begin(); i != Tools.end(); ++i) {
            int k = i->first;
            if (k > max)
                max = k;
        }
        Tools[max+1]= tmp;
    } else
        Tools[1] = tmp;
}

void Tooltable::setTool(const Tool &tool, int pos)
{
    if (pos == -1) {
        addTool(tool);
    } else {
        Tool *tmp = new Tool(tool);
        Tools[pos] = tmp;
    }
}

void Tooltable::deleteTool(int pos)
{
    if (Tools.find(pos) != Tools.end()) {
        Tools.erase(pos);
    } else {
        throw Base::Exception("Index not found");
    }
}

unsigned int Tooltable::getMemSize (void) const
{
    return 0;
}

void Tooltable::Save (Writer &writer) const
{
    writer.Stream() << writer.ind() << "<Tooltable count=\"" <<  getSize() <<"\">" << std::endl;
    writer.incInd();
    for(std::map<int,Tool*>::const_iterator i = Tools.begin(); i != Tools.end(); ++i) {
        int k = i->first;
        Tool *v = i->second;
        writer.Stream() << writer.ind() << "<Toolslot number=\"" << k << "\">" << std::endl;
        writer.incInd();
        v->Save(writer);
        writer.decInd();
        writer.Stream() << writer.ind() << "</Toolslot>" << std::endl;
    }
    writer.decInd();
    writer.Stream() << writer.ind() << "</Tooltable>" << std::endl ;

}

void Tooltable::Restore (XMLReader &reader)
{
    Tools.clear();
    reader.readElement("Tooltable");
    int count = reader.getAttributeAsInteger("count");
    for (int i = 0; i < count; i++) {
        reader.readElement("Toolslot");
        int id = reader.getAttributeAsInteger("number");
        Tool *tmp = new Tool();
        tmp->Restore(reader);
        Tools[id] = tmp;
    }
}

<commit_msg>fixes #0003260: Double Quote in tool name is not escaped in FCStd file<commit_after>/***************************************************************************
 *   Copyright (c) Yorik van Havre (yorik@uncreated.net) 2014              *
 *                                                                         *
 *   This file is part of the FreeCAD CAx development system.              *
 *                                                                         *
 *   This library is free software; you can redistribute it and/or         *
 *   modify it under the terms of the GNU Library General Public           *
 *   License as published by the Free Software Foundation; either          *
 *   version 2 of the License, or (at your option) any later version.      *
 *                                                                         *
 *   This library  is distributed in the hope that it will be useful,      *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU Library General Public License for more details.                  *
 *                                                                         *
 *   You should have received a copy of the GNU Library General Public     *
 *   License along with this library; see the file COPYING.LIB. If not,    *
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
 *   Suite 330, Boston, MA  02111-1307, USA                                *
 *                                                                         *
 ***************************************************************************/

#include "PreCompiled.h"

#ifndef _PreComp_

#endif
#include <Base/Writer.h>
#include <Base/Reader.h>
#include <Base/Exception.h>
#include "Tooltable.h"

using namespace Base;
using namespace Path;

// TOOL

TYPESYSTEM_SOURCE(Path::Tool , Base::Persistence);

// Constructors & destructors

Tool::Tool(const char* name,
           ToolType type,
           ToolMaterial /*material*/,
           double diameter,
           double lengthoffset,
           double flatradius,
           double cornerradius,
           double cuttingedgeangle,
           double cuttingedgeheight)
:Name(name),Type(type),Material(MATUNDEFINED),Diameter(diameter),LengthOffset(lengthoffset),
FlatRadius(flatradius),CornerRadius(cornerradius),CuttingEdgeAngle(cuttingedgeangle),
CuttingEdgeHeight(cuttingedgeheight)
{
}

Tool::Tool()
{
    Type = UNDEFINED;
    Material = MATUNDEFINED;
    Diameter = 0;
    LengthOffset = 0;
    FlatRadius = 0;
    CornerRadius = 0;
    CuttingEdgeAngle = 0;
    CuttingEdgeHeight = 0;
}

Tool::~Tool()
{
}

// Reimplemented from base class

unsigned int Tool::getMemSize (void) const
{
    return 0;
}

void Tool::Save (Writer &writer) const
{
    writer.Stream() << writer.ind() << "<Tool "
                    << "name=\"" << encodeAttribute(Name) << "\" "
                    << "diameter=\"" << Diameter << "\" "
                    << "length=\"" << LengthOffset << "\" "
                    << "flat=\"" <<  FlatRadius << "\" "
                    << "corner=\"" << CornerRadius << "\" "
                    << "angle=\"" << CuttingEdgeAngle << "\" "
                    << "height=\"" << CuttingEdgeHeight << "\" "
                    << "type=\"" << TypeName(Type) << "\" "
                    << "mat=\"" << MaterialName(Material) << "\" "
                    << "/>" << std::endl;
}

void Tool::Restore(XMLReader &reader)
{
    reader.readElement("Tool");
    Name = reader.getAttribute("name");
    Diameter          = reader.hasAttribute("diameter") ? (double) reader.getAttributeAsFloat("diameter") : 0.0;
    LengthOffset      = reader.hasAttribute("length")   ? (double) reader.getAttributeAsFloat("length")   : 0.0;
    FlatRadius        = reader.hasAttribute("flat")     ? (double) reader.getAttributeAsFloat("flat")     : 0.0;
    CornerRadius      = reader.hasAttribute("corner")   ? (double) reader.getAttributeAsFloat("corner")   : 0.0;
    CuttingEdgeAngle  = reader.hasAttribute("angle")    ? (double) reader.getAttributeAsFloat("angle")    : 0.0;
    CuttingEdgeHeight = reader.hasAttribute("height")   ? (double) reader.getAttributeAsFloat("height")   : 0.0;
    std::string type  = reader.hasAttribute("type")     ? reader.getAttribute("type") : "";
    std::string mat   = reader.hasAttribute("mat")      ? reader.getAttribute("mat")  : "";

    if(type=="EndMill")
        Type = Tool::ENDMILL;
    else if(type=="Drill")
        Type = Tool::DRILL;
    else if(type=="CenterDrill")
        Type = Tool::CENTERDRILL;
    else if(type=="CounterSink")
        Type = Tool::COUNTERSINK;
    else if(type=="CounterBore")
        Type = Tool::COUNTERBORE;
    else if(type=="Reamer")
        Type = Tool::REAMER;
    else if(type=="Tap")
        Type = Tool::TAP;
    else if(type=="SlotCutter")
        Type = Tool::SLOTCUTTER;
    else if(type=="BallEndMill")
        Type = Tool::BALLENDMILL;
    else if(type=="ChamferMill")
        Type = Tool::CHAMFERMILL;
    else if(type=="CornerRound")
        Type = Tool::CORNERROUND;
    else if(type=="Engraver")
        Type = Tool::ENGRAVER;
    else
        Type = Tool::UNDEFINED;

    if(mat=="Carbide")
        Material = Tool::CARBIDE;
    else if(mat=="HighSpeedSteel")
        Material = Tool::HIGHSPEEDSTEEL;
    else if(mat=="HighCarbonToolSteel")
        Material = Tool::HIGHCARBONTOOLSTEEL;
    else if(mat=="CastAlloy")
        Material = Tool::CASTALLOY;
    else if(mat=="Ceramics")
        Material = Tool::CERAMICS;
    else if(mat=="Diamond")
        Material = Tool::DIAMOND;
    else if(mat=="Sialon")
        Material = Tool::SIALON;
    else
        Material = Tool::MATUNDEFINED;
}

const char* Tool::TypeName(Tool::ToolType typ) {
    switch (typ) {
      case Tool::DRILL:
        return "Drill";
      case Tool::CENTERDRILL:
        return "CenterDrill";
      case Tool::COUNTERSINK:
        return "CounterSink";
      case Tool::COUNTERBORE:
        return "CounterBore";
      case Tool::REAMER:
        return "Reamer";
      case Tool::TAP:
        return "Tap";
      case Tool::ENDMILL:
        return "EndMill";
      case Tool::SLOTCUTTER:
        return "SlotCutter";
      case Tool::BALLENDMILL:
        return "BallEndMill";
      case Tool::CHAMFERMILL:
        return "ChamferMill";
      case Tool::CORNERROUND:
        return "CornerRound";
      case Tool::ENGRAVER:
        return "Engraver";
      case Tool::UNDEFINED:
        return "Undefined";
    }
    return "Undefined";
}

const char* Tool::MaterialName(Tool::ToolMaterial mat)
{
  switch (mat) {
    case Tool::HIGHSPEEDSTEEL:
        return "HighSpeedSteel";
    case Tool::CARBIDE:
        return "Carbide";
    case Tool::HIGHCARBONTOOLSTEEL:
        return "HighCarbonToolSteel";
    case Tool::CASTALLOY:
        return "CastAlloy";
    case Tool::CERAMICS:
        return "Ceramics";
    case Tool::DIAMOND:
        return "Diamond";
    case Tool::SIALON:
        return "Sialon";
    case Tool::MATUNDEFINED:
        return "Undefined";
  }
  return "Undefined";
}

// TOOLTABLE

TYPESYSTEM_SOURCE(Path::Tooltable , Base::Persistence);

Tooltable::Tooltable()
{
}

Tooltable::~Tooltable()
{
}

void Tooltable::addTool(const Tool &tool)
{
    Tool *tmp = new Tool(tool);
    if (!Tools.empty()) {
        int max = 0;
        for(std::map<int,Tool*>::const_iterator i = Tools.begin(); i != Tools.end(); ++i) {
            int k = i->first;
            if (k > max)
                max = k;
        }
        Tools[max+1]= tmp;
    } else
        Tools[1] = tmp;
}

void Tooltable::setTool(const Tool &tool, int pos)
{
    if (pos == -1) {
        addTool(tool);
    } else {
        Tool *tmp = new Tool(tool);
        Tools[pos] = tmp;
    }
}

void Tooltable::deleteTool(int pos)
{
    if (Tools.find(pos) != Tools.end()) {
        Tools.erase(pos);
    } else {
        throw Base::Exception("Index not found");
    }
}

unsigned int Tooltable::getMemSize (void) const
{
    return 0;
}

void Tooltable::Save (Writer &writer) const
{
    writer.Stream() << writer.ind() << "<Tooltable count=\"" <<  getSize() <<"\">" << std::endl;
    writer.incInd();
    for(std::map<int,Tool*>::const_iterator i = Tools.begin(); i != Tools.end(); ++i) {
        int k = i->first;
        Tool *v = i->second;
        writer.Stream() << writer.ind() << "<Toolslot number=\"" << k << "\">" << std::endl;
        writer.incInd();
        v->Save(writer);
        writer.decInd();
        writer.Stream() << writer.ind() << "</Toolslot>" << std::endl;
    }
    writer.decInd();
    writer.Stream() << writer.ind() << "</Tooltable>" << std::endl ;

}

void Tooltable::Restore (XMLReader &reader)
{
    Tools.clear();
    reader.readElement("Tooltable");
    int count = reader.getAttributeAsInteger("count");
    for (int i = 0; i < count; i++) {
        reader.readElement("Toolslot");
        int id = reader.getAttributeAsInteger("number");
        Tool *tmp = new Tool();
        tmp->Restore(reader);
        Tools[id] = tmp;
    }
}

<|endoftext|>


<commit_before>/**
   @file abstractsensor_i.cpp
   @brief Base class for sensor interface

   Copyright (C) 2009-2010 Nokia Corporation

   @author Joep van Gassel <joep.van.gassel@nokia.com>
   @author Timo Rongas <ext-timo.2.rongas@nokia.com>
   @author Antti Virtanen <antti.i.virtanen@nokia.com>

   This file is part of Sensord.

   Sensord 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.

   Sensord 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 Sensord.  If not, see <http://www.gnu.org/licenses/>.

 */

#include "sensormanagerinterface.h"
#include "abstractsensor_i.h"

struct AbstractSensorChannelInterface::AbstractSensorChannelInterfaceImpl
{
    AbstractSensorChannelInterfaceImpl(QObject* parent, int sessionId);

    SensorError errorCode_;
    QString errorString_;
    int sessionId_;
    int interval_;
    unsigned int bufferInterval_;
    unsigned int bufferSize_;
    SocketReader socketReader_;
    bool running_;
    bool standbyOverride_;
};

AbstractSensorChannelInterface::AbstractSensorChannelInterfaceImpl::AbstractSensorChannelInterfaceImpl(QObject* parent, int sessionId) :
    sessionId_(sessionId),
    interval_(0),
    bufferInterval_(0),
    bufferSize_(1),
    socketReader_(parent),
    running_(false),
    standbyOverride_(false)
{
}

AbstractSensorChannelInterface::AbstractSensorChannelInterface(const QString& path, const char* interfaceName, int sessionId) :
    QDBusAbstractInterface(SERVICE_NAME, path, interfaceName, QDBusConnection::systemBus(), 0),
    pimpl_(new AbstractSensorChannelInterfaceImpl(this, sessionId))
{
    if (!pimpl_->socketReader_.initiateConnection(sessionId)) {
        setError(SClientSocketError, "Socket connection failed.");
        // TODO: Invalidate!
    }

    qDBusRegisterMetaType<DataRange>();

    Q_ASSERT ( isValid() );
}

AbstractSensorChannelInterface::~AbstractSensorChannelInterface()
{
    if ( isValid() )
        release();
    if (!pimpl_->socketReader_.dropConnection())
        setError(SClientSocketError, "Socket disconnect failed.");
    delete pimpl_;
}

SocketReader& AbstractSensorChannelInterface::getSocketReader() const
{
    return pimpl_->socketReader_;
}

bool AbstractSensorChannelInterface::release()
{
    // ToDo: note that after release this interace becomes invalid (this should be handled correctly)
    return SensorManagerInterface::instance().releaseInterface(id(), pimpl_->sessionId_);
}

void AbstractSensorChannelInterface::setError(SensorError errorCode, const QString& errorString)
{
    pimpl_->errorCode_   = errorCode;
    pimpl_->errorString_ = errorString;

    //emit errorSignal(errorCode);
}

QDBusReply<void> AbstractSensorChannelInterface::start()
{
    return start(pimpl_->sessionId_);
}

QDBusReply<void> AbstractSensorChannelInterface::stop()
{
    return stop(pimpl_->sessionId_);
}

QDBusReply<void> AbstractSensorChannelInterface::start(int sessionId)
{
    clearError();

    if (pimpl_->running_) {
        return QDBusReply<void>();
    }
    pimpl_->running_ = true;

    connect(pimpl_->socketReader_.socket(), SIGNAL(readyRead()), this, SLOT(dataReceived()));

    QList<QVariant> argumentList;
    argumentList << qVariantFromValue(sessionId);
    QDBusReply<void> returnValue = callWithArgumentList(QDBus::Block, QLatin1String("start"), argumentList);

    if (pimpl_->standbyOverride_)
    {
        setStandbyOverride(sessionId, true);
    }
    /// Send interval request when started.
    setInterval(sessionId, pimpl_->interval_);
    setBufferInterval(sessionId, pimpl_->bufferInterval_);
    setBufferSize(sessionId, pimpl_->bufferSize_);

    return returnValue;
}

QDBusReply<void> AbstractSensorChannelInterface::stop(int sessionId)
{
    clearError();

    if (!pimpl_->running_) {
        return QDBusReply<void>();
    }
    pimpl_->running_ = false ;

    disconnect(pimpl_->socketReader_.socket(), SIGNAL(readyRead()), this, SLOT(dataReceived()));
    setStandbyOverride(sessionId, false);
    /// Drop interval requests when stopped
    setInterval(sessionId, 0);

    QList<QVariant> argumentList;
    argumentList << qVariantFromValue(sessionId);
    return callWithArgumentList(QDBus::Block, QLatin1String("stop"), argumentList);
}

QDBusReply<void> AbstractSensorChannelInterface::setInterval(int sessionId, int value)
{
    clearError();

    QList<QVariant> argumentList;
    argumentList << qVariantFromValue(sessionId) << qVariantFromValue(value);
    return callWithArgumentList(QDBus::Block, QLatin1String("setInterval"), argumentList);
}

QDBusReply<void> AbstractSensorChannelInterface::setBufferInterval(int sessionId, unsigned int value)
{
    clearError();

    QList<QVariant> argumentList;
    argumentList << qVariantFromValue(sessionId) << qVariantFromValue(value);
    return callWithArgumentList(QDBus::Block, QLatin1String("setBufferInterval"), argumentList);
}

QDBusReply<void> AbstractSensorChannelInterface::setBufferSize(int sessionId, unsigned int value)
{
    clearError();

    QList<QVariant> argumentList;
    argumentList << qVariantFromValue(sessionId) << qVariantFromValue(value);
    return callWithArgumentList(QDBus::Block, QLatin1String("setBufferSize"), argumentList);
}

QDBusReply<bool> AbstractSensorChannelInterface::setStandbyOverride(int sessionId, bool value)
{
    clearError();

    QList<QVariant> argumentList;
    argumentList << qVariantFromValue(sessionId) << qVariantFromValue(value);
    return callWithArgumentList(QDBus::Block, QLatin1String("setStandbyOverride"), argumentList);
}

DataRangeList AbstractSensorChannelInterface::getAvailableDataRanges()
{
    QDBusReply<DataRangeList> ret = call(QDBus::Block, QLatin1String("getAvailableDataRanges"));
    return ret.value();
}

DataRange AbstractSensorChannelInterface::getCurrentDataRange()
{
    clearError();
    QDBusReply<DataRange> retVal = call(QDBus::Block, QLatin1String("getCurrentDataRange"));
    return retVal.value();
}

void AbstractSensorChannelInterface::requestDataRange(DataRange range)
{
    clearError();
    call(QDBus::Block, QLatin1String("requestDataRange"), qVariantFromValue(pimpl_->sessionId_), qVariantFromValue(range));
}

void AbstractSensorChannelInterface::removeDataRangeRequest()
{
    clearError();
    call(QDBus::Block, QLatin1String("removeDataRangeRequest"), qVariantFromValue(pimpl_->sessionId_));
}

DataRangeList AbstractSensorChannelInterface::getAvailableIntervals()
{
    QDBusReply<DataRangeList> ret = call(QDBus::Block, QLatin1String("getAvailableIntervals"));
    return ret.value();
}

IntegerRangeList AbstractSensorChannelInterface::getAvailableBufferIntervals()
{
    QDBusReply<IntegerRangeList> ret = call(QDBus::Block, QLatin1String("getAvailableBufferIntervals"));
    return ret.value();
}

IntegerRangeList AbstractSensorChannelInterface::getAvailableBufferSizes()
{
    QDBusReply<IntegerRangeList> ret = call(QDBus::Block, QLatin1String("getAvailableBufferSizes"));
    return ret.value();
}

int AbstractSensorChannelInterface::sessionId() const
{
    return pimpl_->sessionId_;
}

SensorError AbstractSensorChannelInterface::errorCode() const
{
    // TODO: This solution may introduce problems, if errors are
    //       not cleared before another happens.
    if (pimpl_->errorCode_ != SNoError) {
        return pimpl_->errorCode_;
    }
    return static_cast<SensorError>(errorCodeInt());
}

QString AbstractSensorChannelInterface::errorString() const
{
    if (pimpl_->errorCode_ != SNoError) {
        return pimpl_->errorString_;
    }
    return qvariant_cast<QString>(internalPropGet("errorString"));
}

QString AbstractSensorChannelInterface::description() const
{
    return qvariant_cast<QString>(internalPropGet("description"));
}

QString AbstractSensorChannelInterface::id() const
{
    return qvariant_cast<QString>(internalPropGet("id"));
}

int AbstractSensorChannelInterface::interval() const
{
    return qvariant_cast<int>(internalPropGet("interval"));
}

void AbstractSensorChannelInterface::setInterval(int value)
{
    pimpl_->interval_ = value;
    if (pimpl_->running_)
        setInterval(pimpl_->sessionId_, value);
}

unsigned int AbstractSensorChannelInterface::bufferInterval() const
{
    return qvariant_cast<unsigned int>(internalPropGet("bufferInterval"));
}

void AbstractSensorChannelInterface::setBufferInterval(unsigned int value)
{
    pimpl_->bufferInterval_ = value;
    if (!pimpl_->running_)
        setBufferInterval(pimpl_->sessionId_, value);
}

unsigned int AbstractSensorChannelInterface::bufferSize() const
{
    return qvariant_cast<unsigned int>(internalPropGet("bufferSize"));
}

void AbstractSensorChannelInterface::setBufferSize(unsigned int value)
{
    pimpl_->bufferSize_ = value;
    if (!pimpl_->running_)
        setBufferSize(pimpl_->sessionId_, value);
}

bool AbstractSensorChannelInterface::standbyOverride() const
{
    return pimpl_->standbyOverride_ || qvariant_cast<bool>(internalPropGet("standbyOverride"));
}

bool AbstractSensorChannelInterface::setStandbyOverride(bool override)
{
    pimpl_->standbyOverride_ = override;
    return setStandbyOverride(pimpl_->sessionId_, override);
}

QString AbstractSensorChannelInterface::type() const
{
    return qvariant_cast<QString>(internalPropGet("type"));
}

int AbstractSensorChannelInterface::errorCodeInt() const
{
    return static_cast<SensorManagerError>(qvariant_cast<int>(internalPropGet("errorCodeInt")));
}

void AbstractSensorChannelInterface::clearError()
{
    pimpl_->errorCode_ = SNoError;
    pimpl_->errorString_.clear();
}

void AbstractSensorChannelInterface::dataReceived()
{
}

bool AbstractSensorChannelInterface::read(void* buffer, int size)
{
    return pimpl_->socketReader_.read(buffer, size);
}
<commit_msg>Sensor starting won't anymore assert if sensord is dead.<commit_after>/**
   @file abstractsensor_i.cpp
   @brief Base class for sensor interface

   Copyright (C) 2009-2010 Nokia Corporation

   @author Joep van Gassel <joep.van.gassel@nokia.com>
   @author Timo Rongas <ext-timo.2.rongas@nokia.com>
   @author Antti Virtanen <antti.i.virtanen@nokia.com>

   This file is part of Sensord.

   Sensord 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.

   Sensord 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 Sensord.  If not, see <http://www.gnu.org/licenses/>.

 */

#include "sensormanagerinterface.h"
#include "abstractsensor_i.h"

struct AbstractSensorChannelInterface::AbstractSensorChannelInterfaceImpl
{
    AbstractSensorChannelInterfaceImpl(QObject* parent, int sessionId);

    SensorError errorCode_;
    QString errorString_;
    int sessionId_;
    int interval_;
    unsigned int bufferInterval_;
    unsigned int bufferSize_;
    SocketReader socketReader_;
    bool running_;
    bool standbyOverride_;
};

AbstractSensorChannelInterface::AbstractSensorChannelInterfaceImpl::AbstractSensorChannelInterfaceImpl(QObject* parent, int sessionId) :
    sessionId_(sessionId),
    interval_(0),
    bufferInterval_(0),
    bufferSize_(1),
    socketReader_(parent),
    running_(false),
    standbyOverride_(false)
{
}

AbstractSensorChannelInterface::AbstractSensorChannelInterface(const QString& path, const char* interfaceName, int sessionId) :
    QDBusAbstractInterface(SERVICE_NAME, path, interfaceName, QDBusConnection::systemBus(), 0),
    pimpl_(new AbstractSensorChannelInterfaceImpl(this, sessionId))
{
    if (!pimpl_->socketReader_.initiateConnection(sessionId)) {
        setError(SClientSocketError, "Socket connection failed.");
    }
}

AbstractSensorChannelInterface::~AbstractSensorChannelInterface()
{
    if ( isValid() )
        release();
    if (!pimpl_->socketReader_.dropConnection())
        setError(SClientSocketError, "Socket disconnect failed.");
    delete pimpl_;
}

SocketReader& AbstractSensorChannelInterface::getSocketReader() const
{
    return pimpl_->socketReader_;
}

bool AbstractSensorChannelInterface::release()
{
    // ToDo: note that after release this interace becomes invalid (this should be handled correctly)
    return SensorManagerInterface::instance().releaseInterface(id(), pimpl_->sessionId_);
}

void AbstractSensorChannelInterface::setError(SensorError errorCode, const QString& errorString)
{
    pimpl_->errorCode_   = errorCode;
    pimpl_->errorString_ = errorString;

    //emit errorSignal(errorCode);
}

QDBusReply<void> AbstractSensorChannelInterface::start()
{
    return start(pimpl_->sessionId_);
}

QDBusReply<void> AbstractSensorChannelInterface::stop()
{
    return stop(pimpl_->sessionId_);
}

QDBusReply<void> AbstractSensorChannelInterface::start(int sessionId)
{
    clearError();

    if (pimpl_->running_) {
        return QDBusReply<void>();
    }
    pimpl_->running_ = true;

    connect(pimpl_->socketReader_.socket(), SIGNAL(readyRead()), this, SLOT(dataReceived()));

    QList<QVariant> argumentList;
    argumentList << qVariantFromValue(sessionId);
    QDBusReply<void> returnValue = callWithArgumentList(QDBus::Block, QLatin1String("start"), argumentList);

    if (pimpl_->standbyOverride_)
    {
        setStandbyOverride(sessionId, true);
    }
    /// Send interval request when started.
    setInterval(sessionId, pimpl_->interval_);
    setBufferInterval(sessionId, pimpl_->bufferInterval_);
    setBufferSize(sessionId, pimpl_->bufferSize_);

    return returnValue;
}

QDBusReply<void> AbstractSensorChannelInterface::stop(int sessionId)
{
    clearError();

    if (!pimpl_->running_) {
        return QDBusReply<void>();
    }
    pimpl_->running_ = false ;

    disconnect(pimpl_->socketReader_.socket(), SIGNAL(readyRead()), this, SLOT(dataReceived()));
    setStandbyOverride(sessionId, false);
    /// Drop interval requests when stopped
    setInterval(sessionId, 0);

    QList<QVariant> argumentList;
    argumentList << qVariantFromValue(sessionId);
    return callWithArgumentList(QDBus::Block, QLatin1String("stop"), argumentList);
}

QDBusReply<void> AbstractSensorChannelInterface::setInterval(int sessionId, int value)
{
    clearError();

    QList<QVariant> argumentList;
    argumentList << qVariantFromValue(sessionId) << qVariantFromValue(value);
    return callWithArgumentList(QDBus::Block, QLatin1String("setInterval"), argumentList);
}

QDBusReply<void> AbstractSensorChannelInterface::setBufferInterval(int sessionId, unsigned int value)
{
    clearError();

    QList<QVariant> argumentList;
    argumentList << qVariantFromValue(sessionId) << qVariantFromValue(value);
    return callWithArgumentList(QDBus::Block, QLatin1String("setBufferInterval"), argumentList);
}

QDBusReply<void> AbstractSensorChannelInterface::setBufferSize(int sessionId, unsigned int value)
{
    clearError();

    QList<QVariant> argumentList;
    argumentList << qVariantFromValue(sessionId) << qVariantFromValue(value);
    return callWithArgumentList(QDBus::Block, QLatin1String("setBufferSize"), argumentList);
}

QDBusReply<bool> AbstractSensorChannelInterface::setStandbyOverride(int sessionId, bool value)
{
    clearError();

    QList<QVariant> argumentList;
    argumentList << qVariantFromValue(sessionId) << qVariantFromValue(value);
    return callWithArgumentList(QDBus::Block, QLatin1String("setStandbyOverride"), argumentList);
}

DataRangeList AbstractSensorChannelInterface::getAvailableDataRanges()
{
    QDBusReply<DataRangeList> ret = call(QDBus::Block, QLatin1String("getAvailableDataRanges"));
    return ret.value();
}

DataRange AbstractSensorChannelInterface::getCurrentDataRange()
{
    clearError();
    QDBusReply<DataRange> retVal = call(QDBus::Block, QLatin1String("getCurrentDataRange"));
    return retVal.value();
}

void AbstractSensorChannelInterface::requestDataRange(DataRange range)
{
    clearError();
    call(QDBus::Block, QLatin1String("requestDataRange"), qVariantFromValue(pimpl_->sessionId_), qVariantFromValue(range));
}

void AbstractSensorChannelInterface::removeDataRangeRequest()
{
    clearError();
    call(QDBus::Block, QLatin1String("removeDataRangeRequest"), qVariantFromValue(pimpl_->sessionId_));
}

DataRangeList AbstractSensorChannelInterface::getAvailableIntervals()
{
    QDBusReply<DataRangeList> ret = call(QDBus::Block, QLatin1String("getAvailableIntervals"));
    return ret.value();
}

IntegerRangeList AbstractSensorChannelInterface::getAvailableBufferIntervals()
{
    QDBusReply<IntegerRangeList> ret = call(QDBus::Block, QLatin1String("getAvailableBufferIntervals"));
    return ret.value();
}

IntegerRangeList AbstractSensorChannelInterface::getAvailableBufferSizes()
{
    QDBusReply<IntegerRangeList> ret = call(QDBus::Block, QLatin1String("getAvailableBufferSizes"));
    return ret.value();
}

int AbstractSensorChannelInterface::sessionId() const
{
    return pimpl_->sessionId_;
}

SensorError AbstractSensorChannelInterface::errorCode() const
{
    // TODO: This solution may introduce problems, if errors are
    //       not cleared before another happens.
    if (pimpl_->errorCode_ != SNoError) {
        return pimpl_->errorCode_;
    }
    return static_cast<SensorError>(errorCodeInt());
}

QString AbstractSensorChannelInterface::errorString() const
{
    if (pimpl_->errorCode_ != SNoError) {
        return pimpl_->errorString_;
    }
    return qvariant_cast<QString>(internalPropGet("errorString"));
}

QString AbstractSensorChannelInterface::description() const
{
    return qvariant_cast<QString>(internalPropGet("description"));
}

QString AbstractSensorChannelInterface::id() const
{
    return qvariant_cast<QString>(internalPropGet("id"));
}

int AbstractSensorChannelInterface::interval() const
{
    return qvariant_cast<int>(internalPropGet("interval"));
}

void AbstractSensorChannelInterface::setInterval(int value)
{
    pimpl_->interval_ = value;
    if (pimpl_->running_)
        setInterval(pimpl_->sessionId_, value);
}

unsigned int AbstractSensorChannelInterface::bufferInterval() const
{
    return qvariant_cast<unsigned int>(internalPropGet("bufferInterval"));
}

void AbstractSensorChannelInterface::setBufferInterval(unsigned int value)
{
    pimpl_->bufferInterval_ = value;
    if (!pimpl_->running_)
        setBufferInterval(pimpl_->sessionId_, value);
}

unsigned int AbstractSensorChannelInterface::bufferSize() const
{
    return qvariant_cast<unsigned int>(internalPropGet("bufferSize"));
}

void AbstractSensorChannelInterface::setBufferSize(unsigned int value)
{
    pimpl_->bufferSize_ = value;
    if (!pimpl_->running_)
        setBufferSize(pimpl_->sessionId_, value);
}

bool AbstractSensorChannelInterface::standbyOverride() const
{
    return pimpl_->standbyOverride_ || qvariant_cast<bool>(internalPropGet("standbyOverride"));
}

bool AbstractSensorChannelInterface::setStandbyOverride(bool override)
{
    pimpl_->standbyOverride_ = override;
    return setStandbyOverride(pimpl_->sessionId_, override);
}

QString AbstractSensorChannelInterface::type() const
{
    return qvariant_cast<QString>(internalPropGet("type"));
}

int AbstractSensorChannelInterface::errorCodeInt() const
{
    return static_cast<SensorManagerError>(qvariant_cast<int>(internalPropGet("errorCodeInt")));
}

void AbstractSensorChannelInterface::clearError()
{
    pimpl_->errorCode_ = SNoError;
    pimpl_->errorString_.clear();
}

void AbstractSensorChannelInterface::dataReceived()
{
}

bool AbstractSensorChannelInterface::read(void* buffer, int size)
{
    return pimpl_->socketReader_.read(buffer, size);
}
<|endoftext|>


<commit_before>// Created on: 2014-03-06
// Created by: Kirill GAVRILOV
// Copyright (c) -1999 Matra Datavision
// Copyright (c) 2014-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and / or modify it
// under the terms of the GNU Lesser General Public version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.

#ifndef _OpenGl_GlCore12_H__
#define _OpenGl_GlCore12_H__

#ifdef HAVE_CONFIG_H
# include <oce-config.h>
#endif

#include <OpenGl_GlCore11.hxx>

#if defined(__APPLE__) && !defined(MACOSX_USE_GLX)
  #undef GL_VERSION_1_2
  #undef GL_VERSION_1_3
  #undef GL_VERSION_1_4
  #undef GL_VERSION_1_5
  #undef GL_VERSION_2_0
#endif

#include <OpenGl_glext.h>

//! Function list for GL1.2 core functionality.
struct OpenGl_GlCore12
{

  PFNGLBLENDCOLORPROC        glBlendColor;
  PFNGLBLENDEQUATIONPROC     glBlendEquation;
  PFNGLDRAWRANGEELEMENTSPROC glDrawRangeElements;
  PFNGLTEXIMAGE3DPROC        glTexImage3D;
  PFNGLTEXSUBIMAGE3DPROC     glTexSubImage3D;
  PFNGLCOPYTEXSUBIMAGE3DPROC glCopyTexSubImage3D;

};

#endif // _OpenGl_GlCore12_H__
<commit_msg>OpenGl_GlCore12.hxx: #undef GL_VERSION_x_y in all cases.<commit_after>// Created on: 2014-03-06
// Created by: Kirill GAVRILOV
// Copyright (c) -1999 Matra Datavision
// Copyright (c) 2014-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and / or modify it
// under the terms of the GNU Lesser General Public version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.

#ifndef _OpenGl_GlCore12_H__
#define _OpenGl_GlCore12_H__

#ifdef HAVE_CONFIG_H
# include <oce-config.h>
#endif

#include <OpenGl_GlCore11.hxx>

// We can safely #undef GL_VERSION_x_y since redeclaration of typedef names can
// be done for same type: http://msdn.microsoft.com/en-us/library/87txds41.aspx
// It is required to fix build against Mesa >= 10:
// http://cgit.freedesktop.org/mesa/mesa/commit/?id=a36f7e6
#undef GL_VERSION_1_2
#undef GL_VERSION_1_3
#undef GL_VERSION_1_4
#undef GL_VERSION_1_5
#undef GL_VERSION_2_0

#include <OpenGl_glext.h>

//! Function list for GL1.2 core functionality.
struct OpenGl_GlCore12
{

  PFNGLBLENDCOLORPROC        glBlendColor;
  PFNGLBLENDEQUATIONPROC     glBlendEquation;
  PFNGLDRAWRANGEELEMENTSPROC glDrawRangeElements;
  PFNGLTEXIMAGE3DPROC        glTexImage3D;
  PFNGLTEXSUBIMAGE3DPROC     glTexSubImage3D;
  PFNGLCOPYTEXSUBIMAGE3DPROC glCopyTexSubImage3D;

};

#endif // _OpenGl_GlCore12_H__
<|endoftext|>


<commit_before>/* -*- mode: c++; c-basic-offset:4 -*-
    searchbar.cpp

    This file is part of Kleopatra, the KDE keymanager
    Copyright (c) 2007 Klarälvdalens Datakonsult AB

    Kleopatra is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    Kleopatra 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
    General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

    In addition, as a special exception, the copyright holders give
    permission to link the code of this program with any edition of
    the Qt library by Trolltech AS, Norway (or with modified versions
    of Qt that use the same license as Qt), and distribute linked
    combinations including the two.  You must obey the GNU General
    Public License in all respects for all of the code used other than
    Qt.  If you modify this file, you may extend this exception to
    your version of the file, but you are not obligated to do so.  If
    you do not wish to do so, delete this exception statement from
    your version.
*/

#include "searchbar.h"

#include <QLabel>

#include <QComboBox>
#include <QLineEdit>
#include <KLocale>

#include <QHBoxLayout>

using boost::shared_ptr;

class SearchBar::State::Private {
public:
    QString searchString;
    //TODO add combo state
};

class SearchBar::Private {
    friend class ::SearchBar;
    SearchBar * const q;
public:
    explicit Private( SearchBar * qq );
    ~Private();

    QLineEdit * lineEdit;
    QComboBox * combo;
    mutable shared_ptr<SearchBar::State> state;
};

SearchBar::Private::Private( SearchBar * qq )
  : q( qq )
{
    QHBoxLayout * layout = new QHBoxLayout( q );
    QLabel * label = new QLabel;
    label->setText( i18n( "Find: " ) );
    layout->addWidget( label );
    lineEdit = new QLineEdit;
    connect( lineEdit, SIGNAL( textChanged( QString ) ),
             q, SIGNAL( textChanged( QString ) ) );
    label->setBuddy( lineEdit );
    layout->addWidget( lineEdit, /*stretch=*/1 );
    combo = new QComboBox;
    layout->addWidget( combo );
}

SearchBar::Private::~Private() {}

SearchBar::State::State() : d( new Private )
{}

SearchBar::State::~State() {}

SearchBar::SearchBar( QWidget * parent, Qt::WFlags f )
    : QWidget( parent, f ), d( new Private( this ) )
{

}

boost::shared_ptr<SearchBar::State> SearchBar::state() const
{
    if ( !d->state )
        d->state.reset( new State );
    d->state->d->searchString = d->lineEdit->text();
    return d->state;
}

void SearchBar::setState( shared_ptr<SearchBar::State> state )
{
    d->state = state;
    if ( !d->state )
        return;
    d->lineEdit->setText( d->state->d->searchString );
}

SearchBar::~SearchBar() {}

void SearchBar::setText( const QString& text )
{
    d->lineEdit->setText( text );
}

<commit_msg>no need to store the state object internally<commit_after>/* -*- mode: c++; c-basic-offset:4 -*-
    searchbar.cpp

    This file is part of Kleopatra, the KDE keymanager
    Copyright (c) 2007 Klarälvdalens Datakonsult AB

    Kleopatra is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    Kleopatra 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
    General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

    In addition, as a special exception, the copyright holders give
    permission to link the code of this program with any edition of
    the Qt library by Trolltech AS, Norway (or with modified versions
    of Qt that use the same license as Qt), and distribute linked
    combinations including the two.  You must obey the GNU General
    Public License in all respects for all of the code used other than
    Qt.  If you modify this file, you may extend this exception to
    your version of the file, but you are not obligated to do so.  If
    you do not wish to do so, delete this exception statement from
    your version.
*/

#include "searchbar.h"

#include <QLabel>

#include <QComboBox>
#include <QLineEdit>
#include <KLocale>

#include <QHBoxLayout>

#include <cassert>

using boost::shared_ptr;

class SearchBar::State::Private {
public:
    QString searchString;
    //TODO add combo state
};

class SearchBar::Private {
    friend class ::SearchBar;
    SearchBar * const q;
public:
    explicit Private( SearchBar * qq );
    ~Private();

    QLineEdit * lineEdit;
    QComboBox * combo;
};

SearchBar::Private::Private( SearchBar * qq )
  : q( qq )
{
    QHBoxLayout * layout = new QHBoxLayout( q );
    QLabel * label = new QLabel;
    label->setText( i18n( "Find: " ) );
    layout->addWidget( label );
    lineEdit = new QLineEdit;
    connect( lineEdit, SIGNAL( textChanged( QString ) ),
             q, SIGNAL( textChanged( QString ) ) );
    label->setBuddy( lineEdit );
    layout->addWidget( lineEdit, /*stretch=*/1 );
    combo = new QComboBox;
    layout->addWidget( combo );
}

SearchBar::Private::~Private() {}

SearchBar::State::State() : d( new Private )
{}

SearchBar::State::~State() {}

SearchBar::SearchBar( QWidget * parent, Qt::WFlags f )
    : QWidget( parent, f ), d( new Private( this ) )
{

}

boost::shared_ptr<SearchBar::State> SearchBar::state() const
{
    shared_ptr<SearchBar::State> state( new State );
    state->d->searchString = d->lineEdit->text();
    return state;
}

void SearchBar::setState( shared_ptr<SearchBar::State> state )
{
    assert( state );
    d->lineEdit->setText( state->d->searchString );
}

SearchBar::~SearchBar() {}

void SearchBar::setText( const QString& text )
{
    d->lineEdit->setText( text );
}

<|endoftext|>


<commit_before>/* pilotMemo.cc			KPilot
**
** Copyright (C) 1998-2001 by Dan Pilone
**
** This is a C++ wrapper for the Pilot's Memo Pad structures.
*/

/*
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
** the Free Software Foundation; either version 2.1 of the License, or
** (at your option) any later version.
**
** This program 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 program in a file called COPYING; if not, write to
** the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
** MA 02111-1307, USA.
*/

/*
** Bug reports and questions can be sent to kde-pim@kde.org
*/
static const char *pilotMemo_id =
	"$Id$";

#include "options.h"

#include <qtextcodec.h>

#include "pilotMemo.h"

PilotMemo::PilotMemo(PilotRecord * rec) : PilotAppCategory(rec)
{
	FUNCTIONSETUP;
	fText = codec()->toUnicode((const char *)(rec->getData()),rec->getLen());
	(void) pilotMemo_id;
}

void PilotMemo::unpack(const void *text, int /* firstTime */)
{
	FUNCTIONSETUP;
	kdWarning() << k_funcinfo << ": deprecated and broken function." << endl;
	fText = codec()->toUnicode((const char *)text);
}

// The indirection just to make the base class happy
void *PilotMemo::internalPack(unsigned char *buf)
{
	FUNCTIONSETUP;
	kdWarning() << k_funcinfo << ": Deprecated." << endl;
	QCString s = codec()->fromUnicode(fText);
	return strcpy((char *) buf, (const char *)s);
}

void *PilotMemo::pack(void *buf, int *len)
{
	FUNCTIONSETUP;
	if (*len < 0) return NULL; // buffer size being silly
	if (fText.length() > (unsigned) *len) return NULL; // won't fit either

	QCString s = codec()->fromUnicode(fText);

	// It won't fit if the buffer is too small. This second test
	// is because the encoded length in bytes may be longer (?)
	// than the unencoded length in characters.
	if (s.length() > *len) return NULL;

	// Zero out the buffer, up to the max memo size.
	memset(buf,0,QMIN(*len,MAX_MEMO_LEN));

	// Copy the encoded string and make extra sure it's NUL terminated.
	// Yay, _every_ parameter needs a cast.
	strlcpy(( char *)buf,(const char *)s,
		QMIN((unsigned) *len,(unsigned)MAX_MEMO_LEN));

	return buf;
}

QString PilotMemo::getTextRepresentation(bool richText)
{
	if (richText)
		return i18n("Title: %1
\nMemoText:
%2").
			arg(rtExpand(getTitle(), richText)).arg(rtExpand(text(), richText));
	else
		return i18n("Title: %1\nMemoText:\n%2").arg(getTitle()).arg(text());
}

QString PilotMemo::getTitle() const
{
	if (fText.isEmpty()) return QString::null;

	int memoTitleLen = fText.find('\n');
	if (-1 == memoTitleLen) memoTitleLen=fText.length();
	return fText.left(memoTitleLen);
}

QString PilotMemo::shortTitle() const
{
	FUNCTIONSETUP;
	QString t = QString(getTitle()).simplifyWhiteSpace();

	if (t.length() < 32)
		return t;
	t.truncate(40);

	int spaceIndex = t.findRev(' ');

	if (spaceIndex > 32)
	{
		t.truncate(spaceIndex);
	}

	t += CSL1("...");

	return t;
}

QString PilotMemo::sensibleTitle() const
{
	FUNCTIONSETUP;
	QString s = getTitle();

	if (!s.isEmpty())
	{
		return s;
	}
	else
	{
		return QString(i18n("[unknown]"));
	}
}
<commit_msg>Fix compiler warning about comparing int with unsigned int<commit_after>/* pilotMemo.cc			KPilot
**
** Copyright (C) 1998-2001 by Dan Pilone
**
** This is a C++ wrapper for the Pilot's Memo Pad structures.
*/

/*
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU Lesser General Public License as published by
** the Free Software Foundation; either version 2.1 of the License, or
** (at your option) any later version.
**
** This program 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 program in a file called COPYING; if not, write to
** the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
** MA 02111-1307, USA.
*/

/*
** Bug reports and questions can be sent to kde-pim@kde.org
*/
static const char *pilotMemo_id =
	"$Id$";

#include "options.h"

#include <qtextcodec.h>

#include "pilotMemo.h"

PilotMemo::PilotMemo(PilotRecord * rec) : PilotAppCategory(rec)
{
	FUNCTIONSETUP;
	fText = codec()->toUnicode((const char *)(rec->getData()),rec->getLen());
	(void) pilotMemo_id;
}

void PilotMemo::unpack(const void *text, int /* firstTime */)
{
	FUNCTIONSETUP;
	kdWarning() << k_funcinfo << ": deprecated and broken function." << endl;
	fText = codec()->toUnicode((const char *)text);
}

// The indirection just to make the base class happy
void *PilotMemo::internalPack(unsigned char *buf)
{
	FUNCTIONSETUP;
	kdWarning() << k_funcinfo << ": Deprecated." << endl;
	QCString s = codec()->fromUnicode(fText);
	return strcpy((char *) buf, (const char *)s);
}

void *PilotMemo::pack(void *buf, int *len)
{
	FUNCTIONSETUP;
	if (*len < 0) return NULL; // buffer size being silly
	if (fText.length() > (unsigned) *len) return NULL; // won't fit either

	QCString s = codec()->fromUnicode(fText);

	// It won't fit if the buffer is too small. This second test
	// is because the encoded length in bytes may be longer (?)
	// than the unencoded length in characters.
	if (s.length() > (unsigned) *len) return NULL;

	// Zero out the buffer, up to the max memo size.
	memset(buf,0,QMIN(*len,MAX_MEMO_LEN));

	// Copy the encoded string and make extra sure it's NUL terminated.
	// Yay, _every_ parameter needs a cast.
	strlcpy(( char *)buf,(const char *)s,
		QMIN((unsigned) *len,(unsigned)MAX_MEMO_LEN));

	return buf;
}

QString PilotMemo::getTextRepresentation(bool richText)
{
	if (richText)
		return i18n("Title: %1
\nMemoText:
%2").
			arg(rtExpand(getTitle(), richText)).arg(rtExpand(text(), richText));
	else
		return i18n("Title: %1\nMemoText:\n%2").arg(getTitle()).arg(text());
}

QString PilotMemo::getTitle() const
{
	if (fText.isEmpty()) return QString::null;

	int memoTitleLen = fText.find('\n');
	if (-1 == memoTitleLen) memoTitleLen=fText.length();
	return fText.left(memoTitleLen);
}

QString PilotMemo::shortTitle() const
{
	FUNCTIONSETUP;
	QString t = QString(getTitle()).simplifyWhiteSpace();

	if (t.length() < 32)
		return t;
	t.truncate(40);

	int spaceIndex = t.findRev(' ');

	if (spaceIndex > 32)
	{
		t.truncate(spaceIndex);
	}

	t += CSL1("...");

	return t;
}

QString PilotMemo::sensibleTitle() const
{
	FUNCTIONSETUP;
	QString s = getTitle();

	if (!s.isEmpty())
	{
		return s;
	}
	else
	{
		return QString(i18n("[unknown]"));
	}
}
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: sallang.hxx,v $
 *
 *  $Revision: 1.1.1.1 $
 *
 *  last change: $Author: hr $ $Date: 2000-09-18 17:05:34 $
 *
 *  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 _SALLANG_HXX
#define _SALLANG_HXX

#ifndef _TOOLS_LANG_HXX
#include <tools/lang.hxx>
#endif

// --------------------
// - Language Strings -
// --------------------

// --- Key-Namen ---
#define LSTR_KEY_SHIFT                       0
#define LSTR_KEY_CTRL                        1
#define LSTR_KEY_ALT                         2
#define LSTR_KEY_UP                          3
#define LSTR_KEY_DOWN                        4
#define LSTR_KEY_LEFT                        5
#define LSTR_KEY_RIGHT                       6
#define LSTR_KEY_HOME                        7
#define LSTR_KEY_END                         8
#define LSTR_KEY_PAGEUP                      9
#define LSTR_KEY_PAGEDOWN                   10
#define LSTR_KEY_RETURN                     11
#define LSTR_KEY_ESC                        12
#define LSTR_KEY_TAB                        13
#define LSTR_KEY_BACKSPACE                  14
#define LSTR_KEY_SPACE                      15
#define LSTR_KEY_INSERT                     16
#define LSTR_KEY_DELETE                     17

// --- Anzahl der Texte ---

#define LSTR_COUNT                          18

// --------------------------------------------
// - Methoden zum Abfragen der Sprach-Strings -
// --------------------------------------------

const char** ImplGetLangTab( LanguageType eLang );

#endif // _SALLANG_HXX
<commit_msg>INTEGRATION: CWS qdiet01 (1.1.1.1.332); FILE REMOVED 2003/09/23 11:38:22 mh 1.1.1.1.332.1: remove old obsolete os2 files #i18390#<commit_after><|endoftext|>