<commit_before>//
// (c) Copyright 2017 DESY,ESS
//
// This file is part of h5pp.
//
// This library 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 library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY
// 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., 51 Franklin Street, Fifth Floor
// Boston, MA  02110-1301 USA
// ===========================================================================
//
// Authors:
//    Eugen Wintersberger <eugen.wintersberger@desy.de>
//    Martin Shetty <martin.shetty@esss.se>
// Created on: Aug 24, 2017
//
#include <gtest/gtest.h>
#include <h5cpp/path.hpp>

using namespace hdf5;
using namespace std;

TEST(Path, test_default_construction)
{
  Path p;
  EXPECT_EQ(p.size(),0);
  EXPECT_FALSE(p.is_absolute());
}

TEST(Path, test_construction_from_string)
{
  Path p;

  p = Path("/hello/world/data");
  EXPECT_EQ(p.size(),3);
  EXPECT_TRUE(p.is_absolute());

  p = Path("hello/world");
  EXPECT_EQ(p.size(),2);
  EXPECT_FALSE(p.is_absolute());

  p = Path("hello/world/instrument/data/");
  EXPECT_EQ(p.size(),4);
  EXPECT_FALSE(p.is_absolute());

  p = Path(".");
  EXPECT_EQ(p.size(),0);
  EXPECT_FALSE(p.is_absolute());

  p = Path("./");
  EXPECT_EQ(p.size(),0);
  EXPECT_FALSE(p.is_absolute());

  p = Path("/.");
  EXPECT_EQ(p.size(),0);
  EXPECT_TRUE(p.is_absolute());

  p = Path(".///");
  EXPECT_EQ(p.size(),0);
  EXPECT_FALSE(p.is_absolute());
}

TEST(Path, test_conversion_to_string)
{
  Path p;

  p = Path("/hello/world/data");
  EXPECT_EQ(static_cast<string>(p),"/hello/world/data");

  p = Path("hello/world");
  EXPECT_EQ(static_cast<string>(p),"hello/world");

  p = Path("hello/world/instrument/data/");
  EXPECT_EQ(static_cast<string>(p),"hello/world/instrument/data");

  p = Path(".");
  EXPECT_EQ(static_cast<string>(p),".");

  p = Path("");
  EXPECT_EQ(static_cast<string>(p),".");
}

TEST(Path, test_sanitization)
{
  Path p;

  p = Path("./hello");
  EXPECT_EQ(static_cast<string>(p),"hello");

  p = Path("hello/world/.");
  EXPECT_EQ(static_cast<string>(p),"hello/world");

  p = Path("hello/./world");
  EXPECT_EQ(static_cast<string>(p),"hello/world");

  p = Path(".././../world");
  EXPECT_EQ(static_cast<string>(p),"../../world");

  p = Path("hello/..");
  EXPECT_EQ(static_cast<string>(p),".");

  p = Path("hello/../world");
  EXPECT_EQ(static_cast<string>(p),"world");

  p = Path("hello/world/!/../..");
  EXPECT_EQ(static_cast<string>(p),"hello");

  p = Path("hello/world/../../../..");
  EXPECT_EQ(static_cast<string>(p),"../..");

  p = Path("/hello/world/../../../..");
  EXPECT_EQ(static_cast<string>(p),"../..");
}

TEST(Path, relative_to)
{
  Path p1("a/b/c/d/e");
  Path p2("a/b/c/x/y");
  auto p = p1.relative_to(p2);
  EXPECT_EQ(static_cast<string>(p),"../../d/e");
}

TEST(Path, test_conversion_from_list)
{
  list<string> l{"entry","instrument","detector"};
  Path p;
  copy(l.begin(),l.end(),back_inserter(p));
  EXPECT_EQ(p.size(),3);
  EXPECT_EQ(static_cast<string>(p),"entry/instrument/detector");
}

TEST(Path, test_append)
{
  Path p;

  p = Path("/entry/instrument");
  p.append(Path("detector/data"));
  EXPECT_EQ(static_cast<string>(p),"/entry/instrument/detector/data");

  p = Path("/entry/instrument");
  p.append(Path("../data"));
  EXPECT_EQ(static_cast<string>(p),"/entry/data");

  p = Path("entry/instrument");
  p.append(Path("../../.."));
  EXPECT_EQ(static_cast<string>(p),"..");

  p = Path("/entry/instrument");
  p.append(Path("../../.."));
  EXPECT_EQ(static_cast<string>(p),"..");
}

TEST(Path,test_append_link_name)
{
  Path p("/entry/instrument/detector");
  p = p+"data";
  EXPECT_EQ(static_cast<string>(p),"/entry/instrument/detector/data");
  EXPECT_EQ(p.size(),4);
  EXPECT_TRUE(p.is_absolute());

  p = Path("instrument/detector");
  p = p + "metadata/date";
  EXPECT_EQ(static_cast<string>(p),"instrument/detector/metadata/date");
  EXPECT_EQ(p.size(),4);
  EXPECT_FALSE(p.is_absolute());
}

TEST(Path,test_prepend_link_name)
{
  Path p("instrument/detector");
  p = "/entry" + p;
  EXPECT_EQ(static_cast<string>(p),"/entry/instrument/detector");
  EXPECT_TRUE(p.is_absolute());

  p = Path("detector/data");
  p = "/entry/instrument/" + p;
  EXPECT_EQ(static_cast<string>(p),"/entry/instrument/detector/data");
  EXPECT_TRUE(p.is_absolute());

  p = Path("entry/instrument");
  p = "/" + p;
  EXPECT_EQ(p.size(),2);
  EXPECT_TRUE(p.is_absolute());
}

TEST(Path,test_adding_two_paths)
{
  Path p1("/entry/instrument"), p2("detector/data");
  Path p = p1+p2;
  EXPECT_EQ(p.size(),4);
  EXPECT_TRUE(p.is_absolute());
  EXPECT_EQ(static_cast<string>(p),"/entry/instrument/detector/data");
}

TEST(Path,test_root_path)
{
  Path p("/");
  EXPECT_TRUE(p.is_root());
  EXPECT_TRUE(p.is_absolute());
  EXPECT_EQ(static_cast<string>(p),"/");
}

TEST(Path,test_front)
{
  Path p("/hello/world");
  EXPECT_EQ(p.front(),"hello");

  p = Path("/");
  EXPECT_TRUE(p.is_root());
  EXPECT_EQ(p.front(),"/");
}

TEST(Path,test_back)
{
  Path p("hello/world");
  EXPECT_EQ(p.back(),"world");

  p = Path("/");
  EXPECT_TRUE(p.is_root());
  EXPECT_EQ(p.back(),"/");
}

TEST(Path,test_name)
{
  Path p("hello/world");
  EXPECT_EQ(p.name(),"world");

  p = Path("/");
  EXPECT_TRUE(p.is_root());
  EXPECT_EQ(p.name(),"/");
}

TEST(Path,test_parent_path)
{
  Path p("hello/world");
  EXPECT_EQ(static_cast<string>(p.parent()),"hello");

  p = Path("/hello/world");
  EXPECT_EQ(static_cast<string>(p.parent()),"/hello");

  p = Path("/");
  EXPECT_TRUE(p.is_root());
  EXPECT_EQ(static_cast<string>(p.parent()),"/");
}

TEST(Path,test_path_equality)
{
  Path p1("hello/world");
  Path p2("/hello/world");
  Path p3("/hello");
  EXPECT_TRUE(p1 == p1);
  EXPECT_TRUE(p1 != p2);
  EXPECT_TRUE(p2 != p3);
}
<commit_msg>fixed path test<commit_after>//
// (c) Copyright 2017 DESY,ESS
//
// This file is part of h5pp.
//
// This library 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 library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY
// 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., 51 Franklin Street, Fifth Floor
// Boston, MA  02110-1301 USA
// ===========================================================================
//
// Authors:
//    Eugen Wintersberger <eugen.wintersberger@desy.de>
//    Martin Shetty <martin.shetty@esss.se>
// Created on: Aug 24, 2017
//
#include <gtest/gtest.h>
#include <h5cpp/path.hpp>

using namespace hdf5;
using namespace std;

TEST(Path, test_default_construction)
{
  Path p;
  EXPECT_EQ(p.size(),0);
  EXPECT_FALSE(p.is_absolute());
}

TEST(Path, test_construction_from_string)
{
  Path p;

  p = Path("/hello/world/data");
  EXPECT_EQ(p.size(),3);
  EXPECT_TRUE(p.is_absolute());

  p = Path("hello/world");
  EXPECT_EQ(p.size(),2);
  EXPECT_FALSE(p.is_absolute());

  p = Path("hello/world/instrument/data/");
  EXPECT_EQ(p.size(),4);
  EXPECT_FALSE(p.is_absolute());

  p = Path(".");
  EXPECT_EQ(p.size(),0);
  EXPECT_FALSE(p.is_absolute());

  p = Path("./");
  EXPECT_EQ(p.size(),0);
  EXPECT_FALSE(p.is_absolute());

  p = Path("/.");
  EXPECT_EQ(p.size(),0);
  EXPECT_TRUE(p.is_absolute());

  p = Path(".///");
  EXPECT_EQ(p.size(),0);
  EXPECT_FALSE(p.is_absolute());
}

