diff --git a/pool/shard009/C++/0109950_toolboxcontroller.cpp b/pool/shard009/C++/0109950_toolboxcontroller.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4e0df36147464790fd645fc5c7021c8377d60d7b
--- /dev/null
+++ b/pool/shard009/C++/0109950_toolboxcontroller.cpp
@@ -0,0 +1,102 @@
+/*
+ * niepce - darkroom/toolboxcontroller.cpp
+ *
+ * Copyright (C) 2008-2014 Hubert Figuiere
+ *
+ * This program 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 3 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+#include
+
+#include
+#include
+#include
+
+#include "toolboxcontroller.hpp"
+#include "fwk/base/debug.hpp"
+#include "fwk/toolkit/widgets/editablehscale.hpp"
+#include "dritemwidget.hpp"
+
+#ifndef DATADIR
+#error DATADIR is not defined
+#endif
+
+namespace dr {
+
+ToolboxController::ToolboxController()
+ : Dockable("tools", _("Develop"), "apply") // FIXME there is no equivalent it seems.
+{
+
+}
+
+Gtk::Widget *
+ToolboxController::buildWidget()
+{
+ if(m_widget) {
+ return m_widget;
+ }
+ DrItemWidget *item = nullptr;
+ fwk::EditableHScale *s = nullptr;
+
+ Gtk::Box *toolbox = Dockable::build_vbox();
+ m_widget = toolbox;
+ DBG_ASSERT(toolbox, "vbox not found.");
+
+ item = manage(new DrItemWidget(_("Crop")));
+ toolbox->pack_start(*item, Gtk::PACK_SHRINK);
+ s = Gtk::manage(new fwk::EditableHScale("/org/gnome/Niepce/pixmaps/niepce-transform-rotate.png",
+ -45.0, 45.0, 0.5));
+ item->add_widget(_("Tilt"), *s);
+
+ item = manage(new DrItemWidget(_("White balance")));
+ toolbox->pack_start(*item, Gtk::PACK_SHRINK);
+ s = Gtk::manage(new fwk::EditableHScale(0.0, 100.0, 1.0));
+ item->add_widget(_("Color temperature"), *s);
+
+ item = manage(new DrItemWidget(_("Tone and colour")));
+ toolbox->pack_start(*item, Gtk::PACK_SHRINK);
+ s = Gtk::manage(new fwk::EditableHScale(-5.0, 5.0, 0.1));
+// s->signal_value_changed().connect();
+ item->add_widget(_("Exposure"), *s);
+ s = Gtk::manage(new fwk::EditableHScale(0, 100, 1));
+ item->add_widget(_("Recovery"), *s);
+ s = Gtk::manage(new fwk::EditableHScale(0, 100, 1));
+ item->add_widget(_("Fill Light"), *s);
+ s = Gtk::manage(new fwk::EditableHScale(0, 100, 1));
+ item->add_widget(_("Blacks"), *s);
+ s = Gtk::manage(new fwk::EditableHScale(-100, 100, 1));
+ item->add_widget(_("Brightness"), *s);
+ s = Gtk::manage(new fwk::EditableHScale(-100, 100, 1));
+ item->add_widget(_("Contrast"), *s);
+ s = Gtk::manage(new fwk::EditableHScale(-100, 100, 1));
+ item->add_widget(_("Saturation"), *s);
+ s = Gtk::manage(new fwk::EditableHScale(-100, 100, 1));
+ item->add_widget(_("Vibrance"), *s);
+
+ return m_widget;
+}
+
+
+}
+
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0))
+ indent-tabs-mode:nil
+ fill-column:80
+ End:
+*/
diff --git a/pool/shard009/C++/0109952_analyzer_tester.cc b/pool/shard009/C++/0109952_analyzer_tester.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3b5be7f3ee33c73a9704bafa9f1b736c8a3cd9ea
--- /dev/null
+++ b/pool/shard009/C++/0109952_analyzer_tester.cc
@@ -0,0 +1,88 @@
+// Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
+//
+// 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 "paddle/fluid/inference/analysis/analyzer.h"
+
+#include
+#include
+#include "paddle/fluid/inference/analysis/ut_helper.h"
+#include "paddle/fluid/inference/api/paddle_inference_api.h"
+#include "paddle/fluid/inference/api/paddle_inference_pass.h"
+
+namespace paddle {
+namespace inference {
+namespace analysis {
+
+using namespace framework; // NOLINT
+
+TEST(Analyzer, analysis_without_tensorrt) {
+ FLAGS_IA_enable_tensorrt_subgraph_engine = false;
+ Argument argument;
+ argument.fluid_model_dir.reset(new std::string(FLAGS_inference_model_dir));
+ Analyzer analyser;
+ analyser.Run(&argument);
+}
+
+TEST(Analyzer, analysis_with_tensorrt) {
+ FLAGS_IA_enable_tensorrt_subgraph_engine = true;
+ Argument argument;
+ argument.fluid_model_dir.reset(new std::string(FLAGS_inference_model_dir));
+ Analyzer analyser;
+ analyser.Run(&argument);
+}
+
+void TestWord2vecPrediction(const std::string &model_path) {
+ NativeConfig config;
+ config.model_dir = model_path;
+ config.use_gpu = false;
+ config.device = 0;
+ auto predictor =
+ ::paddle::CreatePaddlePredictor(
+ config);
+
+ // One single batch
+
+ int64_t data[4] = {1, 2, 3, 4};
+ PaddleTensor tensor;
+ tensor.shape = std::vector({4, 1});
+ tensor.data = PaddleBuf(data, sizeof(data));
+ tensor.dtype = PaddleDType::INT64;
+
+ // For simplicity, we set all the slots with the same data.
+ std::vector slots(4, tensor);
+ std::vector outputs;
+ CHECK(predictor->Run(slots, &outputs));
+
+ PADDLE_ENFORCE(outputs.size(), 1UL);
+ // Check the output buffer size and result of each tid.
+ PADDLE_ENFORCE(outputs.front().data.length(), 33168UL);
+ float result[5] = {0.00129761, 0.00151112, 0.000423564, 0.00108815,
+ 0.000932706};
+ const size_t num_elements = outputs.front().data.length() / sizeof(float);
+ // The outputs' buffers are in CPU memory.
+ for (size_t i = 0; i < std::min(5UL, num_elements); i++) {
+ LOG(INFO) << "data: "
+ << static_cast(outputs.front().data.data())[i];
+ PADDLE_ENFORCE(static_cast(outputs.front().data.data())[i],
+ result[i]);
+ }
+}
+
+TEST(Analyzer, word2vec_without_analysis) {
+ TestWord2vecPrediction(FLAGS_inference_model_dir);
+}
+
+} // namespace analysis
+} // namespace inference
+} // namespace paddle
diff --git a/pool/shard009/C++/0109956_Rectangle.cpp b/pool/shard009/C++/0109956_Rectangle.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9dcc4b43134820851a2dc829e7d09edc0ed4ec26
--- /dev/null
+++ b/pool/shard009/C++/0109956_Rectangle.cpp
@@ -0,0 +1,64 @@
+#include
+
+#include
+#include
+#include
+#include
+
+#include "Rectangle.h"
+
+// Rectangle (heigth, witdth)
+ph::Rectangle::Rectangle(const int height, const int width) {
+ this->height = height;
+ this->width = width;
+ this->rectangle = new Geometry;
+ this->addDrawable(rectangle);
+
+ compute();
+}
+
+// creating vertices/ normals / indices; simple rectangle build from two triangles
+void ph::Rectangle::compute() {
+ ref_ptr vertices = new Vec3Array();
+ ref_ptr normals = new Vec3Array();
+ ref_ptr indices = new DrawElementsUInt(GL_TRIANGLE_STRIP);
+
+ vertices->push_back(Vec3((-1/2.0)*height, 0.0, (-1/2.0)*width));
+ vertices->push_back(Vec3((1/2.0)*height, 0.0, (-1/2.0)*width));
+ vertices->push_back(Vec3((-1/2.0)*height, 0.0, (1/2.0)*width));
+ vertices->push_back(Vec3((1/2.0)*height, 0.0, (1/2.0)*width));
+
+ indices->push_back(0); indices->push_back(1); indices->push_back(2);
+ indices->push_back(1); indices->push_back(2); indices->push_back(3);
+
+ this->rectangle->setVertexArray(vertices.get());
+ this->rectangle->addPrimitiveSet(indices.get());
+}
+
+// creating texture coordinates
+void ph::Rectangle::setTextureCoordinates(int textureNumber) {
+ ref_ptr texcoords = new Vec2Array;
+
+ texcoords->push_back(Vec2(0.0,0.0));
+ texcoords->push_back(Vec2(1.0,0.0));
+ texcoords->push_back(Vec2(0.0,1.0));
+ texcoords->push_back(Vec2(1.0,1.0));
+
+ this->rectangle->setTexCoordArray(textureNumber, texcoords.get());
+}
+
+// setting texture on rectangle
+void ph::Rectangle::setTexture(const int textureNumber, const string filename) {
+ this->setTextureCoordinates(textureNumber);
+
+ ref_ptr texture = new Texture2D;
+ ref_ptr image = osgDB::readImageFile(filename);
+ texture->setWrap(Texture::WRAP_S, Texture::CLAMP_TO_EDGE);
+ texture->setImage(image.get());
+ this->getOrCreateStateSet()->setTextureAttributeAndModes(textureNumber, texture.get());
+
+ // enabling culling for rectangles / skybox
+ ref_ptr cull = new CullFace;
+ cull->setMode(CullFace::BACK);
+ this->getOrCreateStateSet()->setAttributeAndModes(cull.get());
+}
diff --git a/pool/shard009/C++/0109958_FreeLink.cc b/pool/shard009/C++/0109958_FreeLink.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fa6389aacb5080e49c65ebc44044dc8db975887b
--- /dev/null
+++ b/pool/shard009/C++/0109958_FreeLink.cc
@@ -0,0 +1,103 @@
+/*
+ * opencog/atoms/core/FreeLink.cc
+ *
+ * Copyright (C) 2015 Linas Vepstas
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License v3 as
+ * published by the Free Software Foundation and including the exceptions
+ * at http://opencog.org/wiki/Licenses
+ *
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program; if not, write to:
+ * Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include
+#include
+#include "FreeLink.h"
+#include "ScopeLink.h"
+#include "VariableList.h"
+
+using namespace opencog;
+
+FreeLink::FreeLink(const HandleSeq& oset,
+ TruthValuePtr tv,
+ AttentionValuePtr av)
+ : Link(FREE_LINK, oset, tv, av)
+{
+ init();
+}
+
+FreeLink::FreeLink(const Handle& a,
+ TruthValuePtr tv,
+ AttentionValuePtr av)
+ : Link(FREE_LINK, a, tv, av)
+{
+ init();
+}
+
+FreeLink::FreeLink(Type t, const HandleSeq& oset,
+ TruthValuePtr tv,
+ AttentionValuePtr av)
+ : Link(t, oset, tv, av)
+{
+ if (not classserver().isA(t, FREE_LINK))
+ throw InvalidParamException(TRACE_INFO, "Expecting a FreeLink");
+
+ // Derived classes have thier own init routines.
+ if (FREE_LINK != t) return;
+ init();
+}
+
+FreeLink::FreeLink(Type t, const Handle& a,
+ TruthValuePtr tv,
+ AttentionValuePtr av)
+ : Link(t, a, tv, av)
+{
+ if (not classserver().isA(t, FREE_LINK))
+ throw InvalidParamException(TRACE_INFO, "Expecting a FreeLink");
+
+ // Derived classes have thier own init routines.
+ if (FREE_LINK != t) return;
+ init();
+}
+
+FreeLink::FreeLink(Type t, const Handle& a, const Handle& b,
+ TruthValuePtr tv,
+ AttentionValuePtr av)
+ : Link(t, a, b, tv, av)
+{
+ if (not classserver().isA(t, FREE_LINK))
+ throw InvalidParamException(TRACE_INFO, "Expecting a FreeLink");
+
+ // Derived classes have thier own init routines.
+ if (FREE_LINK != t) return;
+ init();
+}
+
+FreeLink::FreeLink(Link& l)
+ : Link(l)
+{
+ Type tscope = l.getType();
+ if (not classserver().isA(tscope, FREE_LINK))
+ throw InvalidParamException(TRACE_INFO, "Expecting a FreeLink");
+
+ // Derived classes have thier own init routines.
+ if (FREE_LINK != tscope) return;
+ init();
+}
+
+/* ================================================================= */
+
+void FreeLink::init(void)
+{
+ _vars.find_variables(_outgoing);
+}
diff --git a/pool/shard009/C++/0109959_cryptauth_device_id_provider_impl.cc b/pool/shard009/C++/0109959_cryptauth_device_id_provider_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0dd5e6747aa65ab9d69144dd532db9acf3e43beb
--- /dev/null
+++ b/pool/shard009/C++/0109959_cryptauth_device_id_provider_impl.cc
@@ -0,0 +1,44 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ash/cryptauth/cryptauth_device_id_provider_impl.h"
+
+#include "base/guid.h"
+#include "base/no_destructor.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/common/pref_names.h"
+#include "components/prefs/pref_registry_simple.h"
+#include "components/prefs/pref_service.h"
+
+namespace ash {
+
+// static
+void CryptAuthDeviceIdProviderImpl::RegisterLocalPrefs(
+ PrefRegistrySimple* registry) {
+ registry->RegisterStringPref(prefs::kCryptAuthDeviceId, std::string());
+}
+
+// static
+const CryptAuthDeviceIdProviderImpl*
+CryptAuthDeviceIdProviderImpl::GetInstance() {
+ static const base::NoDestructor provider;
+ return provider.get();
+}
+
+std::string CryptAuthDeviceIdProviderImpl::GetDeviceId() const {
+ PrefService* local_state = g_browser_process->local_state();
+ DCHECK(local_state);
+
+ std::string device_id = local_state->GetString(prefs::kCryptAuthDeviceId);
+ if (device_id.empty()) {
+ device_id = base::GenerateGUID();
+ local_state->SetString(prefs::kCryptAuthDeviceId, device_id);
+ }
+
+ return device_id;
+}
+
+CryptAuthDeviceIdProviderImpl::CryptAuthDeviceIdProviderImpl() = default;
+
+} // namespace ash
diff --git a/pool/shard009/C++/0109960_slot1comp_mc.cpp b/pool/shard009/C++/0109960_slot1comp_mc.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1540712d20ada0bbb1c6e291fce50c7b6c5fb479
--- /dev/null
+++ b/pool/shard009/C++/0109960_slot1comp_mc.cpp
@@ -0,0 +1,43 @@
+/*
+ Copyright (C) 2013-2017 DeSmuME team
+
+ This file 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.
+
+ This file 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 the this software. If not, see .
+*/
+
+//this file contains the components used for emulating standard gamecard "MC" devices (eeprom, fram, flash)
+//this is largely done by accessing the BackupDevice resources in the core emulator
+
+#include "slot1comp_mc.h"
+
+#include "../MMU.h"
+#include "../NDSSystem.h"
+
+Slot1Comp_MC g_Slot1Comp_MC;
+
+u8 Slot1Comp_MC::auxspi_transaction(int PROCNUM, u8 value)
+{
+ return MMU_new.backupDevice.data_command(value, PROCNUM);
+}
+
+void Slot1Comp_MC::auxspi_reset(int PROCNUM)
+{
+ MMU_new.backupDevice.reset_command();
+}
+
+void Slot1Comp_MC::connect()
+{
+ //gamehack: not really a game hack
+ if(gameInfo.IsCode("AXBJ"))
+ MMU_new.backupDevice.uninitializedValue = 0x00; // Daigassou! Band Brothers DX (JP)
+}
\ No newline at end of file
diff --git a/pool/shard009/C++/0109965_page_launcher_api.cc b/pool/shard009/C++/0109965_page_launcher_api.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c52a012adc96e479a7ac47adaae275ff69c6d218
--- /dev/null
+++ b/pool/shard009/C++/0109965_page_launcher_api.cc
@@ -0,0 +1,39 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/api/page_launcher/page_launcher_api.h"
+
+#include "base/lazy_instance.h"
+#include "base/memory/linked_ptr.h"
+#include "chrome/browser/extensions/event_router.h"
+#include "chrome/browser/extensions/extension_system.h"
+#include "chrome/common/extensions/api/page_launcher.h"
+#include "googleurl/src/gurl.h"
+
+namespace extensions {
+
+// static
+void PageLauncherAPI::DispatchOnClickedEvent(
+ Profile* profile,
+ const std::string& extension_id,
+ const GURL& url,
+ const std::string& mimetype,
+ const std::string* page_title,
+ const std::string* selected_text) {
+ api::page_launcher::PageData data;
+ data.url = url.spec();
+ data.mimetype = mimetype;
+ if (page_title)
+ data.title.reset(new std::string(*page_title));
+ if (selected_text)
+ data.selection_text.reset(new std::string(*selected_text));
+
+ scoped_ptr event(
+ new Event("pageLauncher.onClicked",
+ api::page_launcher::OnClicked::Create(data)));
+ EventRouter* event_router = ExtensionSystem::Get(profile)->event_router();
+ event_router->DispatchEventToExtension(extension_id, event.Pass());
+}
+
+} // namespace extensions
diff --git a/pool/shard009/C++/0109967_3955491.cpp b/pool/shard009/C++/0109967_3955491.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e71c5cc2a2c036359d8bdbd80a4a873ddf197ead
--- /dev/null
+++ b/pool/shard009/C++/0109967_3955491.cpp
@@ -0,0 +1,80 @@
+//Language: GNU C++
+
+
+ // #includes {{{
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ using namespace std;
+ // }}}
+ // #defines {{{
+ #define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
+ #define SZ(x) ((int)(x).size())
+ #define ALL(x) (x).begin(),(x).end()
+ #define REP(i,n) for(int i=0;i<(n);i++)
+ #define REP1(i,a,b) for(int i=(a);i<=(b);i++)
+ #define PER(i,n) for(int i=(n)-1;i>=0;i--)
+ #define PER1(i,a,b) for(int i=(a);i>=(b);i--)
+ #define RI(x) scanf("%d",&x)
+ #define DRI(x) int x;RI(x)
+ #define RII(x,y) scanf("%d%d",&x,&y)
+ #define DRII(x,y) int x,y;RII(x,y)
+ #define RIII(x,y,z) scanf("%d%d%d",&x,&y,&z)
+ #define DRIII(x,y,z) int x,y,z;RIII(x,y,z)
+ #define RS(x) scanf("%s",x)
+ #define PI(x) printf("%d\n",x)
+ #define PIS(x) printf("%d ",x)
+ #define CASET int ___T,cas=1;scanf("%d",&___T);while(___T--)
+ #define CASEN0(n) int cas=1;while(scanf("%d",&n)!=EOF&&n)
+ #define CASEN(n) int cas=1;while(scanf("%d",&n)!=EOF)
+ #define MP make_pair
+ #define PB push_back
+ #define MS0(x) memset(x,0,sizeof(x))
+ #define MS1(x) memset(x,-1,sizeof(x))
+
+ #define F first
+ #define S second
+ typedef pair PII;
+ typedef long long LL;
+ typedef unsigned long long ULL;
+ // }}}
+int a[102][2],n;
+int s[102];
+bool dfs(int x,int y){
+ if (x==y) return true;
+ s[x]=1;
+ REP1(i,1,n){
+ if (!s[i] && ((a[i][0]a[x][0])||(a[i][0] a[x][1])))
+ if (dfs(i,y)) return true;
+ }
+ return false;
+
+}
+main(){
+ DRI(t);
+ n=0;
+ REP(i,t){
+ DRIII(o,x,y);
+ if (o==1){
+ a[++n][0]=x;
+ a[n][1]=y;
+ }else{
+ MS0(s);
+ if (dfs(x,y)) puts("YES");else puts("NO");
+ }
+ }
+}
diff --git a/pool/shard009/C++/0109969_GxsChannelUserNotify.cpp b/pool/shard009/C++/0109969_GxsChannelUserNotify.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c20b54b08cec0af1fb65bb9931f337b5056ed69a
--- /dev/null
+++ b/pool/shard009/C++/0109969_GxsChannelUserNotify.cpp
@@ -0,0 +1,51 @@
+/****************************************************************
+ * RetroShare is distributed under the following license:
+ *
+ * Copyright (C) 2014 RetroShare Team
+ *
+ * This program 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.
+ *
+ * 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 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.
+ ****************************************************************/
+
+#include "GxsChannelUserNotify.h"
+#include "gui/MainWindow.h"
+
+GxsChannelUserNotify::GxsChannelUserNotify(RsGxsIfaceHelper *ifaceImpl, QObject *parent) :
+ GxsUserNotify(ifaceImpl, parent)
+{
+}
+
+bool GxsChannelUserNotify::hasSetting(QString *name, QString *group)
+{
+ if (name) *name = tr("Channel Post");
+ if (group) *group = "Channel";
+
+ return true;
+}
+
+QIcon GxsChannelUserNotify::getIcon()
+{
+ return QIcon(":/icons/png/channels.png");
+}
+
+QIcon GxsChannelUserNotify::getMainIcon(bool hasNew)
+{
+ return hasNew ? QIcon(":/icons/png/channels-notify.png") : QIcon(":/icons/png/channels.png");
+}
+
+void GxsChannelUserNotify::iconClicked()
+{
+ MainWindow::showWindow(MainWindow::Channels);
+}
diff --git a/pool/shard009/C++/0109970_SVGAngleInterpolationType.cpp b/pool/shard009/C++/0109970_SVGAngleInterpolationType.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..0a5fefcb5582f5b2e82e00a5dd44366e4a02b50e
--- /dev/null
+++ b/pool/shard009/C++/0109970_SVGAngleInterpolationType.cpp
@@ -0,0 +1,34 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "core/animation/SVGAngleInterpolationType.h"
+
+#include "core/animation/InterpolationEnvironment.h"
+#include "core/animation/StringKeyframe.h"
+#include "core/svg/SVGAngle.h"
+
+namespace blink {
+
+PassOwnPtr SVGAngleInterpolationType::maybeConvertNeutral() const
+{
+ return InterpolationValue::create(*this, InterpolableNumber::create(0));
+}
+
+PassOwnPtr SVGAngleInterpolationType::maybeConvertSVGValue(const SVGPropertyBase& svgValue) const
+{
+ if (toSVGAngle(svgValue).orientType()->enumValue() != SVGMarkerOrientAngle)
+ return nullptr;
+ return InterpolationValue::create(*this, InterpolableNumber::create(toSVGAngle(svgValue).value()));
+}
+
+PassRefPtrWillBeRawPtr SVGAngleInterpolationType::appliedSVGValue(const InterpolableValue& interpolableValue, const NonInterpolableValue*) const
+{
+ double doubleValue = toInterpolableNumber(interpolableValue).value();
+ RefPtrWillBeRawPtr result = SVGAngle::create();
+ result->newValueSpecifiedUnits(SVGAngle::SVG_ANGLETYPE_DEG, doubleValue);
+ return result.release();
+}
+
+} // namespace blink
diff --git a/pool/shard009/C++/0109972_group_cipher_delegate.cpp b/pool/shard009/C++/0109972_group_cipher_delegate.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..da6ea77bb8de1fc9c8195718cc695f10edfd87ce
--- /dev/null
+++ b/pool/shard009/C++/0109972_group_cipher_delegate.cpp
@@ -0,0 +1,118 @@
+//
+// The MIT License(MIT)
+//
+// Copyright(c) 2014 Demonsaw LLC
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in all
+// copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+// SOFTWARE.
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include "component/group/group_security_component.h"
+#include "delegate/group/group_cipher_delegate.h"
+#include "entity/entity.h"
+#include "security/cipher/aes.h"
+#include "security/cipher/mars.h"
+#include "security/cipher/rc6.h"
+#include "security/cipher/serpent.h"
+#include "security/cipher/twofish.h"
+
+Q_DECLARE_METATYPE(eja::entity::ptr);
+
+namespace eja
+{
+ // Utility
+ QWidget* group_cipher_delegate::createEditor(QWidget* parent, const QStyleOptionViewItem& option, const QModelIndex& index) const
+ {
+ QComboBox* widget = new QComboBox(parent);
+ widget->addItem(cipher_name::aes);
+ widget->addItem(cipher_name::mars);
+ widget->addItem(cipher_name::rc6);
+ widget->addItem(cipher_name::serpent);
+ widget->addItem(cipher_name::twofish);
+
+ return widget;
+ }
+
+ void group_cipher_delegate::setEditorData(QWidget* editor, const QModelIndex& index) const
+ {
+ if (QComboBox* widget = qobject_cast(editor))
+ {
+ const auto data = index.data(Qt::EditRole).toString();
+ widget->setCurrentText(data);
+ }
+ else
+ {
+ QStyledItemDelegate::setEditorData(editor, index);
+ }
+ }
+
+ void group_cipher_delegate::setModelData(QWidget* editor, QAbstractItemModel* model, const QModelIndex& index) const
+ {
+ if (QComboBox* widget = qobject_cast(editor))
+ model->setData(index, widget->currentText(), Qt::EditRole);
+ else
+ QStyledItemDelegate::setModelData(editor, model, index);
+ }
+
+ QSize group_cipher_delegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const
+ {
+ // Data
+ auto variant = index.data(Qt::EditRole);
+ QString str = variant.toString();
+
+ // Size
+ QFontMetrics metrics(option.font);
+ QRect rect = metrics.boundingRect(str);
+ rect.setWidth(rect.width() + offset::padding);
+
+ return rect.size();
+ }
+
+ void group_cipher_delegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
+ {
+ QStyledItemDelegate::paint(painter, option, index);
+
+ if (option.state & QStyle::State_Enabled)
+ {
+ // Entity
+ const auto variant = index.data(Qt::DisplayRole);
+ const auto entity = variant.value();
+ if (!entity)
+ return;
+
+ // Security
+ const auto security = entity->get();
+ const auto name = security->get_cipher();
+
+ painter->save();
+ painter->setRenderHint(QPainter::Antialiasing, true);
+
+ // Name
+ QRect rect = QRect(option.rect.left(), option.rect.top(), option.rect.width(), option.rect.height());
+ painter->drawText(rect, Qt::TextSingleLine | Qt::AlignVCenter, name.c_str());
+
+ painter->restore();
+ }
+ }
+}
diff --git a/pool/shard009/C++/0109973_class1.cpp b/pool/shard009/C++/0109973_class1.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..3d01c94b446849b29a3d49576cebabd0c7bdf47d
--- /dev/null
+++ b/pool/shard009/C++/0109973_class1.cpp
@@ -0,0 +1,30 @@
+#include
+#include "class.h"
+
+using namespace std;
+
+CA::CA() {
+ a = 0;
+ cout << "Construction: " << a << endl;
+}
+
+CA::~CA() {
+ cout << "Destruct: " << a << endl;
+}
+
+void CA::setA(int x) {
+ a = x;
+}
+
+void CA::print() {
+ cout << "print: " << a << endl;
+}
+
+int main()
+{
+ CA ca;
+ ca.setA(10);
+ ca.print();
+
+ return 0;
+}
diff --git a/pool/shard009/C++/0109975_CWE762_Mismatched_Memory_Management_Routines__delete_int64_t_realloc_84a.cpp b/pool/shard009/C++/0109975_CWE762_Mismatched_Memory_Management_Routines__delete_int64_t_realloc_84a.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..80b4883f15bf0b1c25dde4cd95b9ff1339987c5c
--- /dev/null
+++ b/pool/shard009/C++/0109975_CWE762_Mismatched_Memory_Management_Routines__delete_int64_t_realloc_84a.cpp
@@ -0,0 +1,95 @@
+/* TEMPLATE GENERATED TESTCASE FILE
+Filename: CWE762_Mismatched_Memory_Management_Routines__delete_int64_t_realloc_84a.cpp
+Label Definition File: CWE762_Mismatched_Memory_Management_Routines__delete.label.xml
+Template File: sources-sinks-84a.tmpl.cpp
+*/
+/*
+ * @description
+ * CWE: 762 Mismatched Memory Management Routines
+ * BadSource: realloc Allocate data using realloc()
+ * GoodSource: Allocate data using new
+ * Sinks:
+ * GoodSink: Deallocate data using free()
+ * BadSink : Deallocate data using delete
+ * Flow Variant: 84 Data flow: data passed to class constructor and destructor by declaring the class object on the heap and deleting it after use
+ *
+ * */
+
+#include "std_testcase.h"
+#include "CWE762_Mismatched_Memory_Management_Routines__delete_int64_t_realloc_84.h"
+
+namespace CWE762_Mismatched_Memory_Management_Routines__delete_int64_t_realloc_84
+{
+
+#ifndef OMITBAD
+
+void bad()
+{
+ int64_t * data;
+ /* Initialize data*/
+ data = NULL;
+ CWE762_Mismatched_Memory_Management_Routines__delete_int64_t_realloc_84_bad * badObject = new CWE762_Mismatched_Memory_Management_Routines__delete_int64_t_realloc_84_bad(data);
+ delete badObject;
+}
+
+#endif /* OMITBAD */
+
+#ifndef OMITGOOD
+
+/* goodG2B uses the GoodSource with the BadSink */
+static void goodG2B()
+{
+ int64_t * data;
+ /* Initialize data*/
+ data = NULL;
+ CWE762_Mismatched_Memory_Management_Routines__delete_int64_t_realloc_84_goodG2B * goodG2BObject = new CWE762_Mismatched_Memory_Management_Routines__delete_int64_t_realloc_84_goodG2B(data);
+ delete goodG2BObject;
+}
+
+/* goodG2B uses the BadSource with the GoodSink */
+static void goodB2G()
+{
+ int64_t * data;
+ /* Initialize data*/
+ data = NULL;
+ CWE762_Mismatched_Memory_Management_Routines__delete_int64_t_realloc_84_goodB2G * goodB2GObject = new CWE762_Mismatched_Memory_Management_Routines__delete_int64_t_realloc_84_goodB2G(data);
+ delete goodB2GObject;
+}
+
+void good()
+{
+ goodG2B();
+ goodB2G();
+}
+
+#endif /* OMITGOOD */
+
+} /* close namespace */
+
+/* Below is the main(). It is only used when building this testcase on
+ its own for testing or for building a binary to use in testing binary
+ analysis tools. It is not used when compiling all the testcases as one
+ application, which is how source code analysis tools are tested. */
+
+#ifdef INCLUDEMAIN
+
+using namespace CWE762_Mismatched_Memory_Management_Routines__delete_int64_t_realloc_84; /* so that we can use good and bad easily */
+
+int main(int argc, char * argv[])
+{
+ /* seed randomness */
+ srand( (unsigned)time(NULL) );
+#ifndef OMITGOOD
+ printLine("Calling good()...");
+ good();
+ printLine("Finished good()");
+#endif /* OMITGOOD */
+#ifndef OMITBAD
+ printLine("Calling bad()...");
+ bad();
+ printLine("Finished bad()");
+#endif /* OMITBAD */
+ return 0;
+}
+
+#endif
diff --git a/pool/shard009/C++/0109977_rounding.cpp b/pool/shard009/C++/0109977_rounding.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9ca84af8d51165cd0a7799b6f4bfb0861f9a9cf8
--- /dev/null
+++ b/pool/shard009/C++/0109977_rounding.cpp
@@ -0,0 +1,95 @@
+/* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
+/*
+ * Main authors:
+ * Vincent Barichard
+ *
+ * Contributing authors:
+ * Christian Schulte
+ *
+ * Copyright:
+ * Christian Schulte, 2012
+ * Vincent Barichard, 2012
+ *
+ * Last modified:
+ * $Date$ by $Author$
+ * $Revision$
+ *
+ * This file is part of Gecode, the generic constraint
+ * development environment:
+ * http://www.gecode.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include
+
+#ifdef GECODE_HAS_MPFR
+
+#include
+#include
+
+namespace Gecode { namespace Float {
+
+ /// Type signatur of mpfr function
+ typedef int mpfr_func(mpfr_t, const __mpfr_struct*, mp_rnd_t);
+
+ /// Routine to call mpfr function with proper rounding
+ forceinline double
+ invoke_mpfr(FloatNum x, mpfr_func f, mp_rnd_t r) {
+ mpfr_t xx;
+ mpfr_init_set_d(xx, x, GMP_RNDN);
+ f(xx, xx, r);
+ FloatNum res = mpfr_get_d(xx, r);
+ mpfr_clear(xx);
+ return res;
+ }
+
+ /// Define mpfr functions with proper rounding
+#define GECODE_GENR_FUNC(name) \
+ FloatNum Rounding::name##_down(FloatNum x) { \
+ return invoke_mpfr(x, mpfr_##name, GMP_RNDD); \
+ } \
+ FloatNum Rounding::name##_up(FloatNum x) { \
+ return invoke_mpfr(x, mpfr_##name, GMP_RNDU); \
+ }
+ GECODE_GENR_FUNC(exp)
+ GECODE_GENR_FUNC(log)
+ GECODE_GENR_FUNC(sin)
+ GECODE_GENR_FUNC(cos)
+ GECODE_GENR_FUNC(tan)
+ GECODE_GENR_FUNC(asin)
+ GECODE_GENR_FUNC(acos)
+ GECODE_GENR_FUNC(atan)
+ GECODE_GENR_FUNC(sinh)
+ GECODE_GENR_FUNC(cosh)
+ GECODE_GENR_FUNC(tanh)
+ GECODE_GENR_FUNC(asinh)
+ GECODE_GENR_FUNC(acosh)
+ GECODE_GENR_FUNC(atanh)
+
+#undef GECODE_GENR_FUNC
+
+}}
+
+#endif
+
+// STATISTICS: float-var
+
diff --git a/pool/shard009/C++/0109982_pointer_partial_void.cc b/pool/shard009/C++/0109982_pointer_partial_void.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3a4377fb6e47f8bcdcbed87bee4a9bc72aa775a0
--- /dev/null
+++ b/pool/shard009/C++/0109982_pointer_partial_void.cc
@@ -0,0 +1,69 @@
+// { dg-require-atomic-builtins "" }
+// { dg-options "-std=gnu++0x" }
+
+// Copyright (C) 2012-2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library 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 3, 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 General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// .
+
+#include
+#include //std::abs
+#include
+
+// pointer arithimetic vs. atomic.
+// atomic vs. explicitly specialized w/o operators, like atomic_bool?
+int main(void)
+{
+ using namespace std;
+
+ typedef int value_type;
+ const size_t n = 2;
+ value_type value = 42;
+ value_type* p = &value;
+ void* vp = p;
+ ptrdiff_t __attribute__((unused)) dist(0);
+
+ atomic a(vp);
+
+ // operator++
+ void* vp2(a);
+ a++;
+ void* vp3(a);
+ dist = reinterpret_cast(vp2) - reinterpret_cast(vp3);
+ VERIFY ( std::abs(dist) == 1 );
+
+ // operator--
+ void* vp4(a);
+ a--;
+ void* vp5(a);
+ dist = reinterpret_cast(vp4) - reinterpret_cast(vp5);
+ VERIFY ( std::abs(dist) == 1 );
+
+ // operator+=
+ void* vp6(a);
+ a+=n;
+ void* vp7(a);
+ dist = reinterpret_cast(vp6) - reinterpret_cast(vp7);
+ VERIFY ( std::abs(dist) == n );
+
+ // operator-=
+ void* vp8(a);
+ a-=n;
+ void* vp9(a);
+ dist = reinterpret_cast(vp8) - reinterpret_cast(vp9);
+ VERIFY ( std::abs(dist) == n );
+
+ return 0;
+}
diff --git a/pool/shard009/C++/0109985_sample_attach.cc b/pool/shard009/C++/0109985_sample_attach.cc
new file mode 100644
index 0000000000000000000000000000000000000000..114990c6b59588f8aa66ff10498aa3574df791e1
--- /dev/null
+++ b/pool/shard009/C++/0109985_sample_attach.cc
@@ -0,0 +1,243 @@
+//----------------------------------------------------------------------------//
+// //
+// ozz-animation is hosted at http://github.com/guillaumeblanc/ozz-animation //
+// and distributed under the MIT License (MIT). //
+// //
+// Copyright (c) 2015 Guillaume Blanc //
+// //
+// Permission is hereby granted, free of charge, to any person obtaining a //
+// copy of this software and associated documentation files (the "Software"), //
+// to deal in the Software without restriction, including without limitation //
+// the rights to use, copy, modify, merge, publish, distribute, sublicense, //
+// and/or sell copies of the Software, and to permit persons to whom the //
+// Software is furnished to do so, subject to the following conditions: //
+// //
+// The above copyright notice and this permission notice shall be included in //
+// all copies or substantial portions of the Software. //
+// //
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR //
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, //
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL //
+// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER //
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING //
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER //
+// DEALINGS IN THE SOFTWARE. //
+// //
+//----------------------------------------------------------------------------//
+
+#include "ozz/animation/runtime/skeleton.h"
+#include "ozz/animation/runtime/animation.h"
+#include "ozz/animation/runtime/sampling_job.h"
+#include "ozz/animation/runtime/local_to_model_job.h"
+
+#include "ozz/base/log.h"
+
+#include "ozz/base/memory/allocator.h"
+
+#include "ozz/base/maths/vec_float.h"
+#include "ozz/base/maths/simd_math.h"
+#include "ozz/base/maths/box.h"
+#include "ozz/base/maths/soa_transform.h"
+
+#include "ozz/options/options.h"
+
+#include "framework/application.h"
+#include "framework/renderer.h"
+#include "framework/imgui.h"
+#include "framework/utils.h"
+
+// Skeleton archive can be specified as an option.
+OZZ_OPTIONS_DECLARE_STRING(
+ skeleton,
+ "Path to the skeleton (ozz archive format).",
+ "media/alain_skeleton.ozz",
+ false)
+
+// Animation archive can be specified as an option.
+OZZ_OPTIONS_DECLARE_STRING(
+ animation,
+ "Path to the animation (ozz archive format).",
+ "media/alain_walk.ozz",
+ false)
+
+class AttachSampleApplication : public ozz::sample::Application {
+ public:
+ AttachSampleApplication()
+ : cache_(NULL),
+ attachment_(0),
+ offset_(-.02f, .03f, .05f) {
+ }
+
+ protected:
+ // Updates current animation time.
+ virtual bool OnUpdate(float _dt) {
+ // Updates current animation time.
+ controller_.Update(animation_, _dt);
+
+ // Samples optimized animation at t = animation_time_.
+ ozz::animation::SamplingJob sampling_job;
+ sampling_job.animation = &animation_;
+ sampling_job.cache = cache_;
+ sampling_job.time = controller_.time();
+ sampling_job.output = locals_;
+ if (!sampling_job.Run()) {
+ return false;
+ }
+
+ // Converts from local space to model space matrices.
+ ozz::animation::LocalToModelJob ltm_job;
+ ltm_job.skeleton = &skeleton_;
+ ltm_job.input = locals_;
+ ltm_job.output = models_;
+ if (!ltm_job.Run()) {
+ return false;
+ }
+
+ return true;
+ }
+
+ // Samples animation, transforms to model space and renders.
+ virtual bool OnDisplay(ozz::sample::Renderer* _renderer) {
+ if (!_renderer->DrawPosture(skeleton_,
+ models_,
+ ozz::math::Float4x4::identity())) {
+ return false;
+ }
+
+ // Prepares attached object transformation.
+ // Gets model space transformation of the joint.
+ const ozz::math::Float4x4& joint = models_[attachment_];
+
+ // Builds offset transformation matrix.
+ const ozz::math::SimdFloat4 translation =
+ ozz::math::simd_float4::Load3PtrU(&offset_.x);
+
+ // Concatenates joint and offset transformations.
+ const ozz::math::Float4x4 transform =
+ joint * ozz::math::Float4x4::Translation(translation);
+
+ // Prepare rendering.
+ const float thickness = .01f;
+ const float length = .5f;
+ const ozz::math::Box box(ozz::math::Float3(-thickness, -thickness, -length),
+ ozz::math::Float3(thickness, thickness, 0.f));
+ const ozz::sample::Renderer::Color colors[2] = {
+ {0xff, 0, 0, 0xff}, {0, 0xff, 0, 0xff}};
+
+ return _renderer->DrawBoxIm(box, transform, colors);
+ }
+
+ virtual bool OnInitialize() {
+ ozz::memory::Allocator* allocator = ozz::memory::default_allocator();
+
+ // Reading skeleton.
+ if (!ozz::sample::LoadSkeleton(OPTIONS_skeleton, &skeleton_)) {
+ return false;
+ }
+
+ // Reading animation.
+ if (!ozz::sample::LoadAnimation(OPTIONS_animation, &animation_)) {
+ return false;
+ }
+
+ // Allocates runtime buffers.
+ const int num_joints = skeleton_.num_joints();
+ const int num_soa_joints = skeleton_.num_soa_joints();
+ locals_ = allocator->AllocateRange(num_soa_joints);
+ models_ = allocator->AllocateRange(num_joints);
+
+ // Allocates a cache that matches animation requirements.
+ cache_ = allocator->New(num_joints);
+
+ // Finds the joint where the object should be attached.
+ for (int i = 0; i < num_joints; i++) {
+ if (std::strstr(skeleton_.joint_names()[i], "LeftHandMiddle")) {
+ attachment_ = i;
+ break;
+ }
+ }
+
+ return true;
+ }
+
+ virtual void OnDestroy() {
+ ozz::memory::Allocator* allocator = ozz::memory::default_allocator();
+ allocator->Deallocate(locals_);
+ allocator->Deallocate(models_);
+ allocator->Delete(cache_);
+ }
+
+ virtual bool OnGui(ozz::sample::ImGui* _im_gui) {
+ // Exposes animation runtime playback controls.
+ {
+ static bool open = true;
+ ozz::sample::ImGui::OpenClose oc(_im_gui, "Animation control", &open);
+ if (open) {
+ controller_.OnGui(animation_, _im_gui);
+ }
+ }
+
+ // Exposes selection of the attachment joint.
+ {
+ static bool open = true;
+ ozz::sample::ImGui::OpenClose oc(_im_gui, "Attachment joint", &open);
+ if (open && skeleton_.num_joints() != 0) {
+ _im_gui->DoLabel("Select joint:");
+ char label[64];
+ std::sprintf(label, "%s (%d)",
+ skeleton_.joint_names()[attachment_],
+ attachment_);
+ _im_gui->DoSlider(label,
+ 0, skeleton_.num_joints() - 1,
+ &attachment_);
+
+ _im_gui->DoLabel("Attachment offset:");
+ sprintf(label, "x: %02f", offset_.x);
+ _im_gui->DoSlider(label, -1.f, 1.f, &offset_.x);
+ sprintf(label, "y: %02f", offset_.y);
+ _im_gui->DoSlider(label, -1.f, 1.f, &offset_.y);
+ sprintf(label, "z: %02f", offset_.z);
+ _im_gui->DoSlider(label, -1.f, 1.f, &offset_.z);
+ }
+ }
+
+ return true;
+ }
+
+ virtual void GetSceneBounds(ozz::math::Box* _bound) const {
+ ozz::sample::ComputePostureBounds(models_, _bound);
+ }
+
+ private:
+
+ // Playback animation controller. This is a utility class that helps with
+ // controlling animation playback time.
+ ozz::sample::PlaybackController controller_;
+
+ // Runtime skeleton.
+ ozz::animation::Skeleton skeleton_;
+
+ // Runtime animation.
+ ozz::animation::Animation animation_;
+
+ // Sampling cache.
+ ozz::animation::SamplingCache* cache_;
+
+ // Buffer of local transforms as sampled from animation_.
+ ozz::Range locals_;
+
+ // Buffer of model space matrices.
+ ozz::Range models_;
+
+ // Joint where the object is attached.
+ int attachment_;
+
+ // Offset, translation of the attached object from the joint.
+ ozz::math::Float3 offset_;
+};
+
+int main(int _argc, const char** _argv) {
+ const char* title =
+ "Ozz-animation sample: Attachment to animated skeleton joints";
+ return AttachSampleApplication().Run(_argc, _argv, "1.0", title);
+}
diff --git a/pool/shard009/C++/0109986_QXmppInvokable.cpp b/pool/shard009/C++/0109986_QXmppInvokable.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e407aa4f3ff41826c06dd3f6e54d030ad91e84e8
--- /dev/null
+++ b/pool/shard009/C++/0109986_QXmppInvokable.cpp
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2008-2021 The QXmpp developers
+ *
+ * Authors:
+ * Ian Reinhart Geiser
+ *
+ * Source:
+ * https://github.com/qxmpp-project/qxmpp
+ *
+ * This file is a part of QXmpp library.
+ *
+ * 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 of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ */
+
+#include "QXmppInvokable.h"
+
+#include
+#include
+#include
+#include
+
+/// Constructs a QXmppInvokable with the specified \a parent.
+///
+/// \param parent
+
+QXmppInvokable::QXmppInvokable(QObject *parent)
+ : QObject(parent)
+{
+}
+
+/// Destroys a QXmppInvokable.
+
+QXmppInvokable::~QXmppInvokable()
+{
+}
+
+QVariant QXmppInvokable::dispatch(const QByteArray &method, const QList &args)
+{
+ buildMethodHash();
+
+ if (!m_methodHash.contains(method))
+ return QVariant();
+
+ int idx = m_methodHash[method];
+ if (paramTypes(args) != metaObject()->method(idx).parameterTypes())
+ return QVariant();
+
+ const char *typeName = metaObject()->method(idx).typeName();
+ int resultType = QMetaType::type(typeName);
+
+ void *result = QMetaType::create(resultType, nullptr);
+
+ QGenericReturnArgument ret(typeName, result);
+ QList genericArgs;
+ QList::ConstIterator iter = args.begin();
+ while (iter != args.end()) {
+ const void *data = iter->data();
+ const char *name = iter->typeName();
+ genericArgs << QGenericArgument(name, data);
+ ++iter;
+ }
+
+ if (QMetaObject::invokeMethod(this, method.constData(), ret,
+ genericArgs.value(0, QGenericArgument()),
+ genericArgs.value(1, QGenericArgument()),
+ genericArgs.value(2, QGenericArgument()),
+ genericArgs.value(3, QGenericArgument()),
+ genericArgs.value(4, QGenericArgument()),
+ genericArgs.value(5, QGenericArgument()),
+ genericArgs.value(6, QGenericArgument()),
+ genericArgs.value(7, QGenericArgument()),
+ genericArgs.value(8, QGenericArgument()),
+ genericArgs.value(9, QGenericArgument()))) {
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ QVariant returnValue(QMetaType(resultType), result);
+#else
+ QVariant returnValue(resultType, result);
+#endif
+ QMetaType::destroy(resultType, result);
+ return returnValue;
+ } else {
+ qDebug("No such method '%s'", method.constData());
+ return QVariant();
+ }
+}
+
+QList QXmppInvokable::paramTypes(const QList ¶ms)
+{
+ QList types;
+ for (const auto &variant : std::as_const(params))
+ types << variant.typeName();
+ return types;
+}
+
+void QXmppInvokable::buildMethodHash()
+{
+ QWriteLocker locker(&m_lock);
+ if (m_methodHash.size() > 0)
+ return;
+
+ int methodCount = metaObject()->methodCount();
+ for (int idx = 0; idx < methodCount; ++idx) {
+ QByteArray signature = metaObject()->method(idx).methodSignature();
+ m_methodHash[signature.left(signature.indexOf('('))] = idx;
+ // qDebug() << metaObject()->method(idx).parameterTypes();
+ }
+}
+
+QStringList QXmppInvokable::interfaces() const
+{
+ QStringList results;
+ int methodCount = metaObject()->methodCount();
+ for (int idx = 0; idx < methodCount; ++idx) {
+ if (metaObject()->method(idx).methodType() == QMetaMethod::Slot) {
+ QByteArray signature = metaObject()->method(idx).methodSignature();
+ results << signature.left(signature.indexOf('('));
+ }
+ }
+ return results;
+}
diff --git a/pool/shard009/C++/0109988_ckeyboardeventstranslator.cpp b/pool/shard009/C++/0109988_ckeyboardeventstranslator.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..97ab98449d8a3cc5656d6ac2dedf4f4bd3fad1a1
--- /dev/null
+++ b/pool/shard009/C++/0109988_ckeyboardeventstranslator.cpp
@@ -0,0 +1,189 @@
+/**************************************************************************
+* Copyright (C) 2008 by Paf *
+* *
+* This program 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. *
+* *
+* 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 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., *
+* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+***************************************************************************/
+
+
+#include
+#include
+
+#include "../include/ckeyboardeventstranslator.h"
+#include "../include/ctranslationevents.h"
+#include "../../dynamicobject/include/dynamicobjectmanager.h"
+#include "../../dynamicobject/include/float.h"
+#include "../../core/include/cmessagemodule.h"
+#include "../../log/include/clogmodule.h"
+#include "../include/cinputmouseevents.h"
+#include
+#include "../../time/include/ctimemodule.h"
+
+#include "../../config.h"
+
+using namespace boost;
+using namespace Gnoll::Core;
+using namespace Gnoll::DynamicObject;
+using namespace Gnoll::Time;
+
+
+namespace Gnoll
+{
+ namespace Input
+ {
+
+ CKeyboardEventsTranslator::CKeyboardEventsTranslator(): keyUp("KEYBOARD_KEYUP"), keyDown("KEYBOARD_KEYDOWN"), m_lastTimeTriggerCalled(0)
+ {
+
+ DynamicObjectManager *pom = DynamicObjectManager::getInstancePtr();
+
+
+ /**
+ * Loading translation map : Keycode -> Action
+ */
+ this->keyboardEventTranslationMap = pom->load("keyboardEventTranslationMap");
+
+
+ /**
+ * Keyboard config
+ */
+ this->keyboardConfig = pom->load("keyboardConfig");
+
+ }
+
+
+ CKeyboardEventsTranslator::~CKeyboardEventsTranslator()
+ {
+ }
+
+
+ void CKeyboardEventsTranslator::handle ( shared_ptr message )
+ {
+ /**
+ * Get the key code
+ */
+ OIS::KeyCode keyCode = message->getData();
+
+
+ /**
+ * Get the value and convert it to a string
+ */
+ string keyCodeValue = lexical_cast (keyCode);
+
+
+ Gnoll::Log::CLogModule::getInstancePtr()->logMessage( "Looking for KeyCode [" + keyCodeValue + "]");
+
+ /**
+ * If an action is associated to this key code, an action message is sent
+ */
+ if ( keyboardEventTranslationMap->hasAttribute(keyCodeValue) )
+ {
+ CTimeModule* timeModule = CTimeModule::getInstancePtr();
+
+ Messages::MessageType messageType = message->getType();
+
+ if (messageType == keyDown)
+ {
+ m_keyPressed[keyCodeValue] = timeModule->getMsecs();
+
+ if (m_durationKeyPressed.find(keyCodeValue) == m_durationKeyPressed.end())
+ {
+ m_durationKeyPressed[keyCodeValue] = 0;
+ }
+ }
+ else
+ {
+ m_durationKeyPressed[keyCodeValue] += timeModule->getMsecs() - m_keyPressed[keyCodeValue];
+ m_keyPressed[keyCodeValue] = 0;
+ }
+
+ }
+
+ }
+
+
+ void CKeyboardEventsTranslator::trigger ( shared_ptr _msg )
+ {
+
+ Messages::MessageType actionEventType(ACTION_EVENT_TYPE);
+ CTimeModule* timeModule = CTimeModule::getInstancePtr();
+
+ shared_ptr defaultKeyboardSensibility = shared_ptr (new Float(1.0f));
+ shared_ptr< Gnoll::DynamicObject::Float > keyboardSensibility = keyboardConfig->getAttributeOrDefault("sensibility", defaultKeyboardSensibility);
+
+ unsigned long int now = timeModule->getMsecs();
+ unsigned long int period = now - m_lastTimeTriggerCalled;
+
+
+ for( map::iterator it = m_durationKeyPressed.begin(); it != m_durationKeyPressed.end(); it++)
+ {
+ unsigned long int timePressed = it->second;
+
+ if (m_keyPressed[it->first] != 0)
+ {
+ timePressed += now - m_keyPressed[it->first];
+
+ m_keyPressed[it->first] = now;
+ }
+
+
+ if (timePressed > 0)
+ {
+
+ float intensity = (float) timePressed / (float) period * (*keyboardSensibility);
+
+ shared_ptr actionList = keyboardEventTranslationMap->getAttribute( it->first );
+ typedef list< shared_ptr >::iterator ListIterator;
+
+ /**
+ * Send all action messages in the list
+ */
+ for (ListIterator itAttrs = actionList->begin(); itAttrs != actionList->end(); itAttrs++)
+ {
+ if (shared_ptr actionName = dynamic_pointer_cast(*itAttrs))
+ {
+ ActionEvent actionEvent(*actionName, intensity);
+
+ shared_ptr data (new boost::any(actionEvent) ) ;
+ shared_ptr actionMessage (new CMessage( actionEventType, data ));
+
+ std::ostringstream tmpString;
+
+ try
+ {
+ CMessageModule::getInstancePtr()->getMessageManager()->queueMessage(actionMessage);
+ tmpString << "Message ajoute ["<< *actionName << "]" << endl;
+ }
+ catch(...)
+ {
+ tmpString << "Message NON ajoute ["<< *actionName << "]" << " of intensity ";
+ tmpString << intensity << " => " << timePressed << " / " << period << endl;
+ }
+
+ Gnoll::Log::CLogModule::getInstancePtr()->logMessage( tmpString.str() );
+
+ it->second = 0;
+ }
+ }
+ }
+ }
+
+ m_lastTimeTriggerCalled = now;
+ }
+ };
+};
+
+
+
diff --git a/pool/shard009/C++/0109996_CCTiledLayerTestCommon.cpp b/pool/shard009/C++/0109996_CCTiledLayerTestCommon.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ec2105327900e8395c150853c730745ff92803a6
--- /dev/null
+++ b/pool/shard009/C++/0109996_CCTiledLayerTestCommon.cpp
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2012 Google 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:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. 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.
+ */
+
+#include "config.h"
+
+#include "CCTiledLayerTestCommon.h"
+
+using namespace WebCore;
+
+namespace WebKitTests {
+
+FakeLayerTextureUpdater::Texture::Texture(FakeLayerTextureUpdater* layer, PassOwnPtr texture)
+ : LayerTextureUpdater::Texture(texture)
+ , m_layer(layer)
+{
+}
+
+FakeLayerTextureUpdater::Texture::~Texture()
+{
+}
+
+void FakeLayerTextureUpdater::Texture::updateRect(CCResourceProvider* resourceProvider, const IntRect&, const IntRect&)
+{
+ texture()->acquireBackingTexture(resourceProvider);
+ m_layer->updateRect();
+}
+
+void FakeLayerTextureUpdater::Texture::prepareRect(const IntRect&, WebCore::CCRenderingStats&)
+{
+ m_layer->prepareRect();
+}
+
+FakeLayerTextureUpdater::FakeLayerTextureUpdater()
+ : m_prepareCount(0)
+ , m_updateCount(0)
+ , m_prepareRectCount(0)
+{
+}
+
+FakeLayerTextureUpdater::~FakeLayerTextureUpdater()
+{
+}
+
+void FakeLayerTextureUpdater::prepareToUpdate(const IntRect& contentRect, const IntSize&, float, float, IntRect& resultingOpaqueRect, CCRenderingStats&)
+{
+ m_prepareCount++;
+ m_lastUpdateRect = contentRect;
+ if (!m_rectToInvalidate.isEmpty()) {
+ m_layer->invalidateContentRect(m_rectToInvalidate);
+ m_rectToInvalidate = IntRect();
+ m_layer = 0;
+ }
+ resultingOpaqueRect = m_opaquePaintRect;
+}
+
+void FakeLayerTextureUpdater::setRectToInvalidate(const IntRect& rect, FakeTiledLayerChromium* layer)
+{
+ m_rectToInvalidate = rect;
+ m_layer = layer;
+}
+
+PassOwnPtr FakeLayerTextureUpdater::createTexture(CCPrioritizedTextureManager* manager)
+{
+ return adoptPtr(new Texture(this, CCPrioritizedTexture::create(manager)));
+}
+
+FakeCCTiledLayerImpl::FakeCCTiledLayerImpl(int id)
+ : CCTiledLayerImpl(id)
+{
+}
+
+FakeCCTiledLayerImpl::~FakeCCTiledLayerImpl()
+{
+}
+
+FakeTiledLayerChromium::FakeTiledLayerChromium(CCPrioritizedTextureManager* textureManager)
+ : TiledLayerChromium()
+ , m_fakeTextureUpdater(adoptRef(new FakeLayerTextureUpdater))
+ , m_textureManager(textureManager)
+{
+ setTileSize(tileSize());
+ setTextureFormat(GraphicsContext3D::RGBA);
+ setBorderTexelOption(CCLayerTilingData::NoBorderTexels);
+ setIsDrawable(true); // So that we don't get false positives if any of these tests expect to return false from drawsContent() for other reasons.
+}
+
+FakeTiledLayerChromium::~FakeTiledLayerChromium()
+{
+}
+
+void FakeTiledLayerChromium::setNeedsDisplayRect(const FloatRect& rect)
+{
+ m_lastNeedsDisplayRect = rect;
+ TiledLayerChromium::setNeedsDisplayRect(rect);
+}
+
+void FakeTiledLayerChromium::update(CCTextureUpdater& updater, const CCOcclusionTracker* occlusion, CCRenderingStats& stats)
+{
+ updateContentRect(updater, visibleContentRect(), occlusion, stats);
+}
+
+void FakeTiledLayerChromium::setTexturePriorities(const CCPriorityCalculator& calculator)
+{
+ // Ensure there is always a target render surface available. If none has been
+ // set (the layer is an orphan for the test), then just set a surface on itself.
+ bool missingTargetRenderSurface = !renderTarget();
+
+ if (missingTargetRenderSurface)
+ createRenderSurface();
+
+ TiledLayerChromium::setTexturePriorities(calculator);
+
+ if (missingTargetRenderSurface) {
+ clearRenderSurface();
+ setRenderTarget(0);
+ }
+}
+
+FakeTiledLayerWithScaledBounds::FakeTiledLayerWithScaledBounds(CCPrioritizedTextureManager* textureManager)
+ : FakeTiledLayerChromium(textureManager)
+{
+}
+
+} // namespace
diff --git a/pool/shard009/C++/0110000_Blob.cpp b/pool/shard009/C++/0110000_Blob.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..2a9f922731a6273b06ab333ea406e7ea73c8c222
--- /dev/null
+++ b/pool/shard009/C++/0110000_Blob.cpp
@@ -0,0 +1,208 @@
+/*
+Copyright (c) 2012-2015, Coherent Labs AD
+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 Coherent UI nor the names of its
+ contributors 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 HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+#include "precompiled.h"
+
+#include
+
+namespace Coherent
+{
+namespace Blob
+{
+ const Value* GetNextValue(const Value* value)
+ {
+ return reinterpret_cast(reinterpret_cast(value) + value->GetSize());
+ }
+
+ template
+ T& Value::As()
+ {
+ return *reinterpret_cast(m_Storage);
+ }
+
+ template Null& Value::As();
+ template Boolean& Value::As();
+ template Integer& Value::As();
+ template UInteger& Value::As();
+ template Number& Value::As();
+ template String& Value::As();
+ template Array& Value::As();
+ template Object& Value::As();
+ template Integer64& Value::As();
+ template WString& Value::As();
+ template Byte& Value::As();
+ template UByte& Value::As();
+
+ template
+ const T& Value::As() const
+ {
+ return *reinterpret_cast(m_Storage);
+ }
+
+ template const Null& Value::As() const;
+ template const Boolean& Value::As() const;
+ template const Integer& Value::As() const;
+ template const UInteger& Value::As() const;
+ template const Number& Value::As() const;
+ template const String& Value::As() const;
+ template const Array& Value::As() const;
+ template const Object& Value::As() const;
+ template const Integer64& Value::As() const;
+ template const WString& Value::As() const;
+ template const Byte& Value::As() const;
+ template const UByte& Value::As() const;
+
+ struct SizeGetter
+ {
+ typedef size_t ResultType;
+
+ template
+ ResultType Invoke(T& value) const
+ {
+ return value.GetSizeInBytes();
+ }
+ };
+
+ size_t Value::GetSize() const
+ {
+ return sizeof(AlignedType) + Invoke(SizeGetter());
+ }
+
+ Array::ConstIterator::ConstIterator(const Value* value) : m_Value(value)
+ {
+
+ }
+
+ Array::ConstIterator::~ConstIterator()
+ {
+
+ }
+
+ const Value& Array::ConstIterator::operator*() const
+ {
+ return *m_Value;
+ }
+
+ const Value* Array::ConstIterator::operator->() const
+ {
+ return m_Value;
+ }
+
+ Array::ConstIterator& Array::ConstIterator::operator++()
+ {
+ m_Value = GetNextValue(m_Value);
+ return *this;
+ }
+
+ bool Array::ConstIterator::operator==(const ConstIterator& rhs) const
+ {
+ return m_Value == rhs.m_Value;
+ }
+
+ bool Array::ConstIterator::operator!=(const ConstIterator& rhs) const
+ {
+ return m_Value != rhs.m_Value;
+ }
+
+ Array::ConstIterator Array::Begin() const
+ {
+ return ConstIterator(reinterpret_cast(m_Storage));
+ }
+
+ Array::ConstIterator Array::End() const
+ {
+ return ConstIterator(reinterpret_cast(m_Storage + m_Size - 2 * sizeof(AlignedType)));
+ }
+
+ const Value* Object::EndOfStorage() const
+ {
+ return reinterpret_cast(m_Storage + m_Size - 2 * sizeof(AlignedType));
+ }
+
+ Object::ConstIterator Object::Begin() const
+ {
+ return ConstIterator(reinterpret_cast(m_Storage), EndOfStorage());
+ }
+
+ Object::ConstIterator Object::End() const
+ {
+ const Value* end = EndOfStorage();
+ return ConstIterator(end, end);
+ }
+
+
+ Object::ConstIterator::ConstIterator(const Value* begin, const Value* end)
+ : m_Value(begin, nullptr)
+ , m_End(end)
+ {
+ if (m_Value.first != m_End)
+ {
+ m_Value.second = GetNextValue(m_Value.first);
+ }
+ }
+
+ Object::ConstIterator::~ConstIterator()
+ {
+ }
+
+
+ Object::ConstIterator& Object::ConstIterator::operator++()
+ {
+ m_Value.first = GetNextValue(m_Value.second);
+ if (m_Value.first != m_End)
+ {
+ m_Value.second = GetNextValue(m_Value.first);
+ }
+ return *this;
+ }
+
+ const Object::ConstIterator::value_type& Object::ConstIterator::operator*() const
+ {
+ return m_Value;
+ }
+
+ const Object::ConstIterator::value_type* Object::ConstIterator::operator->() const
+ {
+ return &m_Value;
+ }
+
+ bool Object::ConstIterator::operator==(const Object::ConstIterator& rhs) const
+ {
+ return m_Value.first == rhs.m_Value.first && m_End == rhs.m_End;
+ }
+
+ bool Object::ConstIterator::operator!=(const Object::ConstIterator& rhs) const
+ {
+ return m_Value.first != rhs.m_Value.first || m_End != rhs.m_End;
+ }
+
+
+
+}
+}
diff --git a/pool/shard009/C++/0110004_cv_api.cc b/pool/shard009/C++/0110004_cv_api.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b0915fd405794d168862294550fb00a28fd60a20
--- /dev/null
+++ b/pool/shard009/C++/0110004_cv_api.cc
@@ -0,0 +1,172 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+/*!
+ * Copyright (c) 2016 by Contributors
+ * \file cv_api.h
+ * \brief C API for opencv
+ * \author Junyuan Xie
+ */
+#include
+#include
+#include
+#include
+#include "cv_api.h"
+#include "../../src/c_api/c_api_common.h"
+
+
+using namespace mxnet;
+// http://www.64lines.com/jpeg-width-height
+// Gets the JPEG size from the array of data passed to the function, file reference: http://www.obrador.com/essentialjpeg/headerinfo.htm
+bool get_jpeg_size(const unsigned char* data, mx_uint data_size, mx_uint *width, mx_uint *height) {
+ // Check for valid JPEG image
+ mx_uint i = 0; // Keeps track of the position within the file
+ if (data[i] == 0xFF && data[i+1] == 0xD8 && data[i+2] == 0xFF && data[i+3] == 0xE0) {
+ i += 4;
+ // Check for valid JPEG header (null terminated JFIF)
+ if (data[i+2] == 'J' && data[i+3] == 'F' && data[i+4] == 'I'
+ && data[i+5] == 'F' && data[i+6] == 0x00) {
+ // Retrieve the block length of the first block since
+ // the first block will not contain the size of file
+ uint16_t block_length = data[i] * 256 + data[i+1];
+ while (i < data_size) {
+ i+=block_length; // Increase the file index to get to the next block
+ if (i >= data_size) return false; // Check to protect against segmentation faults
+ if (data[i] != 0xFF) return false; // Check that we are truly at the start of another block
+ if (data[i+1] == 0xC0) {
+ // 0xFFC0 is the "Start of frame" marker which contains the file size
+ // The structure of the 0xFFC0 block is quite simple
+ // [0xFFC0][ushort length][uchar precision][ushort x][ushort y]
+ *height = data[i+5]*256 + data[i+6];
+ *width = data[i+7]*256 + data[i+8];
+ return true;
+ } else {
+ i+=2; // Skip the block marker
+ block_length = data[i] * 256 + data[i+1]; // Go to the next block
+ }
+ }
+ return false; // If this point is reached then no size was found
+ } else {
+ return false; // Not a valid JFIF string
+ }
+ } else {
+ return false; // Not a valid SOI header
+ }
+}
+
+bool get_png_size(const unsigned char* data, mx_uint data_size, mx_uint *width, mx_uint *height) {
+ if (data[0] == 0x89 && data[1] == 0x50 && data[2] ==0x4E && data[3] == 0x47) {
+ unsigned char const* p = data + 16;
+ *width = ((p[0]*256 + p[1])*256 + p[2])*256 + p[3];
+ p += 4;
+ *height = ((p[0]*256 + p[1])*256 + p[2])*256 + p[3];
+ return true;
+ } else {
+ return false;
+ }
+}
+
+MXNET_DLL int MXCVImdecode(const unsigned char *img, const mx_uint len,
+ const int flag, NDArrayHandle *out) {
+ API_BEGIN();
+ mx_uint dims[3];
+ CHECK_GE(flag, 0) << "flag must be 0 (grayscale) or 1 (colored).";
+ dims[2] = flag == 0 ? 1 : 3;
+ if (get_jpeg_size(img, len, dims+1, dims)) {
+ } else if (get_png_size(img, len, dims+1, dims)) {
+ } else {
+ LOG(FATAL) << "Only supports png and jpg.";
+ }
+ NDArray ndout(mxnet::TShape(dims, dims+3), Context::CPU(), true, mshadow::kUint8);
+ unsigned char *img_cpy = new unsigned char[len];
+ memcpy(img_cpy, img, sizeof(unsigned char)*len);
+ Engine::Get()->PushSync([=](RunContext ctx){
+ ndout.CheckAndAlloc();
+ cv::Mat buf(1, len, CV_8U, img_cpy);
+ cv::Mat dst(dims[0], dims[1], flag == 0 ? CV_8U : CV_8UC3, ndout.data().dptr_);
+#if (CV_MAJOR_VERSION > 3 || (CV_MAJOR_VERSION == 3 && CV_MINOR_VERSION >= 3))
+ cv::imdecode(buf, flag | cv::IMREAD_IGNORE_ORIENTATION, &dst);
+#else
+ cv::imdecode(buf, flag, &dst);
+#endif
+ CHECK(!dst.empty());
+ delete[] img_cpy;
+ }, ndout.ctx(), {}, {ndout.var()});
+ NDArray *tmp = new NDArray();
+ *tmp = ndout;
+ *out = tmp;
+ API_END();
+}
+
+
+MXNET_DLL int MXCVResize(NDArrayHandle src, const mx_uint w, const mx_uint h,
+ const int interpolation, NDArrayHandle *out) {
+ API_BEGIN();
+ NDArray ndsrc = *static_cast(src);
+ CHECK_EQ(ndsrc.shape().ndim(), 3);
+ CHECK_EQ(ndsrc.ctx(), Context::CPU());
+ CHECK_EQ(ndsrc.dtype(), mshadow::kUint8);
+
+ mx_uint dims[3] = {h, w, ndsrc.shape()[2]};
+ NDArray ndout(mxnet::TShape(dims, dims+3), Context::CPU(), true, mshadow::kUint8);
+
+ Engine::Get()->PushSync([=](RunContext ctx){
+ ndout.CheckAndAlloc();
+ cv::Mat buf(ndsrc.shape()[0], ndsrc.shape()[1],
+ dims[2] == 3 ? CV_8UC3 : CV_8U, ndsrc.data().dptr_);
+ cv::Mat dst(h, w, dims[2] == 3 ? CV_8UC3 : CV_8U, ndout.data().dptr_);
+ cv::resize(buf, dst, cv::Size(w, h), 0, 0, interpolation);
+ CHECK(!dst.empty());
+ }, ndout.ctx(), {ndsrc.var()}, {ndout.var()});
+ NDArray *tmp = new NDArray();
+ *tmp = ndout;
+ *out = tmp;
+ API_END();
+}
+
+MXNET_DLL int MXCVcopyMakeBorder(NDArrayHandle src,
+ const int top,
+ const int bot,
+ const int left,
+ const int right,
+ const int type,
+ const double value,
+ NDArrayHandle *out) {
+ API_BEGIN();
+ NDArray ndsrc = *static_cast(src);
+ CHECK_EQ(ndsrc.shape().ndim(), 3);
+ CHECK_EQ(ndsrc.ctx(), Context::CPU());
+ CHECK_EQ(ndsrc.dtype(), mshadow::kUint8);
+
+ int h = ndsrc.shape()[0], w = ndsrc.shape()[1], c = ndsrc.shape()[2];
+ mx_uint dims[3] = {top+h+bot, left+w+right, c};
+ NDArray ndout(mxnet::TShape(dims, dims+3), Context::CPU(), true, mshadow::kUint8);
+
+ Engine::Get()->PushSync([=](RunContext ctx){
+ ndout.CheckAndAlloc();
+ cv::Mat buf(h, w, c == 3 ? CV_8UC3 : CV_8U, ndsrc.data().dptr_);
+ cv::Mat dst(top+h+bot, left+w+right, c == 3 ? CV_8UC3 : CV_8U, ndout.data().dptr_);
+ cv::copyMakeBorder(buf, dst, top, bot, left, right, type, cv::Scalar(value));
+ CHECK(!dst.empty());
+ }, ndout.ctx(), {ndsrc.var()}, {ndout.var()});
+ NDArray *tmp = new NDArray();
+ *tmp = ndout;
+ *out = tmp;
+ API_END();
+}
diff --git a/pool/shard009/C++/0110005_gesture_point.cc b/pool/shard009/C++/0110005_gesture_point.cc
new file mode 100644
index 0000000000000000000000000000000000000000..31d9e918e2c41c9ac688ce040240e4d57cec05f7
--- /dev/null
+++ b/pool/shard009/C++/0110005_gesture_point.cc
@@ -0,0 +1,199 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/base/gestures/gesture_point.h"
+
+#include
+
+#include "base/basictypes.h"
+#include "ui/base/events/event.h"
+#include "ui/base/events/event_constants.h"
+#include "ui/base/gestures/gesture_configuration.h"
+#include "ui/base/gestures/gesture_types.h"
+#include "ui/base/gestures/gesture_util.h"
+
+namespace ui {
+
+GesturePoint::GesturePoint()
+ : first_touch_time_(0.0),
+ last_touch_time_(0.0),
+ last_tap_time_(0.0),
+ velocity_calculator_(
+ GestureConfiguration::points_buffered_for_velocity()),
+ point_id_(-1),
+ touch_id_(-1) {
+}
+
+GesturePoint::~GesturePoint() {}
+
+void GesturePoint::Reset() {
+ first_touch_time_ = last_touch_time_ = 0.0;
+ velocity_calculator_.ClearHistory();
+ point_id_ = -1;
+ clear_enclosing_rectangle();
+}
+
+void GesturePoint::ResetVelocity() {
+ velocity_calculator_.ClearHistory();
+}
+
+void GesturePoint::UpdateValues(const TouchEvent& event) {
+ const int64 event_timestamp_microseconds =
+ event.time_stamp().InMicroseconds();
+ if (event.type() == ui::ET_TOUCH_MOVED) {
+ velocity_calculator_.PointSeen(event.location().x(),
+ event.location().y(),
+ event_timestamp_microseconds);
+ }
+
+ last_touch_time_ = event.time_stamp().InSecondsF();
+ last_touch_position_ = event.location();
+
+ if (event.type() == ui::ET_TOUCH_PRESSED) {
+ first_touch_time_ = last_touch_time_;
+ first_touch_position_ = event.location();
+ velocity_calculator_.ClearHistory();
+ velocity_calculator_.PointSeen(event.location().x(),
+ event.location().y(),
+ event_timestamp_microseconds);
+ clear_enclosing_rectangle();
+ }
+
+ UpdateEnclosingRectangle(event);
+}
+
+void GesturePoint::UpdateForTap() {
+ // Update the tap-position and time, and reset every other state.
+ last_tap_time_ = last_touch_time_;
+ last_tap_position_ = last_touch_position_;
+}
+
+void GesturePoint::UpdateForScroll() {
+ // Update the first-touch position and time so that the scroll-delta and
+ // scroll-velocity can be computed correctly for the next scroll gesture
+ // event.
+ first_touch_position_ = last_touch_position_;
+ first_touch_time_ = last_touch_time_;
+}
+
+bool GesturePoint::IsInClickWindow(const TouchEvent& event) const {
+ return IsInClickTimeWindow() && IsInsideManhattanSquare(event);
+}
+
+bool GesturePoint::IsInDoubleClickWindow(const TouchEvent& event) const {
+ return IsInSecondClickTimeWindow() &&
+ IsSecondClickInsideManhattanSquare(event);
+}
+
+bool GesturePoint::IsInScrollWindow(const TouchEvent& event) const {
+ return event.type() == ui::ET_TOUCH_MOVED &&
+ !IsInsideManhattanSquare(event);
+}
+
+bool GesturePoint::IsInFlickWindow(const TouchEvent& event) {
+ return IsOverMinFlickSpeed() &&
+ event.type() != ui::ET_TOUCH_CANCELLED;
+}
+
+bool GesturePoint::DidScroll(const TouchEvent& event, int dist) const {
+ return abs(last_touch_position_.x() - first_touch_position_.x()) > dist ||
+ abs(last_touch_position_.y() - first_touch_position_.y()) > dist;
+}
+
+bool GesturePoint::HasEnoughDataToEstablishRail() const {
+ int dx = x_delta();
+ int dy = y_delta();
+
+ int delta_squared = dx * dx + dy * dy;
+ return delta_squared > GestureConfiguration::min_scroll_delta_squared();
+}
+
+bool GesturePoint::IsInHorizontalRailWindow() const {
+ int dx = x_delta();
+ int dy = y_delta();
+ return abs(dx) > GestureConfiguration::rail_start_proportion() * abs(dy);
+}
+
+bool GesturePoint::IsInVerticalRailWindow() const {
+ int dx = x_delta();
+ int dy = y_delta();
+ return abs(dy) > GestureConfiguration::rail_start_proportion() * abs(dx);
+}
+
+bool GesturePoint::BreaksHorizontalRail() {
+ float vx = XVelocity();
+ float vy = YVelocity();
+ return fabs(vy) > GestureConfiguration::rail_break_proportion() * fabs(vx) +
+ GestureConfiguration::min_rail_break_velocity();
+}
+
+bool GesturePoint::BreaksVerticalRail() {
+ float vx = XVelocity();
+ float vy = YVelocity();
+ return fabs(vx) > GestureConfiguration::rail_break_proportion() * fabs(vy) +
+ GestureConfiguration::min_rail_break_velocity();
+}
+
+bool GesturePoint::IsInClickTimeWindow() const {
+ double duration = last_touch_time_ - first_touch_time_;
+ return duration >=
+ GestureConfiguration::min_touch_down_duration_in_seconds_for_click() &&
+ duration <
+ GestureConfiguration::max_touch_down_duration_in_seconds_for_click();
+}
+
+bool GesturePoint::IsInSecondClickTimeWindow() const {
+ double duration = last_touch_time_ - last_tap_time_;
+ return duration < GestureConfiguration::max_seconds_between_double_click();
+}
+
+bool GesturePoint::IsInsideManhattanSquare(const TouchEvent& event) const {
+ return ui::gestures::IsInsideManhattanSquare(event.location(),
+ first_touch_position_);
+}
+
+bool GesturePoint::IsSecondClickInsideManhattanSquare(
+ const TouchEvent& event) const {
+ int manhattan_distance = abs(event.location().x() - last_tap_position_.x()) +
+ abs(event.location().y() - last_tap_position_.y());
+ return manhattan_distance <
+ GestureConfiguration::max_distance_between_taps_for_double_tap();
+}
+
+bool GesturePoint::IsOverMinFlickSpeed() {
+ return velocity_calculator_.VelocitySquared() >
+ GestureConfiguration::min_flick_speed_squared();
+}
+
+void GesturePoint::UpdateEnclosingRectangle(const TouchEvent& event) {
+ int radius;
+
+ // Ignore this TouchEvent if it has a radius larger than the maximum
+ // allowed radius size.
+ if (event.radius_x() > GestureConfiguration::max_radius() ||
+ event.radius_y() > GestureConfiguration::max_radius())
+ return;
+
+ // If the device provides at least one of the radius values, take the larger
+ // of the two and use this as both the x radius and the y radius of the
+ // touch region. Otherwise use the default radius value.
+ // TODO(tdanderson): Implement a more specific check for the exact
+ // information provided by the device (0-2 radii values, force, angle) and
+ // use this to compute a more representative rectangular touch region.
+ if (event.radius_x() || event.radius_y())
+ radius = std::max(event.radius_x(), event.radius_y());
+ else
+ radius = GestureConfiguration::default_radius();
+
+ gfx::Rect rect(event.location().x() - radius,
+ event.location().y() - radius,
+ radius * 2,
+ radius * 2);
+ if (IsInClickWindow(event))
+ enclosing_rect_.Union(rect);
+ else
+ enclosing_rect_ = rect;
+}
+
+} // namespace ui
diff --git a/pool/shard009/C++/0110006_searchMatrix.cc b/pool/shard009/C++/0110006_searchMatrix.cc
new file mode 100644
index 0000000000000000000000000000000000000000..066581574e5206157ed7b7811067a03fb35ba556
--- /dev/null
+++ b/pool/shard009/C++/0110006_searchMatrix.cc
@@ -0,0 +1,96 @@
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+using namespace std;
+
+class Solution {
+public:
+ bool searchMatrix(vector>& matrix, int target) {
+ if (matrix.size() == 0 || matrix[0].size() == 0)
+ return false;
+ int i = 0, j = matrix.size(), mid;
+ while (i < j) {
+ mid = (i+j)/2;
+ if (matrix[mid][0] > target)
+ j = mid;
+ else if (matrix[mid].back() < target)
+ i = mid+1;
+ else
+ return std::binary_search (matrix[mid].begin(), matrix[mid].end(), target);
+ }
+ return false;
+ }
+};
+
+/*
+ * input: vector> int ## true|false
+ */
+
+template
+istream& operator >> (istream& in, vector& vi) {
+ T val;
+ vi.clear();
+ while (!in.eof() && isspace(in.peek())) in.get();
+ if (in.eof()) return in;
+ in.get();
+
+ while (true) {
+ while (isspace(in.peek())) in.get();
+ if (in.peek() == '}') {
+ in.get();
+ return in;
+ }
+ else if (in.peek() == ',') in.get();
+ in >> val;
+ vi.push_back(val);
+ }
+
+ return in;
+}
+
+template
+ostream& operator << (ostream& out, vector& vi) {
+ out << "{";
+ if (vi.size() != 0)
+ out << vi[0];
+ for (int i = 1; i < vi.size(); i++)
+ out << ", " << vi[i];
+ out << "}";
+ return out;
+}
+
+
+int main() {
+ bool err = false;
+ string buf;
+ vector> matrix;
+ int target;
+ bool res, expected;
+ cout.setf(std::ios_base::boolalpha);
+
+ while (true) {
+ cin >> matrix;
+ if (cin.eof()) break;
+ cin >> target >> buf >> buf;
+ if (buf == "true")
+ expected = true;
+ else
+ expected = false;
+ res = Solution().searchMatrix(matrix, target);
+ if (res != expected) {
+ err = true;
+ cout << "input: " << matrix << " " << target << endl
+ << "result: " << res << endl
+ << "expected: " << expected << endl << endl;
+ }
+ }
+
+ if (!err)
+ cout << "All tests passed!\n";
+
+ return 0;
+}
diff --git a/pool/shard009/C++/0110014_basic_string.cpp b/pool/shard009/C++/0110014_basic_string.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..25ec20b502d1d29b01b15fdfca401564f0f68dcc
--- /dev/null
+++ b/pool/shard009/C++/0110014_basic_string.cpp
@@ -0,0 +1,127 @@
+/*
+ Copyright (c) 2014, Randolph Voorhies, Shane Grant
+ 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 cereal nor the
+ names of its contributors 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 RANDOLPH VOORHIES AND SHANE GRANT 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 "common.hpp"
+#include
+
+template
+void test_string_basic()
+{
+ std::random_device rd;
+ std::mt19937 gen(rd());
+
+ for(size_t i=0; i<100; ++i)
+ {
+ std::basic_string o_string = random_basic_string(gen);
+ std::basic_string o_string2 = "";
+
+ std::ostringstream os;
+ {
+ OArchive oar(os);
+ oar(o_string);
+ oar(o_string2);
+ }
+
+ std::basic_string i_string;
+ std::basic_string i_string2;
+
+ std::istringstream is(os.str());
+ {
+ IArchive iar(is);
+
+ iar(i_string);
+ iar(i_string2);
+ }
+
+ BOOST_CHECK_EQUAL(i_string, o_string);
+ BOOST_CHECK_EQUAL(i_string2, o_string2);
+ }
+}
+
+template
+void test_string_all()
+{
+ std::random_device rd;
+ std::mt19937 gen(rd());
+
+ for(size_t i=0; i<100; ++i)
+ {
+ std::basic_string o_string = random_basic_string(gen);
+ std::basic_string o_wstring = random_basic_string(gen);
+ std::basic_string o_u16string = random_basic_string(gen);
+ std::basic_string o_u32string = random_basic_string(gen);
+
+ std::ostringstream os;
+ {
+ OArchive oar(os);
+ oar(o_string);
+ oar(o_wstring);
+ oar(o_u16string);
+ oar(o_u32string);
+ }
+
+ std::basic_string i_string;
+ std::basic_string i_wstring;
+ std::basic_string i_u16string;
+ std::basic_string i_u32string;
+
+ std::istringstream is(os.str());
+ {
+ IArchive iar(is);
+
+ iar(i_string);
+ iar(i_wstring);
+ iar(i_u16string);
+ iar(i_u32string);
+ }
+
+ BOOST_CHECK_EQUAL(i_string, o_string);
+ BOOST_CHECK_EQUAL_COLLECTIONS(i_wstring.begin(), i_wstring.end(), o_wstring.begin(), o_wstring.end());
+ BOOST_CHECK_EQUAL_COLLECTIONS(i_u16string.begin(), i_u16string.end(), o_u16string.begin(), o_u16string.end());
+ BOOST_CHECK_EQUAL_COLLECTIONS(i_u32string.begin(), i_u32string.end(), o_u32string.begin(), o_u32string.end());
+ }
+}
+
+BOOST_AUTO_TEST_CASE( binary_string )
+{
+ test_string_all();
+}
+
+BOOST_AUTO_TEST_CASE( portable_binary_string )
+{
+ test_string_all();
+}
+
+BOOST_AUTO_TEST_CASE( xml_string_basic )
+{
+ test_string_basic();
+}
+
+BOOST_AUTO_TEST_CASE( json_string_basic )
+{
+ test_string_basic();
+}
+
diff --git a/pool/shard009/C++/0110021_BinaryTreePreorderTraversal.cc b/pool/shard009/C++/0110021_BinaryTreePreorderTraversal.cc
new file mode 100644
index 0000000000000000000000000000000000000000..af2749ed64af430b2ae01c8ca68f63bd47067a7d
--- /dev/null
+++ b/pool/shard009/C++/0110021_BinaryTreePreorderTraversal.cc
@@ -0,0 +1,31 @@
+// https://oj.leetcode.com/problems/binary-tree-preorder-traversal/
+namespace BinaryTreePreorderTraversal {
+ class Solution {
+ public:
+ vector preorderTraversal(TreeNode *root) {
+ vector v;
+ if (root == NULL) {
+ return v;
+ }
+
+ stack s;
+ s.push(root);
+ while (!s.empty()) {
+ TreeNode * cur = s.top();
+ v.push_back(cur->val);
+ s.pop();
+ if (cur->right) {
+ s.push(cur->right);
+ }
+
+ if (cur->left) {
+ s.push(cur->left);
+ }
+
+ }
+
+ return v;
+
+ }
+ };
+}
diff --git a/pool/shard009/C++/0110022_BoostUtilities.cpp b/pool/shard009/C++/0110022_BoostUtilities.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4c2cf901da23f1b789b77418cfeeacd8620e17ba
--- /dev/null
+++ b/pool/shard009/C++/0110022_BoostUtilities.cpp
@@ -0,0 +1,170 @@
+#include "BoostUtilities.hpp"
+#include "BoostConstants.hpp"
+
+#include "stdlib.h"
+
+namespace BoostUtilities
+{
+ QueueSender::QueueSender(const char* queueName)
+ {
+ pQueue = new interop_message_queue(boost::interprocess::open_only, queueName);
+ }
+
+ SharedMemReader::SharedMemReader(const char* name)
+ {
+ // The intermediate variables in this function are necessary for some reason.
+ std::string sharedMemName = BoostConstants::buildSharedMemName(name);
+ const char* sharedMemChar = sharedMemName.c_str();
+ pSharedMem = new boost::interprocess::shared_memory_object(boost::interprocess::open_only, sharedMemChar, boost::interprocess::read_only);
+
+ std::string mutexName = BoostConstants::buildMutexName(name);
+ const char* mutexChar = mutexName.c_str();
+ pMutex = new boost::interprocess::named_sharable_mutex(boost::interprocess::open_only, mutexChar);
+ }
+
+ ByteBuffer SharedMemReader::fetchData()
+ {
+ // The lock will be released when this object goes out of scope
+ boost::interprocess::sharable_lock myLock(*pMutex);
+ hasLock = true;
+
+ boost::interprocess::offset_t size;
+ pSharedMem->get_size(size);
+
+ if (size == 0)
+ {
+ // Bail out early because mapped_region will freak out if size is zero.
+ ByteBuffer empty;
+ empty.ptr = new char[1]; // Arbitrary valid pointer to an array. We'll be calling delete[] on this later.
+ empty.size = 0;
+ return empty;
+ }
+
+ boost::interprocess::mapped_region region(*pSharedMem, boost::interprocess::read_only);
+ unsigned char *buffer = new unsigned char[region.get_size()];
+ memcpy(buffer, region.get_address(), region.get_size());
+
+ ByteBuffer buf;
+ buf.ptr = buffer;
+ buf.size = region.get_size();
+
+ hasLock = false;
+
+ return buf;
+ }
+
+ void SharedMemReader::unlockMutex()
+ {
+ if (hasLock)
+ {
+ pMutex->unlock_sharable();
+ hasLock = false;
+ }
+ }
+
+ SharedMemWriter::SharedMemWriter(const char* name, int size)
+ {
+ // The intermediate variables in this function are necessary for some reason.
+
+ pMemName = name;
+
+ std::string sharedMemName = BoostConstants::buildSharedMemName(name);
+ const char* sharedMemChar = sharedMemName.c_str();
+ boost::interprocess::shared_memory_object::remove(sharedMemChar);
+ pSharedMem = new boost::interprocess::shared_memory_object(boost::interprocess::create_only, sharedMemChar, boost::interprocess::read_write);
+ pSharedMem->truncate(size);
+
+ std::string mutexName = BoostConstants::buildMutexName(name);
+ const char* mutexChar = mutexName.c_str();
+ boost::interprocess::named_sharable_mutex::remove(mutexChar);
+ pMutex = new boost::interprocess::named_sharable_mutex(boost::interprocess::create_only, mutexChar);
+ }
+
+ SharedMemWriter::~SharedMemWriter()
+ {
+ std::string mutexName = BoostConstants::buildMutexName(pMemName);
+ const char* mutexChar = mutexName.c_str();
+ boost::interprocess::named_sharable_mutex::remove(mutexChar);
+ boost::interprocess::shared_memory_object::remove(pSharedMem->get_name());
+ }
+
+ void SharedMemWriter::writeData(void* address, int size)
+ {
+ // The lock will be released when this object goes out of scope, i.e. when this function exits.
+ boost::interprocess::scoped_lock myLock(*pMutex);
+
+ if (size > 0)
+ {
+ boost::interprocess::mapped_region region(*pSharedMem, boost::interprocess::read_write);
+ std::memcpy(region.get_address(), address, size);
+ }
+ }
+
+ RLBotCoreStatus QueueSender::sendMessage(void* message, int messageSize)
+ {
+ if (messageSize > pQueue->get_max_msg_size())
+ {
+ return RLBotCoreStatus::MessageLargerThanMax;
+ }
+
+ bool sent = pQueue->try_send(message, messageSize, 0);
+
+ if (!sent)
+ {
+ return RLBotCoreStatus::BufferOverfilled;
+ }
+ return RLBotCoreStatus::Success;
+ }
+
+ SharedByteReader::SharedByteReader(const char* name)
+ {
+ // The intermediate variables in this function are necessary for some reason.
+ std::string sharedMemName = BoostConstants::buildSharedMemName(name);
+ const char* sharedMemChar = sharedMemName.c_str();
+ pSharedMem = new boost::interprocess::shared_memory_object(boost::interprocess::open_only, sharedMemChar, boost::interprocess::read_only);
+ }
+
+ // This is expected to be very fast and cheap to call because it does not take a lock
+ // and just reads a single byte from shared memory. Suitable for being called at
+ // high frequency from multiple processes.
+ char SharedByteReader::fetchByte()
+ {
+ boost::interprocess::offset_t size;
+ pSharedMem->get_size(size);
+
+ if (size == 0)
+ {
+ // Bail out early because mapped_region will freak out if size is zero.
+ return 0;
+ }
+
+ boost::interprocess::mapped_region region(*pSharedMem, boost::interprocess::read_only);
+ return *(char*)(region.get_address());
+ }
+
+ SharedByteWriter::SharedByteWriter(const char* name)
+ {
+ // The intermediate variables in this function are necessary for some reason.
+
+ pMemName = name;
+
+ std::string sharedMemName = BoostConstants::buildSharedMemName(name);
+ const char* sharedMemChar = sharedMemName.c_str();
+ boost::interprocess::shared_memory_object::remove(sharedMemChar);
+ pSharedMem = new boost::interprocess::shared_memory_object(boost::interprocess::create_only, sharedMemChar, boost::interprocess::read_write);
+ pSharedMem->truncate(1);
+ }
+
+ SharedByteWriter::~SharedByteWriter()
+ {
+ boost::interprocess::shared_memory_object::remove(pSharedMem->get_name());
+ }
+
+ void SharedByteWriter::writeByte(char data)
+ {
+ char dataArr[] = { data };
+ boost::interprocess::mapped_region region(*pSharedMem, boost::interprocess::read_write);
+ std::memcpy(region.get_address(), dataArr, 1);
+ }
+
+}
diff --git a/pool/shard009/C++/0110026_h264_poc.cc b/pool/shard009/C++/0110026_h264_poc.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2934f25d3b79e8595717b95b807234fd0750f5f8
--- /dev/null
+++ b/pool/shard009/C++/0110026_h264_poc.cc
@@ -0,0 +1,231 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include
+
+#include
+
+#include "base/logging.h"
+#include "base/macros.h"
+#include "media/filters/h264_parser.h"
+#include "media/video/h264_poc.h"
+
+namespace media {
+
+H264POC::H264POC() {
+ Reset();
+}
+
+H264POC::~H264POC() {
+}
+
+void H264POC::Reset() {
+ // It shouldn't be necessary to reset these values, but doing so will improve
+ // reproducibility for buggy streams.
+ ref_pic_order_cnt_msb_ = 0;
+ ref_pic_order_cnt_lsb_ = 0;
+ prev_frame_num_ = 0;
+ prev_frame_num_offset_ = 0;
+}
+
+// Check if a slice includes memory management control operation 5, which
+// results in some |pic_order_cnt| state being cleared.
+static bool HasMMCO5(const media::H264SliceHeader& slice_hdr) {
+ // Require that the frame actually has memory management control operations.
+ if (slice_hdr.nal_ref_idc == 0 ||
+ slice_hdr.idr_pic_flag ||
+ !slice_hdr.adaptive_ref_pic_marking_mode_flag) {
+ return false;
+ }
+
+ for (size_t i = 0; i < arraysize(slice_hdr.ref_pic_marking); i++) {
+ int32_t op = slice_hdr.ref_pic_marking[i].memory_mgmnt_control_operation;
+ if (op == 5)
+ return true;
+
+ // Stop at the end of the list.
+ if (op == 0)
+ return false;
+ }
+
+ // Should not get here, the list is always zero terminated.
+ return false;
+}
+
+bool H264POC::ComputePicOrderCnt(
+ const H264SPS* sps,
+ const H264SliceHeader& slice_hdr,
+ int32_t *pic_order_cnt) {
+ if (slice_hdr.field_pic_flag) {
+ DLOG(ERROR) << "Interlaced frames are not supported";
+ return false;
+ }
+
+ bool mmco5 = HasMMCO5(slice_hdr);
+ int32_t max_frame_num = 1 << (sps->log2_max_frame_num_minus4 + 4);
+ int32_t max_pic_order_cnt_lsb =
+ 1 << (sps->log2_max_pic_order_cnt_lsb_minus4 + 4);
+
+ // Check for invalid (including duplicate) |frame_num| values. All cases are
+ // treated as gaps, which is to say that nothing is done. (Gaps don't affect
+ // POC computation.)
+ if (!slice_hdr.idr_pic_flag &&
+ slice_hdr.frame_num != (prev_frame_num_ + 1) % max_frame_num) {
+ if (!sps->gaps_in_frame_num_value_allowed_flag)
+ DLOG(WARNING) << "Invalid gap in frame_num";
+ }
+
+ // Based on T-REC-H.264 8.2.1, "Decoding process for picture order
+ // count", available from http://www.itu.int/rec/T-REC-H.264.
+ //
+ // Reorganized slightly from spec pseudocode to handle MMCO5 when storing
+ // state instead of when loading it.
+ switch (sps->pic_order_cnt_type) {
+ case 0: {
+ int32_t prev_pic_order_cnt_msb = ref_pic_order_cnt_msb_;
+ int32_t prev_pic_order_cnt_lsb = ref_pic_order_cnt_lsb_;
+
+ // For an IDR picture, clear the state.
+ if (slice_hdr.idr_pic_flag) {
+ prev_pic_order_cnt_msb = 0;
+ prev_pic_order_cnt_lsb = 0;
+ }
+
+ // 8-3. Derive |pic_order_cnt_msb|, accounting for wrapping which is
+ // detected when |pic_order_cnt_lsb| increases or decreases by at
+ // least half of its maximum.
+ int32_t pic_order_cnt_msb;
+ if ((slice_hdr.pic_order_cnt_lsb < prev_pic_order_cnt_lsb) &&
+ (prev_pic_order_cnt_lsb - slice_hdr.pic_order_cnt_lsb >=
+ max_pic_order_cnt_lsb / 2)) {
+ pic_order_cnt_msb = prev_pic_order_cnt_msb + max_pic_order_cnt_lsb;
+ } else if ((slice_hdr.pic_order_cnt_lsb > prev_pic_order_cnt_lsb) &&
+ (slice_hdr.pic_order_cnt_lsb - prev_pic_order_cnt_lsb >
+ max_pic_order_cnt_lsb / 2)) {
+ pic_order_cnt_msb = prev_pic_order_cnt_msb - max_pic_order_cnt_lsb;
+ } else {
+ pic_order_cnt_msb = prev_pic_order_cnt_msb;
+ }
+
+ // 8-4, 8-5. Derive |top_field_order_count| and |bottom_field_order_cnt|
+ // (assuming no interlacing).
+ int32_t top_foc = pic_order_cnt_msb + slice_hdr.pic_order_cnt_lsb;
+ int32_t bottom_foc = top_foc + slice_hdr.delta_pic_order_cnt_bottom;
+ *pic_order_cnt = std::min(top_foc, bottom_foc);
+
+ // Store state.
+ prev_frame_num_ = slice_hdr.frame_num;
+ if (slice_hdr.nal_ref_idc != 0) {
+ if (mmco5) {
+ ref_pic_order_cnt_msb_ = 0;
+ ref_pic_order_cnt_lsb_ = top_foc;
+ } else {
+ ref_pic_order_cnt_msb_ = pic_order_cnt_msb;
+ ref_pic_order_cnt_lsb_ = slice_hdr.pic_order_cnt_lsb;
+ }
+ }
+
+ break;
+ }
+
+ case 1: {
+ // 8-6. Derive |frame_num_offset|.
+ int32_t frame_num_offset;
+ if (slice_hdr.idr_pic_flag)
+ frame_num_offset = 0;
+ else if (prev_frame_num_ > slice_hdr.frame_num)
+ frame_num_offset = prev_frame_num_offset_ + max_frame_num;
+ else
+ frame_num_offset = prev_frame_num_offset_;
+
+ // 8-7. Derive |abs_frame_num|.
+ int32_t abs_frame_num;
+ if (sps->num_ref_frames_in_pic_order_cnt_cycle != 0)
+ abs_frame_num = frame_num_offset + slice_hdr.frame_num;
+ else
+ abs_frame_num = 0;
+
+ if (slice_hdr.nal_ref_idc == 0 && abs_frame_num > 0)
+ abs_frame_num--;
+
+ // 8-9. Derive |expected_pic_order_cnt| (the |pic_order_cnt| indicated
+ // by the cycle described in the SPS).
+ int32_t expected_pic_order_cnt = 0;
+ if (abs_frame_num > 0) {
+ // 8-8. Derive pic_order_cnt_cycle_cnt and
+ // frame_num_in_pic_order_cnt_cycle.
+ // Moved inside 8-9 to avoid division when this check is not done.
+ if (sps->num_ref_frames_in_pic_order_cnt_cycle == 0) {
+ DLOG(ERROR) << "Invalid num_ref_frames_in_pic_order_cnt_cycle";
+ return false;
+ }
+
+ // H264Parser checks that num_ref_frames_in_pic_order_cnt_cycle < 255.
+ int32_t pic_order_cnt_cycle_cnt =
+ (abs_frame_num - 1) / sps->num_ref_frames_in_pic_order_cnt_cycle;
+ int32_t frame_num_in_pic_order_cnt_cycle =
+ (abs_frame_num - 1) % sps->num_ref_frames_in_pic_order_cnt_cycle;
+
+ // 8-9 continued.
+ expected_pic_order_cnt = pic_order_cnt_cycle_cnt *
+ sps->expected_delta_per_pic_order_cnt_cycle;
+ for (int32_t i = 0; i <= frame_num_in_pic_order_cnt_cycle; i++)
+ expected_pic_order_cnt += sps->offset_for_ref_frame[i];
+ }
+ if (slice_hdr.nal_ref_idc == 0)
+ expected_pic_order_cnt += sps->offset_for_non_ref_pic;
+
+ // 8-10. Derive |top_field_order_cnt| and |bottom_field_order_cnt|
+ // (assuming no interlacing).
+ int32_t top_foc = expected_pic_order_cnt + slice_hdr.delta_pic_order_cnt0;
+ int32_t bottom_foc = top_foc + sps->offset_for_top_to_bottom_field +
+ slice_hdr.delta_pic_order_cnt1;
+ *pic_order_cnt = std::min(top_foc, bottom_foc);
+
+ // Store state.
+ prev_frame_num_ = slice_hdr.frame_num;
+ prev_frame_num_offset_ = frame_num_offset;
+ if (mmco5)
+ prev_frame_num_offset_ = 0;
+
+ break;
+ }
+
+ case 2: {
+ // 8-11. Derive |frame_num_offset|.
+ int32_t frame_num_offset;
+ if (slice_hdr.idr_pic_flag)
+ frame_num_offset = 0;
+ else if (prev_frame_num_ > slice_hdr.frame_num)
+ frame_num_offset = prev_frame_num_offset_ + max_frame_num;
+ else
+ frame_num_offset = prev_frame_num_offset_;
+
+ // 8-12, 8-13. Derive |temp_pic_order_count| (it's always the
+ // |pic_order_cnt|, regardless of interlacing).
+ if (slice_hdr.idr_pic_flag)
+ *pic_order_cnt = 0;
+ else if (slice_hdr.nal_ref_idc == 0)
+ *pic_order_cnt = 2 * (frame_num_offset + slice_hdr.frame_num) - 1;
+ else
+ *pic_order_cnt = 2 * (frame_num_offset + slice_hdr.frame_num);
+
+ // Store state.
+ prev_frame_num_ = slice_hdr.frame_num;
+ prev_frame_num_offset_ = frame_num_offset;
+ if (mmco5)
+ prev_frame_num_offset_ = 0;
+
+ break;
+ }
+
+ default:
+ DLOG(ERROR) << "Invalid pic_order_cnt_type: " << sps->pic_order_cnt_type;
+ return false;
+ }
+
+ return true;
+}
+
+} // namespace media
diff --git a/pool/shard009/C++/0110028_brake.cpp b/pool/shard009/C++/0110028_brake.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..22fa8665984117f9dd8a531afb8cfa00a505b1eb
--- /dev/null
+++ b/pool/shard009/C++/0110028_brake.cpp
@@ -0,0 +1,27 @@
+#include "commands/brake.hpp"
+#include "base/commands_baseclean.hpp"
+#include
+#include
+#include
+
+namespace retrobotics {
+namespace isobot {
+namespace commands {
+Brake::Brake()
+ : BaseClean{"Brake"} {
+ Requires(drive_);
+}
+
+auto Brake::Execute() -> void {
+ std::pair accel_xy{oi_->accelerometer_->GetX(), oi_->accelerometer_->GetY()};
+ std::pair accel_rt{std::hypot(accel_xy.first, accel_xy.second), std::atan2(
+ accel_xy.second, accel_xy.first) - oi_->accelerometer_angle_};
+ std::pair wheels{-std::cos(accel_rt.second)
+ * (std::signbit(std::sin(accel_rt.first)) ? 1 : -1) * std::min(accel_rt.first, 1.), std::cos(
+ accel_rt.second) * (std::signbit(std::sin(accel_rt.first)) ? 1 : -1)
+ * std::min(accel_rt.first, 1.)};
+ drive_->set(wheels);
+}
+}
+}
+}
diff --git a/pool/shard009/C++/0110036_protocol-parameter.cpp b/pool/shard009/C++/0110036_protocol-parameter.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..e0960d14ba0a5d4e59137aa4eede044eb26d18b9
--- /dev/null
+++ b/pool/shard009/C++/0110036_protocol-parameter.cpp
@@ -0,0 +1,230 @@
+/**
+ * This file is part of TelepathyQt
+ *
+ * @copyright Copyright (C) 2010 Collabora Ltd.
+ * @copyright Copyright (C) 2010 Nokia Corporation
+ * @license LGPL 2.1
+ *
+ * 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 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include
+
+#include "TelepathyQt/debug-internal.h"
+
+#include
+
+namespace Tp
+{
+
+struct TP_QT_NO_EXPORT ProtocolParameter::Private : public QSharedData
+{
+ Private(const ParamSpec &sp)
+ : spec(sp),
+ type(variantTypeFromDBusSignature(spec.signature))
+ {
+ init();
+ }
+
+ Private(const QString &name, const QString &dbusSignature,
+ ConnMgrParamFlags flags, const QVariant &defaultValue)
+ : type(variantTypeFromDBusSignature(dbusSignature))
+ {
+ spec.name = name;
+ spec.flags = flags;
+ spec.signature = dbusSignature;
+ spec.defaultValue = QDBusVariant(defaultValue);
+ init();
+ }
+
+ void init()
+ {
+ if (spec.flags & ConnMgrParamFlagHasDefault) {
+ if (spec.defaultValue.variant() == QVariant::Invalid) {
+ // flags contains HasDefault but no default value is passed,
+ // lets warn and build a default value from signature
+ warning() << "Building ProtocolParameter with flags containing ConnMgrParamFlagHasDefault"
+ " and no default value, generating a dummy one from signature";
+ spec.defaultValue = QDBusVariant(
+ parseValueWithDBusSignature(QString(), spec.signature));
+ }
+ } else {
+ if (spec.defaultValue.variant() != QVariant::Invalid) {
+ // flags does not contain HasDefault but a default value is passed,
+ // lets add HasDefault to flags
+ debug() << "Building ProtocolParameter with flags not containing ConnMgrParamFlagHasDefault"
+ " and a default value, updating flags to contain ConnMgrParamFlagHasDefault";
+ spec.flags |= ConnMgrParamFlagHasDefault;
+ }
+ }
+ }
+
+ ParamSpec spec;
+ QVariant::Type type;
+};
+
+/**
+ * \class ProtocolParameter
+ * \ingroup clientcm
+ * \headerfile TelepathyQt/protocol-parameter.h
+ *
+ * \brief The ProtocolParameter class represents a Telepathy protocol parameter.
+ */
+
+
+ProtocolParameter::ProtocolParameter()
+{
+}
+
+ProtocolParameter::ProtocolParameter(const ParamSpec &spec)
+ : mPriv(new Private(spec))
+{
+}
+
+ProtocolParameter::ProtocolParameter(const QString &name,
+ const QDBusSignature &dbusSignature,
+ ConnMgrParamFlags flags,
+ QVariant defaultValue)
+ : mPriv(new Private(name, dbusSignature.signature(), flags, defaultValue))
+{
+}
+
+ProtocolParameter::ProtocolParameter(const QString &name,
+ const QString &dbusSignature,
+ ConnMgrParamFlags flags,
+ QVariant defaultValue)
+ : mPriv(new Private(name, dbusSignature, flags, defaultValue))
+{
+}
+
+ProtocolParameter::ProtocolParameter(const ProtocolParameter &other)
+ : mPriv(other.mPriv)
+{
+}
+
+ProtocolParameter::~ProtocolParameter()
+{
+}
+
+ProtocolParameter &ProtocolParameter::operator=(const ProtocolParameter &other)
+{
+ this->mPriv = other.mPriv;
+ return *this;
+}
+
+bool ProtocolParameter::operator==(const ProtocolParameter &other) const
+{
+ if (!isValid() || !other.isValid()) {
+ if (!isValid() && !other.isValid()) {
+ return true;
+ }
+ return false;
+ }
+
+ return (mPriv->spec.name == other.name());
+}
+
+bool ProtocolParameter::operator==(const QString &name) const
+{
+ if (!isValid()) {
+ return false;
+ }
+
+ return (mPriv->spec.name == name);
+}
+
+bool ProtocolParameter::operator<(const Tp::ProtocolParameter& other) const
+{
+ return mPriv->spec.name < other.name();
+}
+
+QString ProtocolParameter::name() const
+{
+ if (!isValid()) {
+ return QString();
+ }
+
+ return mPriv->spec.name;
+}
+
+QDBusSignature ProtocolParameter::dbusSignature() const
+{
+ if (!isValid()) {
+ return QDBusSignature();
+ }
+
+ return QDBusSignature(mPriv->spec.signature);
+}
+
+QVariant::Type ProtocolParameter::type() const
+{
+ if (!isValid()) {
+ return QVariant::Invalid;
+ }
+
+ return mPriv->type;
+}
+
+QVariant ProtocolParameter::defaultValue() const
+{
+ if (!isValid()) {
+ return QVariant();
+ }
+
+ return mPriv->spec.defaultValue.variant();
+}
+
+bool ProtocolParameter::isRequired() const
+{
+ if (!isValid()) {
+ return false;
+ }
+
+ return mPriv->spec.flags & ConnMgrParamFlagRequired;
+}
+
+bool ProtocolParameter::isSecret() const
+{
+ if (!isValid()) {
+ return false;
+ }
+
+ return mPriv->spec.flags & ConnMgrParamFlagSecret;
+}
+
+bool ProtocolParameter::isRequiredForRegistration() const
+{
+ if (!isValid()) {
+ return false;
+ }
+
+ return mPriv->spec.flags & ConnMgrParamFlagRegister;
+}
+
+ParamSpec ProtocolParameter::bareParameter() const
+{
+ if (!isValid()) {
+ return ParamSpec();
+ }
+
+ return mPriv->spec;
+}
+
+uint qHash(const ProtocolParameter& parameter)
+{
+ return qHash(parameter.name());
+}
+
+} // Tp
diff --git a/pool/shard009/C++/0110038_AttributeList.cpp b/pool/shard009/C++/0110038_AttributeList.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..55e9601bf5e5877b0e2ecc0b54ba09be1035d659
--- /dev/null
+++ b/pool/shard009/C++/0110038_AttributeList.cpp
@@ -0,0 +1,229 @@
+//===--- AttributeList.cpp --------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the AttributeList class implementation
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/Sema/AttributeList.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclTemplate.h"
+#include "clang/AST/Expr.h"
+#include "clang/Basic/IdentifierTable.h"
+#include "clang/Basic/TargetInfo.h"
+#include "clang/Sema/SemaInternal.h"
+#include "llvm/ADT/SmallString.h"
+using namespace clang;
+
+IdentifierLoc *IdentifierLoc::create(ASTContext &Ctx, SourceLocation Loc,
+ IdentifierInfo *Ident) {
+ IdentifierLoc *Result = new (Ctx) IdentifierLoc;
+ Result->Loc = Loc;
+ Result->Ident = Ident;
+ return Result;
+}
+
+size_t AttributeList::allocated_size() const {
+ if (IsAvailability) return AttributeFactory::AvailabilityAllocSize;
+ else if (IsTypeTagForDatatype)
+ return AttributeFactory::TypeTagForDatatypeAllocSize;
+ else if (IsProperty)
+ return AttributeFactory::PropertyAllocSize;
+ return (sizeof(AttributeList) + NumArgs * sizeof(ArgsUnion));
+}
+
+AttributeFactory::AttributeFactory() {
+ // Go ahead and configure all the inline capacity. This is just a memset.
+ FreeLists.resize(InlineFreeListsCapacity);
+}
+AttributeFactory::~AttributeFactory() {}
+
+static size_t getFreeListIndexForSize(size_t size) {
+ assert(size >= sizeof(AttributeList));
+ assert((size % sizeof(void*)) == 0);
+ return ((size - sizeof(AttributeList)) / sizeof(void*));
+}
+
+void *AttributeFactory::allocate(size_t size) {
+ // Check for a previously reclaimed attribute.
+ size_t index = getFreeListIndexForSize(size);
+ if (index < FreeLists.size()) {
+ if (AttributeList *attr = FreeLists[index]) {
+ FreeLists[index] = attr->NextInPool;
+ return attr;
+ }
+ }
+
+ // Otherwise, allocate something new.
+ return Alloc.Allocate(size, alignof(AttributeFactory));
+}
+
+void AttributeFactory::reclaimPool(AttributeList *cur) {
+ assert(cur && "reclaiming empty pool!");
+ do {
+ // Read this here, because we're going to overwrite NextInPool
+ // when we toss 'cur' into the appropriate queue.
+ AttributeList *next = cur->NextInPool;
+
+ size_t size = cur->allocated_size();
+ size_t freeListIndex = getFreeListIndexForSize(size);
+
+ // Expand FreeLists to the appropriate size, if required.
+ if (freeListIndex >= FreeLists.size())
+ FreeLists.resize(freeListIndex+1);
+
+ // Add 'cur' to the appropriate free-list.
+ cur->NextInPool = FreeLists[freeListIndex];
+ FreeLists[freeListIndex] = cur;
+
+ cur = next;
+ } while (cur);
+}
+
+void AttributePool::takePool(AttributeList *pool) {
+ assert(pool);
+
+ // Fast path: this pool is empty.
+ if (!Head) {
+ Head = pool;
+ return;
+ }
+
+ // Reverse the pool onto the current head. This optimizes for the
+ // pattern of pulling a lot of pools into a single pool.
+ do {
+ AttributeList *next = pool->NextInPool;
+ pool->NextInPool = Head;
+ Head = pool;
+ pool = next;
+ } while (pool);
+}
+
+#include "clang/Sema/AttrParsedAttrKinds.inc"
+
+static StringRef normalizeAttrName(StringRef AttrName, StringRef ScopeName,
+ AttributeList::Syntax SyntaxUsed) {
+ // Normalize the attribute name, __foo__ becomes foo. This is only allowable
+ // for GNU attributes.
+ bool IsGNU = SyntaxUsed == AttributeList::AS_GNU ||
+ (SyntaxUsed == AttributeList::AS_CXX11 && ScopeName == "gnu");
+ if (IsGNU && AttrName.size() >= 4 && AttrName.startswith("__") &&
+ AttrName.endswith("__"))
+ AttrName = AttrName.slice(2, AttrName.size() - 2);
+
+ return AttrName;
+}
+
+AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name,
+ const IdentifierInfo *ScopeName,
+ Syntax SyntaxUsed) {
+ StringRef AttrName = Name->getName();
+
+ SmallString<64> FullName;
+ if (ScopeName)
+ FullName += ScopeName->getName();
+
+ AttrName = normalizeAttrName(AttrName, FullName, SyntaxUsed);
+
+ // Ensure that in the case of C++11 attributes, we look for '::foo' if it is
+ // unscoped.
+ if (ScopeName || SyntaxUsed == AS_CXX11)
+ FullName += "::";
+ FullName += AttrName;
+
+ return ::getAttrKind(FullName, SyntaxUsed);
+}
+
+unsigned AttributeList::getAttributeSpellingListIndex() const {
+ // Both variables will be used in tablegen generated
+ // attribute spell list index matching code.
+ StringRef Scope = ScopeName ? ScopeName->getName() : "";
+ StringRef Name = normalizeAttrName(AttrName->getName(), Scope,
+ (AttributeList::Syntax)SyntaxUsed);
+
+#include "clang/Sema/AttrSpellingListIndex.inc"
+
+}
+
+struct ParsedAttrInfo {
+ unsigned NumArgs : 4;
+ unsigned OptArgs : 4;
+ unsigned HasCustomParsing : 1;
+ unsigned IsTargetSpecific : 1;
+ unsigned IsType : 1;
+ unsigned IsStmt : 1;
+ unsigned IsKnownToGCC : 1;
+
+ bool (*DiagAppertainsToDecl)(Sema &S, const AttributeList &Attr,
+ const Decl *);
+ bool (*DiagLangOpts)(Sema &S, const AttributeList &Attr);
+ bool (*ExistsInTarget)(const TargetInfo &Target);
+ unsigned (*SpellingIndexToSemanticSpelling)(const AttributeList &Attr);
+};
+
+namespace {
+ #include "clang/Sema/AttrParsedAttrImpl.inc"
+}
+
+static const ParsedAttrInfo &getInfo(const AttributeList &A) {
+ return AttrInfoMap[A.getKind()];
+}
+
+unsigned AttributeList::getMinArgs() const {
+ return getInfo(*this).NumArgs;
+}
+
+unsigned AttributeList::getMaxArgs() const {
+ return getMinArgs() + getInfo(*this).OptArgs;
+}
+
+bool AttributeList::hasCustomParsing() const {
+ return getInfo(*this).HasCustomParsing;
+}
+
+bool AttributeList::diagnoseAppertainsTo(Sema &S, const Decl *D) const {
+ return getInfo(*this).DiagAppertainsToDecl(S, *this, D);
+}
+
+bool AttributeList::diagnoseLangOpts(Sema &S) const {
+ return getInfo(*this).DiagLangOpts(S, *this);
+}
+
+bool AttributeList::isTargetSpecificAttr() const {
+ return getInfo(*this).IsTargetSpecific;
+}
+
+bool AttributeList::isTypeAttr() const {
+ return getInfo(*this).IsType;
+}
+
+bool AttributeList::isStmtAttr() const {
+ return getInfo(*this).IsStmt;
+}
+
+bool AttributeList::existsInTarget(const TargetInfo &Target) const {
+ return getInfo(*this).ExistsInTarget(Target);
+}
+
+bool AttributeList::isKnownToGCC() const {
+ return getInfo(*this).IsKnownToGCC;
+}
+
+unsigned AttributeList::getSemanticSpelling() const {
+ return getInfo(*this).SpellingIndexToSemanticSpelling(*this);
+}
+
+bool AttributeList::hasVariadicArg() const {
+ // If the attribute has the maximum number of optional arguments, we will
+ // claim that as being variadic. If we someday get an attribute that
+ // legitimately bumps up against that maximum, we can use another bit to track
+ // whether it's truly variadic or not.
+ return getInfo(*this).OptArgs == 15;
+}
diff --git a/pool/shard009/C++/0110046_rmsprop_op.cc b/pool/shard009/C++/0110046_rmsprop_op.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9e7960c237fdec4d61ab8cf2663558b7b596d087
--- /dev/null
+++ b/pool/shard009/C++/0110046_rmsprop_op.cc
@@ -0,0 +1,175 @@
+/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.
+
+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 "paddle/fluid/operators/optimizers/rmsprop_op.h"
+
+namespace paddle {
+namespace operators {
+
+class RmspropOp : public framework::OperatorWithKernel {
+ public:
+ using framework::OperatorWithKernel::OperatorWithKernel;
+
+ void InferShape(framework::InferShapeContext *ctx) const override {
+ PADDLE_ENFORCE_EQ(ctx->HasInput("Param"), true,
+ platform::errors::NotFound(
+ "Input(Param) of RmspropOp should not be null."));
+ PADDLE_ENFORCE_EQ(
+ ctx->HasInput("MeanSquare"), true,
+ platform::errors::NotFound(
+ "Input(MeanSquare) of RmspropOp should not be null."));
+ PADDLE_ENFORCE_EQ(
+ ctx->HasInput("LearningRate"), true,
+ platform::errors::NotFound(
+ "Input(LearningRate) of RmspropOp should not be null."));
+ PADDLE_ENFORCE_EQ(ctx->HasInput("Grad"), true,
+ platform::errors::NotFound(
+ "Input(Grad) of RmspropOp should not be null."));
+ PADDLE_ENFORCE_EQ(ctx->HasInput("Moment"), true,
+ platform::errors::NotFound(
+ "Input(Moment) of RmspropOp should not be null."));
+ PADDLE_ENFORCE_EQ(ctx->GetInputsVarType("Param").front(),
+ framework::proto::VarType::LOD_TENSOR,
+ platform::errors::InvalidArgument(
+ "The input var's type in RmspropOp should be "
+ "LoDTensor, but the received is %s",
+ ctx->GetInputsVarType("Param").front()));
+
+ PADDLE_ENFORCE_EQ(
+ ctx->HasOutput("ParamOut"), true,
+ platform::errors::NotFound(
+ "Output(param_out) of RmspropOp should not be null."));
+ PADDLE_ENFORCE_EQ(
+ ctx->HasOutput("MomentOut"), true,
+ platform::errors::NotFound(
+ "Output(MomentOut) of RmspropOp should not be null."));
+ PADDLE_ENFORCE_EQ(
+ ctx->HasOutput("MeanSquareOut"), true,
+ platform::errors::NotFound(
+ "Output(MeanSquareOut) of RmspropOp should not be null."));
+ if (ctx->Attrs().Get("centered")) {
+ PADDLE_ENFORCE_EQ(
+ ctx->HasOutput("MeanGradOut"), true,
+ platform::errors::NotFound(
+ "Output(MeanGradOut) of RmspropOp should not be null."));
+ }
+
+ auto param_dim = ctx->GetInputDim("Param");
+ PADDLE_ENFORCE_EQ(
+ param_dim, ctx->GetInputDim("Grad"),
+ platform::errors::InvalidArgument(
+ "Param and grad input of RmspropOp should have the same dimension. "
+ "But received Param's dim [%s] and Grad's dim [%s].",
+ param_dim, ctx->GetInputDim("Grad")));
+ PADDLE_ENFORCE_EQ(param_dim, ctx->GetInputDim("Moment"),
+ platform::errors::InvalidArgument(
+ "Param and Momentum input of RmspropOp "
+ "should have the same dimension. But received "
+ "Param's dim [%s] and Moment [%s]",
+ param_dim, ctx->GetInputDim("Moment")));
+ PADDLE_ENFORCE_EQ(param_dim, ctx->GetInputDim("MeanSquare"),
+ platform::errors::InvalidArgument(
+ "Param and Momentum input of RmspropOp "
+ "should have the same dimension. But received "
+ "Param's dim [%s] and MeanSquare [%s]",
+ param_dim, ctx->GetInputDim("MeanSquare")));
+
+ auto lr_dim = ctx->GetInputDim("LearningRate");
+ PADDLE_ENFORCE_EQ(framework::product(lr_dim), 1,
+ platform::errors::InvalidArgument(
+ "Learning Rate of RmspropOp should be a scalar. But "
+ "received LearningRate's dim [%s]",
+ framework::product(lr_dim)));
+
+ ctx->SetOutputDim("ParamOut", param_dim);
+ ctx->SetOutputDim("MomentOut", param_dim);
+ ctx->SetOutputDim("MeanSquareOut", param_dim);
+ if (ctx->Attrs().Get("centered")) {
+ ctx->SetOutputDim("MeanGradOut", param_dim);
+ }
+ }
+};
+
+class RmspropOpMaker : public framework::OpProtoAndCheckerMaker {
+ public:
+ void Make() override {
+ AddInput("Param",
+ "(Tensor, default Tensor) "
+ "Input parameter value that has to be updated.");
+ AddInput("MeanSquare",
+ "(Tensor, default Tensor)"
+ " The mean square value that gets updated.");
+ AddInput("MeanGrad",
+ "(Tensor, default Tensor)"
+ " The moving average of gradient")
+ .AsDispensable();
+ AddInput("LearningRate",
+ "(Tensor, default Tensor) "
+ "The learning rate should be a tensor of size 1.");
+ AddInput("Grad",
+ "(Tensor, default Tensor) "
+ "Input gradient of the parameter.");
+ AddInput("Moment",
+ "(Tensor, default Tensor) The moment that gets updated.");
+
+ AddOutput("ParamOut", "(Tensor) Output updated parameter value.");
+ AddOutput("MomentOut", "(Tensor) Output updated moment.");
+ AddOutput("MeanSquareOut", "(Tensor) Output Mean squared updated value.");
+ AddOutput("MeanGradOut",
+ "(Tensor) Output moving average of gradient updated value.");
+
+ AddAttr("epsilon",
+ "(float, default 1e-10) Constant "
+ "for numerical stability.")
+ .SetDefault(1.0e-10f);
+ AddAttr("decay",
+ "(float, default 0.9) "
+ "Discounting factor for coming gradient.")
+ .SetDefault(0.9f);
+ AddAttr("momentum", "(float, default 0.0) Constant value.")
+ .SetDefault(0.0f);
+ AddAttr("centered", "(bool, default false) use centered rmsprop.")
+ .SetDefault(false);
+ AddComment(R"DOC(
+Rmsprop Optimizer.
+
+$$
+MeanSquareOut = decay * MeanSquare + (1 - decay) * Grad * Grad \\
+MomentOut = momentum * Moment +
+ \frac{LearningRate * Grad}{\sqrt{MeanSquareOut + epsilon}} \\
+ParamOut = Param - MomentOut
+$$
+
+if centered is true:
+
+mean_grad = decay * mean_square{t-1} + (1-decay) * gradient
+mean_square = decay * mean_square{t-1} + (1-decay) * gradient ** 2
+mom = momentum * mom{t-1} + learning_rate * g_t /
+ sqrt(mean_square - mean_grad**2 + epsilon)
+param -= mom
+
+The original slides that proposed Rmsprop: Slide 29 of
+http://www.cs.toronto.edu/~tijmen/csc321/slides/lecture_slides_lec6.pdf)
+
+)DOC");
+ }
+};
+} // namespace operators
+} // namespace paddle
+
+namespace ops = paddle::operators;
+REGISTER_OP_WITHOUT_GRADIENT(rmsprop, ops::RmspropOp, ops::RmspropOpMaker);
+REGISTER_OP_CPU_KERNEL(
+ rmsprop, ops::RmspropOpKernel,
+ ops::RmspropOpKernel);
diff --git a/pool/shard009/C++/0110047_ClawHumanView.cpp b/pool/shard009/C++/0110047_ClawHumanView.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ed8a1694add5ded391d8ef5a90cbdeee898eaac4
--- /dev/null
+++ b/pool/shard009/C++/0110047_ClawHumanView.cpp
@@ -0,0 +1,133 @@
+#include "ClawHumanView.h"
+#include "ClawGameLogic.h"
+#include "ActorController.h"
+#include "Engine/UserInterface/GameHUD.h"
+#include "Engine/Resource/Loaders/XmlLoader.h"
+
+//---------------------------------------------------------------------------------------------------------------------
+// ClawHumanView
+//---------------------------------------------------------------------------------------------------------------------
+
+ClawHumanView::ClawHumanView(SDL_Renderer* renderer)
+ : HumanView(renderer)
+{
+ RegisterAllDelegates();
+
+ m_pCamera->SetSize((uint32)g_pApp->GetWindowSize().x, (uint32)g_pApp->GetWindowSize().y);
+
+ Point startingPos = Point(400, 4500);
+ m_pCamera->VSetPosition(startingPos);
+
+ m_pFreeCameraController.reset(new MovementController(m_pCamera));
+
+ m_pKeyboardHandler = m_pFreeCameraController;
+ m_pPointerHandler = m_pFreeCameraController;
+ m_pTouchHandler = m_pFreeCameraController;
+ g_pApp->RegisterTouchRecognizers(*m_pFreeCameraController);
+}
+
+ClawHumanView::~ClawHumanView()
+{
+ RemoveAllDelegates();
+}
+
+bool ClawHumanView::VOnEvent(SDL_Event& event)
+{
+ if (HumanView::VOnEvent(event))
+ {
+ return true;
+ }
+
+ // Handle game specific events
+ return false;
+}
+
+void ClawHumanView::VOnUpdate(uint32 msDiff)
+{
+ // Update engine, then game specific stuff
+ HumanView::VOnUpdate(msDiff);
+
+ // Actor controller has higher priority
+ if (m_pActorController)
+ {
+ m_pActorController->OnUpdate(msDiff);
+ }
+ else if (m_pFreeCameraController)
+ {
+ m_pFreeCameraController->OnUpdate(msDiff);
+ }
+}
+
+void ClawHumanView::VOnAttach(uint32 gameViewId, uint32 actorId)
+{
+ HumanView::VOnAttach(gameViewId, actorId);
+}
+
+void ClawHumanView::VSetControlledActor(uint32 actorId)
+{
+ m_pControlledActor = static_pointer_cast(m_pScene->FindActor(actorId));
+
+ if (!m_pControlledActor)
+ {
+ LOG_ERROR("Trying to assign control to invalid actor. Id: " + ToStr(actorId));
+ return;
+ }
+
+ HumanView::VSetControlledActor(actorId);
+
+ /*m_pFreeCameraController.reset(new MovementController(m_pCamera));
+ m_pKeyboardHandler = m_pFreeCameraController;
+ m_pPointerHandler = m_pFreeCameraController;*/
+
+ m_pActorController.reset(new ActorController(m_pControlledActor));
+ m_pKeyboardHandler = m_pActorController;
+ m_pPointerHandler = m_pActorController;
+ m_pTouchHandler = m_pActorController;
+ g_pApp->RegisterTouchRecognizers(*m_pActorController);
+
+ m_pCamera->SetTarget(m_pControlledActor);
+}
+
+bool ClawHumanView::VLoadGameDelegate(TiXmlElement* pLevelXmlElem, LevelData* pLevelData)
+{
+ if (!HumanView::VLoadGameDelegate(pLevelXmlElem, pLevelData))
+ {
+ return false;
+ }
+
+ if (!m_pHUD->Initialize(g_pApp->GetRenderer(), m_pCamera))
+ {
+ LOG_ERROR("Failed to create in-game HUD");
+ return false;
+ }
+
+ TiXmlElement* pXmlIngameMenuRoot = XmlResourceLoader::LoadAndReturnRootXmlElement("INGAME_MENU.XML");
+ assert(pXmlIngameMenuRoot != NULL);
+
+ m_pIngameMenu.reset(new ScreenElementMenu(g_pApp->GetRenderer()));
+ if (!m_pIngameMenu->Initialize(pXmlIngameMenuRoot))
+ {
+ LOG_ERROR("Failed to create in-game Menu");
+ return false;
+ }
+
+ m_ScreenElements.push_back(m_pHUD);
+ m_ScreenElements.push_back(m_pIngameMenu);
+ m_pIngameMenu->VSetVisible(false);
+
+ return true;
+}
+
+//=====================================================================================================================
+// ClawHumanView: Private implementations
+//=====================================================================================================================
+
+void ClawHumanView::RegisterAllDelegates()
+{
+
+}
+
+void ClawHumanView::RemoveAllDelegates()
+{
+
+}
\ No newline at end of file
diff --git a/pool/shard009/C++/0110051_propitem.cpp b/pool/shard009/C++/0110051_propitem.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..a5684cba59889e188defd57560bef12c68a21d79
--- /dev/null
+++ b/pool/shard009/C++/0110051_propitem.cpp
@@ -0,0 +1,64 @@
+
+#include "propitem.h"
+
+PropItem::PropItem(const QString &name, const QVariant &value, PropItem *parent)
+{
+ itemName = name;
+ itemValue = value;
+ parentItem = parent;
+}
+
+PropItem::~PropItem()
+{
+ qDeleteAll(childItems);
+}
+
+bool PropItem::setData(int column, const QVariant &value)
+{
+ // We can only edit the right hand column
+ if (column != 1) return false;
+ itemValue = value;
+ return true;
+}
+
+void PropItem::appendChild(PropItem *child)
+{
+ childItems.append(child);
+}
+
+PropItem *PropItem::child(int row)
+{
+ return childItems.value(row);
+}
+
+int PropItem::childCount() const
+{
+ return childItems.count();
+}
+
+int PropItem::row() const
+{
+ if (parentItem)
+ return parentItem->childItems.indexOf(const_cast(this));
+ return 0;
+}
+
+int PropItem::columnCount() const
+{
+ return 2;
+}
+
+PropItem *PropItem::parent()
+{
+ return parentItem;
+}
+
+QString PropItem::name() const
+{
+ return itemName;
+}
+
+QVariant PropItem::value()
+{
+ return itemValue;
+}
diff --git a/pool/shard009/C++/0110052_test_memory_pool.cpp b/pool/shard009/C++/0110052_test_memory_pool.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..9d210f6c74629b5e511229d0d068ef97fede9ad2
--- /dev/null
+++ b/pool/shard009/C++/0110052_test_memory_pool.cpp
@@ -0,0 +1,178 @@
+/*****************************************************************************
+ * Licensed to Qualys, Inc. (QUALYS) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * QUALYS licenses this file to You 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.
+ ****************************************************************************/
+
+/**
+ * @file
+ * @brief IronBee++ Internals --- Memory Pool Tests
+ *
+ * @author Christopher Alfeld
+ **/
+
+#include
+#include
+#include
+
+#include "gtest/gtest.h"
+
+#include
+
+using namespace std;
+
+class TestMemoryPool : public ::testing::Test, public IronBee::TestFixture
+{
+};
+
+class test_callback
+{
+public:
+ test_callback(bool& called_flag) :
+ m_called_flag(called_flag)
+ {
+ // nop
+ }
+
+ void operator()()
+ {
+ m_called_flag = true;
+ }
+
+private:
+ bool& m_called_flag;
+};
+
+TEST_F(TestMemoryPool, create)
+{
+ IronBee::MemoryPool m;
+
+ m = IronBee::MemoryPool::create();
+ EXPECT_EQ(string("MemoryPool"), m.name());
+ m.destroy();
+
+ EXPECT_NO_THROW(m = IronBee::MemoryPool::create("Hello World"));
+ EXPECT_EQ(string("Hello World"), m.name());
+
+ IronBee::MemoryPool m2;
+ EXPECT_NO_THROW(m2 = IronBee::MemoryPool::create("WorldChild", m));
+ EXPECT_EQ(string("WorldChild"), m2.name());
+ m2.destroy();
+
+ EXPECT_NO_THROW(m2 = m.create_subpool());
+ EXPECT_EQ(string("SubPool"), m2.name());
+ m2.destroy();
+
+ EXPECT_NO_THROW(m2 = m.create_subpool("WorldChild2"));
+ EXPECT_EQ(string("WorldChild2"), m2.name());
+ m2.destroy();
+ m.destroy();
+}
+
+TEST_F(TestMemoryPool, basic)
+{
+ IronBee::MemoryPool m = IronBee::MemoryPool::create();
+ char* p;
+
+ p = reinterpret_cast(m.alloc(20));
+ EXPECT_TRUE(p);
+
+ int* ip = m.allocate(2);
+ EXPECT_TRUE(ip);
+
+ // With no introspection, testing is limited.
+ EXPECT_NO_THROW(m.clear());
+ EXPECT_NO_THROW(m.destroy());
+}
+
+TEST_F(TestMemoryPool, callbacks)
+{
+ bool called_flag = false;
+
+ IronBee::MemoryPool m = IronBee::MemoryPool::create();
+ m.register_cleanup(test_callback(called_flag));
+
+ ASSERT_FALSE(called_flag);
+ m.clear();
+ EXPECT_TRUE(called_flag);
+ m.destroy();
+ EXPECT_TRUE(called_flag);
+}
+
+TEST_F(TestMemoryPool, boolness)
+{
+ IronBee::MemoryPool singular;
+
+ EXPECT_FALSE(singular);
+
+ ib_mpool_t* ib_memory_pool = reinterpret_cast(1);
+ IronBee::MemoryPool nonsingular(ib_memory_pool);
+
+ EXPECT_TRUE(nonsingular);
+}
+
+TEST_F(TestMemoryPool, expose_c)
+{
+ ib_mpool_t* ib_memory_pool = reinterpret_cast(1);
+ IronBee::MemoryPool m(ib_memory_pool);
+
+ ASSERT_TRUE(m);
+ EXPECT_EQ(ib_memory_pool, m.ib());
+
+ const IronBee::MemoryPool& cm = m;
+ ASSERT_TRUE(cm);
+ EXPECT_EQ(ib_memory_pool, cm.ib());
+}
+
+TEST_F(TestMemoryPool, scoped)
+{
+ bool called_flag = false;
+ {
+ IronBee::ScopedMemoryPool scoped;
+
+ IronBee::MemoryPool m = scoped;
+ EXPECT_TRUE(m);
+ EXPECT_EQ(string("ScopedMemoryPool"), m.name());
+
+ m.register_cleanup(test_callback(called_flag));
+ }
+ EXPECT_TRUE(called_flag);
+
+ called_flag = false;
+ {
+ IronBee::ScopedMemoryPool scoped("Hello World");
+
+ IronBee::MemoryPool m = scoped;
+ EXPECT_TRUE(m);
+ EXPECT_EQ(string("Hello World"), m.name());
+
+ m.register_cleanup(test_callback(called_flag));
+ }
+ EXPECT_TRUE(called_flag);
+}
+
+TEST_F(TestMemoryPool, Const)
+{
+ IronBee::MemoryPool m = IronBee::MemoryPool::create();
+ IronBee::ConstMemoryPool cm = m;
+
+ EXPECT_EQ(cm, m);
+
+ IronBee::MemoryPool m2 = IronBee::MemoryPool::remove_const(cm);
+
+ EXPECT_EQ(cm, m2);
+ EXPECT_EQ(m, m2);
+
+ m.destroy();
+}
diff --git a/pool/shard009/C++/0110054_moveable2.cc b/pool/shard009/C++/0110054_moveable2.cc
new file mode 100644
index 0000000000000000000000000000000000000000..418e5807963f1745eeafee43713c3de8dac825eb
--- /dev/null
+++ b/pool/shard009/C++/0110054_moveable2.cc
@@ -0,0 +1,102 @@
+// { dg-options "-std=gnu++11" }
+
+// Copyright (C) 2009-2015 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library 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 3, 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 General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// .
+
+// 25.3.4 [lib.alg.merge]
+
+#include
+#include
+#include
+#include
+
+using __gnu_test::test_container;
+using __gnu_test::bidirectional_iterator_wrapper;
+using __gnu_test::rvalstruct;
+
+typedef test_container container;
+
+bool
+are_ordered(const rvalstruct& lhs, const rvalstruct& rhs)
+{ return lhs < rhs; }
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ int array1[]={0,2,4,1,3,5};
+ rvalstruct rv_array1[6];
+ std::copy(array1, array1 + 6, rv_array1);
+ container con1(rv_array1, rv_array1 + 6);
+ std::inplace_merge(con1.begin(), con1.it(3), con1.end(), are_ordered);
+ VERIFY( rv_array1[0] == 0 && rv_array1[1] == 1 && rv_array1[2] == 2
+ && rv_array1[3] == 3 && rv_array1[4] == 4 && rv_array1[5] == 5 );
+
+ int array2[]={0,2,4,5,1,3};
+ rvalstruct rv_array2[6];
+ std::copy(array2, array2 + 6, rv_array2);
+ container con2(rv_array2, rv_array2 + 6);
+ std::inplace_merge(con2.begin(), con2.it(4), con2.end(), are_ordered);
+ VERIFY( rv_array2[0] == 0 && rv_array2[1] == 1 && rv_array2[2] == 2
+ && rv_array2[3] == 3 && rv_array2[4] == 4 && rv_array2[5] == 5 );
+
+ int array3[]={1,1,1,2,2,2};
+ rvalstruct rv_array3[6];
+ std::copy(array3, array3 + 6, rv_array3);
+ container con3(rv_array3, rv_array3 + 6);
+ std::inplace_merge(con3.begin(), con3.it(3), con3.end(), are_ordered);
+ VERIFY( rv_array3[0] == 1 && rv_array3[1] == 1 && rv_array3[2] == 1
+ && rv_array3[3] == 2 && rv_array3[4] == 2 && rv_array3[5] == 2 );
+
+ int array4[]={1,1,1,1,2,2};
+ rvalstruct rv_array4[6];
+ std::copy(array4, array4 + 6, rv_array4);
+ container con4(rv_array4, rv_array4 + 6);
+ std::inplace_merge(con4.begin(), con4.it(4), con4.end(), are_ordered);
+ VERIFY( rv_array4[0] == 1 && rv_array4[1] == 1 && rv_array4[2] == 1
+ && rv_array4[3] == 1 && rv_array4[4] == 2 && rv_array4[5] == 2 );
+
+ int array5[]={3,3,3,3};
+ rvalstruct rv_array5[4];
+ std::copy(array5, array5 + 4, rv_array5);
+ container con5(rv_array5, rv_array5 + 4);
+ std::inplace_merge(con5.begin(), con5.it(2), con5.end(), are_ordered);
+ VERIFY( rv_array5[0] == 3 && rv_array5[1] == 3 && rv_array5[2] == 3
+ && rv_array5[3] == 3 );
+
+ int array6[]={3,3,3};
+ rvalstruct rv_array6[3];
+ std::copy(array6, array6 + 3, rv_array6);
+ container con6(rv_array6, rv_array6 + 3);
+ std::inplace_merge(con6.begin(), con6.it(0), con6.end(), are_ordered);
+ VERIFY( rv_array6[0] == 3 && rv_array6[1] == 3 && rv_array6[2] == 3 );
+
+ int array7[]={3,3};
+ rvalstruct rv_array7[2];
+ std::copy(array7, array7 + 2, rv_array7);
+ container con7(rv_array7, rv_array7 + 2);
+ std::inplace_merge(con7.begin(), con7.it(2), con7.end(), are_ordered);
+ VERIFY( rv_array7[0] == 3 && rv_array7[1] == 3 );
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/pool/shard009/C++/0110056_lambdaCaptureReference.cpp b/pool/shard009/C++/0110056_lambdaCaptureReference.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..585ca776a03967f4fcba10278be6f86c89948925
--- /dev/null
+++ b/pool/shard009/C++/0110056_lambdaCaptureReference.cpp
@@ -0,0 +1,28 @@
+// lambdaCaptureReference.cpp
+
+#include
+#include
+
+std::function makeLambda(int a){
+ int local = 2 * a;
+ auto lam = [&local](int b){ return local + b; }; // 1
+ std::cout << "lam(5): "<< lam(5) << std::endl; // 2
+ return lam;
+}
+
+int main(){
+
+ std::cout << std::endl;
+
+ int local = 10;
+
+ auto addLocal = [&local](int b){ return local + b; }; // 3
+
+ auto add10 = makeLambda(5);
+
+ std::cout << "addLocal(5): " << addLocal(5) << std::endl; // 4
+ std::cout << "add10(5): " << add10(5) << std::endl; // 5
+
+ std::cout << std::endl;
+
+}
diff --git a/pool/shard009/C++/0110060_drvkillu.cpp b/pool/shard009/C++/0110060_drvkillu.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..c6a257b573d3a1b5329304d38dfe417b3c3b7073
--- /dev/null
+++ b/pool/shard009/C++/0110060_drvkillu.cpp
@@ -0,0 +1,214 @@
+/*
+ drvkillu.cpp : This file is part of pstoedit
+ Implementation of Kontour output driver.
+
+ Copyright (C) 1993 - 2009 Wolfgang Glunz, wglunz35_AT_pstoedit.net
+ Copyright (C) 1998,1999 Kai-Uwe Sattler, kus_AT_iti.cs.uni-magdeburg.de
+
+ This program 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.
+
+ 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 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+#include "drvkillu.h"
+#include I_fstream
+#include I_stdio
+#include I_stdlib
+#include
+
+
+
+drvKontour::derivedConstructor(drvKontour):constructBase
+{
+// driver specific initializations
+// and writing of header to output file
+
+//
+//
+//
+
+
+ outf << "\n"
+ << "\n";
+
+ outf << "\n" <<
+ " \n"
+ << "\n";
+}
+
+drvKontour::~drvKontour()
+{
+ // driver specific deallocations
+ // and writing of trailer to output file
+ outf << " \n";
+ options=0;
+}
+
+void drvKontour::print_coords()
+{
+ for (unsigned int n = 0; n < numberOfElementsInPath(); n++) {
+ const basedrawingelement & elem = pathElement(n);
+ switch (elem.getType()) {
+ case moveto:{
+ const Point & p = elem.getPoint(0);
+ outf << " \n";
+ }
+ break;
+ case lineto:{
+ const Point & p = elem.getPoint(0);
+ outf << " \n";
+ }
+ break;
+ case closepath:
+ break;
+ case curveto:{
+ for (unsigned int cp = 0; cp < 3; cp++) {
+ const Point & p = elem.getPoint(cp);
+ outf << " \n";
+ }
+ }
+ break;
+ default:
+ errf << "\t\tFatal: unexpected case in drvKontour " << endl;
+ abort();
+ break;
+ }
+ }
+}
+
+
+void drvKontour::open_page()
+{
+}
+
+void drvKontour::close_page()
+{
+}
+
+void drvKontour::show_text(const TextInfo & textinfo)
+{
+ static const float toRad = 3.14159265359f / 180.0f;
+ const double angle = (360.0 - textinfo.currentFontAngle) * toRad;
+ const double cosa = cos(angle);
+ const double sina = sin(angle);
+ outf << "\n";
+ outf << "\n";
+
+ const char *c = textinfo.thetext.value();
+ while (*c != '\0') {
+ if (*c == '<')
+ outf << "<";
+ else if (*c == '&')
+ outf << "&";
+ else if (*c == '>')
+ outf << ">";
+ else
+ outf << *c;
+ c++;
+ }
+ outf << " \n";
+}
+
+void drvKontour::show_path()
+{
+ if (isPolygon())
+ outf << "\n";
+ print_coords();
+ if (isPolygon())
+ outf << " \n";
+ else
+ outf << "\n";
+}
+
+void drvKontour::show_rectangle(const float llx, const float lly,
+ const float urx, const float ury)
+{
+ outf << " " << endl;
+}
+
+int drvKontour::cvtColor(float c)
+{
+ return int ((c * 255.0) + 0.5);
+}
+
+static DriverDescriptionT < drvKontour > D_Kontour("kil", ".kil format for Kontour", "","kil", false, // backend supports subpathes
+ // if subpathes are supported, the backend must deal with
+ // sequences of the following form
+ // moveto (start of subpath)
+ // lineto (a line segment)
+ // lineto
+ // moveto (start of a new subpath)
+ // lineto (a line segment)
+ // lineto
+ //
+ // If this argument is set to false each subpath is drawn
+ // individually which might not necessarily represent
+ // the original drawing.
+ false, // backend supports curves
+ false, // backend supports elements which are filled and have edges
+ true, // backend supports text
+ DriverDescription::noimage, // no support for PNG file images
+ DriverDescription::normalopen, false, // if format supports multiple pages in one file
+ false
+ /*clipping */
+ );
diff --git a/pool/shard009/C++/0110061_test_api_observer_registry.cc b/pool/shard009/C++/0110061_test_api_observer_registry.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fdb6209089573128f6eb759f2ad26c5cb8919723
--- /dev/null
+++ b/pool/shard009/C++/0110061_test_api_observer_registry.cc
@@ -0,0 +1,60 @@
+// Copyright 2021 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "extensions/browser/api/test/test_api_observer_registry.h"
+
+#include
+
+#include "base/check.h"
+#include "base/no_destructor.h"
+
+namespace extensions {
+
+TestApiObserverRegistry::TestApiObserverRegistry() = default;
+TestApiObserverRegistry::~TestApiObserverRegistry() = default;
+
+// static
+TestApiObserverRegistry* TestApiObserverRegistry::GetInstance() {
+ static base::NoDestructor registry;
+ return registry.get();
+}
+
+void TestApiObserverRegistry::NotifyTestPassed(
+ content::BrowserContext* browser_context) {
+ for (auto& observer : observers_) {
+ observer.OnTestPassed(browser_context);
+ }
+}
+
+void TestApiObserverRegistry::NotifyTestFailed(
+ content::BrowserContext* browser_context,
+ const std::string& message) {
+ for (auto& observer : observers_) {
+ observer.OnTestFailed(browser_context, message);
+ }
+}
+
+bool TestApiObserverRegistry::NotifyTestMessage(
+ TestSendMessageFunction* function,
+ const std::string& message) {
+ bool any_listener_will_respond = false;
+ for (auto& observer : observers_) {
+ bool listener_will_respond = observer.OnTestMessage(function, message);
+ DCHECK(!any_listener_will_respond || !listener_will_respond)
+ << "Only one listener may reply.";
+ any_listener_will_respond =
+ any_listener_will_respond || listener_will_respond;
+ }
+ return any_listener_will_respond;
+}
+
+void TestApiObserverRegistry::AddObserver(TestApiObserver* observer) {
+ observers_.AddObserver(observer);
+}
+
+void TestApiObserverRegistry::RemoveObserver(TestApiObserver* observer) {
+ observers_.RemoveObserver(observer);
+}
+
+} // namespace extensions
diff --git a/pool/shard009/C++/0110064_main.cpp b/pool/shard009/C++/0110064_main.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..68b218f51809f341863ceee8ef7b20d2956a2763
--- /dev/null
+++ b/pool/shard009/C++/0110064_main.cpp
@@ -0,0 +1,51 @@
+#include "main.h"
+#include "AppDelegate.h"
+#include "cocos2d.h"
+
+#include
+#include
+#include
+
+using namespace cocos2d;
+
+int APIENTRY _tWinMain(HINSTANCE hInstance,
+ HINSTANCE hPrevInstance,
+ LPTSTR lpCmdLine,
+ int nCmdShow)
+{
+ UNREFERENCED_PARAMETER(hPrevInstance);
+ UNREFERENCED_PARAMETER(lpCmdLine);
+
+ // set current working directory to executable's path
+ {
+ // get to path to the exe
+ TCHAR exePath[MAX_PATH];
+ GetModuleFileName(NULL, exePath, MAX_PATH);
+
+ // terminate the string at the end of the path
+ TCHAR* trailingSlash = wcsrchr(exePath, '\\');
+ if(trailingSlash)
+ *trailingSlash = NULL;
+
+ // switch to the directory of the exe
+ SetCurrentDirectory(exePath);
+ }
+
+ bool fullscreen = false;
+ #ifdef NDEBUG
+ fullscreen = false;
+ #endif
+
+ // create the application instance
+ AppDelegate app;
+
+ // set the view
+ GLView* view = nullptr;
+ if (fullscreen)
+ view = GLViewImpl::createWithFullScreen("TwoScene");
+ else
+ view = GLViewImpl::createWithRect("TwoScene", Rect(0, 0, 1024, 768));
+ Director::getInstance()->setOpenGLView(view);
+
+ return Application::getInstance()->run();
+}
diff --git a/pool/shard009/C++/0110065_SampleRooFitMgr.cc b/pool/shard009/C++/0110065_SampleRooFitMgr.cc
new file mode 100644
index 0000000000000000000000000000000000000000..dfc5218a805bd9201c895936064e34a2e576994f
--- /dev/null
+++ b/pool/shard009/C++/0110065_SampleRooFitMgr.cc
@@ -0,0 +1,109 @@
+/*******************************************************************************
+*
+* Filename : SampleRooFitMgr.cc
+* Description : implementation of roofit manager class
+* Author : Yi-Mu "Enoch" Chen [ ensc@hep1.phys.ntu.edu.tw ]
+*
+*******************************************************************************/
+#include "TstarAnalysis/Common/interface/InitSample.hpp"
+#include "TstarAnalysis/LimitCalc/interface/SampleRooFitMgr.hpp"
+#include
+
+#include "RooDataSet.h"
+
+using namespace std;
+using namespace mgr;
+
+/*******************************************************************************
+* Static member function
+*******************************************************************************/
+RooRealVar&
+SampleRooFitMgr::x(){ return *StaticVar( "x" ); }
+
+/******************************************************************************/
+
+RooRealVar&
+SampleRooFitMgr::w(){ return *StaticVar( "w" ); }
+
+/******************************************************************************/
+
+double
+SampleRooFitMgr::MinMass(){ return x().getMin(); }
+
+/******************************************************************************/
+
+double
+SampleRooFitMgr::MaxMass(){ return x().getMax(); }
+
+/******************************************************************************/
+
+void
+SampleRooFitMgr::InitStaticVars( const double min, const double max )
+{
+ StaticNewVar( "x", "m_{t+jet}", "GeV/c^{2}", min, max );
+ StaticNewVar( "w", "event_weight", "", -1000, 1000 );
+}
+
+/*******************************************************************************
+* Constructor and destructor
+*******************************************************************************/
+SampleRooFitMgr::SampleRooFitMgr( const string& name, const ConfigReader& cfg ) :
+ Named( name ),
+ SampleGroup( name, cfg ),
+ RooFitMgr( name )
+{
+ definesets();
+
+ for( auto& sample : SampleList() ){
+ // Caching sample wide variable (weight sums.. etc), see Common/src/InitSample.cc
+ InitSampleFromEDM( sample );
+
+ // Fitting the defined dataset, see LimitCalc/src/SampleRooFitMgr_FillSet.cc
+ fillsets( sample );
+ }
+}
+
+/******************************************************************************/
+
+SampleRooFitMgr::~SampleRooFitMgr()
+{
+ // for( const auto& name : VarNameList() ){
+ // RooRealVar* var = Var( name );
+ // printf( "%-50s %8.4lf %8.4f %8.4f\n", var->GetName(), var->getVal(), var->getErrorHi(), var->getErrorLo() );
+ // fflush( stdout );
+ // }
+
+ // for( const auto& name : FuncNameList() ){
+ // RooAbsReal* func = Func( name );
+ // printf( "%50s %8.1lf\n", func->GetName(), func->getVal() );
+ // fflush( stdout );
+ // }
+}
+
+
+/*******************************************************************************
+* RooAbsData argument options
+*******************************************************************************/
+RooAbsData*
+SampleRooFitMgr::NewDataSet( const std::string& name )
+{
+ if( DataSet( name ) ){
+ return DataSet( name );
+ } else {
+ RooDataSet* set = new RooDataSet(// Using unbinned RooDataSet object
+ name.c_str(), "",
+ RooArgSet( x(), w() ),
+ RooFit::WeightVar( w() )
+ );
+ AddDataSet( set );
+ return set;
+ }
+}
+
+/******************************************************************************/
+
+RooAbsData*
+SampleRooFitMgr::DataSet( const std::string& name )
+{
+ return RooFitMgr::DataSet( name );
+}
diff --git a/pool/shard009/C++/0110078_guide_algorithm_lowpass.cpp b/pool/shard009/C++/0110078_guide_algorithm_lowpass.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..4d217c8a7825d854d03e2849f3f7dbbd305368c7
--- /dev/null
+++ b/pool/shard009/C++/0110078_guide_algorithm_lowpass.cpp
@@ -0,0 +1,294 @@
+/*
+* guide_algorithm_lowpass.cpp
+* PHD Guiding
+*
+* Created by Bret McKee
+* Copyright (c) 2012 Bret McKee
+* All rights reserved.
+*
+* Based upon work by Craig Stark.
+* Copyright (c) 2006-2010 Craig Stark.
+* All rights reserved.
+*
+* This source code is distributed under the following "BSD" license
+* 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 Bret McKee, Dad Dog Development,
+* Craig Stark, Stark Labs nor the names of its
+* contributors 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 HOLDER OR CONTRIBUTORS BE
+* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+* POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+
+#include "phd.h"
+
+static const double DefaultMinMove = 0.2;
+static const double DefaultSlopeWeight = 5.0;
+
+GuideAlgorithmLowpass::GuideAlgorithmLowpass(Mount *pMount, GuideAxis axis)
+ : GuideAlgorithm(pMount, axis)
+{
+ double minMove = pConfig->Profile.GetDouble(GetConfigPath() + "/minMove", DefaultMinMove);
+ SetMinMove(minMove);
+
+ double slopeWeight = pConfig->Profile.GetDouble(GetConfigPath() + "/SlopeWeight", DefaultSlopeWeight);
+ SetSlopeWeight(slopeWeight);
+
+ reset();
+}
+
+GuideAlgorithmLowpass::~GuideAlgorithmLowpass(void)
+{
+}
+
+GUIDE_ALGORITHM GuideAlgorithmLowpass::Algorithm(void)
+{
+ return GUIDE_ALGORITHM_LOWPASS;
+}
+
+void GuideAlgorithmLowpass::reset(void)
+{
+ m_history.Empty();
+
+ while (m_history.GetCount() < HISTORY_SIZE)
+ {
+ m_history.Add(0.0);
+ }
+}
+
+double GuideAlgorithmLowpass::result(double input)
+{
+ m_history.Add(input);
+
+ ArrayOfDbl sortedHistory(m_history);
+ sortedHistory.Sort(dbl_sort_func);
+
+ m_history.RemoveAt(0);
+ unsigned int numpts = m_history.GetCount();
+
+ double median = sortedHistory[sortedHistory.GetCount()/2];
+ double slope = CalcSlope(m_history);
+ double dReturn = median + m_slopeWeight*slope;
+
+ if (fabs(dReturn) > fabs(input))
+ {
+ Debug.Write(wxString::Format("GuideAlgorithmLowpass::Result() input %.2f is < calculated value %.2f, using input\n", input, dReturn));
+ dReturn = input;
+ }
+
+ //TODO: Undertand this. I think this is wrong, since it divides the orignial input
+ // by 11 if it was less than the computed value. And since the computed
+ // value is median + slope, I'm not sure that it should be divided by 11
+ // either. But the goal of this exercise is to be bug for bug compatible
+ // with PHD 1.x
+
+ if (fabs(input) < m_minMove)
+ {
+ dReturn = 0.0;
+ }
+ else
+ {
+ // Look for a direction reversal - possibly due to backlash comp
+ if (numpts > 2 && (m_history[numpts - 2] * m_history[numpts - 1] < 0))
+ m_pMount->FlagBacklashOverShoot(fabs(input) - m_minMove, m_guideAxis);
+ }
+
+ Debug.Write(wxString::Format("GuideAlgorithmLowpass::Result() returns %.2f from input %.2f\n", dReturn, input));
+
+ return dReturn;
+}
+
+double GuideAlgorithmLowpass::GetMinMove(void)
+{
+ return m_minMove;
+}
+
+bool GuideAlgorithmLowpass::SetMinMove(double minMove)
+{
+ bool bError = false;
+
+ try
+ {
+ if (minMove < 0)
+ {
+ throw ERROR_INFO("invalid minMove");
+ }
+
+ m_minMove = minMove;
+
+ }
+ catch (wxString Msg)
+ {
+ POSSIBLY_UNUSED(Msg);
+ bError = true;
+ m_minMove = DefaultMinMove;
+ }
+
+ pConfig->Profile.SetDouble(GetConfigPath() + "/minMove", m_minMove);
+
+ return bError;
+}
+
+double GuideAlgorithmLowpass::GetSlopeWeight(void)
+{
+ return m_slopeWeight;
+}
+
+bool GuideAlgorithmLowpass::SetSlopeWeight(double slopeWeight)
+{
+ bool bError = false;
+
+ try
+ {
+ if (slopeWeight < 0.0)
+ {
+ throw ERROR_INFO("invalid slopeWeight");
+ }
+
+ m_slopeWeight = slopeWeight;
+ }
+ catch (wxString Msg)
+ {
+ POSSIBLY_UNUSED(Msg);
+ bError = true;
+ m_slopeWeight = DefaultSlopeWeight;
+ }
+
+ pConfig->Profile.SetDouble(GetConfigPath() + "/SlopeWeight", m_slopeWeight);
+
+ return bError;
+}
+
+wxString GuideAlgorithmLowpass::GetSettingsSummary()
+{
+ // return a loggable summary of current mount settings
+ return wxString::Format("Slope weight = %.3f, Minimum move = %.3f\n",
+ GetSlopeWeight(),
+ GetMinMove()
+ );
+}
+
+ConfigDialogPane *GuideAlgorithmLowpass::GetConfigDialogPane(wxWindow *pParent)
+{
+ return new GuideAlgorithmLowpassConfigDialogPane(pParent, this);
+}
+
+GuideAlgorithmLowpass::
+ GuideAlgorithmLowpassConfigDialogPane::
+ GuideAlgorithmLowpassConfigDialogPane(wxWindow *pParent, GuideAlgorithmLowpass *pGuideAlgorithm)
+ : ConfigDialogPane(_("Lowpass Guide Algorithm"), pParent)
+{
+ int width;
+
+ m_pGuideAlgorithm = pGuideAlgorithm;
+
+ width = StringWidth(_T("000.00"));
+ m_pSlopeWeight = new wxSpinCtrlDouble(pParent, wxID_ANY,_T("foo2"), wxPoint(-1,-1),
+ wxSize(width+30, -1), wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.5,_T("SlopeWeight"));
+ m_pSlopeWeight->SetDigits(2);
+
+ DoAdd(_("Slope Weight"), m_pSlopeWeight,
+ _("Weighting of slope parameter in lowpass auto-dec"));
+
+ width = StringWidth(_T("000.00"));
+ m_pMinMove = new wxSpinCtrlDouble(pParent, wxID_ANY,_T("foo2"), wxPoint(-1,-1),
+ wxSize(width+30, -1), wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.05,_T("MinMove"));
+ m_pMinMove->SetDigits(2);
+
+ DoAdd(_("Minimum Move (pixels)"), m_pMinMove,
+ _("How many (fractional) pixels must the star move to trigger a guide pulse? Default = 0.15"));
+
+}
+
+GuideAlgorithmLowpass::
+ GuideAlgorithmLowpassConfigDialogPane::
+ ~GuideAlgorithmLowpassConfigDialogPane(void)
+{
+}
+
+void GuideAlgorithmLowpass::
+ GuideAlgorithmLowpassConfigDialogPane::
+ LoadValues(void)
+{
+ m_pSlopeWeight->SetValue(m_pGuideAlgorithm->GetSlopeWeight());
+ m_pMinMove->SetValue(m_pGuideAlgorithm->GetMinMove());
+}
+
+void GuideAlgorithmLowpass::
+ GuideAlgorithmLowpassConfigDialogPane::
+ UnloadValues(void)
+{
+ m_pGuideAlgorithm->SetSlopeWeight(m_pSlopeWeight->GetValue());
+ m_pGuideAlgorithm->SetMinMove(m_pMinMove->GetValue());
+}
+
+GraphControlPane *GuideAlgorithmLowpass::GetGraphControlPane(wxWindow *pParent, const wxString& label)
+{
+ return new GuideAlgorithmLowpassGraphControlPane(pParent, this, label);
+}
+
+GuideAlgorithmLowpass::
+ GuideAlgorithmLowpassGraphControlPane::
+ GuideAlgorithmLowpassGraphControlPane(wxWindow *pParent, GuideAlgorithmLowpass *pGuideAlgorithm, const wxString& label)
+ : GraphControlPane(pParent, label)
+{
+ int width;
+
+ m_pGuideAlgorithm = pGuideAlgorithm;
+
+ width = StringWidth(_T("000.00"));
+ m_pSlopeWeight = new wxSpinCtrlDouble(this, wxID_ANY, wxEmptyString, wxDefaultPosition,
+ wxSize(width+30, -1), wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.5,_T("SlopeWeight"));
+ m_pSlopeWeight->SetDigits(2);
+ m_pSlopeWeight->Bind(wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, &GuideAlgorithmLowpass::GuideAlgorithmLowpassGraphControlPane::OnSlopeWeightSpinCtrlDouble, this);
+ DoAdd(m_pSlopeWeight, _("Sl W"));
+
+ width = StringWidth(_T("000.00"));
+ m_pMinMove = new wxSpinCtrlDouble(this, wxID_ANY, wxEmptyString, wxDefaultPosition,
+ wxSize(width+30, -1), wxSP_ARROW_KEYS, 0.0, 20.0, 0.0, 0.05,_T("MinMove"));
+ m_pMinMove->SetDigits(2);
+ m_pMinMove->Bind(wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, &GuideAlgorithmLowpass::GuideAlgorithmLowpassGraphControlPane::OnMinMoveSpinCtrlDouble, this);
+ DoAdd(m_pMinMove, _("MnMo"));
+
+ m_pSlopeWeight->SetValue(m_pGuideAlgorithm->GetSlopeWeight());
+ m_pMinMove->SetValue(m_pGuideAlgorithm->GetMinMove());
+}
+
+GuideAlgorithmLowpass::
+ GuideAlgorithmLowpassGraphControlPane::
+ ~GuideAlgorithmLowpassGraphControlPane(void)
+{
+}
+
+void GuideAlgorithmLowpass::
+ GuideAlgorithmLowpassGraphControlPane::
+ OnSlopeWeightSpinCtrlDouble(wxSpinDoubleEvent& evt)
+{
+ m_pGuideAlgorithm->SetSlopeWeight(m_pSlopeWeight->GetValue());
+ GuideLog.SetGuidingParam(m_pGuideAlgorithm->GetAxis() + " Low-pass slope weight", m_pSlopeWeight->GetValue());
+}
+
+void GuideAlgorithmLowpass::
+ GuideAlgorithmLowpassGraphControlPane::
+ OnMinMoveSpinCtrlDouble(wxSpinDoubleEvent& evt)
+{
+ m_pGuideAlgorithm->SetMinMove(m_pMinMove->GetValue());
+ GuideLog.SetGuidingParam(m_pGuideAlgorithm->GetAxis() + " Low-pass minimum move", m_pMinMove->GetValue());
+}
diff --git a/pool/shard009/C++/0110079_MetadataParser.cpp b/pool/shard009/C++/0110079_MetadataParser.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..b91f15863f085557bd01a8486ee05b592f1c8d33
--- /dev/null
+++ b/pool/shard009/C++/0110079_MetadataParser.cpp
@@ -0,0 +1,36 @@
+#if defined(ENABLE_METADATAPARSER)
+
+#include "MetadataParser.h"
+#include "Trace.h"
+#include