TEST(Path, test_conversion_to_string)
{
  Path p;

  p = Path("/hello/world/data");
  EXPECT_EQ(static_cast<string>(p),"/hello/world/data");

  p = Path("hello/world");
  EXPECT_EQ(static_cast<string>(p),"hello/world");

  p = Path("hello/world/instrument/data/");
  EXPECT_EQ(static_cast<string>(p),"hello/world/instrument/data");

  p = Path(".");
  EXPECT_EQ(static_cast<string>(p),".");

  p = Path("");
  EXPECT_EQ(static_cast<string>(p),".");
}

TEST(Path, test_sanitization)
{
  Path p;

  p = Path("./hello");
  EXPECT_EQ(static_cast<string>(p),"hello");

  p = Path("hello/world/.");
  EXPECT_EQ(static_cast<string>(p),"hello/world");

  p = Path("hello/./world");
  EXPECT_EQ(static_cast<string>(p),"hello/world");

  p = Path(".././../world");
  EXPECT_EQ(static_cast<string>(p),"../../world");

  p = Path("hello/..");
  EXPECT_EQ(static_cast<string>(p),".");

  p = Path("hello/../world");
  EXPECT_EQ(static_cast<string>(p),"world");

  p = Path("hello/world/!/../..");
  EXPECT_EQ(static_cast<string>(p),"hello");

  p = Path("hello/world/../../../..");
  EXPECT_EQ(static_cast<string>(p),"../..");

  p = Path("/hello/world/../../../..");
  EXPECT_EQ(static_cast<string>(p),"../..");
}

TEST(Path, relative_to)
{
  Path p1("a/b/c/d/e");
  Path p2("a/b/c/x/y");
  auto p = p1.relative_to(p2);
  EXPECT_EQ(static_cast<string>(p),"../../d/e");
}

TEST(Path, test_conversion_from_list)
{
  list<string> l{"entry","instrument","detector"};
  Path p;
  copy(l.begin(),l.end(),back_inserter(p));
  EXPECT_EQ(p.size(),3);
  EXPECT_EQ(static_cast<string>(p),"entry/instrument/detector");
}

TEST(Path, test_append)
{
  Path p;

  p = Path("/entry/instrument");
  p.append(Path("detector/data"));
  EXPECT_EQ(static_cast<string>(p),"/entry/instrument/detector/data");

  p = Path("/entry/instrument");
  p.append(Path("../data"));
  EXPECT_EQ(static_cast<string>(p),"/entry/data");

  p = Path("entry/instrument");
  p.append(Path("../../.."));
  EXPECT_EQ(static_cast<string>(p),"..");

  p = Path("/entry/instrument");
  p.append(Path("../../.."));
  EXPECT_EQ(static_cast<string>(p),"..");
}

TEST(Path,test_append_link_name)
{
  Path p("/entry/instrument/detector");
  p = p+"data";
  EXPECT_EQ(static_cast<string>(p),"/entry/instrument/detector/data");
  EXPECT_EQ(p.size(),4);
  EXPECT_TRUE(p.is_absolute());

  p = Path("instrument/detector");
  p = p + "metadata/date";
  EXPECT_EQ(static_cast<string>(p),"instrument/detector/metadata/date");
  EXPECT_EQ(p.size(),4);
  EXPECT_FALSE(p.is_absolute());
}

TEST(Path,test_prepend_link_name)
{
  Path p("instrument/detector");
  p = "/entry" + p;
  EXPECT_EQ(static_cast<string>(p),"/entry/instrument/detector");
  EXPECT_TRUE(p.is_absolute());

  p = Path("detector/data");
  p = "/entry/instrument/" + p;
  EXPECT_EQ(static_cast<string>(p),"/entry/instrument/detector/data");
  EXPECT_TRUE(p.is_absolute());

  p = Path("entry/instrument");
  p = "/" + p;
  EXPECT_EQ(p.size(),2);
  EXPECT_TRUE(p.is_absolute());
}

TEST(Path,test_adding_two_paths)
{
  Path p1("/entry/instrument"), p2("detector/data");
  Path p = p1+p2;
  EXPECT_EQ(p.size(),4);
  EXPECT_TRUE(p.is_absolute());
  EXPECT_EQ(static_cast<string>(p),"/entry/instrument/detector/data");
}

TEST(Path,test_root_path)
{
  Path p("/");
  EXPECT_TRUE(p.is_root());
  EXPECT_TRUE(p.is_absolute());
  EXPECT_EQ(static_cast<string>(p),"/");
}

TEST(Path,test_front)
{
  Path p("/hello/world");
  EXPECT_EQ(p.front(),"hello");

  p = Path("/");
  EXPECT_TRUE(p.is_root());
  EXPECT_EQ(p.front(),"/");
}

TEST(Path,test_back)
{
  Path p("hello/world");
  EXPECT_EQ(p.back(),"world");

  p = Path("/");
  EXPECT_TRUE(p.is_root());
  EXPECT_EQ(p.back(),"/");
}

TEST(Path,test_name)
{
  Path p("hello/world");
  EXPECT_EQ(p.name(),"world");

  p = Path("/");
  EXPECT_TRUE(p.is_root());
  EXPECT_EQ(p.name(),".");
}

TEST(Path,test_parent_path)
{
  Path p("hello/world");
  EXPECT_EQ(static_cast<string>(p.parent()),"hello");

  p = Path("/hello/world");
  EXPECT_EQ(static_cast<string>(p.parent()),"/hello");

  p = Path("/");
  EXPECT_TRUE(p.is_root());
  EXPECT_EQ(static_cast<string>(p.parent()),"/");
}

TEST(Path,test_path_equality)
{
  Path p1("hello/world");
  Path p2("/hello/world");
  Path p3("/hello");
  EXPECT_TRUE(p1 == p1);
  EXPECT_TRUE(p1 != p2);
  EXPECT_TRUE(p2 != p3);
}
<|endoftext|>


<commit_before>
#include <ros/ros.h>

#include <gtest/gtest.h>

#include <control_toolbox/pid.h>

#include <boost/math/special_functions/fpclassify.hpp>

using namespace control_toolbox;

TEST(ParameterTest, zeroITermBadIBoundsTest)
{
  RecordProperty("description","This test checks robustness against divide-by-zero errors when given integral term bounds which do not include 0.0.");

  Pid pid(1.0, 0.0, 0.0, -1.0, 0.0);

  double cmd = 0.0;
  double pe,ie,de;

  cmd = pid.computeCommand(-1.0, ros::Duration(1.0));

  pid.getCurrentPIDErrors(&pe,&ie,&de);
  EXPECT_FALSE(boost::math::isinf(ie));
  EXPECT_FALSE(boost::math::isnan(cmd));

  cmd = pid.computeCommand(-1.0, ros::Duration(1.0));
  pid.getCurrentPIDErrors(&pe,&ie,&de);
  EXPECT_FALSE(boost::math::isinf(ie));
  EXPECT_FALSE(boost::math::isnan(cmd));
}

TEST(ParameterTest, integrationWindupTest)
{
  RecordProperty("description","This test succeeds if the integral error is prevented from winding up when the integral gain is non-zero.");

  Pid pid(0.0, 1.0, 0.0, 1.0, -1.0);

  double cmd = 0.0;
  double pe,ie,de;

  cmd = pid.computeCommand(-1.0, ros::Duration(1.0));
  pid.getCurrentPIDErrors(&pe,&ie,&de);
  EXPECT_EQ(-1.0, ie);
  EXPECT_EQ(-1.0, cmd);

  cmd = pid.computeCommand(-1.0, ros::Duration(1.0));
  pid.getCurrentPIDErrors(&pe,&ie,&de);
  EXPECT_EQ(-1.0, ie);
  EXPECT_EQ(-1.0, cmd);
}

TEST(ParameterTest, integrationWindupZeroGainTest)
{
  RecordProperty("description","This test succeeds if the integral error is prevented from winding up when the integral gain is zero. If the integral error is allowed to wind up while it is disabled, it can cause sudden jumps to the minimum or maximum bound in control command when re-enabled.");

  double i_gain = 0.0;
  double i_min = -1.0;
  double i_max = 1.0;
  Pid pid(0.0, i_gain, 0.0, i_max, i_min);

  double cmd = 0.0;
  double pe,ie,de;

  cmd = pid.computeCommand(-1.0, ros::Duration(1.0));
  pid.getCurrentPIDErrors(&pe,&ie,&de);
  EXPECT_LE(i_min, ie);
  EXPECT_LE(ie, i_max);
  EXPECT_EQ(0.0, cmd);

  cmd = pid.computeCommand(-1.0, ros::Duration(1.0));
  pid.getCurrentPIDErrors(&pe,&ie,&de);
  EXPECT_LE(i_min, ie);
  EXPECT_LE(ie, i_max);
  EXPECT_EQ(0.0, cmd);
}

TEST(ParameterTest, gainSettingCopyPIDTest)
{
  RecordProperty("description","This test succeeds if a PID object has its gain set at different points in time then the values are get-ed and still remain the same, as well as when PID is copied.");

  // Test values
  double p_gain = rand() % 100;
  double i_gain = rand() % 100;
  double d_gain = rand() % 100;
  double i_max = rand() % 100;
  double i_min = -1 * rand() % 100;

  // Initialize the default way
  Pid pid1(p_gain, i_gain, d_gain, i_max, i_min);

  // Test return values  -------------------------------------------------
  double p_gain_return, i_gain_return, d_gain_return, i_max_return, i_min_return;
  pid1.getGains(p_gain_return, i_gain_return, d_gain_return, i_max_return, i_min_return);

  EXPECT_EQ(p_gain, p_gain_return);
  EXPECT_EQ(i_gain, i_gain_return);
  EXPECT_EQ(d_gain, d_gain_return);
  EXPECT_EQ(i_max, i_max_return);
  EXPECT_EQ(i_min, i_min_return);

  // Test return values using struct -------------------------------------------------

  // New values
  p_gain = rand() % 100;
  i_gain = rand() % 100;
  d_gain = rand() % 100;
  i_max = rand() % 100;
  i_min = -1 * rand() % 100;
  pid1.setGains(p_gain, i_gain, d_gain, i_max, i_min);

  Pid::Gains g1 = pid1.getGains();
  EXPECT_EQ(p_gain, g1.p_gain_);
  EXPECT_EQ(i_gain, g1.i_gain_);
  EXPECT_EQ(d_gain, g1.d_gain_);
  EXPECT_EQ(i_max, g1.i_max_);
  EXPECT_EQ(i_min, g1.i_min_);

  // \todo test initParam() -------------------------------------------------

  // \todo test bool init(const ros::NodeHandle &n); -----------------------------------

  // Send update command to populate errors -------------------------------------------------
  pid1.setCurrentCmd(10);
  pid1.computeCommand(20, ros::Duration(1.0));

  // Test copy constructor -------------------------------------------------
  Pid pid2(pid1);

  pid2.getGains(p_gain_return, i_gain_return, d_gain_return, i_max_return, i_min_return);

  EXPECT_EQ(p_gain, p_gain_return);
  EXPECT_EQ(i_gain, i_gain_return);
  EXPECT_EQ(d_gain, d_gain_return);
  EXPECT_EQ(i_max, i_max_return);
  EXPECT_EQ(i_min, i_min_return);

  // Test that errors are zero
  double pe, ie, de;
  pid2.getCurrentPIDErrors(&pe, &ie, &de);
  EXPECT_EQ(0.0, pe);
  EXPECT_EQ(0.0, ie);
  EXPECT_EQ(0.0, de);

  // Test assignment constructor -------------------------------------------------
  Pid pid3;
  pid3 = pid1;

  pid3.getGains(p_gain_return, i_gain_return, d_gain_return, i_max_return, i_min_return);

  EXPECT_EQ(p_gain, p_gain_return);
  EXPECT_EQ(i_gain, i_gain_return);
  EXPECT_EQ(d_gain, d_gain_return);
  EXPECT_EQ(i_max, i_max_return);
  EXPECT_EQ(i_min, i_min_return);

  // Test that errors are zero
  double pe2, ie2, de2;
  pid3.getCurrentPIDErrors(&pe2, &ie2, &de2);
  EXPECT_EQ(0.0, pe2);
  EXPECT_EQ(0.0, ie2);
  EXPECT_EQ(0.0, de2);

  // Test return values using struct - const version  -------------------------------------------------

  const Pid pid4(pid3);

  Pid::Gains g3 = pid4.getGains();
  EXPECT_EQ(p_gain, g3.p_gain_);
  EXPECT_EQ(i_gain, g3.i_gain_);
  EXPECT_EQ(d_gain, g3.d_gain_);
  EXPECT_EQ(i_max, g3.i_max_);
  EXPECT_EQ(i_min, g3.i_min_);

}

int main(int argc, char** argv) {
  testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}
<commit_msg>Remove broken test code. Hotfix to #18.<commit_after>
#include <ros/ros.h>

#include <gtest/gtest.h>

#include <control_toolbox/pid.h>

#include <boost/math/special_functions/fpclassify.hpp>

using namespace control_toolbox;

TEST(ParameterTest, zeroITermBadIBoundsTest)
{
  RecordProperty("description","This test checks robustness against divide-by-zero errors when given integral term bounds which do not include 0.0.");

  Pid pid(1.0, 0.0, 0.0, -1.0, 0.0);

  double cmd = 0.0;
  double pe,ie,de;

  cmd = pid.computeCommand(-1.0, ros::Duration(1.0));

  pid.getCurrentPIDErrors(&pe,&ie,&de);
  EXPECT_FALSE(boost::math::isinf(ie));
  EXPECT_FALSE(boost::math::isnan(cmd));

  cmd = pid.computeCommand(-1.0, ros::Duration(1.0));
  pid.getCurrentPIDErrors(&pe,&ie,&de);
  EXPECT_FALSE(boost::math::isinf(ie));
  EXPECT_FALSE(boost::math::isnan(cmd));
}

TEST(ParameterTest, integrationWindupTest)
{
  RecordProperty("description","This test succeeds if the integral error is prevented from winding up when the integral gain is non-zero.");

  Pid pid(0.0, 1.0, 0.0, 1.0, -1.0);

  double cmd = 0.0;
  double pe,ie,de;

  cmd = pid.computeCommand(-1.0, ros::Duration(1.0));
  pid.getCurrentPIDErrors(&pe,&ie,&de);
  EXPECT_EQ(-1.0, ie);
  EXPECT_EQ(-1.0, cmd);

  cmd = pid.computeCommand(-1.0, ros::Duration(1.0));
  pid.getCurrentPIDErrors(&pe,&ie,&de);
  EXPECT_EQ(-1.0, ie);
  EXPECT_EQ(-1.0, cmd);
}

TEST(ParameterTest, integrationWindupZeroGainTest)
{
  RecordProperty("description","This test succeeds if the integral error is prevented from winding up when the integral gain is zero. If the integral error is allowed to wind up while it is disabled, it can cause sudden jumps to the minimum or maximum bound in control command when re-enabled.");

  double i_gain = 0.0;
  double i_min = -1.0;
  double i_max = 1.0;
  Pid pid(0.0, i_gain, 0.0, i_max, i_min);

  double cmd = 0.0;
  double pe,ie,de;

  cmd = pid.computeCommand(-1.0, ros::Duration(1.0));
  pid.getCurrentPIDErrors(&pe,&ie,&de);
  EXPECT_LE(i_min, ie);
  EXPECT_LE(ie, i_max);
  EXPECT_EQ(0.0, cmd);

  cmd = pid.computeCommand(-1.0, ros::Duration(1.0));
  pid.getCurrentPIDErrors(&pe,&ie,&de);
  EXPECT_LE(i_min, ie);
  EXPECT_LE(ie, i_max);
  EXPECT_EQ(0.0, cmd);
}

TEST(ParameterTest, gainSettingCopyPIDTest)
{
  RecordProperty("description","This test succeeds if a PID object has its gain set at different points in time then the values are get-ed and still remain the same, as well as when PID is copied.");

  // Test values
  double p_gain = rand() % 100;
  double i_gain = rand() % 100;
  double d_gain = rand() % 100;
  double i_max = rand() % 100;
  double i_min = -1 * rand() % 100;

  // Initialize the default way
  Pid pid1(p_gain, i_gain, d_gain, i_max, i_min);

  // Test return values  -------------------------------------------------
  double p_gain_return, i_gain_return, d_gain_return, i_max_return, i_min_return;
  pid1.getGains(p_gain_return, i_gain_return, d_gain_return, i_max_return, i_min_return);

  EXPECT_EQ(p_gain, p_gain_return);
  EXPECT_EQ(i_gain, i_gain_return);
  EXPECT_EQ(d_gain, d_gain_return);
  EXPECT_EQ(i_max, i_max_return);
  EXPECT_EQ(i_min, i_min_return);

  // Test return values using struct -------------------------------------------------

  // New values
  p_gain = rand() % 100;
  i_gain = rand() % 100;
  d_gain = rand() % 100;
  i_max = rand() % 100;
  i_min = -1 * rand() % 100;
  pid1.setGains(p_gain, i_gain, d_gain, i_max, i_min);

  Pid::Gains g1 = pid1.getGains();
  EXPECT_EQ(p_gain, g1.p_gain_);
  EXPECT_EQ(i_gain, g1.i_gain_);
  EXPECT_EQ(d_gain, g1.d_gain_);
  EXPECT_EQ(i_max, g1.i_max_);
  EXPECT_EQ(i_min, g1.i_min_);

  // \todo test initParam() -------------------------------------------------

  // \todo test bool init(const ros::NodeHandle &n); -----------------------------------

  // Send update command to populate errors -------------------------------------------------
  pid1.setCurrentCmd(10);
  pid1.computeCommand(20, ros::Duration(1.0));

  // Test copy constructor -------------------------------------------------
  Pid pid2(pid1);

  pid2.getGains(p_gain_return, i_gain_return, d_gain_return, i_max_return, i_min_return);

  EXPECT_EQ(p_gain, p_gain_return);
  EXPECT_EQ(i_gain, i_gain_return);
  EXPECT_EQ(d_gain, d_gain_return);
  EXPECT_EQ(i_max, i_max_return);
  EXPECT_EQ(i_min, i_min_return);

  // Test that errors are zero
  double pe, ie, de;
  pid2.getCurrentPIDErrors(&pe, &ie, &de);
  EXPECT_EQ(0.0, pe);
  EXPECT_EQ(0.0, ie);
  EXPECT_EQ(0.0, de);

  // Test assignment constructor -------------------------------------------------
  Pid pid3;
  pid3 = pid1;

  pid3.getGains(p_gain_return, i_gain_return, d_gain_return, i_max_return, i_min_return);

  EXPECT_EQ(p_gain, p_gain_return);
  EXPECT_EQ(i_gain, i_gain_return);
  EXPECT_EQ(d_gain, d_gain_return);
  EXPECT_EQ(i_max, i_max_return);
  EXPECT_EQ(i_min, i_min_return);

  // Test that errors are zero
  double pe2, ie2, de2;
  pid3.getCurrentPIDErrors(&pe2, &ie2, &de2);
  EXPECT_EQ(0.0, pe2);
  EXPECT_EQ(0.0, ie2);
  EXPECT_EQ(0.0, de2);
}

int main(int argc, char** argv) {
  testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}
<|endoftext|>


<commit_before>#include "ft245_rx_thread.h"

static int read_callback(uint8_t *buffer, int length, FTDIProgressInfo *progress, void *userdata)
{
	(void)progress;
	Ft245RxThread *self = (Ft245RxThread *)userdata;

	emit self->rx(QByteArray((char *)buffer, length));

	if (self->_stop)
	{
		return 1;
	}

	return 0;
}

void Ft245RxThread::doWork(struct ftdi_context *ftdi)
{
	_stop = false;
	ftdi_readstream(ftdi, read_callback,  this, 1, 1);
}

void Ft245RxThread::stop(void)
{
	_stop = false;
}
<commit_msg>should improve xfer speed<commit_after>#include "ft245_rx_thread.h"

static int read_callback(uint8_t *buffer, int length, FTDIProgressInfo *progress, void *userdata)
{
	(void)progress;
	Ft245RxThread *self = (Ft245RxThread *)userdata;

	emit self->rx(QByteArray((char *)buffer, length));

	if (self->_stop)
	{
		return 1;
	}

	return 0;
}

void Ft245RxThread::doWork(struct ftdi_context *ftdi)
{
	_stop = false;
	ftdi_readstream(ftdi, read_callback, this, 256, 8);
}

void Ft245RxThread::stop(void)
{
	_stop = false;
}
<|endoftext|>


<commit_before><commit_msg>Fixed some formatting issues and bug with recursion<commit_after><|endoftext|>


<commit_before>#include "TestClass.hpp"

static int magic = 0x11223344;

int TestClass::testOutlineFunction()
{
	return someData_ * reinterpret_cast<int>(&magic);
}

int TestClass::testOutlineFunctionWithStaticVariable()
{
	static int staticVar = -1;
	staticVar += testOutlineFunction();
	return staticVar;
}

void getTestData1(TestDataArray * d)
{
	GET_TEST_DATA_IMPL();
}
<commit_msg>-: Warning fixed<commit_after>#include "TestClass.hpp"

static int magic = 0x11223344;

int TestClass::testOutlineFunction()
{
	return someData_ * (int)reinterpret_cast<size_t>(&magic);
}

int TestClass::testOutlineFunctionWithStaticVariable()
{
	static int staticVar = -1;
	staticVar += testOutlineFunction();
	return staticVar;
}

void getTestData1(TestDataArray * d)
{
	GET_TEST_DATA_IMPL();
}
<|endoftext|>


<commit_before>/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Mobility Components.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/

#include "qcontactfetchhint.h"
#include "qcontactfetchhint_p.h"

#include <QStringList>

#ifndef QT_NO_DEBUG_STREAM
#include <QDebug>
#endif

QTM_BEGIN_NAMESPACE

/*!
  \class QContactFetchHint

  \inmodule QtContacts
   \since 1.0

  \brief The QContactFetchHint class provides hints to the manager about which contact
  information needs to be retrieved in an asynchronous fetch request or a synchronous
  function call.

  All of the hints may be ignored at the discretion of the manager, however if a manager
  is able to optimize retrieval of contacts due to hints, it may do so.  If a manager
  ignores a hint, it must retrieve the full set of data that the hint refers to.

  The fetch hint contains:
  \list
   \o a list of detail definition names which the client is interested
  in (empty if interested in all detail definitions)
   \o a list of relationship types which the client is interested in
  (empty if interested in all relationships)
   \o some optimization flags which allow the client to tell the backend if they are
  not interested in any relationships, any action preferences, or any binary blobs (images etc).
   \o a preferred size for any images, if the backend supports multiple sizes or scaling
  \endlist

  Important note: a client should not make changes to a contact which has been retrieved
  using a fetch hint other than the default fetch hint.  Doing so can result in information
  loss when saving the contact back to the manager (as the "new" restricted contact will
  replace the previously saved contact in the backend).
 */

/*!
  \enum QContactFetchHint::OptimizationHint

  This enum defines flags which may be set to inform the backend that the client does
  not require certain information.  The backend may safely ignore the hint, but then
  must return the full set of information relating to the optimization hint.

  \value AllRequired Tells the backend that all information is required
  \value NoRelationships Tells the backend that the client does not require retrieved contacts to include a cache of relationships
  \value NoActionPreferences Tells the backend that the client does not require retrieved contacts to include a cache of action preferences
  \value NoBinaryBlobs Tells the backend that the client does not require retrieved contacts to include binary blobs such as thumbnail images
 */

/*!
  Constructs a new contact fetch hint which requests that the backend fetch all information
 */
QContactFetchHint::QContactFetchHint()
    : d(new QContactFetchHintPrivate)
{
}

/*!
  Constructs a new contact fetch hint as a copy of \a other
 */
QContactFetchHint::QContactFetchHint(const QContactFetchHint &other)
    : d(other.d)
{
}

/*!
  Frees any memory in use by the fetch hint
 */
QContactFetchHint::~QContactFetchHint()
{
}

/*!
  Assigns this fetch hint to be equal to the \a other fetch hint
  \since 1.0
 */
QContactFetchHint& QContactFetchHint::operator=(const QContactFetchHint& other)
{
    d = other.d;
    return *this;
}

/*!
  Returns the list of definition names that identify detail definitions of which details
  the manager should (at a minimum) retrieve when fetching contacts.
  This hint may be ignored by the backend, in which case it will return the full set of details for
  each contact retrieved.

  \sa setDetailDefinitionsHint()
  \since 1.0
 */
QStringList QContactFetchHint::detailDefinitionsHint() const
{
    return d->m_definitionsHint;
}

/*!
  Sets the list of definition names that identify detail definitions of which details
  the manager should (at a minimum) retrieve when fetching contacts to \a definitionNames.
  This hint may be ignored by the backend, in which case it will return the full set of details for
  each contact retrieved.

  \sa detailDefinitionsHint()
  \since 1.0
 */
void QContactFetchHint::setDetailDefinitionsHint(const QStringList& definitionNames)
{
    d->m_definitionsHint = definitionNames;
}

/*!
  Returns the list of relationship types that the manager should (at a minimum) retrieve
  when fetching contacts.
  This hint may be ignored by the backend, in which case it will return the full set of
  relationships for each contact retrieved.

  \sa setRelationshipTypesHint(), QContact::relationships()
  \since 1.0
 */
QStringList QContactFetchHint::relationshipTypesHint() const
{
    return d->m_relationshipsHint;
}

/*!
  Sets the list of relationship types that the manager should (at a minimum) retrieve
  when fetching contacts to \a relationshipTypes.
  This hint may be ignored by the backend, in which case it will return the full set of
  relationships for each contact retrieved.

  \sa relationshipTypesHint(), QContact::relationships()
  \since 1.0
 */
void QContactFetchHint::setRelationshipTypesHint(const QStringList& relationshipTypes)
{
    d->m_relationshipsHint = relationshipTypes;
}

/*!
  Returns the preferred pixel dimensions for any images returned
  by the manager for a given request.  This hint may be ignored
  by the manager.

  This is useful when the backend supports multiple sizes of an
  image (or the image is natively scaleable) in order to get an
  image that will look good at the indicated dimensions.

  The caller should be prepared for images of any dimensions,
  in any case.
 */
QSize QContactFetchHint::preferredImageSize() const
{
    return d->m_preferredImageSize;
}

/*!
  Sets the preferred pixel dimensions for any images returned
  by the manager for the given request to \a size.  This hint
  may be ignored by the manager.

  This is useful when the backend supports multiple sizes of an
  image (or the image is natively scaleable) in order to get an
  image that will look good at the indicated dimensions.

  The caller should be prepared for images of any dimensions,
  in any case.
 */
void QContactFetchHint::setPreferredImageSize(const QSize& size)
{
    d->m_preferredImageSize = size;
}

/*!
  Returns the optimization hint flags specified by the client.
  These hints may be ignored by the backend, in which case it will return
  the full set of information accessible in a contact, including
  relationships, action preferences, and binary blobs.

  \sa setOptimizationHints()
  \since 1.0
 */
QContactFetchHint::OptimizationHints QContactFetchHint::optimizationHints() const
{
    return d->m_optimizationHints;
}

/*!
  Sets the optimization hint flags specified by the client to \a hints.
  These hints may be ignored by the backend, in which case it will return
  the full set of information accessible in a contact, including
  relationships, action preferences, and binary blobs.

  \sa optimizationHints()
  \since 1.0
 */
void QContactFetchHint::setOptimizationHints(OptimizationHints hints)
{
    d->m_optimizationHints = hints;
}

/*!
  Returns the number of results which the client considers to be the
  maximum number of useful results.  The client is only interested
  in this number of results, so returning any more results
  would be superfluous to the client's requirements.
  Note that this fetch hint only affects operations where the
  backend would return a list of contacts; this hint specifies
  the maximum number of contacts in the list which would be useful
  to the client.  The backend may ignore this hint, in which case it
  must return all contacts which would otherwise have been returned
  as a result of the operation.

  A negative value for count denotes that the client wishes to
  retrieve all results.  The default value is -1.
 */
int QContactFetchHint::maxCountHint() const
{
    return d->m_maxCount;
}

/*!
  Sets the maximum number of results which the client is interested in
  to \a count.  The client is only interested in this number of results,
  so returning any more results would be superfluous to the client's
  requirements. Note that this fetch hint only affects operations where
  the backend would return a list of contacts; this hint specifies
  the maximum number of contacts in the list which would be useful
  to the client.  The backend may ignore this hint, in which case it
  must return all contacts which would otherwise have been returned
  as a result of the operation.

  A negative value for count denotes that the client wishes to
  retrieve all results.  The default value is -1.
  \since 1.2
*/
void QContactFetchHint::setMaxCountHint(int count)
{
    count < 0 ? (d->m_maxCount = -1) : (d->m_maxCount = count);
}

#ifndef QT_NO_DATASTREAM
QDataStream& operator<<(QDataStream& out, const QContactFetchHint& hint)
{
    quint8 formatVersion = 2; // Version of QDataStream format for QContactFetchHint
    return out << formatVersion
               << hint.detailDefinitionsHint()
               << hint.relationshipTypesHint()
               << static_cast<quint32>(hint.optimizationHints())
               << hint.preferredImageSize()
               << hint.maxCountHint();
}

QDataStream& operator>>(QDataStream& in, QContactFetchHint& hint)
{
    hint = QContactFetchHint();
    quint8 formatVersion;
    in >> formatVersion;
    if (formatVersion == 1 || formatVersion == 2) {
        QStringList detailDefinitionHints;
        QStringList relationshipTypeHints;
        quint32 optimizations;
        QSize dimensions;
        in >> detailDefinitionHints >> relationshipTypeHints >> optimizations >> dimensions;
        hint.setDetailDefinitionsHint(detailDefinitionHints);
        hint.setRelationshipTypesHint(relationshipTypeHints);
        hint.setOptimizationHints(QContactFetchHint::OptimizationHints(optimizations));
        hint.setPreferredImageSize(dimensions);

        // version two also has a maximum fetch count hint.
        if (formatVersion == 2) {
            int maxCountHint = -1;
            in >> maxCountHint;
            hint.setMaxCountHint(maxCountHint);
        }
    } else {
        in.setStatus(QDataStream::ReadCorruptData);
    }
    return in;
}

#endif

#ifndef QT_NO_DEBUG_STREAM
/*!
  Outputs \a hint to the debug stream \a dbg
 */
QDebug operator<<(QDebug dbg, const QContactFetchHint& hint)
{
    dbg.nospace() << "QContactFetchHint("
                  << "detailDefinitionsHint=" << hint.detailDefinitionsHint() << ","
                  << "relationshipTypesHint=" << hint.relationshipTypesHint() << ","
                  << "optimizationHints=" << static_cast<quint32>(hint.optimizationHints()) << ","
                  << "preferredImageSize=" << hint.preferredImageSize()
                  << "maxCountHint=" << hint.maxCountHint()
                  << ")";
    return dbg.maybeSpace();
}
#endif

QTM_END_NAMESPACE
<commit_msg>Added missing since tags to QContactFetchHint documentation<commit_after>/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Mobility Components.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/

#include "qcontactfetchhint.h"
#include "qcontactfetchhint_p.h"

#include <QStringList>

#ifndef QT_NO_DEBUG_STREAM
#include <QDebug>
#endif

QTM_BEGIN_NAMESPACE

/*!
  \class QContactFetchHint

  \inmodule QtContacts
   \since 1.0

  \brief The QContactFetchHint class provides hints to the manager about which contact
  information needs to be retrieved in an asynchronous fetch request or a synchronous
  function call.

  All of the hints may be ignored at the discretion of the manager, however if a manager
  is able to optimize retrieval of contacts due to hints, it may do so.  If a manager
  ignores a hint, it must retrieve the full set of data that the hint refers to.

  The fetch hint contains:
  \list
   \o a list of detail definition names which the client is interested
  in (empty if interested in all detail definitions)
   \o a list of relationship types which the client is interested in
  (empty if interested in all relationships)
   \o some optimization flags which allow the client to tell the backend if they are
  not interested in any relationships, any action preferences, or any binary blobs (images etc).
   \o a preferred size for any images, if the backend supports multiple sizes or scaling
  \endlist

  Important note: a client should not make changes to a contact which has been retrieved
  using a fetch hint other than the default fetch hint.  Doing so can result in information
  loss when saving the contact back to the manager (as the "new" restricted contact will
  replace the previously saved contact in the backend).
 */

/*!
  \enum QContactFetchHint::OptimizationHint

  This enum defines flags which may be set to inform the backend that the client does
  not require certain information.  The backend may safely ignore the hint, but then
  must return the full set of information relating to the optimization hint.

  \value AllRequired Tells the backend that all information is required
  \value NoRelationships Tells the backend that the client does not require retrieved contacts to include a cache of relationships
  \value NoActionPreferences Tells the backend that the client does not require retrieved contacts to include a cache of action preferences
  \value NoBinaryBlobs Tells the backend that the client does not require retrieved contacts to include binary blobs such as thumbnail images
 */

/*!
  Constructs a new contact fetch hint which requests that the backend fetch all information
 */
QContactFetchHint::QContactFetchHint()
    : d(new QContactFetchHintPrivate)
{
}

/*!
  Constructs a new contact fetch hint as a copy of \a other
 */
QContactFetchHint::QContactFetchHint(const QContactFetchHint &other)
    : d(other.d)
{
}

/*!
  Frees any memory in use by the fetch hint
 */
QContactFetchHint::~QContactFetchHint()
{
}

/*!
  Assigns this fetch hint to be equal to the \a other fetch hint
  \since 1.0
 */
QContactFetchHint& QContactFetchHint::operator=(const QContactFetchHint& other)
{
    d = other.d;
    return *this;
}

/*!
  Returns the list of definition names that identify detail definitions of which details
  the manager should (at a minimum) retrieve when fetching contacts.
  This hint may be ignored by the backend, in which case it will return the full set of details for
  each contact retrieved.

  \sa setDetailDefinitionsHint()
  \since 1.0
 */
QStringList QContactFetchHint::detailDefinitionsHint() const
{
    return d->m_definitionsHint;
}

/*!
  Sets the list of definition names that identify detail definitions of which details
  the manager should (at a minimum) retrieve when fetching contacts to \a definitionNames.
  This hint may be ignored by the backend, in which case it will return the full set of details for
  each contact retrieved.

  \sa detailDefinitionsHint()
  \since 1.0
 */
void QContactFetchHint::setDetailDefinitionsHint(const QStringList& definitionNames)
{
    d->m_definitionsHint = definitionNames;
}

/*!
  Returns the list of relationship types that the manager should (at a minimum) retrieve
  when fetching contacts.
  This hint may be ignored by the backend, in which case it will return the full set of
  relationships for each contact retrieved.

  \sa setRelationshipTypesHint(), QContact::relationships()
  \since 1.0
 */
QStringList QContactFetchHint::relationshipTypesHint() const
{
    return d->m_relationshipsHint;
}

/*!
  Sets the list of relationship types that the manager should (at a minimum) retrieve
  when fetching contacts to \a relationshipTypes.
  This hint may be ignored by the backend, in which case it will return the full set of
  relationships for each contact retrieved.

  \sa relationshipTypesHint(), QContact::relationships()
  \since 1.0
 */
void QContactFetchHint::setRelationshipTypesHint(const QStringList& relationshipTypes)
{
    d->m_relationshipsHint = relationshipTypes;
}

/*!
  Returns the preferred pixel dimensions for any images returned
  by the manager for a given request.  This hint may be ignored
  by the manager.

  This is useful when the backend supports multiple sizes of an
  image (or the image is natively scaleable) in order to get an
  image that will look good at the indicated dimensions.

  The caller should be prepared for images of any dimensions,
  in any case.
  \since 1.1
 */
QSize QContactFetchHint::preferredImageSize() const
{
    return d->m_preferredImageSize;
}

/*!
  Sets the preferred pixel dimensions for any images returned
  by the manager for the given request to \a size.  This hint
  may be ignored by the manager.

  This is useful when the backend supports multiple sizes of an
  image (or the image is natively scaleable) in order to get an
  image that will look good at the indicated dimensions.

  The caller should be prepared for images of any dimensions,
  in any case.
  \since 1.1
 */
void QContactFetchHint::setPreferredImageSize(const QSize& size)
{
    d->m_preferredImageSize = size;
}

/*!
  Returns the optimization hint flags specified by the client.
  These hints may be ignored by the backend, in which case it will return
  the full set of information accessible in a contact, including
  relationships, action preferences, and binary blobs.

  \sa setOptimizationHints()
  \since 1.0
 */
QContactFetchHint::OptimizationHints QContactFetchHint::optimizationHints() const
{
    return d->m_optimizationHints;
}

/*!
  Sets the optimization hint flags specified by the client to \a hints.
  These hints may be ignored by the backend, in which case it will return
  the full set of information accessible in a contact, including
  relationships, action preferences, and binary blobs.

  \sa optimizationHints()
  \since 1.0
 */
void QContactFetchHint::setOptimizationHints(OptimizationHints hints)
{
    d->m_optimizationHints = hints;
}

/*!
  Returns the number of results which the client considers to be the
  maximum number of useful results.  The client is only interested
  in this number of results, so returning any more results
  would be superfluous to the client's requirements.
  Note that this fetch hint only affects operations where the
  backend would return a list of contacts; this hint specifies
  the maximum number of contacts in the list which would be useful
  to the client.  The backend may ignore this hint, in which case it
  must return all contacts which would otherwise have been returned
  as a result of the operation.

  A negative value for count denotes that the client wishes to
  retrieve all results.  The default value is -1.
  \since 1.2
 */
int QContactFetchHint::maxCountHint() const
{
    return d->m_maxCount;
}

/*!
  Sets the maximum number of results which the client is interested in
  to \a count.  The client is only interested in this number of results,
  so returning any more results would be superfluous to the client's
  requirements. Note that this fetch hint only affects operations where
  the backend would return a list of contacts; this hint specifies
  the maximum number of contacts in the list which would be useful
  to the client.  The backend may ignore this hint, in which case it
  must return all contacts which would otherwise have been returned
  as a result of the operation.

  A negative value for count denotes that the client wishes to
  retrieve all results.  The default value is -1.
  \since 1.2
*/
void QContactFetchHint::setMaxCountHint(int count)
{
    count < 0 ? (d->m_maxCount = -1) : (d->m_maxCount = count);
}

#ifndef QT_NO_DATASTREAM
QDataStream& operator<<(QDataStream& out, const QContactFetchHint& hint)
{
    quint8 formatVersion = 2; // Version of QDataStream format for QContactFetchHint
    return out << formatVersion
               << hint.detailDefinitionsHint()
               << hint.relationshipTypesHint()
               << static_cast<quint32>(hint.optimizationHints())
               << hint.preferredImageSize()
               << hint.maxCountHint();
}

QDataStream& operator>>(QDataStream& in, QContactFetchHint& hint)
{
    hint = QContactFetchHint();
    quint8 formatVersion;
    in >> formatVersion;
    if (formatVersion == 1 || formatVersion == 2) {
        QStringList detailDefinitionHints;
        QStringList relationshipTypeHints;
        quint32 optimizations;
        QSize dimensions;
        in >> detailDefinitionHints >> relationshipTypeHints >> optimizations >> dimensions;
        hint.setDetailDefinitionsHint(detailDefinitionHints);
        hint.setRelationshipTypesHint(relationshipTypeHints);
        hint.setOptimizationHints(QContactFetchHint::OptimizationHints(optimizations));
        hint.setPreferredImageSize(dimensions);

        // version two also has a maximum fetch count hint.
        if (formatVersion == 2) {
            int maxCountHint = -1;
            in >> maxCountHint;
            hint.setMaxCountHint(maxCountHint);
        }
    } else {
        in.setStatus(QDataStream::ReadCorruptData);
    }
    return in;
}

#endif

#ifndef QT_NO_DEBUG_STREAM
/*!
  Outputs \a hint to the debug stream \a dbg
 */
QDebug operator<<(QDebug dbg, const QContactFetchHint& hint)
{
    dbg.nospace() << "QContactFetchHint("
                  << "detailDefinitionsHint=" << hint.detailDefinitionsHint() << ","
                  << "relationshipTypesHint=" << hint.relationshipTypesHint() << ","
                  << "optimizationHints=" << static_cast<quint32>(hint.optimizationHints()) << ","
                  << "preferredImageSize=" << hint.preferredImageSize()
                  << "maxCountHint=" << hint.maxCountHint()
                  << ")";
    return dbg.maybeSpace();
}
#endif

QTM_END_NAMESPACE
<|endoftext|>


<commit_before>/*
 *
 * Copyright 2015 gRPC authors.
 *
 * 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.
 *
 */

#include "src/core/lib/iomgr/port.h"

#ifdef GRPC_WINSOCK_SOCKET

#include <winsock2.h>

#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/log_windows.h>
#include <grpc/support/thd.h>
#include <grpc/support/useful.h>

#include "src/core/lib/debug/stats.h"
#include "src/core/lib/iomgr/iocp_windows.h"
#include "src/core/lib/iomgr/iomgr_internal.h"
#include "src/core/lib/iomgr/socket_windows.h"
#include "src/core/lib/iomgr/timer.h"

static ULONG g_iocp_kick_token;
static OVERLAPPED g_iocp_custom_overlap;

static gpr_atm g_custom_events = 0;

static HANDLE g_iocp;

static DWORD deadline_to_millis_timeout(grpc_exec_ctx *exec_ctx,
                                        grpc_millis deadline) {
  gpr_timespec timeout;
  if (deadline == GRPC_MILLIS_INF_FUTURE) {
    return INFINITE;
  }
  return (DWORD)GPR_MAX(0, deadline - grpc_exec_ctx_now(exec_ctx));
}

grpc_iocp_work_status grpc_iocp_work(grpc_exec_ctx *exec_ctx,
                                     grpc_millis deadline) {
  BOOL success;
  DWORD bytes = 0;
  DWORD flags = 0;
  ULONG_PTR completion_key;
  LPOVERLAPPED overlapped;
  grpc_winsocket *socket;
  grpc_winsocket_callback_info *info;
  GRPC_STATS_INC_SYSCALL_POLL(exec_ctx);
  success =
      GetQueuedCompletionStatus(g_iocp, &bytes, &completion_key, &overlapped,
                                deadline_to_millis_timeout(exec_ctx, deadline));
  if (success == 0 && overlapped == NULL) {
    return GRPC_IOCP_WORK_TIMEOUT;
  }
  GPR_ASSERT(completion_key && overlapped);
  if (overlapped == &g_iocp_custom_overlap) {
    gpr_atm_full_fetch_add(&g_custom_events, -1);
    if (completion_key == (ULONG_PTR)&g_iocp_kick_token) {
      /* We were awoken from a kick. */
      return GRPC_IOCP_WORK_KICK;
    }
    gpr_log(GPR_ERROR, "Unknown custom completion key.");
    abort();
  }

  socket = (grpc_winsocket *)completion_key;
  if (overlapped == &socket->write_info.overlapped) {
    info = &socket->write_info;
  } else if (overlapped == &socket->read_info.overlapped) {
    info = &socket->read_info;
  } else {
    abort();
  }
  success = WSAGetOverlappedResult(socket->socket, &info->overlapped, &bytes,
                                   FALSE, &flags);
  info->bytes_transfered = bytes;
  info->wsa_error = success ? 0 : WSAGetLastError();
  GPR_ASSERT(overlapped == &info->overlapped);
  grpc_socket_become_ready(exec_ctx, socket, info);
  return GRPC_IOCP_WORK_WORK;
}

void grpc_iocp_init(void) {
  g_iocp =
      CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, (ULONG_PTR)NULL, 0);
  GPR_ASSERT(g_iocp);
}

void grpc_iocp_kick(void) {
  BOOL success;

  gpr_atm_full_fetch_add(&g_custom_events, 1);
  success = PostQueuedCompletionStatus(g_iocp, 0, (ULONG_PTR)&g_iocp_kick_token,
                                       &g_iocp_custom_overlap);
  GPR_ASSERT(success);
}

void grpc_iocp_flush(void) {
  grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
  grpc_iocp_work_status work_status;

  do {
    work_status = grpc_iocp_work(&exec_ctx, GRPC_MILLIS_INF_PAST);
  } while (work_status == GRPC_IOCP_WORK_KICK ||
           grpc_exec_ctx_flush(&exec_ctx));
}

void grpc_iocp_shutdown(void) {
  grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
  while (gpr_atm_acq_load(&g_custom_events)) {
    grpc_iocp_work(&exec_ctx, GRPC_MILLIS_INF_FUTURE);
    grpc_exec_ctx_flush(&exec_ctx);
  }
  grpc_exec_ctx_finish(&exec_ctx);
  GPR_ASSERT(CloseHandle(g_iocp));
}

void grpc_iocp_add_socket(grpc_winsocket *socket) {
  HANDLE ret;
  if (socket->added_to_iocp) return;
  ret = CreateIoCompletionPort((HANDLE)socket->socket, g_iocp,
                               (uintptr_t)socket, 0);
  if (!ret) {
    char *utf8_message = gpr_format_message(WSAGetLastError());
    gpr_log(GPR_ERROR, "Unable to add socket to iocp: %s", utf8_message);
    gpr_free(utf8_message);
    __debugbreak();
    abort();
  }
  socket->added_to_iocp = 1;
  GPR_ASSERT(ret == g_iocp);
}

#endif /* GRPC_WINSOCK_SOCKET */
<commit_msg>Properly flushing execution context cache under Windows.<commit_after>/*
 *
 * Copyright 2015 gRPC authors.
 *
 * 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.
 *
 */

#include "src/core/lib/iomgr/port.h"

#ifdef GRPC_WINSOCK_SOCKET

#include <winsock2.h>

#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/log_windows.h>
#include <grpc/support/thd.h>
#include <grpc/support/useful.h>

#include "src/core/lib/debug/stats.h"
#include "src/core/lib/iomgr/iocp_windows.h"
#include "src/core/lib/iomgr/iomgr_internal.h"
#include "src/core/lib/iomgr/socket_windows.h"
#include "src/core/lib/iomgr/timer.h"

static ULONG g_iocp_kick_token;
static OVERLAPPED g_iocp_custom_overlap;

static gpr_atm g_custom_events = 0;

static HANDLE g_iocp;

static DWORD deadline_to_millis_timeout(grpc_exec_ctx *exec_ctx,
                                        grpc_millis deadline) {
  if (deadline == GRPC_MILLIS_INF_FUTURE) {
    return INFINITE;
  }
  return (DWORD)GPR_MAX(0, deadline - grpc_exec_ctx_now(exec_ctx));
}

grpc_iocp_work_status grpc_iocp_work(grpc_exec_ctx *exec_ctx,
                                     grpc_millis deadline) {
  BOOL success;
  DWORD bytes = 0;
  DWORD flags = 0;
  ULONG_PTR completion_key;
  LPOVERLAPPED overlapped;
  grpc_winsocket *socket;
  grpc_winsocket_callback_info *info;
  GRPC_STATS_INC_SYSCALL_POLL(exec_ctx);
  success =
      GetQueuedCompletionStatus(g_iocp, &bytes, &completion_key, &overlapped,
                                deadline_to_millis_timeout(exec_ctx, deadline));
  grpc_exec_ctx_invalidate_now(exec_ctx);
  if (success == 0 && overlapped == NULL) {
    return GRPC_IOCP_WORK_TIMEOUT;
  }
  GPR_ASSERT(completion_key && overlapped);
  if (overlapped == &g_iocp_custom_overlap) {
    gpr_atm_full_fetch_add(&g_custom_events, -1);
    if (completion_key == (ULONG_PTR)&g_iocp_kick_token) {
      /* We were awoken from a kick. */
      return GRPC_IOCP_WORK_KICK;
    }
    gpr_log(GPR_ERROR, "Unknown custom completion key.");
    abort();
  }

  socket = (grpc_winsocket *)completion_key;
  if (overlapped == &socket->write_info.overlapped) {
    info = &socket->write_info;
  } else if (overlapped == &socket->read_info.overlapped) {
    info = &socket->read_info;
  } else {
    abort();
  }
  success = WSAGetOverlappedResult(socket->socket, &info->overlapped, &bytes,
                                   FALSE, &flags);
  info->bytes_transfered = bytes;
  info->wsa_error = success ? 0 : WSAGetLastError();
  GPR_ASSERT(overlapped == &info->overlapped);
  grpc_socket_become_ready(exec_ctx, socket, info);
  return GRPC_IOCP_WORK_WORK;
}

void grpc_iocp_init(void) {
  g_iocp =
      CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, (ULONG_PTR)NULL, 0);
  GPR_ASSERT(g_iocp);
}

void grpc_iocp_kick(void) {
  BOOL success;

  gpr_atm_full_fetch_add(&g_custom_events, 1);
  success = PostQueuedCompletionStatus(g_iocp, 0, (ULONG_PTR)&g_iocp_kick_token,
                                       &g_iocp_custom_overlap);
  GPR_ASSERT(success);
}

void grpc_iocp_flush(void) {
  grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
  grpc_iocp_work_status work_status;

  do {
    work_status = grpc_iocp_work(&exec_ctx, GRPC_MILLIS_INF_PAST);
  } while (work_status == GRPC_IOCP_WORK_KICK ||
           grpc_exec_ctx_flush(&exec_ctx));
}

void grpc_iocp_shutdown(void) {
  grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
  while (gpr_atm_acq_load(&g_custom_events)) {
    grpc_iocp_work(&exec_ctx, GRPC_MILLIS_INF_FUTURE);
    grpc_exec_ctx_flush(&exec_ctx);
  }
  grpc_exec_ctx_finish(&exec_ctx);
  GPR_ASSERT(CloseHandle(g_iocp));
}

void grpc_iocp_add_socket(grpc_winsocket *socket) {
  HANDLE ret;
  if (socket->added_to_iocp) return;
  ret = CreateIoCompletionPort((HANDLE)socket->socket, g_iocp,
                               (uintptr_t)socket, 0);
  if (!ret) {
    char *utf8_message = gpr_format_message(WSAGetLastError());
    gpr_log(GPR_ERROR, "Unable to add socket to iocp: %s", utf8_message);
    gpr_free(utf8_message);
    __debugbreak();
    abort();
  }
  socket->added_to_iocp = 1;
  GPR_ASSERT(ret == g_iocp);
}

#endif /* GRPC_WINSOCK_SOCKET */
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: fmthbsh.hxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-09 01:50:50 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef _FMTHBSH_HXX
#define _FMTHBSH_HXX

#ifndef _SFXPOOLITEM_HXX //autogen
#include <svtools/poolitem.hxx>
#endif

// ATT_SOFTHYPH ******************************
// Attribut fuer benutzerdefinierte Trennstellen.

class SwFmtSoftHyph : public SfxPoolItem
{
public:
    SwFmtSoftHyph();

    // "pure virtual Methoden" vom SfxPoolItem
    virtual int             operator==( const SfxPoolItem& ) const;
    virtual SfxPoolItem*    Clone( SfxItemPool* pPool = 0 ) const;

    inline SwFmtSoftHyph& operator=(const SwFmtSoftHyph& rSH) {
            return *this;
        }
};

// ATT_HARDBLANK ******************************
// Attribut fuer geschuetzte Leerzeichen.

class SwFmtHardBlank : public SfxPoolItem
{
    sal_Unicode cChar;
public:
    SwFmtHardBlank( sal_Unicode cCh, BOOL bCheck = TRUE );

    // "pure virtual Methoden" vom SfxPoolItem
    virtual int             operator==( const SfxPoolItem& ) const;
    virtual SfxPoolItem*    Clone( SfxItemPool* pPool = 0 ) const;

    inline sal_Unicode GetChar() const { return cChar; }
    inline SwFmtHardBlank& operator=(const SwFmtHardBlank& rHB)
    { cChar = rHB.GetChar(); return *this; }
};

#endif

<commit_msg>INTEGRATION: CWS pchfix04 (1.3.592); FILE MERGED 2007/02/05 08:27:15 os 1.3.592.1: #i73604# usage of ITEMID_* removed<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: fmthbsh.hxx,v $
 *
 *  $Revision: 1.4 $
 *
 *  last change: $Author: kz $ $Date: 2007-05-10 15:53:28 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef _FMTHBSH_HXX
#define _FMTHBSH_HXX

#ifndef _SFXPOOLITEM_HXX //autogen
#include <svtools/poolitem.hxx>
#endif

// ATT_SOFTHYPH ******************************
// Attribut fuer benutzerdefinierte Trennstellen.

class SwFmtSoftHyph : public SfxPoolItem
{
public:
    SwFmtSoftHyph();

    // "pure virtual Methoden" vom SfxPoolItem
    virtual int             operator==( const SfxPoolItem& ) const;
    virtual SfxPoolItem*    Clone( SfxItemPool* pPool = 0 ) const;

    inline SwFmtSoftHyph& operator=(const SwFmtSoftHyph&) {
            return *this;
        }
};

// ATT_HARDBLANK ******************************
// Attribut fuer geschuetzte Leerzeichen.

class SwFmtHardBlank : public SfxPoolItem
{
    sal_Unicode cChar;
public:
    SwFmtHardBlank( sal_Unicode cCh, BOOL bCheck = TRUE );

    // "pure virtual Methoden" vom SfxPoolItem
    virtual int             operator==( const SfxPoolItem& ) const;
    virtual SfxPoolItem*    Clone( SfxItemPool* pPool = 0 ) const;

    inline sal_Unicode GetChar() const { return cChar; }
    inline SwFmtHardBlank& operator=(const SwFmtHardBlank& rHB)
    { cChar = rHB.GetChar(); return *this; }
};

#endif

<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: sortopt.hxx,v $
 *
 *  $Revision: 1.5 $
 *
 *  last change: $Author: rt $ $Date: 2004-08-23 08:38:22 $
 *
 *  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 _SORTOPT_HXX
#define _SORTOPT_HXX

#ifndef _SVARRAY_HXX
#include <svtools/svarray.hxx>
#endif
#ifndef _STRING_HXX
#include <tools/string.hxx>
#endif

#ifndef INCLUDED_SWDLLAPI_H
#include "swdllapi.h"
#endif

enum SwSortOrder        { SRT_ASCENDING, SRT_DESCENDING };
enum SwSortDirection    { SRT_COLUMNS, SRT_ROWS         };

/*--------------------------------------------------------------------
    Beschreibung: SortierSchluessel
 --------------------------------------------------------------------*/
struct SW_DLLPUBLIC SwSortKey
{
    SwSortKey();
    SwSortKey( USHORT nId, const String& rSrtType, SwSortOrder eOrder );
    SwSortKey( const SwSortKey& rOld );

    String          sSortType;
    SwSortOrder     eSortOrder;
    USHORT          nColumnId;
    BOOL            bIsNumeric;
};

SV_DECL_PTRARR(SwSortKeys, SwSortKey*, 3, 1)

struct SW_DLLPUBLIC SwSortOptions
{
    SwSortOptions();
    ~SwSortOptions();
    SwSortOptions(const SwSortOptions& rOpt);

    SwSortKeys      aKeys;
    SwSortDirection eDirection;
    sal_Unicode     cDeli;
    USHORT          nLanguage;
    BOOL            bTable;
    BOOL            bIgnoreCase;
};

#endif  // _SORTOPT_HXX
<commit_msg>INTEGRATION: CWS ooo19126 (1.5.596); FILE MERGED 2005/09/05 13:36:28 rt 1.5.596.1: #i54170# Change license header: remove SISSL<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: sortopt.hxx,v $
 *
 *  $Revision: 1.6 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-09 02:09:45 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef _SORTOPT_HXX
#define _SORTOPT_HXX

#ifndef _SVARRAY_HXX
#include <svtools/svarray.hxx>
#endif
#ifndef _STRING_HXX
#include <tools/string.hxx>
#endif

#ifndef INCLUDED_SWDLLAPI_H
#include "swdllapi.h"
#endif

enum SwSortOrder        { SRT_ASCENDING, SRT_DESCENDING };
enum SwSortDirection    { SRT_COLUMNS, SRT_ROWS         };

/*--------------------------------------------------------------------
    Beschreibung: SortierSchluessel
 --------------------------------------------------------------------*/
struct SW_DLLPUBLIC SwSortKey
{
    SwSortKey();
    SwSortKey( USHORT nId, const String& rSrtType, SwSortOrder eOrder );
    SwSortKey( const SwSortKey& rOld );

    String          sSortType;
    SwSortOrder     eSortOrder;
    USHORT          nColumnId;
    BOOL            bIsNumeric;
};

SV_DECL_PTRARR(SwSortKeys, SwSortKey*, 3, 1)

struct SW_DLLPUBLIC SwSortOptions
{
    SwSortOptions();
    ~SwSortOptions();
    SwSortOptions(const SwSortOptions& rOpt);

    SwSortKeys      aKeys;
    SwSortDirection eDirection;
    sal_Unicode     cDeli;
    USHORT          nLanguage;
    BOOL            bTable;
    BOOL            bIgnoreCase;
};

#endif  // _SORTOPT_HXX
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: toxwrap.hxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: obo $ $Date: 2004-08-12 12:07:50 $
 *
 *  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 _TOXWRAP_HXX
#define _TOXWRAP_HXX

#ifndef _SOLAR_H
#include <tools/solar.h>
#endif
#ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_
#include <com/sun/star/lang/Locale.hpp>
#endif
#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_
#include <com/sun/star/uno/Reference.hxx>
#endif

#ifndef _SWUNODEF_HXX
#include <swunodef.hxx>
#endif

namespace com { namespace sun { namespace star {
namespace i18n {
    class XExtendedIndexEntrySupplier;
}
namespace lang {
    class XMultiServiceFactory;
}
}}};

class String;

class IndexEntrySupplierWrapper
{
    STAR_NMSPC::lang::Locale aLcl;
    STAR_NMSPC::uno::Reference < com::sun::star::i18n::XExtendedIndexEntrySupplier > xIES;

public:
    IndexEntrySupplierWrapper();
    ~IndexEntrySupplierWrapper();

    void SetLocale( const STAR_NMSPC::lang::Locale& rLocale ) { aLcl = rLocale; }

    String GetIndexKey( const String& rTxt, const String& rTxtReading,
                        const STAR_NMSPC::lang::Locale& rLocale ) const;

    String GetFollowingText( BOOL bMorePages ) const;

    STAR_NMSPC::uno::Sequence< ::rtl::OUString >
    GetAlgorithmList( const STAR_NMSPC::lang::Locale& rLcl ) const;

    sal_Bool LoadAlgorithm( const STAR_NMSPC::lang::Locale& rLcl,
                            const String& sSortAlgorithm, long nOptions ) const;

    sal_Int16 CompareIndexEntry( const String& rTxt1, const String& rTxtReading1,
                                 const STAR_NMSPC::lang::Locale& rLcl1,
                                 const String& rTxt2, const String& rTxtReading2,
                                 const STAR_NMSPC::lang::Locale& rLcl2 ) const;
};

#endif
<commit_msg>INTEGRATION: CWS tune03 (1.2.576); FILE MERGED 2004/07/19 19:10:45 mhu 1.2.576.1: #i29979# Added SW_DLLPUBLIC/PRIVATE (see swdllapi.h) to exported symbols/classes.<commit_after>/*************************************************************************
 *
 *  $RCSfile: toxwrap.hxx,v $
 *
 *  $Revision: 1.4 $
 *
 *  last change: $Author: rt $ $Date: 2004-08-23 08:41:21 $
 *
 *  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 _TOXWRAP_HXX
#define _TOXWRAP_HXX

#ifndef _SOLAR_H
#include <tools/solar.h>
#endif
#ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_
#include <com/sun/star/lang/Locale.hpp>
#endif
#ifndef _COM_SUN_STAR_UNO_REFERENCE_HXX_
#include <com/sun/star/uno/Reference.hxx>
#endif

#ifndef _SWUNODEF_HXX
#include <swunodef.hxx>
#endif
#ifndef INCLUDED_SWDLLAPI_H
#include "swdllapi.h"
#endif

namespace com { namespace sun { namespace star {
namespace i18n {
    class XExtendedIndexEntrySupplier;
}
namespace lang {
    class XMultiServiceFactory;
}
}}};

class String;

class SW_DLLPUBLIC IndexEntrySupplierWrapper
{
    STAR_NMSPC::lang::Locale aLcl;
    STAR_NMSPC::uno::Reference < com::sun::star::i18n::XExtendedIndexEntrySupplier > xIES;

public:
    IndexEntrySupplierWrapper();
    ~IndexEntrySupplierWrapper();

    void SetLocale( const STAR_NMSPC::lang::Locale& rLocale ) { aLcl = rLocale; }

    String GetIndexKey( const String& rTxt, const String& rTxtReading,
                        const STAR_NMSPC::lang::Locale& rLocale ) const;

    String GetFollowingText( BOOL bMorePages ) const;

    STAR_NMSPC::uno::Sequence< ::rtl::OUString >
    GetAlgorithmList( const STAR_NMSPC::lang::Locale& rLcl ) const;

    sal_Bool LoadAlgorithm( const STAR_NMSPC::lang::Locale& rLcl,
                            const String& sSortAlgorithm, long nOptions ) const;

    sal_Int16 CompareIndexEntry( const String& rTxt1, const String& rTxtReading1,
                                 const STAR_NMSPC::lang::Locale& rLcl1,
                                 const String& rTxt2, const String& rTxtReading2,
                                 const STAR_NMSPC::lang::Locale& rLcl2 ) const;
};

#endif
<|endoftext|>