blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
201
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
7
100
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
260 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
11.4k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
17 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
80 values
src_encoding
stringclasses
28 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
8
9.86M
extension
stringclasses
52 values
content
stringlengths
8
9.86M
authors
listlengths
1
1
author
stringlengths
0
119
284bb3b7c43566144d344d5e5e6762ed2457d8e9
c352fc3597360aa468af15d42cb8dd5525f7582d
/Hmwrk/Assignment_4/Gaddis_9thEd_Chap5_Prob1_Sum/main.cpp
87d895a811711403491da2aa179a5236f97feb5a
[]
no_license
yesicota/CotaYesenia_Cis5_41366
c400a224118bda9a1f56fe7ecbbe0c6f29ce831a
42d8a36fc4494ac13c51f2015e2e206e54912b06
refs/heads/main
2023-02-22T00:57:21.708991
2021-01-27T07:31:18
2021-01-27T07:31:18
332,184,057
0
0
null
2021-01-23T10:47:37
2021-01-23T10:32:52
null
UTF-8
C++
false
false
826
cpp
/* * File: main.cpp * Author: Yesenia Cota * Created on January 23, 2021, 12:27 AM * Purpose: Use loops to find sum of integers */ //System Libraries #include <iostream> //I/O Library using namespace std; //User Libraries //Global Constants //Math, Science, Universal, Conversions, High Dimensioned Arrays //Function Prototypes //Execution Begins Here int main(int argc, char** argv) { //Initialize the Random Number Seed //Declare Variables int inpInt, //Inputted Integer sumInt=0; //Sum of all integers from 1 to inpInt //Display Inputs cin>>inpInt; //Map Inputs->Outputs for (int count = 0; count <= inpInt; count++) { sumInt += count; } //Display Outputs cout<<"Sum = "<<sumInt; //Exit the Program - Cleanup return 0; }
[ "yesenia.cota138@gmail.com" ]
yesenia.cota138@gmail.com
4fd64b9063ed908cc94e84dd051fb365c7bd2ee9
719d57ab59222a0563a915c8b0267573b2667170
/tools/Templates/TemplateManager.hpp
f0d489fe96d1cc9f301235f4ec29079fddb8002d
[ "MIT" ]
permissive
Adrikikicp/BetterEdit
e93487acb57e6f405e7d2793b29ce47fe8c61cc9
014af9903a69fde7aa038bcc58efe97b9c6ff1c5
refs/heads/master
2023-09-03T19:25:43.441879
2021-10-29T03:00:06
2021-10-29T03:00:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,881
hpp
#pragma once #include <GDMake.h> class TemplateMenu; class TemplateManager; struct TBlock { enum TEdge : uint8_t { eNone = 0, eLeft = 1 << 0, eRight = 1 << 1, eTop = 1 << 2, eBottom = 1 << 3, }; uint8_t edges = eNone; enum TCorner : uint8_t { cNone = 0, cNW = 1 << 4, cNE = 1 << 5, cSW = 1 << 6, cSE = 1 << 7, }; uint8_t corners = cNone; inline uint8_t getID() const { return edges | corners; }; inline uint8_t getEdgeCount() const { uint8_t res; uint8_t c = edges; for (auto ix = 0u; ix < 4; ix++) { res += c & 1; c >>= 1; } return res; } inline uint8_t getCornerCount() const { uint8_t res; uint8_t c = corners; for (auto ix = 0u; ix < 4; ix++) { res += c & 1; c >>= 1; } return res; } }; class Template : public cocos2d::CCObject { protected: std::map<TBlock, std::string> m_mObjects; inline bool init() { return true; } public: inline static Template* create() { auto ret = new Template(); if (ret && ret->init()) { ret->autorelease(); return ret; } CC_SAFE_DELETE(ret); return nullptr; } inline std::map<TBlock, std::string> getBlocks() const { return m_mObjects; } friend class TemplateMenu; friend class TemplateManager; }; class TemplateManager { std::vector<Template*> m_vTemplates; bool init(); public: void encodeDataTo(DS_Dictionary* data); void dataLoaded(DS_Dictionary* data); static TemplateManager* sharedState(); };
[ "60038575+HJfod@users.noreply.github.com" ]
60038575+HJfod@users.noreply.github.com
2f58e3d565a5c4e9ad2e03d507cff0b82a8f3109
36b9decf14d266d6babaf1c44085c2ba869c03ce
/Remnant-main/Remnant/SDK/Trait_Exploiter_parameters.h
bdddeb8be23227d8e0501ee94b44dd364ac1ae6b
[]
no_license
RoryGlenn/RemnantLootSwitcher
6e309a7b2b7bac88a166b552b640c830b863eb2d
85c4cb6839b7c0f60cf8143c571d64ca12439a63
refs/heads/master
2022-12-29T08:47:15.713546
2020-10-23T22:01:45
2020-10-23T22:01:45
305,910,400
0
0
null
null
null
null
UTF-8
C++
false
false
2,140
h
#pragma once // Name: Remnant, Version: 6 #include "../SDK.h" #ifdef _MSC_VER #pragma pack(push, 0x01) #endif /*!!HELPER_DEF!!*/ /*!!DEFINE!!*/ namespace UFT { //--------------------------------------------------------------------------- // Parameters //--------------------------------------------------------------------------- // Function Trait_Exploiter.Trait_Exploiter_C.ModifyInspectInfo struct UTrait_Exploiter_C_ModifyInspectInfo_Params { class AActor* Actor; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) int InspectLevel; // (BlueprintVisible, BlueprintReadOnly, Parm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) struct FInspectInfo Info; // (BlueprintVisible, BlueprintReadOnly, Parm, OutParm, ReferenceParm) bool Rtn; // (Parm, OutParm, ZeroConstructor, IsPlainOldData, NoDestructor) }; // Function Trait_Exploiter.Trait_Exploiter_C.ModifyDamage struct UTrait_Exploiter_C_ModifyDamage_Params { struct FDamageInfo Info; // (BlueprintVisible, BlueprintReadOnly, Parm, OutParm, ReferenceParm, ContainsInstancedReference) bool Rtn; // (Parm, OutParm, ZeroConstructor, IsPlainOldData, NoDestructor) }; // Function Trait_Exploiter.Trait_Exploiter_C.GetWeakPointDamageMod struct UTrait_Exploiter_C_GetWeakPointDamageMod_Params { float Out; // (Parm, OutParm, ZeroConstructor, IsPlainOldData, NoDestructor, HasGetValueTypeHash) }; } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "romglenn@ucsc.edu" ]
romglenn@ucsc.edu
cfe8adeb1a11fd3fbeb7a2af573c2e8e8e7a3c51
b05f4887792696d96c94f2146c9bf0826fcf48e8
/src/coincontrol.h
5d4ba8a35e2d5e21ab7910eff2e469516a08541f
[ "MIT" ]
permissive
alexwasspammed/test1
9a2e2eeabd8e48e41327f4a843e0cc48c24e74d0
d8141c6b52f42b0392bac3a0069a41952d84199b
refs/heads/master
2020-04-14T08:50:54.902401
2014-04-21T09:47:43
2014-04-21T09:47:43
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,059
h
// Copyright (c) 2013-2014 Test1Coin Developers #ifndef COINCONTROL_H #define COINCONTROL_H /** Coin Control Features. */ class CCoinControl { public: CTxDestination destChange; CCoinControl() { SetNull(); } void SetNull() { destChange = CNoDestination(); setSelected.clear(); } bool HasSelected() const { return (setSelected.size() > 0); } bool IsSelected(const uint256& hash, unsigned int n) const { COutPoint outpt(hash, n); return (setSelected.count(outpt) > 0); } void Select(COutPoint& output) { setSelected.insert(output); } void UnSelect(COutPoint& output) { setSelected.erase(output); } void UnSelectAll() { setSelected.clear(); } void ListSelected(std::vector<COutPoint>& vOutpoints) { vOutpoints.assign(setSelected.begin(), setSelected.end()); } private: std::set<COutPoint> setSelected; }; #endif // COINCONTROL_H
[ "alex.was.spammed@gmail.com" ]
alex.was.spammed@gmail.com
186c2c72e419fc672f1251b2535bf3e971eba62d
5c869d5525ade025649d4d4145940065fe5ad078
/20181110/Cau42/Cau42.cpp
7c6352da2f6141d33bb59c3302ff5edd56ca3371
[]
no_license
ledinhchien3320/tindocdaicuong
a37e920a5d6fcc14545da27039e59210e176b38f
2120038e4ccdbce643db9ba6b37906b38771a2ae
refs/heads/master
2020-04-04T14:16:18.862622
2019-03-01T10:02:51
2019-03-01T10:02:51
155,993,201
0
0
null
null
null
null
UTF-8
C++
false
false
353
cpp
#include<iostream> using namespace std; int main() { // tim gia tri k lon nhat sao cho S(k)=1+2+3+...+k < n int n, S = 0, Max1=0,Max=0; cout << "nhap n: "; cin >> n; //chay vong for for (int i = 1; i < n; i++) { S += i; if (S < n) { Max = i; } } if (Max > Max1) { cout << "Cau42= " << Max << endl; } system("pause"); return true; }
[ "thelastone3320@gmail.com" ]
thelastone3320@gmail.com
9559c4813bde271ee54864a9b3624f866b3aaa19
2b210288fb83c773c7a2afa4d874d35f6a000699
/chromium-webcl/src/chrome/browser/devtools/devtools_window.h
4ea733584acd80cbe6dea9667ed7cc6c81a5f6fc
[ "BSD-3-Clause" ]
permissive
mychangle123/Chromium-WebCL
3462ff60a6ef3144729763167be6308921e4195d
2b25f42a0a239127ed39a159c377be58b3102b17
HEAD
2016-09-16T10:47:58.247722
2013-10-31T05:48:50
2013-10-31T05:48:50
14,553,669
1
2
null
null
null
null
UTF-8
C++
false
false
9,449
h
// 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. #ifndef CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_ #define CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_ #include <string> #include <vector> #include "base/basictypes.h" #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/string16.h" #include "chrome/browser/devtools/devtools_file_helper.h" #include "chrome/browser/devtools/devtools_toggle_action.h" #include "content/public/browser/devtools_client_host.h" #include "content/public/browser/devtools_frontend_host_delegate.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" #include "content/public/browser/web_contents_delegate.h" class Browser; class BrowserWindow; class DevToolsControllerTest; class PrefRegistrySyncable; class Profile; namespace base { class Value; } namespace content { class DevToolsAgentHost; class DevToolsClientHost; struct FileChooserParams; class RenderViewHost; class WebContents; } namespace IPC { class Message; } enum DevToolsDockSide { DEVTOOLS_DOCK_SIDE_UNDOCKED = 0, DEVTOOLS_DOCK_SIDE_BOTTOM, DEVTOOLS_DOCK_SIDE_RIGHT, DEVTOOLS_DOCK_SIDE_MINIMIZED }; class DevToolsWindow : private content::NotificationObserver, private content::WebContentsDelegate, private content::DevToolsFrontendHostDelegate { public: static const char kDevToolsApp[]; static std::string GetDevToolsWindowPlacementPrefKey(); static void RegisterUserPrefs(PrefRegistrySyncable* registry); static DevToolsWindow* GetDockedInstanceForInspectedTab( content::WebContents* inspected_tab); static bool IsDevToolsWindow(content::RenderViewHost* window_rvh); static DevToolsWindow* OpenDevToolsWindowForWorker( Profile* profile, content::DevToolsAgentHost* worker_agent); static DevToolsWindow* CreateDevToolsWindowForWorker(Profile* profile); static DevToolsWindow* OpenDevToolsWindow( content::RenderViewHost* inspected_rvh); static DevToolsWindow* ToggleDevToolsWindow( Browser* browser, DevToolsToggleAction action); static void OpenExternalFrontend(Profile* profile, const std::string& frontend_uri, content::DevToolsAgentHost* agent_host); // Exposed for testing, normal clients should not use this method. static DevToolsWindow* ToggleDevToolsWindow( content::RenderViewHost* inspected_rvh, bool force_open, DevToolsToggleAction action); static void InspectElement( content::RenderViewHost* inspected_rvh, int x, int y); virtual ~DevToolsWindow(); // Overridden from DevToolsClientHost. virtual void InspectedContentsClosing() OVERRIDE; content::RenderViewHost* GetRenderViewHost(); void Show(DevToolsToggleAction action); content::WebContents* web_contents() { return web_contents_; } Browser* browser() { return browser_; } // For tests. DevToolsDockSide dock_side() { return dock_side_; } content::DevToolsClientHost* GetDevToolsClientHostForTest(); // Returns preferred devtools window width for given |container_width|. It // tries to use the saved window width, or, if none exists, 1/3 of the // container width, then clamps to try and ensure both devtools and content // are at least somewhat visible. // Called only for the case when devtools window is docked to the side. int GetWidth(int container_width); // Returns preferred devtools window height for given |container_height|. // Uses the same logic as GetWidth. // Called only for the case when devtools window is docked to bottom. int GetHeight(int container_height); // Returns the minimum width devtools window needs. int GetMinimumWidth(); // Returns the minimum height devtools window needs. int GetMinimumHeight(); // Stores preferred devtools window width for this instance. void SetWidth(int width); // Stores preferred devtools window height for this instance. void SetHeight(int height); // Returns the height in minimized mode. int GetMinimizedHeight(); private: friend class DevToolsControllerTest; static DevToolsWindow* Create(Profile* profile, const GURL& frontend_url, content::RenderViewHost* inspected_rvh, DevToolsDockSide dock_side, bool shared_worker_frontend); DevToolsWindow(Profile* profile, const GURL& frontend_url, content::RenderViewHost* inspected_rvh, DevToolsDockSide dock_side); void CreateDevToolsBrowser(); bool FindInspectedBrowserAndTabIndex(Browser**, int* tab); BrowserWindow* GetInspectedBrowserWindow(); bool IsInspectedBrowserPopup(); void UpdateFrontendDockSide(); void Hide(); // Overridden from content::NotificationObserver. virtual void Observe(int type, const content::NotificationSource& source, const content::NotificationDetails& details) OVERRIDE; void ScheduleAction(DevToolsToggleAction action); void DoAction(); static GURL GetDevToolsURL(Profile* profile, const GURL& base_url, DevToolsDockSide dock_side, bool shared_worker_frontend); void UpdateTheme(); void AddDevToolsExtensionsToClient(); void CallClientFunction(const std::string& function_name, const base::Value* arg1 = NULL, const base::Value* arg2 = NULL); // Overridden from content::WebContentsDelegate. virtual content::WebContents* OpenURLFromTab( content::WebContents* source, const content::OpenURLParams& params) OVERRIDE; virtual void AddNewContents(content::WebContents* source, content::WebContents* new_contents, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture, bool* was_blocked) OVERRIDE; virtual void CloseContents(content::WebContents* source) OVERRIDE {} virtual bool PreHandleKeyboardEvent( content::WebContents* source, const content::NativeWebKeyboardEvent& event, bool* is_keyboard_shortcut) OVERRIDE; virtual void HandleKeyboardEvent( content::WebContents* source, const content::NativeWebKeyboardEvent& event) OVERRIDE; virtual content::JavaScriptDialogManager* GetJavaScriptDialogManager() OVERRIDE; virtual void RunFileChooser( content::WebContents* web_contents, const content::FileChooserParams& params) OVERRIDE; virtual void WebContentsFocused(content::WebContents* contents) OVERRIDE; static DevToolsWindow* FindDevToolsWindow(content::DevToolsAgentHost*); static DevToolsWindow* AsDevToolsWindow(content::RenderViewHost*); // content::DevToolsFrontendHostDelegate overrides. virtual void ActivateWindow() OVERRIDE; virtual void ChangeAttachedWindowHeight(unsigned height) OVERRIDE; virtual void CloseWindow() OVERRIDE; virtual void MoveWindow(int x, int y) OVERRIDE; virtual void SetDockSide(const std::string& side) OVERRIDE; virtual void OpenInNewTab(const std::string& url) OVERRIDE; virtual void SaveToFile(const std::string& url, const std::string& content, bool save_as) OVERRIDE; virtual void AppendToFile(const std::string& url, const std::string& content) OVERRIDE; virtual void RequestFileSystems() OVERRIDE; virtual void AddFileSystem() OVERRIDE; virtual void RemoveFileSystem(const std::string& file_system_path) OVERRIDE; // DevToolsFileHelper callbacks. void FileSavedAs(const std::string& url); void AppendedTo(const std::string& url); void FileSystemsLoaded( const std::vector<DevToolsFileHelper::FileSystem>& file_systems); void ShowDevToolsConfirmInfoBar( const string16& message, const base::Callback<void(bool)>& callback); void FileSystemAdded(const DevToolsFileHelper::FileSystem& file_system); void UpdateBrowserToolbar(); bool IsDocked(); void Restore(); static DevToolsDockSide GetDockSideFromPrefs(Profile* profile); static std::string SideToString(DevToolsDockSide dock_side); static DevToolsDockSide SideFromString(const std::string& dock_side); content::WebContents* GetInspectedWebContents(); class InspectedWebContentsObserver; scoped_ptr<InspectedWebContentsObserver> inspected_contents_observer_; class FrontendWebContentsObserver; scoped_ptr<FrontendWebContentsObserver> frontend_contents_observer_; Profile* profile_; content::WebContents* web_contents_; Browser* browser_; DevToolsDockSide dock_side_; bool is_loaded_; DevToolsToggleAction action_on_load_; content::NotificationRegistrar registrar_; scoped_ptr<content::DevToolsClientHost> frontend_host_; base::WeakPtrFactory<DevToolsWindow> weak_factory_; scoped_ptr<DevToolsFileHelper> file_helper_; int width_; int height_; DevToolsDockSide dock_side_before_minimized_; DISALLOW_COPY_AND_ASSIGN(DevToolsWindow); }; #endif // CHROME_BROWSER_DEVTOOLS_DEVTOOLS_WINDOW_H_
[ "ZhangPeiXuan.CN@Gmail.COM" ]
ZhangPeiXuan.CN@Gmail.COM
3b4cb7105087124be94b9c1750dbc4e505b2284c
846a7668ac964632bdb6db639ab381be11c13b77
/android/hardware/qcom/gps/msm8998/gnss/GnssAdapter.cpp
6202a0ef414d468ab8ebaac6db417f6938282a7b
[]
no_license
BPI-SINOVOIP/BPI-A64-Android8
f2900965e96fd6f2a28ced68af668a858b15ebe1
744c72c133b9bf5d2e9efe0ab33e01e6e51d5743
refs/heads/master
2023-05-21T08:02:23.364495
2020-07-15T11:27:51
2020-07-15T11:27:51
143,945,191
2
0
null
null
null
null
UTF-8
C++
false
false
101,401
cpp
/* Copyright (c) 2017, The Linux Foundation. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * 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 The Linux Foundation, 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 "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #define LOG_TAG "LocSvc_GnssAdapter" #include <sys/stat.h> #include <errno.h> #include <ctype.h> #include <cutils/properties.h> #include <math.h> #include <arpa/inet.h> #include <netinet/in.h> #include <netdb.h> #include <GnssAdapter.h> #include <string> #include <loc_log.h> #include <loc_nmea.h> #include <Agps.h> #include <SystemStatus.h> #include <loc_nmea.h> #include <vector> #include <string> #define RAD2DEG (180.0 / M_PI) using namespace loc_core; GnssAdapter::GnssAdapter() : LocAdapterBase(0, LocDualContext::getLocFgContext(NULL, NULL, LocDualContext::mLocationHalName, false)), mUlpProxy(new UlpProxyBase()), mUlpPositionMode(), mGnssSvIdUsedInPosition(), mGnssSvIdUsedInPosAvail(false), mControlCallbacks(), mPowerVoteId(0), mNiData(), mAgpsManager() { LOC_LOGD("%s]: Constructor %p", __func__, this); mUlpPositionMode.mode = LOC_POSITION_MODE_INVALID; readConfigCommand(); setConfigCommand(); } inline GnssAdapter::~GnssAdapter() { LOC_LOGD("%s]: Destructor", __func__); delete mUlpProxy; } void GnssAdapter::setControlCallbacksCommand(LocationControlCallbacks& controlCallbacks) { struct MsgSetControlCallbacks : public LocMsg { GnssAdapter& mAdapter; const LocationControlCallbacks mControlCallbacks; inline MsgSetControlCallbacks(GnssAdapter& adapter, LocationControlCallbacks& controlCallbacks) : LocMsg(), mAdapter(adapter), mControlCallbacks(controlCallbacks) {} inline virtual void proc() const { mAdapter.setControlCallbacks(mControlCallbacks); } }; sendMsg(new MsgSetControlCallbacks(*this, controlCallbacks)); } void GnssAdapter::convertOptions(LocPosMode& out, const LocationOptions& options) { LocPosMode locPosMode = {}; switch (options.mode) { case GNSS_SUPL_MODE_MSB: out.mode = LOC_POSITION_MODE_MS_BASED; break; case GNSS_SUPL_MODE_MSA: out.mode = LOC_POSITION_MODE_MS_ASSISTED; break; default: out.mode = LOC_POSITION_MODE_STANDALONE; break; } out.share_position = true; out.min_interval = options.minInterval; } void GnssAdapter::convertLocation(Location& out, const LocGpsLocation& locGpsLocation, const GpsLocationExtended& locationExtended, const LocPosTechMask techMask) { out.size = sizeof(Location); if (LOC_GPS_LOCATION_HAS_LAT_LONG & locGpsLocation.flags) { out.flags |= LOCATION_HAS_LAT_LONG_BIT; out.latitude = locGpsLocation.latitude; out.longitude = locGpsLocation.longitude; } if (LOC_GPS_LOCATION_HAS_ALTITUDE & locGpsLocation.flags) { out.flags |= LOCATION_HAS_ALTITUDE_BIT; out.altitude = locGpsLocation.altitude; } if (LOC_GPS_LOCATION_HAS_SPEED & locGpsLocation.flags) { out.flags |= LOCATION_HAS_SPEED_BIT; out.speed = locGpsLocation.speed; } if (LOC_GPS_LOCATION_HAS_BEARING & locGpsLocation.flags) { out.flags |= LOCATION_HAS_BEARING_BIT; out.bearing = locGpsLocation.bearing; } if (LOC_GPS_LOCATION_HAS_ACCURACY & locGpsLocation.flags) { out.flags |= LOCATION_HAS_ACCURACY_BIT; out.accuracy = locGpsLocation.accuracy; } if (GPS_LOCATION_EXTENDED_HAS_VERT_UNC & locationExtended.flags) { out.flags |= LOCATION_HAS_VERTICAL_ACCURACY_BIT; out.verticalAccuracy = locationExtended.vert_unc; } if (GPS_LOCATION_EXTENDED_HAS_SPEED_UNC & locationExtended.flags) { out.flags |= LOCATION_HAS_SPEED_ACCURACY_BIT; out.speedAccuracy = locationExtended.speed_unc; } if (GPS_LOCATION_EXTENDED_HAS_BEARING_UNC & locationExtended.flags) { out.flags |= LOCATION_HAS_BEARING_ACCURACY_BIT; out.bearingAccuracy = locationExtended.bearing_unc; } out.timestamp = locGpsLocation.timestamp; if (LOC_POS_TECH_MASK_SATELLITE & techMask) { out.techMask |= LOCATION_TECHNOLOGY_GNSS_BIT; } if (LOC_POS_TECH_MASK_CELLID & techMask) { out.techMask |= LOCATION_TECHNOLOGY_CELL_BIT; } if (LOC_POS_TECH_MASK_WIFI & techMask) { out.techMask |= LOCATION_TECHNOLOGY_WIFI_BIT; } if (LOC_POS_TECH_MASK_SENSORS & techMask) { out.techMask |= LOCATION_TECHNOLOGY_SENSORS_BIT; } } void GnssAdapter::convertLocationInfo(GnssLocationInfoNotification& out, const GpsLocationExtended& locationExtended) { out.size = sizeof(GnssLocationInfoNotification); if (GPS_LOCATION_EXTENDED_HAS_ALTITUDE_MEAN_SEA_LEVEL & locationExtended.flags) { out.flags |= GNSS_LOCATION_INFO_ALTITUDE_MEAN_SEA_LEVEL_BIT; out.altitudeMeanSeaLevel = locationExtended.altitudeMeanSeaLevel; } if (GPS_LOCATION_EXTENDED_HAS_DOP & locationExtended.flags) { out.flags |= GNSS_LOCATION_INFO_DOP_BIT; out.pdop = locationExtended.pdop; out.hdop = locationExtended.hdop; out.vdop = locationExtended.vdop; } if (GPS_LOCATION_EXTENDED_HAS_MAG_DEV & locationExtended.flags) { out.flags |= GNSS_LOCATION_INFO_MAGNETIC_DEVIATION_BIT; out.magneticDeviation = locationExtended.magneticDeviation; } if (GPS_LOCATION_EXTENDED_HAS_HOR_RELIABILITY & locationExtended.flags) { out.flags |= GNSS_LOCATION_INFO_HOR_RELIABILITY_BIT; switch (locationExtended.horizontal_reliability) { case LOC_RELIABILITY_VERY_LOW: out.horReliability = LOCATION_RELIABILITY_VERY_LOW; break; case LOC_RELIABILITY_LOW: out.horReliability = LOCATION_RELIABILITY_LOW; break; case LOC_RELIABILITY_MEDIUM: out.horReliability = LOCATION_RELIABILITY_MEDIUM; break; case LOC_RELIABILITY_HIGH: out.horReliability = LOCATION_RELIABILITY_HIGH; break; default: out.horReliability = LOCATION_RELIABILITY_NOT_SET; break; } } if (GPS_LOCATION_EXTENDED_HAS_VERT_RELIABILITY & locationExtended.flags) { out.flags |= GNSS_LOCATION_INFO_VER_RELIABILITY_BIT; switch (locationExtended.vertical_reliability) { case LOC_RELIABILITY_VERY_LOW: out.verReliability = LOCATION_RELIABILITY_VERY_LOW; break; case LOC_RELIABILITY_LOW: out.verReliability = LOCATION_RELIABILITY_LOW; break; case LOC_RELIABILITY_MEDIUM: out.verReliability = LOCATION_RELIABILITY_MEDIUM; break; case LOC_RELIABILITY_HIGH: out.verReliability = LOCATION_RELIABILITY_HIGH; break; default: out.verReliability = LOCATION_RELIABILITY_NOT_SET; break; } } if (GPS_LOCATION_EXTENDED_HAS_HOR_ELIP_UNC_MAJOR & locationExtended.flags) { out.flags |= GNSS_LOCATION_INFO_HOR_ACCURACY_ELIP_SEMI_MAJOR_BIT; out.horUncEllipseSemiMajor = locationExtended.horUncEllipseSemiMajor; } if (GPS_LOCATION_EXTENDED_HAS_HOR_ELIP_UNC_MINOR & locationExtended.flags) { out.flags |= GNSS_LOCATION_INFO_HOR_ACCURACY_ELIP_SEMI_MINOR_BIT; out.horUncEllipseSemiMinor = locationExtended.horUncEllipseSemiMinor; } if (GPS_LOCATION_EXTENDED_HAS_HOR_ELIP_UNC_AZIMUTH & locationExtended.flags) { out.flags |= GNSS_LOCATION_INFO_HOR_ACCURACY_ELIP_AZIMUTH_BIT; out.horUncEllipseOrientAzimuth = locationExtended.horUncEllipseOrientAzimuth; } } inline uint32_t GnssAdapter::convertGpsLock(const GnssConfigGpsLock gpsLock) { switch (gpsLock) { case GNSS_CONFIG_GPS_LOCK_MO: return 1; case GNSS_CONFIG_GPS_LOCK_NI: return 2; case GNSS_CONFIG_GPS_LOCK_MO_AND_NI: return 3; case GNSS_CONFIG_GPS_LOCK_NONE: default: return 0; } } inline GnssConfigGpsLock GnssAdapter::convertGpsLock(const uint32_t gpsLock) { switch (gpsLock) { case 1: return GNSS_CONFIG_GPS_LOCK_MO; case 2: return GNSS_CONFIG_GPS_LOCK_NI; case 3: return GNSS_CONFIG_GPS_LOCK_MO_AND_NI; case 0: default: return GNSS_CONFIG_GPS_LOCK_NONE; } } inline uint32_t GnssAdapter::convertSuplVersion(const GnssConfigSuplVersion suplVersion) { switch (suplVersion) { case GNSS_CONFIG_SUPL_VERSION_2_0_0: return 0x00020000; case GNSS_CONFIG_SUPL_VERSION_2_0_2: return 0x00020002; case GNSS_CONFIG_SUPL_VERSION_1_0_0: default: return 0x00010000; } } inline GnssConfigSuplVersion GnssAdapter::convertSuplVersion(const uint32_t suplVersion) { switch (suplVersion) { case 0x00020000: return GNSS_CONFIG_SUPL_VERSION_2_0_0; case 0x00020002: return GNSS_CONFIG_SUPL_VERSION_2_0_2; case 0x00010000: default: return GNSS_CONFIG_SUPL_VERSION_1_0_0; } } inline uint32_t GnssAdapter::convertLppProfile(const GnssConfigLppProfile lppProfile) { switch (lppProfile) { case GNSS_CONFIG_LPP_PROFILE_USER_PLANE: return 1; case GNSS_CONFIG_LPP_PROFILE_CONTROL_PLANE: return 2; case GNSS_CONFIG_LPP_PROFILE_USER_PLANE_AND_CONTROL_PLANE: return 3; case GNSS_CONFIG_LPP_PROFILE_RRLP_ON_LTE: default: return 0; } } inline GnssConfigLppProfile GnssAdapter::convertLppProfile(const uint32_t lppProfile) { switch (lppProfile) { case 1: return GNSS_CONFIG_LPP_PROFILE_USER_PLANE; case 2: return GNSS_CONFIG_LPP_PROFILE_CONTROL_PLANE; case 3: return GNSS_CONFIG_LPP_PROFILE_USER_PLANE_AND_CONTROL_PLANE; case 0: default: return GNSS_CONFIG_LPP_PROFILE_RRLP_ON_LTE; } } uint32_t GnssAdapter::convertLppeCp(const GnssConfigLppeControlPlaneMask lppeControlPlaneMask) { uint32_t mask = 0; if (GNSS_CONFIG_LPPE_CONTROL_PLANE_DBH_BIT & lppeControlPlaneMask) { mask |= (1<<0); } if (GNSS_CONFIG_LPPE_CONTROL_PLANE_WLAN_AP_MEASUREMENTS_BIT & lppeControlPlaneMask) { mask |= (1<<1); } return mask; } GnssConfigLppeControlPlaneMask GnssAdapter::convertLppeCp(const uint32_t lppeControlPlaneMask) { GnssConfigLppeControlPlaneMask mask = 0; if ((1<<0) & lppeControlPlaneMask) { mask |= GNSS_CONFIG_LPPE_CONTROL_PLANE_DBH_BIT; } if ((1<<1) & lppeControlPlaneMask) { mask |= GNSS_CONFIG_LPPE_CONTROL_PLANE_WLAN_AP_MEASUREMENTS_BIT; } return mask; } uint32_t GnssAdapter::convertLppeUp(const GnssConfigLppeUserPlaneMask lppeUserPlaneMask) { uint32_t mask = 0; if (GNSS_CONFIG_LPPE_USER_PLANE_DBH_BIT & lppeUserPlaneMask) { mask |= (1<<0); } if (GNSS_CONFIG_LPPE_USER_PLANE_WLAN_AP_MEASUREMENTS_BIT & lppeUserPlaneMask) { mask |= (1<<1); } return mask; } GnssConfigLppeUserPlaneMask GnssAdapter::convertLppeUp(const uint32_t lppeUserPlaneMask) { GnssConfigLppeUserPlaneMask mask = 0; if ((1<<0) & lppeUserPlaneMask) { mask |= GNSS_CONFIG_LPPE_USER_PLANE_DBH_BIT; } if ((1<<1) & lppeUserPlaneMask) { mask |= GNSS_CONFIG_LPPE_USER_PLANE_WLAN_AP_MEASUREMENTS_BIT; } return mask; } uint32_t GnssAdapter::convertAGloProt(const GnssConfigAGlonassPositionProtocolMask aGloPositionProtocolMask) { uint32_t mask = 0; if (GNSS_CONFIG_RRC_CONTROL_PLANE_BIT & aGloPositionProtocolMask) { mask |= (1<<0); } if (GNSS_CONFIG_RRLP_USER_PLANE_BIT & aGloPositionProtocolMask) { mask |= (1<<1); } if (GNSS_CONFIG_LLP_USER_PLANE_BIT & aGloPositionProtocolMask) { mask |= (1<<2); } if (GNSS_CONFIG_LLP_CONTROL_PLANE_BIT & aGloPositionProtocolMask) { mask |= (1<<3); } return mask; } uint32_t GnssAdapter::convertEP4ES(const GnssConfigEmergencyPdnForEmergencySupl emergencyPdnForEmergencySupl) { switch (emergencyPdnForEmergencySupl) { case GNSS_CONFIG_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_YES: return 1; case GNSS_CONFIG_EMERGENCY_PDN_FOR_EMERGENCY_SUPL_NO: default: return 0; } } uint32_t GnssAdapter::convertSuplEs(const GnssConfigSuplEmergencyServices suplEmergencyServices) { switch (suplEmergencyServices) { case GNSS_CONFIG_SUPL_EMERGENCY_SERVICES_YES: return 1; case GNSS_CONFIG_SUPL_EMERGENCY_SERVICES_NO: default: return 0; } } uint32_t GnssAdapter::convertSuplMode(const GnssConfigSuplModeMask suplModeMask) { uint32_t mask = 0; if (GNSS_CONFIG_SUPL_MODE_MSB_BIT & suplModeMask) { mask |= (1<<0); } if (GNSS_CONFIG_SUPL_MODE_MSA_BIT & suplModeMask) { mask |= (1<<1); } return mask; } bool GnssAdapter::resolveInAddress(const char* hostAddress, struct in_addr* inAddress) { bool ret = true; struct hostent* hp; hp = gethostbyname(hostAddress); if (hp != NULL) { /* DNS OK */ memcpy(inAddress, hp->h_addr_list[0], hp->h_length); } else { /* Try IP representation */ if (inet_aton(hostAddress, inAddress) == 0) { /* IP not valid */ LOC_LOGE("%s]: DNS query on '%s' failed", __func__, hostAddress); ret = false; } } return ret; } void GnssAdapter::readConfigCommand() { LOC_LOGD("%s]: ", __func__); struct MsgReadConfig : public LocMsg { GnssAdapter* mAdapter; ContextBase& mContext; inline MsgReadConfig(GnssAdapter* adapter, ContextBase& context) : LocMsg(), mAdapter(adapter), mContext(context) {} inline virtual void proc() const { // reads config into mContext->mGps_conf mContext.readConfig(); mContext.requestUlp((LocAdapterBase*)mAdapter, mContext.getCarrierCapabilities()); } }; if (mContext != NULL) { sendMsg(new MsgReadConfig(this, *mContext)); } } void GnssAdapter::setConfigCommand() { LOC_LOGD("%s]: ", __func__); struct MsgSetConfig : public LocMsg { GnssAdapter& mAdapter; LocApiBase& mApi; inline MsgSetConfig(GnssAdapter& adapter, LocApiBase& api) : LocMsg(), mAdapter(adapter), mApi(api) {} inline virtual void proc() const { LocDualContext::injectFeatureConfig(mAdapter.getContext()); mApi.setSUPLVersion(mAdapter.convertSuplVersion(ContextBase::mGps_conf.SUPL_VER)); mApi.setLPPConfig(mAdapter.convertLppProfile(ContextBase::mGps_conf.LPP_PROFILE)); mApi.setSensorControlConfig(ContextBase::mSap_conf.SENSOR_USAGE, ContextBase::mSap_conf.SENSOR_PROVIDER); mApi.setAGLONASSProtocol(ContextBase::mGps_conf.A_GLONASS_POS_PROTOCOL_SELECT); mApi.setLPPeProtocolCp( mAdapter.convertLppeCp(ContextBase::mGps_conf.LPPE_CP_TECHNOLOGY)); mApi.setLPPeProtocolUp( mAdapter.convertLppeUp(ContextBase::mGps_conf.LPPE_UP_TECHNOLOGY)); // set nmea mask type uint32_t mask = 0; if (NMEA_PROVIDER_MP == ContextBase::mGps_conf.NMEA_PROVIDER) { mask = LOC_NMEA_ALL_SUPPORTED_MASK; } else { mask = LOC_NMEA_MASK_DEBUG_V02; } mApi.setNMEATypes(mask); mApi.setXtraVersionCheck(ContextBase::mGps_conf.XTRA_VERSION_CHECK); if (ContextBase::mSap_conf.GYRO_BIAS_RANDOM_WALK_VALID || ContextBase::mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID || ContextBase::mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID || ContextBase::mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID || ContextBase::mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID ) { mApi.setSensorProperties( ContextBase::mSap_conf.GYRO_BIAS_RANDOM_WALK_VALID, ContextBase::mSap_conf.GYRO_BIAS_RANDOM_WALK, ContextBase::mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY_VALID, ContextBase::mSap_conf.ACCEL_RANDOM_WALK_SPECTRAL_DENSITY, ContextBase::mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, ContextBase::mSap_conf.ANGLE_RANDOM_WALK_SPECTRAL_DENSITY, ContextBase::mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY_VALID, ContextBase::mSap_conf.RATE_RANDOM_WALK_SPECTRAL_DENSITY, ContextBase::mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY_VALID, ContextBase::mSap_conf.VELOCITY_RANDOM_WALK_SPECTRAL_DENSITY); } mApi.setSensorPerfControlConfig( ContextBase::mSap_conf.SENSOR_CONTROL_MODE, ContextBase::mSap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH, ContextBase::mSap_conf.SENSOR_ACCEL_BATCHES_PER_SEC, ContextBase::mSap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH, ContextBase::mSap_conf.SENSOR_GYRO_BATCHES_PER_SEC, ContextBase::mSap_conf.SENSOR_ACCEL_SAMPLES_PER_BATCH_HIGH, ContextBase::mSap_conf.SENSOR_ACCEL_BATCHES_PER_SEC_HIGH, ContextBase::mSap_conf.SENSOR_GYRO_SAMPLES_PER_BATCH_HIGH, ContextBase::mSap_conf.SENSOR_GYRO_BATCHES_PER_SEC_HIGH, ContextBase::mSap_conf.SENSOR_ALGORITHM_CONFIG_MASK); } }; sendMsg(new MsgSetConfig(*this, *mLocApi)); } uint32_t* GnssAdapter::gnssUpdateConfigCommand(GnssConfig config) { // count the number of bits set GnssConfigFlagsMask flagsCopy = config.flags; size_t count = 0; while (flagsCopy > 0) { if (flagsCopy & 1) { count++; } flagsCopy >>= 1; } std::string idsString = "["; uint32_t* ids = NULL; if (count > 0) { ids = new uint32_t[count]; for (size_t i=0; i < count; ++i) { ids[i] = generateSessionId(); IF_LOC_LOGD { idsString += std::to_string(ids[i]) + " "; } } } idsString += "]"; LOC_LOGD("%s]: ids %s flags 0x%X", __func__, idsString.c_str(), config.flags); struct MsgGnssUpdateConfig : public LocMsg { GnssAdapter& mAdapter; LocApiBase& mApi; GnssConfig mConfig; uint32_t* mIds; size_t mCount; inline MsgGnssUpdateConfig(GnssAdapter& adapter, LocApiBase& api, GnssConfig config, uint32_t* ids, size_t count) : LocMsg(), mAdapter(adapter), mApi(api), mConfig(config), mIds(ids), mCount(count) {} inline virtual ~MsgGnssUpdateConfig() { delete[] mIds; } inline virtual void proc() const { //const size_t MAX_BITS_COUNT = 10; //LocationError errs[MAX_BITS_COUNT] = {}; LocationError* errs = new LocationError[mCount]; LocationError err = LOCATION_ERROR_SUCCESS; uint32_t index = 0; if (mConfig.flags & GNSS_CONFIG_FLAGS_GPS_LOCK_VALID_BIT) { uint32_t newGpsLock = mAdapter.convertGpsLock(mConfig.gpsLock); ContextBase::mGps_conf.GPS_LOCK = newGpsLock; if (0 == mAdapter.getPowerVoteId()) { err = mApi.setGpsLock(mConfig.gpsLock); } if (index < mCount) { errs[index++] = err; } } if (mConfig.flags & GNSS_CONFIG_FLAGS_SUPL_VERSION_VALID_BIT) { uint32_t newSuplVersion = mAdapter.convertSuplVersion(mConfig.suplVersion); if (newSuplVersion != ContextBase::mGps_conf.SUPL_VER) { ContextBase::mGps_conf.SUPL_VER = newSuplVersion; err = mApi.setSUPLVersion(mConfig.suplVersion); } else { err = LOCATION_ERROR_SUCCESS; } if (index < mCount) { errs[index++] = err; } } if (mConfig.flags & GNSS_CONFIG_FLAGS_SET_ASSISTANCE_DATA_VALID_BIT) { if (GNSS_ASSISTANCE_TYPE_SUPL == mConfig.assistanceServer.type) { char serverUrl[MAX_URL_LEN] = {}; uint32_t length = 0; const char noHost[] = "NONE"; if (NULL == mConfig.assistanceServer.hostName || strncasecmp(noHost, mConfig.assistanceServer.hostName, sizeof(noHost)) == 0) { } else { length = snprintf(serverUrl, sizeof(serverUrl), "%s:%u", mConfig.assistanceServer.hostName, mConfig.assistanceServer.port); } if (sizeof(serverUrl) > length) { err = mApi.setServer(serverUrl, length); } else { err = LOCATION_ERROR_INVALID_PARAMETER; } } else if (GNSS_ASSISTANCE_TYPE_C2K == mConfig.assistanceServer.type) { struct in_addr addr; if (!mAdapter.resolveInAddress(mConfig.assistanceServer.hostName, &addr)) { LOC_LOGE("%s]: hostName %s cannot be resolved", __func__, mConfig.assistanceServer.hostName); err = LOCATION_ERROR_INVALID_PARAMETER; } else { unsigned int ip = htonl(addr.s_addr); err = mApi.setServer(ip, mConfig.assistanceServer.port, LOC_AGPS_CDMA_PDE_SERVER); } } else { LOC_LOGE("%s]: Not a valid gnss assistance type %u", __func__, mConfig.assistanceServer.type); err = LOCATION_ERROR_INVALID_PARAMETER; } if (index < mCount) { errs[index++] = err; } } if (mConfig.flags & GNSS_CONFIG_FLAGS_LPP_PROFILE_VALID_BIT) { uint32_t newLppProfile = mAdapter.convertLppProfile(mConfig.lppProfile); if (newLppProfile != ContextBase::mGps_conf.LPP_PROFILE) { ContextBase::mGps_conf.LPP_PROFILE = newLppProfile; err = mApi.setLPPConfig(mConfig.lppProfile); } else { err = LOCATION_ERROR_SUCCESS; } if (index < mCount) { errs[index++] = err; } } if (mConfig.flags & GNSS_CONFIG_FLAGS_LPPE_CONTROL_PLANE_VALID_BIT) { uint32_t newLppeControlPlaneMask = mAdapter.convertLppeCp(mConfig.lppeControlPlaneMask); if (newLppeControlPlaneMask != ContextBase::mGps_conf.LPPE_CP_TECHNOLOGY) { ContextBase::mGps_conf.LPPE_CP_TECHNOLOGY = newLppeControlPlaneMask; err = mApi.setLPPeProtocolCp(mConfig.lppeControlPlaneMask); } else { err = LOCATION_ERROR_SUCCESS; } if (index < mCount) { errs[index++] = err; } } if (mConfig.flags & GNSS_CONFIG_FLAGS_LPPE_USER_PLANE_VALID_BIT) { uint32_t newLppeUserPlaneMask = mAdapter.convertLppeUp(mConfig.lppeUserPlaneMask); if (newLppeUserPlaneMask != ContextBase::mGps_conf.LPPE_UP_TECHNOLOGY) { ContextBase::mGps_conf.LPPE_UP_TECHNOLOGY = newLppeUserPlaneMask; err = mApi.setLPPeProtocolUp(mConfig.lppeUserPlaneMask); } else { err = LOCATION_ERROR_SUCCESS; } if (index < mCount) { errs[index++] = err; } } if (mConfig.flags & GNSS_CONFIG_FLAGS_AGLONASS_POSITION_PROTOCOL_VALID_BIT) { uint32_t newAGloProtMask = mAdapter.convertAGloProt(mConfig.aGlonassPositionProtocolMask); if (newAGloProtMask != ContextBase::mGps_conf.A_GLONASS_POS_PROTOCOL_SELECT) { ContextBase::mGps_conf.A_GLONASS_POS_PROTOCOL_SELECT = newAGloProtMask; err = mApi.setAGLONASSProtocol(mConfig.aGlonassPositionProtocolMask); } else { err = LOCATION_ERROR_SUCCESS; } if (index < mCount) { errs[index++] = err; } } if (mConfig.flags & GNSS_CONFIG_FLAGS_EM_PDN_FOR_EM_SUPL_VALID_BIT) { uint32_t newEP4ES = mAdapter.convertEP4ES(mConfig.emergencyPdnForEmergencySupl); if (newEP4ES != ContextBase::mGps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL) { ContextBase::mGps_conf.USE_EMERGENCY_PDN_FOR_EMERGENCY_SUPL = newEP4ES; } err = LOCATION_ERROR_SUCCESS; if (index < mCount) { errs[index++] = err; } } if (mConfig.flags & GNSS_CONFIG_FLAGS_SUPL_EM_SERVICES_BIT) { uint32_t newSuplEs = mAdapter.convertSuplEs(mConfig.suplEmergencyServices); if (newSuplEs != ContextBase::mGps_conf.SUPL_ES) { ContextBase::mGps_conf.SUPL_ES = newSuplEs; } err = LOCATION_ERROR_SUCCESS; if (index < mCount) { errs[index++] = err; } } if (mConfig.flags & GNSS_CONFIG_FLAGS_SUPL_MODE_BIT) { uint32_t newSuplMode = mAdapter.convertSuplMode(mConfig.suplModeMask); if (newSuplMode != ContextBase::mGps_conf.SUPL_MODE) { ContextBase::mGps_conf.SUPL_MODE = newSuplMode; mAdapter.getUlpProxy()->setCapabilities( ContextBase::getCarrierCapabilities()); } err = LOCATION_ERROR_SUCCESS; if (index < mCount) { errs[index++] = err; } } mAdapter.reportResponse(index, errs, mIds); delete[] errs; } }; if (NULL != ids) { sendMsg(new MsgGnssUpdateConfig(*this, *mLocApi, config, ids, count)); } else { LOC_LOGE("%s]: No GNSS config items to update", __func__); } return ids; } uint32_t GnssAdapter::gnssDeleteAidingDataCommand(GnssAidingData& data) { uint32_t sessionId = generateSessionId(); LOC_LOGD("%s]: id %u", __func__, sessionId); struct MsgDeleteAidingData : public LocMsg { GnssAdapter& mAdapter; LocApiBase& mApi; uint32_t mSessionId; GnssAidingData mData; inline MsgDeleteAidingData(GnssAdapter& adapter, LocApiBase& api, uint32_t sessionId, GnssAidingData& data) : LocMsg(), mAdapter(adapter), mApi(api), mSessionId(sessionId), mData(data) {} inline virtual void proc() const { LocationError err = LOCATION_ERROR_SUCCESS; err = mApi.deleteAidingData(mData); mAdapter.reportResponse(err, mSessionId); } }; sendMsg(new MsgDeleteAidingData(*this, *mLocApi, sessionId, data)); return sessionId; } void GnssAdapter::injectLocationCommand(double latitude, double longitude, float accuracy) { LOC_LOGD("%s]: latitude %8.4f longitude %8.4f accuracy %8.4f", __func__, latitude, longitude, accuracy); struct MsgInjectLocation : public LocMsg { LocApiBase& mApi; ContextBase& mContext; double mLatitude; double mLongitude; float mAccuracy; inline MsgInjectLocation(LocApiBase& api, ContextBase& context, double latitude, double longitude, float accuracy) : LocMsg(), mApi(api), mContext(context), mLatitude(latitude), mLongitude(longitude), mAccuracy(accuracy) {} inline virtual void proc() const { if (!mContext.hasCPIExtendedCapabilities()) { mApi.injectPosition(mLatitude, mLongitude, mAccuracy); } } }; sendMsg(new MsgInjectLocation(*mLocApi, *mContext, latitude, longitude, accuracy)); } void GnssAdapter::injectTimeCommand(int64_t time, int64_t timeReference, int32_t uncertainty) { LOC_LOGD("%s]: time %lld timeReference %lld uncertainty %d", __func__, (long long)time, (long long)timeReference, uncertainty); struct MsgInjectTime : public LocMsg { LocApiBase& mApi; ContextBase& mContext; int64_t mTime; int64_t mTimeReference; int32_t mUncertainty; inline MsgInjectTime(LocApiBase& api, ContextBase& context, int64_t time, int64_t timeReference, int32_t uncertainty) : LocMsg(), mApi(api), mContext(context), mTime(time), mTimeReference(timeReference), mUncertainty(uncertainty) {} inline virtual void proc() const { mApi.setTime(mTime, mTimeReference, mUncertainty); } }; sendMsg(new MsgInjectTime(*mLocApi, *mContext, time, timeReference, uncertainty)); } void GnssAdapter::setUlpProxyCommand(UlpProxyBase* ulp) { LOC_LOGD("%s]: ", __func__); struct MsgSetUlpProxy : public LocMsg { GnssAdapter& mAdapter; UlpProxyBase* mUlp; inline MsgSetUlpProxy(GnssAdapter& adapter, UlpProxyBase* ulp) : LocMsg(), mAdapter(adapter), mUlp(ulp) {} inline virtual void proc() const { mAdapter.setUlpProxy(mUlp); } }; sendMsg(new MsgSetUlpProxy(*this, ulp)); } void GnssAdapter::setUlpProxy(UlpProxyBase* ulp) { if (ulp == mUlpProxy) { //This takes care of the case when double initalization happens //and we get the same object back for UlpProxyBase . Do nothing return; } LOC_LOGV("%s]: %p", __func__, ulp); if (NULL == ulp) { LOC_LOGE("%s]: ulp pointer is NULL", __func__); ulp = new UlpProxyBase(); } if (LOC_POSITION_MODE_INVALID != mUlpProxy->mPosMode.mode) { // need to send this mode and start msg to ULP ulp->sendFixMode(mUlpProxy->mPosMode); } if (mUlpProxy->mFixSet) { ulp->sendStartFix(); } delete mUlpProxy; mUlpProxy = ulp; } void GnssAdapter::addClientCommand(LocationAPI* client, const LocationCallbacks& callbacks) { LOC_LOGD("%s]: client %p", __func__, client); struct MsgAddClient : public LocMsg { GnssAdapter& mAdapter; LocationAPI* mClient; const LocationCallbacks mCallbacks; inline MsgAddClient(GnssAdapter& adapter, LocationAPI* client, const LocationCallbacks& callbacks) : LocMsg(), mAdapter(adapter), mClient(client), mCallbacks(callbacks) {} inline virtual void proc() const { mAdapter.saveClient(mClient, mCallbacks); } }; sendMsg(new MsgAddClient(*this, client, callbacks)); } void GnssAdapter::removeClientCommand(LocationAPI* client) { LOC_LOGD("%s]: client %p", __func__, client); struct MsgRemoveClient : public LocMsg { GnssAdapter& mAdapter; LocationAPI* mClient; inline MsgRemoveClient(GnssAdapter& adapter, LocationAPI* client) : LocMsg(), mAdapter(adapter), mClient(client) {} inline virtual void proc() const { mAdapter.stopClientSessions(mClient); mAdapter.eraseClient(mClient); } }; sendMsg(new MsgRemoveClient(*this, client)); } void GnssAdapter::stopClientSessions(LocationAPI* client) { LOC_LOGD("%s]: client %p", __func__, client); for (auto it = mTrackingSessions.begin(); it != mTrackingSessions.end();) { if (client == it->first.client) { LocationError err = stopTrackingMultiplex(it->first.client, it->first.id); if (LOCATION_ERROR_SUCCESS == err) { it = mTrackingSessions.erase(it); continue; } } ++it; // increment only when not erasing an iterator } } void GnssAdapter::updateClientsEventMask() { LOC_API_ADAPTER_EVENT_MASK_T mask = 0; for (auto it=mClientData.begin(); it != mClientData.end(); ++it) { if (it->second.trackingCb != nullptr) { mask |= LOC_API_ADAPTER_BIT_PARSED_POSITION_REPORT; } if (it->second.gnssNiCb != nullptr) { mask |= LOC_API_ADAPTER_BIT_NI_NOTIFY_VERIFY_REQUEST; } if (it->second.gnssSvCb != nullptr) { mask |= LOC_API_ADAPTER_BIT_SATELLITE_REPORT; } if (it->second.gnssNmeaCb != nullptr) { mask |= LOC_API_ADAPTER_BIT_NMEA_1HZ_REPORT; } if (it->second.gnssMeasurementsCb != nullptr) { mask |= LOC_API_ADAPTER_BIT_GNSS_MEASUREMENT; } } updateEvtMask(mask, LOC_REGISTRATION_MASK_SET); } void GnssAdapter::handleEngineUpEvent() { struct MsgRestartSessions : public LocMsg { GnssAdapter& mAdapter; inline MsgRestartSessions(GnssAdapter& adapter) : LocMsg(), mAdapter(adapter) {} virtual void proc() const { mAdapter.restartSessions(); } }; setConfigCommand(); sendMsg(new MsgRestartSessions(*this)); } void GnssAdapter::restartSessions() { LOC_LOGD("%s]: ", __func__); if (mTrackingSessions.empty()) { return; } // get the LocationOptions that has the smallest interval, which should be the active one LocationOptions smallestIntervalOptions = {}; // size is zero until set for the first time for (auto it = mTrackingSessions.begin(); it != mTrackingSessions.end(); ++it) { if (0 == smallestIntervalOptions.size || //size of zero means we havent set it yet it->second.minInterval < smallestIntervalOptions.minInterval) { smallestIntervalOptions = it->second; } } LocPosMode locPosMode = {}; convertOptions(locPosMode, smallestIntervalOptions); mLocApi->startFix(locPosMode); } void GnssAdapter::requestCapabilitiesCommand(LocationAPI* client) { LOC_LOGD("%s]: ", __func__); struct MsgRequestCapabilities : public LocMsg { GnssAdapter& mAdapter; LocApiBase& mApi; LocationAPI* mClient; inline MsgRequestCapabilities(GnssAdapter& adapter, LocApiBase& api, LocationAPI* client) : LocMsg(), mAdapter(adapter), mApi(api), mClient(client) {} inline virtual void proc() const { LocationCallbacks callbacks = mAdapter.getClientCallbacks(mClient); if (callbacks.capabilitiesCb == nullptr) { LOC_LOGE("%s]: capabilitiesCb is NULL", __func__); return; } LocationCapabilitiesMask mask = {}; // time based tracking always supported mask |= LOCATION_CAPABILITIES_TIME_BASED_TRACKING_BIT; if (mApi.isMessageSupported(LOC_API_ADAPTER_MESSAGE_DISTANCE_BASE_LOCATION_BATCHING)){ mask |= LOCATION_CAPABILITIES_TIME_BASED_BATCHING_BIT | LOCATION_CAPABILITIES_DISTANCE_BASED_BATCHING_BIT; } if (mApi.isMessageSupported(LOC_API_ADAPTER_MESSAGE_DISTANCE_BASE_TRACKING)) { mask |= LOCATION_CAPABILITIES_DISTANCE_BASED_TRACKING_BIT; } // geofence always supported mask |= LOCATION_CAPABILITIES_GEOFENCE_BIT; if (mApi.gnssConstellationConfig()) { mask |= LOCATION_CAPABILITIES_GNSS_MEASUREMENTS_BIT; } uint32_t carrierCapabilities = ContextBase::getCarrierCapabilities(); if (carrierCapabilities & LOC_GPS_CAPABILITY_MSB) { mask |= LOCATION_CAPABILITIES_GNSS_MSB_BIT; } if (LOC_GPS_CAPABILITY_MSA & carrierCapabilities) { mask |= LOCATION_CAPABILITIES_GNSS_MSA_BIT; } callbacks.capabilitiesCb(mask); } }; sendMsg(new MsgRequestCapabilities(*this, *mLocApi, client)); } LocationCallbacks GnssAdapter::getClientCallbacks(LocationAPI* client) { LocationCallbacks callbacks = {}; auto it = mClientData.find(client); if (it != mClientData.end()) { callbacks = it->second; } return callbacks; } void GnssAdapter::saveClient(LocationAPI* client, const LocationCallbacks& callbacks) { mClientData[client] = callbacks; updateClientsEventMask(); } void GnssAdapter::eraseClient(LocationAPI* client) { auto it = mClientData.find(client); if (it != mClientData.end()) { mClientData.erase(it); } updateClientsEventMask(); } bool GnssAdapter::hasTrackingCallback(LocationAPI* client) { auto it = mClientData.find(client); return (it != mClientData.end() && it->second.trackingCb); } bool GnssAdapter::hasMeasurementsCallback(LocationAPI* client) { auto it = mClientData.find(client); return (it != mClientData.end() && it->second.gnssMeasurementsCb); } bool GnssAdapter::isTrackingSession(LocationAPI* client, uint32_t sessionId) { LocationSessionKey key(client, sessionId); return (mTrackingSessions.find(key) != mTrackingSessions.end()); } void GnssAdapter::saveTrackingSession(LocationAPI* client, uint32_t sessionId, const LocationOptions& options) { LocationSessionKey key(client, sessionId); mTrackingSessions[key] = options; } void GnssAdapter::eraseTrackingSession(LocationAPI* client, uint32_t sessionId) { LocationSessionKey key(client, sessionId); auto it = mTrackingSessions.find(key); if (it != mTrackingSessions.end()) { mTrackingSessions.erase(it); } } void GnssAdapter::reportResponse(LocationAPI* client, LocationError err, uint32_t sessionId) { LOC_LOGD("%s]: client %p id %u err %u", __func__, client, sessionId, err); auto it = mClientData.find(client); if (it != mClientData.end() && it->second.responseCb != nullptr) { it->second.responseCb(err, sessionId); } else { LOC_LOGW("%s]: client %p id %u not found in data", __func__, client, sessionId); } } void GnssAdapter::reportResponse(LocationError err, uint32_t sessionId) { LOC_LOGD("%s]: id %u err %u", __func__, sessionId, err); if (mControlCallbacks.size > 0 && mControlCallbacks.responseCb != nullptr) { mControlCallbacks.responseCb(err, sessionId); } else { LOC_LOGW("%s]: control client response callback not found", __func__); } } void GnssAdapter::reportResponse(size_t count, LocationError* errs, uint32_t* ids) { IF_LOC_LOGD { std::string idsString = "["; std::string errsString = "["; if (NULL != ids && NULL != errs) { for (size_t i=0; i < count; ++i) { idsString += std::to_string(ids[i]) + " "; errsString += std::to_string(errs[i]) + " "; } } idsString += "]"; errsString += "]"; LOC_LOGD("%s]: ids %s errs %s", __func__, idsString.c_str(), errsString.c_str()); } if (mControlCallbacks.size > 0 && mControlCallbacks.collectiveResponseCb != nullptr) { mControlCallbacks.collectiveResponseCb(count, errs, ids); } else { LOC_LOGW("%s]: control client callback not found", __func__); } } uint32_t GnssAdapter::startTrackingCommand(LocationAPI* client, LocationOptions& options) { uint32_t sessionId = generateSessionId(); LOC_LOGD("%s]: client %p id %u minInterval %u mode %u", __func__, client, sessionId, options.minInterval, options.mode); struct MsgStartTracking : public LocMsg { GnssAdapter& mAdapter; LocApiBase& mApi; LocationAPI* mClient; uint32_t mSessionId; LocationOptions mOptions; inline MsgStartTracking(GnssAdapter& adapter, LocApiBase& api, LocationAPI* client, uint32_t sessionId, LocationOptions options) : LocMsg(), mAdapter(adapter), mApi(api), mClient(client), mSessionId(sessionId), mOptions(options) {} inline virtual void proc() const { LocationError err = LOCATION_ERROR_SUCCESS; if (!mAdapter.hasTrackingCallback(mClient) && !mAdapter.hasMeasurementsCallback(mClient)) { err = LOCATION_ERROR_CALLBACK_MISSING; } else if (0 == mOptions.size) { err = LOCATION_ERROR_INVALID_PARAMETER; } else { // Api doesn't support multiple clients for time based tracking, so mutiplex err = mAdapter.startTrackingMultiplex(mOptions); if (LOCATION_ERROR_SUCCESS == err) { mAdapter.saveTrackingSession(mClient, mSessionId, mOptions); } } mAdapter.reportResponse(mClient, err, mSessionId); } }; sendMsg(new MsgStartTracking(*this, *mLocApi, client, sessionId, options)); return sessionId; } LocationError GnssAdapter::startTrackingMultiplex(const LocationOptions& options) { LocationError err = LOCATION_ERROR_SUCCESS; if (mTrackingSessions.empty()) { err = startTracking(options); } else { // get the LocationOptions that has the smallest interval, which should be the active one LocationOptions smallestIntervalOptions = {}; // size is zero until set for the first time for (auto it = mTrackingSessions.begin(); it != mTrackingSessions.end(); ++it) { if (0 == smallestIntervalOptions.size || //size of zero means we havent set it yet it->second.minInterval < smallestIntervalOptions.minInterval) { smallestIntervalOptions = it->second; } } // if new session's minInterval is smaller than any in other sessions if (options.minInterval < smallestIntervalOptions.minInterval) { // restart time based tracking with new options err = startTracking(options); } } return err; } LocationError GnssAdapter::startTracking(const LocationOptions& options) { LocationError err = LOCATION_ERROR_SUCCESS; LocPosMode locPosMode = {}; convertOptions(locPosMode, options); if (!mUlpProxy->sendFixMode(locPosMode)) { // do nothing } if (!mUlpProxy->sendStartFix()) { loc_api_adapter_err apiErr = mLocApi->startFix(locPosMode); if (LOC_API_ADAPTER_ERR_SUCCESS == apiErr) { err = LOCATION_ERROR_SUCCESS; } else { err = LOCATION_ERROR_GENERAL_FAILURE; } } return err; } void GnssAdapter::setPositionModeCommand(LocPosMode& locPosMode) { LOC_LOGD("%s]: min_interval %u mode %u", __func__, locPosMode.min_interval, locPosMode.mode); struct MsgSetPositionMode : public LocMsg { GnssAdapter& mAdapter; LocApiBase& mApi; LocPosMode mLocPosMode; inline MsgSetPositionMode(GnssAdapter& adapter, LocApiBase& api, LocPosMode& locPosMode) : LocMsg(), mAdapter(adapter), mApi(api), mLocPosMode(locPosMode) {} inline virtual void proc() const { // saves the mode in adapter to be used when startTrackingCommand is called from ULP mAdapter.setUlpPositionMode(mLocPosMode); mApi.setPositionMode(mLocPosMode); } }; sendMsg(new MsgSetPositionMode(*this, *mLocApi, locPosMode)); } void GnssAdapter::startTrackingCommand() { LOC_LOGD("%s]: ", __func__); struct MsgStartTracking : public LocMsg { GnssAdapter& mAdapter; LocApiBase& mApi; inline MsgStartTracking(GnssAdapter& adapter, LocApiBase& api) : LocMsg(), mAdapter(adapter), mApi(api) {} inline virtual void proc() const { // we get this call from ULP, so just call LocApi without multiplexing because // ulp would be doing the multiplexing for us if it is present LocPosMode& ulpPositionMode = mAdapter.getUlpPositionMode(); mApi.startFix(ulpPositionMode); } }; sendMsg(new MsgStartTracking(*this, *mLocApi)); } void GnssAdapter::updateTrackingOptionsCommand(LocationAPI* client, uint32_t id, LocationOptions& options) { LOC_LOGD("%s]: client %p id %u minInterval %u mode %u", __func__, client, id, options.minInterval, options.mode); struct MsgUpdateTracking : public LocMsg { GnssAdapter& mAdapter; LocApiBase& mApi; LocationAPI* mClient; uint32_t mSessionId; LocationOptions mOptions; inline MsgUpdateTracking(GnssAdapter& adapter, LocApiBase& api, LocationAPI* client, uint32_t sessionId, LocationOptions options) : LocMsg(), mAdapter(adapter), mApi(api), mClient(client), mSessionId(sessionId), mOptions(options) {} inline virtual void proc() const { if (mAdapter.isTrackingSession(mClient, mSessionId)) { LocationError err = LOCATION_ERROR_SUCCESS; if (0 == mOptions.size) { err = LOCATION_ERROR_INVALID_PARAMETER; } else { // Api doesn't support multiple clients for time based tracking, so mutiplex err = mAdapter.updateTrackingMultiplex(mClient, mSessionId, mOptions); if (LOCATION_ERROR_SUCCESS == err) { mAdapter.saveTrackingSession(mClient, mSessionId, mOptions); } } mAdapter.reportResponse(mClient, err, mSessionId); } // we do not reportResponse for the case where there is no existing tracking session // for the client and id being used, since updateTrackingCommand can be sent to both // GnssAdapter & FlpAdapter by LocationAPI and we want to avoid incorrect error response } }; sendMsg(new MsgUpdateTracking(*this, *mLocApi, client, id, options)); } LocationError GnssAdapter::updateTrackingMultiplex(LocationAPI* client, uint32_t id, const LocationOptions& options) { LocationError err = LOCATION_ERROR_SUCCESS; if (1 == mTrackingSessions.size()) { err = startTracking(options); } else { LocationSessionKey key(client, id); // get the session we are updating auto it = mTrackingSessions.find(key); if (it != mTrackingSessions.end()) { // find the smallest interval, other than the session we are updating LocationOptions smallestIntervalOptions = {}; // size is 0 until set for the first time for (auto it2 = mTrackingSessions.begin(); it2 != mTrackingSessions.end(); ++it2) { // if session is not the one we are updating and either smallest interval is not set // or there is a new smallest interval, then set the new smallest interval if (it2->first != key && (0 == smallestIntervalOptions.size || it2->second.minInterval < smallestIntervalOptions.minInterval)) { smallestIntervalOptions = it2->second; } } // if session we are updating has smaller interval then next smallest if (options.minInterval < smallestIntervalOptions.minInterval) { // restart time based tracking with the newly updated interval err = startTracking(options); // else if the session we are updating used to be the smallest } else if (it->second.minInterval < smallestIntervalOptions.minInterval) { // restart time based tracking with the next smallest err = startTracking(smallestIntervalOptions); } } } return err; } void GnssAdapter::stopTrackingCommand(LocationAPI* client, uint32_t id) { LOC_LOGD("%s]: client %p id %u", __func__, client, id); struct MsgStopTracking : public LocMsg { GnssAdapter& mAdapter; LocApiBase& mApi; LocationAPI* mClient; uint32_t mSessionId; inline MsgStopTracking(GnssAdapter& adapter, LocApiBase& api, LocationAPI* client, uint32_t sessionId) : LocMsg(), mAdapter(adapter), mApi(api), mClient(client), mSessionId(sessionId) {} inline virtual void proc() const { if (mAdapter.isTrackingSession(mClient, mSessionId)) { LocationError err = LOCATION_ERROR_SUCCESS; // Api doesn't support multiple clients for time based tracking, so mutiplex err = mAdapter.stopTrackingMultiplex(mClient, mSessionId); if (LOCATION_ERROR_SUCCESS == err) { mAdapter.eraseTrackingSession(mClient, mSessionId); } mAdapter.reportResponse(mClient, err, mSessionId); } // we do not reportResponse for the case where there is no existing tracking session // for the client and id being used, since stopTrackingCommand can be sent to both // GnssAdapter & FlpAdapter by LocationAPI and we want to avoid incorrect error response } }; sendMsg(new MsgStopTracking(*this, *mLocApi, client, id)); } LocationError GnssAdapter::stopTrackingMultiplex(LocationAPI* client, uint32_t id) { LocationError err = LOCATION_ERROR_SUCCESS; if (1 == mTrackingSessions.size()) { err = stopTracking(); } else { LocationSessionKey key(client, id); // get the session we are stopping auto it = mTrackingSessions.find(key); if (it != mTrackingSessions.end()) { // find the next smallest interval, other than the session we are stopping LocationOptions smallestIntervalOptions = {}; // size is 0 until set for the first time for (auto it2 = mTrackingSessions.begin(); it2 != mTrackingSessions.end(); ++it2) { // if session is not the one we are stopping and either smallest interval is not set // or there is a new smallest interval, then set the new smallest interval if (it2->first != key && (0 == smallestIntervalOptions.size || it2->second.minInterval < smallestIntervalOptions.minInterval)) { smallestIntervalOptions = it2->second; } } // if session we are stopping has smaller interval then next smallest if (it->second.minInterval < smallestIntervalOptions.minInterval) { // restart time based tracking with next smallest interval err = startTracking(smallestIntervalOptions); } } } return err; } LocationError GnssAdapter::stopTracking() { LocationError err = LOCATION_ERROR_SUCCESS; if (!mUlpProxy->sendStopFix()) { loc_api_adapter_err apiErr = mLocApi->stopFix(); if (LOC_API_ADAPTER_ERR_SUCCESS == apiErr) { err = LOCATION_ERROR_SUCCESS; } else { err = LOCATION_ERROR_GENERAL_FAILURE; } } return err; } void GnssAdapter::stopTrackingCommand() { LOC_LOGD("%s]: ", __func__); struct MsgStopTracking : public LocMsg { GnssAdapter& mAdapter; LocApiBase& mApi; inline MsgStopTracking(GnssAdapter& adapter, LocApiBase& api) : LocMsg(), mAdapter(adapter), mApi(api) {} inline virtual void proc() const { // clear the position mode LocPosMode mLocPosMode = {}; mLocPosMode.mode = LOC_POSITION_MODE_INVALID; mAdapter.setUlpPositionMode(mLocPosMode); // don't need to multiplex because ULP will do that for us if it is present mApi.stopFix(); } }; sendMsg(new MsgStopTracking(*this, *mLocApi)); } void GnssAdapter::getZppCommand() { LOC_LOGD("%s]: ", __func__); struct MsgGetZpp : public LocMsg { GnssAdapter& mAdapter; LocApiBase& mApi; inline MsgGetZpp(GnssAdapter& adapter, LocApiBase& api) : LocMsg(), mAdapter(adapter), mApi(api) {} inline virtual void proc() const { UlpLocation location = {}; LocPosTechMask techMask = LOC_POS_TECH_MASK_DEFAULT; GpsLocationExtended locationExtended = {}; locationExtended.size = sizeof(locationExtended); mApi.getBestAvailableZppFix(location.gpsLocation, techMask); //Mark the location source as from ZPP location.gpsLocation.flags |= LOCATION_HAS_SOURCE_INFO; location.position_source = ULP_LOCATION_IS_FROM_ZPP; mAdapter.getUlpProxy()->reportPosition(location, locationExtended, LOC_SESS_SUCCESS, techMask); } }; sendMsg(new MsgGetZpp(*this, *mLocApi)); } bool GnssAdapter::hasNiNotifyCallback(LocationAPI* client) { auto it = mClientData.find(client); return (it != mClientData.end() && it->second.gnssNiCb); } void GnssAdapter::gnssNiResponseCommand(LocationAPI* client, uint32_t id, GnssNiResponse response) { LOC_LOGD("%s]: client %p id %u response %u", __func__, client, id, response); struct MsgGnssNiResponse : public LocMsg { GnssAdapter& mAdapter; LocationAPI* mClient; uint32_t mSessionId; GnssNiResponse mResponse; inline MsgGnssNiResponse(GnssAdapter& adapter, LocationAPI* client, uint32_t sessionId, GnssNiResponse response) : LocMsg(), mAdapter(adapter), mClient(client), mSessionId(sessionId), mResponse(response) {} inline virtual void proc() const { NiData& niData = mAdapter.getNiData(); LocationError err = LOCATION_ERROR_SUCCESS; if (!mAdapter.hasNiNotifyCallback(mClient)) { err = LOCATION_ERROR_ID_UNKNOWN; } else { NiSession* pSession = NULL; if (mSessionId == niData.sessionEs.reqID && NULL != niData.sessionEs.rawRequest) { pSession = &niData.sessionEs; // ignore any SUPL NI non-Es session if a SUPL NI ES is accepted if (mResponse == GNSS_NI_RESPONSE_ACCEPT && NULL != niData.session.rawRequest) { pthread_mutex_lock(&niData.session.tLock); niData.session.resp = GNSS_NI_RESPONSE_IGNORE; niData.session.respRecvd = true; pthread_cond_signal(&niData.session.tCond); pthread_mutex_unlock(&niData.session.tLock); } } else if (mSessionId == niData.session.reqID && NULL != niData.session.rawRequest) { pSession = &niData.session; } if (pSession) { LOC_LOGI("%s]: gnssNiResponseCommand: send user mResponse %u for id %u", __func__, mResponse, mSessionId); pthread_mutex_lock(&pSession->tLock); pSession->resp = mResponse; pSession->respRecvd = true; pthread_cond_signal(&pSession->tCond); pthread_mutex_unlock(&pSession->tLock); } else { err = LOCATION_ERROR_ID_UNKNOWN; LOC_LOGE("%s]: gnssNiResponseCommand: id %u not an active session", __func__, mSessionId); } } mAdapter.reportResponse(mClient, err, mSessionId); } }; sendMsg(new MsgGnssNiResponse(*this, client, id, response)); } void GnssAdapter::gnssNiResponseCommand(GnssNiResponse response, void* rawRequest) { LOC_LOGD("%s]: response %u", __func__, response); struct MsgGnssNiResponse : public LocMsg { LocApiBase& mApi; const GnssNiResponse mResponse; const void* mPayload; inline MsgGnssNiResponse(LocApiBase& api, const GnssNiResponse response, const void* rawRequest) : LocMsg(), mApi(api), mResponse(response), mPayload(rawRequest) {} inline virtual ~MsgGnssNiResponse() { // this is a bit weird since mPayload is not // allocated by this class. But there is no better way. // mPayload actually won't be NULL here. free((void*)mPayload); } inline virtual void proc() const { mApi.informNiResponse(mResponse, mPayload); } }; sendMsg(new MsgGnssNiResponse(*mLocApi, response, rawRequest)); } uint32_t GnssAdapter::enableCommand(LocationTechnologyType techType) { uint32_t sessionId = generateSessionId(); LOC_LOGD("%s]: id %u techType %u", __func__, sessionId, techType); struct MsgEnableGnss : public LocMsg { GnssAdapter& mAdapter; LocApiBase& mApi; ContextBase& mContext; uint32_t mSessionId; LocationTechnologyType mTechType; inline MsgEnableGnss(GnssAdapter& adapter, LocApiBase& api, ContextBase& context, uint32_t sessionId, LocationTechnologyType techType) : LocMsg(), mAdapter(adapter), mApi(api), mContext(context), mSessionId(sessionId), mTechType(techType) {} inline virtual void proc() const { LocationError err = LOCATION_ERROR_SUCCESS; uint32_t powerVoteId = mAdapter.getPowerVoteId(); if (mTechType != LOCATION_TECHNOLOGY_TYPE_GNSS) { err = LOCATION_ERROR_INVALID_PARAMETER; } else if (powerVoteId > 0) { err = LOCATION_ERROR_ALREADY_STARTED; } else { mContext.modemPowerVote(true); mAdapter.setPowerVoteId(mSessionId); mApi.setGpsLock(GNSS_CONFIG_GPS_LOCK_NONE); } mAdapter.reportResponse(err, mSessionId); } }; if (mContext != NULL) { sendMsg(new MsgEnableGnss(*this, *mLocApi, *mContext, sessionId, techType)); } else { LOC_LOGE("%s]: Context is NULL", __func__); } return sessionId; } void GnssAdapter::disableCommand(uint32_t id) { LOC_LOGD("%s]: id %u", __func__, id); struct MsgDisableGnss : public LocMsg { GnssAdapter& mAdapter; LocApiBase& mApi; ContextBase& mContext; uint32_t mSessionId; inline MsgDisableGnss(GnssAdapter& adapter, LocApiBase& api, ContextBase& context, uint32_t sessionId) : LocMsg(), mAdapter(adapter), mApi(api), mContext(context), mSessionId(sessionId) {} inline virtual void proc() const { LocationError err = LOCATION_ERROR_SUCCESS; uint32_t powerVoteId = mAdapter.getPowerVoteId(); if (powerVoteId != mSessionId) { err = LOCATION_ERROR_ID_UNKNOWN; } else { mContext.modemPowerVote(false); mAdapter.setPowerVoteId(0); mApi.setGpsLock(mAdapter.convertGpsLock(ContextBase::mGps_conf.GPS_LOCK)); } mAdapter.reportResponse(err, mSessionId); } }; if (mContext != NULL) { sendMsg(new MsgDisableGnss(*this, *mLocApi, *mContext, id)); } } void GnssAdapter::reportPositionEvent(const UlpLocation& ulpLocation, const GpsLocationExtended& locationExtended, enum loc_sess_status status, LocPosTechMask techMask, bool fromUlp) { LOC_LOGD("%s]: fromUlp %u status %u", __func__, fromUlp, status); // if this event is not called from ULP, then try to call into ULP and return if successfull if (!fromUlp) { if (mUlpProxy->reportPosition(ulpLocation, locationExtended, status, techMask)) { return; } } struct MsgReportPosition : public LocMsg { GnssAdapter& mAdapter; const UlpLocation mUlpLocation; const GpsLocationExtended mLocationExtended; loc_sess_status mStatus; LocPosTechMask mTechMask; inline MsgReportPosition(GnssAdapter& adapter, const UlpLocation& ulpLocation, const GpsLocationExtended& locationExtended, loc_sess_status status, LocPosTechMask techMask) : LocMsg(), mAdapter(adapter), mUlpLocation(ulpLocation), mLocationExtended(locationExtended), mStatus(status), mTechMask(techMask) {} inline virtual void proc() const { // extract bug report info - this returns true if consumed by systemstatus SystemStatus* s = LocDualContext::getSystemStatus(); if ((nullptr != s) && (LOC_SESS_SUCCESS == mStatus)){ s->eventPosition(mUlpLocation, mLocationExtended); } mAdapter.reportPosition(mUlpLocation, mLocationExtended, mStatus, mTechMask); } }; sendMsg(new MsgReportPosition(*this, ulpLocation, locationExtended, status, techMask)); } void GnssAdapter::reportPosition(const UlpLocation& ulpLocation, const GpsLocationExtended& locationExtended, enum loc_sess_status status, LocPosTechMask techMask) { bool reported = false; // what's in the if is... (line by line) // 1. this is a final fix; and // 1.1 it is a Satellite fix; or // 1.2 it is a sensor fix // 2. (must be intermediate fix... implicit) // 2.1 we accepte intermediate; and // 2.2 it is NOT the case that // 2.2.1 there is inaccuracy; and // 2.2.2 we care about inaccuracy; and // 2.2.3 the inaccuracy exceeds our tolerance if ((LOC_SESS_SUCCESS == status && ((LOC_POS_TECH_MASK_SATELLITE | LOC_POS_TECH_MASK_SENSORS | LOC_POS_TECH_MASK_HYBRID) & techMask)) || (LOC_SESS_INTERMEDIATE == ContextBase::mGps_conf.INTERMEDIATE_POS && !((ulpLocation.gpsLocation.flags & LOC_GPS_LOCATION_HAS_ACCURACY) && (ContextBase::mGps_conf.ACCURACY_THRES != 0) && (ulpLocation.gpsLocation.accuracy > ContextBase::mGps_conf.ACCURACY_THRES)))) { if (locationExtended.flags & GPS_LOCATION_EXTENDED_HAS_GNSS_SV_USED_DATA) { mGnssSvIdUsedInPosAvail = true; mGnssSvIdUsedInPosition = locationExtended.gnss_sv_used_ids; } for (auto it=mClientData.begin(); it != mClientData.end(); ++it) { if (nullptr != it->second.trackingCb) { Location location = {}; convertLocation(location, ulpLocation.gpsLocation, locationExtended, techMask); it->second.trackingCb(location); } if (nullptr != it->second.gnssLocationInfoCb) { GnssLocationInfoNotification locationInfo = {}; convertLocationInfo(locationInfo, locationExtended); it->second.gnssLocationInfoCb(locationInfo); } } reported = true; } else { LOC_LOGI("%s: not reported. Status: %d, techMask: %d, flags %d, accuracy %f", __func__, (int)status, (int)techMask, (int)ulpLocation.gpsLocation.flags, (float)ulpLocation.gpsLocation.accuracy); } if (NMEA_PROVIDER_AP == ContextBase::mGps_conf.NMEA_PROVIDER && !mTrackingSessions.empty()) { uint8_t generate_nmea = (reported && status != LOC_SESS_FAILURE); std::vector<std::string> nmeaArraystr; loc_nmea_generate_pos(ulpLocation, locationExtended, generate_nmea, nmeaArraystr); for (auto sentence : nmeaArraystr) { reportNmea(sentence.c_str(), sentence.length()); } } // Free the allocated memory for rawData UlpLocation* gp = (UlpLocation*)&(ulpLocation); if (gp != NULL && gp->rawData != NULL) { delete (char*)gp->rawData; gp->rawData = NULL; gp->rawDataSize = 0; } } void GnssAdapter::reportSvEvent(const GnssSvNotification& svNotify, bool fromUlp) { LOC_LOGD("%s]: fromUlp %u", __func__, fromUlp); // if this event is not called from ULP, then try to call into ULP and return if successfull if (!fromUlp) { if (mUlpProxy->reportSv(svNotify)) { return; } } struct MsgReportSv : public LocMsg { GnssAdapter& mAdapter; const GnssSvNotification mSvNotify; inline MsgReportSv(GnssAdapter& adapter, const GnssSvNotification& svNotify) : LocMsg(), mAdapter(adapter), mSvNotify(svNotify) {} inline virtual void proc() const { mAdapter.reportSv((GnssSvNotification&)mSvNotify); } }; sendMsg(new MsgReportSv(*this, svNotify)); } void GnssAdapter::reportSv(GnssSvNotification& svNotify) { int numSv = svNotify.count; int16_t gnssSvId = 0; uint64_t svUsedIdMask = 0; for (int i=0; i < numSv; i++) { svUsedIdMask = 0; gnssSvId = svNotify.gnssSvs[i].svId; switch (svNotify.gnssSvs[i].type) { case GNSS_SV_TYPE_GPS: if (mGnssSvIdUsedInPosAvail) { svUsedIdMask = mGnssSvIdUsedInPosition.gps_sv_used_ids_mask; } break; case GNSS_SV_TYPE_GLONASS: if (mGnssSvIdUsedInPosAvail) { svUsedIdMask = mGnssSvIdUsedInPosition.glo_sv_used_ids_mask; } break; case GNSS_SV_TYPE_BEIDOU: if (mGnssSvIdUsedInPosAvail) { svUsedIdMask = mGnssSvIdUsedInPosition.bds_sv_used_ids_mask; } break; case GNSS_SV_TYPE_GALILEO: if (mGnssSvIdUsedInPosAvail) { svUsedIdMask = mGnssSvIdUsedInPosition.gal_sv_used_ids_mask; } break; case GNSS_SV_TYPE_QZSS: if (mGnssSvIdUsedInPosAvail) { svUsedIdMask = mGnssSvIdUsedInPosition.qzss_sv_used_ids_mask; } // QZSS SV id's need to reported as it is to framework, since // framework expects it as it is. See GnssStatus.java. // SV id passed to here by LocApi is 1-based. svNotify.gnssSvs[i].svId += (QZSS_SV_PRN_MIN - 1); break; default: svUsedIdMask = 0; break; } // If SV ID was used in previous position fix, then set USED_IN_FIX // flag, else clear the USED_IN_FIX flag. if (svUsedIdMask & (1 << (gnssSvId - 1))) { svNotify.gnssSvs[i].gnssSvOptionsMask |= GNSS_SV_OPTIONS_USED_IN_FIX_BIT; } } for (auto it=mClientData.begin(); it != mClientData.end(); ++it) { if (nullptr != it->second.gnssSvCb) { it->second.gnssSvCb(svNotify); } } if (NMEA_PROVIDER_AP == ContextBase::mGps_conf.NMEA_PROVIDER && !mTrackingSessions.empty()) { std::vector<std::string> nmeaArraystr; loc_nmea_generate_sv(svNotify, nmeaArraystr); for (auto sentence : nmeaArraystr) { reportNmea(sentence.c_str(), sentence.length()); } } mGnssSvIdUsedInPosAvail = false; } void GnssAdapter::reportNmeaEvent(const char* nmea, size_t length, bool fromUlp) { // if this event is not called from ULP, then try to call into ULP and return if successfull if (!fromUlp && !loc_nmea_is_debug(nmea, length)) { if (mUlpProxy->reportNmea(nmea, length)) { return; } } struct MsgReportNmea : public LocMsg { GnssAdapter& mAdapter; const char* mNmea; size_t mLength; inline MsgReportNmea(GnssAdapter& adapter, const char* nmea, size_t length) : LocMsg(), mAdapter(adapter), mNmea(new char[length+1]), mLength(length) { strlcpy((char*)mNmea, nmea, length+1); } inline virtual ~MsgReportNmea() { delete[] mNmea; } inline virtual void proc() const { // extract bug report info - this returns true if consumed by systemstatus bool ret = false; SystemStatus* s = LocDualContext::getSystemStatus(); if (nullptr != s) { ret = s->setNmeaString(mNmea, mLength); } if (false == ret) { // forward NMEA message to upper layer mAdapter.reportNmea(mNmea, mLength); } } }; sendMsg(new MsgReportNmea(*this, nmea, length)); } void GnssAdapter::reportNmea(const char* nmea, size_t length) { GnssNmeaNotification nmeaNotification = {}; nmeaNotification.size = sizeof(GnssNmeaNotification); struct timeval tv; gettimeofday(&tv, (struct timezone *) NULL); int64_t now = tv.tv_sec * 1000LL + tv.tv_usec / 1000; nmeaNotification.timestamp = now; nmeaNotification.nmea = nmea; nmeaNotification.length = length; for (auto it=mClientData.begin(); it != mClientData.end(); ++it) { if (nullptr != it->second.gnssNmeaCb) { it->second.gnssNmeaCb(nmeaNotification); } } } bool GnssAdapter::requestNiNotifyEvent(const GnssNiNotification &notify, const void* data) { LOC_LOGI("%s]: notif_type: %d, timeout: %d, default_resp: %d" "requestor_id: %s (encoding: %d) text: %s text (encoding: %d) extras: %s", __func__, notify.type, notify.timeout, notify.timeoutResponse, notify.requestor, notify.requestorEncoding, notify.message, notify.messageEncoding, notify.extras); struct MsgReportNiNotify : public LocMsg { GnssAdapter& mAdapter; const GnssNiNotification mNotify; const void* mData; inline MsgReportNiNotify(GnssAdapter& adapter, const GnssNiNotification& notify, const void* data) : LocMsg(), mAdapter(adapter), mNotify(notify), mData(data) {} inline virtual void proc() const { mAdapter.requestNiNotify(mNotify, mData); } }; sendMsg(new MsgReportNiNotify(*this, notify, data)); return true; } static void* niThreadProc(void *args) { NiSession* pSession = (NiSession*)args; int rc = 0; /* return code from pthread calls */ struct timeval present_time; struct timespec expire_time; pthread_mutex_lock(&pSession->tLock); /* Calculate absolute expire time */ gettimeofday(&present_time, NULL); expire_time.tv_sec = present_time.tv_sec + pSession->respTimeLeft; expire_time.tv_nsec = present_time.tv_usec * 1000; LOC_LOGD("%s]: time out set for abs time %ld with delay %d sec", __func__, (long)expire_time.tv_sec, pSession->respTimeLeft); while (!pSession->respRecvd) { rc = pthread_cond_timedwait(&pSession->tCond, &pSession->tLock, &expire_time); if (rc == ETIMEDOUT) { pSession->resp = GNSS_NI_RESPONSE_NO_RESPONSE; LOC_LOGD("%s]: time out after valting for specified time. Ret Val %d", __func__, rc); break; } } LOC_LOGD("%s]: Java layer has sent us a user response and return value from " "pthread_cond_timedwait = %d pSession->resp is %u", __func__, rc, pSession->resp); pSession->respRecvd = false; /* Reset the user response flag for the next session*/ // adding this check to support modem restart, in which case, we need the thread // to exit without calling sending data. We made sure that rawRequest is NULL in // loc_eng_ni_reset_on_engine_restart() GnssAdapter* adapter = pSession->adapter; GnssNiResponse resp; void* rawRequest = NULL; bool sendResponse = false; if (NULL != pSession->rawRequest) { if (pSession->resp != GNSS_NI_RESPONSE_IGNORE) { resp = pSession->resp; rawRequest = pSession->rawRequest; sendResponse = true; } else { free(pSession->rawRequest); } pSession->rawRequest = NULL; } pthread_mutex_unlock(&pSession->tLock); pSession->respTimeLeft = 0; pSession->reqID = 0; if (sendResponse) { adapter->gnssNiResponseCommand(resp, rawRequest); } return NULL; } bool GnssAdapter::requestNiNotify(const GnssNiNotification& notify, const void* data) { NiSession* pSession = NULL; gnssNiCallback gnssNiCb = nullptr; for (auto it=mClientData.begin(); it != mClientData.end(); ++it) { if (nullptr != it->second.gnssNiCb) { gnssNiCb = it->second.gnssNiCb; break; } } if (nullptr == gnssNiCb) { EXIT_LOG(%s, "no clients with gnssNiCb."); return false; } if (notify.type == GNSS_NI_TYPE_EMERGENCY_SUPL) { if (NULL != mNiData.sessionEs.rawRequest) { LOC_LOGI("%s]: supl es NI in progress, new supl es NI ignored, type: %d", __func__, notify.type); if (NULL != data) { free((void*)data); } } else { pSession = &mNiData.sessionEs; } } else { if (NULL != mNiData.session.rawRequest || NULL != mNiData.sessionEs.rawRequest) { LOC_LOGI("%s]: supl NI in progress, new supl NI ignored, type: %d", __func__, notify.type); if (NULL != data) { free((void*)data); } } else { pSession = &mNiData.session; } } if (pSession) { /* Save request */ pSession->rawRequest = (void*)data; pSession->reqID = ++mNiData.reqIDCounter; pSession->adapter = this; int sessionId = pSession->reqID; /* For robustness, spawn a thread at this point to timeout to clear up the notification * status, even though the OEM layer in java does not do so. **/ pSession->respTimeLeft = 5 + (notify.timeout != 0 ? notify.timeout : LOC_NI_NO_RESPONSE_TIME); int rc = 0; rc = pthread_create(&pSession->thread, NULL, niThreadProc, pSession); if (rc) { LOC_LOGE("%s]: Loc NI thread is not created.", __func__); } rc = pthread_detach(pSession->thread); if (rc) { LOC_LOGE("%s]: Loc NI thread is not detached.", __func__); } if (nullptr != gnssNiCb) { gnssNiCb(sessionId, notify); } } return true; } void GnssAdapter::reportGnssMeasurementDataEvent(const GnssMeasurementsNotification& measurementsNotify) { LOC_LOGD("%s]: ", __func__); struct MsgReportGnssMeasurementData : public LocMsg { GnssAdapter& mAdapter; const GnssMeasurementsNotification mMeasurementsNotify; inline MsgReportGnssMeasurementData(GnssAdapter& adapter, const GnssMeasurementsNotification& measurementsNotify) : LocMsg(), mAdapter(adapter), mMeasurementsNotify(measurementsNotify) {} inline virtual void proc() const { mAdapter.reportGnssMeasurementData(mMeasurementsNotify); } }; sendMsg(new MsgReportGnssMeasurementData(*this, measurementsNotify)); } void GnssAdapter::reportGnssMeasurementData(const GnssMeasurementsNotification& measurementsNotify) { for (auto it=mClientData.begin(); it != mClientData.end(); ++it) { if (nullptr != it->second.gnssMeasurementsCb) { it->second.gnssMeasurementsCb(measurementsNotify); } } } void GnssAdapter::reportSvMeasurementEvent(GnssSvMeasurementSet &svMeasurementSet) { LOC_LOGD("%s]: ", __func__); // We send SvMeasurementSet to AmtProxy/ULPProxy to be forwarded as necessary. mUlpProxy->reportSvMeasurement(svMeasurementSet); } void GnssAdapter::reportSvPolynomialEvent(GnssSvPolynomial &svPolynomial) { LOC_LOGD("%s]: ", __func__); // We send SvMeasurementSet to AmtProxy/ULPProxy to be forwarded as necessary. mUlpProxy->reportSvPolynomial(svPolynomial); } /* INIT LOC AGPS MANAGER */ void GnssAdapter::initAgpsCommand(void* statusV4Cb){ LOC_LOGI("GnssAdapter::initAgpsCommand"); /* Set ATL open/close callbacks */ AgpsAtlOpenStatusCb atlOpenStatusCb = [this](int handle, int isSuccess, char* apn, AGpsBearerType bearerType, AGpsExtType agpsType) { mLocApi->atlOpenStatus( handle, isSuccess, apn, bearerType, agpsType); }; AgpsAtlCloseStatusCb atlCloseStatusCb = [this](int handle, int isSuccess) { mLocApi->atlCloseStatus(handle, isSuccess); }; /* Register DS Client APIs */ AgpsDSClientInitFn dsClientInitFn = [this](bool isDueToSSR) { return mLocApi->initDataServiceClient(isDueToSSR); }; AgpsDSClientOpenAndStartDataCallFn dsClientOpenAndStartDataCallFn = [this] { return mLocApi->openAndStartDataCall(); }; AgpsDSClientStopDataCallFn dsClientStopDataCallFn = [this] { mLocApi->stopDataCall(); }; AgpsDSClientCloseDataCallFn dsClientCloseDataCallFn = [this] { mLocApi->closeDataCall(); }; AgpsDSClientReleaseFn dsClientReleaseFn = [this] { mLocApi->releaseDataServiceClient(); }; /* Send Msg function */ SendMsgToAdapterMsgQueueFn sendMsgFn = [this](LocMsg* msg) { sendMsg(msg); }; /* Message to initialize AGPS module */ struct AgpsMsgInit: public LocMsg { AgpsManager* mAgpsManager; AgpsFrameworkInterface::AgnssStatusIpV4Cb mFrameworkStatusV4Cb; AgpsAtlOpenStatusCb mAtlOpenStatusCb; AgpsAtlCloseStatusCb mAtlCloseStatusCb; AgpsDSClientInitFn mDSClientInitFn; AgpsDSClientOpenAndStartDataCallFn mDSClientOpenAndStartDataCallFn; AgpsDSClientStopDataCallFn mDSClientStopDataCallFn; AgpsDSClientCloseDataCallFn mDSClientCloseDataCallFn; AgpsDSClientReleaseFn mDSClientReleaseFn; SendMsgToAdapterMsgQueueFn mSendMsgFn; GnssAdapter& mAdapter; inline AgpsMsgInit(AgpsManager* agpsManager, AgpsFrameworkInterface::AgnssStatusIpV4Cb frameworkStatusV4Cb, AgpsAtlOpenStatusCb atlOpenStatusCb, AgpsAtlCloseStatusCb atlCloseStatusCb, AgpsDSClientInitFn dsClientInitFn, AgpsDSClientOpenAndStartDataCallFn dsClientOpenAndStartDataCallFn, AgpsDSClientStopDataCallFn dsClientStopDataCallFn, AgpsDSClientCloseDataCallFn dsClientCloseDataCallFn, AgpsDSClientReleaseFn dsClientReleaseFn, SendMsgToAdapterMsgQueueFn sendMsgFn, GnssAdapter& adapter) : LocMsg(), mAgpsManager(agpsManager), mFrameworkStatusV4Cb( frameworkStatusV4Cb), mAtlOpenStatusCb(atlOpenStatusCb), mAtlCloseStatusCb( atlCloseStatusCb), mDSClientInitFn(dsClientInitFn), mDSClientOpenAndStartDataCallFn( dsClientOpenAndStartDataCallFn), mDSClientStopDataCallFn( dsClientStopDataCallFn), mDSClientCloseDataCallFn( dsClientCloseDataCallFn), mDSClientReleaseFn( dsClientReleaseFn), mSendMsgFn(sendMsgFn), mAdapter(adapter) { LOC_LOGV("AgpsMsgInit"); } inline virtual void proc() const { LOC_LOGV("AgpsMsgInit::proc()"); mAgpsManager->registerCallbacks(mFrameworkStatusV4Cb, mAtlOpenStatusCb, mAtlCloseStatusCb, mDSClientInitFn, mDSClientOpenAndStartDataCallFn, mDSClientStopDataCallFn, mDSClientCloseDataCallFn, mDSClientReleaseFn, mSendMsgFn); mAgpsManager->createAgpsStateMachines(); /* Register for AGPS event mask */ mAdapter.updateEvtMask(LOC_API_ADAPTER_BIT_LOCATION_SERVER_REQUEST, LOC_REGISTRATION_MASK_ENABLED); } }; /* Send message to initialize AGPS Manager */ sendMsg(new AgpsMsgInit( &mAgpsManager, (AgpsFrameworkInterface::AgnssStatusIpV4Cb)statusV4Cb, atlOpenStatusCb, atlCloseStatusCb, dsClientInitFn, dsClientOpenAndStartDataCallFn, dsClientStopDataCallFn, dsClientCloseDataCallFn, dsClientReleaseFn, sendMsgFn, *this)); } /* GnssAdapter::requestATL * Method triggered in QMI thread as part of handling below message: * eQMI_LOC_SERVER_REQUEST_OPEN_V02 * Triggers the AGPS state machine to setup AGPS call for below WWAN types: * eQMI_LOC_WWAN_TYPE_INTERNET_V02 * eQMI_LOC_WWAN_TYPE_AGNSS_V02 */ bool GnssAdapter::requestATL(int connHandle, LocAGpsType agpsType){ LOC_LOGI("GnssAdapter::requestATL"); sendMsg( new AgpsMsgRequestATL( &mAgpsManager, connHandle, (AGpsExtType)agpsType)); return true; } /* GnssAdapter::requestSuplES * Method triggered in QMI thread as part of handling below message: * eQMI_LOC_SERVER_REQUEST_OPEN_V02 * Triggers the AGPS state machine to setup AGPS call for below WWAN types: * eQMI_LOC_WWAN_TYPE_AGNSS_EMERGENCY_V02 */ bool GnssAdapter::requestSuplES(int connHandle){ LOC_LOGI("GnssAdapter::requestSuplES"); sendMsg( new AgpsMsgRequestATL( &mAgpsManager, connHandle, LOC_AGPS_TYPE_SUPL_ES)); return true; } /* GnssAdapter::releaseATL * Method triggered in QMI thread as part of handling below message: * eQMI_LOC_SERVER_REQUEST_CLOSE_V02 * Triggers teardown of an existing AGPS call */ bool GnssAdapter::releaseATL(int connHandle){ LOC_LOGI("GnssAdapter::releaseATL"); /* Release SUPL/INTERNET/SUPL_ES ATL */ struct AgpsMsgReleaseATL: public LocMsg { AgpsManager* mAgpsManager; int mConnHandle; inline AgpsMsgReleaseATL(AgpsManager* agpsManager, int connHandle) : LocMsg(), mAgpsManager(agpsManager), mConnHandle(connHandle) { LOC_LOGV("AgpsMsgReleaseATL"); } inline virtual void proc() const { LOC_LOGV("AgpsMsgReleaseATL::proc()"); mAgpsManager->releaseATL(mConnHandle); } }; sendMsg( new AgpsMsgReleaseATL(&mAgpsManager, connHandle)); return true; } /* GnssAdapter::reportDataCallOpened * DS Client data call opened successfully. * Send message to AGPS Manager to handle. */ bool GnssAdapter::reportDataCallOpened(){ LOC_LOGI("GnssAdapter::reportDataCallOpened"); struct AgpsMsgSuplEsOpened: public LocMsg { AgpsManager* mAgpsManager; inline AgpsMsgSuplEsOpened(AgpsManager* agpsManager) : LocMsg(), mAgpsManager(agpsManager) { LOC_LOGV("AgpsMsgSuplEsOpened"); } inline virtual void proc() const { LOC_LOGV("AgpsMsgSuplEsOpened::proc()"); mAgpsManager->reportDataCallOpened(); } }; sendMsg( new AgpsMsgSuplEsOpened(&mAgpsManager)); return true; } /* GnssAdapter::reportDataCallClosed * DS Client data call closed. * Send message to AGPS Manager to handle. */ bool GnssAdapter::reportDataCallClosed(){ LOC_LOGI("GnssAdapter::reportDataCallClosed"); struct AgpsMsgSuplEsClosed: public LocMsg { AgpsManager* mAgpsManager; inline AgpsMsgSuplEsClosed(AgpsManager* agpsManager) : LocMsg(), mAgpsManager(agpsManager) { LOC_LOGV("AgpsMsgSuplEsClosed"); } inline virtual void proc() const { LOC_LOGV("AgpsMsgSuplEsClosed::proc()"); mAgpsManager->reportDataCallClosed(); } }; sendMsg( new AgpsMsgSuplEsClosed(&mAgpsManager)); return true; } void GnssAdapter::dataConnOpenCommand( AGpsExtType agpsType, const char* apnName, int apnLen, LocApnIpType ipType){ LOC_LOGI("GnssAdapter::frameworkDataConnOpen"); struct AgpsMsgAtlOpenSuccess: public LocMsg { AgpsManager* mAgpsManager; AGpsExtType mAgpsType; char* mApnName; int mApnLen; LocApnIpType mIpType; inline AgpsMsgAtlOpenSuccess(AgpsManager* agpsManager, AGpsExtType agpsType, const char* apnName, int apnLen, LocApnIpType ipType) : LocMsg(), mAgpsManager(agpsManager), mAgpsType(agpsType), mApnName( new char[apnLen + 1]), mApnLen(apnLen), mIpType(ipType) { LOC_LOGV("AgpsMsgAtlOpenSuccess"); memcpy(mApnName, apnName, apnLen); mApnName[apnLen] = 0; } inline ~AgpsMsgAtlOpenSuccess() { delete[] mApnName; } inline virtual void proc() const { LOC_LOGV("AgpsMsgAtlOpenSuccess::proc()"); mAgpsManager->reportAtlOpenSuccess(mAgpsType, mApnName, mApnLen, mIpType); } }; sendMsg( new AgpsMsgAtlOpenSuccess( &mAgpsManager, (AGpsExtType)agpsType, apnName, apnLen, ipType)); } void GnssAdapter::dataConnClosedCommand(AGpsExtType agpsType){ LOC_LOGI("GnssAdapter::frameworkDataConnClosed"); struct AgpsMsgAtlClosed: public LocMsg { AgpsManager* mAgpsManager; AGpsExtType mAgpsType; inline AgpsMsgAtlClosed(AgpsManager* agpsManager, AGpsExtType agpsType) : LocMsg(), mAgpsManager(agpsManager), mAgpsType(agpsType) { LOC_LOGV("AgpsMsgAtlClosed"); } inline virtual void proc() const { LOC_LOGV("AgpsMsgAtlClosed::proc()"); mAgpsManager->reportAtlClosed(mAgpsType); } }; sendMsg( new AgpsMsgAtlClosed(&mAgpsManager, (AGpsExtType)agpsType)); } void GnssAdapter::dataConnFailedCommand(AGpsExtType agpsType){ LOC_LOGI("GnssAdapter::frameworkDataConnFailed"); struct AgpsMsgAtlOpenFailed: public LocMsg { AgpsManager* mAgpsManager; AGpsExtType mAgpsType; inline AgpsMsgAtlOpenFailed(AgpsManager* agpsManager, AGpsExtType agpsType) : LocMsg(), mAgpsManager(agpsManager), mAgpsType(agpsType) { LOC_LOGV("AgpsMsgAtlOpenFailed"); } inline virtual void proc() const { LOC_LOGV("AgpsMsgAtlOpenFailed::proc()"); mAgpsManager->reportAtlOpenFailed(mAgpsType); } }; sendMsg( new AgpsMsgAtlOpenFailed(&mAgpsManager, (AGpsExtType)agpsType)); } void GnssAdapter::convertSatelliteInfo(std::vector<GnssDebugSatelliteInfo>& out, const GnssSvType& in_constellation, const SystemStatusReports& in) { uint64_t sv_mask = 0ULL; uint32_t svid_min = 0; uint32_t svid_num = 0; uint32_t svid_idx = 0; uint64_t eph_health_good_mask = 0ULL; uint64_t eph_health_bad_mask = 0ULL; uint64_t server_perdiction_available_mask = 0ULL; float server_perdiction_age = 0.0f; // set constellationi based parameters switch (in_constellation) { case GNSS_SV_TYPE_GPS: svid_min = GNSS_BUGREPORT_GPS_MIN; svid_num = GPS_NUM; svid_idx = 0; if (!in.mSvHealth.empty()) { eph_health_good_mask = in.mSvHealth.back().mGpsGoodMask; eph_health_bad_mask = in.mSvHealth.back().mGpsBadMask; } if (!in.mXtra.empty()) { server_perdiction_available_mask = in.mXtra.back().mGpsXtraValid; server_perdiction_age = (float)(in.mXtra.back().mGpsXtraAge); } break; case GNSS_SV_TYPE_GLONASS: svid_min = GNSS_BUGREPORT_GLO_MIN; svid_num = GLO_NUM; svid_idx = GPS_NUM; if (!in.mSvHealth.empty()) { eph_health_good_mask = in.mSvHealth.back().mGloGoodMask; eph_health_bad_mask = in.mSvHealth.back().mGloBadMask; } if (!in.mXtra.empty()) { server_perdiction_available_mask = in.mXtra.back().mGloXtraValid; server_perdiction_age = (float)(in.mXtra.back().mGloXtraAge); } break; case GNSS_SV_TYPE_QZSS: svid_min = GNSS_BUGREPORT_QZSS_MIN; svid_num = QZSS_NUM; svid_idx = GPS_NUM+GLO_NUM+BDS_NUM+GAL_NUM; if (!in.mSvHealth.empty()) { eph_health_good_mask = in.mSvHealth.back().mQzssGoodMask; eph_health_bad_mask = in.mSvHealth.back().mQzssBadMask; } if (!in.mXtra.empty()) { server_perdiction_available_mask = in.mXtra.back().mQzssXtraValid; server_perdiction_age = (float)(in.mXtra.back().mQzssXtraAge); } break; case GNSS_SV_TYPE_BEIDOU: svid_min = GNSS_BUGREPORT_BDS_MIN; svid_num = BDS_NUM; svid_idx = GPS_NUM+GLO_NUM; if (!in.mSvHealth.empty()) { eph_health_good_mask = in.mSvHealth.back().mBdsGoodMask; eph_health_bad_mask = in.mSvHealth.back().mBdsBadMask; } if (!in.mXtra.empty()) { server_perdiction_available_mask = in.mXtra.back().mBdsXtraValid; server_perdiction_age = (float)(in.mXtra.back().mBdsXtraAge); } break; case GNSS_SV_TYPE_GALILEO: svid_min = GNSS_BUGREPORT_GAL_MIN; svid_num = GAL_NUM; svid_idx = GPS_NUM+GLO_NUM+BDS_NUM; if (!in.mSvHealth.empty()) { eph_health_good_mask = in.mSvHealth.back().mGalGoodMask; eph_health_bad_mask = in.mSvHealth.back().mGalBadMask; } if (!in.mXtra.empty()) { server_perdiction_available_mask = in.mXtra.back().mGalXtraValid; server_perdiction_age = (float)(in.mXtra.back().mGalXtraAge); } break; default: return; } // extract each sv info from systemstatus report for(uint32_t i=0; i<svid_num; i++) { GnssDebugSatelliteInfo s = {}; s.size = sizeof(s); s.svid = i + svid_min; s.constellation = in_constellation; if (!in.mNavData.empty()) { s.mEphemerisType = in.mNavData.back().mNav[svid_idx+i].mType; s.mEphemerisSource = in.mNavData.back().mNav[svid_idx+i].mSource; } else { s.mEphemerisType = GNSS_EPH_TYPE_UNKNOWN; s.mEphemerisSource = GNSS_EPH_SOURCE_UNKNOWN; } sv_mask = 0x1ULL << i; if (eph_health_good_mask & sv_mask) { s.mEphemerisHealth = GNSS_EPH_HEALTH_GOOD; } else if (eph_health_bad_mask & sv_mask) { s.mEphemerisHealth = GNSS_EPH_HEALTH_BAD; } else { s.mEphemerisHealth = GNSS_EPH_HEALTH_UNKNOWN; } if (!in.mNavData.empty()) { s.ephemerisAgeSeconds = (float)(in.mNavData.back().mNav[svid_idx+i].mAgeSec); } else { s.ephemerisAgeSeconds = 0.0f; } if (server_perdiction_available_mask & sv_mask) { s.serverPredictionIsAvailable = true; } else { s.serverPredictionIsAvailable = false; } s.serverPredictionAgeSeconds = server_perdiction_age; out.push_back(s); } return; } bool GnssAdapter::getDebugReport(GnssDebugReport& r) { LOC_LOGD("%s]: ", __func__); SystemStatus* systemstatus = LocDualContext::getSystemStatus(); if (nullptr == systemstatus) { return false; } SystemStatusReports reports = {}; systemstatus->getReport(reports, true); r.size = sizeof(r); // location block r.mLocation.size = sizeof(r.mLocation); if(!reports.mLocation.empty() && reports.mLocation.back().mValid) { r.mLocation.mValid = true; r.mLocation.mLocation.latitude = reports.mLocation.back().mLocation.gpsLocation.latitude; r.mLocation.mLocation.longitude = reports.mLocation.back().mLocation.gpsLocation.longitude; r.mLocation.mLocation.altitude = reports.mLocation.back().mLocation.gpsLocation.altitude; r.mLocation.mLocation.speed = (double)(reports.mLocation.back().mLocation.gpsLocation.speed); r.mLocation.mLocation.bearing = (double)(reports.mLocation.back().mLocation.gpsLocation.bearing); r.mLocation.mLocation.accuracy = (double)(reports.mLocation.back().mLocation.gpsLocation.accuracy); r.mLocation.verticalAccuracyMeters = reports.mLocation.back().mLocationEx.vert_unc; r.mLocation.speedAccuracyMetersPerSecond = reports.mLocation.back().mLocationEx.speed_unc; r.mLocation.bearingAccuracyDegrees = reports.mLocation.back().mLocationEx.bearing_unc; r.mLocation.mUtcReported = reports.mLocation.back().mUtcReported; } else if(!reports.mBestPosition.empty() && reports.mBestPosition.back().mValid) { r.mLocation.mValid = true; r.mLocation.mLocation.latitude = (double)(reports.mBestPosition.back().mBestLat) * RAD2DEG; r.mLocation.mLocation.longitude = (double)(reports.mBestPosition.back().mBestLon) * RAD2DEG; r.mLocation.mLocation.altitude = reports.mBestPosition.back().mBestAlt; r.mLocation.mUtcReported = reports.mBestPosition.back().mUtcReported; } else { r.mLocation.mValid = false; } if (r.mLocation.mValid) { LOC_LOGV("getDebugReport - lat=%f lon=%f alt=%f speed=%f", r.mLocation.mLocation.latitude, r.mLocation.mLocation.longitude, r.mLocation.mLocation.altitude, r.mLocation.mLocation.speed); } // time block r.mTime.size = sizeof(r.mTime); if(!reports.mTimeAndClock.empty() && reports.mTimeAndClock.back().mTimeValid) { r.mTime.mValid = true; r.mTime.timeEstimate = (((int64_t)(reports.mTimeAndClock.back().mGpsWeek)*7 + GNSS_UTC_TIME_OFFSET)*24*60*60 - (int64_t)(reports.mTimeAndClock.back().mLeapSeconds))*1000ULL + (int64_t)(reports.mTimeAndClock.back().mGpsTowMs); r.mTime.timeUncertaintyNs = (float)((reports.mTimeAndClock.back().mTimeUnc + reports.mTimeAndClock.back().mLeapSecUnc)*1000); r.mTime.frequencyUncertaintyNsPerSec = (float)(reports.mTimeAndClock.back().mClockFreqBiasUnc); LOC_LOGV("getDebugReport - timeestimate=%ld unc=%f frequnc=%f", r.mTime.timeEstimate, r.mTime.timeUncertaintyNs, r.mTime.frequencyUncertaintyNsPerSec); } else { r.mTime.mValid = false; } // satellite info block convertSatelliteInfo(r.mSatelliteInfo, GNSS_SV_TYPE_GPS, reports); convertSatelliteInfo(r.mSatelliteInfo, GNSS_SV_TYPE_GLONASS, reports); convertSatelliteInfo(r.mSatelliteInfo, GNSS_SV_TYPE_QZSS, reports); convertSatelliteInfo(r.mSatelliteInfo, GNSS_SV_TYPE_BEIDOU, reports); convertSatelliteInfo(r.mSatelliteInfo, GNSS_SV_TYPE_GALILEO, reports); LOC_LOGV("getDebugReport - satellite=%lu", r.mSatelliteInfo.size()); return true; }
[ "mingxin.android@gmail.com" ]
mingxin.android@gmail.com
2d325b0310706e921cdadd2f960c1985d83c81df
a303be0a547d717b0deb19b5bdcc75010e131b51
/dp/dp_bit_masking1.cpp
da44750b8ac91910a0830cddbdc5b635e3dad125
[]
no_license
harrypotter0/competitive-programming
ff883c4dc5aa8d72f1af589bb654a422e32c8a38
82a8497e69212dc62e75af74b0d5a3b390b8aca2
refs/heads/master
2023-03-23T07:07:14.295053
2021-03-17T01:24:45
2021-03-17T01:24:45
70,964,689
16
9
null
2021-03-17T01:24:49
2016-10-15T03:52:53
Python
UTF-8
C++
false
false
1,392
cpp
#include <bits/stdc++.h> using namespace std; const int inf = 1e9; // Poori Duniya bhadwi hai int dp[15][100][1 << 15]; int n; struct edge { int u, v, w, energy; edge(int a, int b, int c, int d) { u = a, v = b, w = c, energy = d; } }; vector<edge> graph[20]; // O(2^n*n^2*E) int solve(int u, int mask, int energy) { if (mask == ((1 << n) - 1)) // if mask is the last one return 0 or inf for addition return energy >= 0 ? 0 : inf; if (energy <= 0) //if energy is negative you can't reach return inf; int& ret = dp[u][energy][mask]; if (ret != -1) return ret; ret = inf; // main loop for recursive calls for (edge e: graph[u]) {// O(E) int v = e.v, w = e.w, req_energy = e.energy; if (mask & (1 << v)) // check is vth bit is set continue; else ret = min(ret, solve(v, mask | (1 << v), energy - req_energy) + w); //O(2^n*n^2) } return ret; } int main(void) { int m, energy; memset(dp, -1, sizeof(dp)); scanf("%d %d %d", &n, &m, &energy); for (int i = 0; i < m; i++) { int u, v, w, en; scanf("%d %d %d %d", &u, &v, &w, &en); u--; v--; graph[u].push_back(edge(u, v, w, en)); graph[v].push_back(edge(v, u, w, en)); } int ans = solve(0, 1, energy); printf("%d\n", ans >= inf ? -1 : ans); return 0; }
[ "9654263057akashkandpal@gmail.com" ]
9654263057akashkandpal@gmail.com
87eedfff8aece916a28bd9c76c52ada3d2f24472
4d9e5b590eca7ae4099881d42112e811446cdb46
/20_ODBC_aw/output/application._ODBC_aw/BuildConfig/src/operator/ODBCAppend_3.cpp
fee22823714b85b49dd1d5205024e4810928eaaa
[]
no_license
cly1213/2019_NCTU_IBM_Streams_Course
c31b68515fab064f8252384a3dfee4e327dc000f
342d895f28b8f5d2c44aeadbf1989a50d0e80d1d
refs/heads/master
2022-01-23T08:59:19.474948
2019-07-24T11:50:28
2019-07-24T11:50:28
198,313,604
0
0
null
null
null
null
UTF-8
C++
false
false
20,254
cpp
// eJzFkU9z2jAQxUdfhekhvdiKSduEm7HzBxtIimCgXBhZ3gENtqSR1nXcT19BSSCnHDs6aff33rydJ3QdyKIOHFrgtQvKYjB4TodJbAyoklwT6t816QVBiJ2BcAhZa53Y0rvuLmes382TfTR9GjVj9iP7Qyne7n9P5oLS6Wj4_0nOVP8aL1becr7JsGRvWbZ_1yx3u_0yNg6fZi5e9PNluukqCvBPPFrUenJNG73iyxZVxv6nS2zUR6PbzY04TzY9Y5hSLjTNYRQNlEUttruneECwohuDrk3vA1LjpworYCSPhFaKRAotUq1aGpQ6M9hL_0PBwPqbpdp6y8vvVe_0oD1Pe3YRnsQte66r3lcToqaJBeLAAF_0afmU665J31Nv7jkPssXAhw7jN1ayXCXD_1bEuwMXFOhm_1OigkunQ1XSaItfTur_1VxWRxP7ritySY_0hRSaTCfkSSxqGvz055DeTt3LfhO_1ViddkI_1ACdZheMFOct20lzKJchx8adkMPQ_0G3K8UzSv3LpPXR #include "./ODBCAppend_3.h" using namespace SPL::_Operator; #include <SPL/Runtime/Function/SPLFunctions.h> #include <SPL/Runtime/Operator/Port/Punctuation.h> #define MY_OPERATOR_SCOPE SPL::_Operator #define MY_BASE_OPERATOR ODBCAppend_3_Base #define MY_OPERATOR ODBCAppend_3$OP MY_OPERATOR_SCOPE::MY_OPERATOR::MY_OPERATOR() : MY_BASE_OPERATOR() { SPLAPPTRC(L_DEBUG, "Constructor", SPL_OPER_DBG); // Init variables for Metrics OperatorMetrics &opm = getContext().getMetrics(); droppedTuples_ = &opm.getCustomMetricByName("droppedTuples"); // Init variables for SQL handles henv = SQL_NULL_HENV; hstmt[0] = SQL_NULL_HSTMT; hdbc = SQL_NULL_HDBC; // Init variables for SQL Connection Information connectionDatabase = "streams"; connectionUser = "db2inst1"; connectionPassword = "db2expr1"; // Attempt to connect to the DB if (!attemptODBCConnection()) { std::string msg = DB_OPERATOR_SHUTDOWN; SPLAPPLOG(L_ERROR, msg, SPL_OPER_DBG); throw ODBCOperatorShutdownException(); } SPLAPPTRC(L_DEBUG, "register ODBCAppend for governance", SPL_OPER_DBG); std::map<std::string,std::string> props; props["outputOperatorType"]="ODBCAppend"; props["srcName"]=connectionDatabase; props["srcType"]="database"; props["registerType"] = "output"; setTagData("OperatorIGC", props); } MY_OPERATOR_SCOPE::MY_OPERATOR::~MY_OPERATOR() { SPLAPPTRC(L_DEBUG, "Destructor", SPL_OPER_DBG); rc = SQLEndTran(SQL_HANDLE_DBC, hdbc, SQL_COMMIT); handleSQLRC(SQL_HANDLE_DBC, hdbc, rc); if (hstmt[0] != SQL_NULL_HSTMT) { SPLAPPTRC(L_DEBUG, "SQLFreeStmt(SQL_UNBIND)", SPL_OPER_DBG); rc = SQLFreeStmt(hstmt[0], SQL_UNBIND); handleSQLRC(SQL_HANDLE_STMT, hstmt[0], rc); SPLAPPTRC(L_DEBUG, "SQLFreeStmt(SQL_RESET_PARAMS)", SPL_OPER_DBG); rc = SQLFreeStmt(hstmt[0], SQL_RESET_PARAMS); handleSQLRC(SQL_HANDLE_STMT, hstmt[0], rc); SPLAPPTRC(L_DEBUG, "SQLFreeStmt(SQL_CLOSE)", SPL_OPER_DBG); rc = SQLFreeStmt(hstmt[0], SQL_CLOSE); handleSQLRC(SQL_HANDLE_STMT, hstmt[0], rc); SPLAPPTRC(L_DEBUG, "SQLFreeHandle(SQL_HANDLE_STMT)", SPL_OPER_DBG); rc = SQLFreeHandle(SQL_HANDLE_STMT, hstmt[0]); handleSQLRC(SQL_HANDLE_STMT, hstmt[0], rc); } hstmt[0] = SQL_NULL_HSTMT; if (hdbc != SQL_NULL_HDBC) { SPLAPPTRC(L_DEBUG, "SQLDisconnect", SPL_OPER_DBG); rc = SQLDisconnect(hdbc); handleSQLRC(SQL_HANDLE_DBC, hdbc, rc); SPLAPPTRC(L_DEBUG, "SQLFreeHandle(SQL_HANDLE_DBC)", SPL_OPER_DBG); rc = SQLFreeHandle(SQL_HANDLE_DBC, hdbc); handleSQLRC(SQL_HANDLE_DBC, hdbc, rc); hdbc = SQL_NULL_HDBC; } if (henv != SQL_NULL_HENV) { SPLAPPTRC(L_DEBUG, "SQLFreeHandle(SQL_HANDLE_ENV)", SPL_OPER_DBG); rc = SQLFreeHandle(SQL_HANDLE_ENV, henv); handleSQLRC(SQL_HANDLE_ENV, henv, rc); henv = SQL_NULL_HENV; } } void MY_OPERATOR_SCOPE::MY_OPERATOR::allPortsReady() { SPLAPPTRC(L_DEBUG, "allPortsReady", SPL_OPER_DBG); } void MY_OPERATOR_SCOPE::MY_OPERATOR::prepareToShutdown() { SPLAPPTRC(L_DEBUG, "prepareToShutdown", SPL_OPER_DBG); } void MY_OPERATOR_SCOPE::MY_OPERATOR::process(uint32_t idx) { SPLAPPTRC(L_DEBUG, "Process Thread (" << idx << ")", SPL_OPER_DBG); } void MY_OPERATOR_SCOPE::MY_OPERATOR::process(Tuple & tuple, uint32_t port) { // No mutable input streams } void MY_OPERATOR_SCOPE::MY_OPERATOR::process(Tuple const & tuple, uint32_t port) { SPLAPPTRC(L_TRACE, "Process Tuple " << tuple, SPL_OPER_DBG); const IPort0Type & iport$0 = static_cast<const IPort0Type &>(tuple); // Bind tuple attributes to columns orderidParam1[0][0] = (SQLINTEGER) iport$0.get_OrderId(); customernameParam2Length[0][0] = (iport$0.get_CustomerName().size() > 50) ? 50 : (int)iport$0.get_CustomerName().size(); strncpy( (char *) customernameParam2[0], ((std::string) iport$0.get_CustomerName()).c_str(), 50); customeridParam3[0][0] = (SQLINTEGER) iport$0.get_CustomerId(); productnameParam4Length[0][0] = (iport$0.get_ProductName().size() > 50) ? 50 : (int)iport$0.get_ProductName().size(); strncpy( (char *) productnameParam4[0], ((std::string) iport$0.get_ProductName()).c_str(), 50); productidParam5[0][0] = (SQLINTEGER) iport$0.get_ProductId(); priceParam6Length[0][0] = (iport$0.get_Price().size() > 10) ? 10 : (int)iport$0.get_Price().size(); strncpy( (char *) priceParam6[0], ((std::string) iport$0.get_Price()).c_str(), 10); shipmentstatusParam7[0][0] = (SQLINTEGER) iport$0.get_ShipmentStatus(); shippingdateParam8Length[0][0] = (iport$0.get_ShippingDate().size() > 50) ? 50 : (int)iport$0.get_ShippingDate().size(); strncpy( (char *) shippingdateParam8[0], ((std::string) iport$0.get_ShippingDate()).c_str(), 50); if (hstmt[0] == SQL_NULL_HSTMT) { SPLAPPTRC(L_INFO, "Attempting connection", SPL_OPER_DBG); if (!attemptODBCConnection()) { std::string msg = DB_OPERATOR_SHUTDOWN; SPLAPPLOG(L_ERROR, msg, SPL_OPER_DBG); SPL::Functions::Utility::shutdownPE(); } } if (hstmt[0] != SQL_NULL_HSTMT) { rc = SQLExecute(hstmt[0]); SPLAPPLOG(L_INFO, DB_ODBC_RUN_STATEMENT, SPL_OPER_DBG); if (handleSQLRC(SQL_HANDLE_STMT, hstmt[0], rc) == false) { droppedTuples_->incrementValue(1); // Determine whether the connection has failed bool badConnection = false; SQLUINTEGER state = SQL_CD_FALSE; rc = SQLGetConnectAttr(hdbc, SQL_ATTR_CONNECTION_DEAD, &state, SQL_IS_UINTEGER, 0); if (rc == SQL_SUCCESS || rc == SQL_SUCCESS_WITH_INFO) { badConnection = (state == SQL_CD_TRUE); } else { SPLAPPTRC(L_DEBUG, "SQLGetConnectAttr failed", SPL_OPER_DBG); } if (badConnection) { SPLAPPTRC(L_DEBUG, "Bad connection", SPL_OPER_DBG); resetODBCConnection(); } } } else { SPLAPPTRC(L_ERROR, "SQL Statement not run because statement is not allocated. This could be due to a connection error.", SPL_OPER_DBG); } } void MY_OPERATOR_SCOPE::MY_OPERATOR::process(Punctuation const & punct, uint32_t port) { SPLAPPTRC(L_TRACE, "Process Punctuation " << punct, SPL_OPER_DBG); } bool MY_OPERATOR::attemptODBCConnection() { SPLAPPTRC(L_DEBUG, "attemptODBCConnection", SPL_OPER_DBG); while (!establishODBCConnection()) { // Reset connection for next attempt resetODBCConnection(); // Sleep for 10.0 seconds and retry connection attempt std::string msg = DB_CONNECTION_RETRY(10.0); SPLAPPLOG(L_INFO, msg, SPL_OPER_DBG); if (getPE().blockUntilShutdownRequest((double) 10.0)) { break; } } if (!getPE().getShutdownRequested()) { std::string msg = DB_CONNECTION_SUCCESSFUL; SPLAPPLOG(L_INFO, msg, SPL_OPER_DBG); } return true; } bool MY_OPERATOR::establishODBCConnection() { SPLAPPTRC(L_DEBUG, "establishODBCConnection", SPL_OPER_DBG); // Allocate the environment handle rc = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &henv); if (handleSQLRC(SQL_HANDLE_ENV, henv, rc) == false) { SPLAPPTRC(L_ERROR, "Failed to allocate environment handle", SPL_OPER_DBG); return false; } rc = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0); if (handleSQLRC(SQL_HANDLE_ENV, henv, rc) == false) { SPLAPPTRC(L_ERROR, "Failed to set ODBC version environment attribute", SPL_OPER_DBG); return false; } // Allocate the connection handle if (henv != SQL_NULL_HENV) { rc = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc); if (handleSQLRC(SQL_HANDLE_ENV, henv, rc) == false) { SPLAPPTRC(L_ERROR, "Failed to allocate connection handle", SPL_OPER_DBG); return false; } } // Connect to database if (hdbc != SQL_NULL_HDBC) { rc = SQLConnect(hdbc, (UCHAR*) connectionDatabase.c_str(), SQL_NTS, (UCHAR*) connectionUser.c_str(), SQL_NTS, (UCHAR *) connectionPassword.c_str(), SQL_NTS); if (handleSQLRC(SQL_HANDLE_DBC, hdbc, rc) == false) { SPLAPPTRC(L_ERROR, "Failed to connect to database", SPL_OPER_DBG); return false; } } // Allocate statement handle(s) if (hdbc != SQL_NULL_HDBC) { rc = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt[0]); if (handleSQLRC(SQL_HANDLE_DBC, hdbc, rc) == false) { SPLAPPTRC(L_ERROR, "Failed to allocate statement for hstmt[0]", SPL_OPER_DBG); return false; } } rc = SQLSetConnectAttr(hdbc, SQL_ATTR_AUTOCOMMIT, (SQLPOINTER) SQL_AUTOCOMMIT_ON, SQL_IS_UINTEGER); if (handleSQLRC(SQL_HANDLE_DBC, hdbc, rc) == false) { SPLAPPTRC(L_ERROR, "Failed to SetAutoCommit.", SPL_OPER_DBG); return false; } // Prepare statement rc = SQLPrepare(hstmt[0], (SQLCHAR *) "INSERT INTO OrderResults (OrderId,CustomerName,CustomerId,ProductName,ProductId,Price,ShipmentStatus,ShippingDate) VALUES(?,?,?,?,?,?,?,?)", SQL_NTS); if (handleSQLRC(SQL_HANDLE_STMT, hstmt[0], rc) == false) { SPLAPPTRC(L_ERROR, "Failed to prepare query for hstmt[0]", SPL_OPER_DBG); return false; } // Determine number of result columns for the statement if (hstmt[0] != SQL_NULL_HSTMT) { rc = SQLNumResultCols(hstmt[0], &stmtcols); if (handleSQLRC(SQL_HANDLE_STMT, hstmt[0], rc) == false) { SPLAPPTRC(L_ERROR, "Failed to retrieve number of result columns for statement", SPL_OPER_DBG); return false; } } // Initialize string buffers for (int i = 50; i < 51; i += 51 ) { customernameParam2[0][i] = '\0'; } for (int i = 50; i < 51; i += 51 ) { productnameParam4[0][i] = '\0'; } for (int i = 10; i < 11; i += 11 ) { priceParam6[0][i] = '\0'; } for (int i = 50; i < 51; i += 51 ) { shippingdateParam8[0][i] = '\0'; } // Bind parameters for hstmt[0] rc = SQLBindParameter(hstmt[0], 1, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, orderidParam1[0], 0, NULL); if (handleSQLRC(SQL_HANDLE_STMT, hstmt[0], rc) == false) { SPLAPPTRC(L_ERROR, "Failed to bind parameter orderidParam1[0] in position 1", SPL_OPER_DBG); return false; } rc = SQLBindParameter(hstmt[0], 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 50, 0, customernameParam2[0], 51, customernameParam2Length[0]); if (handleSQLRC(SQL_HANDLE_STMT, hstmt[0], rc) == false) { SPLAPPTRC(L_ERROR, "Failed to bind parameter customernameParam2[0] in position 2", SPL_OPER_DBG); return false; } rc = SQLBindParameter(hstmt[0], 3, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, customeridParam3[0], 0, NULL); if (handleSQLRC(SQL_HANDLE_STMT, hstmt[0], rc) == false) { SPLAPPTRC(L_ERROR, "Failed to bind parameter customeridParam3[0] in position 3", SPL_OPER_DBG); return false; } rc = SQLBindParameter(hstmt[0], 4, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 50, 0, productnameParam4[0], 51, productnameParam4Length[0]); if (handleSQLRC(SQL_HANDLE_STMT, hstmt[0], rc) == false) { SPLAPPTRC(L_ERROR, "Failed to bind parameter productnameParam4[0] in position 4", SPL_OPER_DBG); return false; } rc = SQLBindParameter(hstmt[0], 5, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, productidParam5[0], 0, NULL); if (handleSQLRC(SQL_HANDLE_STMT, hstmt[0], rc) == false) { SPLAPPTRC(L_ERROR, "Failed to bind parameter productidParam5[0] in position 5", SPL_OPER_DBG); return false; } rc = SQLBindParameter(hstmt[0], 6, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 10, 0, priceParam6[0], 11, priceParam6Length[0]); if (handleSQLRC(SQL_HANDLE_STMT, hstmt[0], rc) == false) { SPLAPPTRC(L_ERROR, "Failed to bind parameter priceParam6[0] in position 6", SPL_OPER_DBG); return false; } rc = SQLBindParameter(hstmt[0], 7, SQL_PARAM_INPUT, SQL_C_LONG, SQL_INTEGER, 0, 0, shipmentstatusParam7[0], 0, NULL); if (handleSQLRC(SQL_HANDLE_STMT, hstmt[0], rc) == false) { SPLAPPTRC(L_ERROR, "Failed to bind parameter shipmentstatusParam7[0] in position 7", SPL_OPER_DBG); return false; } rc = SQLBindParameter(hstmt[0], 8, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, 50, 0, shippingdateParam8[0], 51, shippingdateParam8Length[0]); if (handleSQLRC(SQL_HANDLE_STMT, hstmt[0], rc) == false) { SPLAPPTRC(L_ERROR, "Failed to bind parameter shippingdateParam8[0] in position 8", SPL_OPER_DBG); return false; } SPLAPPTRC(L_DEBUG, "establishODBCConnection completed", SPL_OPER_DBG); return true; } bool MY_OPERATOR::resetODBCConnection() { SPLAPPTRC(L_DEBUG, "resetODBCConnection", SPL_OPER_DBG); rc = SQLEndTran(SQL_HANDLE_DBC, hdbc, SQL_COMMIT); if (handleSQLRC(SQL_HANDLE_DBC, hdbc, rc) == false) { SPLAPPTRC(L_ERROR, "Failed to commit transaction.", SPL_OPER_DBG); } if (hstmt[0] != SQL_NULL_HSTMT) { SPLAPPTRC(L_DEBUG, "SQLFreeStmt(SQL_UNBIND)", SPL_OPER_DBG); rc = SQLFreeStmt(hstmt[0], SQL_UNBIND); handleSQLRC(SQL_HANDLE_STMT, hstmt[0], rc); SPLAPPTRC(L_DEBUG, "SQLFreeStmt(SQL_RESET_PARAMS)", SPL_OPER_DBG); rc = SQLFreeStmt(hstmt[0], SQL_RESET_PARAMS); handleSQLRC(SQL_HANDLE_STMT, hstmt[0], rc); SPLAPPTRC(L_DEBUG, "SQLFreeStmt(SQL_CLOSE)", SPL_OPER_DBG); rc = SQLFreeStmt(hstmt[0], SQL_CLOSE); handleSQLRC(SQL_HANDLE_STMT, hstmt[0], rc); SPLAPPTRC(L_DEBUG, "SQLFreeHandle(SQL_HANDLE_STMT)", SPL_OPER_DBG); rc = SQLFreeHandle(SQL_HANDLE_STMT, hstmt[0]); handleSQLRC(SQL_HANDLE_STMT, hstmt[0], rc); } hstmt[0] = SQL_NULL_HSTMT; if (hdbc != SQL_NULL_HDBC) { SPLAPPTRC(L_DEBUG, "SQLDisconnect", SPL_OPER_DBG); rc = SQLDisconnect(hdbc); handleSQLRC(SQL_HANDLE_DBC, hdbc, rc); SPLAPPTRC(L_DEBUG, "SQLFreeHandle(SQL_HANDLE_DBC)", SPL_OPER_DBG); rc = SQLFreeHandle(SQL_HANDLE_DBC, hdbc); handleSQLRC(SQL_HANDLE_DBC, hdbc, rc); hdbc = SQL_NULL_HDBC; } if (henv != SQL_NULL_HENV) { SPLAPPTRC(L_DEBUG, "SQLFreeHandle(SQL_HANDLE_ENV)", SPL_OPER_DBG); rc = SQLFreeHandle(SQL_HANDLE_ENV, henv); handleSQLRC(SQL_HANDLE_ENV, henv, rc); henv = SQL_NULL_HENV; } SPLAPPTRC(L_DEBUG, "resetODBCConnection completed", SPL_OPER_DBG); return true; } static SPL::Operator * initer() { return new MY_OPERATOR_SCOPE::MY_OPERATOR(); } bool MY_BASE_OPERATOR::globalInit_ = MY_BASE_OPERATOR::globalIniter(); bool MY_BASE_OPERATOR::globalIniter() { instantiators_.insert(std::make_pair("ODBCAppend_3",&initer)); return true; } template<class T> static void initRTC (SPL::Operator& o, T& v, const char * n) { SPL::ValueHandle vh = v; o.getContext().getRuntimeConstantValue(vh, n); } MY_BASE_OPERATOR::MY_BASE_OPERATOR() : Operator() { uint32_t index = getIndex(); param$connectionDocument$0 = SPL::rstring("/data/Day4/connections.xml"); addParameterValue ("connectionDocument", SPL::ConstValueHandle(param$connectionDocument$0)); param$connection$0 = SPL::rstring("MyConnection"); addParameterValue ("connection", SPL::ConstValueHandle(param$connection$0)); param$access$0 = SPL::rstring("writeToOrderResultsTable"); addParameterValue ("access", SPL::ConstValueHandle(param$access$0)); (void) getParameters(); // ensure thread safety by initializing here } MY_BASE_OPERATOR::~MY_BASE_OPERATOR() { for (ParameterMapType::const_iterator it = paramValues_.begin(); it != paramValues_.end(); it++) { const ParameterValueListType& pvl = it->second; for (ParameterValueListType::const_iterator it2 = pvl.begin(); it2 != pvl.end(); it2++) { delete *it2; } } } void MY_BASE_OPERATOR::tupleLogic(Tuple const & tuple, uint32_t port) { } void MY_BASE_OPERATOR::processRaw(Tuple const & tuple, uint32_t port) { tupleLogic (tuple, port); static_cast<MY_OPERATOR_SCOPE::MY_OPERATOR*>(this)->MY_OPERATOR::process(tuple, port); } void MY_BASE_OPERATOR::punctLogic(Punctuation const & punct, uint32_t port) { } void MY_BASE_OPERATOR::punctPermitProcessRaw(Punctuation const & punct, uint32_t port) { { punctNoPermitProcessRaw(punct, port); } } void MY_BASE_OPERATOR::punctNoPermitProcessRaw(Punctuation const & punct, uint32_t port) { switch(punct) { case Punctuation::WindowMarker: punctLogic(punct, port); process(punct, port); break; case Punctuation::FinalMarker: punctLogic(punct, port); process(punct, port); break; case Punctuation::DrainMarker: case Punctuation::ResetMarker: case Punctuation::ResumeMarker: break; case Punctuation::SwitchMarker: break; case Punctuation::WatermarkMarker: break; default: break; } } void MY_BASE_OPERATOR::processRaw(Punctuation const & punct, uint32_t port) { switch(port) { case 0: punctNoPermitProcessRaw(punct, port); break; } } void MY_BASE_OPERATOR::checkpointStateVariables(NetworkByteBuffer & opstate) const { } void MY_BASE_OPERATOR::restoreStateVariables(NetworkByteBuffer & opstate) { } void MY_BASE_OPERATOR::checkpointStateVariables(Checkpoint & ckpt) { } void MY_BASE_OPERATOR::resetStateVariables(Checkpoint & ckpt) { } void MY_BASE_OPERATOR::resetStateVariablesToInitialState() { } bool MY_BASE_OPERATOR::hasStateVariables() const { return false; } void MY_BASE_OPERATOR::resetToInitialStateRaw() { AutoMutex $apm($svMutex); StateHandler *sh = getContext().getStateHandler(); if (sh != NULL) { sh->resetToInitialState(); } resetStateVariablesToInitialState(); } void MY_BASE_OPERATOR::checkpointRaw(Checkpoint & ckpt) { AutoMutex $apm($svMutex); StateHandler *sh = getContext().getStateHandler(); if (sh != NULL) { sh->checkpoint(ckpt); } checkpointStateVariables(ckpt); } void MY_BASE_OPERATOR::resetRaw(Checkpoint & ckpt) { AutoMutex $apm($svMutex); StateHandler *sh = getContext().getStateHandler(); if (sh != NULL) { sh->reset(ckpt); } resetStateVariables(ckpt); }
[ "leo@MacBook-Air.Home" ]
leo@MacBook-Air.Home
f9a01c5e97cc2b5cfb6cbdc1567c4145310725a7
120eb6e3eefd4083d719ab90ed288c88fcedfaed
/game/properties/TileDef.h
a0a2435bb54b8dfc53563fad7475918a3284fcd9
[]
no_license
AspidT/Zerlight
b111d6c874033b1bccef1780d8479f216d0239b0
2fb6d713580f4b93217274ee8f655b5af0682a07
refs/heads/master
2020-04-18T18:59:39.029017
2019-01-28T16:47:29
2019-01-28T16:48:51
167,700,733
0
0
null
null
null
null
UTF-8
C++
false
false
298
h
// // Created by tatiana on 15.12.18. // #ifndef ZERLIGHT_TILEDEF_H #define ZERLIGHT_TILEDEF_H #include "guichan/gui/ZColor.h" namespace properties { struct TileDef { std::string SpriteID; float DrawOrder; gui::ZColor Color; }; } #endif //ZERLIGHT_TILEDEF_H
[ "hx03@yandex.ru" ]
hx03@yandex.ru
b4992c1788df2eb289b825b0387546bf7141ee46
c2c1fbaf67708be4315a4a5f387e34b1dd117e70
/CppAsync/util/ScopeGuard.h
fe1f2b993cf927005ba804a93ceef901723e5363
[ "Apache-2.0" ]
permissive
elix22/CppAsync
6c792436f5a25f24f677590926b8e850547de739
546d79d7f4de6387a044df527277c54a3266a11a
refs/heads/master
2021-04-26T23:31:40.205599
2016-10-13T18:28:07
2016-10-13T18:28:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,457
h
/* * Copyright 2015-2016 Valentin Milea * * 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. */ /** * @file ScopeGuard.h * * Declares the ScopeGuard class * */ #pragma once #include "../impl/Common.h" #include "../impl/Assert.h" #include "../Log.h" namespace ut { /** Classic scope guard for RAII */ template <class F> class ScopeGuard { public: using type = ScopeGuard<F>; /** * Create a dummy scope guard */ explicit ScopeGuard() : mIsDismissed(true) { } /** * Create a scope guard * @param cleanup functor to call at end of scope */ explicit ScopeGuard(const F& cleanup) : mIsDismissed(false) , mCleanup(cleanup) { } /** * Create a scope guard * @param cleanup functor to call at end of scope */ explicit ScopeGuard(F&& cleanup) : mIsDismissed(false) , mCleanup(std::move(cleanup)) { } /** * Move constructor */ ScopeGuard(ScopeGuard&& other) : mIsDismissed(other.mIsDismissed) , mCleanup(std::move(other.mCleanup)) { other.mIsDismissed = true; } /** * Move assignment */ ScopeGuard& operator=(ScopeGuard&& other) { mIsDismissed = other.mIsDismissed; other.mIsDismissed = true; mCleanup = std::move(other.mCleanup); return *this; } /** Perform cleanup unless dismissed */ ~ScopeGuard() { if (!mIsDismissed) { #ifdef UT_NO_EXCEPTIONS mCleanup(); #else try { mCleanup(); } catch (const std::exception& ex) { (void) ex; ut_dcheckf(false, "ScopeGuard caught an exception: '%s'", ex.what()); } catch (...) { ut_dcheck(false && "ScopeGuard caught exception"); } #endif } } /* Dismiss guard */ void dismiss() const _ut_noexcept { mIsDismissed = true; } /* Check if dismissed */ bool isDismissed() const _ut_noexcept { return mIsDismissed; } void touch() const _ut_noexcept { /* avoids "variable unused" compiler warnings */ } private: ScopeGuard(const ScopeGuard&) = delete; ScopeGuard& operator=(const ScopeGuard&) = delete; mutable bool mIsDismissed; F mCleanup; }; /** Create a scope guard with template argument deduction */ template <class F> ScopeGuard<F> makeScopeGuard(F cleanup) { return ScopeGuard<F>(cleanup); } } // // These macros should be enough unless you intend to move ScopeGuard // /** Macro for creating anonymous scope guards */ #define ut_scope_guard_(cleanup) \ const auto& _ut_anonymous_label(scopeGuard) = ut::makeScopeGuard(cleanup); \ _ut_anonymous_label(scopeGuard).touch() /** Macro for creating named scope guards */ #define ut_named_scope_guard_(name, cleanup) \ const auto& name = ut::makeScopeGuard(cleanup)
[ "valentin.milea@gmail.com" ]
valentin.milea@gmail.com
582e88ec407d8b29dd5a71015fbeb118c2bcbeb0
019c446b2c8f8e902226851db1b31eb1e3c850d5
/oneEngine/oneGame/source/core-ext/system/shell/Inputs.h
724216531103b6dbfe90bd6fd8c7846813dead84
[ "FTL", "BSD-3-Clause" ]
permissive
skarik/1Engine
cc9b6f7cf81903b75663353926a23224b81d1389
9f53b4cb19a6b8bb3bf2e3a4104c73614ffd4359
refs/heads/master
2023-09-04T23:12:50.706308
2023-08-29T05:28:21
2023-08-29T05:28:21
109,445,379
9
2
BSD-3-Clause
2021-08-30T06:48:27
2017-11-03T21:41:51
C++
UTF-8
C++
false
false
779
h
//===============================================================================================// // // core-ext/system/shell/Inputs.h // // Contains shell-specific feature interfaces // //===============================================================================================// #ifndef CORE_EXT_SYSTEM_SHELL_INPUTS_H #define CORE_EXT_SYSTEM_SHELL_INPUTS_H #include "core/types/types.h" namespace core { namespace shell { // GetDoubleClickInterval() : Returns the make time in seconds the OS recognizes a double-click. CORE_API const float GetDoubleClickInterval ( void ); // SetSystemMousePosition(position) : Sets the system mouse position CORE_API void SetSystemMousePosition ( const int x, const int y ); } } #endif//CORE_EXT_SYSTEM_SHELL_INPUTS_H
[ "josh@epichousestudios.com" ]
josh@epichousestudios.com
34572b9104248614b7c3a853d10a99947c32c1f7
ced225937df2527063d09a1e23405052c65c28e4
/src/exceptions.h
fe10fb960324027ee8527e37fc5db7794f39cc9c
[]
no_license
veljkodj/system-software
d01bdd5e755e84694da9f0ffaab7b0c9011bd0b9
31999c6349dba3c89c772475e466c7838602d4d3
refs/heads/master
2023-03-23T00:05:53.691943
2021-03-19T00:03:36
2021-03-19T00:03:36
310,136,659
0
1
null
null
null
null
UTF-8
C++
false
false
1,038
h
#ifndef EXCEPTIONS_H #define EXCEPTIONS_H #include <iostream> #include <string.h> #include <sstream> using namespace std; class AssemblyException : public exception { public: AssemblyException(string message) noexcept : exception(), message(message), line(-1) {} AssemblyException(string message, unsigned long line) noexcept : exception(), message(message), line(line) {} ~AssemblyException() { delete[] a[0]; delete a; } const char* what() const noexcept override { ostringstream temp; temp << "Error: "; if (line != -1) temp << " on line " << line << ": "; else temp << ": "; temp << message; string errorDescription = temp.str(); char *cstr = new char[errorDescription.length() + 1]; strcpy(cstr, errorDescription.c_str()); a[0] = cstr; return cstr; } private: string message; unsigned long line; char** a = new char*[1]; }; #endif
[ "veljkodjordjevic97@gmail.com" ]
veljkodjordjevic97@gmail.com
08331a2b318d9f1ed7e3060043d3be5b4b94225d
6f49cc2d5112a6b97f82e7828f59b201ea7ec7b9
/apiwdbe/QryWdbeSil1NInterrupt.cpp
dce881b0664a6780c7f7536522b68789d6e53897
[ "MIT" ]
permissive
mpsitech/wdbe-WhizniumDBE
d3702800d6e5510e41805d105228d8dd8b251d7a
89ef36b4c86384429f1e707e5fa635f643e81240
refs/heads/master
2022-09-28T10:27:03.683192
2022-09-18T22:04:37
2022-09-18T22:04:37
282,705,449
5
0
null
null
null
null
UTF-8
C++
false
false
6,450
cpp
/** * \file QryWdbeSil1NInterrupt.cpp * API code for job QryWdbeSil1NInterrupt (implementation) * \copyright (C) 2016-2020 MPSI Technologies GmbH * \author Alexander Wirthmueller (auto-generation) * \date created: 26 Aug 2021 */ // IP header --- ABOVE #include "QryWdbeSil1NInterrupt.h" using namespace std; using namespace Sbecore; using namespace Xmlio; /****************************************************************************** class QryWdbeSil1NInterrupt::StatApp ******************************************************************************/ QryWdbeSil1NInterrupt::StatApp::StatApp( const uint firstcol , const uint jnumFirstdisp , const uint ncol , const uint ndisp ) : Block() { this->firstcol = firstcol; this->jnumFirstdisp = jnumFirstdisp; this->ncol = ncol; this->ndisp = ndisp; mask = {FIRSTCOL, JNUMFIRSTDISP, NCOL, NDISP}; }; bool QryWdbeSil1NInterrupt::StatApp::readXML( xmlXPathContext* docctx , string basexpath , bool addbasetag ) { clear(); bool basefound; if (addbasetag) basefound = checkUclcXPaths(docctx, basexpath, basexpath, "StatAppQryWdbeSil1NInterrupt"); else basefound = checkXPath(docctx, basexpath); string itemtag = "StatitemAppQryWdbeSil1NInterrupt"; if (basefound) { if (extractUintAttrUclc(docctx, basexpath, itemtag, "Si", "sref", "firstcol", firstcol)) add(FIRSTCOL); if (extractUintAttrUclc(docctx, basexpath, itemtag, "Si", "sref", "jnumFirstdisp", jnumFirstdisp)) add(JNUMFIRSTDISP); if (extractUintAttrUclc(docctx, basexpath, itemtag, "Si", "sref", "ncol", ncol)) add(NCOL); if (extractUintAttrUclc(docctx, basexpath, itemtag, "Si", "sref", "ndisp", ndisp)) add(NDISP); }; return basefound; }; set<uint> QryWdbeSil1NInterrupt::StatApp::comm( const StatApp* comp ) { set<uint> items; if (firstcol == comp->firstcol) insert(items, FIRSTCOL); if (jnumFirstdisp == comp->jnumFirstdisp) insert(items, JNUMFIRSTDISP); if (ncol == comp->ncol) insert(items, NCOL); if (ndisp == comp->ndisp) insert(items, NDISP); return(items); }; set<uint> QryWdbeSil1NInterrupt::StatApp::diff( const StatApp* comp ) { set<uint> commitems; set<uint> diffitems; commitems = comm(comp); diffitems = {FIRSTCOL, JNUMFIRSTDISP, NCOL, NDISP}; for (auto it = commitems.begin(); it != commitems.end(); it++) diffitems.erase(*it); return(diffitems); }; /****************************************************************************** class QryWdbeSil1NInterrupt::StatShr ******************************************************************************/ QryWdbeSil1NInterrupt::StatShr::StatShr( const uint ntot , const uint jnumFirstload , const uint nload ) : Block() { this->ntot = ntot; this->jnumFirstload = jnumFirstload; this->nload = nload; mask = {NTOT, JNUMFIRSTLOAD, NLOAD}; }; bool QryWdbeSil1NInterrupt::StatShr::readXML( xmlXPathContext* docctx , string basexpath , bool addbasetag ) { clear(); bool basefound; if (addbasetag) basefound = checkUclcXPaths(docctx, basexpath, basexpath, "StatShrQryWdbeSil1NInterrupt"); else basefound = checkXPath(docctx, basexpath); string itemtag = "StatitemShrQryWdbeSil1NInterrupt"; if (basefound) { if (extractUintAttrUclc(docctx, basexpath, itemtag, "Si", "sref", "ntot", ntot)) add(NTOT); if (extractUintAttrUclc(docctx, basexpath, itemtag, "Si", "sref", "jnumFirstload", jnumFirstload)) add(JNUMFIRSTLOAD); if (extractUintAttrUclc(docctx, basexpath, itemtag, "Si", "sref", "nload", nload)) add(NLOAD); }; return basefound; }; set<uint> QryWdbeSil1NInterrupt::StatShr::comm( const StatShr* comp ) { set<uint> items; if (ntot == comp->ntot) insert(items, NTOT); if (jnumFirstload == comp->jnumFirstload) insert(items, JNUMFIRSTLOAD); if (nload == comp->nload) insert(items, NLOAD); return(items); }; set<uint> QryWdbeSil1NInterrupt::StatShr::diff( const StatShr* comp ) { set<uint> commitems; set<uint> diffitems; commitems = comm(comp); diffitems = {NTOT, JNUMFIRSTLOAD, NLOAD}; for (auto it = commitems.begin(); it != commitems.end(); it++) diffitems.erase(*it); return(diffitems); }; /****************************************************************************** class QryWdbeSil1NInterrupt::StgIac ******************************************************************************/ QryWdbeSil1NInterrupt::StgIac::StgIac( const uint jnum , const uint jnumFirstload , const uint nload ) : Block() { this->jnum = jnum; this->jnumFirstload = jnumFirstload; this->nload = nload; mask = {JNUM, JNUMFIRSTLOAD, NLOAD}; }; bool QryWdbeSil1NInterrupt::StgIac::readXML( xmlXPathContext* docctx , string basexpath , bool addbasetag ) { clear(); bool basefound; if (addbasetag) basefound = checkUclcXPaths(docctx, basexpath, basexpath, "StgIacQryWdbeSil1NInterrupt"); else basefound = checkXPath(docctx, basexpath); string itemtag = "StgitemIacQryWdbeSil1NInterrupt"; if (basefound) { if (extractUintAttrUclc(docctx, basexpath, itemtag, "Si", "sref", "jnum", jnum)) add(JNUM); if (extractUintAttrUclc(docctx, basexpath, itemtag, "Si", "sref", "jnumFirstload", jnumFirstload)) add(JNUMFIRSTLOAD); if (extractUintAttrUclc(docctx, basexpath, itemtag, "Si", "sref", "nload", nload)) add(NLOAD); }; return basefound; }; void QryWdbeSil1NInterrupt::StgIac::writeXML( xmlTextWriter* wr , string difftag , bool shorttags ) { if (difftag.length() == 0) difftag = "StgIacQryWdbeSil1NInterrupt"; string itemtag; if (shorttags) itemtag = "Si"; else itemtag = "StgitemIacQryWdbeSil1NInterrupt"; xmlTextWriterStartElement(wr, BAD_CAST difftag.c_str()); writeUintAttr(wr, itemtag, "sref", "jnum", jnum); writeUintAttr(wr, itemtag, "sref", "jnumFirstload", jnumFirstload); writeUintAttr(wr, itemtag, "sref", "nload", nload); xmlTextWriterEndElement(wr); }; set<uint> QryWdbeSil1NInterrupt::StgIac::comm( const StgIac* comp ) { set<uint> items; if (jnum == comp->jnum) insert(items, JNUM); if (jnumFirstload == comp->jnumFirstload) insert(items, JNUMFIRSTLOAD); if (nload == comp->nload) insert(items, NLOAD); return(items); }; set<uint> QryWdbeSil1NInterrupt::StgIac::diff( const StgIac* comp ) { set<uint> commitems; set<uint> diffitems; commitems = comm(comp); diffitems = {JNUM, JNUMFIRSTLOAD, NLOAD}; for (auto it = commitems.begin(); it != commitems.end(); it++) diffitems.erase(*it); return(diffitems); };
[ "aw@mpsitech.com" ]
aw@mpsitech.com
36221d5c16e30fca50cef395d32a10554937b6d6
f1d0f38a1a3f8e0b5265b731fd5aa9f1111630c2
/source/OBJ_Parser.cpp
3dfeb8c6fd1598a9d8aa9d5848ef477d0d59a8a8
[ "MIT" ]
permissive
Kair0z/Custom-Rasterizer
9c6fd06c5828145b41fcc04ddc8eaf7bf7678a7b
f83c636c29b85e12cc3c1c85b25a0bc2da2eaf84
refs/heads/main
2023-01-04T16:51:41.763195
2020-10-29T08:16:05
2020-10-29T08:16:05
304,494,660
0
0
null
null
null
null
UTF-8
C++
false
false
9,380
cpp
#include "pch.h" #include "OBJ_Parser.h" #include <regex> #include <fstream> #include <sstream> #include "Utils.h" std::unordered_map<std::string, std::vector<uint32_t>> OBJ_Parser::stat_LoadedIndexbuffers{}; std::unordered_map<std::string, std::vector<Input_Vertex>> OBJ_Parser::stat_LoadedVertexbuffers{}; enum class Linetype { Comment, Vertex, Face, VertexNormal, VertTexCoordinate, Unknown }; OBJ_Parser::OBJ_Parser(PrimitiveTopology topology) : m_Topology{topology} { } PrimitiveTopology OBJ_Parser::GetTopology() const { return m_Topology; } std::vector<std::string> OBJ_Parser::operator()(const std::string& filename, std::vector<Input_Vertex>& out_Vertices, std::vector<uint32_t>& out_Indices) const { std::vector<std::string> out_Comments; // Check if already parsed once this run if (stat_LoadedIndexbuffers.find(filename) == stat_LoadedIndexbuffers.cend() && stat_LoadedVertexbuffers.find(filename) == stat_LoadedVertexbuffers.cend()) { std::string fullPath = "Resources/" + filename + ".obj"; std::vector<FPoint3> temp_Points; std::vector<FVector2> temp_UVs; std::vector<FVector3> temp_Normals; // BuildData() decides how many components every part (1/3) of the face has // 1 --> only vertex data! (bare minimum) // 2 --> only vertex coordinates! // 3 --> only vertex normals! int amountOfDatatypes{ 1 }; BuildData(fullPath, out_Comments, temp_Points, temp_UVs, temp_Normals, amountOfDatatypes); BuildIdxBuffer(fullPath, out_Vertices, out_Indices, temp_Points, temp_UVs, temp_Normals, amountOfDatatypes); BuildTangents(out_Vertices, out_Indices); stat_LoadedIndexbuffers[filename] = out_Indices; stat_LoadedVertexbuffers[filename] = out_Vertices; return out_Comments; } else { out_Vertices = stat_LoadedVertexbuffers[filename]; out_Indices = stat_LoadedIndexbuffers[filename]; } return out_Comments; } #pragma region subMethods void OBJ_Parser::BuildData(const std::string& filepath , std::vector<std::string>& returnComments , std::vector<FPoint3>& temp_Points , std::vector<FVector2>& temp_UVs , std::vector<FVector3>& temp_Normals , int& amountOfDatatypes) const { std::ifstream input(filepath, std::ios::in); if (!input) { std::cout << "Error loading file! " << filepath << " \n"; } std::string line{}; Linetype lineType{}; bool hasNormals{ false }; bool hasCoordinates{ false }; std::string signature{}; std::vector<std::string> capturedGroups; // build all data except idx-buffer while (!input.eof()) { std::getline(input, line); std::string regString{ "^\\s*(\\S+)\\s+(.*)" }; std::regex captureSignRegex{ regString }; capturedGroups = Utils::GetCaptureGroups(line, captureSignRegex); // if we captured something: if (capturedGroups.size() > 0) { signature = capturedGroups[1]; // Set up linetype if (signature == "#") lineType = Linetype::Comment; else if (signature == "v") lineType = Linetype::Vertex; else if (signature == "f") lineType = Linetype::Face; else if (signature == "vn") lineType = Linetype::VertexNormal; else if (signature == "vt") lineType = Linetype::VertTexCoordinate; else lineType = Linetype::Unknown; //std::cout << capturedGroups[2] << "\n"; Actual content of the line (#: string of text), (v: 3 numbers), ... switch (lineType) { case Linetype::Vertex: temp_Points.emplace_back(CapturePoint(capturedGroups[2])); break; case Linetype::Comment: returnComments.push_back(capturedGroups[2]); break; case Linetype::Face: // Do nothing yet! break; case Linetype::VertexNormal: temp_Normals.emplace_back(CaptureNormal(capturedGroups[2])); hasNormals = true; break; case Linetype::VertTexCoordinate: temp_UVs.emplace_back(CaptureTexCoord(capturedGroups[2])); hasCoordinates = true; break; case Linetype::Unknown: // std::cout << "Unknown linetype found in file! \n"; //std::cout << line << "\n"; break; } } } amountOfDatatypes += int(hasCoordinates) + int(hasNormals); } void OBJ_Parser::BuildIdxBuffer(const std::string& filepath , std::vector<Input_Vertex>& vertices , std::vector<uint32_t>& indices , const std::vector<FPoint3>& temp_Points , const std::vector<FVector2>& temp_UVs , const std::vector<FVector3>& temp_Normals , int amountOfDatatypes) const { std::string line{}; std::vector<std::string> capturedGroups; std::ifstream input2(filepath, std::ios::in); if (!input2) { std::cout << "Error loading file! (input2) " << filepath << "\n"; } while (!input2.eof()) { std::getline(input2, line); std::string regString{ "^\\s*(\\S+)\\s+(.*)" }; std::regex captureSignRegex{ regString }; capturedGroups = Utils::GetCaptureGroups(line, captureSignRegex); if (capturedGroups.size() > 0) { if (capturedGroups[1] == "f") { CaptureFace(capturedGroups[2], vertices, indices, temp_Points, temp_UVs, temp_Normals, amountOfDatatypes); } } } } void OBJ_Parser::CaptureFace(const std::string& faceString , std::vector<Input_Vertex>& vertices , std::vector<uint32_t>& indices , const std::vector<FPoint3>& temp_Points , const std::vector<FVector2>& temp_UVs , const std::vector<FVector3>& temp_Normals , int amountOfDatatypes) const { std::string group{}; switch (amountOfDatatypes) { case 1: group = "(\\d+)"; // vertices only! break; case 2: group = "(\\d+\/\\d+)"; // vertices + vt! break; case 3: group = "(\\d+\/\\d+\/\\d+)"; // vertices + vt + vn! break; default: group = "DEADMEAT!"; std::cout << "Uh oh!, Deadmeat!\n"; break; } std::string fullString{ "(" }; for (int i{}; i < 3; ++i) { fullString += group; fullString += "\\s*"; } fullString += ")"; std::regex reg(fullString); std::vector<std::string> captureElements = Utils::GetCaptureGroups(faceString, reg); std::string substrings[3]; // If not all 3 + (full capture-offsets(2)) elements were captured, nothing more we can do! if (captureElements.size() != 5) return; substrings[0] = captureElements[2]; substrings[1] = captureElements[3]; substrings[2] = captureElements[4]; Face face; switch (amountOfDatatypes) { case 1: group = "(\\d+)"; // vertices only! break; case 2: group = "(\\d+)\/(\\d+)"; // vertices + vt! break; case 3: group = "(\\d+)\/(\\d+)\/(\\d+)";; // vertices + vt + vn! break; default: group = "DEADMEAT!"; std::cout << "Uh oh!, Deadmeat!\n"; break; } // For each of the [amountOfDatatypes] face-elements for (int i{}; i < 3; ++i) { Input_Vertex vertex{}; std::vector<std::string> capture; std::regex regex(group); capture = Utils::GetCaptureGroups(substrings[i], regex); std::stringstream ss; // Store data in your buffers: [1] & [2] & [3] // (1) idx: int idx{}; ss.str(capture[1]); ss >> idx; ss.clear(); face[i] = idx; vertex.SetPoint(temp_Points[face[i] - 1]); if (amountOfDatatypes > 1) { // (2) vt: int vt_Idx{}; ss.str(capture[2]); ss >> vt_Idx; ss.clear(); if (temp_UVs.size() > vt_Idx - 1) vertex.SetUV(temp_UVs[vt_Idx - 1]); } if (amountOfDatatypes > 2) { // (3) vn: int vn_Idx{}; ss.str(capture[3]); ss >> vn_Idx; ss.clear(); if (temp_Normals.size() > vn_Idx - 1) vertex.SetNormal(temp_Normals[vn_Idx - 1]); } indices.push_back(unsigned int(vertices.size())); vertices.push_back(vertex); } //// RHS //indices.push_back(face[0] - 1); //indices.push_back(face[1] - 1); //indices.push_back(face[2] - 1); } FPoint3 OBJ_Parser::CapturePoint(const std::string& vertexString) const { std::stringstream ss{ vertexString }; FPoint3 temp{}; float tempFloat{}; for (int i{}; i < 3; ++i) { ss >> tempFloat; temp[i] = tempFloat; } return temp; } FVector2 OBJ_Parser::CaptureTexCoord(const std::string& vtString) const { std::stringstream ss{ vtString }; FVector2 uv_Temp{}; for (int i{}; i < 2; ++i) { ss >> uv_Temp[i]; } uv_Temp.y = 1 - uv_Temp.y; return uv_Temp; } FVector3 OBJ_Parser::CaptureNormal(const std::string& vnString) const { std::stringstream ss{ vnString }; FVector3 vn_Temp{}; for (int i{}; i < 3; ++i) { ss >> vn_Temp[i]; } Elite::Normalize(vn_Temp); return vn_Temp; } #pragma endregion void OBJ_Parser::BuildTangents(std::vector<Input_Vertex>& out_Vertices, const std::vector<uint32_t>& out_Indices) const { for (uint32_t i{}; i < out_Indices.size(); i += 3) { uint32_t i0 = out_Indices[i]; uint32_t i1 = out_Indices[i + 1]; uint32_t i2 = out_Indices[i + 2]; const FPoint3& p0 = out_Vertices[i0].GetPoint(); const FPoint3& p1 = out_Vertices[i1].GetPoint(); const FPoint3& p2 = out_Vertices[i2].GetPoint(); const FVector2& uv0 = out_Vertices[i0].GetUV(); const FVector2& uv1 = out_Vertices[i1].GetUV(); const FVector2& uv2 = out_Vertices[i2].GetUV(); const FVector3 edge0 = p1 - p0; const FVector3 edge1 = p2 - p0; const FVector2 diffX = FVector2(uv1.x - uv0.x, uv2.x - uv0.x); const FVector2 diffY = FVector2(uv1.y - uv0.y, uv2.y - uv0.y); float r = 1.f / Elite::Cross(diffX, diffY); FVector3 tangent = (edge0 * diffY.y - edge1 * diffY.x) * r; out_Vertices[i0].SetTangent(tangent); out_Vertices[i1].SetTangent(tangent); out_Vertices[i2].SetTangent(tangent); } for (Input_Vertex& v : out_Vertices) { v.SetTangent(Elite::GetNormalized(Elite::Reject(v.GetTangent(), v.GetNormal()))); } }
[ "52052044+Kair0z@users.noreply.github.com" ]
52052044+Kair0z@users.noreply.github.com
ef94735ef6da4622e8d005ebe163479e70f809cf
1a33019b4176750fdbb1460bae7b5c27f5eaf6b4
/Back/Agent/Nas/AuthJsonMgr.cpp
ab440472c855fcc6b416525cd7921d4118cfd2bc
[]
no_license
gaofeilong/uniplatform
42a727cd77990e7e9fc3e071d4d6ceb5f2e5a514
940e9266045adfb8ca3a96a113842418bb903391
refs/heads/master
2021-06-28T23:21:02.115026
2017-09-10T15:34:50
2017-09-10T15:34:50
103,040,546
0
1
null
null
null
null
GB18030
C++
false
false
27,598
cpp
#include "Protocol.h" #include "AuthJsonMgr.h" #include "Include/LvmConf.h" #include "Include/Constant.h" #include "Utils/Log/Log.h" #include "Utils/Common/CommonFunc.h" #include "Utils/Shell/System.h" #include "Agent/Disk/LvmMgr.h" #include "Agent/Disk/FsOper.h" #include <stdio.h> #include <string.h> using std::string; using std::vector; using namespace FsOper; static const std::string authConf = std::string(MAIN_PATH) + CONF_USERTYPE; //static CConfParser conf(authConf); //static CUserOper* m_user = NULL; AuthJsonMgr::AuthJsonMgr() :m_type(-1), conf(authConf), m_user(NULL) { bool isset = false; int usertype = -1; std::string value; conf.Load(); conf.GetVal("[global]", "isset", value); isset = atoi(value.c_str()); conf.GetVal("[global]", "usertype", value); usertype = atoi(value.c_str()); m_type = AUTH_NULL; if (isset) { if(usertype >= AUTH_LOCAL && usertype <= AUTH_NIS) { m_type = usertype; } } //conf.Clear(); m_user = CUserOper::Create(m_type); if (m_user == NULL) { m_type = AUTH_NULL; LOG_ERR("UserOper Create error!"); } } AuthJsonMgr::~AuthJsonMgr() { if (m_user != NULL) { delete m_user; } } Packet *AuthJsonMgr::Handle(const Packet *p) { switch(p->Cmd) { case CMD_NAS_AUTH_GET: return GetAuthType(p); case CMD_NAS_AUTH_SET: return SetAuthType(p); case CMD_NAS_AUTH_GROUP_ADD: return AddGroup(p); case CMD_NAS_AUTH_GROUP_DEL: return DelGroup(p); case CMD_NAS_AUTH_GROUP_GET: return GetGroup(p); case CMD_NAS_AUTH_GROUP_SET: return SetGroup(p); case CMD_NAS_AUTH_USER_ADD: return AddUser(p); case CMD_NAS_AUTH_USER_DEL: return DelUser(p); case CMD_NAS_AUTH_USER_GET: return GetUser(p); case CMD_NAS_AUTH_USER_SET: return SetUser(p); case CMD_NAS_QUOTA_GROUP_GET: return GetGroupQuota(p); case CMD_NAS_QUOTA_GROUP_SET: return SetGroupQuota(p); case CMD_NAS_QUOTA_USER_GET: return GetUserQuota(p); case CMD_NAS_QUOTA_USER_SET: return SetUserQuota(p); } LOG_ERR("AuthJsonMgr: unknown cmd: %08X", p->Cmd); return RequestError("unknown request"); } Packet *AuthJsonMgr::GetAuthType(const Packet *p) { LOG_DBG("GetAuthType()\n"); Json::Value request, respond; int ret = JsonValue(p, request); if (ret < 0) { return RequestError("parse request error"); } char errinfo[256] = {0}; if (RET_SUCCESS != conf.Load()) { sprintf(errinfo, "load auth config error"); LOG_ERR("GetAuthType(): %s", errinfo); //return RequestError(errinfo); } //respond["isset"] = Json::Value(); int usertype = AUTH_NULL; int isset = 0; std::string value; conf.GetVal("[global]", "isset", value); respond["isset"] = isset = atoi(value.c_str()); conf.GetVal("[global]", "usertype", value); respond["usertype"] = usertype = atoi(value.c_str()); if(usertype == AUTH_AD) { std::string domain,serverip,passwd; conf.GetVal("[AD]", "ADdomain", domain); conf.GetVal("[AD]", "ADserver", serverip); conf.GetVal("[AD]", "ADpasswd", passwd); respond["domainname"] = domain; respond["serverip"] = serverip; respond["passwd"] = passwd; } if(usertype == AUTH_NIS) { std::string domain,serverip; conf.GetVal("[NIS]", "NISdomain", domain); conf.GetVal("[NIS]", "NISserver", serverip); respond["domainname"] = domain; respond["serverip"] = serverip; } return RequestOk(respond); } Packet *AuthJsonMgr::SetAuthType(const Packet *p) { LOG_DBG("SetAuthType()\n"); Json::Value request, respond; int ret = JsonValue(p, request); if (ret < 0) { return RequestError("parse request error"); } char errinfo[256] = {0}; if (RET_SUCCESS != conf.Load()) { sprintf(errinfo, "load auth config error"); LOG_ERR("SetAuthType(): %s", errinfo); return RequestError(errinfo); } char cmd[1024] = {0}; int usertype = AUTH_NULL; std::string ip, basedn; std::string domainname,serverip,passwd; usertype = request["usertype"].isNull() ? usertype : atoi(request["usertype"].asString().c_str()); if(usertype == AUTH_AD || usertype == AUTH_NIS) { domainname = request["domainname"].isNull() ? string() : request["domainname"].asString(); domainname = StrUpper(domainname); serverip = request["serverip"].isNull() ? string() : request["serverip"].asString(); passwd = request["passwd"].isNull() ? string() : request["passwd"].asString(); } ResumeUserType(); conf.Load(); if (usertype == AUTH_LOCAL) { conf.SetVal("[global]", "usertype", "1"); strcpy(cmd,"authconfig --updateall --disableldap --disableldapauth --disablekrb5 --disablekrb5kdcdns --disablekrb5realmdns \ --disablewinbind --disablewinbindauth --disablewinbindusedefaultdomain --disablenis "); } else if(usertype == AUTH_LDAP) { conf.SetVal("[global]", "usertype", "2"); conf.GetVal("[ldap]", "ip", ip); conf.GetVal("[ldap]", "basedn", basedn); strcpy(cmd,"authconfig --updateall --enableldap --enableldapauth --ldapserver='"); strcat(cmd, ip.c_str()); strcat(cmd, "' --ldapbasedn='"); strcat(cmd, basedn.c_str()); strcat(cmd, "'"); } else if(usertype == AUTH_AD) { system("\\cp -f /etc/krb5.conf /etc/krb5.conf.NAS_AD_RESERVE_PREINST"); //authconfig --updateall --enablekrb5 --krb5kdc="192.168.1.58:88" --krb5adminserver="192.168.1.58:749" --krb5realm="SCINAS.COM" //--enablekrb5kdcdns --enablekrb5realmdns --enablewinbind --enablewinbindauth --smbsecurity=ads --smbrealm="SCINAS.COM" //--smbidmapuid=16777216-33554431 --smbidmapgid=16777216-33554431 --winbindtemplateshell=/bin/bash //--enablewinbindusedefaultdomain conf.SetVal("[global]", "usertype", "3"); conf.SetVal("[AD]", "ADdomain", domainname); conf.SetVal("[AD]", "ADserver", serverip); strcpy(cmd,"authconfig --updateall --enablekrb5 --krb5kdc='"); strcat(cmd, serverip.c_str()); strcat(cmd, ":88' --krb5adminserver='"); strcat(cmd, serverip.c_str()); strcat(cmd, ":749' --krb5realm='"); strcat(cmd, domainname.c_str()); strcat(cmd, "' --enablekrb5kdcdns --enablekrb5realmdns --enablewinbind --enablewinbindauth --smbsecurity=ads --smbrealm='"); strcat(cmd, domainname.c_str()); strcat(cmd, "' --smbidmapuid=16777216-33554431 --smbidmapgid=16777216-33554431 --winbindtemplateshell=/bin/bash"); strcat(cmd, " --enablewinbindusedefaultdomain;"); } else if(usertype == AUTH_NIS) { //authconfig --updateall --enablenis --nisdomain=nashsu.com --nisserver=192.168.1.59 conf.SetVal("[global]", "usertype", "4"); conf.SetVal("[NIS]", "NISdomain", domainname); conf.SetVal("[NIS]", "NISserver", serverip); strcpy(cmd,"authconfig --updateall --enablenis --nisdomain='"); strcat(cmd, domainname.c_str()); strcat(cmd, "' --nisserver='"); strcat(cmd, serverip.c_str()); strcat(cmd, "'"); } if (!ExeCmd(cmd)) { LOG_ERR("Execmd(%s) error", cmd); if (usertype==AUTH_AD) { system("\\mv -f /etc/krb5.conf.NAS_AD_RESERVE_PREINST /etc/krb5.conf"); } return RequestError("执行验证配置失败!"); } if(usertype == AUTH_AD) { ///usr/bin/net join -w SCINAS -S 192.168.1.58 -U Administrator //添加DNS char cmd2[1500] = {0}; //sprintf(cmd2,"more /etc/resolv.conf | grep -w '%s' | grep -v '^#'",serverip.c_str()); sprintf(cmd2, "\\cp -f /etc/resolv.conf /etc/resolv.conf.NAS_AD_RESERVE_PREINST"); system(cmd2); memset(cmd2,0,1500); sprintf(cmd2,"echo nameserver %s > /etc/resolv.conf",serverip.c_str()); system(cmd2); memset(cmd2,0,1500); sprintf(cmd2, "%s%s %s %s %s", MAIN_PATH, PL_ADPW, domainname.c_str(),serverip.c_str(),passwd.c_str()); conf.SetVal("[AD]", "ADpasswd", passwd.c_str()); std::string result; int joined = 1; if (!Popen(cmd2, result)) { LOG_ERR("Popen (%s) error", cmd2); joined = 0; } else { if(result.find("Failed to join domain") != std::string::npos || result.find("Unable to join domain") != std::string::npos || result.find("Could not connect to server") != std::string::npos || result.find("Connection failed") != std::string::npos || result.find("assword:") != std::string::npos ) { LOG_ERR("Join AD domain faild"); joined = 0; } } if(joined == 0) { ResumeUserType(); return RequestError("关联到AD域失败。"); } } else if(usertype == AUTH_NIS) { if(system("ypcat passwd") != 0) { ResumeUserType(); LOG_ERR("ypcat passwd error"); return RequestError("NIS认证密码失败。"); } } system("rm -fr /etc/nas/Conf/old*.txt 2>/dev/null"); conf.SetVal("[global]", "isset", "1"); conf.Write(); sprintf(cmd, "service smb restart"); if (!ExeCmd(cmd)) { LOG_ERR("Execmd(%s) error", cmd); return RequestError("重启Smb服务失败"); } //outpack.m_type = CPacket::PACKET_OK; //outpack.m_info = "设置验证方式成功。"; return RequestOk(respond); } Packet *AuthJsonMgr::AddGroup(const Packet *p) { LOG_DBG("AddGroup()\n"); Json::Value request, respond; int ret = JsonValue(p, request); if (ret < 0) { return RequestError("parse request error"); } CUserOper::GroupInfoList list; for (uint i=0; i<request["glist"].size(); ++i) { CUserOper::GroupInfo group; group.group = request["glist"][i]["gname"].isNull() ? string() : request["glist"][i]["gname"].asString(); if (group.group.empty()) { continue; } list.push_back(group); } char errinfo[256] = {0}; if (!m_user->AddMultipleGroups(list)) { respond["type"] = m_type; if (AUTH_NULL != m_type) { for (uint i=0; i<list.size(); ++i) { respond["glist"][i]["gname"] = list[i].group; } } sprintf(errinfo, "add group list error"); LOG_ERR("AddGroup(): %s", errinfo); respond["info"] = errinfo; return OnRequest(respond, CMD_ERR); } return RequestOk(respond); } Packet *AuthJsonMgr::DelGroup(const Packet *p) { LOG_DBG("DelGroup()\n"); Json::Value request, respond; int ret = JsonValue(p, request); if (ret < 0) { return RequestError("parse request error"); } CUserOper::GroupInfoList list; for (uint i=0; i<request["glist"].size(); ++i) { CUserOper::GroupInfo group; group.group = request["glist"][i]["gname"].isNull() ? string() : request["glist"][i]["gname"].asString(); if (group.group.empty()) { continue; } //group.gid = request["glist"][i]["gid"].isNull() ? 0 : atoi(request["glist"][i]["gname"].asString().c_str()); list.push_back(group); } char errinfo[256] = {0}; bool bRet = m_user->DelMultipleGroups(list); // CServiceAccess::LoadAll(); if (!bRet) { respond["type"] = m_type; if (AUTH_NULL != m_type) { for (uint i=0; i<list.size(); ++i) { respond["glist"][i]["gname"] = list[i].group; } } sprintf(errinfo, "del group list error"); LOG_ERR("DelGroup(): %s", errinfo); respond["info"] = errinfo; return OnRequest(respond, CMD_ERR); } return RequestOk(respond); } Packet *AuthJsonMgr::GetGroup(const Packet *p) { LOG_DBG("GetGroup()\n"); Json::Value request, respond; int ret = JsonValue(p, request); if (ret < 0) { return RequestError("parse request error"); } char errinfo[256] = {0}; bool bRet = false; respond["type"] = m_type; do { if (m_type == AUTH_NULL) { sprintf(errinfo, "no auth type configured!"); bRet = true; break; } CUserOper::GroupInfoList list; if (!m_user->GetGroupList(list)) { sprintf(errinfo, "GetGroupList error"); LOG_ERR("GetGroup(): %s", errinfo); break; } for (uint i = 0; i < list.size(); ++i) { CUserOper::GroupInfo& info = list[i]; respond["glist"][i]["gid"] = info.gid; respond["glist"][i]["gname"] = info.group; respond["glist"][i]["descript"] = info.groupInfo; respond["glist"][i]["type"] = m_type; // 获取用户列表 CUserOper::UserInfoList ulist; if (!m_user->GetUserList(ulist)) { sprintf(errinfo, "GetUserList error"); LOG_ERR("GetGroup(): %s", errinfo); break; } bool removable = true; for (uint j = 0; j < ulist.size(); ++j) { CUserOper::UserInfo& uinfo = ulist[j]; if (uinfo.gid == info.gid) { removable = false; break; } } respond["glist"][i]["removable"] = removable; } bRet = true; } while (false); if (!bRet) { return RequestError(errinfo); } return RequestOk(respond); } Packet *AuthJsonMgr::SetGroup(const Packet *p) { LOG_DBG("SetGroup()\n"); Json::Value request, respond; int ret = JsonValue(p, request); if (ret < 0) { return RequestError("parse request error"); } vector<string> vt; char errinfo[256] = {0}; if (RET_SUCCESS != RET_FAILED) { sprintf(errinfo, "load iscsi config error"); LOG_ERR("SetGroup(): %s", errinfo); return RequestError(errinfo); } respond["auth"] = Json::Value(); return RequestOk(respond); } Packet *AuthJsonMgr::AddUser(const Packet *p) { LOG_DBG("AddUser()\n"); Json::Value request, respond; int ret = JsonValue(p, request); if (ret < 0) { return RequestError("parse request error"); } CUserOper::UserInfoList list; for (uint i=0; i<request["ulist"].size(); ++i) { CUserOper::UserInfo user; user.user = request["ulist"][i]["uname"].isNull() ? string() : request["ulist"][i]["uname"].asString(); if (user.user.empty()) { continue; } user.gid = request["ulist"][i]["gid"].isNull() ? 0 : atoi(request["ulist"][i]["gid"].asString().c_str()); user.pwd = request["ulist"][i]["pwd"].isNull() ? string() : request["ulist"][i]["pwd"].asString(); list.push_back(user); } char errinfo[256] = {0}; if (!m_user->AddMultipleUsers(list)) { respond["type"] = m_type; if (AUTH_NULL != m_type) { for (uint i=0; i<list.size(); ++i) { respond["ulist"][i]["uname"] = list[i].user; respond["ulist"][i]["gid"] = list[i].gid; respond["ulist"][i]["pwd"] = list[i].pwd; } } sprintf(errinfo, "add user list error"); LOG_ERR("AddUser(): %s", errinfo); respond["info"] = errinfo; return OnRequest(respond, CMD_ERR); } return RequestOk(respond); } Packet *AuthJsonMgr::DelUser(const Packet *p) { LOG_DBG("DelUser()\n"); Json::Value request, respond; int ret = JsonValue(p, request); if (ret < 0) { return RequestError("parse request error"); } CUserOper::UserInfoList list; for (uint i=0; i<request["ulist"].size(); ++i) { CUserOper::UserInfo user; user.user = request["ulist"][i]["uname"].isNull() ? string() : request["ulist"][i]["uname"].asString(); if (user.user.empty()) { continue; } //user.uid = request["ulist"][i]["uid"].isNull() ? 0 : atoi(request["ulist"][i]["uid"].asString().c_str()); list.push_back(user); } char errinfo[256] = {0}; bool bRet = m_user->DelMultipleUsers(list); // CServiceAccess::LoadAll(); if (!bRet) { respond["type"] = m_type; if (AUTH_NULL != m_type) { for (uint i=0; i<list.size(); ++i) { respond["ulist"][i]["uname"] = list[i].user; } } sprintf(errinfo, "del user list error"); LOG_ERR("DelUser(): %s", errinfo); respond["info"] = errinfo; return OnRequest(respond, CMD_ERR); } return RequestOk(respond); } Packet *AuthJsonMgr::GetUser(const Packet *p) { LOG_DBG("GetUser()\n"); Json::Value request, respond; int ret = JsonValue(p, request); if (ret < 0) { return RequestError("parse request error"); } bool bRet = false; char errinfo[256] = {0}; respond["type"] = m_type; do { if (m_type == AUTH_NULL) { sprintf(errinfo, "no auth type configured!"); bRet = true; break; } CUserOper::UserInfoList list; if (!m_user->GetUserList(list)) { sprintf(errinfo, "GetUserList error"); LOG_ERR("GetUser(): %s", errinfo); break; } // 获取组列表 CUserOper::GroupInfoList glist; if (!m_user->GetGroupList(glist)) { sprintf(errinfo, "GetGroupList error"); LOG_ERR("GetUser(): %s", errinfo); break; } for (uint i = 0; i < list.size(); ++i) { CUserOper::UserInfo& info = list[i]; respond["ulist"][i]["uid"] = info.uid; respond["ulist"][i]["uname"] = info.user; respond["ulist"][i]["issetpwd"] = info.issetpwd; respond["ulist"][i]["type"] = m_type; respond["ulist"][i]["gid"] = info.gid; for (uint j = 0; j < glist.size(); ++j) { if (glist[j].gid == info.gid) { respond["ulist"][i]["gname"] = glist[j].group; break; } } } for (uint i = 0; i < glist.size(); ++i) { respond["glist"][i]["gname"] = glist[i].group; respond["glist"][i]["gid"] = glist[i].gid; respond["glist"][i]["type"] = m_type; } bRet = true; } while (false); if (!bRet) { return RequestError(errinfo); } return RequestOk(respond); } Packet *AuthJsonMgr::SetUser(const Packet *p) { LOG_DBG("SetUser()\n"); Json::Value request, respond; int ret = JsonValue(p, request); if (ret < 0) { return RequestError("parse request error"); } CUserOper::UserInfoList list; char errinfo[256] = {0}; bool bRet = true; for (uint i=0; i<request["ulist"].size(); ++i) { CUserOper::UserInfo user; user.user = request["ulist"][i]["uname"].isNull() ? string() : request["ulist"][i]["uname"].asString(); if (user.user.empty()) { continue; } user.uid = request["ulist"][i]["uid"].isNull() ? 0 : atoi(request["ulist"][i]["uid"].asString().c_str()); user.pwd = request["ulist"][i]["pwd"].isNull() ? string() : request["ulist"][i]["pwd"].asString(); if (!m_user->SetUserPwd(user)) { bRet = false; list.push_back(user); } bRet || (bRet = true); } if (!bRet) { respond["type"] = m_type; if (AUTH_NULL != m_type) { for (uint i=0; i<list.size(); ++i) { respond["ulist"][i]["uname"] = list[i].user; } } sprintf(errinfo, "set user passwd error"); LOG_ERR("SetUser(): %s", errinfo); respond["info"] = errinfo; return OnRequest(respond, CMD_ERR); } return RequestOk(respond); } Packet *AuthJsonMgr::GetGroupQuota(const Packet *p) { LOG_DBG("GetGroupQuota()\n"); Json::Value request, respond; int ret = JsonValue(p, request); if (ret < 0) { return RequestError("parse request error"); } return RequestOk(respond); } Packet *AuthJsonMgr::SetGroupQuota(const Packet *p) { LOG_DBG("SetGroupQuota()\n"); Json::Value request, respond; int ret = JsonValue(p, request); if (ret < 0) { return RequestError("parse request error"); } return RequestOk(respond); } Packet *AuthJsonMgr::GetUserQuota(const Packet *p) { LOG_DBG("GetUserQuota()\n"); Json::Value request, respond; int ret = JsonValue(p, request); if (ret < 0) { return RequestError("parse request error"); } return RequestOk(respond); } Packet *AuthJsonMgr::SetUserQuota(const Packet *p) { LOG_DBG("SetUserQuota()\n"); Json::Value request, respond; int ret = JsonValue(p, request); if (ret < 0) { return RequestError("parse request error"); } return RequestOk(respond); } void AuthJsonMgr::ResumeUserType() { std::string path2 = CONF_SMB; CConfParser conf2(path2); conf2.Load(); conf2.SetVal("[global]", "security", "user"); conf2.Write(); system("authconfig --updateall --disableldap --disableldapauth --disablekrb5 --disablekrb5kdcdns --disablekrb5realmdns " "--disablewinbind --disablewinbindauth --disablewinbindusedefaultdomain --disablenis"); char cmd[1500] = {0}; sprintf(cmd, "cat /etc/resolv.conf.NAS_AD_RESERVE_PREINST"); if (system(cmd) == 0) { memset(cmd,0,1500); sprintf(cmd, "\\mv /etc/resolv.conf.NAS_AD_RESERVE_PREINST /etc/resolv.conf"); system(cmd); } }
[ "gfl@localhost.localdomain" ]
gfl@localhost.localdomain
6e7918d5df4bd1c2bd1af401426aa9a02658c0ce
4c97f219d0a7896495d258a0e1a5f0cc3fd045e9
/src/propagation-of-uncertainty-calculator/propagation-of-uncertainty-calculator.cpp
5345daf735ef967d7c0edf8a3b54b07a2e06b4bc
[]
no_license
diamant711/Analysis
dee7fdc95c2eb3c92513b3920642396058219039
aa35fde40b7394b31a5b919e83eec3acc90fd172
refs/heads/master
2023-05-13T15:48:40.699009
2021-06-04T13:45:19
2021-06-04T13:45:19
373,458,068
0
0
null
null
null
null
UTF-8
C++
false
false
4,821
cpp
#include "propagation-of-uncertainty-calculator.h" #include <fstream> static void save_propagation_data(propagation_data *data){ ofstream file_out; file_out.open(FILE_LOG); if(!file_out.good()){ cout << "Error on opening file" << endl; } file_out << data->formula << endl; file_out << data->num_par << endl; for(int i = 0; i < data->num_par; i++) file_out << data->parameters[i][0] << ' ' << data->parameters[i][1] << endl; for(int i = 0; i < data->num_par; i++) file_out << data->parameters_name[i] << endl; } static bool restore_propagation_data(propagation_data *data){ char sel; ifstream file_in; file_in.open(FILE_LOG); if(!file_in.good()){ return 0; } data->formula = new char[100]; file_in >> data->formula; file_in >> data->num_par; data->parameters = new double*[data->num_par]; for(int i = 0; i < data->num_par; i++){ data->parameters[i] = new double[2]; file_in >> data->parameters[i][0] >> data->parameters[i][1]; } data->parameters_name = new char*[data->num_par]; for(int i = 0; i < data->num_par; i++){ data->parameters_name[i] = new char[6]; file_in >> data->parameters_name[i]; } cout << "Formula = " << data->formula << endl; for(int i = 0; i < data->num_par; i++) cout << "[" << i << "] ~ " << data->parameters_name[i] << " = " << data->parameters[i][0] << " +- " << data->parameters[i][1] << endl; while(1){ cout << "Use this data? [y/m/n] "; cin >> sel; switch (sel) { case 's': return 1; break; case 'm': int sel2; cout << "What do you want to modify? formula (-1), parameters (0:" << data->num_par - 1 << "): "; cin >> sel2; if(sel2 <= -1) { cout << "New formula = "; cin >> data->formula; save_propagation_data(data); return 1; } else if(sel2 >= 0) { cout << data->parameters_name[sel2] << " = "; cin >> data->parameters[sel2][0]; cout << "Sigma " << data->parameters_name[sel2] << " = "; cin >> data->parameters[sel2][1]; save_propagation_data(data); return 1; } else { return 0; } break; case 'n': for(int i = 0; i < data->num_par; i++){ delete[] data->parameters_name[i]; delete[] data->parameters[i]; } delete[] data->parameters; delete[] data->parameters_name; delete[] data->formula; return 0; break; default: cout << "Error on input, retry" << endl; break; } } } static char* replace_param(propagation_data *data, int par, char *mod_formula){ mod_formula = new char[strlen(data->formula) - 2]; for(int i = 0; data->formula[i] != '\0'; i++){ if(data->formula[i] == '['){ if(data->formula[i + 1] == (par + 48)){ if(data->formula[i + 2] == ']'){ for(int j = 0; j < i; j++) mod_formula[j] = data->formula[j]; mod_formula[i] = 'x'; int k = 1; for(int j = i + 3; data->formula[j] != '\0'; j++){ mod_formula[j - 2] = data->formula[j]; k++; } mod_formula[i + k] = '\0'; } } } } return mod_formula; } void propagation_data_in_parser(propagation_data *data){ if(!restore_propagation_data(data)){ cout << "Insert a relation: "; data->formula = new char[100]; cin >> data->formula; for(int i = 0; data->formula[i] != '\0'; i++){ if(data->formula[i] == '['){ if (data->formula[i + 2] == ']') { data->num_par = (data->formula[i + 1] - 48 + 1); } } } data->parameters = new double*[data->num_par]; data->parameters_name = new char*[data->num_par]; for(int i = 0; i < data->num_par; i++){ cout << "Parameter name [" << i << "] : "; data->parameters_name[i] = new char[6]; cin >> data->parameters_name[i]; cout << data->parameters_name[i] << " = "; data->parameters[i] = new double[2]; cin >> data->parameters[i][0]; cout << "Sigma " << data->parameters_name[i] << " = "; cin >> data->parameters[i][1]; } save_propagation_data(data); } } void propagation_data_calculus(propagation_data *data){ TF1 *func; double partial_result = 0; char *mod_formula = NULL; for(int i = 0; i < data->num_par; i++){ func = new TF1("func", replace_param(data, i, mod_formula)); for(int j = 0; j < data->num_par; j++) if(i != j) func->SetParameter(j, data->parameters[j][0]); partial_result += pow(func->Derivative(data->parameters[i][0]), 2) * pow(data->parameters[i][1], 2); delete func; } delete[] mod_formula; data->result = sqrt(partial_result); } void propagation_data_output(propagation_data *data){ char *mod_formula; TF1 *func = new TF1("func", replace_param(data, 0, mod_formula)); for(int i = 1; i < data->num_par; i++) func->SetParameter(i, data->parameters[i][0]); cout << endl << "Result = " << func->Eval(data->parameters[0][0]) << " +- " << data->result << endl; delete func; delete[] mod_formula; }
[ "53996598+diamant711@users.noreply.github.com" ]
53996598+diamant711@users.noreply.github.com
1015caff7a036beb2db439e3548540a7a7686942
1ae555d3088dc123836060371fc520bf0ff13e52
/atcoder/abc151/c.cpp
ee5c19ac3f895229598ecf8d9ae0535aa172fe32
[]
no_license
knagakura/procon
a87b9a1717674aeb5ee3da0301d465e95c758fde
c6ac49dbaaa908ff13cb0d9af439efe5439ec691
refs/heads/master
2022-01-31T19:46:33.535685
2022-01-23T11:59:02
2022-01-23T11:59:02
161,764,993
0
0
null
null
null
null
UTF-8
C++
false
false
1,554
cpp
#include <bits/stdc++.h> using namespace std; #define rep(i,N) for(int i=0;i<int(N);++i) #define rep1(i,N) for(int i=1;i<int(N);++i) #define all(a) (a).begin(),(a).end() #define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; } #define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; } #define bit(k) (1LL<<(k)) typedef long long ll; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } const int INF = 1e9; const ll INFLL = 1e18; const ll MOD = 1e9+7; const double PI = acos(-1.0); const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; /*------------------------------------/ for library*/ /*------------------------------------*/ int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); int N,M; cin>>N>>M; vector<int> p(M); vector<string> S(M); rep(i,M){ cin>>p[i]>>S[i]; p[i]--; } vector<bool> ACed(N,false); vector<int> pena(N,0); rep(i,M){ if(ACed[p[i]])continue; if(S[i] == "AC"){ ACed[p[i]] = true; } if(S[i] == "WA")pena[p[i]]++; } int penasum = 0; int acsum = 0; rep(i,N){ if(ACed[i]){ acsum++; penasum += pena[i]; } } cout<<acsum<<" "<<penasum<<endl; }
[ "knagakura@bs.s.u-tokyo.ac.jp" ]
knagakura@bs.s.u-tokyo.ac.jp
fd4c1d6c1647c27161b2140a1ec9c1f49fdc5ff8
e0acf68d2caf0ea2556a7d0a23d5117e44fb81f7
/HSTracker/Utility/CardMissing/CardMissingDetector.cpp
75b2ec17a446bf3168252209d5238d3be6e7e7c8
[ "MIT" ]
permissive
nicgrayson/HSTracker
8264e47d11d21e450608bc424ccfa09763d01f72
c7df66d3d277bffc3dcf0725b175b0beacc362fc
refs/heads/master
2021-01-21T01:33:55.339490
2017-01-21T07:24:54
2017-01-21T07:24:54
79,630,614
0
0
null
2017-01-21T07:19:47
2017-01-21T07:19:47
null
UTF-8
C++
false
false
3,539
cpp
// // CardMissingDetector.cpp // HSTracker // // Created by Benjamin Michotte on 31/10/16. // Copyright © 2016 Benjamin Michotte. All rights reserved. // #include "CardMissingDetector.hpp" #include <iostream> #include <corefoundation/corefoundation.h> CardMissingDetector::CardMissingDetector() { didInit = false; try { detector = cv::xfeatures2d::SIFT::create(); CFBundleRef mainBundle = CFBundleGetMainBundle(); CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle); char path[PATH_MAX]; if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX)) { std::cerr << "Failed to load cards images, card detection will fail" << std::endl; } CFRelease(resourcesURL); for(int test_lock = 0; test_lock <= 1; test_lock++) { std::ostringstream string; string << path << "/lock_" << test_lock << ".png"; cv::Mat img_lock = cv::imread(string.str(), 0); std::vector<cv::KeyPoint> keypoints_lock; detector->detect(img_lock, keypoints_lock); cv::Mat descriptors_lock; detector->compute(img_lock, keypoints_lock, descriptors_lock); descriptorsForLocks.push_back(descriptors_lock); } didInit = true; } catch (const std::length_error& e) { std::cerr << "Error: Failed to initialize CardMissingDetector" << std::endl; std::cerr << "Caught std::length_error what=" << e.what() << std::endl; didInit = false; } } int CardMissingDetector::detectLocks(std::string tempfile) { if (!didInit) { std::cerr << "Error: Called detectLocks on uninitialized CardMissingDetector." << std::endl; return -2; } try { cv::Mat img_screen = cv::imread(tempfile, 0); cv::Ptr<cv::Feature2D> detector = cv::xfeatures2d::SIFT::create(); std::vector<cv::KeyPoint> keypoints_screen; detector->detect(img_screen, keypoints_screen); cv::Mat descriptors_screen; detector->compute(img_screen, keypoints_screen, descriptors_screen); int best_match = 0; int best_lock = 0; for(int test_lock = 0; test_lock <= 1; test_lock++) { cv::FlannBasedMatcher matcher; std::vector< std::vector<cv::DMatch> > matches; matcher.knnMatch(descriptors_screen, descriptorsForLocks[test_lock], matches, 2); std::vector<cv::DMatch> good_matches; for (int i=0; i<matches.size(); i++) { cv::DMatch nn1 = matches[i][0]; cv::DMatch nn2 = matches[i][1]; if (nn1.distance < ratio_test_ratio * nn2.distance) { good_matches.push_back(matches[i][0]); } } // std::cout << "Matches for rank " << test_lock << ": " << good_matches.size() << std::endl; if (good_matches.size() > best_match) { best_match = int(good_matches.size()); best_lock = test_lock; } } if (best_match > nmatches_threshold) { return best_lock; } else { return -1; } } catch (const std::length_error& e) { std::cerr << "Caught std::length_error in detectLocks, what=" << e.what() << std::endl; return -3; } } bool CardMissingDetector::getDidInit() { return didInit; }
[ "bmichotte@gmail.com" ]
bmichotte@gmail.com
1694a70abc0c7de1cce3fbc0b48375bae326dfc4
3b71fc0d749fe2d22d61d5cfcd2e919edf33f719
/src/qt/sendcoinsentry.cpp
ff046e57e317cd60bed67b9cae806b3bc9d759ea
[ "MIT" ]
permissive
PacoBits/MoneyBagCoin
3cc7350759779501ae358fb05490cb2fe3869d26
88f1607eb49366af465814c7803ce35b7c5e12fc
refs/heads/master
2020-03-25T08:06:15.145471
2018-08-05T08:55:47
2018-08-05T08:55:47
143,597,554
2
0
null
2018-08-05T08:53:27
2018-08-05T08:53:26
null
UTF-8
C++
false
false
4,521
cpp
#include "sendcoinsentry.h" #include "ui_sendcoinsentry.h" #include "guiutil.h" #include "bitcoinunits.h" #include "addressbookpage.h" #include "walletmodel.h" #include "optionsmodel.h" #include "addresstablemodel.h" #include "stealth.h" #include <QApplication> #include <QClipboard> SendCoinsEntry::SendCoinsEntry(QWidget *parent) : QFrame(parent), ui(new Ui::SendCoinsEntry), model(0) { ui->setupUi(this); #ifdef Q_OS_MAC ui->payToLayout->setSpacing(4); #endif #if QT_VERSION >= 0x040700 /* Do not move this to the XML file, Qt before 4.7 will choke on it */ ui->addAsLabel->setPlaceholderText(tr("Enter a label for this address to add it to your address book")); ui->payTo->setPlaceholderText(tr("Enter a MoneyBagCoin address (e.g. MrBD1wq3nSdpefyQXhLQuXQWAk7Jd7o474)")); #endif setFocusPolicy(Qt::TabFocus); setFocusProxy(ui->payTo); GUIUtil::setupAddressWidget(ui->payTo, this); } SendCoinsEntry::~SendCoinsEntry() { delete ui; } void SendCoinsEntry::on_pasteButton_clicked() { // Paste text from clipboard into recipient field ui->payTo->setText(QApplication::clipboard()->text()); } void SendCoinsEntry::on_addressBookButton_clicked() { if(!model) return; AddressBookPage dlg(AddressBookPage::ForSending, AddressBookPage::SendingTab, this); dlg.setModel(model->getAddressTableModel()); if(dlg.exec()) { ui->payTo->setText(dlg.getReturnValue()); ui->payAmount->setFocus(); } } void SendCoinsEntry::on_payTo_textChanged(const QString &address) { if(!model) return; // Fill in label from address book, if address has an associated label QString associatedLabel = model->getAddressTableModel()->labelForAddress(address); if(!associatedLabel.isEmpty()) ui->addAsLabel->setText(associatedLabel); } void SendCoinsEntry::setModel(WalletModel *model) { this->model = model; if(model && model->getOptionsModel()) connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); connect(ui->payAmount, SIGNAL(textChanged()), this, SIGNAL(payAmountChanged())); clear(); } void SendCoinsEntry::setRemoveEnabled(bool enabled) { ui->deleteButton->setEnabled(enabled); } void SendCoinsEntry::clear() { ui->payTo->clear(); ui->addAsLabel->clear(); ui->payAmount->clear(); ui->payTo->setFocus(); // update the display unit, to not use the default ("BTC") updateDisplayUnit(); } void SendCoinsEntry::on_deleteButton_clicked() { emit removeEntry(this); } bool SendCoinsEntry::validate() { // Check input validity bool retval = true; if(!ui->payAmount->validate()) { retval = false; } else { if(ui->payAmount->value() <= 0) { // Cannot send 0 coins or less ui->payAmount->setValid(false); retval = false; } } if(!ui->payTo->hasAcceptableInput() || (model && !model->validateAddress(ui->payTo->text()))) { ui->payTo->setValid(false); retval = false; } return retval; } SendCoinsRecipient SendCoinsEntry::getValue() { SendCoinsRecipient rv; rv.address = ui->payTo->text(); rv.label = ui->addAsLabel->text(); rv.amount = ui->payAmount->value(); if (rv.address.length() > 75 && IsStealthAddress(rv.address.toStdString())) rv.typeInd = AddressTableModel::AT_Stealth; else rv.typeInd = AddressTableModel::AT_Normal; return rv; } QWidget *SendCoinsEntry::setupTabChain(QWidget *prev) { QWidget::setTabOrder(prev, ui->payTo); QWidget::setTabOrder(ui->payTo, ui->addressBookButton); QWidget::setTabOrder(ui->addressBookButton, ui->pasteButton); QWidget::setTabOrder(ui->pasteButton, ui->deleteButton); QWidget::setTabOrder(ui->deleteButton, ui->addAsLabel); return ui->payAmount->setupTabChain(ui->addAsLabel); } void SendCoinsEntry::setValue(const SendCoinsRecipient &value) { ui->payTo->setText(value.address); ui->addAsLabel->setText(value.label); ui->payAmount->setValue(value.amount); } bool SendCoinsEntry::isClear() { return ui->payTo->text().isEmpty(); } void SendCoinsEntry::setFocus() { ui->payTo->setFocus(); } void SendCoinsEntry::updateDisplayUnit() { if(model && model->getOptionsModel()) { // Update payAmount with the current unit ui->payAmount->setDisplayUnit(model->getOptionsModel()->getDisplayUnit()); } }
[ "moneybagcoins@gmail.com" ]
moneybagcoins@gmail.com
de9e1e615fd6432d243807d6bb69776e8416a8af
f93238259313cf6122932a94aafe696a060f7896
/codeforces/1093/D.cpp
b24425ac814c8f2b1b5afdde2bbcfacdc1bfafd0
[]
no_license
SubhashPadala/Codeforces
639efb57b74bd3eceb0745501fc61328ae4b4fb7
e9d42440b4a3fec6343cc32760ade23b092f3414
refs/heads/master
2023-08-08T04:44:54.402270
2021-07-19T07:58:00
2021-09-23T09:29:53
409,528,312
0
0
null
null
null
null
UTF-8
C++
false
false
3,661
cpp
// Problem ID - 1093D // _____ ___ __ // ___________(_)___ ________ ___ | / / // __ ___/__ / __ | / /_ __ `/__ | / / // _(__ ) _ / __ |/ / / /_/ / __ |/ / // /____/ /_/ _____/ \__,_/ _____/ // ________________________ ________ ______ ______ ______ _________ // ____ _/____ _/___ __/ ___ __ \______ ____ /______ ____ /_____ /________ _______ / // __ / __ / __ / __ /_/ /_ __ `/__ / _ __ `/__ //_/__ //_/_ __ `/_ __ / // __/ / __/ / _ / _ ____/ / /_/ / _ / / /_/ / _ ,< _ ,< / /_/ / / /_/ / // /___/ /___/ /_/ /_/ \__,_/ /_/ \__,_/ /_/|_| /_/|_| \__,_/ \__,_/ // #include "bits/stdc++.h" using namespace std; template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; } template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; } void dbg_out() { cerr << endl; } template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); } #ifdef KILL_BUG #define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__) #else #define dbg(...) #endif #define IOS ios::sync_with_stdio(false) #define TIE cin.tie(0);cout.tie(0) #define fi first #define se second #define pb push_back #define int long long #define mp make_pair #define ln "\n" #define case cout << "Case #" << cno << ": " << ln #define sz(x) ((int)(x).size()) #define prec(x) cout << fixed << showpoint; cout << setprecision(x) #define rep(i, a, b) for(int i = a; i < b; i++) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() using vi = vector<int>; using pii = pair<int, int>; using vp = vector<pii>; using vv = vector<vector<int>>; using mii = map<int, int>; const int MOD = (int)1e9 + 7; const int MOD2 = (int)998244353; const int inf = (int)1e18 + 1; int binexp(int a, int n) { int res = 1; while (n > 0) { if (n & 1) res = res * a; a = a * a; n >>= 1; } return res; } int binexp(int a, int n, int m) { a %= m; int res = 1; while (n > 0) { if (n & 1) res = (res * a) % m; a = (a * a) % m; n >>= 1; } return res; } void reset(){ } vv adj; vi visited, color; bool dfs(int u, int c, vi&cnt) { color[u] = c; cnt[c]++; for(auto&i: adj[u]) { if(color[i]==-1) { if(!dfs(i, !c, cnt)) return false; } else if(color[i]==c) return false; } return true; } void runtestcase() { int n, m; cin>>n>>m; adj.assign(n, vi()); visited.assign(n, 0); color.assign(n, -1); vi pow2(n+1); pow2[0] = 1; for(int i = 1; i <= n; i++) pow2[i] = (pow2[i-1]*2)%MOD2; rep(i, 0, m) { int a, b; cin>>a>>b; a--, b--; adj[a].pb(b); adj[b].pb(a); } vi cnt(2); int ans = 1; for(int i = 0; i < n; i++) { if(color[i]==-1) { if(!dfs(i, 0, cnt)) { cout << 0 << ln; return; } //ans+=(2*cnt)%MOD2; int k = (pow2[cnt[0]]+pow2[cnt[1]])%MOD2; //dbg(k, cnt); ans = (ans*k)%MOD2; cnt.assign(2, 0); } } cout << ans << ln; return; } int32_t main() { IOS; #ifndef KILL_BUG TIE; #endif int testcase = 1; cin >> testcase; rep(tc, 1, testcase+1) { dbg(tc); reset(); runtestcase(); } return 0; }
[ "111901038@smail.iitpkd.ac.in" ]
111901038@smail.iitpkd.ac.in
6d562412617baa897080303b9d1a2936c217313c
d311c5c45071c02170a0dc0be733b051863c9483
/dark_possible.cpp
a5ae8b3e640272e3a0310dba40207e15bcacf7bb
[]
no_license
MatthewJulian/Frozlunky
889d5cc1b88084f48edc60836d5907e0363b6c76
8385dd74aaa1fba992dfe08ba51ab6d952535f96
refs/heads/master
2022-10-19T07:18:42.403555
2020-06-07T18:42:44
2020-06-07T18:45:33
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,469
cpp
#include "dark_possible.h" BYTE dark_find[] = {0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x4E, 0x00, 0x00, 0x7D, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x00, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}; std::string dark_mask = "x.....xxxxx.x.....x.x.....x"; BYTE check_patch[] = {0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90}; DarkPossiblePatch::DarkPossiblePatch(std::shared_ptr<Spelunky> spel) : Patch(spel), is_valid(true), orig_check(nullptr) { dark_determine = spel->get_stored_hook("drkf"); if(dark_determine == 0x0) { dark_determine = spel->find_mem(dark_find, dark_mask); if(dark_determine == 0x0) { is_valid = false; return; } dark_determine += 0x14; #ifdef DEBUG_MODE std::cout << "Found dark_determine at " << std::setbase(16) << dark_determine << std::endl; #endif spel->store_hook("drkf", dark_determine); } dark_check_pos = dark_determine-0x4C; orig_check = new BYTE[sizeof(check_patch)]; spel->read_mem(dark_check_pos, orig_check, sizeof(check_patch)); } DarkPossiblePatch::~DarkPossiblePatch() { if(orig_check != nullptr) { delete[] orig_check; orig_check = nullptr; } } bool DarkPossiblePatch::_perform() { spel->write_mem(dark_check_pos, check_patch, sizeof(check_patch)); return true; } bool DarkPossiblePatch::_undo() { spel->write_mem(dark_check_pos, orig_check, sizeof(check_patch)); return true; }
[ "sashavol@sashavol.com" ]
sashavol@sashavol.com
25e34aef2362379523f7c0e195a198704ae37484
8d2f78fe90d2baa34ec7ec6a84a4522391a2a9c7
/AcStp/AccStp01/AccStpGT03/AccStpGT03.ino
4b326c4aa76b54a8286eba11cdf1abf9765b50a1
[]
no_license
SelimBenIsmail/stage_lisa
d006cb516c6abcfbe3ae3fe13a3bbbea15a952ed
c1dfedc1837c68cf10b9237cc59d3250c89ad556
refs/heads/master
2022-11-17T06:45:48.613399
2020-07-14T14:12:12
2020-07-14T14:12:12
279,605,884
0
0
null
null
null
null
UTF-8
C++
false
false
4,035
ino
#include <AccelStepper.h> #include <IRremote.h> #define RECV 2 //PORTD2 #define EN 3 //PORTD3 // intérêt ? #define m0 4 //PORTD4 #define m1 5 //PORTD5 #define m2 6 //PORTD6 #define DIR 8 //PORTB0 #define STEP 7 //PORTD7 #define RLED 16 #define GLED 15 class MStepper: public AccelStepper { public: MStepper():AccelStepper(AccelStepper::DRIVER,STEP,DIR) {} void stop1() { if (_direction == DIRECTION_CW) moveTo(currentPosition() + 1600); else moveTo(currentPosition() - 1600); }// end stop1 int aquiNum(uint8_t led, decode_results objIRdecode, IRrecv objIRrecv){ int tab[3]= {0xff,0xff,0xff}; int angle =0; int i; String codeIR; pinMode(led,OUTPUT); digitalWrite (led, HIGH); delay(1000); //anti rebond for(i=0;i<3;i++){ while(tab[i]==0xff){ if(objIRrecv.decode(&objIRdecode)){ codeIR =objIRdecode.value; if (codeIR == "551520375") //switchcase ne fonctionnent qu'avec des int ou des char, pas avec des strings tab[i] = 1; else if (codeIR == "551504055") tab[i] = 2; else if (codeIR == "551536695") tab[i] = 3; else if (codeIR == "551495895") tab[i] = 4; else if (codeIR == "551528535") tab[i] = 5; else if (codeIR == "551512215") tab[i] = 6; else if (codeIR == "551544855") tab[i] = 7; else if (codeIR == "551491815") tab[i] = 8; else if (codeIR == "551524455") tab[i] = 9; else if (codeIR == "551487735") tab[i] = 0; delay(500); objIRrecv.resume(); // Receive the next value }// end if }// end while Serial.print(tab[i]); }// end for digitalWrite (led, LOW); angle = (tab[0]*100 + tab[1]*10 + tab[2])% 360; if (!angle) angle = 360; Serial.println(""); Serial.print("Angle: "); Serial.println(angle); angle = angle*17.777; // conversion en step (configuré sur un mode micro step: 1,8°/32) Serial.print("Step: "); Serial.println(angle); return angle; }// end aquiNum protected: /* void step(long step) { if (_direction) PORTB = PORTB | 0x01; else PORTB = PORTB & 0xFE; PORTD = PORTD | 0x80; delayMicroseconds(2); PORTD = PORTD & 0x7F; }*/ }; decode_results resultsIR; IRrecv irrecv(RECV); MStepper turntableMotor; bool enableMotor = HIGH; void setup(){ Serial.begin(115200); pinMode (EN, OUTPUT); pinMode( m0 , OUTPUT ); pinMode( m1 , OUTPUT ); pinMode( m2 , OUTPUT ); pinMode( GLED , OUTPUT ); digitalWrite(EN, LOW); digitalWrite(m0 , HIGH); digitalWrite(m1 , HIGH); digitalWrite(m2 , HIGH); turntableMotor.setMaxSpeed(1800); turntableMotor.setAcceleration(800); Serial.println("Enabling IRin"); irrecv.enableIRIn(); // Start the receiver Serial.println("Enabled IRin"); digitalWrite (GLED, HIGH); } void loop(){ if(irrecv.decode(&resultsIR)){ String codeIR = String(resultsIR.value) ; irrecv.resume(); // Receive the next value // Serial.println(resultsIR.value); if (codeIR == "551489775"){ //Bouton off enableMotor = !enableMotor ; digitalWrite(EN,enableMotor); } else if(codeIR == "551485695"){ // Bouton Prog + turntableMotor.move(1600); //1/4 de tour while(turntableMotor.distanceToGo()>0) turntableMotor.run(); } else if (codeIR == "551540010"){ // Bouton Guide. Serial.println("entrez le position à atteindre en degré"); turntableMotor.moveTo (turntableMotor.aquiNum(RLED,resultsIR,irrecv)); while(turntableMotor.distanceToGo()>0) turntableMotor.run(); } delay(500); }// end if IRrecv digitalWrite (GLED, !enableMotor); }// end Main loop
[ "skorm-xci@live.be" ]
skorm-xci@live.be
f1bc25245bccf902285d159f4e80e3893b9d802e
916ef1b31f0b683de4f043626d9df59f37edbbc4
/atcoder/05_AtCoder-Beginner-Contest/abc176/C/main.cpp
3d881693fbb6e466e100a9ef6c37c7774e62346b
[]
no_license
solareenlo/cpp
56cc33673d30dd4a4031e4b81cec16b08b3490e0
f78f8a098849938153e6e3a282737e067dbe2c58
refs/heads/master
2021-03-31T04:31:39.420394
2020-11-29T22:22:25
2020-11-29T22:22:25
248,076,420
0
0
null
null
null
null
UTF-8
C++
false
false
373
cpp
#include <bits/stdc++.h> #define REP(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; int main() { cin.tie(0)->sync_with_stdio(false); int n; cin >> n; vector<ll> a(n); REP(i, n) cin >> a[i]; ll sum = 0; REP(i, n - 1) { if (a[i+1] < a[i]) { sum += a[i] - a[i+1]; a[i+1] = a[i]; } } cout << sum << '\n'; return 0; }
[ "solareenlo@gmail.com" ]
solareenlo@gmail.com
59e8005dcf26e85ab5abeebef2eb3812bf2636a7
a35b30a7c345a988e15d376a4ff5c389a6e8b23a
/boost/regex/v4/regex_match.hpp
e56ac2f53685046b685993f81e45a2b14341f456
[]
no_license
huahang/thirdparty
55d4cc1c8a34eff1805ba90fcbe6b99eb59a7f0b
07a5d64111a55dda631b7e8d34878ca5e5de05ab
refs/heads/master
2021-01-15T14:29:26.968553
2014-02-06T07:35:22
2014-02-06T07:35:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
66
hpp
#include "thirdparty/boost_1_55_0/boost/regex/v4/regex_match.hpp"
[ "liuhuahang@xiaomi.com" ]
liuhuahang@xiaomi.com
f906c073b90be9f9eb0c7eb3b54e4d251c2468ae
5913ce5afbdff2fe8e7cf7bc65e1172b94b6dd0d
/File.cpp
2cc73d8591a11f8d086adf94b2ff549f2c1172fe
[]
no_license
Anonymous-solver/codingWithCpp
1271dba1ffd60201fe1d8c6a30aeeaa9dd88e6f6
755eb2bb0c902b5f1314857263cad2e4c927f714
refs/heads/main
2023-05-14T07:16:19.573320
2021-06-03T20:35:38
2021-06-03T20:35:38
373,632,860
1
0
null
null
null
null
UTF-8
C++
false
false
484
cpp
#include <stdio.h> #include <stdlib.h> int main() { //freopen("Abc.txt","w",stdout); freopen("Output.text","r",stdin); long int i=0; long long arr[100001]; for(i=0;i<=100;i++) { int tm; scanf("%lld ",&arr[i]); // printf("%d ",rand()); } long int src=101; for(i=0;i<=100;i++) { if(arr[i]==src) { printf("Found"); return 0; } } printf("Not Found"); return 0; }
[ "anik.uits29@gmail.com" ]
anik.uits29@gmail.com
47a428f15579aa47e50100090958a9bb20e05f1b
16137a5967061c2f1d7d1ac5465949d9a343c3dc
/cpp_code/strings/03a-ccstrs.cc
c456988fecbb3a54d0dfe6848bd25f9e872437f5
[]
no_license
MIPT-ILab/cpp-lects-rus
330f977b93f67771b118ad03ee7b38c3615deef3
ba8412dbf4c8f3bee7c6344a89e0780ee1dd38f2
refs/heads/master
2022-07-28T07:36:59.831016
2022-07-20T08:34:26
2022-07-20T08:34:26
104,261,623
27
4
null
2021-02-04T21:39:23
2017-09-20T19:56:44
TeX
UTF-8
C++
false
false
292
cc
#include <cassert> #include <string> using std::string; int main () { string astr = "hello"; string bstr; bstr.reserve(15); int alen = astr.length(); assert(alen == 5); bstr = astr; bstr += ", world!"; int res = astr.compare(bstr); assert(res < 0); }
[ "konstantin.vladimirov@gmail.com" ]
konstantin.vladimirov@gmail.com
5c9fc7f8c1a1c6e75a6506324ae57baba09aa320
a851b11e8cb7549f51853e9d325ef0f88d0d619a
/arduino-basic/AlternateLeds/AlternateLeds.ino
4ad8255feccb0f4e46d1728237f2a47c84e63342
[]
no_license
pksingh99/IoT-Samples
75e73dcc407a2fd9128b18eb25353b1c8fd41bd8
51b4bf351756b599df5d2ef1800c9772bd2dd676
refs/heads/master
2021-05-30T05:54:06.201854
2016-01-10T19:27:59
2016-01-10T19:27:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
372
ino
#define greenLed 6 #define redLed 7 void setup(){ Serial.begin(9600); pinMode(greenLed, OUTPUT); pinMode(redLed, OUTPUT); } void loop(){ lightRed(); delay(1000); lightGreen(); delay(1000); } void lightRed(){ digitalWrite(greenLed, LOW); digitalWrite(redLed, HIGH); } void lightGreen(){ digitalWrite(redLed, LOW); digitalWrite(greenLed, HIGH); }
[ "root@Sowmies-MacBook-Pro.local" ]
root@Sowmies-MacBook-Pro.local
80b9d575a719553de4b2b82c7d40a34010c18310
a71582e89e84a4fae2595f034d06af6d8ad2d43a
/tensorflow/compiler/xla/client/xla_builder.cc
cc0e02d8f51314043fcfa8d42b05249ae938f8fa
[ "Apache-2.0" ]
permissive
tfboyd/tensorflow
5328b1cabb3e24cb9534480fe6a8d18c4beeffb8
865004e8aa9ba630864ecab18381354827efe217
refs/heads/master
2021-07-06T09:41:36.700837
2019-04-01T20:21:03
2019-04-01T20:26:09
91,494,603
3
0
Apache-2.0
2018-07-17T22:45:10
2017-05-16T19:06:01
C++
UTF-8
C++
false
false
145,822
cc
/* Copyright 2018 The TensorFlow 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 "tensorflow/compiler/xla/client/xla_builder.h" #include <functional> #include <numeric> #include <queue> #include <string> #include <utility> #include "absl/algorithm/container.h" #include "absl/container/flat_hash_map.h" #include "absl/container/flat_hash_set.h" #include "absl/memory/memory.h" #include "absl/strings/match.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" #include "tensorflow/compiler/xla/client/sharding_builder.h" #include "tensorflow/compiler/xla/client/xla_computation.h" #include "tensorflow/compiler/xla/execution_options_util.h" #include "tensorflow/compiler/xla/service/hlo_input_output_alias_config.h" #include "tensorflow/compiler/xla/service/hlo_instruction.h" #include "tensorflow/compiler/xla/service/hlo_opcode.h" #include "tensorflow/compiler/xla/service/shape_inference.h" #include "tensorflow/compiler/xla/util.h" namespace xla { using absl::StrCat; namespace { static const char kNameSeparator = '.'; // Retrieves the base name of an instruction or computation fully qualified // name, using separator as boundary between the initial base name part, and // the numeric identification. string GetBaseName(const string& name, char separator) { auto pos = name.rfind(separator); CHECK_NE(pos, string::npos) << name; return name.substr(0, pos); } // Generates a fully qualified computation/instruction name. string GetFullName(const string& base_name, char separator, int64 id) { const char separator_str[] = {separator, '\0'}; return StrCat(base_name, separator_str, id); } // Common function to standardize setting name and IDs on computation and // instruction proto entities. template <typename T> void SetProtoIdAndName(T* entry, const string& base_name, char separator, int64 id) { entry->set_id(id); entry->set_name(GetFullName(base_name, separator, id)); } } // namespace XlaOp operator-(const XlaOp& x) { return Neg(x); } XlaOp operator+(const XlaOp& x, const XlaOp& y) { return Add(x, y); } XlaOp operator-(const XlaOp& x, const XlaOp& y) { return Sub(x, y); } XlaOp operator*(const XlaOp& x, const XlaOp& y) { return Mul(x, y); } XlaOp operator/(const XlaOp& x, const XlaOp& y) { return Div(x, y); } XlaOp operator%(const XlaOp& x, const XlaOp& y) { return Rem(x, y); } XlaOp operator~(const XlaOp& x) { return Not(x); } XlaOp operator&(const XlaOp& x, const XlaOp& y) { return And(x, y); } XlaOp operator|(const XlaOp& x, const XlaOp& y) { return Or(x, y); } XlaOp operator^(const XlaOp& x, const XlaOp& y) { return Xor(x, y); } XlaOp operator<<(const XlaOp& x, const XlaOp& y) { return ShiftLeft(x, y); } XlaOp operator>>(const XlaOp& x, const XlaOp& y) { XlaBuilder* builder = x.builder(); return builder->ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { TF_ASSIGN_OR_RETURN(xla::Shape shape, builder->GetShape(x)); if (!ShapeUtil::ElementIsIntegral(shape)) { return InvalidArgument( "Argument to >> operator does not have an integral type (%s).", ShapeUtil::HumanString(shape)); } if (ShapeUtil::ElementIsSigned(shape)) { return ShiftRightArithmetic(x, y); } else { return ShiftRightLogical(x, y); } }); } StatusOr<Shape> XlaBuilder::GetShape(const XlaOp& op) const { TF_RETURN_IF_ERROR(first_error_); TF_ASSIGN_OR_RETURN(auto instr, LookUpInstruction(op)); return Shape(instr->shape()); } StatusOr<std::vector<Shape>> XlaBuilder::GetOperandShapes( absl::Span<const XlaOp> operands) const { std::vector<Shape> operand_shapes; for (const XlaOp& operand : operands) { TF_ASSIGN_OR_RETURN(const Shape& shape, GetShape(operand)); operand_shapes.push_back(shape); } return operand_shapes; } XlaBuilder::XlaBuilder(const string& computation_name) : name_(computation_name) {} XlaBuilder::~XlaBuilder() {} XlaOp XlaBuilder::ReportError(const Status& error) { CHECK(!error.ok()); if (die_immediately_on_error_) { LOG(FATAL) << "error building computation: " << error; } if (first_error_.ok()) { first_error_ = error; first_error_backtrace_.CreateCurrent(/*skip_count=*/1); } return XlaOp(this); } XlaOp XlaBuilder::ReportErrorOrReturn(const StatusOr<XlaOp>& op) { if (!first_error_.ok()) { return XlaOp(this); } if (!op.ok()) { return ReportError(op.status()); } return op.ValueOrDie(); } XlaOp XlaBuilder::ReportErrorOrReturn( const std::function<StatusOr<XlaOp>()>& op_creator) { return ReportErrorOrReturn(op_creator()); } StatusOr<ProgramShape> XlaBuilder::GetProgramShape(int64 root_id) const { TF_RETURN_IF_ERROR(first_error_); TF_ASSIGN_OR_RETURN(const HloInstructionProto* root_proto, LookUpInstructionByHandle(root_id)); ProgramShape program_shape; *program_shape.mutable_result() = Shape(root_proto->shape()); // Check that the parameter numbers are continuous from 0, and add parameter // shapes and names to the program shape. const int64 param_count = parameter_numbers_.size(); for (int64 i = 0; i < param_count; i++) { program_shape.add_parameters(); program_shape.add_parameter_names(); } for (const HloInstructionProto& instr : instructions_) { // Parameter number uniqueness is guaranteed in XlaBuilder::Parameter(). So // to verify continuity, we just need to verify that every parameter is in // the right range. if (instr.opcode() == HloOpcodeString(HloOpcode::kParameter)) { const int64 index = instr.parameter_number(); TF_RET_CHECK(index >= 0 && index < param_count) << "invalid parameter number: " << index; *program_shape.mutable_parameters(index) = Shape(instr.shape()); *program_shape.mutable_parameter_names(index) = instr.name(); } } return program_shape; } StatusOr<ProgramShape> XlaBuilder::GetProgramShape() const { TF_RET_CHECK(!instructions_.empty()); return GetProgramShape(instructions_.back().id()); } StatusOr<ProgramShape> XlaBuilder::GetProgramShape(XlaOp root) const { if (root.builder_ != this) { return InvalidArgument("Given root operation is not in this computation."); } return GetProgramShape(root.handle()); } void XlaBuilder::IsConstantVisitor(const int64 op_handle, absl::flat_hash_set<int64>* visited, bool* is_constant) const { if (visited->contains(op_handle) || !*is_constant) { return; } const HloInstructionProto& instr = *(LookUpInstructionByHandle(op_handle).ValueOrDie()); const HloOpcode opcode = StringToHloOpcode(instr.opcode()).ValueOrDie(); switch (opcode) { default: for (const int64 operand_id : instr.operand_ids()) { IsConstantVisitor(operand_id, visited, is_constant); } // TODO(b/32495713): We aren't checking the called computations. break; case HloOpcode::kGetDimensionSize: { int64 dimension_number = instr.dimensions(0); const HloInstructionProto& operand = *(LookUpInstructionByHandle(instr.operand_ids(0)).ValueOrDie()); Shape operand_shape(operand.shape()); if (operand_shape.is_dynamic_dimension(dimension_number)) { *is_constant = false; } break; } // Non functional ops. case HloOpcode::kRng: case HloOpcode::kAllReduce: // TODO(b/33009255): Implement constant folding for cross replica sum. case HloOpcode::kInfeed: case HloOpcode::kOutfeed: case HloOpcode::kCall: // TODO(b/32495713): We aren't checking the to_apply computation itself, // so we conservatively say that computations containing the Call op // cannot be constant. We cannot set is_functional=false in other similar // cases since we're already relying on IsConstant to return true. case HloOpcode::kCustomCall: case HloOpcode::kWhile: // TODO(b/32495713): We aren't checking the condition and body // computations themselves. case HloOpcode::kScatter: // TODO(b/32495713): We aren't checking the embedded computation in // Scatter. case HloOpcode::kSend: case HloOpcode::kRecv: case HloOpcode::kParameter: *is_constant = false; break; } if (!*is_constant) { VLOG(1) << "Non-constant: " << instr.name(); } visited->insert(op_handle); } Status XlaBuilder::SetDynamicBinding(int64 dynamic_size_param_num, ShapeIndex dynamic_size_param_index, int64 target_param_num, ShapeIndex target_param_index, int64 target_dim_num) { bool param_exists = false; for (HloInstructionProto& instr : instructions_) { if (instr.opcode() == HloOpcodeString(HloOpcode::kParameter) && instr.parameter_number() == target_param_num) { param_exists = true; Shape param_shape(instr.shape()); Shape* param_shape_ptr = &param_shape; for (int64 index : target_param_index) { param_shape_ptr = param_shape_ptr->mutable_tuple_shapes(index); } // TODO(b/121223198): Set `is_dynamic` to the parameter shape when XLA // backend can handle dynamic dimensions. *instr.mutable_shape() = param_shape.ToProto(); } } if (!param_exists) { return InvalidArgument( "Asked to mark parameter %lld as dynamic sized parameter, but the " "doesn't exists", target_param_num); } TF_RETURN_IF_ERROR(dynamic_parameter_binding_.Bind( DynamicParameterBinding::DynamicParameter{dynamic_size_param_num, dynamic_size_param_index}, DynamicParameterBinding::DynamicDimension{ target_param_num, target_param_index, target_dim_num})); return Status::OK(); } XlaComputation XlaBuilder::BuildAndNoteError() { DCHECK(parent_builder_ != nullptr); auto build_status = Build(); if (!build_status.ok()) { parent_builder_->ReportError( AddStatus(build_status.status(), absl::StrCat("error from: ", name_))); return {}; } return build_status.ConsumeValueOrDie(); } Status XlaBuilder::GetCurrentStatus() const { if (!first_error_.ok()) { string backtrace; first_error_backtrace_.Dump(tensorflow::DebugWriteToString, &backtrace); return AppendStatus(first_error_, backtrace); } return Status::OK(); } StatusOr<XlaComputation> XlaBuilder::Build(bool remove_dynamic_dimensions) { TF_RETURN_IF_ERROR(GetCurrentStatus()); return Build(instructions_.back().id(), remove_dynamic_dimensions); } StatusOr<XlaComputation> XlaBuilder::Build(XlaOp root, bool remove_dynamic_dimensions) { if (root.builder_ != this) { return InvalidArgument("Given root operation is not in this computation."); } return Build(root.handle(), remove_dynamic_dimensions); } StatusOr<XlaComputation> XlaBuilder::Build(int64 root_id, bool remove_dynamic_dimensions) { TF_RETURN_IF_ERROR(GetCurrentStatus()); // TODO(b/121223198): XLA backend cannot handle dynamic dimensions yet, remove // all dynamic dimensions before building xla program until we have support in // the backend. if (remove_dynamic_dimensions) { std::function<void(ShapeProto*)> remove_dynamic_dimension = [&](ShapeProto* shape) { if (shape->tuple_shapes_size() != 0) { for (int64 i = 0; i < shape->tuple_shapes_size(); ++i) { remove_dynamic_dimension(shape->mutable_tuple_shapes(i)); } } for (int64 i = 0; i < shape->dimensions_size(); ++i) { shape->set_is_dynamic_dimension(i, false); } }; for (auto& instruction : instructions_) { remove_dynamic_dimension(instruction.mutable_shape()); } } HloComputationProto entry; SetProtoIdAndName(&entry, name_, kNameSeparator, GetNextId()); TF_ASSIGN_OR_RETURN(ProgramShape program_shape, GetProgramShape(root_id)); *entry.mutable_program_shape() = program_shape.ToProto(); entry.set_root_id(root_id); for (auto& instruction : instructions_) { // Ensures that the instruction names are unique among the whole graph. instruction.set_name( GetFullName(instruction.name(), kNameSeparator, instruction.id())); entry.add_instructions()->Swap(&instruction); } XlaComputation computation(entry.id()); HloModuleProto* module = computation.mutable_proto(); module->set_name(entry.name()); module->set_id(entry.id()); module->set_entry_computation_name(entry.name()); module->set_entry_computation_id(entry.id()); *module->mutable_host_program_shape() = entry.program_shape(); for (auto& e : embedded_) { module->add_computations()->Swap(&e.second); } module->add_computations()->Swap(&entry); if (!input_output_aliases_.empty()) { TF_RETURN_IF_ERROR( PopulateInputOutputAlias(module, program_shape, input_output_aliases_)); } *(module->mutable_dynamic_parameter_binding()) = dynamic_parameter_binding_.ToProto(); // Clear data held by this builder. this->instructions_.clear(); this->handle_to_index_.clear(); this->embedded_.clear(); this->parameter_numbers_.clear(); return std::move(computation); } /* static */ Status XlaBuilder::PopulateInputOutputAlias( HloModuleProto* module, const ProgramShape& program_shape, const std::vector<InputOutputAlias>& input_output_aliases) { HloInputOutputAliasConfig config(program_shape.result()); for (auto& alias : input_output_aliases) { // The HloInputOutputAliasConfig does not do parameter validation as it only // carries the result shape. Maybe it should be constructed with a // ProgramShape to allow full validation. We will still get an error when // trying to compile the HLO module, but would be better to have validation // at this stage. if (alias.param_number >= program_shape.parameters_size()) { return InvalidArgument("Invalid parameter number %ld (total %ld)", alias.param_number, program_shape.parameters_size()); } const Shape& parameter_shape = program_shape.parameters(alias.param_number); if (!ShapeUtil::IndexIsValid(parameter_shape, alias.param_index)) { return InvalidArgument("Invalid parameter %ld index: %s", alias.param_number, alias.param_index.ToString().c_str()); } TF_RETURN_IF_ERROR(config.SetUpAlias( alias.output_index, alias.param_number, alias.param_index, HloInputOutputAliasConfig::AliasKind::kUserAlias)); } *module->mutable_input_output_alias() = config.ToProto(); return Status::OK(); } StatusOr<XlaOp> XlaBuilder::InDimBroadcast( const Shape& shape, const XlaOp& operand, absl::Span<const int64> broadcast_dimensions) { TF_RETURN_IF_ERROR(first_error_); HloInstructionProto instr; *instr.mutable_shape() = shape.ToProto(); for (int64 dim : broadcast_dimensions) { instr.add_dimensions(dim); } return AddInstruction(std::move(instr), HloOpcode::kBroadcast, {operand}); } StatusOr<XlaOp> XlaBuilder::AddBroadcastSequence(const Shape& output_shape, const XlaOp& operand) { TF_RETURN_IF_ERROR(first_error_); TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); CHECK(ShapeUtil::IsScalar(operand_shape) || operand_shape.rank() == output_shape.rank()); Shape broadcast_shape = ShapeUtil::ChangeElementType(output_shape, operand_shape.element_type()); // Do explicit broadcast for scalar. if (ShapeUtil::IsScalar(operand_shape)) { return InDimBroadcast(broadcast_shape, operand, {}); } // Do explicit broadcast for degenerate broadcast. std::vector<int64> broadcast_dimensions; std::vector<int64> reshaped_dimensions; for (int i = 0; i < operand_shape.rank(); i++) { if (operand_shape.dimensions(i) == output_shape.dimensions(i)) { broadcast_dimensions.push_back(i); reshaped_dimensions.push_back(operand_shape.dimensions(i)); } else { TF_RET_CHECK(operand_shape.dimensions(i) == 1) << "An explicit broadcast sequence requires the broadcasted " "dimensions to be trivial; operand shape: " << operand_shape << "; output_shape: " << output_shape; } } // Eliminate the size one dimensions. TF_ASSIGN_OR_RETURN(XlaOp reshaped_operand, Reshape(ShapeUtil::MakeShape(operand_shape.element_type(), reshaped_dimensions), operand)); // Broadcast 'reshape' up to the larger size. return InDimBroadcast(broadcast_shape, reshaped_operand, broadcast_dimensions); } XlaOp XlaBuilder::UnaryOp(HloOpcode unop, const XlaOp& operand) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); TF_ASSIGN_OR_RETURN(Shape shape, ShapeInference::InferUnaryOpShape(unop, operand_shape)); *instr.mutable_shape() = shape.ToProto(); return AddInstruction(std::move(instr), unop, {operand}); }); } XlaOp XlaBuilder::BinaryOp(HloOpcode binop, const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> broadcast_dimensions, absl::optional<ComparisonDirection> direction) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& lhs_shape, GetShape(lhs)); TF_ASSIGN_OR_RETURN(const Shape& rhs_shape, GetShape(rhs)); TF_ASSIGN_OR_RETURN(Shape shape, ShapeInference::InferBinaryOpShape( binop, lhs_shape, rhs_shape, broadcast_dimensions)); *instr.mutable_shape() = shape.ToProto(); if (binop == HloOpcode::kCompare) { if (!direction.has_value()) { return InvalidArgument( "kCompare expects a ComparisonDirection, but none provided."); } instr.set_comparison_direction(ComparisonDirectionToString(*direction)); } else if (direction.has_value()) { return InvalidArgument( "A comparison direction is provided for a non-compare opcode: %s.", HloOpcodeString(binop)); } const int64 lhs_rank = lhs_shape.rank(); const int64 rhs_rank = rhs_shape.rank(); XlaOp updated_lhs = lhs; XlaOp updated_rhs = rhs; if (!broadcast_dimensions.empty() && lhs_rank != rhs_rank) { const bool should_broadcast_lhs = lhs_rank < rhs_rank; XlaOp from = should_broadcast_lhs ? lhs : rhs; const Shape& from_shape = should_broadcast_lhs ? lhs_shape : rhs_shape; std::vector<int64> to_size; std::vector<bool> to_size_is_dynamic; for (int i = 0; i < shape.rank(); i++) { to_size.push_back(shape.dimensions(i)); to_size_is_dynamic.push_back(shape.is_dynamic_dimension(i)); } for (int64 from_dim = 0; from_dim < from_shape.rank(); from_dim++) { int64 to_dim = broadcast_dimensions[from_dim]; to_size[to_dim] = from_shape.dimensions(from_dim); to_size_is_dynamic[to_dim] = from_shape.is_dynamic_dimension(from_dim); } const Shape& broadcasted_shape = ShapeUtil::MakeShape( from_shape.element_type(), to_size, to_size_is_dynamic); TF_ASSIGN_OR_RETURN( XlaOp broadcasted_operand, InDimBroadcast(broadcasted_shape, from, broadcast_dimensions)); updated_lhs = should_broadcast_lhs ? broadcasted_operand : lhs; updated_rhs = !should_broadcast_lhs ? broadcasted_operand : rhs; } TF_ASSIGN_OR_RETURN(Shape updated_lhs_shape, GetShape(updated_lhs)); if (!ShapeUtil::SameDimensions(shape, updated_lhs_shape)) { TF_ASSIGN_OR_RETURN(updated_lhs, AddBroadcastSequence(shape, updated_lhs)); } TF_ASSIGN_OR_RETURN(Shape updated_rhs_shape, GetShape(updated_rhs)); if (!ShapeUtil::SameDimensions(shape, updated_rhs_shape)) { TF_ASSIGN_OR_RETURN(updated_rhs, AddBroadcastSequence(shape, updated_rhs)); } return AddInstruction(std::move(instr), binop, {updated_lhs, updated_rhs}); }); } XlaOp XlaBuilder::TernaryOp(HloOpcode triop, const XlaOp& lhs, const XlaOp& rhs, const XlaOp& ehs) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& lhs_shape, GetShape(lhs)); TF_ASSIGN_OR_RETURN(const Shape& rhs_shape, GetShape(rhs)); TF_ASSIGN_OR_RETURN(const Shape& ehs_shape, GetShape(ehs)); TF_ASSIGN_OR_RETURN( Shape shape, ShapeInference::InferTernaryOpShape(triop, lhs_shape, rhs_shape, ehs_shape)); *instr.mutable_shape() = shape.ToProto(); XlaOp updated_lhs = lhs; XlaOp updated_rhs = rhs; XlaOp updated_ehs = ehs; if (!shape.IsTuple()) { if (!lhs_shape.IsTuple() && !ShapeUtil::SameDimensions(shape, lhs_shape)) { // lhs is being implicitly broadcasted. Change to explicit. TF_ASSIGN_OR_RETURN(updated_lhs, AddBroadcastSequence(shape, lhs)); } if (!rhs_shape.IsTuple() && !ShapeUtil::SameDimensions(shape, rhs_shape)) { // rhs is being implicitly broadcasted. Change to explicit. TF_ASSIGN_OR_RETURN(updated_rhs, AddBroadcastSequence(shape, rhs)); } if (!ehs_shape.IsTuple() && !ShapeUtil::SameDimensions(shape, ehs_shape)) { // ehs is being implicitly broadcasted. Change to explicit. TF_ASSIGN_OR_RETURN(updated_ehs, AddBroadcastSequence(shape, ehs)); } } return AddInstruction(std::move(instr), triop, {updated_lhs, updated_rhs, updated_ehs}); }); } XlaOp XlaBuilder::ConstantLiteral(const LiteralSlice& literal) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; *instr.mutable_shape() = literal.shape().ToProto(); *instr.mutable_literal() = literal.ToProto(); return AddInstruction(std::move(instr), HloOpcode::kConstant); }); } XlaOp XlaBuilder::Iota(const Shape& shape, int64 iota_dimension) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; *instr.mutable_shape() = shape.ToProto(); instr.add_dimensions(iota_dimension); return AddInstruction(std::move(instr), HloOpcode::kIota); }); } XlaOp XlaBuilder::Iota(PrimitiveType type, int64 size) { return Iota(ShapeUtil::MakeShape(type, {size}), /*iota_dimension=*/0); } XlaOp XlaBuilder::Call(const XlaComputation& computation, absl::Span<const XlaOp> operands) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; std::vector<const Shape*> operand_shape_ptrs; TF_ASSIGN_OR_RETURN(const auto& operand_shapes, GetOperandShapes(operands)); absl::c_transform(operand_shapes, std::back_inserter(operand_shape_ptrs), [](const Shape& shape) { return &shape; }); TF_ASSIGN_OR_RETURN(const ProgramShape& called_program_shape, computation.GetProgramShape()); TF_ASSIGN_OR_RETURN(Shape shape, ShapeInference::InferCallShape( operand_shape_ptrs, /*to_apply=*/called_program_shape)); *instr.mutable_shape() = shape.ToProto(); AddCalledComputation(computation, &instr); return AddInstruction(std::move(instr), HloOpcode::kCall, operands); }); } XlaOp XlaBuilder::Parameter( int64 parameter_number, const Shape& shape, const string& name, const std::vector<bool>& replicated_at_leaf_buffers) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; if (!parameter_numbers_.insert(parameter_number).second) { return InvalidArgument("parameter %d already registered", parameter_number); } instr.set_parameter_number(parameter_number); instr.set_name(name); *instr.mutable_shape() = shape.ToProto(); if (!replicated_at_leaf_buffers.empty()) { auto replication = instr.mutable_parameter_replication(); for (bool replicated : replicated_at_leaf_buffers) { replication->add_replicated_at_leaf_buffers(replicated); } } return AddInstruction(std::move(instr), HloOpcode::kParameter); }); } XlaOp XlaBuilder::Broadcast(const XlaOp& operand, absl::Span<const int64> broadcast_sizes) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); TF_ASSIGN_OR_RETURN( const Shape& shape, ShapeInference::InferBroadcastShape(operand_shape, broadcast_sizes)); // The client-level broadcast op just appends dimensions on the left (adds // lowest numbered dimensions). The HLO broadcast instruction is more // flexible and can add new dimensions anywhere. The instruction's // dimensions field maps operand dimensions to dimensions in the broadcast // output, so to append dimensions on the left the instruction's dimensions // should just be the n highest dimension numbers of the output shape where // n is the number of input dimensions. const int64 operand_rank = operand_shape.rank(); std::vector<int64> dimensions(operand_rank); for (int i = 0; i < operand_rank; ++i) { dimensions[i] = i + shape.rank() - operand_rank; } return InDimBroadcast(shape, operand, dimensions); }); } XlaOp XlaBuilder::BroadcastInDim( const XlaOp& operand, const absl::Span<const int64> out_dim_size, const absl::Span<const int64> broadcast_dimensions) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); // Output shape, in the case of degenerate broadcast, the out_dim_size is // not necessarily the same as the dimension sizes of the output shape. auto output_shape = ShapeUtil::MakeShape(operand_shape.element_type(), out_dim_size); for (int i = 0; i < broadcast_dimensions.size(); i++) { if (broadcast_dimensions[i] < 0 || broadcast_dimensions[i] > out_dim_size.size()) { return InvalidArgument("Broadcast dimension %lld is out of bound", broadcast_dimensions[i]); } output_shape.set_dynamic_dimension(broadcast_dimensions[i], operand_shape.is_dynamic_dimension(i)); } TF_RETURN_IF_ERROR(ShapeInference::InferBroadcastShape( operand_shape, output_shape, broadcast_dimensions) .status()); std::vector<int64> in_dim_size(out_dim_size.begin(), out_dim_size.end()); for (int i = 0; i < broadcast_dimensions.size(); i++) { in_dim_size[broadcast_dimensions[i]] = operand_shape.dimensions(i); } const auto& in_dim_shape = ShapeUtil::MakeShape(operand_shape.element_type(), in_dim_size); TF_ASSIGN_OR_RETURN( XlaOp in_dim_broadcast, InDimBroadcast(in_dim_shape, operand, broadcast_dimensions)); // If broadcast is not degenerate, return broadcasted result. if (ShapeUtil::Equal(in_dim_shape, output_shape)) { return in_dim_broadcast; } // Otherwise handle degenerate broadcast case. return AddBroadcastSequence(output_shape, in_dim_broadcast); }); } StatusOr<XlaOp> XlaBuilder::Reshape(const Shape& shape, const XlaOp& operand) { TF_RETURN_IF_ERROR(first_error_); HloInstructionProto instr; *instr.mutable_shape() = shape.ToProto(); return AddInstruction(std::move(instr), HloOpcode::kReshape, {operand}); } XlaOp XlaBuilder::Slice(const XlaOp& operand, absl::Span<const int64> start_indices, absl::Span<const int64> limit_indices, absl::Span<const int64> strides) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); TF_ASSIGN_OR_RETURN( Shape shape, ShapeInference::InferSliceShape( operand_shape, start_indices, limit_indices, strides)); *instr.mutable_shape() = shape.ToProto(); for (int i = 0; i < start_indices.size(); i++) { auto* slice_config = instr.add_slice_dimensions(); slice_config->set_start(start_indices[i]); slice_config->set_limit(limit_indices[i]); slice_config->set_stride(strides[i]); } return AddInstruction(std::move(instr), HloOpcode::kSlice, {operand}); }); } XlaOp XlaBuilder::SliceInDim(const XlaOp& operand, int64 start_index, int64 limit_index, int64 stride, int64 dimno) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { TF_ASSIGN_OR_RETURN(const Shape& shape, GetShape(operand)); std::vector<int64> starts(shape.rank(), 0); std::vector<int64> limits(shape.dimensions().begin(), shape.dimensions().end()); std::vector<int64> strides(shape.rank(), 1); starts[dimno] = start_index; limits[dimno] = limit_index; strides[dimno] = stride; return Slice(operand, starts, limits, strides); }); } XlaOp XlaBuilder::DynamicSlice(const XlaOp& operand, const XlaOp& start_indices, absl::Span<const int64> slice_sizes) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); TF_ASSIGN_OR_RETURN(const Shape& start_indices_shape, GetShape(start_indices)); TF_ASSIGN_OR_RETURN(Shape shape, ShapeInference::InferDynamicSliceShape( operand_shape, {start_indices_shape}, slice_sizes)); *instr.mutable_shape() = shape.ToProto(); for (int64 size : slice_sizes) { instr.add_dynamic_slice_sizes(size); } return AddInstruction(std::move(instr), HloOpcode::kDynamicSlice, {operand, start_indices}); }); } XlaOp XlaBuilder::DynamicSlice(const XlaOp& operand, absl::Span<const XlaOp> start_indices, absl::Span<const int64> slice_sizes) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); std::vector<const Shape*> start_indices_shape_ptrs; TF_ASSIGN_OR_RETURN(const auto& start_indices_shapes, GetOperandShapes(start_indices)); absl::c_transform(start_indices_shapes, std::back_inserter(start_indices_shape_ptrs), [](const Shape& shape) { return &shape; }); TF_ASSIGN_OR_RETURN(Shape shape, ShapeInference::InferDynamicSliceShape( operand_shape, start_indices_shapes, slice_sizes)); *instr.mutable_shape() = shape.ToProto(); for (int64 size : slice_sizes) { instr.add_dynamic_slice_sizes(size); } std::vector<XlaOp> operands = {operand}; operands.insert(operands.end(), start_indices.begin(), start_indices.end()); return AddInstruction(std::move(instr), HloOpcode::kDynamicSlice, operands); }); } XlaOp XlaBuilder::DynamicUpdateSlice(const XlaOp& operand, const XlaOp& update, const XlaOp& start_indices) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); TF_ASSIGN_OR_RETURN(const Shape& update_shape, GetShape(update)); TF_ASSIGN_OR_RETURN(const Shape& start_indices_shape, GetShape(start_indices)); TF_ASSIGN_OR_RETURN( Shape shape, ShapeInference::InferDynamicUpdateSliceShape( operand_shape, update_shape, {start_indices_shape})); *instr.mutable_shape() = shape.ToProto(); return AddInstruction(std::move(instr), HloOpcode::kDynamicUpdateSlice, {operand, update, start_indices}); }); } XlaOp XlaBuilder::DynamicUpdateSlice(const XlaOp& operand, const XlaOp& update, absl::Span<const XlaOp> start_indices) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); TF_ASSIGN_OR_RETURN(const Shape& update_shape, GetShape(update)); std::vector<const Shape*> start_indices_shape_ptrs; TF_ASSIGN_OR_RETURN(const auto& start_indices_shapes, GetOperandShapes(start_indices)); absl::c_transform(start_indices_shapes, std::back_inserter(start_indices_shape_ptrs), [](const Shape& shape) { return &shape; }); TF_ASSIGN_OR_RETURN(Shape shape, ShapeInference::InferDynamicUpdateSliceShape( operand_shape, update_shape, start_indices_shapes)); *instr.mutable_shape() = shape.ToProto(); std::vector<XlaOp> operands = {operand, update}; operands.insert(operands.end(), start_indices.begin(), start_indices.end()); return AddInstruction(std::move(instr), HloOpcode::kDynamicUpdateSlice, operands); }); } XlaOp XlaBuilder::ConcatInDim(absl::Span<const XlaOp> operands, int64 dimension) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; std::vector<const Shape*> operand_shape_ptrs; TF_ASSIGN_OR_RETURN(const auto& operand_shapes, GetOperandShapes(operands)); absl::c_transform(operand_shapes, std::back_inserter(operand_shape_ptrs), [](const Shape& shape) { return &shape; }); TF_ASSIGN_OR_RETURN(Shape shape, ShapeInference::InferConcatOpShape( operand_shape_ptrs, dimension)); *instr.mutable_shape() = shape.ToProto(); instr.add_dimensions(dimension); return AddInstruction(std::move(instr), HloOpcode::kConcatenate, operands); }); } XlaOp XlaBuilder::Pad(const XlaOp& operand, const XlaOp& padding_value, const PaddingConfig& padding_config) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); TF_ASSIGN_OR_RETURN(const Shape& padding_value_shape, GetShape(padding_value)); TF_ASSIGN_OR_RETURN( Shape shape, ShapeInference::InferPadShape( operand_shape, padding_value_shape, padding_config)); *instr.mutable_shape() = shape.ToProto(); *instr.mutable_padding_config() = padding_config; return AddInstruction(std::move(instr), HloOpcode::kPad, {operand, padding_value}); }); } XlaOp XlaBuilder::Reshape(const XlaOp& operand, absl::Span<const int64> dimensions, absl::Span<const int64> new_sizes) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); TF_ASSIGN_OR_RETURN(const Shape shape, ShapeInference::InferReshapeShape( operand_shape, dimensions, new_sizes)); XlaOp transposed = IsIdentityPermutation(dimensions) ? operand : Transpose(operand, dimensions); return Reshape(shape, transposed); }); } XlaOp XlaBuilder::Reshape(const XlaOp& operand, absl::Span<const int64> new_sizes) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { TF_ASSIGN_OR_RETURN(Shape shape, GetShape(operand)); std::vector<int64> dimensions(shape.dimensions_size()); std::iota(dimensions.begin(), dimensions.end(), 0); return Reshape(operand, dimensions, new_sizes); }); } XlaOp XlaBuilder::Collapse(const XlaOp& operand, absl::Span<const int64> dimensions) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { if (dimensions.size() <= 1) { // Not collapsing anything, trivially we can return the operand versus // enqueueing a trivial reshape. return operand; } // Out-of-order collapse is not supported. // Checks that the collapsed dimensions are in order and consecutive. for (absl::Span<const int64>::size_type i = 1; i < dimensions.size(); ++i) { if (dimensions[i] - 1 != dimensions[i - 1]) { return InvalidArgument( "Collapsed dimensions are not in consecutive order."); } } // Create a new sizes vector from the old shape, replacing the collapsed // dimensions by the product of their sizes. TF_ASSIGN_OR_RETURN(const Shape& original_shape, GetShape(operand)); VLOG(3) << "original shape: " << ShapeUtil::HumanString(original_shape); VLOG(3) << "dims to collapse: " << absl::StrJoin(dimensions, ","); std::vector<int64> new_sizes; for (int i = 0; i < original_shape.rank(); ++i) { if (i <= dimensions.front() || i > dimensions.back()) { new_sizes.push_back(original_shape.dimensions(i)); } else { new_sizes.back() *= original_shape.dimensions(i); } } VLOG(3) << "new sizes: [" << absl::StrJoin(new_sizes, ",") << "]"; return Reshape(operand, new_sizes); }); } void XlaBuilder::Trace(const string& tag, const XlaOp& operand) { ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; *instr.mutable_shape() = ShapeUtil::MakeNil().ToProto(); *instr.mutable_literal() = LiteralUtil::CreateR1U8(tag).ToProto(); return AddInstruction(std::move(instr), HloOpcode::kTrace, {operand}); }); } XlaOp XlaBuilder::Select(const XlaOp& pred, const XlaOp& on_true, const XlaOp& on_false) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { TF_ASSIGN_OR_RETURN(const Shape& true_shape, GetShape(on_true)); TF_ASSIGN_OR_RETURN(const Shape& false_shape, GetShape(on_false)); TF_RET_CHECK(true_shape.IsTuple() == false_shape.IsTuple()); HloOpcode opcode = true_shape.IsTuple() ? HloOpcode::kTupleSelect : HloOpcode::kSelect; return TernaryOp(opcode, pred, on_true, on_false); }); } XlaOp XlaBuilder::Tuple(absl::Span<const XlaOp> elements) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; std::vector<const Shape*> operand_shape_ptrs; TF_ASSIGN_OR_RETURN(const auto& operand_shapes, GetOperandShapes(elements)); absl::c_transform(operand_shapes, std::back_inserter(operand_shape_ptrs), [](const Shape& shape) { return &shape; }); TF_ASSIGN_OR_RETURN(const Shape shape, ShapeInference::InferVariadicOpShape( HloOpcode::kTuple, operand_shape_ptrs)); *instr.mutable_shape() = shape.ToProto(); return AddInstruction(std::move(instr), HloOpcode::kTuple, elements); }); } XlaOp XlaBuilder::GetTupleElement(const XlaOp& tuple_data, int64 index) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& tuple_shape, GetShape(tuple_data)); if (!tuple_shape.IsTuple()) { return InvalidArgument( "Operand to GetTupleElement() is not a tuple; got %s", ShapeUtil::HumanString(tuple_shape)); } *instr.mutable_shape() = ShapeUtil::GetTupleElementShape(tuple_shape, index).ToProto(); instr.set_tuple_index(index); return AddInstruction(std::move(instr), HloOpcode::kGetTupleElement, {tuple_data}); }); } XlaOp XlaBuilder::Dot(const XlaOp& lhs, const XlaOp& rhs, const PrecisionConfig* precision_config) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { TF_ASSIGN_OR_RETURN(const Shape& lhs_shape, GetShape(lhs)); DotDimensionNumbers dimension_numbers; dimension_numbers.add_lhs_contracting_dimensions( lhs_shape.dimensions_size() == 1 ? 0 : 1); dimension_numbers.add_rhs_contracting_dimensions(0); return DotGeneral(lhs, rhs, dimension_numbers, precision_config); }); } XlaOp XlaBuilder::DotGeneral(const XlaOp& lhs, const XlaOp& rhs, const DotDimensionNumbers& dimension_numbers, const PrecisionConfig* precision_config) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& lhs_shape, GetShape(lhs)); TF_ASSIGN_OR_RETURN(const Shape& rhs_shape, GetShape(rhs)); // If one operand is a scalar, just multiply the two operands. if (ShapeUtil::IsScalar(lhs_shape) || ShapeUtil::IsScalar(rhs_shape)) { if (dimension_numbers.rhs_batch_dimensions_size() != 0 || dimension_numbers.lhs_batch_dimensions_size() != 0 || dimension_numbers.rhs_contracting_dimensions_size() != 0 || dimension_numbers.lhs_contracting_dimensions_size() != 0) { return InvalidArgument( "Dots with scalar operands must have no contracting or batch " "dimensions"); } return xla::Mul(lhs, rhs); } TF_ASSIGN_OR_RETURN(Shape shape, ShapeInference::InferDotOpShape(lhs_shape, rhs_shape, dimension_numbers)); *instr.mutable_shape() = shape.ToProto(); *instr.mutable_dot_dimension_numbers() = dimension_numbers; if (precision_config != nullptr) { *instr.mutable_precision_config() = *precision_config; } return AddInstruction(std::move(instr), HloOpcode::kDot, {lhs, rhs}); }); } Status XlaBuilder::VerifyConvolution( const Shape& lhs_shape, const Shape& rhs_shape, const ConvolutionDimensionNumbers& dimension_numbers) const { if (lhs_shape.rank() != rhs_shape.rank()) { return InvalidArgument( "Convolution arguments must have same number of " "dimensions. Got: %s and %s", ShapeUtil::HumanString(lhs_shape), ShapeUtil::HumanString(rhs_shape)); } int num_dims = lhs_shape.rank(); if (num_dims < 2) { return InvalidArgument( "Convolution expects argument arrays with >= 3 dimensions. " "Got: %s and %s", ShapeUtil::HumanString(lhs_shape), ShapeUtil::HumanString(rhs_shape)); } int num_spatial_dims = num_dims - 2; const auto check_spatial_dimensions = [&](const char* const field_name, const tensorflow::protobuf::RepeatedField<tensorflow::protobuf_int64>& numbers) { if (numbers.size() != num_spatial_dims) { return InvalidArgument("Expected %d elements for %s, but got %d.", num_spatial_dims, field_name, numbers.size()); } for (int i = 0; i < numbers.size(); ++i) { if (numbers.Get(i) < 0 || numbers.Get(i) >= num_dims) { return InvalidArgument("Convolution %s[%d] is out of bounds: %d", field_name, i, numbers.Get(i)); } } return Status::OK(); }; TF_RETURN_IF_ERROR( check_spatial_dimensions("input_spatial_dimensions", dimension_numbers.input_spatial_dimensions())); TF_RETURN_IF_ERROR( check_spatial_dimensions("kernel_spatial_dimensions", dimension_numbers.kernel_spatial_dimensions())); return check_spatial_dimensions( "output_spatial_dimensions", dimension_numbers.output_spatial_dimensions()); } XlaOp XlaBuilder::Conv(const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> window_strides, Padding padding, int64 feature_group_count, int64 batch_group_count, const PrecisionConfig* precision_config) { return ConvWithGeneralDimensions( lhs, rhs, window_strides, padding, CreateDefaultConvDimensionNumbers(window_strides.size()), feature_group_count, batch_group_count, precision_config); } XlaOp XlaBuilder::ConvWithGeneralPadding( const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> window_strides, absl::Span<const std::pair<int64, int64>> padding, int64 feature_group_count, int64 batch_group_count, const PrecisionConfig* precision_config) { return ConvGeneral(lhs, rhs, window_strides, padding, CreateDefaultConvDimensionNumbers(window_strides.size()), feature_group_count, batch_group_count, precision_config); } XlaOp XlaBuilder::ConvWithGeneralDimensions( const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> window_strides, Padding padding, const ConvolutionDimensionNumbers& dimension_numbers, int64 feature_group_count, int64 batch_group_count, const PrecisionConfig* precision_config) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { TF_ASSIGN_OR_RETURN(const Shape& lhs_shape, GetShape(lhs)); TF_ASSIGN_OR_RETURN(const Shape& rhs_shape, GetShape(rhs)); TF_RETURN_IF_ERROR( VerifyConvolution(lhs_shape, rhs_shape, dimension_numbers)); std::vector<int64> base_area_dimensions( dimension_numbers.input_spatial_dimensions_size()); for (std::vector<int64>::size_type i = 0; i < base_area_dimensions.size(); ++i) { base_area_dimensions[i] = lhs_shape.dimensions(dimension_numbers.input_spatial_dimensions(i)); } std::vector<int64> window_dimensions( dimension_numbers.kernel_spatial_dimensions_size()); for (std::vector<int64>::size_type i = 0; i < window_dimensions.size(); ++i) { window_dimensions[i] = rhs_shape.dimensions(dimension_numbers.kernel_spatial_dimensions(i)); } return ConvGeneral(lhs, rhs, window_strides, MakePadding(base_area_dimensions, window_dimensions, window_strides, padding), dimension_numbers, feature_group_count, batch_group_count, precision_config); }); } XlaOp XlaBuilder::ConvGeneral( const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> window_strides, absl::Span<const std::pair<int64, int64>> padding, const ConvolutionDimensionNumbers& dimension_numbers, int64 feature_group_count, int64 batch_group_count, const PrecisionConfig* precision_config) { return ConvGeneralDilated(lhs, rhs, window_strides, padding, {}, {}, dimension_numbers, feature_group_count, batch_group_count, precision_config); } XlaOp XlaBuilder::ConvGeneralDilated( const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> window_strides, absl::Span<const std::pair<int64, int64>> padding, absl::Span<const int64> lhs_dilation, absl::Span<const int64> rhs_dilation, const ConvolutionDimensionNumbers& dimension_numbers, int64 feature_group_count, int64 batch_group_count, const PrecisionConfig* precision_config) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& lhs_shape, GetShape(lhs)); TF_ASSIGN_OR_RETURN(const Shape& rhs_shape, GetShape(rhs)); TF_RETURN_IF_ERROR( VerifyConvolution(lhs_shape, rhs_shape, dimension_numbers)); std::vector<int64> window_dimensions( dimension_numbers.kernel_spatial_dimensions_size()); for (std::vector<int64>::size_type i = 0; i < window_dimensions.size(); ++i) { window_dimensions[i] = rhs_shape.dimensions(dimension_numbers.kernel_spatial_dimensions(i)); } TF_ASSIGN_OR_RETURN(*instr.mutable_window(), MakeWindow(window_dimensions, window_strides, padding, lhs_dilation, rhs_dilation)); TF_ASSIGN_OR_RETURN( Shape shape, ShapeInference::InferConvolveShape( lhs_shape, rhs_shape, feature_group_count, batch_group_count, instr.window(), dimension_numbers)); *instr.mutable_shape() = shape.ToProto(); *instr.mutable_convolution_dimension_numbers() = dimension_numbers; instr.set_feature_group_count(feature_group_count); instr.set_batch_group_count(batch_group_count); if (precision_config != nullptr) { *instr.mutable_precision_config() = *precision_config; } return AddInstruction(std::move(instr), HloOpcode::kConvolution, {lhs, rhs}); }); } StatusOr<Window> XlaBuilder::MakeWindow( absl::Span<const int64> window_dimensions, absl::Span<const int64> window_strides, absl::Span<const std::pair<int64, int64>> padding, absl::Span<const int64> lhs_dilation, absl::Span<const int64> rhs_dilation) const { const auto verify_size = [&](const size_t x, const char* x_name) { if (x == 0 || x == window_dimensions.size()) { return Status::OK(); } else { return InvalidArgument( "%s", absl::StrCat( "Window has different number of window dimensions than of ", x_name, "\nNumber of window dimensions: ", window_dimensions.size(), "\nNumber of ", x_name, ": ", x, "\n")); } }; TF_RETURN_IF_ERROR(verify_size(window_strides.size(), "window strides")); TF_RETURN_IF_ERROR(verify_size(padding.size(), "padding entries")); TF_RETURN_IF_ERROR(verify_size(lhs_dilation.size(), "lhs dilation factors")); TF_RETURN_IF_ERROR(verify_size(rhs_dilation.size(), "rhs dilation factors")); Window window; for (size_t i = 0; i < window_dimensions.size(); i++) { auto dim = window.add_dimensions(); dim->set_size(window_dimensions[i]); if (!window_strides.empty()) { dim->set_stride(window_strides[i]); } else { dim->set_stride(1); } if (!padding.empty()) { dim->set_padding_low(padding[i].first); dim->set_padding_high(padding[i].second); } else { dim->set_padding_low(0); dim->set_padding_high(0); } if (!lhs_dilation.empty()) { dim->set_base_dilation(lhs_dilation[i]); } else { dim->set_base_dilation(1); } if (!rhs_dilation.empty()) { dim->set_window_dilation(rhs_dilation[i]); } else { dim->set_window_dilation(1); } dim->set_window_reversal(false); } return window; } XlaOp XlaBuilder::Fft(const XlaOp& operand, const FftType fft_type, const absl::Span<const int64> fft_length) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); TF_ASSIGN_OR_RETURN(Shape shape, ShapeInference::InferFftShape( operand_shape, fft_type, fft_length)); *instr.mutable_shape() = shape.ToProto(); instr.set_fft_type(fft_type); for (int64 i : fft_length) { instr.add_fft_length(i); } return AddInstruction(std::move(instr), HloOpcode::kFft, {operand}); }); } XlaOp XlaBuilder::Infeed(const Shape& shape, const string& config) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; if (!LayoutUtil::HasLayout(shape)) { return InvalidArgument("Given shape to Infeed must have a layout"); } const Shape infeed_instruction_shape = ShapeUtil::MakeTupleShape({shape, ShapeUtil::MakeTokenShape()}); *instr.mutable_shape() = infeed_instruction_shape.ToProto(); instr.set_infeed_config(config); if (shape.IsArray() && sharding() && sharding()->type() == OpSharding::Type::OpSharding_Type_OTHER) { // TODO(b/110793772): Support tiled array-shaped infeeds. return InvalidArgument( "Tiled sharding is not yet supported for array-shaped infeeds"); } if (sharding() && sharding()->type() == OpSharding::Type::OpSharding_Type_REPLICATED) { return InvalidArgument( "Replicated sharding is not yet supported for infeeds"); } // Infeed takes a single token operand. Generate the token to pass to the // infeed. XlaOp token; auto make_token = [&]() { HloInstructionProto token_instr; *token_instr.mutable_shape() = ShapeUtil::MakeTokenShape().ToProto(); return AddInstruction(std::move(token_instr), HloOpcode::kAfterAll, {}); }; if (sharding()) { // Arbitrarily assign token to device 0. OpSharding sharding = sharding_builder::AssignDevice(0); XlaScopedShardingAssignment scoped_sharding(this, sharding); TF_ASSIGN_OR_RETURN(token, make_token()); } else { TF_ASSIGN_OR_RETURN(token, make_token()); } // The sharding is set by the client according to the data tuple shape. // However, the shape of the infeed instruction is a tuple containing the // data and a token. For tuple sharding type, the sharding must be changed // to accommodate the token. XlaOp infeed; if (sharding() && sharding()->type() == OpSharding::Type::OpSharding_Type_TUPLE) { // TODO(b/80000000): Remove this when clients have been updated to handle // tokens. OpSharding infeed_instruction_sharding = *sharding(); // Arbitrarily assign the token to device 0. *infeed_instruction_sharding.add_tuple_shardings() = sharding_builder::AssignDevice(0); XlaScopedShardingAssignment scoped_sharding(this, infeed_instruction_sharding); TF_ASSIGN_OR_RETURN(infeed, AddInstruction(std::move(instr), HloOpcode::kInfeed, {token})); } else { TF_ASSIGN_OR_RETURN(infeed, AddInstruction(std::move(instr), HloOpcode::kInfeed, {token})); } // The infeed instruction produces a tuple of the infed data and a token // type. Return XLA op containing the data. // TODO(b/80000000): Remove this when clients have been updated to handle // tokens. HloInstructionProto infeed_data; *infeed_data.mutable_shape() = shape.ToProto(); infeed_data.set_tuple_index(0); return AddInstruction(std::move(infeed_data), HloOpcode::kGetTupleElement, {infeed}); }); } XlaOp XlaBuilder::InfeedWithToken(const XlaOp& token, const Shape& shape, const string& config) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; if (!LayoutUtil::HasLayout(shape)) { return InvalidArgument("Given shape to Infeed must have a layout"); } const Shape infeed_instruction_shape = ShapeUtil::MakeTupleShape({shape, ShapeUtil::MakeTokenShape()}); *instr.mutable_shape() = infeed_instruction_shape.ToProto(); instr.set_infeed_config(config); if (shape.IsArray() && sharding() && sharding()->type() == OpSharding::Type::OpSharding_Type_OTHER) { // TODO(b/110793772): Support tiled array-shaped infeeds. return InvalidArgument( "Tiled sharding is not yet supported for array-shaped infeeds"); } if (sharding() && sharding()->type() == OpSharding::Type::OpSharding_Type_REPLICATED) { return InvalidArgument( "Replicated sharding is not yet supported for infeeds"); } return AddInstruction(std::move(instr), HloOpcode::kInfeed, {token}); }); } void XlaBuilder::Outfeed(const XlaOp& operand, const Shape& shape_with_layout, const string& outfeed_config) { ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; *instr.mutable_shape() = ShapeUtil::MakeTokenShape().ToProto(); // Check and set outfeed shape. if (!LayoutUtil::HasLayout(shape_with_layout)) { return InvalidArgument("Given shape to Outfeed must have a layout"); } TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); if (!ShapeUtil::Compatible(operand_shape, shape_with_layout)) { return InvalidArgument( "Outfeed shape %s must be compatible with operand shape %s", ShapeUtil::HumanStringWithLayout(shape_with_layout), ShapeUtil::HumanStringWithLayout(operand_shape)); } *instr.mutable_outfeed_shape() = shape_with_layout.ToProto(); instr.set_outfeed_config(outfeed_config); // Outfeed takes a token as its second operand. Generate the token to pass // to the outfeed. HloInstructionProto token_instr; *token_instr.mutable_shape() = ShapeUtil::MakeTokenShape().ToProto(); TF_ASSIGN_OR_RETURN(XlaOp token, AddInstruction(std::move(token_instr), HloOpcode::kAfterAll, {})); TF_RETURN_IF_ERROR( AddInstruction(std::move(instr), HloOpcode::kOutfeed, {operand, token}) .status()); // The outfeed instruction produces a token. However, existing users expect // a nil shape (empty tuple). This should only be relevant if the outfeed is // the root of a computation. // TODO(b/80000000): Remove this when clients have been updated to handle // tokens. HloInstructionProto tuple_instr; *tuple_instr.mutable_shape() = ShapeUtil::MakeNil().ToProto(); // The dummy tuple should have no sharding. { XlaScopedShardingAssignment scoped_sharding(this, OpSharding()); TF_ASSIGN_OR_RETURN( XlaOp empty_tuple, AddInstruction(std::move(tuple_instr), HloOpcode::kTuple, {})); return empty_tuple; } }); } XlaOp XlaBuilder::OutfeedWithToken(const XlaOp& operand, const XlaOp& token, const Shape& shape_with_layout, const string& outfeed_config) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; *instr.mutable_shape() = ShapeUtil::MakeTokenShape().ToProto(); // Check and set outfeed shape. if (!LayoutUtil::HasLayout(shape_with_layout)) { return InvalidArgument("Given shape to Outfeed must have a layout"); } TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); if (!ShapeUtil::Compatible(operand_shape, shape_with_layout)) { return InvalidArgument( "Outfeed shape %s must be compatible with operand shape %s", ShapeUtil::HumanStringWithLayout(shape_with_layout), ShapeUtil::HumanStringWithLayout(operand_shape)); } *instr.mutable_outfeed_shape() = shape_with_layout.ToProto(); instr.set_outfeed_config(outfeed_config); return AddInstruction(std::move(instr), HloOpcode::kOutfeed, {operand, token}); }); } XlaOp XlaBuilder::CreateToken() { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; *instr.mutable_shape() = ShapeUtil::MakeTokenShape().ToProto(); return AddInstruction(std::move(instr), HloOpcode::kAfterAll); }); } XlaOp XlaBuilder::AfterAll(absl::Span<const XlaOp> tokens) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { if (tokens.empty()) { return InvalidArgument("AfterAll requires at least one operand"); } for (int i = 0; i < tokens.size(); ++i) { const XlaOp& operand = tokens[i]; TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); if (!operand_shape.IsToken()) { return InvalidArgument( "All operands to AfterAll must be tokens; operand %d has shape %s", i, ShapeUtil::HumanString(operand_shape)); } } HloInstructionProto instr; *instr.mutable_shape() = ShapeUtil::MakeTokenShape().ToProto(); return AddInstruction(std::move(instr), HloOpcode::kAfterAll, tokens); }); } XlaOp XlaBuilder::CustomCall( const string& call_target_name, absl::Span<const XlaOp> operands, const Shape& shape, const string& opaque, absl::optional<absl::Span<const Shape>> operand_shapes_with_layout) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; if (absl::StartsWith(call_target_name, "$")) { return InvalidArgument( "Invalid custom_call_target \"%s\": Call targets that start with '$' " "are reserved for internal use.", call_target_name); } *instr.mutable_shape() = shape.ToProto(); instr.set_custom_call_target(call_target_name); instr.set_custom_call_opaque(opaque); if (operand_shapes_with_layout.has_value()) { if (!LayoutUtil::HasLayout(shape)) { return InvalidArgument( "Result shape must have layout for custom call with constrained " "layout."); } if (operands.size() != operand_shapes_with_layout->size()) { return InvalidArgument( "Must specify a shape with layout for each operand for custom call " "with constrained layout; given %d shapes, expected %d", operand_shapes_with_layout->size(), operands.size()); } instr.set_constrain_layout(true); int64 operand_num = 0; for (const Shape& operand_shape : *operand_shapes_with_layout) { if (!LayoutUtil::HasLayout(operand_shape)) { return InvalidArgument( "No layout specified for operand %d for custom call with " "constrained layout.", operand_num); } *instr.add_operand_shapes_with_layout() = operand_shape.ToProto(); ++operand_num; } } return AddInstruction(std::move(instr), HloOpcode::kCustomCall, operands); }); } XlaOp XlaBuilder::Transpose(const XlaOp& operand, absl::Span<const int64> permutation) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); TF_ASSIGN_OR_RETURN(Shape shape, ShapeInference::InferTransposeShape( operand_shape, permutation)); *instr.mutable_shape() = shape.ToProto(); for (int64 dim : permutation) { instr.add_dimensions(dim); } return AddInstruction(std::move(instr), HloOpcode::kTranspose, {operand}); }); } XlaOp XlaBuilder::Rev(const XlaOp& operand, absl::Span<const int64> dimensions) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); TF_ASSIGN_OR_RETURN(Shape shape, ShapeInference::InferReverseShape( operand_shape, dimensions)); *instr.mutable_shape() = shape.ToProto(); for (int64 dim : dimensions) { instr.add_dimensions(dim); } return AddInstruction(std::move(instr), HloOpcode::kReverse, {operand}); }); } namespace { // Switch from a floating point value to a integer value in such a way that when // using the integer value to compare, we get the same result for normal values, // and -Nan is treated as the smallest value, and Nan is treated as the largest // value. // If f is a float, and // x = bit_cast<int32>(f); // y = x < 0 ? numeric_limits<int32>::max() - x : x; // then y is ordered as an int32 such that finite values have the obvious order, // -0 is ordered before 0, and -NaN and NaN appear at the beginning and end of // the ordering. // Note that in order to avoid -x to overflow, we calculate // numeric_limits<int32>::max() - x as unsigned, and then convert back to // signed. XlaOp BitcastConvertFloatingPointToIntegral(const XlaOp& value, int64 bit_width) { PrimitiveType signed_type; PrimitiveType unsigned_type; XlaOp max_value; switch (bit_width) { case 16: max_value = ConstantR0(value.builder(), static_cast<uint16>(std::numeric_limits<int16>::max())); signed_type = S16; unsigned_type = U16; break; case 32: max_value = ConstantR0(value.builder(), static_cast<uint32>(std::numeric_limits<int32>::max())); signed_type = S32; unsigned_type = U32; break; case 64: max_value = ConstantR0(value.builder(), static_cast<uint64>(std::numeric_limits<int64>::max())); signed_type = S64; unsigned_type = U64; break; default: return value.builder()->ReportError( InvalidArgument("Invalid bit width %lld for Comparator floating " "point parameter.", bit_width)); } auto signed_value = BitcastConvertType(value, signed_type); auto unsigned_value = BitcastConvertType(value, unsigned_type); auto flipped_value = BitcastConvertType(Sub(max_value, unsigned_value), signed_type); auto is_negative = Lt(signed_value, ConstantLiteral(value.builder(), LiteralUtil::Zero(signed_type))); return Select(is_negative, flipped_value, signed_value); } } // namespace XlaOp XlaBuilder::Sort(const XlaOp& keys, absl::Span<const XlaOp> values, int64 dimension) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { std::vector<XlaOp> operands{keys}; for (const XlaOp& value : values) { operands.push_back(value); } // Build the default less-than comparator (copied from lib/comparators.cc). // TODO(b/122298745): Remove the deprecated API method so that this code // duplication can be deleted. auto b = this->CreateSubBuilder("comparator"); std::vector<PrimitiveType> operand_types; for (const XlaOp& operand : operands) { TF_ASSIGN_OR_RETURN(auto operand_shape, GetShape(operand)); operand_types.push_back(operand_shape.element_type()); } int64 parameter_count = 0; XlaOp first_lhs_param; XlaOp first_rhs_param; for (auto operand_type : operand_types) { auto scalar_shape = ShapeUtil::MakeShape(operand_type, {}); auto lhs_param = b->Parameter(parameter_count * 2, scalar_shape, absl::StrCat("p.", parameter_count, ".lhs")); auto rhs_param = b->Parameter(parameter_count * 2 + 1, scalar_shape, absl::StrCat("p.", parameter_count, ".rhs")); if (parameter_count == 0) { first_lhs_param = lhs_param; first_rhs_param = rhs_param; } ++parameter_count; } if (primitive_util::IsFloatingPointType(operand_types[0])) { PrimitiveType compare_type = operand_types[0]; // Special-case handling for BF16. We currently do not support direct // comparisons with BF16, so we convert to F32 and then use the F32 // comparison logic. if (compare_type == BF16) { compare_type = F32; first_lhs_param = b->ConvertElementType(first_lhs_param, F32); first_rhs_param = b->ConvertElementType(first_rhs_param, F32); } int64 bit_width = primitive_util::BitWidth(compare_type); first_lhs_param = BitcastConvertFloatingPointToIntegral(first_lhs_param, bit_width); first_rhs_param = BitcastConvertFloatingPointToIntegral(first_rhs_param, bit_width); } Lt(first_lhs_param, first_rhs_param); TF_ASSIGN_OR_RETURN(auto comparator, b->Build()); return Sort(operands, comparator, dimension, /*is_stable=*/false); }); } XlaOp XlaBuilder::Sort(absl::Span<const XlaOp> operands, const XlaComputation& comparator, int64 dimension, bool is_stable) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; instr.set_is_stable(is_stable); std::vector<const Shape*> operand_shape_ptrs; TF_ASSIGN_OR_RETURN(std::vector<Shape> operand_shapes, GetOperandShapes(operands)); absl::c_transform(operand_shapes, std::back_inserter(operand_shape_ptrs), [](const Shape& shape) { return &shape; }); TF_ASSIGN_OR_RETURN(Shape shape, ShapeInference::InferVariadicOpShape( HloOpcode::kSort, operand_shape_ptrs)); *instr.mutable_shape() = shape.ToProto(); if (dimension == -1) { TF_ASSIGN_OR_RETURN(const Shape& keys_shape, GetShape(operands[0])); dimension = keys_shape.rank() - 1; } instr.add_dimensions(dimension); AddCalledComputation(comparator, &instr); return AddInstruction(std::move(instr), HloOpcode::kSort, operands); }); } XlaOp XlaBuilder::ConvertElementType(const XlaOp& operand, PrimitiveType new_element_type) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); TF_ASSIGN_OR_RETURN(Shape shape, ShapeInference::InferConvertShape( operand_shape, new_element_type)); *instr.mutable_shape() = shape.ToProto(); return AddInstruction(std::move(instr), HloOpcode::kConvert, {operand}); }); } XlaOp XlaBuilder::BitcastConvertType(const XlaOp& operand, PrimitiveType new_element_type) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); TF_ASSIGN_OR_RETURN(Shape shape, ShapeInference::InferConvertShape( operand_shape, new_element_type)); *instr.mutable_shape() = shape.ToProto(); return AddInstruction(std::move(instr), HloOpcode::kBitcastConvert, {operand}); }); } XlaOp XlaBuilder::Clamp(const XlaOp& min, const XlaOp& operand, const XlaOp& max) { return TernaryOp(HloOpcode::kClamp, min, operand, max); } XlaOp XlaBuilder::Map(absl::Span<const XlaOp> operands, const XlaComputation& computation, absl::Span<const int64> dimensions, absl::Span<const XlaOp> static_operands) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { if (!static_operands.empty()) { return Unimplemented("static_operands is not supported in Map"); } HloInstructionProto instr; std::vector<const Shape*> operand_shape_ptrs; TF_ASSIGN_OR_RETURN(const auto& operand_shapes, GetOperandShapes(operands)); absl::c_transform(operand_shapes, std::back_inserter(operand_shape_ptrs), [](const Shape& shape) { return &shape; }); TF_ASSIGN_OR_RETURN(const ProgramShape& called_program_shape, computation.GetProgramShape()); TF_ASSIGN_OR_RETURN( Shape shape, ShapeInference::InferMapShape( operand_shape_ptrs, called_program_shape, dimensions)); *instr.mutable_shape() = shape.ToProto(); Shape output_shape(instr.shape()); const int64 output_rank = output_shape.rank(); AddCalledComputation(computation, &instr); std::vector<XlaOp> new_operands(operands.begin(), operands.end()); for (XlaOp& new_operand : new_operands) { TF_ASSIGN_OR_RETURN(Shape shape, GetShape(new_operand)); const int64 rank = shape.rank(); if (rank != output_rank) { TF_ASSIGN_OR_RETURN(new_operand, InDimBroadcast(output_shape, new_operand, {})); TF_ASSIGN_OR_RETURN(shape, GetShape(new_operand)); } if (!ShapeUtil::SameDimensions(output_shape, shape)) { TF_ASSIGN_OR_RETURN(new_operand, AddBroadcastSequence(output_shape, new_operand)); } } return AddInstruction(std::move(instr), HloOpcode::kMap, new_operands); }); } XlaOp XlaBuilder::RngOp(RandomDistribution distribution, absl::Span<const XlaOp> parameters, const Shape& shape) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; // Check the number of parameters per RNG distribution. switch (distribution) { case RandomDistribution::RNG_NORMAL: case RandomDistribution::RNG_UNIFORM: if (parameters.size() != 2) { return InvalidArgument( "RNG distribution (%s) expects 2 parameters, but got %ld", RandomDistribution_Name(distribution), parameters.size()); } break; default: LOG(FATAL) << "unhandled distribution " << distribution; } TF_RETURN_IF_ERROR(ShapeUtil::ValidateShapeWithOptionalLayout(shape)); *instr.mutable_shape() = shape.ToProto(); instr.set_distribution(distribution); return AddInstruction(std::move(instr), HloOpcode::kRng, parameters); }); } XlaOp XlaBuilder::RngNormal(const XlaOp& mu, const XlaOp& sigma, const Shape& shape) { return RngOp(RandomDistribution::RNG_NORMAL, {mu, sigma}, shape); } XlaOp XlaBuilder::RngUniform(const XlaOp& a, const XlaOp& b, const Shape& shape) { return RngOp(RandomDistribution::RNG_UNIFORM, {a, b}, shape); } XlaOp XlaBuilder::While(const XlaComputation& condition, const XlaComputation& body, const XlaOp& init) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; // Infer shape. TF_ASSIGN_OR_RETURN(const auto& body_program_shape, body.GetProgramShape()); TF_ASSIGN_OR_RETURN(const auto& condition_program_shape, condition.GetProgramShape()); TF_ASSIGN_OR_RETURN(const Shape& init_shape, GetShape(init)); TF_ASSIGN_OR_RETURN(Shape shape, ShapeInference::InferWhileShape( condition_program_shape, body_program_shape, init_shape)); *instr.mutable_shape() = shape.ToProto(); // Body comes before condition computation in the vector. AddCalledComputation(body, &instr); AddCalledComputation(condition, &instr); return AddInstruction(std::move(instr), HloOpcode::kWhile, {init}); }); } XlaOp XlaBuilder::Gather(const XlaOp& input, const XlaOp& start_indices, const GatherDimensionNumbers& dimension_numbers, absl::Span<const int64> slice_sizes) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& input_shape, GetShape(input)); TF_ASSIGN_OR_RETURN(const Shape& start_indices_shape, GetShape(start_indices)); TF_ASSIGN_OR_RETURN(Shape shape, ShapeInference::InferGatherShape( input_shape, start_indices_shape, dimension_numbers, slice_sizes)); *instr.mutable_shape() = shape.ToProto(); *instr.mutable_gather_dimension_numbers() = dimension_numbers; for (int64 bound : slice_sizes) { instr.add_gather_slice_sizes(bound); } return AddInstruction(std::move(instr), HloOpcode::kGather, {input, start_indices}); }); } XlaOp XlaBuilder::Scatter(const XlaOp& input, const XlaOp& scatter_indices, const XlaOp& updates, const XlaComputation& update_computation, const ScatterDimensionNumbers& dimension_numbers) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& input_shape, GetShape(input)); TF_ASSIGN_OR_RETURN(const Shape& scatter_indices_shape, GetShape(scatter_indices)); TF_ASSIGN_OR_RETURN(const Shape& updates_shape, GetShape(updates)); TF_ASSIGN_OR_RETURN(const ProgramShape& to_apply_shape, update_computation.GetProgramShape()); TF_ASSIGN_OR_RETURN(Shape shape, ShapeInference::InferScatterShape( input_shape, scatter_indices_shape, updates_shape, to_apply_shape, dimension_numbers)); *instr.mutable_shape() = shape.ToProto(); *instr.mutable_scatter_dimension_numbers() = dimension_numbers; AddCalledComputation(update_computation, &instr); return AddInstruction(std::move(instr), HloOpcode::kScatter, {input, scatter_indices, updates}); }); } XlaOp XlaBuilder::Conditional(const XlaOp& predicate, const XlaOp& true_operand, const XlaComputation& true_computation, const XlaOp& false_operand, const XlaComputation& false_computation) { // The index of true_computation must be 0 and that of false computation // must be 1. return Conditional(predicate, {&true_computation, &false_computation}, {true_operand, false_operand}); } XlaOp XlaBuilder::Conditional( const XlaOp& branch_index, absl::Span<const XlaComputation* const> branch_computations, absl::Span<const XlaOp> branch_operands) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& branch_index_shape, GetShape(branch_index)); std::vector<Shape> branch_operand_shapes(branch_operands.size()); std::vector<ProgramShape> branch_computation_shapes( branch_computations.size()); for (int j = 0; j < branch_operands.size(); ++j) { TF_ASSIGN_OR_RETURN(branch_operand_shapes[j], GetShape(branch_operands[j])); TF_ASSIGN_OR_RETURN(branch_computation_shapes[j], branch_computations[j]->GetProgramShape()); } TF_ASSIGN_OR_RETURN(const Shape shape, ShapeInference::InferConditionalShape( branch_index_shape, branch_computation_shapes, branch_operand_shapes)); *instr.mutable_shape() = shape.ToProto(); for (const XlaComputation* branch_computation : branch_computations) { AddCalledComputation(*branch_computation, &instr); } std::vector<XlaOp> operands(1, branch_index); for (const XlaOp branch_operand : branch_operands) { operands.emplace_back(branch_operand); } return AddInstruction(std::move(instr), HloOpcode::kConditional, absl::MakeSpan(operands)); }); } XlaOp XlaBuilder::Reduce(const XlaOp& operand, const XlaOp& init_value, const XlaComputation& computation, absl::Span<const int64> dimensions_to_reduce) { return Reduce(absl::Span<const XlaOp>({operand}), absl::Span<const XlaOp>({init_value}), computation, dimensions_to_reduce); } XlaOp XlaBuilder::Reduce(absl::Span<const XlaOp> operands, absl::Span<const XlaOp> init_values, const XlaComputation& computation, absl::Span<const int64> dimensions_to_reduce) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const ProgramShape& called_program_shape, computation.GetProgramShape()); std::vector<XlaOp> all_operands; all_operands.insert(all_operands.end(), operands.begin(), operands.end()); all_operands.insert(all_operands.end(), init_values.begin(), init_values.end()); std::vector<const Shape*> operand_shape_ptrs; TF_ASSIGN_OR_RETURN(const auto& operand_shapes, GetOperandShapes(all_operands)); absl::c_transform(operand_shapes, std::back_inserter(operand_shape_ptrs), [](const Shape& shape) { return &shape; }); TF_ASSIGN_OR_RETURN( Shape shape, ShapeInference::InferReduceShape( operand_shape_ptrs, dimensions_to_reduce, called_program_shape)); *instr.mutable_shape() = shape.ToProto(); for (int64 dim : dimensions_to_reduce) { instr.add_dimensions(dim); } AddCalledComputation(computation, &instr); return AddInstruction(std::move(instr), HloOpcode::kReduce, all_operands); }); } XlaOp XlaBuilder::ReduceAll(const XlaOp& operand, const XlaOp& init_value, const XlaComputation& computation) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); std::vector<int64> all_dimnos(operand_shape.rank()); std::iota(all_dimnos.begin(), all_dimnos.end(), 0); return Reduce(operand, init_value, computation, all_dimnos); }); } XlaOp XlaBuilder::ReduceWindow(const XlaOp& operand, const XlaOp& init_value, const XlaComputation& computation, absl::Span<const int64> window_dimensions, absl::Span<const int64> window_strides, Padding padding) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); TF_RETURN_IF_ERROR( ValidatePaddingValues(AsInt64Slice(operand_shape.dimensions()), window_dimensions, window_strides)); std::vector<std::pair<int64, int64>> padding_values = MakePadding(AsInt64Slice(operand_shape.dimensions()), window_dimensions, window_strides, padding); return ReduceWindowWithGeneralPadding( operand, init_value, computation, window_dimensions, window_strides, /*base_dilations=*/{}, /*window_dilations=*/{}, padding_values); }); } XlaOp XlaBuilder::ReduceWindowWithGeneralPadding( const XlaOp& operand, const XlaOp& init_value, const XlaComputation& computation, absl::Span<const int64> window_dimensions, absl::Span<const int64> window_strides, absl::Span<const int64> base_dilations, absl::Span<const int64> window_dilations, absl::Span<const std::pair<int64, int64>> padding) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); TF_ASSIGN_OR_RETURN(const Shape& init_shape, GetShape(init_value)); TF_ASSIGN_OR_RETURN(const ProgramShape& to_apply_shape, computation.GetProgramShape()); TF_ASSIGN_OR_RETURN(*instr.mutable_window(), MakeWindow(window_dimensions, window_strides, padding, /*lhs_dilation=*/base_dilations, /*rhs_dilation=*/window_dilations)); TF_ASSIGN_OR_RETURN(Shape shape, ShapeInference::InferReduceWindowShape( operand_shape, init_shape, instr.window(), to_apply_shape)); *instr.mutable_shape() = shape.ToProto(); AddCalledComputation(computation, &instr); return AddInstruction(std::move(instr), HloOpcode::kReduceWindow, {operand, init_value}); }); } XlaOp XlaBuilder::BatchNormTraining(const XlaOp& operand, const XlaOp& scale, const XlaOp& offset, float epsilon, int64 feature_index) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); TF_ASSIGN_OR_RETURN(const Shape& scale_shape, GetShape(scale)); TF_ASSIGN_OR_RETURN(const Shape& offset_shape, GetShape(offset)); TF_ASSIGN_OR_RETURN( Shape shape, ShapeInference::InferBatchNormTrainingShape( operand_shape, scale_shape, offset_shape, feature_index)); *instr.mutable_shape() = shape.ToProto(); instr.set_epsilon(epsilon); instr.set_feature_index(feature_index); return AddInstruction(std::move(instr), HloOpcode::kBatchNormTraining, {operand, scale, offset}); }); } XlaOp XlaBuilder::BatchNormInference(const XlaOp& operand, const XlaOp& scale, const XlaOp& offset, const XlaOp& mean, const XlaOp& variance, float epsilon, int64 feature_index) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); TF_ASSIGN_OR_RETURN(const Shape& scale_shape, GetShape(scale)); TF_ASSIGN_OR_RETURN(const Shape& offset_shape, GetShape(offset)); TF_ASSIGN_OR_RETURN(const Shape& mean_shape, GetShape(mean)); TF_ASSIGN_OR_RETURN(const Shape& variance_shape, GetShape(variance)); TF_ASSIGN_OR_RETURN( Shape shape, ShapeInference::InferBatchNormInferenceShape( operand_shape, scale_shape, offset_shape, mean_shape, variance_shape, feature_index)); *instr.mutable_shape() = shape.ToProto(); instr.set_epsilon(epsilon); instr.set_feature_index(feature_index); return AddInstruction(std::move(instr), HloOpcode::kBatchNormInference, {operand, scale, offset, mean, variance}); }); } XlaOp XlaBuilder::BatchNormGrad(const XlaOp& operand, const XlaOp& scale, const XlaOp& batch_mean, const XlaOp& batch_var, const XlaOp& grad_output, float epsilon, int64 feature_index) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); TF_ASSIGN_OR_RETURN(const Shape& scale_shape, GetShape(scale)); TF_ASSIGN_OR_RETURN(const Shape& batch_mean_shape, GetShape(batch_mean)); TF_ASSIGN_OR_RETURN(const Shape& batch_var_shape, GetShape(batch_var)); TF_ASSIGN_OR_RETURN(const Shape& grad_output_shape, GetShape(grad_output)); TF_ASSIGN_OR_RETURN(Shape shape, ShapeInference::InferBatchNormGradShape( operand_shape, scale_shape, batch_mean_shape, batch_var_shape, grad_output_shape, feature_index)); *instr.mutable_shape() = shape.ToProto(); instr.set_epsilon(epsilon); instr.set_feature_index(feature_index); return AddInstruction(std::move(instr), HloOpcode::kBatchNormGrad, {operand, scale, batch_mean, batch_var, grad_output}); }); } XlaOp XlaBuilder::CrossReplicaSum( const XlaOp& operand, absl::Span<const ReplicaGroup> replica_groups) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { TF_ASSIGN_OR_RETURN(const Shape& shape, GetShape(operand)); const Shape& scalar_shape = ShapeUtil::MakeShape(shape.element_type(), {}); auto b = CreateSubBuilder("sum"); Add(b->Parameter(/*parameter_number=*/0, scalar_shape, "x"), b->Parameter(/*parameter_number=*/1, scalar_shape, "y")); TF_ASSIGN_OR_RETURN(auto computation, b->Build()); return CrossReplicaSum(operand, computation, replica_groups, /*channel_id=*/absl::nullopt); }); } XlaOp XlaBuilder::CrossReplicaSum( const XlaOp& operand, const XlaComputation& computation, absl::Span<const ReplicaGroup> replica_groups, const absl::optional<ChannelHandle>& channel_id) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); TF_ASSIGN_OR_RETURN(Shape shape, ShapeInference::InferAllReduceShape({&operand_shape})); *instr.mutable_shape() = shape.ToProto(); for (const ReplicaGroup& group : replica_groups) { *instr.add_replica_groups() = group; } if (channel_id.has_value()) { instr.set_all_reduce_id(channel_id->handle()); } AddCalledComputation(computation, &instr); return AddInstruction(std::move(instr), HloOpcode::kAllReduce, {operand}); }); } XlaOp XlaBuilder::AllToAll(const XlaOp& operand, int64 split_dimension, int64 concat_dimension, int64 split_count, const std::vector<ReplicaGroup>& replica_groups) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); // The HloInstruction for Alltoall currently only handles the data // communication: it accepts N already split parts and scatters them to N // cores, and each core gathers the N received parts into a tuple as the // output. So here we explicitly split the operand before the hlo alltoall, // and concat the tuple elements. // // First, run shape inference to make sure the shapes are valid. TF_RETURN_IF_ERROR( ShapeInference::InferAllToAllShape(operand_shape, split_dimension, concat_dimension, split_count) .status()); // Split into N parts. std::vector<XlaOp> slices; slices.reserve(split_count); const int64 block_size = operand_shape.dimensions(split_dimension) / split_count; for (int i = 0; i < split_count; i++) { slices.push_back(SliceInDim(operand, /*start_index=*/i * block_size, /*limit_index=*/(i + 1) * block_size, /*stride=*/1, /*dimno=*/split_dimension)); } // Handle data communication. HloInstructionProto instr; TF_ASSIGN_OR_RETURN(auto slice_shapes, this->GetOperandShapes(slices)); std::vector<const Shape*> slice_shape_ptrs; absl::c_transform(slice_shapes, std::back_inserter(slice_shape_ptrs), [](const Shape& shape) { return &shape; }); TF_ASSIGN_OR_RETURN( Shape shape, ShapeInference::InferAllToAllTupleShape(slice_shape_ptrs)); *instr.mutable_shape() = shape.ToProto(); for (const ReplicaGroup& group : replica_groups) { *instr.add_replica_groups() = group; } TF_ASSIGN_OR_RETURN( XlaOp alltoall, AddInstruction(std::move(instr), HloOpcode::kAllToAll, slices)); // Concat the N received parts. std::vector<XlaOp> received; received.reserve(split_count); for (int i = 0; i < split_count; i++) { received.push_back(this->GetTupleElement(alltoall, i)); } return this->ConcatInDim(received, concat_dimension); }); } XlaOp XlaBuilder::CollectivePermute( const XlaOp& operand, const std::vector<std::pair<int64, int64>>& source_target_pairs) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); HloInstructionProto instr; TF_ASSIGN_OR_RETURN( Shape shape, ShapeInference::InferCollectivePermuteShape(operand_shape)); *instr.mutable_shape() = shape.ToProto(); for (const auto& pair : source_target_pairs) { auto* proto_pair = instr.add_source_target_pairs(); proto_pair->set_source(pair.first); proto_pair->set_target(pair.second); } return AddInstruction(std::move(instr), HloOpcode::kCollectivePermute, {operand}); }); } XlaOp XlaBuilder::ReplicaId() { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; *instr.mutable_shape() = ShapeUtil::MakeShape(U32, {}).ToProto(); return AddInstruction(std::move(instr), HloOpcode::kReplicaId, {}); }); } XlaOp XlaBuilder::SelectAndScatter(const XlaOp& operand, const XlaComputation& select, absl::Span<const int64> window_dimensions, absl::Span<const int64> window_strides, Padding padding, const XlaOp& source, const XlaOp& init_value, const XlaComputation& scatter) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); return SelectAndScatterWithGeneralPadding( operand, select, window_dimensions, window_strides, MakePadding(AsInt64Slice(operand_shape.dimensions()), window_dimensions, window_strides, padding), source, init_value, scatter); }); } XlaOp XlaBuilder::SelectAndScatterWithGeneralPadding( const XlaOp& operand, const XlaComputation& select, absl::Span<const int64> window_dimensions, absl::Span<const int64> window_strides, absl::Span<const std::pair<int64, int64>> padding, const XlaOp& source, const XlaOp& init_value, const XlaComputation& scatter) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); TF_ASSIGN_OR_RETURN(const Shape& source_shape, GetShape(source)); TF_ASSIGN_OR_RETURN(const Shape& init_shape, GetShape(init_value)); TF_ASSIGN_OR_RETURN(const ProgramShape& select_shape, select.GetProgramShape()); TF_ASSIGN_OR_RETURN(const ProgramShape& scatter_shape, scatter.GetProgramShape()); TF_ASSIGN_OR_RETURN(*instr.mutable_window(), MakeWindow(window_dimensions, window_strides, padding, /*lhs_dilation=*/{}, /*rhs_dilation=*/{})); TF_ASSIGN_OR_RETURN(Shape shape, ShapeInference::InferSelectAndScatterShape( operand_shape, select_shape, instr.window(), source_shape, init_shape, scatter_shape)); *instr.mutable_shape() = shape.ToProto(); AddCalledComputation(select, &instr); AddCalledComputation(scatter, &instr); return AddInstruction(std::move(instr), HloOpcode::kSelectAndScatter, {operand, source, init_value}); }); } XlaOp XlaBuilder::ReducePrecision(const XlaOp& operand, const int exponent_bits, const int mantissa_bits) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); TF_ASSIGN_OR_RETURN(Shape shape, ShapeInference::InferReducePrecisionShape( operand_shape, exponent_bits, mantissa_bits)); *instr.mutable_shape() = shape.ToProto(); instr.set_exponent_bits(exponent_bits); instr.set_mantissa_bits(mantissa_bits); return AddInstruction(std::move(instr), HloOpcode::kReducePrecision, {operand}); }); } void XlaBuilder::Send(const XlaOp& operand, const ChannelHandle& handle) { ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { // Send HLO takes two operands: a data operand and a token. Generate the // token to pass into the send. // TODO(b/80000000): Remove this when clients have been updated to handle // tokens. HloInstructionProto token_instr; *token_instr.mutable_shape() = ShapeUtil::MakeTokenShape().ToProto(); TF_ASSIGN_OR_RETURN(XlaOp token, AddInstruction(std::move(token_instr), HloOpcode::kAfterAll, {})); return SendWithToken(operand, token, handle); }); } XlaOp XlaBuilder::SendWithToken(const XlaOp& operand, const XlaOp& token, const ChannelHandle& handle) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { if (handle.type() != ChannelHandle::DEVICE_TO_DEVICE) { return InvalidArgument("Send must use a device-to-device channel"); } // Send instruction produces a tuple of {aliased operand, U32 context, // token}. HloInstructionProto send_instr; TF_ASSIGN_OR_RETURN(const Shape& shape, GetShape(operand)); *send_instr.mutable_shape() = ShapeUtil::MakeTupleShape( {shape, ShapeUtil::MakeShape(U32, {}), ShapeUtil::MakeTokenShape()}) .ToProto(); send_instr.set_channel_id(handle.handle()); TF_ASSIGN_OR_RETURN(XlaOp send, AddInstruction(std::move(send_instr), HloOpcode::kSend, {operand, token})); HloInstructionProto send_done_instr; *send_done_instr.mutable_shape() = ShapeUtil::MakeTokenShape().ToProto(); send_done_instr.set_channel_id(handle.handle()); return AddInstruction(std::move(send_done_instr), HloOpcode::kSendDone, {send}); }); } XlaOp XlaBuilder::Recv(const Shape& shape, const ChannelHandle& handle) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { // Recv HLO takes a single token operand. Generate the token to pass into // the Recv and RecvDone instructions. // TODO(b/80000000): Remove this when clients have been updated to handle // tokens. HloInstructionProto token_instr; *token_instr.mutable_shape() = ShapeUtil::MakeTokenShape().ToProto(); TF_ASSIGN_OR_RETURN(XlaOp token, AddInstruction(std::move(token_instr), HloOpcode::kAfterAll, {})); XlaOp recv = RecvWithToken(token, shape, handle); // The RecvDone instruction produces a tuple of the data and a token // type. Return XLA op containing the data. // TODO(b/80000000): Remove this when clients have been updated to handle // tokens. HloInstructionProto recv_data; *recv_data.mutable_shape() = shape.ToProto(); recv_data.set_tuple_index(0); return AddInstruction(std::move(recv_data), HloOpcode::kGetTupleElement, {recv}); }); } XlaOp XlaBuilder::RecvWithToken(const XlaOp& token, const Shape& shape, const ChannelHandle& handle) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { if (handle.type() != ChannelHandle::DEVICE_TO_DEVICE) { return InvalidArgument("Recv must use a device-to-device channel"); } // Recv instruction produces a tuple of {receive buffer, U32 context, // token}. HloInstructionProto recv_instr; *recv_instr.mutable_shape() = ShapeUtil::MakeTupleShape( {shape, ShapeUtil::MakeShape(U32, {}), ShapeUtil::MakeTokenShape()}) .ToProto(); recv_instr.set_channel_id(handle.handle()); TF_ASSIGN_OR_RETURN(XlaOp recv, AddInstruction(std::move(recv_instr), HloOpcode::kRecv, {token})); HloInstructionProto recv_done_instr; *recv_done_instr.mutable_shape() = ShapeUtil::MakeTupleShape({shape, ShapeUtil::MakeTokenShape()}) .ToProto(); recv_done_instr.set_channel_id(handle.handle()); return AddInstruction(std::move(recv_done_instr), HloOpcode::kRecvDone, {recv}); }); } XlaOp XlaBuilder::SendToHost(const XlaOp& operand, const XlaOp& token, const Shape& shape_with_layout, const ChannelHandle& handle) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { if (!LayoutUtil::HasLayout(shape_with_layout)) { return InvalidArgument("Shape passed to SendToHost must have a layout"); } TF_ASSIGN_OR_RETURN(const Shape& operand_shape, GetShape(operand)); if (!ShapeUtil::Compatible(operand_shape, shape_with_layout)) { return InvalidArgument( "SendToHost shape %s must be compatible with operand shape %s", ShapeUtil::HumanStringWithLayout(shape_with_layout), ShapeUtil::HumanStringWithLayout(operand_shape)); } // TODO(b/111544877): Support tuple shapes. if (!operand_shape.IsArray()) { return InvalidArgument("SendToHost only supports array shapes, shape: %s", ShapeUtil::HumanString(operand_shape)); } if (handle.type() != ChannelHandle::DEVICE_TO_HOST) { return InvalidArgument("SendToHost must use a device-to-host channel"); } // Send instruction produces a tuple of {aliased operand, U32 context, // token}. HloInstructionProto send_instr; *send_instr.mutable_shape() = ShapeUtil::MakeTupleShape({shape_with_layout, ShapeUtil::MakeShape(U32, {}), ShapeUtil::MakeTokenShape()}) .ToProto(); send_instr.set_channel_id(handle.handle()); send_instr.set_is_host_transfer(true); TF_ASSIGN_OR_RETURN(XlaOp send, AddInstruction(std::move(send_instr), HloOpcode::kSend, {operand, token})); HloInstructionProto send_done_instr; *send_done_instr.mutable_shape() = ShapeUtil::MakeTokenShape().ToProto(); send_done_instr.set_channel_id(handle.handle()); send_done_instr.set_is_host_transfer(true); return AddInstruction(std::move(send_done_instr), HloOpcode::kSendDone, {send}); }); } XlaOp XlaBuilder::RecvFromHost(const XlaOp& token, const Shape& shape, const ChannelHandle& handle) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { if (!LayoutUtil::HasLayout(shape)) { return InvalidArgument("Shape passed to RecvFromHost must have a layout"); } // TODO(b/111544877): Support tuple shapes. if (!shape.IsArray()) { return InvalidArgument( "RecvFromHost only supports array shapes, shape: %s", ShapeUtil::HumanString(shape)); } if (handle.type() != ChannelHandle::HOST_TO_DEVICE) { return InvalidArgument("RecvFromHost must use a host-to-device channel"); } // Recv instruction produces a tuple of {receive buffer, U32 context, // token}. HloInstructionProto recv_instr; *recv_instr.mutable_shape() = ShapeUtil::MakeTupleShape( {shape, ShapeUtil::MakeShape(U32, {}), ShapeUtil::MakeTokenShape()}) .ToProto(); recv_instr.set_channel_id(handle.handle()); recv_instr.set_is_host_transfer(true); TF_ASSIGN_OR_RETURN(XlaOp recv, AddInstruction(std::move(recv_instr), HloOpcode::kRecv, {token})); HloInstructionProto recv_done_instr; *recv_done_instr.mutable_shape() = ShapeUtil::MakeTupleShape({shape, ShapeUtil::MakeTokenShape()}) .ToProto(); recv_done_instr.set_channel_id(handle.handle()); recv_done_instr.set_is_host_transfer(true); return AddInstruction(std::move(recv_done_instr), HloOpcode::kRecvDone, {recv}); }); } XlaOp XlaBuilder::GetDimensionSize(const XlaOp& operand, int64 dimension) { return ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const auto& operand_shape, GetShape(operand)); TF_ASSIGN_OR_RETURN(Shape shape, ShapeInference::InferGetDimensionSizeShape( operand_shape, dimension)); *instr.mutable_shape() = shape.ToProto(); instr.add_dimensions(dimension); return AddInstruction(std::move(instr), HloOpcode::kGetDimensionSize, {operand}); }); } StatusOr<bool> XlaBuilder::IsConstant(const XlaOp& operand) const { TF_RETURN_IF_ERROR(first_error_); // Verify that the handle is valid. TF_RETURN_IF_ERROR(LookUpInstruction(operand).status()); bool is_constant = true; absl::flat_hash_set<int64> visited; IsConstantVisitor(operand.handle(), &visited, &is_constant); return is_constant; } StatusOr<XlaComputation> XlaBuilder::BuildConstantSubGraph( const XlaOp& root_op) { TF_ASSIGN_OR_RETURN(bool is_constant, IsConstant(root_op)); if (!is_constant) { auto op_status = LookUpInstruction(root_op); string op_string = op_status.ok() ? op_status.ValueOrDie()->name() : "<unknown operation>"; return InvalidArgument( "Operand to BuildConstantSubGraph depends on a parameter.\n\n" " op requested for constant subgraph: %s\n\n" "This is an internal error that typically happens when the XLA user " "(e.g. TensorFlow) is attempting to determine a value that must be a " "compile-time constant (e.g. an array dimension) but it is not capable " "of being evaluated at XLA compile time.\n\n" "Please file a usability bug with the framework being used (e.g. " "TensorFlow).", op_string); } TF_ASSIGN_OR_RETURN(const HloInstructionProto* root, LookUpInstruction(root_op)); HloComputationProto entry; SetProtoIdAndName(&entry, StrCat(name_, "_compute_constant"), kNameSeparator, GetNextId()); entry.set_root_id(root->id()); ProgramShapeProto* program_shape = entry.mutable_program_shape(); *program_shape->mutable_result() = root->shape(); // We use std::set to keep the instruction ids in ascending order (which is // also a valid dependency order). The related ops will be added to the // subgraph in the same order. std::set<int64> related_ops; absl::flat_hash_set<int64> related_calls; // Related computations. std::queue<int64> worklist; worklist.push(root->id()); related_ops.insert(root->id()); while (!worklist.empty()) { int64 handle = worklist.front(); worklist.pop(); TF_ASSIGN_OR_RETURN(const HloInstructionProto* instr_proto, LookUpInstructionByHandle(handle)); if (instr_proto->opcode() == HloOpcodeString(HloOpcode::kGetDimensionSize)) { // At this point, BuildConstantSubGraph should never encounter a // GetDimensionSize with a dynamic dimension. IsConstant check would have // failed at the beginning of this function. // // Replace GetDimensionSize with a Constant representing the static bound // of the shape. int64 dimension = instr_proto->dimensions(0); int64 operand_handle = instr_proto->operand_ids(0); TF_ASSIGN_OR_RETURN(const HloInstructionProto* operand_proto, LookUpInstructionByHandle(operand_handle)); TF_RET_CHECK(!operand_proto->shape().is_dynamic_dimension(dimension)); auto constant_dimension_size = static_cast<uint32>(operand_proto->shape().dimensions(dimension)); Literal literal = LiteralUtil::CreateR0(constant_dimension_size); HloInstructionProto const_instr; *const_instr.mutable_shape() = literal.shape().ToProto(); *const_instr.mutable_literal() = literal.ToProto(); *const_instr.mutable_opcode() = HloOpcodeString(HloOpcode::kConstant); const_instr.set_id(handle); *const_instr.mutable_name() = GetFullName(const_instr.opcode(), kNameSeparator, const_instr.id()); *entry.add_instructions() = const_instr; // Add to the result constant graph. } else { for (int64 id : instr_proto->operand_ids()) { if (related_ops.insert(id).second) { worklist.push(id); } } for (int64 called_id : instr_proto->called_computation_ids()) { related_calls.insert(called_id); } } } // Add related ops to the computation. for (int64 id : related_ops) { TF_ASSIGN_OR_RETURN(const HloInstructionProto* instr_src, LookUpInstructionByHandle(id)); if (instr_src->opcode() == HloOpcodeString(HloOpcode::kGetDimensionSize)) { continue; } auto* instr = entry.add_instructions(); *instr = *instr_src; // Ensures that the instruction names are unique among the graph. const string& new_name = StrCat(instr->name(), ".", entry.id(), ".", instr->id()); instr->set_name(new_name); } XlaComputation computation(entry.id()); HloModuleProto* module = computation.mutable_proto(); module->set_name(entry.name()); module->set_id(entry.id()); module->set_entry_computation_name(entry.name()); module->set_entry_computation_id(entry.id()); *module->mutable_host_program_shape() = *program_shape; for (auto& e : embedded_) { if (related_calls.find(e.second.id()) != related_calls.end()) { *module->add_computations() = e.second; } } *module->add_computations() = std::move(entry); return std::move(computation); } std::unique_ptr<XlaBuilder> XlaBuilder::CreateSubBuilder( const string& computation_name) { auto sub_builder = absl::make_unique<XlaBuilder>(computation_name); sub_builder->parent_builder_ = this; sub_builder->die_immediately_on_error_ = this->die_immediately_on_error_; return sub_builder; } /* static */ ConvolutionDimensionNumbers XlaBuilder::CreateDefaultConvDimensionNumbers(int num_spatial_dims) { ConvolutionDimensionNumbers dimension_numbers; dimension_numbers.set_input_batch_dimension(kConvBatchDimension); dimension_numbers.set_input_feature_dimension(kConvFeatureDimension); dimension_numbers.set_output_batch_dimension(kConvBatchDimension); dimension_numbers.set_output_feature_dimension(kConvFeatureDimension); dimension_numbers.set_kernel_output_feature_dimension( kConvKernelOutputDimension); dimension_numbers.set_kernel_input_feature_dimension( kConvKernelInputDimension); for (int i = 0; i < num_spatial_dims; ++i) { dimension_numbers.add_input_spatial_dimensions(i + 2); dimension_numbers.add_kernel_spatial_dimensions(i + 2); dimension_numbers.add_output_spatial_dimensions(i + 2); } return dimension_numbers; } /* static */ Status XlaBuilder::Validate( const ConvolutionDimensionNumbers& dnum) { if (dnum.input_spatial_dimensions_size() < 2) { return FailedPrecondition("input spacial dimension < 2: %d", dnum.input_spatial_dimensions_size()); } if (dnum.kernel_spatial_dimensions_size() < 2) { return FailedPrecondition("kernel spacial dimension < 2: %d", dnum.kernel_spatial_dimensions_size()); } if (dnum.output_spatial_dimensions_size() < 2) { return FailedPrecondition("output spacial dimension < 2: %d", dnum.output_spatial_dimensions_size()); } if (std::set<int64>( {dnum.input_batch_dimension(), dnum.input_feature_dimension(), dnum.input_spatial_dimensions(0), dnum.input_spatial_dimensions(1)}) .size() != 4) { return FailedPrecondition( "dimension numbers for the input are not unique: (%d, %d, %d, " "%d)", dnum.input_batch_dimension(), dnum.input_feature_dimension(), dnum.input_spatial_dimensions(0), dnum.input_spatial_dimensions(1)); } if (std::set<int64>({dnum.kernel_output_feature_dimension(), dnum.kernel_input_feature_dimension(), dnum.kernel_spatial_dimensions(0), dnum.kernel_spatial_dimensions(1)}) .size() != 4) { return FailedPrecondition( "dimension numbers for the weight are not unique: (%d, %d, %d, " "%d)", dnum.kernel_output_feature_dimension(), dnum.kernel_input_feature_dimension(), dnum.kernel_spatial_dimensions(0), dnum.kernel_spatial_dimensions(1)); } if (std::set<int64>({dnum.output_batch_dimension(), dnum.output_feature_dimension(), dnum.output_spatial_dimensions(0), dnum.output_spatial_dimensions(1)}) .size() != 4) { return FailedPrecondition( "dimension numbers for the output are not unique: (%d, %d, %d, " "%d)", dnum.output_batch_dimension(), dnum.output_feature_dimension(), dnum.output_spatial_dimensions(0), dnum.output_spatial_dimensions(1)); } return Status::OK(); } StatusOr<XlaOp> XlaBuilder::AddInstruction(HloInstructionProto&& instr, HloOpcode opcode, absl::Span<const XlaOp> operands) { TF_RETURN_IF_ERROR(first_error_); const int64 handle = GetNextId(); instr.set_id(handle); instr.set_opcode(HloOpcodeString(opcode)); if (instr.name().empty()) { instr.set_name(instr.opcode()); } for (const auto& operand : operands) { if (operand.builder_ == nullptr) { return InvalidArgument("invalid XlaOp with handle %d", operand.handle()); } if (operand.builder_ != this) { return InvalidArgument("Do not add XlaOp from builder %s to builder %s", operand.builder_->name(), this->name()); } instr.add_operand_ids(operand.handle()); } *instr.mutable_metadata() = metadata_; if (sharding_) { *instr.mutable_sharding() = *sharding_; } handle_to_index_[handle] = instructions_.size(); instructions_.push_back(std::move(instr)); XlaOp op(handle, this); return op; } void XlaBuilder::AddCalledComputation(const XlaComputation& computation, HloInstructionProto* instr) { absl::flat_hash_map<int64, int64> remapped_ids; std::vector<HloComputationProto> imported_computations; imported_computations.reserve(computation.proto().computations_size()); // Before we import the computations by remapping IDs, and capturing the // old->new mappings in remapped_ids. for (const HloComputationProto& e : computation.proto().computations()) { HloComputationProto new_computation(e); int64 computation_id = GetNextId(); remapped_ids[new_computation.id()] = computation_id; SetProtoIdAndName(&new_computation, GetBaseName(new_computation.name(), kNameSeparator), kNameSeparator, computation_id); for (auto& instruction : *new_computation.mutable_instructions()) { int64 instruction_id = GetNextId(); remapped_ids[instruction.id()] = instruction_id; SetProtoIdAndName(&instruction, GetBaseName(instruction.name(), kNameSeparator), kNameSeparator, instruction_id); } new_computation.set_root_id(remapped_ids.at(new_computation.root_id())); imported_computations.push_back(std::move(new_computation)); } // Once we have imported all the computations, and captured all the ID // mappings, we go back and fixup the IDs in the imported computations. instr->add_called_computation_ids( remapped_ids.at(computation.proto().entry_computation_id())); for (auto& imported_computation : imported_computations) { for (auto& instruction : *imported_computation.mutable_instructions()) { for (auto& operand_id : *instruction.mutable_operand_ids()) { operand_id = remapped_ids.at(operand_id); } for (auto& control_predecessor_id : *instruction.mutable_control_predecessor_ids()) { control_predecessor_id = remapped_ids.at(control_predecessor_id); } for (auto& called_computation_id : *instruction.mutable_called_computation_ids()) { called_computation_id = remapped_ids.at(called_computation_id); } } int64 computation_id = imported_computation.id(); embedded_.insert({computation_id, std::move(imported_computation)}); } } StatusOr<const HloInstructionProto*> XlaBuilder::LookUpInstruction( const XlaOp& op) const { TF_RETURN_IF_ERROR(first_error_); if (op.builder_ == nullptr) { return InvalidArgument( "invalid XlaOp with handle %d; the builder of this op is freed", op.handle()); } if (op.builder_ != this) { return InvalidArgument( "XlaOp with handle %d is built by builder '%s', but is trying to use " "it in builder '%s'", op.handle(), op.builder_->name(), this->name()); } return LookUpInstructionByHandle(op.handle()); } StatusOr<const HloInstructionProto*> XlaBuilder::LookUpInstructionByHandle( int64 handle) const { auto it = handle_to_index_.find(handle); if (it == handle_to_index_.end()) { return InvalidArgument("No XlaOp with handle %d", handle); } return &instructions_[it->second]; } // Enqueues a "retrieve parameter value" instruction for a parameter that was // passed to the computation. XlaOp Parameter(XlaBuilder* builder, int64 parameter_number, const Shape& shape, const string& name) { std::vector<bool> empty_bools; return Parameter(builder, parameter_number, shape, name, empty_bools); } XlaOp Parameter(XlaBuilder* builder, int64 parameter_number, const Shape& shape, const string& name, const std::vector<bool>& replicated_at_leaf_buffers) { return builder->Parameter(parameter_number, shape, name, replicated_at_leaf_buffers); } // Enqueues a constant with the value of the given literal onto the // computation. XlaOp ConstantLiteral(XlaBuilder* builder, const LiteralSlice& literal) { return builder->ConstantLiteral(literal); } XlaOp Broadcast(const XlaOp& operand, absl::Span<const int64> broadcast_sizes) { return operand.builder()->Broadcast(operand, broadcast_sizes); } XlaOp BroadcastInDim(const XlaOp& operand, const absl::Span<const int64> out_dim_size, const absl::Span<const int64> broadcast_dimensions) { return operand.builder()->BroadcastInDim(operand, out_dim_size, broadcast_dimensions); } XlaOp Pad(const XlaOp& operand, const XlaOp& padding_value, const PaddingConfig& padding_config) { return operand.builder()->Pad(operand, padding_value, padding_config); } XlaOp Reshape(const XlaOp& operand, absl::Span<const int64> dimensions, absl::Span<const int64> new_sizes) { return operand.builder()->Reshape(operand, dimensions, new_sizes); } XlaOp Reshape(const XlaOp& operand, absl::Span<const int64> new_sizes) { return operand.builder()->Reshape(operand, new_sizes); } XlaOp Collapse(const XlaOp& operand, absl::Span<const int64> dimensions) { return operand.builder()->Collapse(operand, dimensions); } XlaOp Slice(const XlaOp& operand, absl::Span<const int64> start_indices, absl::Span<const int64> limit_indices, absl::Span<const int64> strides) { return operand.builder()->Slice(operand, start_indices, limit_indices, strides); } XlaOp SliceInDim(const XlaOp& operand, int64 start_index, int64 limit_index, int64 stride, int64 dimno) { return operand.builder()->SliceInDim(operand, start_index, limit_index, stride, dimno); } XlaOp DynamicSlice(const XlaOp& operand, const XlaOp& start_indices, absl::Span<const int64> slice_sizes) { return operand.builder()->DynamicSlice(operand, start_indices, slice_sizes); } XlaOp DynamicSlice(const XlaOp& operand, absl::Span<const XlaOp> start_indices, absl::Span<const int64> slice_sizes) { return operand.builder()->DynamicSlice(operand, start_indices, slice_sizes); } XlaOp DynamicUpdateSlice(const XlaOp& operand, const XlaOp& update, const XlaOp& start_indices) { return operand.builder()->DynamicUpdateSlice(operand, update, start_indices); } XlaOp DynamicUpdateSlice(const XlaOp& operand, const XlaOp& update, absl::Span<const XlaOp> start_indices) { return operand.builder()->DynamicUpdateSlice(operand, update, start_indices); } XlaOp ConcatInDim(XlaBuilder* builder, absl::Span<const XlaOp> operands, int64 dimension) { return builder->ConcatInDim(operands, dimension); } void Trace(const string& tag, const XlaOp& operand) { return operand.builder()->Trace(tag, operand); } XlaOp Select(const XlaOp& pred, const XlaOp& on_true, const XlaOp& on_false) { return pred.builder()->Select(pred, on_true, on_false); } XlaOp Tuple(XlaBuilder* builder, absl::Span<const XlaOp> elements) { return builder->Tuple(elements); } XlaOp GetTupleElement(const XlaOp& tuple_data, int64 index) { return tuple_data.builder()->GetTupleElement(tuple_data, index); } XlaOp Eq(const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> broadcast_dimensions) { return Compare(lhs, rhs, broadcast_dimensions, ComparisonDirection::kEq); } XlaOp Ne(const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> broadcast_dimensions) { return Compare(lhs, rhs, broadcast_dimensions, ComparisonDirection::kNe); } XlaOp Ge(const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> broadcast_dimensions) { return Compare(lhs, rhs, broadcast_dimensions, ComparisonDirection::kGe); } XlaOp Gt(const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> broadcast_dimensions) { return Compare(lhs, rhs, broadcast_dimensions, ComparisonDirection::kGt); } XlaOp Le(const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> broadcast_dimensions) { return Compare(lhs, rhs, broadcast_dimensions, ComparisonDirection::kLe); } XlaOp Lt(const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> broadcast_dimensions) { return Compare(lhs, rhs, broadcast_dimensions, ComparisonDirection::kLt); } XlaOp Compare(const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> broadcast_dimensions, ComparisonDirection direction) { return lhs.builder()->BinaryOp(HloOpcode::kCompare, lhs, rhs, broadcast_dimensions, direction); } XlaOp Dot(const XlaOp& lhs, const XlaOp& rhs, const PrecisionConfig* precision_config) { return lhs.builder()->Dot(lhs, rhs, precision_config); } XlaOp DotGeneral(const XlaOp& lhs, const XlaOp& rhs, const DotDimensionNumbers& dimension_numbers, const PrecisionConfig* precision_config) { return lhs.builder()->DotGeneral(lhs, rhs, dimension_numbers, precision_config); } XlaOp Conv(const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> window_strides, Padding padding, int64 feature_group_count, int64 batch_group_count, const PrecisionConfig* precision_config) { return lhs.builder()->Conv(lhs, rhs, window_strides, padding, feature_group_count, batch_group_count, precision_config); } XlaOp ConvWithGeneralPadding(const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> window_strides, absl::Span<const std::pair<int64, int64>> padding, int64 feature_group_count, int64 batch_group_count, const PrecisionConfig* precision_config) { return lhs.builder()->ConvWithGeneralPadding( lhs, rhs, window_strides, padding, feature_group_count, batch_group_count, precision_config); } XlaOp ConvWithGeneralDimensions( const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> window_strides, Padding padding, const ConvolutionDimensionNumbers& dimension_numbers, int64 feature_group_count, int64 batch_group_count, const PrecisionConfig* precision_config) { return lhs.builder()->ConvWithGeneralDimensions( lhs, rhs, window_strides, padding, dimension_numbers, feature_group_count, batch_group_count, precision_config); } XlaOp ConvGeneral(const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> window_strides, absl::Span<const std::pair<int64, int64>> padding, const ConvolutionDimensionNumbers& dimension_numbers, int64 feature_group_count, int64 batch_group_count, const PrecisionConfig* precision_config) { return lhs.builder()->ConvGeneral(lhs, rhs, window_strides, padding, dimension_numbers, feature_group_count, batch_group_count, precision_config); } XlaOp ConvGeneralDilated(const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> window_strides, absl::Span<const std::pair<int64, int64>> padding, absl::Span<const int64> lhs_dilation, absl::Span<const int64> rhs_dilation, const ConvolutionDimensionNumbers& dimension_numbers, int64 feature_group_count, int64 batch_group_count, const PrecisionConfig* precision_config) { return lhs.builder()->ConvGeneralDilated( lhs, rhs, window_strides, padding, lhs_dilation, rhs_dilation, dimension_numbers, feature_group_count, batch_group_count, precision_config); } XlaOp Fft(const XlaOp& operand, FftType fft_type, absl::Span<const int64> fft_length) { return operand.builder()->Fft(operand, fft_type, fft_length); } XlaOp TriangularSolve(XlaOp a, XlaOp b, bool left_side, bool lower, bool unit_diagonal, TriangularSolveOptions::Transpose transpose_a) { XlaBuilder* builder = a.builder(); return builder->ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& a_shape, builder->GetShape(a)); TF_ASSIGN_OR_RETURN(const Shape& b_shape, builder->GetShape(b)); xla::TriangularSolveOptions& options = *instr.mutable_triangular_solve_options(); options.set_left_side(left_side); options.set_lower(lower); options.set_unit_diagonal(unit_diagonal); options.set_transpose_a(transpose_a); TF_ASSIGN_OR_RETURN(Shape shape, ShapeInference::InferTriangularSolveShape( a_shape, b_shape, options)); *instr.mutable_shape() = shape.ToProto(); return builder->AddInstruction(std::move(instr), HloOpcode::kTriangularSolve, {a, b}); }); } XlaOp Cholesky(XlaOp a, bool lower) { XlaBuilder* builder = a.builder(); return builder->ReportErrorOrReturn([&]() -> StatusOr<XlaOp> { HloInstructionProto instr; TF_ASSIGN_OR_RETURN(const Shape& a_shape, builder->GetShape(a)); xla::CholeskyOptions& options = *instr.mutable_cholesky_options(); options.set_lower(lower); TF_ASSIGN_OR_RETURN(Shape shape, ShapeInference::InferCholeskyShape(a_shape)); *instr.mutable_shape() = shape.ToProto(); return builder->AddInstruction(std::move(instr), HloOpcode::kCholesky, {a}); }); } XlaOp Infeed(XlaBuilder* builder, const Shape& shape, const string& config) { return builder->Infeed(shape, config); } void Outfeed(const XlaOp& operand, const Shape& shape_with_layout, const string& outfeed_config) { return operand.builder()->Outfeed(operand, shape_with_layout, outfeed_config); } XlaOp Call(XlaBuilder* builder, const XlaComputation& computation, absl::Span<const XlaOp> operands) { return builder->Call(computation, operands); } XlaOp CustomCall(XlaBuilder* builder, const string& call_target_name, absl::Span<const XlaOp> operands, const Shape& shape, const string& opaque) { return builder->CustomCall(call_target_name, operands, shape, opaque, /*operand_shapes_with_layout=*/absl::nullopt); } XlaOp CustomCallWithLayout(XlaBuilder* builder, const string& call_target_name, absl::Span<const XlaOp> operands, const Shape& shape, absl::Span<const Shape> operand_shapes_with_layout, const string& opaque) { return builder->CustomCall(call_target_name, operands, shape, opaque, operand_shapes_with_layout); } XlaOp Complex(const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> broadcast_dimensions) { return lhs.builder()->BinaryOp(HloOpcode::kComplex, lhs, rhs, broadcast_dimensions); } XlaOp Conj(const XlaOp& operand) { return Complex(Real(operand), Neg(Imag(operand))); } XlaOp Add(const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> broadcast_dimensions) { return lhs.builder()->BinaryOp(HloOpcode::kAdd, lhs, rhs, broadcast_dimensions); } XlaOp Sub(const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> broadcast_dimensions) { return lhs.builder()->BinaryOp(HloOpcode::kSubtract, lhs, rhs, broadcast_dimensions); } XlaOp Mul(const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> broadcast_dimensions) { return lhs.builder()->BinaryOp(HloOpcode::kMultiply, lhs, rhs, broadcast_dimensions); } XlaOp Div(const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> broadcast_dimensions) { return lhs.builder()->BinaryOp(HloOpcode::kDivide, lhs, rhs, broadcast_dimensions); } XlaOp Rem(const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> broadcast_dimensions) { return lhs.builder()->BinaryOp(HloOpcode::kRemainder, lhs, rhs, broadcast_dimensions); } XlaOp Max(const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> broadcast_dimensions) { return lhs.builder()->BinaryOp(HloOpcode::kMaximum, lhs, rhs, broadcast_dimensions); } XlaOp Min(const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> broadcast_dimensions) { return lhs.builder()->BinaryOp(HloOpcode::kMinimum, lhs, rhs, broadcast_dimensions); } XlaOp And(const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> broadcast_dimensions) { return lhs.builder()->BinaryOp(HloOpcode::kAnd, lhs, rhs, broadcast_dimensions); } XlaOp Or(const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> broadcast_dimensions) { return lhs.builder()->BinaryOp(HloOpcode::kOr, lhs, rhs, broadcast_dimensions); } XlaOp Xor(const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> broadcast_dimensions) { return lhs.builder()->BinaryOp(HloOpcode::kXor, lhs, rhs, broadcast_dimensions); } XlaOp Not(const XlaOp& operand) { return operand.builder()->UnaryOp(HloOpcode::kNot, operand); } XlaOp PopulationCount(const XlaOp& operand) { return operand.builder()->UnaryOp(HloOpcode::kPopulationCount, operand); } XlaOp ShiftLeft(const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> broadcast_dimensions) { return lhs.builder()->BinaryOp(HloOpcode::kShiftLeft, lhs, rhs, broadcast_dimensions); } XlaOp ShiftRightArithmetic(const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> broadcast_dimensions) { return lhs.builder()->BinaryOp(HloOpcode::kShiftRightArithmetic, lhs, rhs, broadcast_dimensions); } XlaOp ShiftRightLogical(const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> broadcast_dimensions) { return lhs.builder()->BinaryOp(HloOpcode::kShiftRightLogical, lhs, rhs, broadcast_dimensions); } XlaOp Reduce(const XlaOp& operand, const XlaOp& init_value, const XlaComputation& computation, absl::Span<const int64> dimensions_to_reduce) { return operand.builder()->Reduce(operand, init_value, computation, dimensions_to_reduce); } // Reduces several arrays simultaneously among the provided dimensions, given // "computation" as a reduction operator. XlaOp Reduce(XlaBuilder* builder, absl::Span<const XlaOp> operands, absl::Span<const XlaOp> init_values, const XlaComputation& computation, absl::Span<const int64> dimensions_to_reduce) { return builder->Reduce(operands, init_values, computation, dimensions_to_reduce); } XlaOp ReduceAll(const XlaOp& operand, const XlaOp& init_value, const XlaComputation& computation) { return operand.builder()->ReduceAll(operand, init_value, computation); } XlaOp ReduceWindow(const XlaOp& operand, const XlaOp& init_value, const XlaComputation& computation, absl::Span<const int64> window_dimensions, absl::Span<const int64> window_strides, Padding padding) { return operand.builder()->ReduceWindow(operand, init_value, computation, window_dimensions, window_strides, padding); } XlaOp ReduceWindowWithGeneralPadding( const XlaOp& operand, const XlaOp& init_value, const XlaComputation& computation, absl::Span<const int64> window_dimensions, absl::Span<const int64> window_strides, absl::Span<const int64> base_dilations, absl::Span<const int64> window_dilations, absl::Span<const std::pair<int64, int64>> padding) { return operand.builder()->ReduceWindowWithGeneralPadding( operand, init_value, computation, window_dimensions, window_strides, base_dilations, window_dilations, padding); } XlaOp CrossReplicaSum(const XlaOp& operand, absl::Span<const ReplicaGroup> replica_groups) { return operand.builder()->CrossReplicaSum(operand, replica_groups); } XlaOp CrossReplicaSum(const XlaOp& operand, const XlaComputation& computation, absl::Span<const ReplicaGroup> replica_groups, const absl::optional<ChannelHandle>& channel_id) { return operand.builder()->CrossReplicaSum(operand, computation, replica_groups, channel_id); } XlaOp AllToAll(const XlaOp& operand, int64 split_dimension, int64 concat_dimension, int64 split_count, const std::vector<ReplicaGroup>& replica_groups) { return operand.builder()->AllToAll(operand, split_dimension, concat_dimension, split_count, replica_groups); } XlaOp CollectivePermute( const XlaOp& operand, const std::vector<std::pair<int64, int64>>& source_target_pairs) { return operand.builder()->CollectivePermute(operand, source_target_pairs); } XlaOp ReplicaId(XlaBuilder* builder) { return builder->ReplicaId(); } XlaOp SelectAndScatter(const XlaOp& operand, const XlaComputation& select, absl::Span<const int64> window_dimensions, absl::Span<const int64> window_strides, Padding padding, const XlaOp& source, const XlaOp& init_value, const XlaComputation& scatter) { return operand.builder()->SelectAndScatter(operand, select, window_dimensions, window_strides, padding, source, init_value, scatter); } XlaOp SelectAndScatterWithGeneralPadding( const XlaOp& operand, const XlaComputation& select, absl::Span<const int64> window_dimensions, absl::Span<const int64> window_strides, absl::Span<const std::pair<int64, int64>> padding, const XlaOp& source, const XlaOp& init_value, const XlaComputation& scatter) { return operand.builder()->SelectAndScatterWithGeneralPadding( operand, select, window_dimensions, window_strides, padding, source, init_value, scatter); } XlaOp Abs(const XlaOp& operand) { return operand.builder()->UnaryOp(HloOpcode::kAbs, operand); } XlaOp Atan2(const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> broadcast_dimensions) { return lhs.builder()->BinaryOp(HloOpcode::kAtan2, lhs, rhs, broadcast_dimensions); } XlaOp Exp(const XlaOp& operand) { return operand.builder()->UnaryOp(HloOpcode::kExp, operand); } XlaOp Expm1(const XlaOp& operand) { return operand.builder()->UnaryOp(HloOpcode::kExpm1, operand); } XlaOp Floor(const XlaOp& operand) { return operand.builder()->UnaryOp(HloOpcode::kFloor, operand); } XlaOp Ceil(const XlaOp& operand) { return operand.builder()->UnaryOp(HloOpcode::kCeil, operand); } XlaOp Round(const XlaOp& operand) { return operand.builder()->UnaryOp(HloOpcode::kRoundNearestAfz, operand); } XlaOp Log(const XlaOp& operand) { return operand.builder()->UnaryOp(HloOpcode::kLog, operand); } XlaOp Log1p(const XlaOp& operand) { return operand.builder()->UnaryOp(HloOpcode::kLog1p, operand); } XlaOp Sign(const XlaOp& operand) { return operand.builder()->UnaryOp(HloOpcode::kSign, operand); } XlaOp Clz(const XlaOp& operand) { return operand.builder()->UnaryOp(HloOpcode::kClz, operand); } XlaOp Cos(const XlaOp& operand) { return operand.builder()->UnaryOp(HloOpcode::kCos, operand); } XlaOp Sin(const XlaOp& operand) { return operand.builder()->UnaryOp(HloOpcode::kSin, operand); } XlaOp Tanh(const XlaOp& operand) { return operand.builder()->UnaryOp(HloOpcode::kTanh, operand); } XlaOp Real(const XlaOp& operand) { return operand.builder()->UnaryOp(HloOpcode::kReal, operand); } XlaOp Imag(const XlaOp& operand) { return operand.builder()->UnaryOp(HloOpcode::kImag, operand); } XlaOp Sqrt(const XlaOp& operand) { return operand.builder()->UnaryOp(HloOpcode::kSqrt, operand); } XlaOp Rsqrt(const XlaOp& operand) { return operand.builder()->UnaryOp(HloOpcode::kRsqrt, operand); } XlaOp Pow(const XlaOp& lhs, const XlaOp& rhs, absl::Span<const int64> broadcast_dimensions) { return lhs.builder()->BinaryOp(HloOpcode::kPower, lhs, rhs, broadcast_dimensions); } XlaOp IsFinite(const XlaOp& operand) { return operand.builder()->UnaryOp(HloOpcode::kIsFinite, operand); } XlaOp ConvertElementType(const XlaOp& operand, PrimitiveType new_element_type) { return operand.builder()->ConvertElementType(operand, new_element_type); } XlaOp BitcastConvertType(const XlaOp& operand, PrimitiveType new_element_type) { return operand.builder()->BitcastConvertType(operand, new_element_type); } XlaOp Neg(const XlaOp& operand) { return operand.builder()->UnaryOp(HloOpcode::kNegate, operand); } XlaOp Transpose(const XlaOp& operand, absl::Span<const int64> permutation) { return operand.builder()->Transpose(operand, permutation); } XlaOp Rev(const XlaOp& operand, absl::Span<const int64> dimensions) { return operand.builder()->Rev(operand, dimensions); } XlaOp Sort(const XlaOp& keys, absl::Span<const XlaOp> values, int64 dimension) { return keys.builder()->Sort(keys, values, dimension); } XlaOp Sort(absl::Span<const XlaOp> operands, const XlaComputation& comparator, int64 dimension, bool is_stable) { return operands[0].builder()->Sort(operands, comparator, dimension, is_stable); } XlaOp Clamp(const XlaOp& min, const XlaOp& operand, const XlaOp& max) { return min.builder()->Clamp(min, operand, max); } XlaOp Map(XlaBuilder* builder, absl::Span<const XlaOp> operands, const XlaComputation& computation, absl::Span<const int64> dimensions, absl::Span<const XlaOp> static_operands) { return builder->Map(operands, computation, dimensions, static_operands); } XlaOp RngNormal(const XlaOp& mu, const XlaOp& sigma, const Shape& shape) { return mu.builder()->RngNormal(mu, sigma, shape); } XlaOp RngUniform(const XlaOp& a, const XlaOp& b, const Shape& shape) { return a.builder()->RngUniform(a, b, shape); } XlaOp While(const XlaComputation& condition, const XlaComputation& body, const XlaOp& init) { return init.builder()->While(condition, body, init); } XlaOp Conditional(const XlaOp& predicate, const XlaOp& true_operand, const XlaComputation& true_computation, const XlaOp& false_operand, const XlaComputation& false_computation) { return predicate.builder()->Conditional(predicate, true_operand, true_computation, false_operand, false_computation); } XlaOp Conditional(const XlaOp& branch_index, absl::Span<const XlaComputation* const> branch_computations, absl::Span<const XlaOp> branch_operands) { return branch_index.builder()->Conditional(branch_index, branch_computations, branch_operands); } XlaOp ReducePrecision(const XlaOp& operand, const int exponent_bits, const int mantissa_bits) { return operand.builder()->ReducePrecision(operand, exponent_bits, mantissa_bits); } XlaOp Gather(const XlaOp& input, const XlaOp& start_indices, const GatherDimensionNumbers& dimension_numbers, absl::Span<const int64> slice_sizes) { return input.builder()->Gather(input, start_indices, dimension_numbers, slice_sizes); } XlaOp Scatter(const XlaOp& input, const XlaOp& scatter_indices, const XlaOp& updates, const XlaComputation& update_computation, const ScatterDimensionNumbers& dimension_numbers) { return input.builder()->Scatter(input, scatter_indices, updates, update_computation, dimension_numbers); } void Send(const XlaOp& operand, const ChannelHandle& handle) { return operand.builder()->Send(operand, handle); } XlaOp Recv(XlaBuilder* builder, const Shape& shape, const ChannelHandle& handle) { return builder->Recv(shape, handle); } XlaOp SendWithToken(const XlaOp& operand, const XlaOp& token, const ChannelHandle& handle) { return operand.builder()->SendWithToken(operand, token, handle); } XlaOp RecvWithToken(const XlaOp& token, const Shape& shape, const ChannelHandle& handle) { return token.builder()->RecvWithToken(token, shape, handle); } XlaOp SendToHost(const XlaOp& operand, const XlaOp& token, const Shape& shape_with_layout, const ChannelHandle& handle) { return operand.builder()->SendToHost(operand, token, shape_with_layout, handle); } XlaOp RecvFromHost(const XlaOp& token, const Shape& shape, const ChannelHandle& handle) { return token.builder()->RecvFromHost(token, shape, handle); } XlaOp InfeedWithToken(const XlaOp& token, const Shape& shape, const string& config) { return token.builder()->InfeedWithToken(token, shape, config); } XlaOp OutfeedWithToken(const XlaOp& operand, const XlaOp& token, const Shape& shape_with_layout, const string& outfeed_config) { return operand.builder()->OutfeedWithToken(operand, token, shape_with_layout, outfeed_config); } XlaOp CreateToken(XlaBuilder* builder) { return builder->CreateToken(); } XlaOp AfterAll(XlaBuilder* builder, absl::Span<const XlaOp> tokens) { return builder->AfterAll(tokens); } XlaOp BatchNormTraining(const XlaOp& operand, const XlaOp& scale, const XlaOp& offset, float epsilon, int64 feature_index) { return operand.builder()->BatchNormTraining(operand, scale, offset, epsilon, feature_index); } XlaOp BatchNormInference(const XlaOp& operand, const XlaOp& scale, const XlaOp& offset, const XlaOp& mean, const XlaOp& variance, float epsilon, int64 feature_index) { return operand.builder()->BatchNormInference( operand, scale, offset, mean, variance, epsilon, feature_index); } XlaOp BatchNormGrad(const XlaOp& operand, const XlaOp& scale, const XlaOp& batch_mean, const XlaOp& batch_var, const XlaOp& grad_output, float epsilon, int64 feature_index) { return operand.builder()->BatchNormGrad(operand, scale, batch_mean, batch_var, grad_output, epsilon, feature_index); } XlaOp Iota(XlaBuilder* builder, PrimitiveType type, int64 size) { return builder->Iota(type, size); } XlaOp Iota(XlaBuilder* builder, const Shape& shape, int64 iota_dimension) { return builder->Iota(shape, iota_dimension); } XlaOp GetDimensionSize(const XlaOp& operand, int64 dimension) { return operand.builder()->GetDimensionSize(operand, dimension); } } // namespace xla
[ "gardener@tensorflow.org" ]
gardener@tensorflow.org
544cea5d8b889b702b3321d621d274225e1c0c91
5950a96a3fdbca4ede33be78cb409c6cbde747fd
/dependencies/build/SFGUI-0.1.0-source/src/SFGUI/GLCanvas.cpp
a5f2acc3f35f81d37a8d0b03c4b772766215e8e6
[ "Bitstream-Vera", "LicenseRef-scancode-public-domain", "Zlib", "LicenseRef-scancode-unknown-license-reference" ]
permissive
Soth1985/Survive
d2a34cbd08f008cdb04cfde3277a0e9af96d9802
535e32717e1bb2d60c8a2477a98c9c559ce34304
refs/heads/master
2021-03-13T00:01:33.925164
2013-07-25T11:49:47
2013-07-25T11:49:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,068
cpp
#include <SFGUI/GLCanvas.hpp> #include <SFGUI/Renderer.hpp> #include <SFGUI/Container.hpp> #include <cmath> namespace sfg { GLCanvas::GLCanvas() : Widget(), m_custom_draw_callback( new Signal ), m_last_update( 0.f ), m_desired_refresh_rate( 0.f ) { m_custom_viewport = Renderer::Get().CreateViewport(); SetViewport( m_custom_viewport ); m_custom_draw_callback->Connect( &GLCanvas::ResetUpdateTime, this ); } GLCanvas::Ptr GLCanvas::Create() { Ptr gl_canvas_ptr( new GLCanvas() ); return gl_canvas_ptr; } RenderQueue* GLCanvas::InvalidateImpl() const { RenderQueue* queue( new RenderQueue ); queue->Add( Renderer::Get().CreateGLCanvas( m_custom_draw_callback ) ); // Override whatever viewport our parents want us to use. // Yes... we are very naughty aren't we... queue->SetViewport( m_custom_viewport ); return queue; } sf::Vector2f GLCanvas::CalculateRequisition() { return sf::Vector2f( 0.f, 0.f ); } void GLCanvas::HandleSizeChange() { sf::FloatRect allocation = GetAllocation(); m_custom_viewport->SetSize( sf::Vector2f( std::floor( allocation.width + .5f ), std::floor( allocation.height + .5f ) ) ); Invalidate(); } void GLCanvas::HandleAbsolutePositionChange() { sf::Vector2f position = Widget::GetAbsolutePosition(); Container::PtrConst parent = GetParent(); sf::Vector2f parent_position( 0.f, 0.f ); while( parent ) { if( parent->GetName() == "Viewport" ) { // Try to get the first ancestor of the viewport that is not a viewport itself. // Add up all allocations while searching. Container::PtrConst viewport_parent = parent->GetParent(); while( viewport_parent && viewport_parent->GetName() == "Viewport" ) { parent_position += sf::Vector2f( viewport_parent->GetAllocation().left, viewport_parent->GetAllocation().top ); viewport_parent = viewport_parent->GetParent(); } if( !viewport_parent || ( viewport_parent->GetName() == "Viewport" ) ) { parent_position = sf::Vector2f( 0.f, 0.f ); break; } parent_position += viewport_parent->GetAbsolutePosition(); parent_position += sf::Vector2f( parent->GetAllocation().left, parent->GetAllocation().top ); break; } parent = parent->GetParent(); } m_custom_viewport->SetDestinationOrigin( sf::Vector2f( std::floor( parent_position.x + position.x + .5f ), std::floor( parent_position.y + position.y + .5f ) ) ); Invalidate(); } const std::string& GLCanvas::GetName() const { static const std::string name( "GLCanvas" ); return name; } Signal& GLCanvas::GetCustomDrawCallbackSignal() { return *m_custom_draw_callback; } void GLCanvas::HandleUpdate( float seconds ) { m_last_update += seconds; if( ( m_desired_refresh_rate > 0.f ) && ( m_last_update > ( 1.f / m_desired_refresh_rate ) ) ) { sfg::Renderer::Get().Redraw(); } } void GLCanvas::SetDesiredRefreshRate( float rate ) { if( rate < 0.f ) { return; } m_desired_refresh_rate = rate; } void GLCanvas::ResetUpdateTime() { m_last_update = 0.f; } void GLCanvas::Redraw() { sfg::Renderer::Get().Redraw(); } }
[ "soth1985@yahoo.com" ]
soth1985@yahoo.com
0fdef8dba9ed7e5f78a37cacef10f0d2d40cfa3c
e007067b50d6753c32f941a29e9ebffedc3e738c
/LDisk.cpp
ba2b7a8cfb84a12e85097d6d71d1759b91667e86
[]
no_license
JamesSpaniak/File-System
30280fa44d51c611ab70a848f93219a30130e86a
c852b4d9897c03cf1a793c9b6ed71b91a4f99e04
refs/heads/master
2020-05-20T01:36:50.962059
2019-05-07T03:42:57
2019-05-07T03:42:57
185,314,756
0
0
null
null
null
null
UTF-8
C++
false
false
7,184
cpp
#include "Tree.hpp" /* Author(s): James Spaniak */ LDisk::LDisk(int blocks, const int blockSize_) { totalBlocks = blocks; blockSize = blockSize_; DNode *newHead = new DNode(0, totalBlocks-1, 0); head = newHead; } /* insert new data into the LDisk LL if it will fit size: size of file in blocks takes in the LFile linked list that corresponds to the file being inserted so we can keep track of what blocks each file is in on the disk */ int LDisk::insert(int size, LFile* fhead) { DNode* temp = head; int lastNodeSpace, compare, blockSplit, available, origSize, diskSlotSpace; bool weShouldMerge; //first check there will be enough space to add available = 0; while(temp!=NULL) { if(!temp->usedBit) available += temp->end - temp->start + 1; if(available >= (size + blockSize - 1)/blockSize) break; temp=temp->next; } if(available < (size + blockSize - 1)/blockSize) return 1; //if we are here there is enough space to add the file in question //reset temp to head temp = head; DNode *prev = NULL; while(size > 0) { while(temp->usedBit) { prev = temp; temp=temp->next; if(temp==NULL) { return 1; } } //if there is space left on the last node we want to add it there first before appending another lastNodeSpace = fhead->getLastNodeSpace(); if(lastNodeSpace > 0) { compare = std::min(lastNodeSpace, size); size-=compare; fhead->fillLastNode(compare); } else { //append another node blockSplit = temp->end-temp->start+1; if(prev!=NULL) { weShouldMerge = fhead->isAddressPresent(prev->start*blockSize); } else { weShouldMerge=false; } if(size <= blockSplit*blockSize) { //bytes to add can fit in current space of open nodes origSize = size; while(size) { //add one node at a time compare = std::min(size, blockSize); size-=compare; if(weShouldMerge) fhead->appendNodeWithSize(compare, prev->start*blockSize); else fhead->appendNodeWithSize(compare, temp->start*blockSize); } split(temp, (origSize+blockSize-1)/blockSize, 1); if(weShouldMerge) { prev->next = temp->next; prev->end = temp->end; } } else { //we can fill this space completely but we need to look for more space after diskSlotSpace = blockSplit*blockSize; while(diskSlotSpace) { fhead->appendNodeWithSize(blockSize, temp->start*blockSize); diskSlotSpace-=blockSize; } size-=diskSlotSpace; temp->usedBit=1; if(weShouldMerge) { prev->next = temp->next; prev->end = temp->end; } } } } return 0; } //remove number of bytes (size) from file void LDisk::remove(int size, LFile* fhead) { FNode* temp; DNode* diskNode = head; DNode* diskNodePrev = NULL; int address; int bytes; bool check; //dont want to set size of file to below 0 if(size > fhead->getSize()) { size = fhead->getSize(); } while(size > 0) { temp = fhead->getHead(); diskNode = head; diskNodePrev = NULL; if(temp==NULL) return; while(temp->next!=NULL) { temp = temp->next; } address = temp->blockAddress/blockSize; if(temp==NULL) return; check=true; while(diskNode!=NULL && check) { if(address >= diskNode->start && address <= diskNode->end) { check=false; } diskNodePrev = diskNode; diskNode=diskNode->next; } if(diskNode==NULL) { std::cout << "Could not find block address" << std::endl; return; } if(temp->capacity <= size && size <= blockSize) { fhead->remove(temp->capacity); size-=temp->capacity; } else if(temp->capacity < blockSize && size >= blockSize) { fhead->remove(temp->capacity); size-=temp->capacity; } else if(size>=blockSize) { bytes = blockSize; fhead->remove(bytes); size-=bytes; } else { fhead->remove(size); size=0; return; } if(diskNodePrev->start==diskNodePrev->end) { diskNodePrev->usedBit=0; } else { split(diskNodePrev, diskNodePrev->end-diskNodePrev->start, 1); } } } /* Merges all adjacent unused nodes together */ void LDisk::merge() { DNode* temp = head; while(temp->next!=NULL) { if(!temp->usedBit && !temp->next->usedBit) { temp->end = temp->next->end; temp->next = temp->next->next; } else { temp=temp->next; } } } //print linked list void LDisk::print(bool debug) { if(head==NULL) return; DNode *temp = head; int fragmentation = 0; int currStatus = temp->usedBit; int currStart=temp->start; int currEnd = temp->end; if(debug) { while(temp!=NULL) { printNode(temp); if(!temp->usedBit) { fragmentation+=temp->end-temp->start+1; } temp=temp->next; } } else { while(temp!=NULL) { if(temp->usedBit!=currStatus) { if(currStatus) { std::cout << "Used: " << currStart << " - " << currEnd << std::endl; } else { std::cout << "Free: " << currStart << " - " << currEnd << std::endl; } } currEnd=temp->end; temp=temp->next; } } std::cout << "Fragmentation: " << fragmentation << std::endl; } LDisk::~LDisk() { } /* Function to split a node into two nodes in the same location of the linked list Params: node: DNode to be split toSplit: size of node to be cut off toStatus: new status of node (1, 0) */ void LDisk::split(DNode *node, int toSplit, int toStatus) { int available; int oldEnd, oldStart; int newStatus = 1 - toStatus; DNode *newNode; oldStart = node->start;//28 oldEnd = node->end;//33 newNode = new DNode(oldStart+toSplit, oldEnd, newStatus);//28+5 node->end = oldStart+toSplit-1; node->usedBit = toStatus; newNode->next = node->next; node->next = newNode; } void LDisk::printNode(DNode *node) { if(node->usedBit) { std::cout << "Used: " << node->start << " - " << node->end << std::endl; } else { std::cout << "Free: " << node->start << " - " << node->end << std::endl; } }
[ "jspaniak@stevens.edu" ]
jspaniak@stevens.edu
8182542483597ea6878034b4f06f722493e6a43c
5e117c7f994525ed76be9cab04a633fd99ef1d15
/AdvancedLevel/second time/1043.Is it a Binary Search Tree(25)/main.cpp
466e9886c152351fa5254896c8538c9610c59be6
[]
no_license
Weijun-H/PAT
05151dd355bb87e1b18d7a2139a9acd1b57b5d2e
923260408375f9d06f426f05c7d6654baf8a039c
refs/heads/master
2022-02-16T04:07:25.194752
2019-09-07T16:27:45
2019-09-07T16:27:45
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,769
cpp
#include <iostream> #include <vector> using namespace std; struct node{ int data; node*lchild=NULL,*rchild=NULL; node(int d):data(d){} }; void insert(node*& root,int data){ if(root==NULL){ root = new node(data); return; } if(root->data>data)insert(root->lchild,data); else insert(root->rchild,data); } vector<int>pre,premirror,post,post_mirror; void preorder(node* root){ if(root==NULL)return; pre.push_back(root->data); preorder(root->lchild); preorder(root->rchild); } void preorder_mirror(node* root){ if(root==NULL)return; premirror.push_back(root->data); preorder_mirror(root->rchild); preorder_mirror(root->lchild); } void postorder(node*root){ if(root==NULL)return; postorder(root->lchild); postorder(root->rchild); post.push_back(root->data); } void postorder_mirror(node*root){ if(root==NULL)return; postorder_mirror(root->rchild); postorder_mirror(root->lchild); post_mirror.push_back(root->data); } int main(){ int n; cin>>n; node*root = NULL; vector<int>origin; for (int i = 0; i < n; ++i) { int data; cin>>data; insert(root,data); origin.push_back(data); } preorder(root); preorder_mirror(root); postorder(root); postorder_mirror(root); if(origin==pre){ printf("YES\n"); for (int i = 0; i < post.size(); ++i) { printf("%d",post[i]); if(i!=post.size()-1)printf(" "); } } else if(origin==premirror){ printf("YES\n"); for (int i = 0; i < post_mirror.size(); ++i) { printf("%d",post_mirror[i]); if(i!=post_mirror.size()-1)printf(" "); } } else{printf("NO\n");} }
[ "huangweijun1001@gmail.com" ]
huangweijun1001@gmail.com
920292e6723bd0bf6de5278ff9a16c5236c67b61
5c3b212599b36a72224162b0578cc60ee0d9fdf7
/1-10/8. 跳台阶.cpp
e418669a459600434592c97a7d292a475566dbe0
[]
no_license
XiaoliSong/Aim-at-offer-C
9ad02fc1ac9f6137674627dd3b35139b68d356ae
e4ac1d4e095ff08f05661550b04a31676e5ef586
refs/heads/master
2020-03-07T05:14:33.116600
2018-04-04T03:04:28
2018-04-04T03:04:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,407
cpp
/* GitHub:https://github.com/XiaoliSong/Aim-at-offer 链接:https://www.nowcoder.com/questionTerminal/8c82a5b80378478f9484d87d1c5f12a4 题目:一只青蛙一次可以跳上1级台阶,也可以跳上2级。求该青蛙跳上一个n级的台阶总共有多少种跳法。 分析: 如果采用递归,则需要很多的重复计算,可以采用备忘录方法进行存储避免不必要的重复计算 当然可以注意到类似于斐波那契数列,跳n次台阶的方法数目=跳n-1次台阶的方法数目+跳n-2次台阶的方法数目 所以可以采用循环方法解决 */ //递归 /* class Solution { public: int jumpFloor(int n) { if(n<=1) return 1; return jumpFloor(n-1)+jumpFloor(n-2); } }; */ //备忘录方法 /* class Solution { public: vector<int> nums; int jumpFloor(int n) { nums.resize(n+1,0); return jumpProcess(n); } int jumpProcess(int n){ if(n<=1) return 1; if(nums[n]!=0) return nums[n]; else{ nums[n]=jumpProcess(n-1)+jumpProcess(n-2); } return nums[n]; } }; */ //循环方法 class Solution { public: int jumpFloor(int n) { if(n<=1) return 1; int pre1=1,pre2=1; n=n-1; while(n>0){ int cur=pre1+pre2; pre2=pre1; pre1=cur; n--; } return pre1; } };
[ "321219693@qq.com" ]
321219693@qq.com
a36dad8bb2bdd4dfff15909d3634a8971b866b8a
485e6d219bb9da627eb76f9d95f19b74a605324a
/samples/snippets/cpp/VS_Snippets_CLR_System/system.Random.Sample/cpp/sampleex.cpp
252967f4f1fd9b497bb81dce491c47b04376b5fe
[ "MIT", "CC-BY-4.0" ]
permissive
malaterre/dotnet-api-docs
1bdfa431f0be125eb5fde1414d0c6b7d9409712a
f8f2ff2a648373c67656e1dc496541afcdc8e881
refs/heads/main
2023-08-14T23:17:45.892657
2021-10-05T03:47:30
2021-10-05T03:47:30
413,752,612
1
0
NOASSERTION
2021-10-05T09:27:38
2021-10-05T09:27:38
null
UTF-8
C++
false
false
5,841
cpp
// SampleEx.cpp : main project file. // <Snippet1> using namespace System; // This derived class converts the uniformly distributed random // numbers generated by base.Sample() to another distribution. public ref class RandomProportional : Random { // The Sample method generates a distribution proportional to the value // of the random numbers, in the range [0.0, 1.0]. protected: virtual double Sample() override { return Math::Sqrt(Random::Sample()); } public: RandomProportional() {} virtual int Next() override { return (int) (Sample() * Int32::MaxValue); } }; int main(array<System::String ^> ^args) { const int rows = 4, cols = 6; const int runCount = 1000000; const int distGroupCount = 10; const double intGroupSize = ((double) Int32::MaxValue + 1.0) / (double)distGroupCount; RandomProportional ^randObj = gcnew RandomProportional(); array<int>^ intCounts = gcnew array<int>(distGroupCount); array<int>^ realCounts = gcnew array<int>(distGroupCount); Console::WriteLine( "\nThe derived RandomProportional class overrides " + "the Sample method to \ngenerate random numbers " + "in the range [0.0, 1.0]. The distribution \nof " + "the numbers is proportional to their numeric values. " + "For example, \nnumbers are generated in the " + "vicinity of 0.75 with three times the \n" + "probability of those generated near 0.25."); Console::WriteLine( "\nRandom doubles generated with the NextDouble() " + "method:\n"); // Generate and display [rows * cols] random doubles. for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) Console::Write("{0,12:F8}", randObj->NextDouble()); Console::WriteLine(); } Console::WriteLine( "\nRandom integers generated with the Next() " + "method:\n"); // Generate and display [rows * cols] random integers. for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) Console::Write("{0,12}", randObj->Next()); Console::WriteLine(); } Console::WriteLine( "\nTo demonstrate the proportional distribution, " + "{0:N0} random \nintegers and doubles are grouped " + "into {1} equal value ranges. This \n" + "is the count of values in each range:\n", runCount, distGroupCount); Console::WriteLine( "{0,21}{1,10}{2,20}{3,10}", "Integer Range", "Count", "Double Range", "Count"); Console::WriteLine( "{0,21}{1,10}{2,20}{3,10}", "-------------", "-----", "------------", "-----"); // Generate random integers and doubles, and then count // them by group. for (int i = 0; i < runCount; i++) { intCounts[ (int)((double)randObj->Next() / intGroupSize) ]++; realCounts[ (int)(randObj->NextDouble() * (double)distGroupCount) ]++; } // Display the count of each group. for (int i = 0; i < distGroupCount; i++) Console::WriteLine( "{0,10}-{1,10}{2,10:N0}{3,12:N5}-{4,7:N5}{5,10:N0}", (int)((double)i * intGroupSize), (int)((double)(i + 1) * intGroupSize - 1.0), intCounts[ i ], ((double)i) / (double)distGroupCount, ((double)(i + 1)) / (double)distGroupCount, realCounts[ i ]); return 0; } /* This example of Random.Sample() displays output similar to the following: The derived RandomProportional class overrides the Sample method to generate random numbers in the range [0.0, 1.0). The distribution of the numbers is proportional to the number values. For example, numbers are generated in the vicinity of 0.75 with three times the probability of those generated near 0.25. Random doubles generated with the NextDouble() method: 0.59455719 0.17589882 0.83134398 0.35795862 0.91467727 0.54022658 0.93716947 0.54817519 0.94685080 0.93705478 0.18582318 0.71272428 0.77708682 0.95386216 0.70412393 0.86099417 0.08275804 0.79108316 0.71019941 0.84205103 0.41685082 0.58186880 0.89492302 0.73067715 Random integers generated with the Next() method: 1570755704 1279192549 1747627711 1705700211 1372759203 1849655615 2046235980 1210843924 1554274149 1307936697 1480207570 1057595022 337854215 844109928 2028310798 1386669369 2073517658 1291729809 1537248240 1454198019 1934863511 1640004334 2032620207 534654791 To demonstrate the proportional distribution, 1,000,000 random integers and doubles are grouped into 10 equal value ranges. This is the count of values in each range: Integer Range Count Double Range Count ------------- ----- ------------ ----- 0- 214748363 10,079 0.00000-0.10000 10,148 214748364- 429496728 29,835 0.10000-0.20000 29,849 429496729- 644245093 49,753 0.20000-0.30000 49,948 644245094- 858993458 70,325 0.30000-0.40000 69,656 858993459-1073741823 89,906 0.40000-0.50000 90,337 1073741824-1288490187 109,868 0.50000-0.60000 110,225 1288490188-1503238552 130,388 0.60000-0.70000 129,986 1503238553-1717986917 149,231 0.70000-0.80000 150,428 1717986918-1932735282 170,234 0.80000-0.90000 169,610 1932735283-2147483647 190,381 0.90000-1.00000 189,813 */ // </Snippet1>
[ "noreply@github.com" ]
noreply@github.com
299447624ecf22fad0a1ebef22f342205cdc66fb
2ba2b07343d8d72c1b1f426e77a65f9eda153aed
/srcs/AComponent.cpp
1947acfb07578c31da8483aaa16969aa768946f7
[]
no_license
jloro/GameEngine
0e894977c618ca63258473b7de1643f536367d4f
2a1498d1ee7f91052e96e7dbca8b05bddad28aac
refs/heads/master
2020-08-08T20:14:32.932173
2019-12-12T11:31:15
2019-12-12T11:31:15
213,907,306
4
0
null
null
null
null
UTF-8
C++
false
false
816
cpp
#include "AComponent.hpp" AComponent::AComponent() : _gameObj(nullptr), _transform(nullptr) { } AComponent::AComponent(GameObject *obj) : _gameObj(obj) { if (_gameObj != nullptr) { _transform = _gameObj->GetTransform(); } } AComponent::AComponent(std::shared_ptr<GameObject> obj) : _gameObj(obj.get()) { if (_gameObj != nullptr) { _transform = _gameObj->GetTransform(); } } AComponent::~AComponent() {} void AComponent::SetGameObject(GameObject *obj) { _gameObj = obj; if (_gameObj != nullptr) { _transform = _gameObj->GetTransform(); } else { _transform = nullptr; } } GameObject *AComponent::GetGameObj() const {return _gameObj;}; std::shared_ptr<Transform> AComponent::GetTransform() const {return _transform;};
[ "jloro@student.42.fr" ]
jloro@student.42.fr
1479327d46c3e208d86dde828b24c441d2d9c31c
cb56f8fe6b0fb074c4b52b834bb67866e1f9d280
/sources/Application/Persistency/Persistent.h
687b8a1070476e29533c6fe69b5fc38e00839894
[ "BSD-3-Clause" ]
permissive
djdiskmachine/LittleGPTracker
64f45a650e8211aa78fd77bc891d4316ce9a41e9
ec13c06cd07ac9dd93f7390d6464fc02010b100b
refs/heads/master
2023-07-25T22:31:15.699304
2023-02-16T21:23:18
2023-02-16T21:23:18
520,839,751
17
5
BSD-3-Clause
2023-09-12T13:59:00
2022-08-03T10:43:10
C++
UTF-8
C++
false
false
434
h
#ifndef _PERSISTENT_H_ #define _PERSISTENT_H_ #include "Foundation/Services/SubService.h" #include "Externals/TinyXML/tinyxml.h" class Persistent:SubService { public: Persistent(const char *nodeName) ; void Save(TiXmlNode *node) ; bool Restore(TiXmlElement *element) ; protected: virtual void SaveContent(TiXmlNode *node)=0 ; virtual void RestoreContent(TiXmlElement *element)=0 ; private: const char *nodeName_ ; } ; #endif
[ "marc.nostromo@gmail.com" ]
marc.nostromo@gmail.com
68bf0582acd7708c36c4fdaf63a46dc55acf061d
0656064629e6ccc853c9075b013d7a797aa0218b
/Source/FIT2097_A2/KeyItem.cpp
ff7bdde9a91fc48f91156db0ea6c664949df40d6
[]
no_license
DarryKrusher/FIT2097_A2_dlin38
d434188e6bd961d491c759e674f02f120c364c47
1dfb34a832b8b17f42b399a27c6e6fcecc3ed9a3
refs/heads/master
2020-04-04T14:30:13.777662
2018-11-03T16:35:34
2018-11-03T16:35:34
156,000,855
0
0
null
null
null
null
UTF-8
C++
false
false
484
cpp
// Fill out your copyright notice in the Description page of Project Settings. #include "KeyItem.h" #include "FIT2097_A2.h" #include "Net/UnrealNetwork.h" AKeyItem::AKeyItem() { bReplicateMovement = true; GetStaticMeshComponent()->SetSimulatePhysics(true); GetStaticMeshComponent()->SetMobility(EComponentMobility::Movable); } void AKeyItem::Tick(float DeltaTime) { Super::Tick(DeltaTime); } void AKeyItem::BeginPlay() { Super::BeginPlay(); }
[ "noreply@github.com" ]
noreply@github.com
03961089b19e3c34e087e87ac2b3fea1a9ef98b3
69e4539f98f70ba635e3e4d1623813961ea22a61
/numericStringSort/numericStringSort.cpp
2ad4a6a8b8d97053e7f05399a4254bcc5126a770
[]
no_license
hoangngv/spoj_problems
5738822443bf18f0b415cf40b8cff6248641a0aa
60a34bd10539aa80b38da33683013f655f09dce7
refs/heads/master
2021-10-27T21:05:58.618404
2019-04-19T18:47:30
2019-04-19T18:47:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
830
cpp
#include<iostream> #include<string> #include<algorithm> #include<vector> using namespace std; bool NumericSort(string a, string b) { while (a[0] == '0') { a.erase(a.begin()); } while (b[0] == '0') { b.erase(b.begin()); } int n = a.length(); int m = b.length(); if (n == m) return a < b; return n < m; } int main() { int n; cout << "Enter number of elements to be sorted Numerically\n"; cin >> n; vector<string> v(n); cout << "Enter the string of Numbers\n"; for (int i = 0; i < n; i++) { cin >> v[i]; } sort(v.begin(), v.end()); cout << "Elements sorted normally \n"; for (int i = 0; i < n; i++) { cout << v[i] << " "; } cout << "\n"; sort(v.begin(), v.end(), NumericSort); cout << "Elements sorted Numerically \n"; for (int i = 0; i < n; i++) { cout << v[i] << " "; } return 0; }
[ "nvhoang191@gmail.com" ]
nvhoang191@gmail.com
513e786581028319ca18646acf0eb022bd73a7f7
980697ff277a1c3ee9ffcb73cfcc08bcdf35a4fa
/src/schoolmips/marsohod.cpp
9b52285ee946e01e3b0dee7455e50be53f0036c3
[ "Zlib" ]
permissive
berezhko/Atanua
517d41f18aafe12ed930369a678ecaa1214ead64
8c2cf22c8bc77934105c20a44a169bd024be58a9
refs/heads/master
2021-01-10T14:13:12.974919
2020-02-24T05:56:55
2020-02-24T05:56:55
52,298,278
0
0
null
null
null
null
UTF-8
C++
false
false
1,754
cpp
#include "atanua.h" #include "marsohod.h" #include "Vmarsohod.h" #include <verilated.h> #include <vector> ChipMarsohod::ChipMarsohod() { set(0,0,4.54,2.25,"Marsohod Schoolmips process"); float xpos = 0.15 + 0.54; float ypos = 0.; for (int i = 0; i < 14; i++) { if (i == 7) { xpos = 0.15; ypos = 1.75; } mPin.push_back(&pin[i]); pin[i].set(xpos, ypos, this, pins_label[i]); xpos += 0.54; } mTexture = load_texture("data/chip_14pin.png"); chipImpl = new Vmarsohod; } void ChipMarsohod::render(int aChipId) { drawtexturedrect(mTexture,mX,mY,mW,mH,0xffffffff); fn.drawstring("Marsohod",mX+0.6,mY+0.6,0x5fffffff,0.75); } #include "checknet.h" void ChipMarsohod::update(float aTick) { CheckNet::State pinstate = CheckNet::invalid; chipImpl->CLK100MHZ = 0; chipImpl->KEY0 = 0; chipImpl->KEY1 = 0; // Check state for input pins CheckNet check; for (int i = 0; i < 3; i++) { check.add(pin[i].mNet); } pinstate = check(); if (pinstate == CheckNet::valid) { chipImpl->CLK100MHZ |= (pin[0].mNet->mState == NETSTATE_HIGH); chipImpl->KEY0 |= (pin[1].mNet->mState == NETSTATE_HIGH); chipImpl->KEY1 |= (pin[2].mNet->mState == NETSTATE_HIGH); } chipImpl->eval(); // Define state for output pins for (int i = 3; i < 14; i++) { int mask = (1 << (i-3)); int aState = gConfig.mPropagateInvalidState; if (pinstate == CheckNet::valid) { aState = (chipImpl->LED & mask) ? PINSTATE_WRITE_HIGH : PINSTATE_WRITE_LOW; } pin[i].setState(aState); } } ChipMarsohod::~ChipMarsohod() { chipImpl->final(); delete chipImpl; }
[ "ivan@berezhko.ru" ]
ivan@berezhko.ru
80b578995676c5d96cef3ac529051dd259c43894
e486e3665ae0f2ca28499c63419452039cc1ee7d
/Lesson03/Source/Lesson03/CollisionPawn.h
5fba6abc4c2c8ac0501f9a73d6f86e9065137188
[]
no_license
XiaoYuanRen/UE4_CPPStudy_Lesson03
4ab7f474634838730165650ed60ba93d23a807b4
0f04e541359ed4a585b2458016c4bdce23e9895a
refs/heads/master
2020-03-27T21:55:33.244959
2018-09-05T05:04:08
2018-09-05T05:04:08
147,187,448
0
0
null
null
null
null
UTF-8
C++
false
false
1,081
h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "GameFramework/Pawn.h" #include "RunTime/Engine/Classes/Particles/ParticleSystemComponent.h" #include "CollisionPawnMovementComponent.h" #include "CollisionPawn.generated.h" UCLASS() class LESSON03_API ACollisionPawn : public APawn { GENERATED_BODY() public: // Sets default values for this pawn's properties ACollisionPawn(); class UCollisionPawnMovementComponent* OurMovementComponent; protected: // Called when the game starts or when spawned virtual void BeginPlay() override; public: // Called every frame virtual void Tick(float DeltaTime) override; // Called to bind functionality to input virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override; UParticleSystemComponent* OurParitcleSystem; virtual UPawnMovementComponent* GetMovementComponent() const override; void MoveForward(float AxisValue); void MoveRight(float AxisValue); void Turn(float AxisValue); void ToggelFire(); };
[ "skjcul@163.com" ]
skjcul@163.com
0c24a44a36f675a5c130c23ff59a4706d2437dcd
0430e85ce07c949486c69034ab68cf8882670e87
/SimplePT2.cpp
3f84c9b359a84436eb714f735d84899c687166b2
[]
no_license
jeremyparnell95/Monte-Carlo-Integration-and-Path-Tracing
9288e2dee93ae90a3474590b428482a114c0b936
72b1ab4f88abf757b8d34763fd1450dbd734b9b3
refs/heads/master
2020-04-12T16:56:31.022762
2018-12-20T20:40:40
2018-12-20T20:40:40
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,471
cpp
#include <stdio.h> #include <stdlib.h> #include <cmath> #include <random> #include <vector> #include <omp.h> #define PI 3.1415926535897932384626433832795 //Hoang Nguyen - 86865361 //Jeremy Parnell - /* * Thread-safe random number generator */ struct RNG { RNG() : distrb(0.0, 1.0), engines() {} void init(int nworkers) { engines.resize(nworkers); #if 0 std::random_device rd; for ( int i = 0; i < nworkers; ++i ) engines[i].seed(rd()); #else std::seed_seq seq{ 1234 }; std::vector<std::uint32_t> seeds(nworkers); seq.generate(seeds.begin(), seeds.end()); for ( int i = 0; i < nworkers; ++i ) engines[i].seed(seeds[i]); #endif } double operator()() { int id = omp_get_thread_num(); return distrb(engines[id]); } std::uniform_real_distribution<double> distrb; std::vector<std::mt19937> engines; } rng; /* * Basic data types */ struct Vec { double x, y, z; Vec(double x_ = 0, double y_ = 0, double z_ = 0) { x = x_; y = y_; z = z_; } Vec operator+ (const Vec &b) const { return Vec(x+b.x, y+b.y, z+b.z); } Vec operator- (const Vec &b) const { return Vec(x-b.x, y-b.y, z-b.z); } Vec operator* (double b) const { return Vec(x*b, y*b, z*b); } Vec mult(const Vec &b) const { return Vec(x*b.x, y*b.y, z*b.z); } Vec& normalize() { return *this = *this * (1.0/std::sqrt(x*x+y*y+z*z)); } double dot(const Vec &b) const { return x*b.x+y*b.y+z*b.z; } Vec cross(const Vec&b) const { return Vec(y*b.z-z*b.y, z*b.x-x*b.z, x*b.y-y*b.x); } }; struct Ray { Vec o, d; Ray(Vec o_, Vec d_) : o(o_), d(d_) {} }; struct BRDF { virtual Vec eval(const Vec &n, const Vec &o, const Vec &i) const = 0; virtual void sample(const Vec &n, const Vec &o, Vec &i, double &pdf) const = 0; virtual bool isSpecular() const = 0; }; /* * Utility functions */ inline double clamp(double x) { return x < 0 ? 0 : x > 1 ? 1 : x; } inline int toInt(double x) { return static_cast<int>(std::pow(clamp(x), 1.0/2.2)*255+.5); } /* * Shapes */ struct Sphere { Vec p, e; // position, emitted radiance double rad; // radius const BRDF &brdf; // BRDF Sphere(double rad_, Vec p_, Vec e_, const BRDF &brdf_) : rad(rad_), p(p_), e(e_), brdf(brdf_) {} double intersect(const Ray &r) const { // returns distance, 0 if nohit Vec op = p-r.o; // Solve t^2*d.d + 2*t*(o-p).d + (o-p).(o-p)-R^2 = 0 double t, eps = 1e-4, b = op.dot(r.d), det = b*b-op.dot(op)+rad*rad; if ( det<0 ) return 0; else det = sqrt(det); return (t = b-det)>eps ? t : ((t = b+det)>eps ? t : 0); } }; /* * Sampling functions */ inline void createLocalCoord(const Vec &n, Vec &u, Vec &v, Vec &w) { w = n; u = ((std::abs(w.x)>.1 ? Vec(0, 1) : Vec(1)).cross(w)).normalize(); v = w.cross(u); } /* * Uniform Random PSA Function */ Vec uniRandomPSA(const Vec &n) { double z, r, phi, x, y; Vec u, v, w; z = sqrt(rng()); r = sqrt(1.0 - z * z); phi = 2.0 * PI * rng(); x = r * cos(phi); y = r * sin(phi); createLocalCoord(n, u, v, w); return u*x + v*y + w*z; } /* * BRDFs */ // Ideal diffuse BRDF struct DiffuseBRDF : public BRDF { DiffuseBRDF(Vec kd_) : kd(kd_) {} Vec eval(const Vec &n, const Vec &o, const Vec &i) const { return kd * (1.0/PI); } void sample(const Vec &n, const Vec &o, Vec &i, double &pdf) const { i = uniRandomPSA(n); pdf = i.dot(n) / PI; } bool isSpecular() const { return false; } Vec kd; }; // Ideal Specular BRDF struct SpecularBRDF: public BRDF { SpecularBRDF(Vec ks_) : ks(ks_) {} Vec eval(const Vec &n, const Vec &o, const Vec &i) const { Vec temp = n * 2.0 * n.dot(o) - o; if (i.x == temp.x and i.y == temp.y and i.z == temp.z){ return ks * (1/n.dot(i)); } else{ return Vec(0.0, 0.0, 0.0); } } void sample(const Vec &n, const Vec &o, Vec &i, double &pdf) const { i = n * 2.0 * n.dot(o) - o; pdf = 1.0; } bool isSpecular() const { return true; } Vec ks; }; void luminaireSample(const Sphere &obj, Vec &n, Vec &y1, double &pdf){ double lam1 = rng(); double lam2 = rng(); double z = 2.0 * lam1 - 1.0; double x = sqrt(1.0 - pow(z,2)) * cos(2.0 * PI * lam2); double y = sqrt(1.0 - pow(z,2)) * sin(2.0 * PI * lam2); n = Vec(x,y,z).normalize(); y1 = n * obj.rad + obj.p; pdf = 1 / (4 * PI * pow(obj.rad,2)); } /* * Scene configuration */ // Pre-defined BRDFs const DiffuseBRDF leftWall(Vec(.75,.25,.25)), rightWall(Vec(.25,.25,.75)), otherWall(Vec(.75,.75,.75)), blackSurf(Vec(0.0,0.0,0.0)), brightSurf(Vec(0.9,0.9,0.9)); const SpecularBRDF mirrorSurf(Vec(0.999,0.999,0.999)); // Scene: list of spheres const Sphere spheres[] = { Sphere(1e5, Vec(1e5+1,40.8,81.6), Vec(), leftWall), // Left Sphere(1e5, Vec(-1e5+99,40.8,81.6), Vec(), rightWall), // Right Sphere(1e5, Vec(50,40.8, 1e5), Vec(), otherWall), // Back Sphere(1e5, Vec(50, 1e5, 81.6), Vec(), otherWall), // Bottom Sphere(1e5, Vec(50,-1e5+81.6,81.6), Vec(), otherWall), // Top Sphere(16.5, Vec(27,16.5,47), Vec(), brightSurf), // Ball 1 Sphere(16.5, Vec(73,16.5,78), Vec(), mirrorSurf), // Ball 2 Sphere(5.0, Vec(50,70.0,81.6), Vec(50,50,50), blackSurf) // Light }; // Camera position & direction const Ray cam(Vec(50, 52, 295.6), Vec(0, -0.042612, -1).normalize()); /* * Global functions */ bool intersect(const Ray &r, double &t, int &id) { double n = sizeof(spheres)/sizeof(Sphere), d, inf = t = 1e20; for ( int i = int(n); i--;) if ( (d = spheres[i].intersect(r))&&d<t ) { t = d; id = i; } return t<inf; } Vec reflectedRadiance(const Ray &r, int depth) { double t; // Distance to intersection int id = 0; // id of intersected sphere if ( !intersect(r, t, id) ) return Vec(); // if miss, return black const Sphere &obj = spheres[id]; // the hit object Vec x = r.o + r.d*t; // The intersection point Vec o = (Vec() - r.d).normalize(); // The outgoing direction (= -r.d) Vec nx = (x - obj.p).normalize(); // The normal direction if ( nx.dot(o) < 0 ) nx = nx*-1.0; const BRDF &brdf = obj.brdf; // Surface BRDF at x //Calculating Direct Radiance const Sphere &obj1 = spheres[7]; Vec y1, ny, w1, neg_w1; double pdf1, r2, vis = 0.0; luminaireSample(obj1, ny, y1, pdf1); w1 = (y1 - x).normalize(); neg_w1 = Vec(-w1.x, -w1.y, -w1.z); r2 = (y1-x).dot(y1-x); int id1 = 0, id2 = 0, temp, temp1; Ray int_x(x, w1); Ray int_y(y1, neg_w1); temp = intersect(int_x, t, id1); temp1 = intersect(int_y, t, id2); if (id1 == 7 and id2 == id and temp == 1 and temp1 == 1) { vis = 1.0; } Vec Le = obj1.e; Vec reflRad = Le.mult(brdf.eval(x, o, w1)) * vis * nx.dot(w1) * ny.dot(neg_w1) * (1.0 / (r2*pdf1)); //Calculating Indirect Radiance int rrDepth = 5; double survivalProb = 0.9, p, pdf2; Vec w2; if (depth <= rrDepth) { p = 1.0; } else { p = survivalProb; } if (rng() < p) { brdf.sample(nx, o, w2, pdf2); Ray y2(x, w2); reflRad = reflRad + (reflectedRadiance(y2, depth+1).mult(brdf.eval(nx, o, w2))) * (nx.dot(w2) * (1.0 / (pdf2*p))); } return reflRad; } /* * KEY FUNCTION: radiance estimator */ Vec receivedRadiance(const Ray &r, int depth, bool flag) { double t; // Distance to intersection int id = 0; // id of intersected sphere if ( !intersect(r, t, id) ) return Vec(); // if miss, return black const Sphere &obj = spheres[id]; // the hit object Vec x = r.o + r.d*t; // The intersection point Vec o = (Vec() - r.d).normalize(); // The outgoing direction (= -r.d) Vec n = (x - obj.p).normalize(); // The normal direction if ( n.dot(o) < 0 ) n = n*-1.0; Vec Le = obj.e; // Emitted radiance const BRDF &brdf = obj.brdf; // Surface BRDF at x if (obj.brdf.isSpecular()) { int rrDepth = 5; double survivalProb = 0.9, p; if (depth <= rrDepth) { p = 1.0; } else { p = survivalProb; } double pdf; if (rng() < p) { Vec i = uniRandomPSA(n); brdf.sample(n,o,i,pdf); Ray y(x, i); Le = Le + receivedRadiance(y, depth+1, flag).mult(brdf.eval(n,o,i)) * (n.dot(i) / (pdf*p)); } return Le; } else { Le = Le + reflectedRadiance(r, depth); return Le; } } /* * Main function (do not modify) */ int main(int argc, char *argv[]) { int nworkers = omp_get_num_procs(); omp_set_num_threads(nworkers); rng.init(nworkers); int w = 480, h = 360, samps = argc==2 ? atoi(argv[1])/4 : 1; // # samples Vec cx = Vec(w*.5135/h), cy = (cx.cross(cam.d)).normalize()*.5135; std::vector<Vec> c(w*h); #pragma omp parallel for schedule(dynamic, 1) for ( int y = 0; y < h; y++ ) { for ( int x = 0; x < w; x++ ) { const int i = (h - y - 1)*w + x; for ( int sy = 0; sy < 2; ++sy ) { for ( int sx = 0; sx < 2; ++sx ) { Vec r; for ( int s = 0; s<samps; s++ ) { double r1 = 2*rng(), dx = r1<1 ? sqrt(r1)-1 : 1-sqrt(2-r1); double r2 = 2*rng(), dy = r2<1 ? sqrt(r2)-1 : 1-sqrt(2-r2); Vec d = cx*(((sx+.5 + dx)/2 + x)/w - .5) + cy*(((sy+.5 + dy)/2 + y)/h - .5) + cam.d; r = r + receivedRadiance(Ray(cam.o, d.normalize()), 1, true)*(1./samps); } c[i] = c[i] + Vec(clamp(r.x), clamp(r.y), clamp(r.z))*.25; } } } #pragma omp critical fprintf(stderr,"\rRendering (%d spp) %6.2f%%",samps*4,100.*y/(h-1)); } fprintf(stderr, "\n"); // Write resulting image to a PPM file FILE *f = fopen("image.ppm", "w"); fprintf(f, "P3\n%d %d\n%d\n", w, h, 255); for ( int i = 0; i<w*h; i++ ) fprintf(f, "%d %d %d ", toInt(c[i].x), toInt(c[i].y), toInt(c[i].z)); fclose(f); return 0; }
[ "jeremyparnell95@gmail.com" ]
jeremyparnell95@gmail.com
a5b52e9d958cfe8c929c0618d57d9a57139cdff2
0a0979e48e32134daecd22937a45b53095f94392
/utils/constant.h
b58450fafcbc90ce218234d0e47c9aac2fe2b201
[]
no_license
ituncle/MyServer
0533d3d76c4f30820e5308301245b4e27d76a759
8500ed06d7dea9b51f8d72c72e27a581408b24d8
refs/heads/master
2020-04-02T23:17:37.498081
2016-06-06T03:38:14
2016-06-06T03:38:14
60,492,896
1
0
null
null
null
null
UTF-8
C++
false
false
598
h
/* * Constant.h * * Created on: Mar 28, 2016 * Author: kingTang */ #ifndef UTILS_CONSTANT_H_ #define UTILS_CONSTANT_H_ namespace ft { namespace utils { class MAX_BITS { public: /** * 整形/短整形以字符串出现时其字符数 * 注:不同进制,其字符数不一样 */ enum { INT_HEX = 8, //十六进制 INT_DECIMAL = 11, //十进制 INT_BINARY = 32, //二进制 SHORT_HEX = 4, //十六进制 SHORT_DECIMAL = 6, //十进制 SHORT_BINARY = 16, //二进制 } ; }; } } #endif /* UTILS_CONSTANT_H_ */
[ "wucqf@foxmail.com" ]
wucqf@foxmail.com
4d8934609870f683995c36bd8be4b2ff3669b068
faedf096135c178c72c2741fc08855bfee97b778
/Weekly_Contest/235/5722. Truncate Sentence.cpp
4a95abbddb0590555947026b876c780110c5357e
[]
no_license
dk-17/LeetCode-Contest
c87b66299b66da0e118042040c5df471f28b8b2c
ee1a77d08bd641612e36788cba5dec182c32e61d
refs/heads/main
2023-07-08T18:29:22.305823
2021-08-17T12:08:46
2021-08-17T12:08:46
342,332,812
0
0
null
null
null
null
UTF-8
C++
false
false
309
cpp
class Solution { public: string truncateSentence(string s, int k) { int count = 0; string ans = ""; for(int i = 0; i< s.length(); i++){ if(isspace(s[i])) count++; if(count == k) break; ans+=s[i]; } return ans; } };
[ "noreply@github.com" ]
noreply@github.com
e43d0a5cb98418498b3da76adb6ba8012f74a0fb
2f6d60ccba1e5b62de9f828ebcd77bc7997cee66
/include.cpp
64f579efac5598d7dbe2729cd88a44588f4aafc2
[ "MIT" ]
permissive
triztian/mobilecpp
6dd67c0e83015142f875caa07d1c33ace0075731
0b4d31de8724f43488768c9f12453afac8b35216
refs/heads/master
2020-06-18T11:12:36.490249
2019-07-11T02:06:29
2019-07-11T02:06:29
196,284,056
0
0
null
null
null
null
UTF-8
C++
false
false
22
cpp
#include <exception>
[ "tristiana@4thdown.co" ]
tristiana@4thdown.co
004cd75b2138eb969fd06b299f6aa4c47c6cc2c9
bf032a886be90735d5d57797c1f43cfa0615407d
/src/Log.h
3402db4fcd9b753cce55d43d88b65e350b8101f4
[]
no_license
rucoder/modbusd
ef56d4dc5d4a3f8494df78052f46a8ff944b9b93
9b1371dc7afe574945fa75a91967803d2af4481b
refs/heads/master
2021-01-10T19:10:08.085045
2013-11-14T13:28:33
2013-11-14T13:28:33
10,158,479
0
2
null
null
null
null
UTF-8
C++
false
false
365
h
/* * Log.h * * Created on: May 16, 2013 * Author: ruinmmal */ #ifndef LOG_H_ #define LOG_H_ #include "DaemonProcess.h" void LogInit(std::string filename); int GetLogFd(); void Log(std::string format, ...); extern void LogFatal(std::string format, ...); void SetLogContext(EExecutionContext context); void LogRedirect(FILE **pfp); #endif /* LOG_H_ */
[ "Miha.Malyshev@yandex.ru" ]
Miha.Malyshev@yandex.ru
fa8ce3141b218547efd2a4216a24b078ee92d1b0
fb5f2c8927d773c4fdda06aefd1021923950b6d4
/Lesson8_Arrays/Lesson8_Arrays/stdafx.cpp
94ef5f4d8eb90abcc6a8a0dce0991b2f26c73c33
[]
no_license
pocketform/ProgramStudy
19007cba9589ed6514b3bf2e00307f9e3f88a2d4
44f2dcebba575bc7d53ac2e839e4eefd192ac158
refs/heads/master
2020-07-20T09:46:30.362825
2016-11-14T21:15:21
2016-11-14T21:15:21
73,747,568
0
0
null
null
null
null
UTF-8
C++
false
false
293
cpp
// stdafx.cpp : source file that includes just the standard includes // Lesson8_Arrays.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h" // TODO: reference any additional headers you need in STDAFX.H // and not in this file
[ "pocketform@gmail.com" ]
pocketform@gmail.com
c6c446cbb1b6a74d1ea20808f5a5f854ddfd57a0
b24f625afaade9bb74aae263226ff600d7c3e818
/L5_Application/gps.hpp
530c6aaee85335a94a92e3e7c16d3b0d94528092
[]
no_license
ankit4970/project_wifitrack
e6d9f037d3b21156a6c426943a5f7f0526061899
9623c4f80a98182da6b21f186936be08c8d3fc6d
refs/heads/master
2016-09-13T05:29:35.535509
2016-05-23T17:30:15
2016-05-23T17:30:15
57,782,673
1
0
null
null
null
null
UTF-8
C++
false
false
5,509
hpp
/* * gps.hpp * * Created on: Apr 19, 2016 * Author: ankit */ #ifndef L5_APPLICATION_GPS_HPP_ #define L5_APPLICATION_GPS_HPP_ /** * Acceleration Sensor class used to get acceleration data reading from the on-board sensor. * Acceleration data reading can provide absolute tilt of the board (if under no movement), * and it can also provide the movement activity of the board. * * @ingroup BoardIO */ #include <io.hpp> #include "utilities.h" #include "uart2.hpp" #include "common.hpp" #define FONA_HEADSETAUDIO 0 #define FONA_EXTAUDIO 1 #define FONA_STTONE_DIALTONE 1 #define FONA_STTONE_BUSY 2 #define FONA_STTONE_CONGESTION 3 #define FONA_STTONE_PATHACK 4 #define FONA_STTONE_DROPPED 5 #define FONA_STTONE_ERROR 6 #define FONA_STTONE_CALLWAIT 7 #define FONA_STTONE_RINGING 8 #define FONA_STTONE_BEEP 16 #define FONA_STTONE_POSTONE 17 #define FONA_STTONE_ERRTONE 18 #define FONA_STTONE_INDIANDIALTONE 19 #define FONA_STTONE_USADIALTONE 20 #define SIM808_DEFAULT_TIMEOUT_MS (0xFFFFFFFFUL) #define FONA_HTTP_GET 0 #define FONA_HTTP_POST 1 #define FONA_HTTP_HEAD 2 #define FONA_CALL_READY 0 #define FONA_CALL_FAILED 1 #define FONA_CALL_UNKNOWN 2 #define FONA_CALL_RINGING 3 #define FONA_CALL_INPROGRESS 4 /* Accepted Error baud rate value (in percent unit) */ #define UART_ACCEPTED_BAUDRATE_ERROR (3) /*!< Acceptable UART baudrate error */ /*********************************************************************//** * Macro defines for Macro defines for UART line control register **********************************************************************/ #define UART_LCR_WLEN5 ((uint8_t)(0)) /*!< UART 5 bit data mode */ #define UART_LCR_WLEN6 ((uint8_t)(1<<0)) /*!< UART 6 bit data mode */ #define UART_LCR_WLEN7 ((uint8_t)(2<<0)) /*!< UART 7 bit data mode */ #define UART_LCR_WLEN8 ((uint8_t)(3<<0)) /*!< UART 8 bit data mode */ #define UART_LCR_STOPBIT_SEL ((uint8_t)(1<<2)) /*!< UART Two Stop Bits Select */ #define UART_LCR_PARITY_EN ((uint8_t)(1<<3)) /*!< UART Parity Enable */ #define UART_LCR_PARITY_ODD ((uint8_t)(0)) /*!< UART Odd Parity Select */ #define UART_LCR_PARITY_EVEN ((uint8_t)(1<<4)) /*!< UART Even Parity Select */ #define UART_LCR_PARITY_F_1 ((uint8_t)(2<<4)) /*!< UART force 1 stick parity */ #define UART_LCR_PARITY_F_0 ((uint8_t)(3<<4)) /*!< UART force 0 stick parity */ #define UART_LCR_BREAK_EN ((uint8_t)(1<<6)) /*!< UART Transmission Break enable */ #define UART_LCR_DLAB_EN ((uint8_t)(1<<7)) /*!< UART Divisor Latches Access bit enable */ #define UART_LCR_BITMASK ((uint8_t)(0xFF)) /*!< UART line control bit mask */ /*********************************************************************//** * Macro defines for Macro defines for UARTn Divisor Latch MSB register **********************************************************************/ #define UART_DLM_MASKBIT ((uint8_t)0xFF) /*!< Divisor latch MSB bit mask */ #define UART_LOAD_DLM(div) (((div) >> 8) & 0xFF) /**< Macro for loading most significant halfs of divisors */ /*********************************************************************//** * Macro defines for Macro defines for UARTn Divisor Latch LSB register **********************************************************************/ #define UART_LOAD_DLL(div) ((div) & 0xFF) /**< Macro for loading least significant halfs of divisors */ #define UART_DLL_MASKBIT ((uint8_t)0xFF) /*!< Divisor latch LSB bit mask */ /*********************************************************************//** * Macro defines for Macro defines for UART Fractional divider register **********************************************************************/ #define UART_FDR_DIVADDVAL(n) ((uint32_t)(n&0x0F)) /**< Baud-rate generation pre-scaler divisor */ #define UART_FDR_MULVAL(n) ((uint32_t)((n<<4)&0xF0)) /**< Baud-rate pre-scaler multiplier value */ #define UART_FDR_BITMASK ((uint32_t)(0xFF)) /**< UART Fractional Divider register bit mask */ /* --------------------- BIT DEFINITIONS -------------------------------------- */ #define GPS_RESET_PIN 0 class sim808_gps : public SingletonTemplate<sim808_gps> { public: bool sim808_gpsInit(LPC_UART_TypeDef *UARTx,uint32_t baudrate); bool enableGPS(bool onoff); bool getGPS(senseordata *sensor); bool sim808_parseReply(int8_t *toreply,uint16_t *v, int8_t divider, uint8_t index); bool sim808_sendCheckReply(int8_t *send, int8_t *reply); bool sendParseReply(int8_t * tosend,int8_t* toreply,uint16_t *v, int8_t divider= ',', uint8_t index=0); void sim808_putch(uint8_t data); void sim808_flushin(); uint8_t sim808_getReply(int8_t *send,bool multiline = false); uint32_t sim808_send(int8_t *txbuf); uint8_t sim808_getch(); bool changeBaudRate(uint32_t baudRate); void sim808_reset(LPC_GPIO_TypeDef *GPIOx,uint8_t pinNumber); uint8_t gps_uartReceive( uint8_t *rxbuf, uint32_t buflen,TRANSFER_BLOCK_Type flag, bool multiline = false); QueueHandle_t gpsTxQueue = NULL; ///< Queue for UARTs transmit buffer private: sim808_gps() ///< Private constructor of this Singleton class { } friend class SingletonTemplate<sim808_gps>; ///< Friend class used for Singleton Template uint8_t replybuffer[MAX_BUFFER_SIZE]={0}; volatile uint32_t UART3RxQueueWritePos = 0; LPC_UART_TypeDef* mUARTx = NULL; }; #endif /* L5_APPLICATION_GPS_HPP_ */
[ "ankit4970@gmail.com" ]
ankit4970@gmail.com
eb2cee925dd05e2ce0e475fd2505e1eafeada67f
f7d38c41804931f27a2d128163fec27460343467
/ext/libexecstream/exec-stream.cpp
211d8b7437a5fac1a3ab0e1641a8a6c9eb4fe2b2
[ "BSD-3-Clause", "DOC" ]
permissive
CSM-Offenburg/cantera
779993eefae349db678fb1f229419da535e3b959
7d87534bb7ef0a55bca2ab3dc4282a2ae7ddd8d5
refs/heads/master
2021-05-23T03:57:16.376671
2020-04-19T08:43:29
2020-05-02T23:50:31
60,643,860
2
2
NOASSERTION
2018-11-12T18:45:56
2016-06-07T20:22:51
C++
UTF-8
C++
false
false
11,298
cpp
/* Copyright (C) 2004 Artem Khodush Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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 "exec-stream.h" #include <list> #include <vector> #include <algorithm> #include <exception> #ifdef _WIN32 #define NOMINMAX #include <windows.h> #define HELPERS_H "win/exec-stream-helpers.h" #define HELPERS_CPP "win/exec-stream-helpers.cpp" #define IMPL_CPP "win/exec-stream-impl.cpp" #else #include <errno.h> #include <string.h> #include <unistd.h> #include <fcntl.h> #include <signal.h> #include <sys/time.h> #include <sys/types.h> #include <sys/wait.h> #include <pthread.h> #define HELPERS_H "posix/exec-stream-helpers.h" #define HELPERS_CPP "posix/exec-stream-helpers.cpp" #define IMPL_CPP "posix/exec-stream-impl.cpp" #endif // helper classes namespace exec_stream_internal { class buffer_list_t { public: struct buffer_t { std::size_t size; char * data; }; buffer_list_t(); ~buffer_list_t(); void get( char * dst, std::size_t & size ); void get_translate_crlf( char * dst, std::size_t & size ); void put( char * const src, std::size_t size ); void put_translate_crlf( char * const src, std::size_t size ); buffer_t detach(); bool empty(); bool full( std::size_t limit ); // limit==0 -> no limit void clear(); private: typedef std::list< buffer_t > buffers_t; buffers_t m_buffers; std::size_t m_read_offset; // offset into the first buffer std::size_t m_total_size; }; buffer_list_t::buffer_list_t() { m_total_size=0; m_read_offset=0; } buffer_list_t::~buffer_list_t() { clear(); } void buffer_list_t::get( char * dst, std::size_t & size ) { std::size_t written_size=0; while( size>0 && m_total_size>0 ) { std::size_t portion_size=std::min( size, m_buffers.front().size-m_read_offset ); std::char_traits< char >::copy( dst, m_buffers.front().data+m_read_offset, portion_size ); dst+=portion_size; size-=portion_size; m_total_size-=portion_size; m_read_offset+=portion_size; written_size+=portion_size; if( m_read_offset==m_buffers.front().size ) { delete[] m_buffers.front().data; m_buffers.pop_front(); m_read_offset=0; } } size=written_size; } void buffer_list_t::get_translate_crlf( char * dst, std::size_t & size ) { std::size_t written_size=0; while( written_size!=size && m_total_size>0 ) { while( written_size!=size && m_read_offset!=m_buffers.front().size ) { char c=m_buffers.front().data[m_read_offset]; if( c!='\r' ) { // MISFEATURE: single \r in the buffer will cause end of file *dst++=c; ++written_size; } --m_total_size; ++m_read_offset; } if( m_read_offset==m_buffers.front().size ) { delete[] m_buffers.front().data; m_buffers.pop_front(); m_read_offset=0; } } size=written_size; } void buffer_list_t::put( char * const src, std::size_t size ) { buffer_t buffer; buffer.data=new char[size]; buffer.size=size; std::char_traits< char >::copy( buffer.data, src, size ); m_buffers.push_back( buffer ); m_total_size+=buffer.size; } void buffer_list_t::put_translate_crlf( char * const src, std::size_t size ) { char const * p=src; std::size_t lf_count=0; while( p!=src+size ) { if( *p=='\n' ) { ++lf_count; } ++p; } buffer_t buffer; buffer.data=new char[size+lf_count]; buffer.size=size+lf_count; p=src; char * dst=buffer.data; while( p!=src+size ) { if( *p=='\n' ) { *dst++='\r'; } *dst++=*p; ++p; } m_buffers.push_back( buffer ); m_total_size+=buffer.size; } buffer_list_t::buffer_t buffer_list_t::detach() { buffer_t buffer=m_buffers.front(); m_buffers.pop_front(); m_total_size-=buffer.size; return buffer; } bool buffer_list_t::empty() { return m_total_size==0; } bool buffer_list_t::full( std::size_t limit ) { return limit!=0 && m_total_size>=limit; } void buffer_list_t::clear() { for( buffers_t::iterator i=m_buffers.begin(); i!=m_buffers.end(); ++i ) { delete[] i->data; } m_buffers.clear(); m_read_offset=0; m_total_size=0; } } // platform-dependent helpers namespace exec_stream_internal { #include HELPERS_H #include HELPERS_CPP } // stream buffer class namespace exec_stream_internal { class exec_stream_buffer_t : public std::streambuf { public: exec_stream_buffer_t( exec_stream_t::stream_kind_t kind, thread_buffer_t & thread_buffer ); virtual ~exec_stream_buffer_t(); void clear(); protected: virtual int_type underflow(); virtual int_type overflow( int_type c ); virtual int sync(); private: bool send_buffer(); bool send_char( char c ); exec_stream_t::stream_kind_t m_kind; thread_buffer_t & m_thread_buffer; char * m_stream_buffer; }; const std::size_t STREAM_BUFFER_SIZE=4096; exec_stream_buffer_t::exec_stream_buffer_t( exec_stream_t::stream_kind_t kind, thread_buffer_t & thread_buffer ) : m_kind( kind ), m_thread_buffer( thread_buffer ) { m_stream_buffer=new char[STREAM_BUFFER_SIZE]; clear(); } exec_stream_buffer_t::~exec_stream_buffer_t() { delete[] m_stream_buffer; } void exec_stream_buffer_t::clear() { if( m_kind==exec_stream_t::s_in ) { setp( m_stream_buffer, m_stream_buffer+STREAM_BUFFER_SIZE ); }else { setg( m_stream_buffer, m_stream_buffer+STREAM_BUFFER_SIZE, m_stream_buffer+STREAM_BUFFER_SIZE ); } } exec_stream_buffer_t::int_type exec_stream_buffer_t::underflow() { if( gptr()==egptr() ) { std::size_t read_size=STREAM_BUFFER_SIZE; bool no_more = true; m_thread_buffer.get( m_kind, m_stream_buffer, read_size, no_more ); if( no_more || read_size==0 ) { // there is no way for underflow to return something other than eof when 0 bytes are read return traits_type::eof(); }else { setg( m_stream_buffer, m_stream_buffer, m_stream_buffer+read_size ); } } return traits_type::to_int_type( *eback() ); } bool exec_stream_buffer_t::send_buffer() { if( pbase()!=pptr() ) { std::size_t write_size=pptr()-pbase(); std::size_t n=write_size; bool no_more; m_thread_buffer.put( pbase(), n, no_more ); if( no_more || n!=write_size ) { return false; }else { setp( m_stream_buffer, m_stream_buffer+STREAM_BUFFER_SIZE ); } } return true; } bool exec_stream_buffer_t::send_char( char c ) { std::size_t write_size=1; bool no_more; m_thread_buffer.put( &c, write_size, no_more ); return write_size==1 && !no_more; } exec_stream_buffer_t::int_type exec_stream_buffer_t::overflow( exec_stream_buffer_t::int_type c ) { if( !send_buffer() ) { return traits_type::eof(); } if( c!=traits_type::eof() ) { if( pbase()==epptr() ) { if( !send_char( static_cast<char>(c) ) ) { return traits_type::eof(); } }else { sputc( static_cast<char>(c) ); } } return traits_type::not_eof( c ); } int exec_stream_buffer_t::sync() { if( !send_buffer() ) { return -1; } return 0; } // stream classes class exec_istream_t : public std::istream { public: exec_istream_t( exec_stream_buffer_t & buf ) : std::istream( &buf ) { } }; class exec_ostream_t : public std::ostream { public: exec_ostream_t( exec_stream_buffer_t & buf ) : std::ostream( &buf ){ } }; } // platform-dependent implementation #include IMPL_CPP //platform-independent exec_stream_t member functions exec_stream_t::exec_stream_t() { m_impl=new impl_t; exceptions( true ); } exec_stream_t::exec_stream_t( std::string const & program, std::string const & arguments ) { m_impl=new impl_t; exceptions( true ); start( program, arguments ); } void exec_stream_t::new_impl() { m_impl=new impl_t; } exec_stream_t::~exec_stream_t() { try { close(); }catch( ... ) { } delete m_impl; } std::ostream & exec_stream_t::in() { return m_impl->m_in; } std::istream & exec_stream_t::out() { return m_impl->m_out; } std::istream & exec_stream_t::err() { return m_impl->m_err; } void exec_stream_t::exceptions( bool enable ) { if( enable ) { // getline sets failbit on eof, so we should enable badbit and badbit _only_ to propagate our exceptions through iostream code. m_impl->m_in.exceptions( std::ios_base::badbit ); m_impl->m_out.exceptions( std::ios_base::badbit ); m_impl->m_err.exceptions( std::ios_base::badbit ); }else { m_impl->m_in.exceptions( std::ios_base::goodbit ); m_impl->m_out.exceptions( std::ios_base::goodbit ); m_impl->m_err.exceptions( std::ios_base::goodbit ); } } // exec_stream_t::error_t namespace exec_stream_internal { std::string int2str( unsigned long i, int base, std::size_t width ) { std::string s; s.reserve(4); while( i!=0 ) { s="0123456789abcdef"[i%base]+s; i/=base; } if( width!=0 ) { while( s.size()<width ) { s="0"+s; } } return s; } } exec_stream_t::error_t::error_t() { } exec_stream_t::error_t::error_t( std::string const & msg ) { m_msg=msg; } exec_stream_t::error_t::error_t( std::string const & msg, error_code_t code ) { compose( msg, code ); } exec_stream_t::error_t::~error_t() throw() { } char const * exec_stream_t::error_t::what() const throw() { return m_msg.c_str(); } void exec_stream_t::error_t::compose( std::string const & msg, error_code_t code ) { m_msg=msg; m_msg+="\n[code 0x"+int2str( code, 16, 4 )+" ("+int2str( code, 10, 0 )+")]"; }
[ "speth@mit.edu" ]
speth@mit.edu
5b01518f28909e8b1fc4caecba07e7508ac22903
d088041add785e8a7a652cb94e75ccc60348e7aa
/generic-pc/video_priv.h
067d9b5f888687cfbb516d71772891808fa063f4
[]
no_license
neutrino-mp/libstb-hal
d768623b9de719a24b92ba5fe48eafee12085102
b1f5e8046267d1f5463211cc2151487b6aa9cbef
refs/heads/master
2020-04-10T21:26:24.352882
2017-12-25T12:39:05
2017-12-25T12:39:05
31,829,411
1
6
null
2017-11-03T10:31:52
2015-03-07T22:12:16
C++
UTF-8
C++
false
false
2,928
h
/* Copyright 2013 Stefan Seyfried <seife@tuxboxcvs.slipkontur.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, see <http://www.gnu.org/licenses/>. */ #ifndef __vdec__ #include <OpenThreads/Thread> #include <OpenThreads/Mutex> #include "video_hal.h" extern "C" { #include <libavutil/rational.h> } #define VDEC_MAXBUFS 0x40 class VDec : public OpenThreads::Thread { friend class GLFbPC; friend class cDemux; friend class cVideo; private: /* called from GL thread */ class SWFramebuffer : public std::vector<unsigned char> { public: SWFramebuffer() : mWidth(0), mHeight(0) {} void width(int w) { mWidth = w; } void height(int h) { mHeight = h; } void pts(uint64_t p) { mPts = p; } void AR(AVRational a) { mAR = a; } int width() const { return mWidth; } int height() const { return mHeight; } int64_t pts() const { return mPts; } AVRational AR() const { return mAR; } private: int mWidth; int mHeight; int64_t mPts; AVRational mAR; }; int buf_in, buf_out, buf_num; public: /* constructor & destructor */ VDec(void); ~VDec(void); /* aspect ratio */ int getAspectRatio(void); int setAspectRatio(int aspect, int mode); void getPictureInfo(int &width, int &height, int &rate); #if 0 /* cropping mode */ int setCroppingMode(int x = 0 /*vidDispMode_t x = VID_DISPMODE_NORM*/); /* get play state */ int getPlayState(void); /* blank on freeze */ int getBlank(void); int setBlank(int enable); #endif int GetVideoSystem(); int SetVideoSystem(int system); /* change video play state. Parameters are all unused. */ int Start(); int Stop(bool blank = true); int SetStreamType(VIDEO_FORMAT type); void ShowPicture(const char * fname); void Pig(int x, int y, int w, int h); bool GetScreenImage(unsigned char * &data, int &xres, int &yres, bool get_video = true, bool get_osd = false, bool scale_to_video = false); SWFramebuffer *getDecBuf(void); int64_t GetPTS(void); private: void run(); SWFramebuffer buffers[VDEC_MAXBUFS]; int dec_w, dec_h; int dec_r; bool w_h_changed; bool thread_running; VIDEO_FORMAT v_format; OpenThreads::Mutex buf_m; DISPLAY_AR display_aspect; DISPLAY_AR_MODE display_crop; int output_h; VIDEO_STD v_std; int pig_x; int pig_y; int pig_w; int pig_h; bool pig_changed; OpenThreads::Mutex still_m; bool stillpicture; }; #endif
[ "seife@tuxbox-git.slipkontur.de" ]
seife@tuxbox-git.slipkontur.de
b119cf4a3cc726b07df90aebdbd67a14629461dd
6e0b25bf4106b09a103ad7bfeb2fe174e46c9176
/pr9/re10/7.6/phi
757893e08826443ee5749ad4e172f7a586168f46
[]
no_license
franterminator/OpenFoamCaminos
3bc1d207bed77408f31ef1846a35794fab8cd3d5
5556bc3ddf9cf8aa5a661cd3af74a2b2d76d3471
refs/heads/master
2020-04-16T04:28:19.657010
2019-01-11T15:58:00
2019-01-11T15:58:00
165,268,264
0
0
null
null
null
null
UTF-8
C++
false
false
12,936
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 5.x | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class surfaceScalarField; location "7.6"; object phi; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 3 -1 0 0 0 0]; internalField nonuniform List<scalar> 760 ( 0.00134817675 -0.00134817711 0.00245763984 -0.00110946309 0.00313513471 -0.000677494875 0.00355971574 -0.000424581015 0.00383225133 -0.00027253558 0.00400945218 -0.000177200847 0.00412521452 -0.000115762356 0.00419921708 -7.4002572e-05 0.00424243235 -4.3215269e-05 0.00426055359 -1.81212184e-05 0.00425562237 4.93123316e-06 0.00422675779 2.88645643e-05 0.0041693894 5.7368374e-05 0.00407358504 9.58043589e-05 0.00391995093 0.00015363412 0.00367201931 0.000247931649 0.00326316025 0.000408859059 0.00257264078 0.000690519447 0.00140850173 0.00116413902 0.00140850173 -5.46952001e-05 -0.00129348191 0.000412592721 -0.00157675101 0.00103002986 -0.00129493203 0.00157871391 -0.000973265069 0.00201483273 -0.000708654389 0.00234477729 -0.000507145391 0.00258511634 -0.000356101399 0.00275126943 -0.00024015567 0.0028545678 -0.000146513655 0.00290179532 -6.53487401e-05 0.00289536661 1.13599653e-05 0.00283293038 9.13008103e-05 0.00270712575 0.000183172997 0.00250436374 0.000298566346 0.00220410987 0.000453887977 0.00178090172 0.000671139817 0.001217568 0.000972192807 0.000552812575 0.0013552749 1.30664923e-05 0.00170388511 0.00142156821 -0.000271734626 -0.00102174728 -0.000221026546 -0.00162745908 7.13678468e-05 -0.00158732643 0.00044628568 -0.00134818292 0.000812489702 -0.00107485842 0.00112929929 -0.000823954961 0.00138207834 -0.00060888043 0.0015680079 -0.00042608523 0.00168837697 -0.000266882742 0.00174468453 -0.000121656318 0.00173678975 1.92547502e-05 0.00166213443 0.000165956164 0.0015157129 0.000329594538 0.00129125425 0.000523024985 0.000985011682 0.000760130516 0.000605009638 0.00105114185 0.000189850705 0.00138735176 -0.000160045067 0.00170517069 -0.000261640613 0.00180548067 0.00115992757 -0.00022794158 -0.000793805701 -0.000361197295 -0.00149420335 -0.000308328188 -0.00164019554 -0.000134821184 -0.00152168994 8.92093935e-05 -0.00129888901 0.000314971874 -0.00104971744 0.000513263017 -0.000807171547 0.000668300044 -0.000581122236 0.000771990346 -0.000370573053 0.000820036116 -0.000169702117 0.00080972764 2.95632138e-05 0.000739201023 0.000236482804 0.000607935684 0.000460859907 0.000419110891 0.000711849782 0.000184524329 0.000994717052 -6.71911906e-05 0.00130285735 -0.000280617557 0.00160077813 -0.000369418478 0.00179397163 -0.000246993618 0.00168305583 0.000912933941 -0.000168965228 -0.000624840487 -0.000352016182 -0.00131115237 -0.000431557665 -0.00156065403 -0.000408908958 -0.00154433865 -0.00031943517 -0.00138836283 -0.000200095187 -0.00116905744 -7.98100836e-05 -0.000927456637 2.15782674e-05 -0.000682510554 9.14287217e-05 -0.000440423493 0.000122135397 -0.000200408816 0.000109757186 4.19413925e-05 5.36457004e-05 0.000292594289 -4.27490046e-05 0.000557254646 -0.000169694015 0.00083879482 -0.000307652417 0.00113267545 -0.000423468633 0.00141867353 -0.000470024888 0.00164733437 -0.000397824834 0.00172177159 -0.000196431024 0.00148166204 0.000716502917 -0.000124192149 -0.000500648356 -0.000308335651 -0.00112700887 -0.000450494099 -0.00141849556 -0.000523204 -0.00147162873 -0.000535391042 -0.0013761758 -0.000508160821 -0.0011962877 -0.000463156901 -0.000972460572 -0.000418060939 -0.000727606488 -0.00038561899 -0.000472865403 -0.000373912043 -0.00021211576 -0.000386727925 5.4757237e-05 -0.000423459517 0.000329325851 -0.000478356386 0.000612151529 -0.000539178262 0.000899616738 -0.000585818857 0.00117931606 -0.000590512324 0.00142336698 -0.000523085139 0.00157990715 -0.000366699099 0.00156538554 -0.000150585993 0.00126554895 0.000565916941 -9.45729361e-05 -0.00040607543 -0.000264649758 -0.000956932063 -0.000430738397 -0.00125240691 -0.000556976935 -0.00134539015 -0.000636793194 -0.00129635952 -0.00067814175 -0.00115493916 -0.000693943934 -0.000956658428 -0.000696929256 -0.000724621171 -0.000697274051 -0.000472520566 -0.000701661729 -0.000207728044 -0.000712860689 6.59561851e-05 -0.000729336367 0.000345801482 -0.000744753828 0.000627568966 -0.000747580309 0.000902443248 -0.000721469885 0.00115320568 -0.000647843368 0.00134974048 -0.000512876914 0.00144494067 -0.000321206289 0.00137371489 -0.000116485715 0.00106082837 0.000449431247 -7.53437239e-05 -0.000330731698 -0.000228206821 -0.000804068995 -0.000398353678 -0.00108226006 -0.000550539533 -0.00119320428 -0.000670626436 -0.00117627257 -0.000757578315 -0.00106798728 -0.000816784804 -0.000897451979 -0.000855587462 -0.000685818553 -0.000880624314 -0.000447483703 -0.000896360312 -0.000191991993 -0.000904270054 7.38659597e-05 -0.000902360293 0.000343891693 -0.000884972219 0.00061018084 -0.000843104183 0.000860575198 -0.000765820195 0.00107592173 -0.000643664721 0.00122758505 -0.000475103922 0.00127637988 -0.000276309842 0.00117492078 -9.21328696e-05 0.000876651375 0.000357298384 -6.22882871e-05 -0.000268443385 -0.000198541311 -0.000667815991 -0.000362893665 -0.000917907744 -0.000523850746 -0.0010322472 -0.000664415229 -0.00103570805 -0.000778128894 -0.000954273565 -0.000864812146 -0.000810768731 -0.000927165475 -0.000623465277 -0.000968399709 -0.000406249506 -0.000990721226 -0.000169670448 -0.000994436348 7.75811426e-05 -0.000977525706 0.000326981073 -0.00093569499 0.000568350085 -0.000863101255 0.00078798141 -0.000754123179 0.00096694365 -0.00060662631 0.00108008822 -0.000426950393 0.001096704 -0.000236038274 0.000984008664 -7.43490172e-05 0.000714962098 0.000282949354 -5.27689558e-05 -0.000215674402 -0.000173812769 -0.000546772171 -0.000327557399 -0.000764163146 -0.000486866 -0.000872938644 -0.00063438021 -0.000888193842 -0.00076075785 -0.000827895873 -0.000862116629 -0.000709409909 -0.000937654736 -0.00054792719 -0.000987783238 -0.000356121066 -0.00101282399 -0.000144629724 -0.00101222277 7.69799643e-05 -0.000984240675 0.00029899904 -0.000926163036 0.000510272458 -0.000835158809 0.000696977138 -0.000709976108 0.000841760902 -0.000553597347 0.000923709454 -0.000376676981 0.000919783669 -0.000200960035 0.000808291751 -6.08626139e-05 0.000574864679 0.000222086721 -4.5297932e-05 -0.000170376461 -0.000152453956 -0.000439616111 -0.000293299593 -0.000623317509 -0.000444763105 -0.000721475174 -0.000590345869 -0.00074261112 -0.000719473377 -0.000698768351 -0.000826046333 -0.00060283689 -0.000906878176 -0.00046709531 -0.00096034756 -0.000302651716 -0.00098540317 -0.00011957418 -0.000980963188 7.25399641e-05 -0.000945732116 0.000263768018 -0.000878480007 0.000443020408 -0.000778855035 0.000597352172 -0.000648784051 0.000711689873 -0.000494403566 0.000769328929 -0.000328204169 0.000753584271 -0.000170678368 0.00065076598 -5.02806476e-05 0.000454466983 0.000171806066 -3.90622027e-05 -0.00013131428 -0.000133403799 -0.000345274474 -0.000260349946 -0.000496371323 -0.000400388948 -0.00058143618 -0.000538431203 -0.00060456892 -0.000663692813 -0.000573506779 -0.000768938064 -0.000497591611 -0.00084952306 -0.000386510246 -0.000902500901 -0.000249673847 -0.000925934087 -9.61410389e-05 -0.000918488899 6.50947127e-05 -0.000879356221 0.000224635331 -0.000808535335 0.000372199573 -0.000707505248 0.000496322138 -0.000580261672 0.000584446299 -0.000434588338 0.000623655556 -0.000283248307 0.000602244207 -0.000144573376 0.000512091049 -4.17551873e-05 0.000351648815 0.00013005089 -3.36094327e-05 -9.77048839e-05 -0.000115973522 -0.000262910374 -0.00022868588 -0.000383658916 -0.000355331114 -0.000454790906 -0.000482448471 -0.000477451584 -0.000599656661 -0.000456298651 -0.000699324763 -0.00039792354 -0.00077605049 -0.000309784479 -0.000826127604 -0.000199596665 -0.000847124104 -7.51445198e-05 -0.000837646083 5.56166419e-05 -0.000797332227 0.000184321417 -0.00072710255 0.000301969893 -0.00062965643 0.000398876066 -0.000510163453 0.000464953368 -0.000377005126 0.00049049723 -0.000242314866 0.000467553916 -0.000121978246 0.000391754402 -3.47332259e-05 0.000264403796 9.53176802e-05 -2.86574999e-05 -6.90474077e-05 -9.96602521e-05 -0.000191907651 -0.000198117023 -0.000285202126 -0.000310357549 -0.000342550324 -0.000424616034 -0.000363193064 -0.000531265875 -0.00034964884 -0.00062276547 -0.000306424009 -0.000693446659 -0.000239103312 -0.000739258816 -0.000153784462 -0.000757558009 -5.68452639e-05 -0.000747003423 4.50620665e-05 -0.000707597936 0.000144915882 -0.000640884419 0.000235256326 -0.000550277081 0.000308268727 -0.000441462345 0.000356138672 -0.000322745842 0.000371780763 -0.000205166573 0.00034997465 -0.000102185443 0.00028877325 -2.88024256e-05 0.000191020762 6.65152607e-05 -2.39811949e-05 -4.50662018e-05 -8.39974465e-05 -0.000131891444 -0.000168257122 -0.000200942479 -0.000265595503 -0.000245211918 -0.000365935575 -0.000262852932 -0.000460594466 -0.000254989921 -0.000542423522 -0.000224594989 -0.000605821337 -0.000175705559 -0.000646681753 -0.00011292406 -0.000662339382 -4.11875884e-05 -0.000651561306 3.42840466e-05 -0.000614612921 0.000107967502 -0.000553400637 0.000174044 -0.000471663911 0.000226531961 -0.000375154016 0.000259628776 -0.00027170195 0.000268328728 -0.000171058846 0.000249331573 -8.44170613e-05 0.000202131467 -2.3599866e-05 0.000130203554 4.29153887e-05 -1.93492005e-05 -2.57169629e-05 -6.8470022e-05 -8.27706437e-05 -0.000138506766 -0.000130905785 -0.000220638101 -0.000163080609 -0.00030642842 -0.000177062581 -0.000388228736 -0.000173189547 -0.000459474147 -0.000153349557 -0.000514859802 -0.000120319943 -0.00055042981 -7.7354105e-05 -0.000563627582 -2.79898244e-05 -0.000553348422 2.40049302e-05 -0.00052001641 7.46355357e-05 -0.000465682598 0.000119710191 -0.000394114915 0.000154964245 -0.000310822998 0.000176336829 -0.000222941272 0.000180447002 -0.000138894619 0.000165284942 -6.78135097e-05 0.000131050376 -1.87621077e-05 8.11521538e-05 2.41532722e-05 -1.45055169e-05 -1.12114123e-05 -5.25210862e-05 -4.47550516e-05 -0.000108122804 -7.5304093e-05 -0.000174687809 -9.65156532e-05 -0.000245343263 -0.000106407149 -0.000313520821 -0.000105011956 -0.000373387881 -9.3482445e-05 -0.000420129403 -7.35784057e-05 -0.000450116072 -4.73674724e-05 -0.0004610091 -1.70968403e-05 -0.000451841648 1.48374738e-05 -0.000423096902 4.58908254e-05 -0.000376775953 7.33892782e-05 -0.000316426441 9.46147354e-05 -0.000247079552 0.000106989916 -0.000175030362 0.000108397791 -0.000107403066 9.76576451e-05 -5.14858443e-05 7.51331686e-05 -1.3914617e-05 4.35809377e-05 1.02386524e-05 -9.20280903e-06 -2.00860242e-06 -3.56847273e-05 -1.82730892e-05 -7.64355088e-05 -3.45532923e-05 -0.000126811018 -4.61401683e-05 -0.000181408084 -5.18101268e-05 -0.000234817166 -5.1602889e-05 -0.000282132228 -4.61673517e-05 -0.000319263522 -3.64470694e-05 -0.000343116495 -2.35144908e-05 -0.000351700046 -8.51332055e-06 -0.000344207031 7.34442623e-06 -0.00032108444 2.27682326e-05 -0.000284086156 3.63910204e-05 -0.000236279523 4.68081286e-05 -0.000181958567 5.26689633e-05 -0.000126403748 5.28429566e-05 -7.54285467e-05 4.668243e-05 -3.4681631e-05 3.43862524e-05 -8.71390765e-06 1.76132223e-05 1.52474768e-06 -3.43754506e-06 1.42891671e-06 -1.80438834e-05 -3.66672511e-06 -4.34060271e-05 -9.19110937e-06 -7.64336523e-05 -1.3112525e-05 -0.000113187155 -1.50566435e-05 -0.000149665128 -1.51249479e-05 -0.000182251559 -1.35809291e-05 -0.000207952846 -1.07457592e-05 -0.00022451408 -6.95322618e-06 -0.000230484748 -2.54264712e-06 -0.000225272647 2.13230364e-06 -0.000209197092 6.69265557e-06 -0.000183535364 1.07292916e-05 -0.000150536808 1.38095898e-05 -0.000113368286 1.5500458e-05 -7.59397547e-05 1.5414428e-05 -4.25472226e-05 1.32898899e-05 -1.72767403e-05 9.11576297e-06 -3.10385949e-06 3.44034167e-06 -1.5791082e-06 1.4288875e-06 -2.23785817e-06 -1.14289632e-05 -2.45414631e-05 -3.95980884e-05 -5.47230435e-05 -6.83039958e-05 -7.90497681e-05 -8.6002984e-05 -8.85456094e-05 -8.64132946e-05 -7.97206467e-05 -6.89913707e-05 -5.51817886e-05 -3.96813259e-05 -2.42668881e-05 -1.09769929e-05 -1.86123068e-06 1.57910836e-06 ) ; boundaryField { walls { type calculated; value uniform 0; } mov_wall { type calculated; value uniform 0; } empty { type empty; value nonuniform 0(); } } // ************************************************************************* //
[ "franterminator@hotmail.com" ]
franterminator@hotmail.com
658a532514e759b3c80b74d419c4bd65e97189f7
352b4ded0fc31eb363165ab3ad15143a61f152ef
/KFPlugin/KFRecruit/KFRecruitModule.hpp
85f8acaeecab1ae9b9dbdbfc3981f99bb1e3e950
[]
no_license
lori227/Dark
c9c2409d0888916f4a52fb8d0e5081ecb56ff4ba
86ec8fff527f488f1be058e1e40350d5a0b11b41
refs/heads/master
2022-10-12T06:31:06.129090
2020-06-12T05:52:45
2020-06-12T05:52:45
181,450,024
0
0
null
null
null
null
UTF-8
C++
false
false
5,949
hpp
#ifndef __KF_RECRUIT_MOUDLE_H__ #define __KF_RECRUIT_MOUDLE_H__ /************************************************************************ // @Moudle : 英雄招募系统 // @Author : __凌_痕__ // @QQ : 7969936 // @Mail : lori227@qq.com // @Date : 2019-7-15 ************************************************************************/ #include "KFrameEx.h" #include "KFRecruitInterface.h" #include "KFProtocol/KFProtocol.h" #include "KFTimer/KFTimerInterface.h" #include "KFHero/KFHeroInterface.h" #include "KFKernel/KFKernelInterface.h" #include "KFPlayer/KFPlayerInterface.h" #include "KFDisplay/KFDisplayInterface.h" #include "KFMessage/KFMessageInterface.h" #include "KFFilter/KFFilterInterface.h" #include "KFGenerate/KFGenerateInterface.h" #include "KFExecute/KFExecuteInterface.h" #include "KFRecruitConfig.hpp" #include "KFZConfig/KFFormulaConfig.h" #include "KFZConfig/KFDivisorConfig.hpp" #include "KFZConfig/KFProfessionConfig.hpp" #include "KFZConfig/KFGenerateConfig.hpp" #include "KFZConfig/KFElementConfig.h" #include "KFZConfig/KFTechnologyConfig.hpp" namespace KFrame { class KFDivisorSetting; class KFRecruitModule : public KFRecruitInterface { public: KFRecruitModule() = default; ~KFRecruitModule() = default; // 逻辑 virtual void BeforeRun(); // 关闭 virtual void BeforeShut(); //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// protected: // 打开招募所界面 __KF_MESSAGE_FUNCTION__( HandleOpenRecruitReq ); // 刷新招募英雄 __KF_MESSAGE_FUNCTION__( HandleRefreshRecruitReq ); // 选择偏好因子 __KF_MESSAGE_FUNCTION__( HandleChooseDivisorReq ); // 删除偏好因子 __KF_MESSAGE_FUNCTION__( HandleRemoveDivisorReq ); // 招募英雄 __KF_MESSAGE_FUNCTION__( HandleRecruitHeroReq ); // 设置英雄名字 __KF_MESSAGE_FUNCTION__( HandleSetRecruitHeroNameReq ); protected: // 添加招募英雄 __KF_ADD_ELEMENT_FUNCTION__( AddRecruitHeroElement ); /////////////////////////////////////////////////////////////////////// // 进入游戏 __KF_ENTER_PLAYER_FUNCTION__( OnEnterRecruitModule ); __KF_ENTER_PLAYER_FUNCTION__( OnAfterEnterRecruitModule ); // 离开游戏 __KF_LEAVE_PLAYER_FUNCTION__( OnLeaveRecruitModule ); // 刷新招募次数 __KF_TIMER_FUNCTION__( OnTimerRefreshRecruitCount ); // 检测刷新招募时间 void CheckRefreshRecruitTimer( KFEntity* player ); // 刷新招募时间 void StartRefreshRecruitTimer( KFEntity* player, KFData* kfrefreshtime, uint32 intervaltime ); // 招募数量改变 __KF_UPDATE_DATA_FUNCTION__( OnRecruitCountUpdateCallBack ); // 招募所解锁 __KF_ADD_DATA_FUNCTION__( OnAddRecruitBuild ); // 招募所是否激活 bool IsRecruitActive( KFEntity* player ); // 删除英雄 __KF_REMOVE_DATA_FUNCTION__( OnRemoveHero ); // 刷新免费英雄 void RefreshRecruitFreeHero( KFEntity* player, uint32 herocount ); // 刷新招募列表 uint32 RefreshRecruitLists( KFEntity* player, uint32 type ); // 计算招募英雄的数量 uint32 CalcRecruitHeroCount( KFData* kfeffect ); // 默认的招募英雄池子和权重 uint32 CalcRecruitGenerateWeight( KFData* kfeffect, const KFRecruitSetting* kfrecruitsetting, UInt32Map& generateweight, uint32 type ); // 生成招募英雄 void GenerateRecruitHero( KFEntity* player, KFData* kfeffect, KFData* kfrecruitrecord, uint32 generateid, const DivisorList& divisorlist, const UInt32Set& professionlist, uint32 mingrowth, uint32 maxgrowth ); // 计算招募花费 void CalcRecruitCostData( KFEntity* player, KFData* kfeffect, KFData* kfrecruit, KFData* kfhero, uint32 generateid, bool update ); void CalcRecruitCostItem( KFEntity* player, KFData* kfhero, const KFFormulaParam* kfformulaparam, KFElementSetting* kfelementsetting ); void CalcRecruitCostCurrency( KFEntity* player, KFData* kfeffect, KFData* kfhero, const KFFormulaParam* kfformulaparam, KFElementSetting* kfelementsetting ); // 计算种族亲和 uint32 CalcRecruitHeroDiscount( KFData* kfeffect, KFData* kfhero, double price ); // 刷新种族亲和 void RefreshRecruitHeroDiscount( KFEntity* player, KFData* kfeffect, uint32 race ); // 计算招募英雄的等级 uint32 CalcRecruitHeroLevel( KFData* kfeffect ); // 解锁的职业列表 UInt32Set& CalcRecruitHeroProfession( KFData* kfeffect ); // 计算招募因子 DivisorList& CalcRecruitHeroDivisor( KFData* kfeffect ); // 招募因子列表 DivisorList& DivisorListByType( KFData* kfdivisorrecord, uint32 type ); // 解锁招募因子 __KF_EXECUTE_FUNCTION__( OnExecuteTechnologyRecruitDivisor ); // 招募数量 __KF_EXECUTE_FUNCTION__( OnExecuteTechnologyRecruitCount ); // 招募权重 __KF_EXECUTE_FUNCTION__( OnExecuteTechnologyRecruitWeight ); // 招募亲和 __KF_EXECUTE_FUNCTION__( OnExecuteTechnologyRecruitDiscount ); // 解锁职业 __KF_EXECUTE_FUNCTION__( OnExecuteTechnologyRecruitProfession ); // 解锁等级 __KF_EXECUTE_FUNCTION__( OnExecuteTechnologyRecruitLevel ); // 招募成长率 __KF_EXECUTE_FUNCTION__( OnExecuteTechnologyRecruitGrowth ); protected: // 玩家上下文组件 KFComponent* _kf_component = nullptr; }; } #endif
[ "lori227@qq.com" ]
lori227@qq.com
41d1b84dbca4351d21ab9128682e313c124287cf
fd763525912dbd03646fa1c4a896ba5b19739665
/POproject1symulacja/Roslina.h
31977f920b8d86106845babb57b12feac0b246fd
[]
no_license
Vihajster/POproject2017_symulation
0048fcbe91a61f8e8c55b86daf20e6f91aa8dc81
c3b0d9c58c4d73220d5a6371468efed30d1f5a85
refs/heads/master
2020-09-14T18:48:12.369534
2019-11-21T16:37:58
2019-11-21T16:37:58
223,219,244
0
0
null
null
null
null
UTF-8
C++
false
false
135
h
#pragma once #include "Organizm.h" class Roslina :public Organizm { public: Roslina(Swiat & Swiat, position p); void akcja(); };
[ "marcingrabowskiv@gmail.com" ]
marcingrabowskiv@gmail.com
53d419afe3a89b6267e979ffd26dd232fcc82115
21f597731b48faa1b4839f1482b62d6bb1abea23
/libtsuba/src/ParquetWriter.cpp
7795513f992770a50b77074af0168c77fb2e8f0f
[ "BSD-3-Clause", "LicenseRef-scancode-warranty-disclaimer" ]
permissive
katana-ryan-vazquez/katana
78a6df4c631450e9ee7b9e0590d8fdac7db64663
917b9eef173c0091b9eca3df219ad18412ae1be7
refs/heads/master
2023-06-01T22:16:23.559637
2021-06-23T00:13:29
2021-06-23T00:13:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
9,008
cpp
#include "tsuba/ParquetWriter.h" #include "katana/ArrowInterchange.h" #include "katana/Result.h" #include "tsuba/Errors.h" #include "tsuba/FaultTest.h" template <typename T> using Result = katana::Result<T>; namespace { // constant taken directly from the arrow docs constexpr uint64_t kMaxStringChunkSize = 0x7FFFFFFE; katana::Result<std::vector<std::shared_ptr<arrow::Array>>> LargeStringToChunkedString( const std::shared_ptr<arrow::LargeStringArray>& arr) { std::vector<std::shared_ptr<arrow::Array>> chunks; arrow::StringBuilder builder; uint64_t inserted = 0; for (uint64_t i = 0, size = arr->length(); i < size; ++i) { if (!arr->IsValid(i)) { auto status = builder.AppendNull(); if (!status.ok()) { return KATANA_ERROR( tsuba::ErrorCode::ArrowError, "appending null: {}", status); } continue; } arrow::util::string_view val = arr->GetView(i); uint64_t val_size = val.size(); KATANA_LOG_ASSERT(val_size < kMaxStringChunkSize); if (inserted + val_size >= kMaxStringChunkSize) { std::shared_ptr<arrow::Array> new_arr; auto status = builder.Finish(&new_arr); if (!status.ok()) { return KATANA_ERROR( tsuba::ErrorCode::ArrowError, "finishing string array: {}", status); } chunks.emplace_back(new_arr); inserted = 0; builder.Reset(); } inserted += val_size; auto status = builder.Append(val); if (!status.ok()) { return KATANA_ERROR( tsuba::ErrorCode::ArrowError, "adding string to array: {}", status); } } std::shared_ptr<arrow::Array> new_arr; auto status = builder.Finish(&new_arr); if (!status.ok()) { return KATANA_ERROR( tsuba::ErrorCode::ArrowError, "finishing string array: {}", status); } if (new_arr->length() > 0) { chunks.emplace_back(new_arr); } return chunks; } // HandleBadParquetTypes here and HandleBadParquetTypes in ParquetReader.cpp // workaround a libarrow2.0 limitation in reading and writing LargeStrings to // parquet files. katana::Result<std::shared_ptr<arrow::ChunkedArray>> HandleBadParquetTypes(std::shared_ptr<arrow::ChunkedArray> old_array) { switch (old_array->type()->id()) { case arrow::Type::type::LARGE_STRING: { std::vector<std::shared_ptr<arrow::Array>> new_chunks; for (const auto& chunk : old_array->chunks()) { auto arr = std::static_pointer_cast<arrow::LargeStringArray>(chunk); auto new_chunk_res = LargeStringToChunkedString(arr); if (!new_chunk_res) { return new_chunk_res.error(); } const auto& chunks = new_chunk_res.value(); new_chunks.insert(new_chunks.end(), chunks.begin(), chunks.end()); } auto maybe_res = arrow::ChunkedArray::Make(new_chunks, arrow::utf8()); if (!maybe_res.ok()) { return KATANA_ERROR( tsuba::ErrorCode::ArrowError, "building chunked array: {}", maybe_res.status()); } return maybe_res.ValueOrDie(); } default: return old_array; } } katana::Result<std::shared_ptr<arrow::Table>> HandleBadParquetTypes(const std::shared_ptr<arrow::Table>& old_table) { std::vector<std::shared_ptr<arrow::ChunkedArray>> new_arrays; std::vector<std::shared_ptr<arrow::Field>> new_fields; for (int i = 0, size = old_table->num_columns(); i < size; ++i) { auto new_array_res = HandleBadParquetTypes(old_table->column(i)); if (!new_array_res) { return new_array_res.error(); } std::shared_ptr<arrow::ChunkedArray> new_array = std::move(new_array_res.value()); auto old_field = old_table->field(i); new_fields.emplace_back( std::make_shared<arrow::Field>(old_field->name(), new_array->type())); new_arrays.emplace_back(new_array); } return arrow::Table::Make(arrow::schema(new_fields), new_arrays); } uint64_t EstimateElementSize(const std::shared_ptr<arrow::ChunkedArray>& chunked_array) { uint64_t cumulative_size = 0; for (const auto& chunk : chunked_array->chunks()) { cumulative_size += katana::ApproxArrayMemUse(chunk); } return cumulative_size / chunked_array->length(); } uint64_t EstimateRowSize(const std::shared_ptr<arrow::Table>& table) { uint64_t row_size = 0; for (const auto& col : table->columns()) { row_size += EstimateElementSize(col); } return row_size; } constexpr uint64_t kMB = 1UL << 20; std::vector<std::shared_ptr<arrow::Table>> BlockTable(std::shared_ptr<arrow::Table> table, uint64_t mbs_per_block) { if (table->num_rows() <= 1) { return {table}; } uint64_t row_size = EstimateRowSize(table); uint64_t block_size = mbs_per_block * kMB; if (row_size * table->num_rows() < block_size) { return {std::move(table)}; } int64_t rows_per_block = (block_size + row_size - 1) / row_size; std::vector<std::shared_ptr<arrow::Table>> blocks; int64_t row_idx = 0; int64_t num_rows = table->num_rows(); while (row_idx < table->num_rows()) { blocks.emplace_back( table->Slice(row_idx, std::min(num_rows - row_idx, rows_per_block))); row_idx += rows_per_block; } return blocks; } } // namespace Result<std::unique_ptr<tsuba::ParquetWriter>> tsuba::ParquetWriter::Make( const std::shared_ptr<arrow::ChunkedArray>& array, const std::string& name, WriteOpts opts) { return Make( arrow::Table::Make( arrow::schema({arrow::field(name, array->type())}), {array}), opts); } Result<std::unique_ptr<tsuba::ParquetWriter>> tsuba::ParquetWriter::Make( std::shared_ptr<arrow::Table> table, WriteOpts opts) { if (!opts.write_blocked) { return std::unique_ptr<ParquetWriter>( new ParquetWriter({std::move(table)}, opts)); } return std::unique_ptr<ParquetWriter>(new ParquetWriter( BlockTable(std::move(table), opts.mbs_per_block), opts)); } katana::Result<void> tsuba::ParquetWriter::WriteToUri(const katana::Uri& uri, WriteGroup* group) { try { return StoreParquet(uri, group); } catch (const std::exception& exp) { return KATANA_ERROR( tsuba::ErrorCode::ArrowError, "arrow exception: {}", exp.what()); } } std::shared_ptr<parquet::WriterProperties> tsuba::ParquetWriter::StandardWriterProperties() { return parquet::WriterProperties::Builder() .version(opts_.parquet_version) ->data_page_version(opts_.data_page_version) ->build(); } std::shared_ptr<parquet::ArrowWriterProperties> tsuba::ParquetWriter::StandardArrowProperties() { return parquet::ArrowWriterProperties::Builder().build(); } /// Store the arrow table in a file katana::Result<void> tsuba::ParquetWriter::StoreParquet( std::shared_ptr<arrow::Table> table, const katana::Uri& uri, tsuba::WriteGroup* desc) { auto ff = std::make_shared<tsuba::FileFrame>(); if (auto res = ff->Init(); !res) { return res.error().WithContext("creating output buffer"); } ff->Bind(uri.string()); auto future = std::async( std::launch::async, [table = std::move(table), ff = std::move(ff), desc, writer_props = StandardWriterProperties(), arrow_props = StandardArrowProperties()]() mutable -> katana::Result<void> { auto res = HandleBadParquetTypes(table); if (!res) { return res.error().WithContext( "conversion from arrow to parquet mismatch"); } table = std::move(res.value()); auto write_result = parquet::arrow::WriteTable( *table, arrow::default_memory_pool(), ff, std::numeric_limits<int64_t>::max(), writer_props, arrow_props); table.reset(); if (!write_result.ok()) { return KATANA_ERROR( tsuba::ErrorCode::ArrowError, "arrow error: {}", write_result); } if (desc) { desc->AddToOutstanding(ff->map_size()); } TSUBA_PTP(tsuba::internal::FaultSensitivity::Normal); return ff->Persist(); }); if (!desc) { return future.get(); } desc->AddOp(std::move(future), uri.string()); return katana::ResultSuccess(); } katana::Result<void> tsuba::ParquetWriter::StoreParquet( const katana::Uri& uri, tsuba::WriteGroup* desc) { if (!opts_.write_blocked) { KATANA_LOG_ASSERT(tables_.size() == 1); return StoreParquet(tables_[0], uri, desc); } std::unique_ptr<tsuba::WriteGroup> our_desc; if (!desc) { auto desc_res = WriteGroup::Make(); if (!desc_res) { return desc_res.error(); } our_desc = std::move(desc_res.value()); desc = our_desc.get(); } katana::Result<void> ret = katana::ResultSuccess(); for (uint64_t i = 0, num_tables = tables_.size(); i < num_tables; ++i) { ret = StoreParquet(tables_[i], uri + fmt::format(".{:06}", i), desc); if (!ret) { break; } } if (desc == our_desc.get()) { auto final_ret = desc->Finish(); if (!final_ret && !ret) { KATANA_LOG_ERROR("multiple errors, masking: {}", final_ret.error()); return ret; } ret = final_ret; } return ret; }
[ "tylerscotthunt@gmail.com" ]
tylerscotthunt@gmail.com
a9b16fde2796d669c8c7016b2a08541579032372
415832b7faab4ec97970ae5aa00de62ec24c9c31
/Tutorials/Solution/TI_01_graphene/M_10.0/siesta.TBT.CC
ccc105ae094015d022a8b39d118d537880d2247c
[]
no_license
lwk205/TopoToolsSiesta
f82e95c1e4eaa4df03961989b1214bb0732685c9
a40e11a5cd22e6f7854c8d241e0ae68bfa192df2
refs/heads/master
2023-04-24T09:20:57.502184
2021-05-15T07:52:46
2021-05-15T07:52:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
78,116
cc
# Contour path for the transport part # Re(c) [eV] Im(c) [eV] w [eV] 0.50000000000000001E-03 0.00000000000000000E+00 0.10000000000000000E-02 0.15000000000000000E-02 0.00000000000000000E+00 0.10000000000000000E-02 0.25000000000000001E-02 0.00000000000000000E+00 0.10000000000000000E-02 0.35000000000000001E-02 0.00000000000000000E+00 0.10000000000000000E-02 0.45000000000000005E-02 0.00000000000000000E+00 0.10000000000000000E-02 0.55000000000000005E-02 0.00000000000000000E+00 0.10000000000000000E-02 0.65000000000000006E-02 0.00000000000000000E+00 0.10000000000000000E-02 0.75000000000000006E-02 0.00000000000000000E+00 0.10000000000000000E-02 0.85000000000000006E-02 0.00000000000000000E+00 0.10000000000000000E-02 0.94999999999999998E-02 0.00000000000000000E+00 0.10000000000000000E-02 0.10500000000000001E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.11500000000000000E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.12500000000000001E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.13500000000000000E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.14500000000000001E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.15500000000000000E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.16500000000000001E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.17500000000000002E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.18500000000000003E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.19500000000000000E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.20500000000000001E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.21500000000000002E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.22500000000000003E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.23500000000000000E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.24500000000000001E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.25500000000000002E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.26500000000000003E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.27500000000000000E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.28500000000000001E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.29500000000000002E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.30500000000000003E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.31500000000000000E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.32500000000000001E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.33500000000000002E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.34500000000000003E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.35500000000000004E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.36500000000000005E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.37499999999999999E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.38500000000000000E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.39500000000000000E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.40500000000000001E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.41500000000000002E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.42500000000000003E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.43500000000000004E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.44500000000000005E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.45499999999999999E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.46500000000000000E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.47500000000000001E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.48500000000000001E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.49500000000000002E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.50500000000000003E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.51500000000000004E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.52500000000000005E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.53500000000000006E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.54500000000000000E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.55500000000000001E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.56500000000000002E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.57500000000000002E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.58500000000000003E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.59500000000000004E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.60500000000000005E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.61500000000000006E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.62500000000000000E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.63500000000000001E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.64500000000000002E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.65500000000000003E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.66500000000000004E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.67500000000000004E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.68500000000000005E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.69500000000000006E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.70500000000000007E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.71500000000000008E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.72500000000000009E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.73500000000000010E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.74499999999999997E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.75499999999999998E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.76499999999999999E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.77499999999999999E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.78500000000000000E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.79500000000000001E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.80500000000000002E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.81500000000000003E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.82500000000000004E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.83500000000000005E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.84500000000000006E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.85500000000000007E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.86500000000000007E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.87500000000000008E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.88500000000000009E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.89500000000000010E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.90500000000000011E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.91499999999999998E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.92499999999999999E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.93500000000000000E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.94500000000000001E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.95500000000000002E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.96500000000000002E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.97500000000000003E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.98500000000000004E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.99500000000000005E-01 0.00000000000000000E+00 0.10000000000000000E-02 0.10050000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.10150000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.10250000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.10350000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.10450000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.10550000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.10650000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.10750000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.10850000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.10950000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.11050000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.11150000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.11250000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.11350000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.11450000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.11550000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.11650000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.11750000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.11850000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.11950000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.12050000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.12150000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.12250000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.12350000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.12450000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.12550000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.12650000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.12750000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.12850000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.12950000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.13050000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.13150000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.13250000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.13350000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.13450000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.13550000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.13650000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.13750000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.13850000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.13950000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.14050000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.14150000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.14250000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.14350000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.14450000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.14550000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.14650000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.14750000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.14849999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.14949999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.15049999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.15150000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.15250000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.15350000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.15450000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.15550000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.15650000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.15750000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.15850000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.15950000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.16050000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.16150000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.16250000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.16350000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.16450000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.16550000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.16650000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.16750000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.16850000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.16950000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.17050000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.17150000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.17250000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.17350000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.17450000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.17550000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.17650000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.17750000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.17850000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.17950000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.18050000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.18149999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.18250000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.18350000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.18450000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.18550000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.18650000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.18750000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.18850000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.18950000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.19050000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.19150000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.19250000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.19350000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.19450000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.19550000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.19650000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.19750000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.19850000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.19950000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.20050000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.20150000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.20250000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.20350000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.20450000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.20550000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.20650000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.20750000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.20850000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.20950000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.21050000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.21150000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.21250000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.21350000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.21450000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.21550000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.21650000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.21750000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.21850000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.21950000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.22050000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.22150000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.22250000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.22350000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.22450000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.22550000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.22650000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.22750000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.22850000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.22950000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.23050000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.23150000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.23250000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.23350000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.23450000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.23550000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.23650000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.23750000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.23850000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.23950000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.24050000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.24150000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.24250000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.24350000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.24450000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.24550000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.24650000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.24750000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.24850000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.24950000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.25050000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.25150000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.25250000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.25350000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.25450000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.25550000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.25650000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.25750000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.25850000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.25950000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.26050000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.26150000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.26250000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.26350000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.26450000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.26550000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.26650000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.26750000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.26850000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.26950000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.27050000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.27150000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.27250000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.27350000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.27450000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.27550000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.27650000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.27750000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.27850000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.27950000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.28050000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.28150000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.28250000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.28350000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.28450000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.28550000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.28650000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.28750000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.28850000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.28950000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.29050000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.29150000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.29250000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.29350000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.29450000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.29550000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.29649999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.29749999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.29849999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.29949999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.30049999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.30149999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.30249999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.30349999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.30449999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.30549999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.30649999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.30750000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.30850000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.30950000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.31050000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.31150000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.31250000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.31350000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.31450000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.31550000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.31650000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.31750000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.31850000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.31950000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.32050000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.32150000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.32250000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.32350000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.32450000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.32550000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.32650000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.32750000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.32850000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.32950000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.33050000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.33150000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.33250000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.33350000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.33450000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.33550000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.33650000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.33750000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.33850000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.33950000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.34050000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.34150000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.34250000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.34350000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.34450000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.34550000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.34650000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.34750000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.34850000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.34950000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.35050000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.35150000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.35250000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.35350000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.35450000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.35550000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.35650000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.35750000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.35850000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.35950000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.36050000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.36150000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.36249999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.36349999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.36449999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.36549999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.36649999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.36749999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.36849999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.36950000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.37050000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.37150000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.37250000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.37350000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.37450000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.37550000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.37650000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.37750000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.37850000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.37950000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.38050000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.38150000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.38250000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.38350000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.38450000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.38550000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.38650000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.38750000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.38850000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.38950000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.39050000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.39150000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.39250000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.39350000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.39450000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.39550000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.39650000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.39750000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.39850000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.39950000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.40050000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.40150000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.40250000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.40350000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.40450000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.40550000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.40650000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.40750000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.40850000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.40950000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.41050000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.41150000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.41250000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.41350000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.41450000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.41550000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.41650000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.41750000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.41850000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.41950000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.42050000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.42150000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.42250000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.42350000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.42450000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.42550000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.42650000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.42750000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.42849999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.42949999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.43049999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.43149999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.43250000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.43350000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.43450000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.43550000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.43650000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.43750000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.43850000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.43950000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.44050000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.44150000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.44250000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.44350000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.44450000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.44550000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.44650000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.44750000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.44850000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.44950000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.45050000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.45150000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.45250000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.45350000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.45450000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.45550000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.45650000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.45750000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.45850000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.45950000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.46050000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.46150000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.46250000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.46350000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.46450000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.46550000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.46650000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.46750000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.46850000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.46950000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.47050000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.47150000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.47250000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.47350000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.47450000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.47550000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.47650000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.47750000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.47850000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.47950000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.48050000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.48150000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.48250000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.48350000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.48450000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.48550000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.48650000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.48750000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.48850000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.48950000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.49050000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.49150000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.49250000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.49350000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.49450000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.49550000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.49650000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.49750000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.49850000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.49950000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.50050000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.50150000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.50250000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.50350000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.50450000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.50550000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.50650000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.50750000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.50850000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.50950000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.51050000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.51150000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.51250000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.51350000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.51450000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.51550000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.51650000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.51750000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.51850000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.51950000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.52050000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.52150000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.52250000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.52350000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.52450000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.52550000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.52650000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.52749999999999997E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.52849999999999997E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.52949999999999997E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.53049999999999997E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.53149999999999997E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.53249999999999997E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.53349999999999997E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.53449999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.53549999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.53649999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.53749999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.53849999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.53949999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.54049999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.54149999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.54249999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.54349999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.54449999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.54549999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.54649999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.54749999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.54849999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.54949999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.55049999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.55149999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.55249999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.55349999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.55449999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.55549999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.55649999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.55750000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.55850000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.55950000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.56050000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.56150000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.56250000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.56350000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.56450000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.56550000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.56650000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.56750000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.56850000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.56950000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.57050000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.57150000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.57250000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.57350000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.57450000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.57550000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.57650000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.57750000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.57850000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.57950000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.58050000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.58150000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.58250000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.58350000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.58450000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.58550000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.58650000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.58750000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.58850000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.58950000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.59050000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.59150000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.59250000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.59350000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.59450000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.59550000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.59650000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.59750000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.59850000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.59950000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.60050000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.60150000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.60250000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.60350000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.60450000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.60550000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.60650000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.60750000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.60850000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.60950000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.61050000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.61150000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.61250000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.61350000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.61450000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.61550000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.61650000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.61750000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.61850000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.61950000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.62050000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.62150000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.62250000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.62350000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.62450000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.62550000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.62650000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.62750000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.62850000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.62950000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.63050000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.63150000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.63250000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.63350000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.63450000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.63550000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.63650000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.63750000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.63850000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.63950000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.64050000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.64150000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.64250000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.64350000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.64450000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.64550000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.64650000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.64750000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.64850000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.64950000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.65050000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.65150000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.65250000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.65350000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.65450000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.65550000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.65650000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.65750000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.65850000000000009E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.65949999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.66049999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.66149999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.66249999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.66349999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.66449999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.66549999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.66649999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.66749999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.66849999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.66949999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.67049999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.67149999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.67249999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.67349999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.67449999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.67549999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.67649999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.67749999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.67849999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.67949999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.68049999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.68149999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.68250000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.68350000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.68450000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.68550000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.68650000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.68750000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.68850000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.68950000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.69050000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.69150000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.69250000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.69350000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.69450000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.69550000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.69650000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.69750000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.69850000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.69950000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.70050000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.70150000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.70250000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.70350000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.70450000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.70550000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.70650000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.70750000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.70850000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.70950000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.71050000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.71150000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.71250000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.71350000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.71450000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.71550000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.71650000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.71750000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.71850000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.71950000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.72050000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.72150000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.72250000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.72350000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.72450000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.72550000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.72650000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.72750000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.72850000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.72950000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.73050000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.73150000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.73250000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.73350000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.73450000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.73550000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.73650000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.73750000000000004E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.73850000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.73950000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.74050000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.74150000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.74250000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.74350000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.74450000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.74550000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.74650000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.74750000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.74850000000000005E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.74950000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.75050000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.75150000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.75250000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.75350000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.75450000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.75550000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.75650000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.75750000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.75850000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.75950000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.76050000000000006E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.76150000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.76250000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.76350000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.76450000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.76550000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.76650000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.76750000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.76850000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.76950000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.77050000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.77150000000000007E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.77250000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.77350000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.77450000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.77550000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.77650000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.77750000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.77850000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.77950000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.78050000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.78150000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.78250000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.78350000000000009E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.78450000000000009E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.78550000000000009E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.78650000000000009E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.78750000000000009E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.78850000000000009E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.78950000000000009E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.79050000000000009E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.79149999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.79249999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.79349999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.79449999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.79549999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.79649999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.79749999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.79849999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.79949999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.80049999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.80149999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.80249999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.80349999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.80449999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.80549999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.80649999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.80750000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.80850000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.80950000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.81050000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.81150000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.81250000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.81350000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.81450000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.81550000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.81650000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.81750000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.81850000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.81950000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.82050000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.82150000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.82250000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.82350000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.82450000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.82550000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.82650000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.82750000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.82850000000000001E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.82950000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.83050000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.83150000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.83250000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.83350000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.83450000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.83550000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.83650000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.83750000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.83850000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.83950000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.84050000000000002E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.84150000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.84250000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.84350000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.84450000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.84550000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.84650000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.84750000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.84850000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.84950000000000003E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.85050000000000014E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.85149999999999992E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.85250000000000015E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.85349999999999993E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.85450000000000015E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.85549999999999993E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.85650000000000015E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.85749999999999993E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.85850000000000015E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.85949999999999993E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.86050000000000015E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.86149999999999993E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.86250000000000016E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.86349999999999993E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.86450000000000016E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.86549999999999994E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.86650000000000016E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.86749999999999994E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.86850000000000016E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.86949999999999994E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.87050000000000016E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.87149999999999994E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.87250000000000016E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.87349999999999994E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.87450000000000017E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.87549999999999994E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.87650000000000017E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.87749999999999995E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.87850000000000017E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.87949999999999995E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.88050000000000017E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.88149999999999995E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.88250000000000017E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.88349999999999995E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.88450000000000017E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.88549999999999995E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.88650000000000018E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.88749999999999996E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.88850000000000018E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.88949999999999996E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.89050000000000018E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.89149999999999996E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.89250000000000018E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.89349999999999996E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.89450000000000018E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.89549999999999996E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.89650000000000019E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.89749999999999996E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.89850000000000019E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.89949999999999997E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.90050000000000019E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.90149999999999997E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.90250000000000019E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.90349999999999997E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.90450000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.90549999999999997E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.90650000000000008E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.90749999999999997E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.90850000000000009E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.90949999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.91050000000000009E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.91149999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.91250000000000009E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.91349999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.91450000000000009E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.91549999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.91650000000000009E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.91749999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.91850000000000009E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.91949999999999998E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.92050000000000010E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.92149999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.92250000000000010E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.92349999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.92450000000000010E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.92549999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.92650000000000010E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.92749999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.92850000000000010E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.92949999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.93050000000000010E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.93149999999999999E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.93250000000000011E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.93350000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.93450000000000011E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.93550000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.93650000000000011E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.93750000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.93850000000000011E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.93950000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.94050000000000011E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.94150000000000000E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.94250000000000012E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.94349999999999989E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.94450000000000012E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.94549999999999990E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.94650000000000012E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.94749999999999990E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.94850000000000012E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.94949999999999990E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.95050000000000012E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.95149999999999990E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.95250000000000012E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.95349999999999990E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.95450000000000013E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.95549999999999990E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.95650000000000013E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.95749999999999991E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.95850000000000013E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.95949999999999991E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.96050000000000013E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.96149999999999991E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.96250000000000013E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.96349999999999991E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.96450000000000014E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.96549999999999991E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.96650000000000014E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.96749999999999992E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.96850000000000014E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.96949999999999992E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.97050000000000014E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.97149999999999992E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.97250000000000014E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.97349999999999992E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.97450000000000014E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.97549999999999992E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.97650000000000015E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.97749999999999992E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.97850000000000015E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.97949999999999993E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.98050000000000015E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.98149999999999993E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.98250000000000015E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.98349999999999993E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.98450000000000015E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.98549999999999993E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.98650000000000015E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.98749999999999993E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.98850000000000016E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.98949999999999994E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.99050000000000016E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.99149999999999994E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.99250000000000016E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.99349999999999994E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.99450000000000016E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.99549999999999994E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.99650000000000016E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.99749999999999994E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.99850000000000017E+00 0.00000000000000000E+00 0.10000000000000000E-02 0.99949999999999994E+00 0.00000000000000000E+00 0.10000000000000000E-02
[ "nils.wittemeier@gmail.com" ]
nils.wittemeier@gmail.com
88553ce3a8fb898354e2fd543014801dd976f2c3
767b01aeace632036a0d33c66b940c7381864b09
/GamePlayObserver.cpp
b0340c24965421f1b0b83d74335b5078428d098b
[]
no_license
ChrisOgal/KONYa4
40a3a03ec006a3a8acbbf38ae6fe5c62d6de7d96
e0d6b531a7d58edee46c3e6f95f0bd094794fdec
refs/heads/master
2020-04-09T08:10:46.499090
2018-12-03T22:00:50
2018-12-03T22:00:50
160,185,003
0
0
null
2018-12-03T12:07:44
2018-12-03T12:07:44
null
UTF-8
C++
false
false
625
cpp
// // Created by client on 2018-11-21. // #include "GamePlayObserver.h" void GamePlayObserver::Update() { } void GamePlayObserver::Update(std::string message){ display(message); } void GamePlayObserver::display(std::string message) { cout << " =====> " << _subject->getCurrentPlayer()->getMonster() << ": " << message << endl; } GamePlayObserver::GamePlayObserver() { }; GamePlayObserver::GamePlayObserver(GamePlay* observed) { _subject = observed; _subject->attach(this); } GamePlayObserver::~GamePlayObserver() { _subject->detach(this); } void GamePlayObserver::Update(int cardNumber) { };
[ "dina.sadirmekova@gmail.com" ]
dina.sadirmekova@gmail.com
545a6362c45de12ae2dda54332fc4366a0f9ed9e
b33fe9efadb22204bc1fed1f8773246c028f64b9
/include/Event/TapLandEvent.h
05552d9a7c0b44c2942a74152d37143744e59e07
[]
no_license
Wmaxlees/mtgai
e4ff15bdd6eefc2268f50084f45585f467ef28c4
ea07a03795f4de5bf35559f243a8869fc480d650
refs/heads/master
2020-04-12T05:12:05.577164
2019-01-12T01:04:49
2019-01-12T01:04:49
162,318,151
0
0
null
null
null
null
UTF-8
C++
false
false
540
h
#pragma once #ifndef _H_EVENT_TAPLANDEVENT #define _H_EVENT_TAPLANDEVENT #include "Card/CardInstance.h" #include "Event/EventBase.h" namespace mtg { namespace event { class TapLandEvent : public EventBase { public: TapLandEvent(unsigned char playerIdx, std::shared_ptr<card::CardInstance> card); std::string getType() const override; std::shared_ptr<card::CardInstance> getCard() const; private: unsigned char m_PlayerIdx; std::shared_ptr<card::CardInstance> m_Card; }; } } #endif //_H_EVENT_TAPLANDEVENT
[ "max.lees@gmail.com" ]
max.lees@gmail.com
6201c89b12063f3b936dc421ae771af2998e7f86
820b4dfdeacf99c65e20358d4970922a77be1c10
/Reader/EpubBook.h
d8f4f7f94678d081f576959105e2cbb6521c129d
[]
no_license
songjinxi/Reader
17d2f79c5931102e5d1007079c1c355663647976
fc1c63172358f65c82fab036d02a7d1340d29e44
refs/heads/master
2020-12-12T04:00:44.698220
2020-12-10T16:40:26
2020-12-10T16:40:26
234,037,859
0
0
null
2020-01-15T08:47:59
2020-01-15T08:47:58
null
UTF-8
C++
false
false
1,465
h
#ifndef __EPUB_BOOK_H__ #define __EPUB_BOOK_H__ #include "Book.h" #include <string> #include <map> #include <vector> typedef struct file_data_t { void *data; size_t size; } file_data_t; typedef std::map<std::string, file_data_t> filelist_t; typedef struct mainfest_item_t { std::string id; std::string href; std::string media_type; } mainfest_item_t; typedef std::map<std::string, mainfest_item_t *> mainfest_t; typedef std::vector<std::string> spine_t; typedef struct navpoint_t { std::string id; std::string src; std::string text; int order; } navpoint_t; typedef std::map<std::string, navpoint_t *> navmap_t; typedef struct epub_t { std::string path; std::string ocf; std::string opf; std::string ncx; mainfest_t mainfest; spine_t spine; navmap_t navmap; } epub_t; class EpubBook : public Book { public: EpubBook(); virtual ~EpubBook(); public: virtual book_type_t GetBookType(void); Bitmap * GetCoverImage(void); protected: virtual bool ParserBook(void); void FreeFilelist(void); bool UnzipBook(void); bool ParserOcf(epub_t &epub); bool ParserOpf(epub_t &epub); bool ParserNcx(epub_t &epub); bool ParserOps(file_data_t *fdata, wchar_t **text, int *len, wchar_t **title, int *tlen, bool parsertitle); bool ParserChapters(epub_t &epub); bool ParserCover(epub_t &epub); protected: Bitmap *m_Cover; filelist_t m_flist; }; #endif
[ "binbin.yu@montage-lz.com" ]
binbin.yu@montage-lz.com
fd87a9e4c27df9243b3d2a8d2c94051adb0ae04c
f21ef44c3265e683bd0baf9e2a5cabfdd21f754a
/Dynamic Programming/131. Palindrome Partitioning.cpp
b0a09641a3dc6da47da8083936117b685bdf40db
[]
no_license
Moomyd/LeetCode
c2bd2b4b9dfc0468cce7454ff672e73d3d3c77d4
324d60311c658c67a998fcba1e84f76695650b5e
refs/heads/master
2023-02-26T22:07:43.030873
2021-02-10T16:19:24
2021-02-10T16:19:24
281,713,842
0
0
null
null
null
null
UTF-8
C++
false
false
837
cpp
class Solution { public: vector<vector<string>> partition(string s) { vector<vector<string>> res; vector<string> path; finder(s,0,path,res); return res; } void finder(string s,int p,vector<string> &path,vector<vector<string>>&res){ if(p==s.size()){ res.push_back(path); return ; } for(int i=p;i<s.size();i++){ if(isPalindrome(s.substr(p,i-p+1))){ path.push_back(s.substr(p,i-p+1)); finder(s,i+1,path,res); path.pop_back(); } } } bool isPalindrome(string s){ int f=0; int end=s.size()-1; while(f<end){ if(s[f++]!=s[end--]) return false; } return true; } };
[ "1345449751@qq.com" ]
1345449751@qq.com
d3e8634c84222d2561bdcf1b81273636c5968139
80e17f421b3b1e11baa8c6860532b0803657789f
/demo/Chapter-12/FriendList.cpp
1871f05f0c70317b659d91293c8dac2f9d5c9aff
[]
no_license
TakeOver5/My-C-Notes
be26f2243cd6f5eb31c3e85e4e70f5ee1643405e
8f5a8545288157ce4e5495d91738bbde1c306c94
refs/heads/master
2023-02-23T18:59:47.733031
2018-11-12T20:11:45
2018-11-12T20:11:45
126,676,278
1
0
null
null
null
null
UTF-8
C++
false
false
3,956
cpp
/* * 時間:2018/10/12 * 功能: * 添加好友名單與輸出好友名單。 * 目的: * 使用 fprint() 與 fscanf() 串流輸出入函式。 */ #include <stdio.h> #include <stdlib.h> typedef struct friends{ char name[10]; char phone[15]; char birth[15]; } FRIENDS; void show(char *); void enter(char *); int main(void){ char ch; char LIST[] = "FriendList.txt"; while(1){ printf("請問您要 1)輸出好友名單 2)新增好友資料:"); scanf("%c", &ch); if(ch == '1') show(LIST); else if(ch == '2') enter(LIST); /* 由於 scanf 本身的問題,在 scanf 成功回傳之後 stdin 裡面可能還有一些不正確的資料 若是不使用 fflush(stdin),再次呼叫 scanf 的話 這些不正確的資料,就可能會讓 scanf 失敗,或回傳不正確的東西 */ /* 但 fflush 不應該用在 stdin 而是 stdout 某些編譯器可能不持支這個語法 */ //fflush(stdin); /* C 語言把鍵盤,顯示器等設備當做文件來處理。 也就是說從鍵盤輸入相當於從一個文件中讀入;向顯示器輸出相當向一個文件寫出 而 stdin 是 C 標準庫定義的標準文件之一,它與鍵盤相關聯, 我一般把它理解為指向鍵盤這個「文件」的指針。 而 rewind() 函式的作用是把文件的當前位罝指針指向文件頭。 上述兩者結合,rewind(stdin) 的作用, 也就是把「指向鍵盤(一個文件)的指針從當前位置挪到鍵盤(一個文件)開頭」, 相當於拋棄當前鍵盤暫存區中的數據,重新開始輸入。 */ rewind(stdin); } system("pause"); return 0; } void show(char *fn){ FRIENDS f; FILE *fp; if((fp = fopen(fn, "r")) == NULL){ printf("將檔案開啟錯誤!\n"); return; } /* 從指標文件 fp 的文件中(fp), 按控制格式讀取數據("%s"),存取到對應的變數中(f.name) */ while(fscanf(fp, "%s", f.name) != EOF){ fscanf(fp, "%s", f.phone); fscanf(fp, "%s", f.birth); printf("===================================\n"); printf("%10s 的電話:%-15s\n", f.name, f.phone); printf("%10s 的生日:%-15s\n", f.name, f.birth); } printf("===================================\n"); fclose(fp); } void enter(char *fn){ FRIENDS temp; FILE *fp; fp = fopen(fn, "a"); printf("請輸入名稱:"); scanf("%s", temp.name); /* 將 temp.name 的資料,寫入文件指標 fp 指向的文件中 因為 fscanf 函式,遇到空白會停止,所以在控制字串中加入空白("%s "),分隔資料 */ fprintf(fp, "%s ", temp.name); printf("請輸入電話號碼:"); scanf("%s", temp.phone); fprintf(fp, "%s ", temp.phone); printf("請輸入生日:"); scanf("%s", temp.birth); fprintf(fp, "%s\n", temp.birth); fclose(fp); } /* ------------ 在 cmd 的輸出結果 --------------- 請問您要 1)輸出好友名單 2)新增好友資料:2 請輸入名稱:LISA 請輸入電話號碼:0909090909 請輸入生日:1994/12/12 請問您要 1)輸出好友名單 2)新增好友資料:2 請輸入名稱:PETER 請輸入電話號碼:0911111111 請輸入生日:1003/03/13 請問您要 1)輸出好友名單 2)新增好友資料:1 =================================== LISA 的電話:0909090909 LISA 的生日:1994/12/12 =================================== PETER 的電話:0911111111 PETER 的生日:1003/03/13 =================================== ---------------------------------------------- */
[ "tapirusindicus5@gmail.com" ]
tapirusindicus5@gmail.com
f111ef46ca420f836759cec28da6c3f92c39549a
002b8a23926c577b69603998d7db15a1c2c7813c
/src/chap-05/OperOverAssignComplex/main.cpp
0592c5fdb1742610738f3610895869f240ec014a
[]
no_license
jin519/ThisIsCPlusPlus
5d86114fd2bdbd1a35bbb3990eaab550d265260a
0c8dd4e42f7d6637a72e39533ebedd71fa3049e3
refs/heads/master
2021-05-23T11:37:49.304003
2020-05-31T15:17:23
2020-05-31T15:17:23
253,268,472
4
1
null
null
null
null
UHC
C++
false
false
687
cpp
// 248p += 연산자 함수 추가 #include <iostream> using namespace std; class MyData { public: MyData(const int data) { __pData = new int(data); } ~MyData() { delete __pData; } operator int() { return *__pData; } MyData& operator=(const MyData& rhs) { if (this == &rhs) return *this; delete __pData; __pData = new int(*rhs.__pData); return *this; } MyData& operator+=(const MyData& rhs) { int* pData = new int(*__pData); *pData += *(rhs.__pData); delete __pData; __pData = pData; return *this; } private: int* __pData = nullptr; }; int main() { MyData a(0), b(5), c(10); a += b; a += c; cout << a << endl; return 0; }
[ "godjin519@gmail.com" ]
godjin519@gmail.com
7fd1a1fd438fd8d5fc53255adc2d483a398c2e65
7527a2a652a545244560ef623c50ebd708baaf64
/morphac/mechanics/models/include/diffdrive_model.h
baf87b174f7cb4fe2792862b91a4c9c990e1336b
[ "MIT" ]
permissive
shrenikm/Morphac
976d305aa7e42ad466edc8a68a9350b2acc200c4
5a5623e641b5bf4f4a5226233d3ac5c321656932
refs/heads/master
2023-01-11T05:57:58.140218
2020-10-09T07:59:51
2020-10-09T07:59:51
211,552,686
1
0
MIT
2022-12-27T15:44:00
2019-09-28T19:38:20
C++
UTF-8
C++
false
false
925
h
#ifndef DIFFDRIVE_MODEL_H #define DIFFDRIVE_MODEL_H #include "Eigen/Dense" #include "common/error_handling/include/error_macros.h" #include "mechanics/models/include/kinematic_model.h" #include "utils/include/angle_utils.h" namespace morphac { namespace mechanics { namespace models { class DiffdriveModel : public morphac::mechanics::models::KinematicModel { public: DiffdriveModel(const double radius, const double width); morphac::constructs::State ComputeStateDerivative( const morphac::constructs::State& state, const morphac::constructs::ControlInput& control_input) const override; morphac::constructs::State NormalizeState( const morphac::constructs::State& state) const override; morphac::robot::blueprint::Footprint DefaultFootprint() const override; const double radius; const double width; }; } // namespace models } // namespace mechanics } // namespace morphac #endif
[ "shrenik95@gmail.com" ]
shrenik95@gmail.com
67c5a3b8ddfd7267ba9f8c40984a6f795e52f91d
5dd6758fec7818c74c59ba03f8834e645454b4f9
/examples/asciiIO/pzxRobot/pzxRobot.ino
569ec2f1bde1b8e9d8b91a3510391956b9abd221
[ "BSD-3-Clause" ]
permissive
ethanjli/liquid-handling-robotics
9ef0dc5fb15ac7aa84d996935801b1c6062f90b0
fc7043558072e77981206ae123dfd3a24ef89029
refs/heads/master
2022-05-09T19:19:47.142416
2022-04-11T23:51:42
2022-04-11T23:51:42
116,604,013
0
1
BSD-3-Clause
2021-05-29T22:37:03
2018-01-07T22:26:54
HTML
UTF-8
C++
false
false
1,043
ino
#define DISABLE_LOGGING #define LHR_Messaging_ASCIIIO #define LHR_Protocol_Core #define LHR_Protocol_Board #define LHR_Protocol_AbsoluteLinearActuatorAxis #define LHR_Protocol_CumulativeLinearActuatorAxis #include <LiquidHandlingRobotics.h> #define LHR_Standard_pipettorAxis #define LHR_Standard_zAxis //#define LHR_Standard_yAxis #define LHR_Standard_xAxis #include <StandardLiquidHandlingRobot.h> LHR_instantiateMessaging(transport, messager); LHR_instantiateBasics(core, board); LHR_instantiateAxes(pipettorAxis, zAxis, yAxis, yAxisCalibrator, xAxis, xAxisCalibrator, messager, motors); void setup() { LHR_setupMessaging(transport, messager, core); LHR_setupBasics(core, board); LHR_setupAxes(pipettorAxis, zAxis, yAxis, yAxisCalibrator, xAxis, xAxisCalibrator); LHR_connect(transport, messager, core, board, pipettorAxis, zAxis, yAxis, yAxisCalibrator, xAxis, xAxisCalibrator); } void loop() { LHR_updateMessaging(transport, messager); LHR_updateBasics(core, board); LHR_updateAxes(pipettorAxis, zAxis, yAxis, xAxis); }
[ "lietk12@gmail.com" ]
lietk12@gmail.com
0383adfab0b5c876f1093d53aa515976fce5f577
05fbc783910e2b851455b8f130315e45ca4dc963
/Graph/Level of Nodes.cpp
339e906bf56ce9abdeadbff0523920615b794d4c
[]
no_license
SandeepMaithani/Amazon_DSA_Series
c92d0e28d1a367c67109bf4eecac51edd4c9bb0e
031d89c25a2be4632488078ae1a2a92e44e61500
refs/heads/master
2023-02-21T19:50:42.018132
2021-01-18T15:14:48
2021-01-18T15:14:48
308,928,222
1
0
null
null
null
null
UTF-8
C++
false
false
1,454
cpp
/* Complexity Analysis :- Time Complexity: O(N). In BFS traversal every node is visited only once, so Time Complexity is O(N). Space Complexity: O(N). The space is required to store the nodes in a queue. */ /* Intution :- Key idea here is to use BFS(Breadth-First Search) traversal, it is a graph traversal technique where a node and its neighbours are visited first and then the neighbours of neighbours. In simple terms, it traverses level-wise from the source. First, it traverses level 1 nodes (direct neighbours of source node) and then level 2 nodes (neighbours of source node) and so on. We will mark each node to its respective level from source node and using that marking BFS can be used to determine the level of each node from a given source node. */ int levels(vector<int> g[], int N, int X) { queue<pair<int, int>>bfsHelper; vector<bool>visited(N, false); bfsHelper.push({0, 0}); while (!bfsHelper.empty()) { int currNode = bfsHelper.front().first; int currLevel = bfsHelper.front().second; bfsHelper.pop(); if (visited[currNode] == true) { continue; } visited[currNode] = true; if (currNode == X) { return currLevel; } for (auto neighbour : g[currNode]) { if (visited[neighbour] == false) { bfsHelper.push({neighbour, currLevel + 1}); } } } return -1; }
[ "sandeep1137@gmail.com" ]
sandeep1137@gmail.com
b9d9a382389d8b14162b268550def8a963ccccbb
5d83739af703fb400857cecc69aadaf02e07f8d1
/Archive2/5a/13b9cae19de234/main.cpp
130d331b49fa31b8b3fd3e0962ea71bc51c315d0
[]
no_license
WhiZTiM/coliru
3a6c4c0bdac566d1aa1c21818118ba70479b0f40
2c72c048846c082f943e6c7f9fa8d94aee76979f
refs/heads/master
2021-01-01T05:10:33.812560
2015-08-24T19:09:22
2015-08-24T19:09:22
56,789,706
3
0
null
null
null
null
UTF-8
C++
false
false
384
cpp
#include <iostream> enum class PaintColor{ BLACK=0, PINK=1, ORANGE=2 }; enum class Vehicle : char{ //Vehicle is 1 byte size CAR=0, JET=1, BOAT=2 }; int main() { PaintColor p; p = PaintColor::PINK; Vehicle v; v = Vehicle::BOAT; std::cout << (int)p << std::endl; std::cout << (int)v<< std::endl; std::cout << sizeof(v)<< std::endl; }
[ "francis.rammeloo@36614edc-3e3a-acb8-9062-c8ae0e4185df" ]
francis.rammeloo@36614edc-3e3a-acb8-9062-c8ae0e4185df
ef20cfd61aa9e833ba6b76915251e0bffda20275
fc1fc1fb369153c2cd19cd1940150a87ccb6094e
/tiny_obj_loader.cc
b73e76628cfecaedee549adf5b0c6e9766d017bc
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
lighttransport/obj2eson
e55f0d56c06568d04637d1f15628c24daf60866a
bc5ebfe3559446d9d8077c7cb8150039b749322b
refs/heads/master
2016-09-06T19:42:20.598135
2014-12-25T07:19:30
2014-12-25T07:19:30
20,096,447
5
0
null
null
null
null
UTF-8
C++
false
false
17,375
cc
// // Copyright 2012-2013, Syoyo Fujita. // // Licensed under 2-clause BSD liecense. // // // version 0.9.7: Support multi-materials(per-face material ID) per object/group. // version 0.9.6: Support Ni(index of refraction) mtl parameter. // Parse transmittance material parameter correctly. // version 0.9.5: Parse multiple group name. // Add support of specifying the base path to load material file. // version 0.9.4: Initial suupport of group tag(g) // version 0.9.3: Fix parsing triple 'x/y/z' // version 0.9.2: Add more .mtl load support // version 0.9.1: Add initial .mtl load support // version 0.9.0: Initial // #include <cstdlib> #include <cstring> #include <cassert> #include <string> #include <vector> #include <map> #include <fstream> #include <sstream> #include "tiny_obj_loader.h" namespace tinyobj { struct vertex_index { int v_idx, vt_idx, vn_idx; vertex_index() {}; vertex_index(int idx) : v_idx(idx), vt_idx(idx), vn_idx(idx) {}; vertex_index(int vidx, int vtidx, int vnidx) : v_idx(vidx), vt_idx(vtidx), vn_idx(vnidx) {}; }; // for std::map static inline bool operator<(const vertex_index& a, const vertex_index& b) { if (a.v_idx != b.v_idx) return (a.v_idx < b.v_idx); if (a.vn_idx != b.vn_idx) return (a.vn_idx < b.vn_idx); if (a.vt_idx != b.vt_idx) return (a.vt_idx < b.vt_idx); return false; } struct obj_shape { std::vector<float> v; std::vector<float> vn; std::vector<float> vt; }; static inline bool isSpace(const char c) { return (c == ' ') || (c == '\t'); } static inline bool isNewLine(const char c) { return (c == '\r') || (c == '\n') || (c == '\0'); } // Make index zero-base, and also support relative index. static inline int fixIndex(int idx, int n) { int i; if (idx > 0) { i = idx - 1; } else if (idx == 0) { i = 0; } else { // negative value = relative i = n + idx; } return i; } static inline std::string parseString(const char*& token) { std::string s; int b = strspn(token, " \t"); int e = strcspn(token, " \t\r"); s = std::string(&token[b], &token[e]); token += (e - b); return s; } static inline int parseInt(const char*& token) { token += strspn(token, " \t"); int i = atoi(token); token += strcspn(token, " \t\r"); return i; } static inline float parseFloat(const char*& token) { token += strspn(token, " \t"); float f = (float)atof(token); token += strcspn(token, " \t\r"); return f; } static inline void parseFloat2( float& x, float& y, const char*& token) { x = parseFloat(token); y = parseFloat(token); } static inline void parseFloat3( float& x, float& y, float& z, const char*& token) { x = parseFloat(token); y = parseFloat(token); z = parseFloat(token); } // Parse triples: i, i/j/k, i//k, i/j static vertex_index parseTriple( const char* &token, int vsize, int vnsize, int vtsize) { vertex_index vi(-1); vi.v_idx = fixIndex(atoi(token), vsize); token += strcspn(token, "/ \t\r"); if (token[0] != '/') { return vi; } token++; // i//k if (token[0] == '/') { token++; vi.vn_idx = fixIndex(atoi(token), vnsize); token += strcspn(token, "/ \t\r"); return vi; } // i/j/k or i/j vi.vt_idx = fixIndex(atoi(token), vtsize); token += strcspn(token, "/ \t\r"); if (token[0] != '/') { return vi; } // i/j/k token++; // skip '/' vi.vn_idx = fixIndex(atoi(token), vnsize); token += strcspn(token, "/ \t\r"); return vi; } static unsigned int updateVertex( std::map<vertex_index, unsigned int>& vertexCache, std::vector<float>& positions, std::vector<float>& normals, std::vector<float>& texcoords, const std::vector<float>& in_positions, const std::vector<float>& in_normals, const std::vector<float>& in_texcoords, const vertex_index& i) { const std::map<vertex_index, unsigned int>::iterator it = vertexCache.find(i); if (it != vertexCache.end()) { // found cache return it->second; } assert(in_positions.size() > (unsigned int) (3*i.v_idx+2)); positions.push_back(in_positions[3*i.v_idx+0]); positions.push_back(in_positions[3*i.v_idx+1]); positions.push_back(in_positions[3*i.v_idx+2]); if (i.vn_idx >= 0) { normals.push_back(in_normals[3*i.vn_idx+0]); normals.push_back(in_normals[3*i.vn_idx+1]); normals.push_back(in_normals[3*i.vn_idx+2]); } if (i.vt_idx >= 0) { texcoords.push_back(in_texcoords[2*i.vt_idx+0]); texcoords.push_back(in_texcoords[2*i.vt_idx+1]); } unsigned int idx = positions.size() / 3 - 1; vertexCache[i] = idx; return idx; } void InitMaterial(material_t& material) { material.name = ""; material.ambient_texname = ""; material.diffuse_texname = ""; material.specular_texname = ""; material.normal_texname = ""; for (int i = 0; i < 3; i ++) { material.ambient[i] = 0.f; material.diffuse[i] = 0.f; material.specular[i] = 0.f; material.transmittance[i] = 0.f; material.emission[i] = 0.f; } material.illum = 0; material.dissolve = 1.f; material.shininess = 1.f; material.ior = 1.f; material.unknown_parameter.clear(); } static bool exportFaceGroupToShape( shape_t& shape, std::map<vertex_index, unsigned int> vertexCache, const std::vector<float> &in_positions, const std::vector<float> &in_normals, const std::vector<float> &in_texcoords, const std::vector<std::vector<vertex_index> >& faceGroup, const int material_id, const std::string &name, bool clearCache) { if (faceGroup.empty()) { return false; } // Flatten vertices and indices for (size_t i = 0; i < faceGroup.size(); i++) { const std::vector<vertex_index>& face = faceGroup[i]; vertex_index i0 = face[0]; vertex_index i1(-1); vertex_index i2 = face[1]; size_t npolys = face.size(); // Polygon -> triangle fan conversion for (size_t k = 2; k < npolys; k++) { i1 = i2; i2 = face[k]; unsigned int v0 = updateVertex(vertexCache, shape.mesh.positions, shape.mesh.normals, shape.mesh.texcoords, in_positions, in_normals, in_texcoords, i0); unsigned int v1 = updateVertex(vertexCache, shape.mesh.positions, shape.mesh.normals, shape.mesh.texcoords, in_positions, in_normals, in_texcoords, i1); unsigned int v2 = updateVertex(vertexCache, shape.mesh.positions, shape.mesh.normals, shape.mesh.texcoords, in_positions, in_normals, in_texcoords, i2); shape.mesh.indices.push_back(v0); shape.mesh.indices.push_back(v1); shape.mesh.indices.push_back(v2); shape.mesh.material_ids.push_back(material_id); } } shape.name = name; if (clearCache) vertexCache.clear(); return true; } std::string LoadMtl ( std::map<std::string, int>& material_map, std::vector<material_t>& materials, std::istream& inStream) { material_map.clear(); std::stringstream err; material_t material; int maxchars = 8192; // Alloc enough size. std::vector<char> buf(maxchars); // Alloc enough size. while (inStream.peek() != -1) { inStream.getline(&buf[0], maxchars); std::string linebuf(&buf[0]); // Trim newline '\r\n' or '\n' if (linebuf.size() > 0) { if (linebuf[linebuf.size()-1] == '\n') linebuf.erase(linebuf.size()-1); } if (linebuf.size() > 0) { if (linebuf[linebuf.size()-1] == '\r') linebuf.erase(linebuf.size()-1); } // Skip if empty line. if (linebuf.empty()) { continue; } // Skip leading space. const char* token = linebuf.c_str(); token += strspn(token, " \t"); assert(token); if (token[0] == '\0') continue; // empty line if (token[0] == '#') continue; // comment line // new mtl if ((0 == strncmp(token, "newmtl", 6)) && isSpace((token[6]))) { // flush previous material. if (!material.name.empty()) { material_map.insert(std::pair<std::string, int>(material.name, materials.size())); materials.push_back(material); } // initial temporary material InitMaterial(material); // set new mtl name char namebuf[4096]; token += 7; sscanf(token, "%s", namebuf); material.name = namebuf; continue; } // ambient if (token[0] == 'K' && token[1] == 'a' && isSpace((token[2]))) { token += 2; float r, g, b; parseFloat3(r, g, b, token); material.ambient[0] = r; material.ambient[1] = g; material.ambient[2] = b; continue; } // diffuse if (token[0] == 'K' && token[1] == 'd' && isSpace((token[2]))) { token += 2; float r, g, b; parseFloat3(r, g, b, token); material.diffuse[0] = r; material.diffuse[1] = g; material.diffuse[2] = b; continue; } // specular if (token[0] == 'K' && token[1] == 's' && isSpace((token[2]))) { token += 2; float r, g, b; parseFloat3(r, g, b, token); material.specular[0] = r; material.specular[1] = g; material.specular[2] = b; continue; } // transmittance if (token[0] == 'K' && token[1] == 't' && isSpace((token[2]))) { token += 2; float r, g, b; parseFloat3(r, g, b, token); material.transmittance[0] = r; material.transmittance[1] = g; material.transmittance[2] = b; continue; } // ior(index of refraction) if (token[0] == 'N' && token[1] == 'i' && isSpace((token[2]))) { token += 2; material.ior = parseFloat(token); continue; } // emission if(token[0] == 'K' && token[1] == 'e' && isSpace(token[2])) { token += 2; float r, g, b; parseFloat3(r, g, b, token); material.emission[0] = r; material.emission[1] = g; material.emission[2] = b; continue; } // shininess if(token[0] == 'N' && token[1] == 's' && isSpace(token[2])) { token += 2; material.shininess = parseFloat(token); continue; } // illum model if (0 == strncmp(token, "illum", 5) && isSpace(token[5])) { token += 6; material.illum = parseInt(token); continue; } // dissolve if ((token[0] == 'd' && isSpace(token[1]))) { token += 1; material.dissolve = parseFloat(token); continue; } if (token[0] == 'T' && token[1] == 'r' && isSpace(token[2])) { token += 2; material.dissolve = parseFloat(token); continue; } // ambient texture if ((0 == strncmp(token, "map_Ka", 6)) && isSpace(token[6])) { token += 7; material.ambient_texname = token; continue; } // diffuse texture if ((0 == strncmp(token, "map_Kd", 6)) && isSpace(token[6])) { token += 7; material.diffuse_texname = token; continue; } // specular texture if ((0 == strncmp(token, "map_Ks", 6)) && isSpace(token[6])) { token += 7; material.specular_texname = token; continue; } // normal texture if ((0 == strncmp(token, "map_Ns", 6)) && isSpace(token[6])) { token += 7; material.normal_texname = token; continue; } // unknown parameter const char* _space = strchr(token, ' '); if(!_space) { _space = strchr(token, '\t'); } if(_space) { int len = _space - token; std::string key(token, len); std::string value = _space + 1; material.unknown_parameter.insert(std::pair<std::string, std::string>(key, value)); } } // flush last material. material_map.insert(std::pair<std::string, int>(material.name, materials.size())); materials.push_back(material); return err.str(); } std::string MaterialFileReader::operator() ( const std::string& matId, std::vector<material_t>& materials, std::map<std::string, int>& matMap) { std::string filepath; if (!m_mtlBasePath.empty()) { filepath = std::string(m_mtlBasePath) + matId; } else { filepath = matId; } std::ifstream matIStream(filepath.c_str()); return LoadMtl(matMap, materials, matIStream); } std::string LoadObj( std::vector<shape_t>& shapes, std::vector<material_t>& materials, // [output] const char* filename, const char* mtl_basepath) { shapes.clear(); std::stringstream err; std::ifstream ifs(filename); if (!ifs) { err << "Cannot open file [" << filename << "]" << std::endl; return err.str(); } std::string basePath; if (mtl_basepath) { basePath = mtl_basepath; } MaterialFileReader matFileReader( basePath ); return LoadObj(shapes, materials, ifs, matFileReader); } std::string LoadObj( std::vector<shape_t>& shapes, std::vector<material_t>& materials, // [output] std::istream& inStream, MaterialReader& readMatFn) { std::stringstream err; std::vector<float> v; std::vector<float> vn; std::vector<float> vt; std::vector<std::vector<vertex_index> > faceGroup; std::string name; // material std::map<std::string, int> material_map; std::map<vertex_index, unsigned int> vertexCache; int material = -1; shape_t shape; int maxchars = 8192; // Alloc enough size. std::vector<char> buf(maxchars); // Alloc enough size. while (inStream.peek() != -1) { inStream.getline(&buf[0], maxchars); std::string linebuf(&buf[0]); // Trim newline '\r\n' or '\n' if (linebuf.size() > 0) { if (linebuf[linebuf.size()-1] == '\n') linebuf.erase(linebuf.size()-1); } if (linebuf.size() > 0) { if (linebuf[linebuf.size()-1] == '\r') linebuf.erase(linebuf.size()-1); } // Skip if empty line. if (linebuf.empty()) { continue; } // Skip leading space. const char* token = linebuf.c_str(); token += strspn(token, " \t"); assert(token); if (token[0] == '\0') continue; // empty line if (token[0] == '#') continue; // comment line // vertex if (token[0] == 'v' && isSpace((token[1]))) { token += 2; float x, y, z; parseFloat3(x, y, z, token); v.push_back(x); v.push_back(y); v.push_back(z); continue; } // normal if (token[0] == 'v' && token[1] == 'n' && isSpace((token[2]))) { token += 3; float x, y, z; parseFloat3(x, y, z, token); vn.push_back(x); vn.push_back(y); vn.push_back(z); continue; } // texcoord if (token[0] == 'v' && token[1] == 't' && isSpace((token[2]))) { token += 3; float x, y; parseFloat2(x, y, token); vt.push_back(x); vt.push_back(y); continue; } // face if (token[0] == 'f' && isSpace((token[1]))) { token += 2; token += strspn(token, " \t"); std::vector<vertex_index> face; while (!isNewLine(token[0])) { vertex_index vi = parseTriple(token, v.size() / 3, vn.size() / 3, vt.size() / 2); face.push_back(vi); int n = strspn(token, " \t\r"); token += n; } faceGroup.push_back(face); continue; } // use mtl if ((0 == strncmp(token, "usemtl", 6)) && isSpace((token[6]))) { char namebuf[4096]; token += 7; sscanf(token, "%s", namebuf); faceGroup.clear(); if (material_map.find(namebuf) != material_map.end()) { material = material_map[namebuf]; } else { // { error!! material not found } material = -1; } continue; } // load mtl if ((0 == strncmp(token, "mtllib", 6)) && isSpace((token[6]))) { char namebuf[4096]; token += 7; sscanf(token, "%s", namebuf); std::string err_mtl = readMatFn(namebuf, materials, material_map); if (!err_mtl.empty()) { faceGroup.clear(); // for safety return err_mtl; } continue; } // group name if (token[0] == 'g' && isSpace((token[1]))) { // flush previous face group. bool ret = exportFaceGroupToShape(shape, vertexCache, v, vn, vt, faceGroup, material, name, true); if (ret) { shapes.push_back(shape); } shape = shape_t(); //material = -1; faceGroup.clear(); std::vector<std::string> names; while (!isNewLine(token[0])) { std::string str = parseString(token); names.push_back(str); token += strspn(token, " \t\r"); // skip tag } assert(names.size() > 0); // names[0] must be 'g', so skipt 0th element. if (names.size() > 1) { name = names[1]; } else { name = ""; } continue; } // object name if (token[0] == 'o' && isSpace((token[1]))) { // flush previous face group. bool ret = exportFaceGroupToShape(shape, vertexCache, v, vn, vt, faceGroup, material, name, true); if (ret) { shapes.push_back(shape); } //material = -1; faceGroup.clear(); shape = shape_t(); // @todo { multiple object name? } char namebuf[4096]; token += 2; sscanf(token, "%s", namebuf); name = std::string(namebuf); continue; } // Ignore unknown command. } bool ret = exportFaceGroupToShape(shape, vertexCache, v, vn, vt, faceGroup, material, name, true); if (ret) { shapes.push_back(shape); } faceGroup.clear(); // for safety return err.str(); } }
[ "syoyo@lighttransport.com" ]
syoyo@lighttransport.com
afe4808413da2678bbff9d2efb2322cf783a92ab
817cc371e2eb56f37c400b7f96d658d0683476b1
/202005_practice/atcoder_train/agc043_d.cpp
2a987fcaecc015b9b3b859bb669e0af05ea03dfe
[]
no_license
KanadeSiina/PracticeCode
c696495bd71395648ac62a41d0a41869f50c5eb4
146c8d5889eee7917a355feb8b03d1415a29ae9d
refs/heads/master
2020-09-05T00:49:29.165600
2020-06-30T12:48:15
2020-06-30T12:48:15
219,937,221
2
0
null
null
null
null
UTF-8
C++
false
false
5,751
cpp
/* Aa^~ kokoro ga pyonpyon suru n jaa^~ // ZZZXXkXkkkZ!``` ``` ``` ``` ``` ``` ``` ``` ``` ``` ``` ```?Wfpppbpbbpbbpbbbkbkk // ppbbbpbbpVr`` `` ` ` ` ` ```` `` ` ` `` ` ` ` ` ` ` ` ` ` dppbbkkkkkkkkkkqkqkk // HkqqqqqkkWr`` ` ` ``` ``` `?G, ` ` ``.JC!```` ` ` `` `` ````(Wpbkkkkkkkkqkkkkkqk // mmmmmqqqqpr` `` `` ```````.+zT=`` `` 7TO-.```````` `` `` ```(yppbkkkkkkkkkkkkkkk // ggmgmmqqqH$ ``````````....````` ` ````````.`````` `` ``````.yfpppbbbbkkkkqqqqqH // gmmmmmqqqkW<```` `````...````` .,.` ````....````` ``````` (Wbqqmgmmgmggggggggg // qmmmqqqqkkWk.``````````````````` ;:<`` `````.`````````````-_<-?WHHqmmmmmmgmmgggg // @@@@@@@gggHH6- ``````````````` `` _ `` ```````````````` ._~~_.`-?Wkqmmmmmmmggg@g // @@@@g@gggHY~.-<_- `````````````````````````````````` ._~~(<-``.`.(WHqqqmmggggmmm // @@g@gggHH=.`..._<-___..```````````````````````. .-_~~~_(!``-.``.`` OHHWUWHmqHWXW // gggggmqK1.``..~.. _<<+-(____.. ```````` ..__~~_((<<!.`.``` .``.`` j0C1XUHmHIdW // ggmmqH0!,_``.>`````` _<<;<v<<<++((((((((((<<<<<<~_. (-.``~``.>..``` jOuWHHqHIdH // gmmqkW!`(_ J>` `` ` _~<`_~~~~<<<<<<<~~__````````` ?1. ._`(__``` zXWHg@HkXH // gHHWS{``(lJ<!``.``.```(:+>`._`````.` <..`` - ``. ` _ ?&._.I`_`````` .XyVfppppW // HHHSv``.(X:_..... _..(;+<!.(<..-.....-.-_..+_`..<.`.`..`_IJd} .`..````jqg@@@@@@ // XHWZ{..<Jk~!.`.. (<.-(+>(_.(1.(_..`.`.`.<_.+<_..<<-..._..-zy>.`_`...```.WH@HHHHH // bkWt~.-jCz(_..`.(+<.(;< ._-<=_(<_..-....(_.<1<..(<<.`._..-JUS-._.`...```dHmH9VUH // WUUO..(f.(c...__+z<-(+~` _-+<_(><..__.`.(<._.z_.(1;_..__.(C(zT-(..`...``(WHR<+Xk // kkkk._(_.->..._(z;:_><.._>_+_<(1>_._<...(v<<.(<.(+z<..-_(Z~_<_j+_..`...`(WHKz1ZW // @@gR._+_..~..-<+z<<?<>```_.<_.(+1><_;_..(1_:`.<<??1z--(+Z!..<_.j<....`..(bgHAAQX // @@mR.(j:..~.._<z!`.(>~``` ~(_.(+<1><><_.(((_`.<__`.<_.(X>...<_.(<.....`.JUWWWyWW // @gmH_(zl..(.._+>```<+_````.~>``(+.<?>>_._(<```(<<``(__<>....<.._<.......dXkkkHHH // mmqHl(dk_.(_.-=~`.`.1-..._~-1.``_:`(??<_~(`.--.&_.`.<(;<...._.._<..`..._Xg@@@@@@ // qHkpk(dX<.(;..j_```.(((JJ&a&-~``````.1<_```-(((e+.-(/`(>...._..(<......(Wmggg@@g // HVHbWcz><__+_.(_.(dWWHHH@HHc~````````.+~`` (jHMMMHHHm&.?..._<..(<_..._.(WqqHHmHg // 0>vWWkzZwl~<o.__`__~X@@HM@Hb ```.`.``. ```` d@@HHH@@K?76...(<..(<_...(_(ppWWWWHq // X0XWHKXXw$<(z<.( `` WHHMHHHH_``````````````.WHHMNMHHH_`(...(<_.(z_..._<(fWVC174W // XuXWHHWWz>__+z+.!`..??CZYCOX_`````````````.`~.OvTUZUS_`~.._+?_.(_~_.._zjO=1+~+jy // kkkkkkkkX:._<z=1(_`` << ``->``.``.``.``.```` ?<`` (v!`._..(??_.(1._.._=dUOOzzzwX // @@@@@@@@H<...1O=v<_...__ -_````````````````.`` `` ~.`` :.~+=?~.(;_(...jdQQQQQkkk // H@@@@@@@H~...(==>.~~~~~....`.`````````.`````.`........->.(===~~<<.(...(dg@@@@@@@ // @@@H@@HHH_.__(=l>~.~~~~~....``.``.``.```..`......~~~~~(<_+=l=~_<.->..~_dqggggg@g // @H@@@@MHH_._<(=l>...........```````````````.`...~~~~~~+<(=lz=~((j=z_..~jWqmmgggm // @@H@@HHWH_._<(lll-.......```.````.``.`..`````........_z<+llZz~(lOO=<...(VYUUUW9Y // @@HMMHWZf>~_=:=llw+.`````````.`.```__~~_``.`````.....(z+llOOz_zllOlz~..~<<1+dW>_ // MMM#MHHWXl~_=>1ltwOl&.`.``.`````.``````````````.````.(llttwtz(OltwOz<..__zwOwwOz // HM#HMHUUI<._1z+ttOZttlt&....``.``.`.````.``...``...(zZtttOktzjttttwlz_._<(Xkkkkk // HHHmHSZu:(_~+OztttXtttOZZttO+-..............-(+ztOttwttttd0tOZttttwOl<~.(_dMMHHH // rvuuXuuI~~<~(uttttwvOwwwkQQHMMHHHHHHHHHMMMNmgey?OwwwrtttwXOtwttttttXtO-~.((wZyyy // HHHHHHK>(~(-(dOrtrrl(QgMHMMMHHHHHHHHHHHHHHHH##HMNkX0rrrrXXrd%`` (Ctwwtz_~.<(Wg@H // NNNNNHD(~(zo~zXrrrQdHHMMNMHHHHHHHHHHHHHHHHHHHHHH##HNmyrdKkwZ ` _``-zwrt1~~_<(MNM // MMMMM#<<_jwr:(Z4QHHMMHMHHHHHHHHHHHHHHHHHHHHHHHHHHHH###NHSXZ>` ~````.OXtt>~._<?MM */ #include<bits/stdc++.h> using namespace std; #ifndef ONLINE_JUDGE #define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0) void err() { cout << "\033[39;0m" << endl; } template<template<typename...> class T, typename t, typename... A> void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); } template<typename T, typename... A> void err(T a, A... x) { cout << a << ' '; err(x...); } #else #define dbg(...) #endif typedef long long ll; typedef pair<int,int> pi; typedef vector<int> vi; template<class T> using vc=vector<T>; template<class T> using vvc=vc<vc<T>>; template<class T> void mkuni(vector<T>&v) { sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end()); } ll rand_int(ll l, ll r) //[l, r] { static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count()); return uniform_int_distribution<ll>(l, r)(gen); } template<class T> void print(T x,int suc=1) { cout<<x; if(suc==1) cout<<'\n'; else cout<<' '; } template<class T> void print(const vector<T>&v,int suc=1) { for(int i=0;i<v.size();i++) print(v[i],i==(int)(v.size())-1?suc:2); } const int maxn=6005; ll dp[maxn][2*maxn]; ll quick(ll a,ll b,int mod) { ll ret=1; while(b) { if(b&1) ret=ret*a%mod; a=a*a%mod; b>>=1; } return ret; } ll inv[maxn]; int main() { int n,m; cin>>n>>m; for(int i=0;i<maxn;i++) inv[i]=quick(i,m-2,m); n*=3; const int var=maxn; dp[0][var]=1; for(int i=1;i<=n;i++) { for(int k=1;k<=3;k++) { if(i-k<0) continue; for(int j=0;j<2*maxn;j++) { if(!dp[i-k][j]) continue; int delta=k==1?1:(k==2?-1:0); dp[i][j+delta]=(dp[i][j+delta]+dp[i-k][j]*inv[i])%m; //dbg(i,j+delta,dp[i][j+delta],dp[i-k][j]); } } } ll fac=1; for(int i=1;i<=n;i++) fac=fac*i%m; ll ans=0; for(int i=var;i<maxn*2;i++) ans=(ans+dp[n][i]*fac%m)%m; print(ans); }
[ "lluozheyan@gmail.com" ]
lluozheyan@gmail.com
ce4bfd66150df7745581ddd7fcce791a2ab0b512
a0e71eef6163725c53f11ed6b43e89ddaf9993c3
/main.cpp
ec2438bd1647c72a290810661401ee0f2df790d4
[]
no_license
viktand/vap2
316c26d6074d012a7137a57db5336ae300d40afe
888b2798a32fc3d13bc319d0a6862d44dfbc82da
refs/heads/master
2016-08-04T10:24:58.103210
2013-09-11T12:48:29
2013-09-11T12:48:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
535
cpp
#include "mainwindow.h" #include <QApplication> #include <iostream> // временно !!! using namespace std; // временно !!! int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; w.cou_prm=argc; if (argc>1) for (int i = 0; i < argc; i++) { // Выводим список аргументов в цикле cout << "Argument " << i << " : " << argv[i] << endl; w.prm<<argv[i]; } w.show(); w.on_show(); return a.exec(); }
[ "viktand@bk.ru" ]
viktand@bk.ru
4963f79d91efc3f236a4c94882e2501bcf1607c8
c30d4130c348a2bcf9ab6f847a03fd1d0fed78b4
/ProProg/sum.cpp
53b162b09c0fb831d495918a5a8ff44ebb5c9634
[]
no_license
boyplus/competitive-programming
6278c5f9c93ce830b62aa16ed4877dc82f5dd538
88ead4fddb09ac2ca658ad291c0fc6e8679eedda
refs/heads/master
2022-11-07T05:31:34.004320
2020-06-28T16:09:58
2020-06-28T16:09:58
67,353,435
0
0
null
null
null
null
UTF-8
C++
false
false
820
cpp
#include <cstdio> #include <limits.h> #include <algorithm> #include <cstring> using namespace std; bool chk[10000000]; int arr[20000]; int main(){ int n; while(scanf("%d",&n) != EOF){ int Min = INT_MAX,want,ans1=0,ans2=0; for(int i=0;i<n;i++){ scanf("%d",&arr[i]); chk[arr[i]] = true; } scanf("%d",&want); sort(arr,arr+n); for(int i=0;i<n;i++){ int diff = want - arr[i]; if(diff >= 0){ if(chk[diff] == true){ int temp = arr[i] - diff; if(temp < 0){ temp = temp*-1; } if(temp < Min){ ans1 = arr[i]; ans2 = diff; Min = temp; } } } } if(ans1 > ans2){ int temp = ans1; ans1 = ans2; ans2 = temp; } printf("Peter should buy books whose prices are %d and %d.\n\n",ans1,ans2); memset(chk,false,sizeof(chk)); } return 0; }
[ "ict224bj@gmail.com" ]
ict224bj@gmail.com
6998733e9a311217c576e6b2cf42220354403e58
5fe6563b77647d2dcaa69f0d9ed6cf3ae388b737
/badgy_1.ino
6a31b7c879ef793a997c14d0aad758c0cd3b3de7
[]
no_license
yurikoex/badgy_game
55f55aafccfe01fb78249c9e16297e643179d43d
eb5df219208d81d511e07943db980d8dbf1b0d5a
refs/heads/master
2020-03-26T11:32:22.089255
2018-08-15T12:02:41
2018-08-15T12:02:41
144,847,647
0
0
null
null
null
null
UTF-8
C++
false
false
5,558
ino
/* e-paper display lib */ #include <GxEPD.h> #include <GxGDEH029A1/GxGDEH029A1.cpp> #include <GxIO/GxIO_SPI/GxIO_SPI.cpp> #include <GxIO/GxIO.cpp> /* include any other fonts you want to use https://github.com/adafruit/Adafruit-GFX-Library */ #include <Fonts/Picopixel.h> /* WiFi libs*/ #include <ESP8266WiFi.h> #include <WiFiClient.h> #include <DNSServer.h> #include <ESP8266WebServer.h> #include <ESP8266HTTPUpdateServer.h> #include <WiFiManager.h> #include <Hash.h> extern "C" { #include "user_interface.h" } #include <avr/pgmspace.h> /* Always include the update server, or else you won't be able to do OTA updates! */ /**/const int port = 8888; /**/ESP8266WebServer httpServer(port); /**/ESP8266HTTPUpdateServer httpUpdater; /* Configure pins for display */ GxIO_Class io(SPI, SS, 0, 2); GxEPD_Class display(io); // default selection of D4, D2 byte buttonState = 0; byte lastButtonState = 0; unsigned long lastDebounceTime = 0; unsigned long debounceDelay = 50; const uint8_t offsetx = 8; const uint8_t offsety = 18; const uint8_t columns = 7; const uint8_t rows = 16; const uint8_t gridSize = 16; const uint8_t width = 122; const uint8_t height = 250; uint8_t playerx = 4; uint8_t playery = 9; const GFXfont* font = &Picopixel; char cstr[16]; void setup(){ display.init(); pinMode(1,INPUT_PULLUP); //down pinMode(3,INPUT_PULLUP); //left pinMode(5,INPUT_PULLUP); //center pinMode(12,INPUT_PULLUP); //right pinMode(10,INPUT_PULLUP); //up /* Enter OTA mode if the center button is pressed */ if(digitalRead(5) == 0){ /* WiFi Manager automatically connects using the saved credentials, if that fails it will go into AP mode */ WiFiManager wifiManager; wifiManager.setAPCallback(configModeCallback); wifiManager.autoConnect("Badgy AP"); /* Once connected to WiFi, startup the OTA update server if the center button is held on boot */ httpUpdater.setup(&httpServer); httpServer.begin(); showIP(); while(1){ httpServer.handleClient(); } } update(); } void showIP(){ clearScreen(); setFont(); String url = WiFi.localIP().toString() + ":"+String(port)+"/update"; byte charArraySize = url.length() + 1; char urlCharArray[charArraySize]; url.toCharArray(urlCharArray, charArraySize); showText(urlCharArray, 0, 10); display.update(); } void configModeCallback (WiFiManager *myWiFiManager){ display.setRotation(3); //even = portrait, odd = landscape display.fillScreen(GxEPD_WHITE); const GFXfont* f = &Picopixel ; display.setTextColor(GxEPD_BLACK); display.setFont(f); display.setCursor(0,50); display.println("Connect to Badgy AP"); display.println("to setup your WiFi!"); display.update(); } void clearScreen(){ display.setRotation(2); //display.fillScreen(GxEPD_WHITE); } void setFont(){ display.setTextColor(GxEPD_BLACK); display.setFont(font); } void showMemory(){ showText(itoa(system_get_free_heap_size(), cstr, 10),1,5); } void showText(char* text, uint8_t x, uint8_t y){ setFont(); display.setCursor(x,y); display.println(text); } void drawSquare(uint8_t x, uint8_t y){ for(uint16_t i=0; i < gridSize; i++){ display.drawPixel(offsetx+(x*gridSize)+i, offsety+(y*gridSize), GxEPD_BLACK); display.drawPixel(offsetx+(x*gridSize)+i, offsety+(y*gridSize)+gridSize, GxEPD_BLACK); display.drawPixel(offsetx+(x*gridSize), offsety+(y*gridSize)+i, GxEPD_BLACK); display.drawPixel(offsetx+(x*gridSize)+gridSize, offsety+(y*gridSize)+i, GxEPD_BLACK); } } void drawGrid(){ for (uint8_t x=0; x < columns; x++){ for (uint8_t y=0; y < rows; y++){ drawSquare(x,y); } } } const unsigned char player[] PROGMEM = { 0xff, 0xff, 0xe7, 0xdb, 0xdb, 0xe7, 0xff, 0xff }; void drawPlayer(){ display.drawBitmap(player, offsetx+(playerx*gridSize)+4, offsety+(playery*gridSize)+4, 8, 8, GxEPD_BLACK); // display.drawPixel(offsetx+(playerx*gridSize)+(gridSize/2), offsety+(playery*gridSize)+(gridSize/2), GxEPD_BLACK); } void update() { clearScreen(); showMemory(); drawGrid(); drawPlayer(); display.update(); } void loop() { byte reading = (digitalRead(1) == 0 ? 0 : (1<<0)) | //down (digitalRead(3) == 0 ? 0 : (1<<1)) | //left (digitalRead(5) == 0 ? 0 : (1<<2)) | //center (digitalRead(12) == 0 ? 0 : (1<<3)) | //right (digitalRead(10) == 0 ? 0 : (1<<4)); //up if(reading != lastButtonState){ lastDebounceTime = millis(); } if((millis() - lastDebounceTime) > debounceDelay){ if(reading != buttonState){ buttonState = reading; for(int i=0; i<5; i++){ if(bitRead(buttonState, i) == 0){ switch(i){ case 0: //left if(playerx > 0 && playerx < columns){ playerx--; } break; case 1: //up if(playery > 0 && playery < rows){ playery--; } break; case 2: playerx = 4; playery = 9; break; case 3: //down if(playery <= rows){ playery++; } break; case 4: //right if(playerx <= columns){ playerx++; } break; default: break; } } } update(); } } lastButtonState = reading; }
[ "josh_lunsford@homedepot.com" ]
josh_lunsford@homedepot.com
f4c82e9a8c64f90fbf63d4d5577fa3f803523b40
ff3b513ffe0925bba25cf0af4c62ea846388339b
/VereEngine/BodyMesh.cpp
f4c34f319b9d57ac94577a36ddd8cf9634fc60e9
[ "Zlib", "MIT" ]
permissive
VereWolf/VereEngine
9b311796fbd2c4919040c8ce93a1272a42713e80
6b5453554cef1ef5d5dbf58206806198a3beec35
refs/heads/master
2021-07-18T13:32:31.815101
2017-12-24T21:15:08
2017-12-24T21:15:08
94,897,016
4
1
null
2017-11-22T13:09:45
2017-06-20T13:55:34
C++
UTF-8
C++
false
false
7,395
cpp
#include "pch.h" #include "Vertex.h" #include "Effects.h" #include "GenerateMesh.h" #include "Camera.h" #include "LoadVMB.h" #include "BodyMesh.h" BodyMesh::BodyMesh() { XMMATRIX I = XMMatrixIdentity(); XMStoreFloat4x4(&mMesh, I); mTS.x = 0.0f; mTS.y = 0.01f; //mBodyBase = new BodyBase; } void BodyMesh::Draw(ID3D11Device* device, ID3D11DeviceContext* dc, Camera *cam, btTransform transform) { if (mTS.x < 0.0f || mTS.x > 1.0f) mTS.y *= -1.0f; mTS.x += mTS.y; XMMATRIX view = cam->View(); dc->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); dc->IASetInputLayout(InputLayouts::Body); UINT stride = sizeof(Vertex::Body); XMMATRIX M = XMLoadFloat4x4(&VereMath::ConvertToXMFLOAT4X4(transform)); for (UINT n = 0; n < mVMBmat.size(); ++n) { UINT offset = 0; dc->IASetVertexBuffers(0, 1, &mVB, &stride, &offset); dc->IASetIndexBuffer(mIB, DXGI_FORMAT_R32_UINT, 0); ID3DX11EffectTechnique* activeTech = Effects::BodyFX->Light1Tech; D3DX11_TECHNIQUE_DESC techDesc; activeTech->GetDesc(&techDesc); XMFLOAT3 EyePos = { 0.0f, 0.0f, 0.0f }; XMFLOAT3 dir = VereMath::ConvertToXMFLOAT3(transform.getOrigin().normalize()); Effects::BodyFX->SetEyePosW(dir); Effects::BodyFX->SetMaterial(mVMBmat.at(n).material); Effects::BodyFX->SetViewProj(cam->ViewProj()); Effects::BodyFX->SetWorld(M); Effects::BodyFX->SetWorldN(M); //Effects::BodyFX->SetDiffuseMap(mDiffuseMapSRV[n]); //Effects::BodyFX->SetSpecularMap(mSpecularMapSRV[n]); //Effects::BodyFX->SetNormalMap(mNormalMapSRV[n]); //Effects::BodyFX->SetIsDiffuseMap(isDiffuseMap.at(n)); //Effects::BodyFX->SetIsSpecularMap(isSpecularMap.at(n)); //Effects::BodyFX->SetIsNormalMap(isNormalMap.at(n)); Effects::BodyFX->SetTS(mTS.x); for (UINT p = 0; p < techDesc.Passes; ++p) { activeTech->GetPassByIndex(p)->Apply(0, dc); dc->DrawIndexed(3 * mVMBmat.at(n).faceCount, 3 * mVMBmat.at(n).faceStart, 0); } } } bool BodyMesh::CreateSphere(ID3D11Device* device, float diameter, int numGridInRow) { /*mVMBmat.resize(1); mVMBmat.at(0).faceCount = 1200; mVMBmat.at(0).faceStart = 0; mVMBmat.at(0).d = 0.0f; mVMBmat.at(0).material.Ambient = XMFLOAT4(0.3f, 0.3f, 0.3f, 1.0f); mVMBmat.at(0).material.Diffuse = XMFLOAT4(0.3f, 0.3f, 0.3f, 1.0f); mVMBmat.at(0).material.Specular = XMFLOAT4(0.3f, 0.3f, 0.3f, 1.0f); mVMBmat.at(0).material.Reflect = XMFLOAT4(0.3f, 0.3f, 0.3f, 1.0f); GenerateMesh::GenerateSphere(diameter, numGridInRow, XMFLOAT3(0.0f, 0.0f, 0.0f), mVertices, mIndices); if (!BuildVerticesBuffer(device, &mVertices)) return false; if (!BuildIndicesBuffer(device, &mIndices)) return false; /mDiffuseMapSRV.resize(mVMBmat.size()); mSpecularMapSRV.resize(mVMBmat.size()); mNormalMapSRV.resize(mVMBmat.size()); isDiffuseMap.resize(mVMBmat.size()); isSpecularMap.resize(mVMBmat.size()); isNormalMap.resize(mVMBmat.size()); for (UINT i = 0; i < mVMBmat.size(); ++i) { isDiffuseMap.at(i) = false; isSpecularMap.at(i) = false; isNormalMap.at(i) = false; }*/ return true; } bool BodyMesh::CreateObject(ID3D11Device* device, std::string filePath, std::wstring texturePath, std::string nameFile) { std::vector<Vertex::Body> itsVertices; std::vector<UINT> itsIndices; VMBLoader mBodyBase; if (!mBodyBase.LoadVMB(nameFile.insert(0, filePath), &itsVertices, &itsIndices, &mVMBmat)) return false; if (!BuildVerticesBuffer(device, &itsVertices)) return false; if (!BuildIndicesBuffer(device, &itsIndices)) return false; mDiffuseMapSRV.resize(mVMBmat.size()); mSpecularMapSRV.resize(mVMBmat.size()); mNormalMapSRV.resize(mVMBmat.size()); isDiffuseMap.resize(mVMBmat.size()); isSpecularMap.resize(mVMBmat.size()); isNormalMap.resize(mVMBmat.size()); for (UINT i = 0; i < mVMBmat.size(); ++i) { mVMBmat.at(i).paths.at(1).insert(0, texturePath); mVMBmat.at(i).paths.at(1).replace(mVMBmat.at(i).paths.at(1).end() - 3, mVMBmat.at(i).paths.at(1).end(), L"dds"); mVMBmat.at(i).paths.at(2) = mVMBmat.at(i).paths.at(1); mVMBmat.at(i).paths.at(2).replace(mVMBmat.at(i).paths.at(2).end() - 5, mVMBmat.at(i).paths.at(2).end() - 4, L"S"); mVMBmat.at(i).paths.at(5) = mVMBmat.at(i).paths.at(1); mVMBmat.at(i).paths.at(5).replace(mVMBmat.at(i).paths.at(5).end() - 5, mVMBmat.at(i).paths.at(5).end() - 4, L"N"); //if (FAILED(D3DX11CreateShaderResourceViewFromFile(device, mVMBmat.at(i).paths.at(1).c_str(), 0, 0, &mDiffuseMapSRV.at(i), 0))) { isDiffuseMap.at(i) = false; } /*else { isDiffuseMap.at(i) = true; }*/ //if (FAILED(D3DX11CreateShaderResourceViewFromFile(device, mVMBmat.at(i).paths.at(2).c_str(), 0, 0, &mSpecularMapSRV.at(i), 0))) { isSpecularMap.at(i) = false; } /*else { isSpecularMap.at(i) = true; }*/ //if (FAILED(D3DX11CreateShaderResourceViewFromFile(device, mVMBmat.at(i).paths.at(5).c_str(), 0, 0, &mNormalMapSRV.at(i), 0))) { isNormalMap.at(i) = false; } /*else { isNormalMap.at(i) = true; }*/ } return true; } bool BodyMesh::BuildVerticesBuffer(ID3D11Device* device) { D3D11_BUFFER_DESC vertexBuffer; vertexBuffer.Usage = D3D11_USAGE_DEFAULT; vertexBuffer.ByteWidth = sizeof(Vertex::Body) * mVertices.size(); vertexBuffer.BindFlags = D3D11_BIND_VERTEX_BUFFER; vertexBuffer.CPUAccessFlags = 0; vertexBuffer.MiscFlags = 0; vertexBuffer.StructureByteStride = 0; D3D11_SUBRESOURCE_DATA vinitData; vinitData.pSysMem = &mVertices.at(0); if (FAILED(device->CreateBuffer(&vertexBuffer, &vinitData, &mVB))) return false; return true; } bool BodyMesh::BuildVerticesBuffer(ID3D11Device* device, std::vector<Vertex::Body> *vertices) { D3D11_BUFFER_DESC vertexBuffer; vertexBuffer.Usage = D3D11_USAGE_DEFAULT; vertexBuffer.ByteWidth = sizeof(Vertex::Body) * vertices->size(); vertexBuffer.BindFlags = D3D11_BIND_VERTEX_BUFFER; vertexBuffer.CPUAccessFlags = 0; vertexBuffer.MiscFlags = 0; vertexBuffer.StructureByteStride = 0; D3D11_SUBRESOURCE_DATA vinitData; vinitData.pSysMem = &vertices->at(0); if (FAILED(device->CreateBuffer(&vertexBuffer, &vinitData, &mVB))) return false; return true; } bool BodyMesh::BuildIndicesBuffer(ID3D11Device* device) { D3D11_BUFFER_DESC indexBuffer; indexBuffer.Usage = D3D11_USAGE_DEFAULT; indexBuffer.ByteWidth = sizeof(UINT) * mIndices.size(); indexBuffer.BindFlags = D3D11_BIND_INDEX_BUFFER; indexBuffer.CPUAccessFlags = 0; indexBuffer.MiscFlags = 0; indexBuffer.StructureByteStride = 0; D3D11_SUBRESOURCE_DATA iinitData; iinitData.pSysMem = &mIndices.at(0); if (FAILED(device->CreateBuffer(&indexBuffer, &iinitData, &mIB))) return false; return true; } bool BodyMesh::BuildIndicesBuffer(ID3D11Device* device, std::vector<UINT> *indices) { D3D11_BUFFER_DESC indexBuffer; indexBuffer.Usage = D3D11_USAGE_DEFAULT; indexBuffer.ByteWidth = sizeof(UINT) * indices->size(); indexBuffer.BindFlags = D3D11_BIND_INDEX_BUFFER; indexBuffer.CPUAccessFlags = 0; indexBuffer.MiscFlags = 0; indexBuffer.StructureByteStride = 0; D3D11_SUBRESOURCE_DATA iinitData; iinitData.pSysMem = &indices->at(0); if (FAILED(device->CreateBuffer(&indexBuffer, &iinitData, &mIB))) return false; return true; }
[ "noreply@github.com" ]
noreply@github.com
e65da660b8487471ba196961cc3edd3432931261
67c7802255237bc9f9c785b8c6c6b2347518fbe3
/MinimumBias/Minbias.cxx
2b6771eb7191b58aa683267a18c7a99c8486ee8c
[]
no_license
Erdbeergeist/HadronicRecoil
78eab5093b6f79d098c883dbcfb2f64db85454c8
3ba449e71bfedce57f3ff1bbdfd3c6c78eac8829
refs/heads/master
2021-01-23T02:29:01.537907
2015-07-22T15:22:51
2015-07-22T15:22:51
33,138,344
2
0
null
null
null
null
UTF-8
C++
false
false
4,527
cxx
/// Lukas Mittnacht March 2015 #include <stdlib.h> #include "./EWCommonIncludes.h" #include <cmath> using namespace std; using std::vector; #include "./setbranches.h" #include "./minhists.h" #include "./Minbias_functions.h" int main(int argc, char *argv[]) { if (argc < 3){ ///Check Parameters cout<<"Please specify Input and Output Files as Parameters.\n"; return 1; } ///Declare neccessary Variables int totalEvents,ZMmin=0,ZMmax=1000000,totalZ=0; bool isZ = false; bool Zfilt = true; string infile = argv[1]; ///Declare I/O Files const char* outfile = argv[2]; ///If a 3rd Argument is given check if it is "0" and if it is do not ///filter for ZEvents (MinimumBias) if (argc == 4){ string arg3 = argv[3]; if (arg3 == "0"){ Zfilt = false; } } /// Open Input ROOT File TFile *fileI = new TFile(infile.c_str(),"READ"); if (fileI->IsOpen()) cout<<"File "<<infile<<" opened successfully.\n"; /// Create Output File TFile *fileO = new TFile(outfile,"RECREATE"); if (fileO->IsOpen()) cout<<"File "<<outfile<<" created successfully.\n"; ///List fileI contents fileI->ls(); /// Create TTree from file1 TTree *tree = (TTree*) fileI->Get("MainzCaloCells"); ///Set Branch Addresses setbranches(tree); /// Check all Events totalEvents = tree->GetEntries(); cout<<"A total of: "<< totalEvents<<" Events have been found. \n"; Hists hist; ///Event Loop for (int i=0;i<totalEvents;i++) { tree->GetEntry(i); /// Wether or not to check ZEvents if (Zfilt == true){ for (int cond=0;cond<5;cond++){ TLorentzVector recoZ; ///Check for ZEvents with the given Minimum & Maximum Mass switch (cond) { case 0: isZ = Zcheck(mu_charge,mu_pt,mu_eta,mu_phi,recoZ,ZMmin,ZMmax,&hist); hist.FillZHists(mu_pt->size(),0,0,0); break; case 1: isZ = Zcheck(mu_charge,mu_pt,mu_eta,mu_phi,recoZ,10,20,&hist); break; case 2: isZ = Zcheck(mu_charge,mu_pt,mu_eta,mu_phi,recoZ,5,10,&hist); break; case 3: isZ = Zcheck(mu_charge,mu_pt,mu_eta,mu_phi,recoZ,2,5,&hist); break; case 4: isZ = Zcheck(mu_charge,mu_pt,mu_eta,mu_phi,recoZ,ZMmin,2,&hist); break; } if (isZ == true) { ///Initialize the Vectors and assign the values TVector3 mu1,mu2,Zvec,hadrec; mu1.SetPtEtaPhi(mu_pt->at(0),mu_eta->at(0),mu_phi->at(0)); mu2.SetPtEtaPhi(mu_pt->at(1),mu_eta->at(1),mu_phi->at(1)); Zvec.SetPtEtaPhi(recoZ.Pt(),recoZ.Eta(),recoZ.Phi()); ///Contains ALL Tracks (also Tracks that have not been associated) vector<double> sumpt = sumtrackpt(all_prim_track_pt,all_pile_track_pt,all_track_pt); vector<double> vecsumpt = vecsumtrackpt(all_prim_track_pt,all_prim_track_eta,all_prim_track_phi,all_pile_track_pt,all_pile_track_eta,all_pile_track_phi,all_track_pt,all_track_eta,all_track_phi,mu_pt,mu_eta,mu_phi); ///subtract the muons for (int i=0;i<mu_pt->size();i++){ sumpt[0] = sumpt[0]- mu_pt->at(i)/1000; //sumpt[1] = sumpt[1]- mu_pt->at(i)/1000; sumpt[2] = sumpt[2]- mu_pt->at(i)/1000; } if (cond == 0) { ///Hadronic Recoil calculated by adding up everything but muons hadrec = calcHadronicRecoil(vecCellsPt,vecCellsEta,vecCellsPhi,mu1,mu2); hist.FillHadrecHists(hadrec,sumpt,Zvec.Pt()); hist.Fill2DZHists(recoZ,NumberOfVertices,hadrec); hist.FillZHists(0,recoZ.Pt()/1000,recoZ.M()/1000,1); hist.FillVecSum(hadrec,vecsumpt,Zvec); } hist.FillHists(NumberOfVertices,averageNumberOfInteractions,sumpt,cond); isZ = false; } } } ///NO check for ZEvents, take every event (MinimumBias) else if (Zfilt == false) { vector<double> sumpt; TLorentzVector recoZ; isZ = Zcheck(mu_charge,mu_pt,mu_eta,mu_phi,recoZ,ZMmin,ZMmax,&hist); /// No Condition sumpt = sumtrackpt(all_prim_track_pt,all_pile_track_pt,all_track_pt); for (int i=0;i<mu_pt->size();i++){ sumpt[0] = sumpt[0]- mu_pt->at(i)/1000; //sumpt[1] = sumpt[1]- mu_pt->at(i)/1000; sumpt[2] = sumpt[2]- mu_pt->at(i)/1000; } hist.FillHists(NumberOfVertices,averageNumberOfInteractions,sumpt,0); } ///Check the Track Association and Fill the correct histograms checkassociation(&hist,countPVvec,countSVvec,vecCellsPt,vecCellsEta,vecCellsPhi,NumberOfVertices); } //cout<<"A total of: "<<totalZ<<" Z Events have been found\n"; hist.WriteFile(fileO); }
[ "luxmitges@web.de" ]
luxmitges@web.de
f60499e2aec4f5cb3a9d8d83c85a9d57d36831f5
fa236f75a0096a75f155672b6bc0dea149b22ba0
/Number.h
f20ae136a92d25ad2ad78ac69b5e3bd9d2da4798
[]
no_license
rahulpau-l/sorting-visualizer
dfd1b8d0ae3cc8a8263158edfef019dffa7f7675
7a351df705e6a299c56e99b08613712d79b7fd76
refs/heads/main
2023-05-31T17:09:44.675747
2021-05-30T01:35:09
2021-05-30T01:35:09
369,656,726
0
0
null
null
null
null
UTF-8
C++
false
false
314
h
// // Created by Rahul on 2021-05-20. // #ifndef NUMBER_H #define NUMBER_H #include <SFML/Graphics.hpp> class Number { public: int num{}; sf::RectangleShape rect; Number(); Number(const Number &n); void setNum(int c); void setSize(sf::Vector2<float> &&dimension); }; #endif //NUMBER_H
[ "70454548+rahulpau-l@users.noreply.github.com" ]
70454548+rahulpau-l@users.noreply.github.com
505520258d926fe283dec37b256b97d7aa8a560e
1d928c3f90d4a0a9a3919a804597aa0a4aab19a3
/c++/electron/2017/4/common_web_contents_delegate.h
27209411c72b1b7bdd5c75c1feebb2c727197c59
[ "MIT" ]
permissive
rosoareslv/SED99
d8b2ff5811e7f0ffc59be066a5a0349a92cbb845
a062c118f12b93172e31e8ca115ce3f871b64461
refs/heads/main
2023-02-22T21:59:02.703005
2021-01-28T19:40:51
2021-01-28T19:40:51
306,497,459
1
1
null
2020-11-24T20:56:18
2020-10-23T01:18:07
null
UTF-8
C++
false
false
6,949
h
// Copyright (c) 2015 GitHub, Inc. // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. #ifndef ATOM_BROWSER_COMMON_WEB_CONTENTS_DELEGATE_H_ #define ATOM_BROWSER_COMMON_WEB_CONTENTS_DELEGATE_H_ #include <map> #include <string> #include <vector> #include "brightray/browser/devtools_file_system_indexer.h" #include "brightray/browser/inspectable_web_contents_delegate.h" #include "brightray/browser/inspectable_web_contents_impl.h" #include "brightray/browser/inspectable_web_contents_view_delegate.h" #include "content/public/browser/web_contents_delegate.h" using brightray::DevToolsFileSystemIndexer; namespace atom { class AtomBrowserContext; class AtomJavaScriptDialogManager; class NativeWindow; class WebDialogHelper; class CommonWebContentsDelegate : public content::WebContentsDelegate, public brightray::InspectableWebContentsDelegate, public brightray::InspectableWebContentsViewDelegate { public: CommonWebContentsDelegate(); virtual ~CommonWebContentsDelegate(); // Creates a InspectableWebContents object and takes onwership of // |web_contents|. void InitWithWebContents(content::WebContents* web_contents, AtomBrowserContext* browser_context); // Set the window as owner window. void SetOwnerWindow(NativeWindow* owner_window); void SetOwnerWindow(content::WebContents* web_contents, NativeWindow* owner_window); // Returns the WebContents managed by this delegate. content::WebContents* GetWebContents() const; // Returns the WebContents of devtools. content::WebContents* GetDevToolsWebContents() const; brightray::InspectableWebContents* managed_web_contents() const { return web_contents_.get(); } NativeWindow* owner_window() const { return owner_window_.get(); } bool is_html_fullscreen() const { return html_fullscreen_; } protected: // content::WebContentsDelegate: content::WebContents* OpenURLFromTab( content::WebContents* source, const content::OpenURLParams& params) override; bool CanOverscrollContent() const override; content::JavaScriptDialogManager* GetJavaScriptDialogManager( content::WebContents* source) override; content::ColorChooser* OpenColorChooser( content::WebContents* web_contents, SkColor color, const std::vector<content::ColorSuggestion>& suggestions) override; void RunFileChooser(content::RenderFrameHost* render_frame_host, const content::FileChooserParams& params) override; void EnumerateDirectory(content::WebContents* web_contents, int request_id, const base::FilePath& path) override; void EnterFullscreenModeForTab(content::WebContents* source, const GURL& origin) override; void ExitFullscreenModeForTab(content::WebContents* source) override; bool IsFullscreenForTabOrPending( const content::WebContents* source) const override; blink::WebSecurityStyle GetSecurityStyle( content::WebContents* web_contents, content::SecurityStyleExplanations* explanations) override; void HandleKeyboardEvent( content::WebContents* source, const content::NativeWebKeyboardEvent& event) override; // brightray::InspectableWebContentsDelegate: void DevToolsSaveToFile(const std::string& url, const std::string& content, bool save_as) override; void DevToolsAppendToFile(const std::string& url, const std::string& content) override; void DevToolsRequestFileSystems() override; void DevToolsAddFileSystem(const base::FilePath& path) override; void DevToolsRemoveFileSystem( const base::FilePath& file_system_path) override; void DevToolsIndexPath(int request_id, const std::string& file_system_path) override; void DevToolsStopIndexing(int request_id) override; void DevToolsSearchInPath(int request_id, const std::string& file_system_path, const std::string& query) override; // brightray::InspectableWebContentsViewDelegate: #if defined(TOOLKIT_VIEWS) gfx::ImageSkia GetDevToolsWindowIcon() override; #endif #if defined(USE_X11) void GetDevToolsWindowWMClass( std::string* name, std::string* class_name) override; #endif // Destroy the managed InspectableWebContents object. void ResetManagedWebContents(); private: // Callback for when DevToolsSaveToFile has completed. void OnDevToolsSaveToFile(const std::string& url); // Callback for when DevToolsAppendToFile has completed. void OnDevToolsAppendToFile(const std::string& url); // void OnDevToolsIndexingWorkCalculated(int request_id, const std::string& file_system_path, int total_work); void OnDevToolsIndexingWorked(int request_id, const std::string& file_system_path, int worked); void OnDevToolsIndexingDone(int request_id, const std::string& file_system_path); void OnDevToolsSearchCompleted(int request_id, const std::string& file_system_path, const std::vector<std::string>& file_paths); // Set fullscreen mode triggered by html api. void SetHtmlApiFullscreen(bool enter_fullscreen); // The window that this WebContents belongs to. base::WeakPtr<NativeWindow> owner_window_; // Whether window is fullscreened by HTML5 api. bool html_fullscreen_; // Whether window is fullscreened by window api. bool native_fullscreen_; std::unique_ptr<WebDialogHelper> web_dialog_helper_; std::unique_ptr<AtomJavaScriptDialogManager> dialog_manager_; scoped_refptr<DevToolsFileSystemIndexer> devtools_file_system_indexer_; // Make sure BrowserContext is alwasys destroyed after WebContents. scoped_refptr<AtomBrowserContext> browser_context_; // The stored InspectableWebContents object. // Notice that web_contents_ must be placed after dialog_manager_, so we can // make sure web_contents_ is destroyed before dialog_manager_, otherwise a // crash would happen. std::unique_ptr<brightray::InspectableWebContents> web_contents_; // Maps url to file path, used by the file requests sent from devtools. typedef std::map<std::string, base::FilePath> PathsMap; PathsMap saved_files_; // Map id to index job, used for file system indexing requests from devtools. typedef std::map< int, scoped_refptr<DevToolsFileSystemIndexer::FileSystemIndexingJob>> DevToolsIndexingJobsMap; DevToolsIndexingJobsMap devtools_indexing_jobs_; DISALLOW_COPY_AND_ASSIGN(CommonWebContentsDelegate); }; } // namespace atom #endif // ATOM_BROWSER_COMMON_WEB_CONTENTS_DELEGATE_H_
[ "rodrigosoaresilva@gmail.com" ]
rodrigosoaresilva@gmail.com
e78193889958517ffca3d44f01c850d2767df79a
773e31eeaa8711e82915f0038684005eb22471a6
/Marlin_pantalla_12864_23042015/vector_3.cpp
a96602a5ee581491fa1ef02795949f68140726e1
[]
no_license
Shiul93/3D-Configuration
a6315b45777c1072082bea65e1c041132057fe83
cddecca40ef98ea245d57f8a8a75a43620395be2
refs/heads/master
2021-04-09T17:52:38.428558
2018-07-20T10:26:08
2018-07-20T10:26:08
125,875,373
0
0
null
null
null
null
UTF-8
C++
false
false
4,723
cpp
/* vector_3.cpp - Vector library for bed leveling Copyright (c) 2012 Lars Brubaker. All right reserved. 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 <math.h> #include "Marlin.h" #ifdef ENABLE_AUTO_BED_LEVELING #include "vector_3.h" vector_3::vector_3() { this->x = 0; this->y = 0; this->z = 0; } vector_3::vector_3(float x, float y, float z) { this->x = x; this->y = y; this->z = z; } vector_3 vector_3::cross(vector_3 left, vector_3 right) { return vector_3(left.y * right.z - left.z * right.y, left.z * right.x - left.x * right.z, left.x * right.y - left.y * right.x); } vector_3 vector_3::operator+(vector_3 v) { return vector_3((x + v.x), (y + v.y), (z + v.z)); } vector_3 vector_3::operator-(vector_3 v) { return vector_3((x - v.x), (y - v.y), (z - v.z)); } vector_3 vector_3::get_normal() { vector_3 normalized = vector_3(x, y, z); normalized.normalize(); return normalized; } float vector_3::get_length() { float length = sqrt((x * x) + (y * y) + (z * z)); return length; } void vector_3::normalize() { float length = get_length(); x /= length; y /= length; z /= length; } void vector_3::apply_rotation(matrix_3x3 matrix) { float resultX = x * matrix.matrix[3*0+0] + y * matrix.matrix[3*1+0] + z * matrix.matrix[3*2+0]; float resultY = x * matrix.matrix[3*0+1] + y * matrix.matrix[3*1+1] + z * matrix.matrix[3*2+1]; float resultZ = x * matrix.matrix[3*0+2] + y * matrix.matrix[3*1+2] + z * matrix.matrix[3*2+2]; x = resultX; y = resultY; z = resultZ; } void vector_3::debug(char* title) { SERIAL_PROTOCOL(title); SERIAL_PROTOCOLPGM(" x: "); SERIAL_PROTOCOL(x); SERIAL_PROTOCOLPGM(" y: "); SERIAL_PROTOCOL(y); SERIAL_PROTOCOLPGM(" z: "); SERIAL_PROTOCOL(z); SERIAL_PROTOCOLPGM("\n"); } void apply_rotation_xyz(matrix_3x3 matrix, float &x, float& y, float& z) { vector_3 vector = vector_3(x, y, z); vector.apply_rotation(matrix); x = vector.x; y = vector.y; z = vector.z; } matrix_3x3 matrix_3x3::create_from_rows(vector_3 row_0, vector_3 row_1, vector_3 row_2) { //row_0.debug("row_0"); //row_1.debug("row_1"); //row_2.debug("row_2"); matrix_3x3 new_matrix; new_matrix.matrix[0] = row_0.x; new_matrix.matrix[1] = row_0.y; new_matrix.matrix[2] = row_0.z; new_matrix.matrix[3] = row_1.x; new_matrix.matrix[4] = row_1.y; new_matrix.matrix[5] = row_1.z; new_matrix.matrix[6] = row_2.x; new_matrix.matrix[7] = row_2.y; new_matrix.matrix[8] = row_2.z; //new_matrix.debug("new_matrix"); return new_matrix; } void matrix_3x3::set_to_identity() { matrix[0] = 1; matrix[1] = 0; matrix[2] = 0; matrix[3] = 0; matrix[4] = 1; matrix[5] = 0; matrix[6] = 0; matrix[7] = 0; matrix[8] = 1; } matrix_3x3 matrix_3x3::create_look_at(vector_3 target) { vector_3 z_row = target.get_normal(); vector_3 x_row = vector_3(1, 0, -target.x/target.z).get_normal(); vector_3 y_row = vector_3(0, 1, -target.y/target.z).get_normal(); // x_row.debug("x_row"); // y_row.debug("y_row"); // z_row.debug("z_row"); // create the matrix already correctly transposed matrix_3x3 rot = matrix_3x3::create_from_rows(x_row, y_row, z_row); // rot.debug("rot"); return rot; } matrix_3x3 matrix_3x3::transpose(matrix_3x3 original) { matrix_3x3 new_matrix; new_matrix.matrix[0] = original.matrix[0]; new_matrix.matrix[1] = original.matrix[3]; new_matrix.matrix[2] = original.matrix[6]; new_matrix.matrix[3] = original.matrix[1]; new_matrix.matrix[4] = original.matrix[4]; new_matrix.matrix[5] = original.matrix[7]; new_matrix.matrix[6] = original.matrix[2]; new_matrix.matrix[7] = original.matrix[5]; new_matrix.matrix[8] = original.matrix[8]; return new_matrix; } void matrix_3x3::debug(char* title) { SERIAL_PROTOCOL(title); SERIAL_PROTOCOL("\n"); int count = 0; for(int i=0; i<3; i++) { for(int j=0; j<3; j++) { SERIAL_PROTOCOL(matrix[count]); SERIAL_PROTOCOLPGM(" "); count++; } SERIAL_PROTOCOLPGM("\n"); } } #endif // #ifdef ENABLE_AUTO_BED_LEVELING
[ "lfllamas93@gmail.com" ]
lfllamas93@gmail.com
a42fcaa62f9ed822b3a5516aa0a6e862c264f281
cd0448d3790f0a36b1c70d7ca349aae8b1d9da3a
/skeleton_tracking/src/pose.cpp
e8840047c251af7fecdc760605c43f84a4a7f041
[]
no_license
chjXu/multi-human-robot-interaction
ac40e6c9d4191cd8c361bfd5c4697136353ecc19
2ba7758678ec926eb470e163ee1703fbc808e51e
refs/heads/main
2023-06-18T21:55:33.225992
2021-07-27T09:42:30
2021-07-27T09:42:30
382,189,134
4
2
null
null
null
null
UTF-8
C++
false
false
1,236
cpp
#include <human_pose/pose.h> using namespace HumanPose; void Pose_Info::setPose(human_pose_msgs::HumanList human_list, int id){ // topic中的数据都是cm为单位的, in 1920*1080 for(int i=0; i<15; ++i){ pose_3d[i].x = human_list.human_list[id].body_key_points_prob[i].x; pose_3d[i].y = human_list.human_list[id].body_key_points_prob[i].y; pose_3d[i].z = human_list.human_list[id].body_key_points_prob[i].z; pose_3d[i].p = human_list.human_list[id].body_key_points_prob[i].p; pose_3d[i].available = true; } } void Pose_Info::trangulation(Eigen::Matrix3d rot, Eigen::Matrix<double, 3, 1> trans){ if(pose_3d.empty()){ return; } for(int i=0; i<pose_3d.size(); ++i){ Eigen::Matrix<double,3,1> world_point; Eigen::Matrix<double,3,1> cam_point; cam_point(0,0) = pose_3d[i].x / 100.0; cam_point(1,0) = pose_3d[i].y / 100.0; cam_point(2,0) = pose_3d[i].z / 100.0; world_point = rot * cam_point + trans; pose_3d[i].x = world_point(0,0); pose_3d[i].y = world_point(1,0); pose_3d[i].z = world_point(2,0); } } void Pose_Info::setAction(int action){ this->action = action; }
[ "noreply@github.com" ]
noreply@github.com
5f917db2673ca2512ff2a0618ddf9c27f9e2b0fd
a8283ea32c5736dc2cf495acbb1a4809a28e8422
/login.cpp
2fa264f0322b2291befc109b2b88ef37ff14936b
[]
no_license
ereslibre/spokify
5a0c406f99bd8e8c610c9fa039283d7cd7aac8bd
673e3f23f8361561cf72ad4c26a526f514a33e47
refs/heads/master
2020-04-09T12:46:43.751886
2010-11-07T08:00:22
2010-11-07T08:00:22
2,510,590
0
0
null
null
null
null
UTF-8
C++
false
false
2,950
cpp
/* * This file is part of Spokify. * Copyright (C) 2010 Rafael Fernández López <ereslibre@kde.org> * * Spokify 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. * * Spokify 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 Spokify. If not, see <http://www.gnu.org/licenses/>. */ #include "login.h" #include "mainwindow.h" #include <QtGui/QLabel> #include <QtGui/QCheckBox> #include <QtGui/QFormLayout> #include <KLocale> #include <KLineEdit> #include <kwallet.h> Login::Login(MainWindow *mainWindow) : KDialog(mainWindow) , m_username(new KLineEdit(this)) , m_password(new KLineEdit(this)) , m_remember(new QCheckBox(i18n("Remember me"), this)) , m_mainWindow(mainWindow) { setWindowTitle(i18n("Login")); setButtons(KDialog::Ok | KDialog::Cancel); m_password->setEchoMode(KLineEdit::Password); m_remember->setCheckState(Qt::Checked); QWidget *main = new QWidget(this); QFormLayout *layout = new QFormLayout; layout->addRow(i18n("Username"), m_username); layout->addRow(i18n("Password"), m_password); layout->addWidget(m_remember); QLabel *note = new QLabel(i18n("Note that for logging in you need a Premium Account"), main); note->setWordWrap(true); layout->addWidget(note); main->setLayout(layout); connect(this, SIGNAL(okClicked()), SLOT(loginSlot())); setMainWidget(main); m_wallet = KWallet::Wallet::openWallet(KWallet::Wallet::NetworkWallet(), winId()); if (m_wallet) { if (!m_wallet->hasFolder("spokify")) { m_wallet->createFolder("spokify"); } m_wallet->setFolder("spokify"); } } Login::~Login() { } void Login::accept() { if (m_wallet && m_remember->checkState() == Qt::Checked) { QMap<QString, QString> authInfo; authInfo["username"] = m_username->text(); authInfo["password"] = m_password->text(); m_wallet->writeMap("spokify", authInfo); m_wallet->sync(); } KDialog::accept(); } void Login::showEvent(QShowEvent *event) { if (m_wallet) { QMap<QString, QString> authInfo; m_wallet->readMap("spokify", authInfo); m_username->setText(authInfo["username"]); m_password->setText(authInfo["password"]); } KDialog::showEvent(event); } void Login::loginSlot() { //BEGIN: Spotify login sp_session_login(m_mainWindow->session(), m_username->text().toLatin1(), m_password->text().toLatin1()); //END: Spotify login }
[ "ereslibre@ereslibre.es" ]
ereslibre@ereslibre.es
870899199ab1cb49369c9d2cc795bc37700b8c5a
33aeb7cfb53ea3d33d9417a7a557406129e96a79
/BasicPureFunctionAnalysis/BasicPureFunctionAnalysis.cpp
0281c6b31ec94b78853e5572824323c1d3c48631
[]
no_license
someoneb100/KK-seminarski-opt-prolazi
86eae53b2d2f4eb696cf0a0bf477d038e5d58aeb
19432905057fb1c1e3c1bd8cfe1f80b5031cd0d8
refs/heads/master
2022-10-24T16:57:58.935288
2020-06-14T18:08:28
2020-06-14T18:08:28
257,669,433
0
0
null
null
null
null
UTF-8
C++
false
false
4,146
cpp
#include "llvm/IR/LegacyPassManager.h" #include "llvm/Transforms/IPO/PassManagerBuilder.h" #include "../includes/PureCallGraph.hpp" #include "../includes/BasicPureFunctionAnalysis.hpp" #include "../includes/PureFunctionInfo.hpp" #include <map> using namespace std; PureCallGraph graf; map<Function*, PureFunctionInfo*> podaci; set<Value*> globalne; set<Value*> globalneKonstante; bool BasicPureFunctionAnalysis::runOnModule(Module &M) { //provera postojanja globalnih promenljivih auto krajGlobalnih = M.getGlobalList().end(); for(auto it = M.getGlobalList().begin(); it!=krajGlobalnih; it++){ if(it->isConstant()) globalneKonstante.insert(&(*it)); else globalne.insert(&(*it)); } //Punjenje memorije for (auto F = M.begin(); F != M.end(); F++){ Function* f = &(*F); graf.add(f); if(podaci.find(f) == podaci.end()) podaci[f] = new PureFunctionInfo(f); //Provera argumenata FunctionType* a = f->getFunctionType(); for(auto Arg = a->param_begin(); Arg != a->param_end(); Arg++){ int broj_pokazivackih_argumenata = 0; if((*Arg)->isPointerTy() && !(cast<PointerType>(*Arg)->getElementType()->isFunctionTy())) broj_pokazivackih_argumenata++; if(broj_pokazivackih_argumenata) podaci[f]->setPointerAttributes(broj_pokazivackih_argumenata); } //Provera pojedinacnih instrukcija for (const BasicBlock &BB : *F){ for (const Instruction &I : BB){ if(isa<CallInst>(I)){ Function *callee = cast<CallInst>(I).getCalledFunction(); graf.connect(f, callee); } for(auto it = I.op_begin(); it!=I.op_end();it++){ Value* Op = it->get(); if (globalne.find(Op) != globalne.end()){ podaci[f]->addGlobal(Op); } //Type* T = Op->getType(); //if(T->isPointerTy() && !(cast<PointerType>(*T).getElementType()->isFunctionTy())) //errs().write_escaped(Op->getName()) << '\n'; } } } } //Provera povezanosti auto krajPodataka = podaci.end(); for(auto it = podaci.begin(); it != krajPodataka; it++){ PureFunctionInfo* F= it->second; if(F->isDirectlyImpureFunction()){ set<Function*> zavisnosti = graf.getDependancies(F->getFunction()); auto krajZavisnosti = zavisnosti.end(); for(auto it2 = zavisnosti.begin(); it2 != krajZavisnosti; it2++){ if(F->isExternalFunction()) podaci[*it2]->addExternal(F); if(F->isGlobalFunction() || F->getNumberOfPointerAttributes()) podaci[*it2]->addGlobal(F); } } } //Izlistavanje rezultata for(auto it = podaci.begin(); it != podaci.end(); it++){ PureFunctionInfo* F= it->second; errs()<<">-------------------------------------------------------|\n"; errs()<<"Ime funkcije: "; errs().write_escaped(F->getFunction()->getName()) << '\n'; if(F->isPureFunction()) errs()<<"Cista funkcija!\n"; if(F->isExternalFunction()) errs()<<"Funkcija nije definisana, ne moze se ustanoviti cistost pre linkovanja\n"; if(F->hasExternalFunctions() && !F->hasGlobalFunctions()) errs()<<"Funkcija poziva nedefinisane funkcije, ne moze se ustanoviti cistost pre linkovanja\n"; if(F->isGlobalFunction()) errs()<<"Funkcija koristi globalne promenljive\n"; if(F->hasGlobalFunctions()) errs()<<"Funkcija poziva neciste funkcije\n"; if(F->getNumberOfPointerAttributes()) errs()<<"Funkcija ima pokazivacke argumente\n"; errs()<<">-------------------------------------------------------|\n"; } //Oslobadjanje memorije for(auto it = podaci.begin(); it != podaci.end(); it++) delete it->second; return false; } void BasicPureFunctionAnalysis::getAnalysisUsage(AnalysisUsage &AU) const { AU.setPreservesAll(); } char BasicPureFunctionAnalysis::ID = 0; static RegisterPass<BasicPureFunctionAnalysis> X("bpfa", "Osnovna analiza cistih funkcija", true, true); static llvm::RegisterStandardPasses Y( llvm::PassManagerBuilder::EP_EarlyAsPossible, [](const llvm::PassManagerBuilder &Builder, llvm::legacy::PassManagerBase &PM) { PM.add(new BasicPureFunctionAnalysis()); });
[ "lawamulet@gmail.com" ]
lawamulet@gmail.com
97a52b7ee58a525bcc56e5ba53e5ec0bc1ee4306
645dad5fd3a586bd659476fb6baaf33afcd3d4c3
/samples/extensions/fragment_shading_rate/fragment_shading_rate.h
cbbc2dfce88f2cb9742b171899e58904f67e805d
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT", "LicenseRef-scancode-public-domain" ]
permissive
1div0/Vulkan-Samples
56b5df8b9ff133766d740bf7065f3aa5b478882a
0d98a3b4b89b63211ccb4b7a7f536b813b0910c9
refs/heads/master
2022-02-03T12:19:28.902986
2022-01-17T17:32:09
2022-01-17T17:32:09
223,759,979
0
0
Apache-2.0
2019-11-24T14:46:25
2019-11-24T14:46:25
null
UTF-8
C++
false
false
3,145
h
/* Copyright (c) 2020-2021, Sascha Willems * * SPDX-License-Identifier: Apache-2.0 * * 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. */ /* * Using variable fragment shading rates from a subpass attachment with VK_KHR_fragment_shading_rate * This sample creates an image that contains different shading rates, which are then sampled during rendering */ #pragma once #include "api_vulkan_sample.h" class FragmentShadingRate : public ApiVulkanSample { public: bool enable_attachment_shading_rate = true; bool color_shading_rate = false; bool display_skysphere = true; VkPhysicalDeviceFragmentShadingRatePropertiesKHR physical_device_fragment_shading_rate_properties{}; VkPhysicalDeviceFragmentShadingRateFeaturesKHR enabled_physical_device_fragment_shading_rate_features{}; struct ShadingRateImage { VkImage image = VK_NULL_HANDLE; VkDeviceMemory memory = VK_NULL_HANDLE; VkImageView view = VK_NULL_HANDLE; } shading_rate_image; struct { Texture skysphere; Texture scene; } textures; struct { std::unique_ptr<vkb::sg::SubMesh> skysphere; std::unique_ptr<vkb::sg::SubMesh> scene; } models; struct { std::unique_ptr<vkb::core::Buffer> scene; } uniform_buffers; struct UBOScene { glm::mat4 projection; glm::mat4 modelview; glm::mat4 skysphere_modelview; int32_t color_shading_rate; } ubo_scene; VkPipelineLayout pipeline_layout; struct Pipelines { VkPipeline skysphere; VkPipeline sphere; } pipelines; VkDescriptorSetLayout descriptor_set_layout; VkDescriptorSet descriptor_set; struct { glm::vec4 offset; uint32_t object_type; } push_const_block; FragmentShadingRate(); ~FragmentShadingRate(); virtual void request_gpu_features(vkb::PhysicalDevice &gpu) override; void create_shading_rate_attachment(); void invalidate_shading_rate_attachment(); void setup_render_pass() override; void setup_framebuffer() override; void build_command_buffers() override; void load_assets(); void setup_descriptor_pool(); void setup_descriptor_set_layout(); void setup_descriptor_sets(); void prepare_pipelines(); void prepare_uniform_buffers(); void update_uniform_buffers(); void draw(); bool prepare(vkb::Platform &platform) override; virtual void render(float delta_time) override; virtual void on_update_ui_overlay(vkb::Drawer &drawer) override; virtual bool resize(const uint32_t width, const uint32_t height) override; }; std::unique_ptr<vkb::VulkanSample> create_fragment_shading_rate();
[ "noreply@github.com" ]
noreply@github.com
5e89b8279d5477753886c67f82bb2e870fd774cc
91a882547e393d4c4946a6c2c99186b5f72122dd
/Source/XPSP1/NT/ds/security/cryptoapi/crypstub/keysvr.cpp
d1fcb001ece35d8162e38a8763ff9fde167899ec
[]
no_license
IAmAnubhavSaini/cryptoAlgorithm-nt5src
94f9b46f101b983954ac6e453d0cf8d02aa76fc7
d9e1cdeec650b9d6d3ce63f9f0abe50dabfaf9e2
refs/heads/master
2023-09-02T10:14:14.795579
2021-11-20T13:47:06
2021-11-20T13:47:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
24,098
cpp
#include <nt.h> #include <ntrtl.h> #include <nturtl.h> #include <windows.h> #include <ntsecapi.h> #include <wincrypt.h> #include <userenv.h> #include <lmcons.h> #include <certca.h> #include "keysvc.h" #include "cryptui.h" #include "lenroll.h" #include "keysvcc.h" DWORD BindLocalKeyService(handle_t *hProxy); // key service stub functions ULONG s_KeyrOpenKeyService( /* [in] */ handle_t hRPCBinding, /* [in] */ KEYSVC_TYPE OwnerType, /* [in] */ PKEYSVC_UNICODE_STRING pOwnerName, /* [in] */ ULONG ulDesiredAccess, /* [in] */ PKEYSVC_BLOB pAuthentication, /* [in, out] */ PKEYSVC_BLOB *ppReserved, /* [out] */ KEYSVC_HANDLE *phKeySvc) { RPC_BINDING_HANDLE hProxy = NULL; RPC_STATUS RpcStatus = RPC_S_OK; RpcStatus = RpcImpersonateClient(hRPCBinding); if (RPC_S_OK != RpcStatus) { return RpcStatus; } RpcStatus = BindLocalKeyService(&hProxy); if(RPC_S_OK != RpcStatus) { goto error; } __try { RpcStatus = s_KeyrOpenKeyService( hProxy, OwnerType, pOwnerName, ulDesiredAccess, pAuthentication, ppReserved, phKeySvc); } __except ( EXCEPTION_EXECUTE_HANDLER ) { RpcStatus = _exception_code(); } error: if(hProxy) { RpcBindingFree(&hProxy); } RpcRevertToSelf(); return RpcStatus; } ULONG s_KeyrEnumerateProviders( /* [in] */ handle_t hRPCBinding, /* [in] */ KEYSVC_HANDLE hKeySvc, /* [in, out] */ PKEYSVC_BLOB *ppReserved, /* [in, out] */ ULONG *pcProviderCount, /* [in, out][size_is(,*pcProviderCount)] */ PKEYSVC_PROVIDER_INFO *ppProviders) { RPC_BINDING_HANDLE hProxy = NULL; RPC_STATUS RpcStatus = RPC_S_OK; RpcStatus = RpcImpersonateClient(hRPCBinding); if (RPC_S_OK != RpcStatus) { return RpcStatus; } RpcStatus = BindLocalKeyService(&hProxy); if(RPC_S_OK != RpcStatus) { goto error; } __try { RpcStatus = s_KeyrEnumerateProviders( hProxy, hKeySvc, ppReserved, pcProviderCount, ppProviders); } __except ( EXCEPTION_EXECUTE_HANDLER ) { RpcStatus = _exception_code(); } error: if(hProxy) { RpcBindingFree(&hProxy); } RpcRevertToSelf(); return RpcStatus; } ULONG s_KeyrEnumerateProviderTypes( /* [in] */ handle_t hRPCBinding, /* [in] */ KEYSVC_HANDLE hKeySvc, /* [in, out] */ PKEYSVC_BLOB *ppReserved, /* [in, out] */ ULONG *pcProviderCount, /* [in, out][size_is(,*pcProviderCount)] */ PKEYSVC_PROVIDER_INFO *ppProviders) { RPC_BINDING_HANDLE hProxy = NULL; RPC_STATUS RpcStatus = RPC_S_OK; RpcStatus = RpcImpersonateClient(hRPCBinding); if (RPC_S_OK != RpcStatus) { return RpcStatus; } RpcStatus = BindLocalKeyService(&hProxy); if(RPC_S_OK != RpcStatus) { goto error; } __try { RpcStatus = s_KeyrEnumerateProviderTypes( hProxy, hKeySvc, ppReserved, pcProviderCount, ppProviders); } __except ( EXCEPTION_EXECUTE_HANDLER ) { RpcStatus = _exception_code(); } error: if(hProxy) { RpcBindingFree(&hProxy); } RpcRevertToSelf(); return RpcStatus; } ULONG s_KeyrEnumerateProvContainers( /* [in] */ handle_t hRPCBinding, /* [in] */ KEYSVC_HANDLE hKeySvc, /* [in] */ KEYSVC_PROVIDER_INFO Provider, /* [in, out] */ PKEYSVC_BLOB *ppReserved, /* [in, out] */ ULONG *pcContainerCount, /* [in, out][size_is(,*pcContainerCount)] */ PKEYSVC_UNICODE_STRING *ppContainers) { RPC_BINDING_HANDLE hProxy = NULL; RPC_STATUS RpcStatus = RPC_S_OK; RpcStatus = RpcImpersonateClient(hRPCBinding); if (RPC_S_OK != RpcStatus) { return RpcStatus; } RpcStatus = BindLocalKeyService(&hProxy); if(RPC_S_OK != RpcStatus) { goto error; } __try { RpcStatus = s_KeyrEnumerateProvContainers( hProxy, hKeySvc, Provider, ppReserved, pcContainerCount, ppContainers); } __except ( EXCEPTION_EXECUTE_HANDLER ) { RpcStatus = _exception_code(); } error: if(hProxy) { RpcBindingFree(&hProxy); } RpcRevertToSelf(); return RpcStatus; } ULONG s_KeyrCloseKeyService( /* [in] */ handle_t hRPCBinding, /* [in] */ KEYSVC_HANDLE hKeySvc, /* [in, out] */ PKEYSVC_BLOB *ppReserved) { RPC_BINDING_HANDLE hProxy = NULL; RPC_STATUS RpcStatus = RPC_S_OK; RpcStatus = RpcImpersonateClient(hRPCBinding); if (RPC_S_OK != RpcStatus) { return RpcStatus; } RpcStatus = BindLocalKeyService(&hProxy); if(RPC_S_OK != RpcStatus) { goto error; } __try { RpcStatus = s_KeyrCloseKeyService( hProxy, hKeySvc, ppReserved); } __except ( EXCEPTION_EXECUTE_HANDLER ) { RpcStatus = _exception_code(); } error: if(hProxy) { RpcBindingFree(&hProxy); } RpcRevertToSelf(); return RpcStatus; } ULONG s_KeyrGetDefaultProvider( /* [in] */ handle_t hRPCBinding, /* [in] */ KEYSVC_HANDLE hKeySvc, /* [in] */ ULONG ulProvType, /* [in] */ ULONG ulFlags, /* [in, out] */ PKEYSVC_BLOB *ppReserved, /* [out] */ ULONG *pulDefType, /* [out] */ PKEYSVC_PROVIDER_INFO *ppProvider) { RPC_BINDING_HANDLE hProxy = NULL; RPC_STATUS RpcStatus = RPC_S_OK; RpcStatus = RpcImpersonateClient(hRPCBinding); if (RPC_S_OK != RpcStatus) { return RpcStatus; } RpcStatus = BindLocalKeyService(&hProxy); if(RPC_S_OK != RpcStatus) { goto error; } __try { RpcStatus = s_KeyrGetDefaultProvider( hProxy, hKeySvc, ulProvType, ulFlags, ppReserved, pulDefType, ppProvider); } __except ( EXCEPTION_EXECUTE_HANDLER ) { RpcStatus = _exception_code(); } error: if(hProxy) { RpcBindingFree(&hProxy); } RpcRevertToSelf(); return RpcStatus; } ULONG s_KeyrSetDefaultProvider( /* [in] */ handle_t hRPCBinding, /* [in] */ KEYSVC_HANDLE hKeySvc, /* [in] */ ULONG ulFlags, /* [in, out] */ PKEYSVC_BLOB *ppReserved, /* [in] */ KEYSVC_PROVIDER_INFO Provider) { RPC_BINDING_HANDLE hProxy = NULL; RPC_STATUS RpcStatus = RPC_S_OK; RpcStatus = RpcImpersonateClient(hRPCBinding); if (RPC_S_OK != RpcStatus) { return RpcStatus; } RpcStatus = BindLocalKeyService(&hProxy); if(RPC_S_OK != RpcStatus) { goto error; } __try { RpcStatus = s_KeyrSetDefaultProvider( hProxy, hKeySvc, ulFlags, ppReserved, Provider); } __except ( EXCEPTION_EXECUTE_HANDLER ) { RpcStatus = _exception_code(); } error: if(hProxy) { RpcBindingFree(&hProxy); } RpcRevertToSelf(); return RpcStatus; } ULONG s_KeyrEnroll( /* [in] */ handle_t hRPCBinding, /* [in] */ BOOL fKeyService, /* [in] */ ULONG ulPurpose, /* [in] */ PKEYSVC_UNICODE_STRING pAcctName, /* [in] */ PKEYSVC_UNICODE_STRING pCALocation, /* [in] */ PKEYSVC_UNICODE_STRING pCAName, /* [in] */ BOOL fNewKey, /* [in] */ PKEYSVC_CERT_REQUEST_PVK_NEW pKeyNew, /* [in] */ PKEYSVC_BLOB __RPC_FAR pCert, /* [in] */ PKEYSVC_CERT_REQUEST_PVK_NEW pRenewKey, /* [in] */ PKEYSVC_UNICODE_STRING pHashAlg, /* [in] */ PKEYSVC_UNICODE_STRING pDesStore, /* [in] */ ULONG ulStoreFlags, /* [in] */ PKEYSVC_CERT_ENROLL_INFO pRequestInfo, /* [in] */ ULONG ulFlags, /* [out][in] */ PKEYSVC_BLOB __RPC_FAR *ppReserved, /* [out] */ PKEYSVC_BLOB __RPC_FAR *ppPKCS7Blob, /* [out] */ PKEYSVC_BLOB __RPC_FAR *ppHashBlob, /* [out] */ ULONG __RPC_FAR *pulStatus) { RPC_BINDING_HANDLE hProxy = NULL; RPC_STATUS RpcStatus = RPC_S_OK; RpcStatus = RpcImpersonateClient(hRPCBinding); if (RPC_S_OK != RpcStatus) { return RpcStatus; } RpcStatus = BindLocalKeyService(&hProxy); if(RPC_S_OK != RpcStatus) { goto error; } __try { RpcStatus = s_KeyrEnroll( hProxy, fKeyService, ulPurpose, pAcctName, pCALocation, pCAName, fNewKey, pKeyNew, pCert, pRenewKey, pHashAlg, pDesStore, ulStoreFlags, pRequestInfo, ulFlags, ppReserved, ppPKCS7Blob, ppHashBlob, pulStatus); } __except ( EXCEPTION_EXECUTE_HANDLER ) { RpcStatus = _exception_code(); } error: if(hProxy) { RpcBindingFree(&hProxy); } RpcRevertToSelf(); return RpcStatus; } ULONG s_KeyrExportCert( /* [in] */ handle_t hRPCBinding, /* [in] */ KEYSVC_HANDLE hKeySvc, /* [in] */ PKEYSVC_UNICODE_STRING pPassword, /* [in] */ PKEYSVC_UNICODE_STRING pCertStore, /* [in] */ ULONG cHashCount, /* [size_is][in] */ KEYSVC_CERT_HASH *pHashes, /* [in] */ ULONG ulFlags, /* [in, out] */ PKEYSVC_BLOB *ppReserved, /* [out] */ PKEYSVC_BLOB *ppPFXBlob) { RPC_BINDING_HANDLE hProxy = NULL; RPC_STATUS RpcStatus = RPC_S_OK; RpcStatus = RpcImpersonateClient(hRPCBinding); if (RPC_S_OK != RpcStatus) { return RpcStatus; } RpcStatus = BindLocalKeyService(&hProxy); if(RPC_S_OK != RpcStatus) { goto error; } __try { RpcStatus = s_KeyrExportCert( hProxy, hKeySvc, pPassword, pCertStore, cHashCount, pHashes, ulFlags, ppReserved, ppPFXBlob); } __except ( EXCEPTION_EXECUTE_HANDLER ) { RpcStatus = _exception_code(); } error: if(hProxy) { RpcBindingFree(&hProxy); } RpcRevertToSelf(); return RpcStatus; } ULONG s_KeyrImportCert( /* [in] */ handle_t hRPCBinding, /* [in] */ KEYSVC_HANDLE hKeySvc, /* [in] */ PKEYSVC_UNICODE_STRING pPassword, /* [in] */ KEYSVC_UNICODE_STRING *pCertStore, /* [in] */ PKEYSVC_BLOB pPFXBlob, /* [in] */ ULONG ulFlags, /* [in, out] */ PKEYSVC_BLOB *ppReserved) { RPC_BINDING_HANDLE hProxy = NULL; RPC_STATUS RpcStatus = RPC_S_OK; RpcStatus = RpcImpersonateClient(hRPCBinding); if (RPC_S_OK != RpcStatus) { return RpcStatus; } RpcStatus = BindLocalKeyService(&hProxy); if(RPC_S_OK != RpcStatus) { goto error; } __try { RpcStatus = s_KeyrImportCert( hProxy, hKeySvc, pPassword, pCertStore, pPFXBlob, ulFlags, ppReserved); } __except ( EXCEPTION_EXECUTE_HANDLER ) { RpcStatus = _exception_code(); } error: if(hProxy) { RpcBindingFree(&hProxy); } RpcRevertToSelf(); return RpcStatus; } ULONG s_KeyrEnumerateAvailableCertTypes( /* [in] */ handle_t hRPCBinding, /* [in] */ KEYSVC_HANDLE hKeySvc, /* [in, out] */ PKEYSVC_BLOB *ppReserved, /* [out][in] */ ULONG *pcCertTypeCount, /* [in, out][size_is(,*pcCertTypeCount)] */ PKEYSVC_UNICODE_STRING *ppCertTypes) { RPC_BINDING_HANDLE hProxy = NULL; RPC_STATUS RpcStatus = RPC_S_OK; RpcStatus = RpcImpersonateClient(hRPCBinding); if (RPC_S_OK != RpcStatus) { return RpcStatus; } RpcStatus = BindLocalKeyService(&hProxy); if(RPC_S_OK != RpcStatus) { goto error; } __try { RpcStatus = s_KeyrEnumerateAvailableCertTypes( hProxy, hKeySvc, ppReserved, pcCertTypeCount, ppCertTypes); } __except ( EXCEPTION_EXECUTE_HANDLER ) { RpcStatus = _exception_code(); } error: if(hProxy) { RpcBindingFree(&hProxy); } RpcRevertToSelf(); return RpcStatus; } ULONG s_KeyrEnumerateCAs( /* [in] */ handle_t hRPCBinding, /* [in] */ KEYSVC_HANDLE hKeySvc, /* [in, out] */ PKEYSVC_BLOB *ppReserved, /* [in] */ ULONG ulFlags, /* [out][in] */ ULONG *pcCACount, /* [in, out][size_is(,*pcCACount)] */ PKEYSVC_UNICODE_STRING *ppCAs) { RPC_BINDING_HANDLE hProxy = NULL; RPC_STATUS RpcStatus = RPC_S_OK; RpcStatus = RpcImpersonateClient(hRPCBinding); if (RPC_S_OK != RpcStatus) { return RpcStatus; } RpcStatus = BindLocalKeyService(&hProxy); if(RPC_S_OK != RpcStatus) { goto error; } __try { RpcStatus = s_KeyrEnumerateCAs( hProxy, hKeySvc, ppReserved, ulFlags, pcCACount, ppCAs); } __except ( EXCEPTION_EXECUTE_HANDLER ) { RpcStatus = _exception_code(); } error: if(hProxy) { RpcBindingFree(&hProxy); } RpcRevertToSelf(); return RpcStatus; } DWORD BindLocalKeyService(handle_t *hProxy) { WCHAR *pStringBinding = NULL; *hProxy = NULL; RPC_STATUS RpcStatus = RPC_S_OK; RpcStatus = RpcStringBindingComposeW( NULL, KEYSVC_LOCAL_PROT_SEQ, NULL, KEYSVC_LOCAL_ENDPOINT, NULL, &pStringBinding); if (RPC_S_OK != RpcStatus) { goto error; } RpcStatus = RpcBindingFromStringBindingW( pStringBinding, hProxy); if (RPC_S_OK != RpcStatus) { goto error; } RpcStatus = RpcEpResolveBinding( *hProxy, IKeySvc_v1_0_c_ifspec); if (RPC_S_OK != RpcStatus) { if(*hProxy) { RpcBindingFree(hProxy); *hProxy = NULL; } goto error; } error: if (NULL != pStringBinding) { RpcStringFreeW(&pStringBinding); } return RpcStatus; } ULONG s_KeyrEnroll_V2 (/* [in] */ handle_t hRPCBinding, /* [in] */ BOOL fKeyService, /* [in] */ ULONG ulPurpose, /* [in] */ ULONG ulFlags, /* [in] */ PKEYSVC_UNICODE_STRING pAcctName, /* [in] */ PKEYSVC_UNICODE_STRING pCALocation, /* [in] */ PKEYSVC_UNICODE_STRING pCAName, /* [in] */ BOOL fNewKey, /* [in] */ PKEYSVC_CERT_REQUEST_PVK_NEW_V2 pKeyNew, /* [in] */ PKEYSVC_BLOB __RPC_FAR pCert, /* [in] */ PKEYSVC_CERT_REQUEST_PVK_NEW_V2 pRenewKey, /* [in] */ PKEYSVC_UNICODE_STRING pHashAlg, /* [in] */ PKEYSVC_UNICODE_STRING pDesStore, /* [in] */ ULONG ulStoreFlags, /* [in] */ PKEYSVC_CERT_ENROLL_INFO pRequestInfo, /* [in] */ ULONG ulReservedFlags, /* [out][in] */ PKEYSVC_BLOB __RPC_FAR *ppReserved, /* [out][in] */ PKEYSVC_BLOB __RPC_FAR *ppRequest, /* [out] */ PKEYSVC_BLOB __RPC_FAR *ppPKCS7Blob, /* [out] */ PKEYSVC_BLOB __RPC_FAR *ppHashBlob, /* [out] */ ULONG __RPC_FAR *pulStatus) { RPC_BINDING_HANDLE hProxy = NULL; RPC_STATUS RpcStatus = RPC_S_OK; RpcStatus = RpcImpersonateClient(hRPCBinding); if (RPC_S_OK != RpcStatus) { return RpcStatus; } RpcStatus = BindLocalKeyService(&hProxy); if(RPC_S_OK != RpcStatus) { goto error; } __try { RpcStatus = s_KeyrEnroll_V2( hProxy, fKeyService, ulPurpose, ulFlags, pAcctName, pCALocation, pCAName, fNewKey, pKeyNew, pCert, pRenewKey, pHashAlg, pDesStore, ulStoreFlags, pRequestInfo, ulReservedFlags, ppReserved, ppRequest, ppPKCS7Blob, ppHashBlob, pulStatus); } __except ( EXCEPTION_EXECUTE_HANDLER ) { RpcStatus = _exception_code(); } error: if(hProxy) { RpcBindingFree(&hProxy); } RpcRevertToSelf(); return RpcStatus; } ULONG s_KeyrQueryRequestStatus (/* [in] */ handle_t hRPCBinding, /* [in] */ unsigned __int64 u64Request, /* [out, ref] */ KEYSVC_QUERY_CERT_REQUEST_INFO *pQueryInfo) { RPC_BINDING_HANDLE hProxy = NULL; RPC_STATUS RpcStatus = RPC_S_OK; RpcStatus = RpcImpersonateClient(hRPCBinding); if (RPC_S_OK != RpcStatus) { return RpcStatus; } RpcStatus = BindLocalKeyService(&hProxy); if(RPC_S_OK != RpcStatus) { goto error; } __try { RpcStatus = s_KeyrQueryRequestStatus( hProxy, u64Request, pQueryInfo); } __except ( EXCEPTION_EXECUTE_HANDLER ) { RpcStatus = _exception_code(); } error: if(hProxy) { RpcBindingFree(&hProxy); } RpcRevertToSelf(); return RpcStatus; } ULONG s_RKeyrPFXInstall (/* [in] */ handle_t hRPCBinding, /* [in] */ PKEYSVC_BLOB pPFX, /* [in] */ PKEYSVC_UNICODE_STRING pPassword, /* [in] */ ULONG ulFlags) { RPC_BINDING_HANDLE hProxy = NULL; RPC_STATUS RpcStatus = RPC_S_OK; RpcStatus = RpcImpersonateClient(hRPCBinding); if (RPC_S_OK != RpcStatus) { return RpcStatus; } RpcStatus = BindLocalKeyService(&hProxy); if(RPC_S_OK != RpcStatus) { goto error; } __try { RpcStatus = s_RKeyrPFXInstall( hProxy, pPFX, pPassword, ulFlags); } __except ( EXCEPTION_EXECUTE_HANDLER ) { RpcStatus = _exception_code(); } error: if(hProxy) { RpcBindingFree(&hProxy); } RpcRevertToSelf(); return RpcStatus; } ULONG s_RKeyrOpenKeyService( /* [in] */ handle_t hRPCBinding, /* [in] */ KEYSVC_TYPE OwnerType, /* [in] */ PKEYSVC_UNICODE_STRING pOwnerName, /* [in] */ ULONG ulDesiredAccess, /* [in] */ PKEYSVC_BLOB pAuthentication, /* [in, out] */ PKEYSVC_BLOB *ppReserved, /* [out] */ KEYSVC_HANDLE *phKeySvc) { return s_KeyrOpenKeyService (hRPCBinding, OwnerType, pOwnerName, ulDesiredAccess, pAuthentication, ppReserved, phKeySvc); } ULONG s_RKeyrCloseKeyService( /* [in] */ handle_t hRPCBinding, /* [in] */ KEYSVC_HANDLE hKeySvc, /* [in, out] */ PKEYSVC_BLOB *ppReserved) { return s_KeyrCloseKeyService (hRPCBinding, hKeySvc, ppReserved); }
[ "support@cryptoalgo.cf" ]
support@cryptoalgo.cf
03f5035078775ebbb371734bfdb562c9d31bc3da
5be058c0f3ecf00be2b889741dc135dc32ef51fe
/CtrlTree_fw/main.cpp
15da633dc4c798ab66ec6822e0538fcaebcbf7f9
[]
no_license
Kreyl/BmstuCtrlTree
6633b3127bcf817e1437437fad7777cda5d3a398
5073dee2d3ba02904cfbc3f6a6d85ed136fc13a8
refs/heads/master
2020-09-11T18:39:34.812137
2020-08-28T09:22:59
2020-08-28T09:22:59
222,155,414
0
0
null
null
null
null
UTF-8
C++
false
false
37,852
cpp
#include "kl_crc.h" #include "TControl.h" #include "ch.h" #include "hal.h" #include "MsgQ.h" #include "uart2.h" #include "shell.h" #include "usb_cdc.h" #include "SimpleSensors.h" #include "led.h" #include "Sequences.h" #include "kl_i2c.h" #include "Device.h" #include <string> #include "UpdateFw.h" #include "Adf5356.h" #if 1 // ======================== Variables & prototypes ======================= // Forever bool OsIsInitialized = false; EvtMsgQ_t<EvtMsg_t, MAIN_EVT_Q_LEN> EvtQMain; void OnCmd(Shell_t *PShell); void ITask(); // Hoard of UARTs static const UartParams_t CmdUartParams (115200, CMD_UART_PARAMS); static const UartParams_t RS232Params (19200, RS232_PARAMS); static const UartParams_t RS485ExtParams(19200, RS485EXT_PARAMS); static const UartParams_t RS485IntParams(19200, RS485INT_PARAMS); // Control from outside CmdUart_t Uart{CmdUartParams}; CmdUart485_t RS485Ext{RS485ExtParams, RS485_EXT_TXEN}; CmdUart_t RS232{RS232Params}; // Internal host HostUart485_t RS485Int{RS485IntParams, RS485_INT_TXEN}; #define TIMEOUT_SHORT_ms 54UL #define TIMEOUT_MID_ms 360UL #define TIMEOUT_LONG_ms 9999UL bool UsbIsConnected = false; LedBlinker_t Led{LED_PIN}; DeviceList_t DevList; uint8_t ProcessMasterCmd(Shell_t *PShell, Cmd_t *PCmd); void OnSlaveCmd(Shell_t *PShell, Cmd_t *PCmd); void ProcessCmdForSlave(Shell_t *PShell, Cmd_t *PCmd, uint32_t Addr); static TmrKL_t TmrOneSecond {TIME_MS2I(999), evtIdEverySecond, tktPeriodic}; // Measure battery periodically uint8_t FileBuf[FILEBUF_SZ]; #endif #if 1 // ============================= Classes ================================= class GpioReg_t { private: uint32_t IReg = 0; public: void Set(uint32_t AReg) { IReg = AReg; uint32_t PortE = IReg & 0xFFFF; // Lower bits uint32_t PortD = ((IReg >> 16) & 0x7FF) << 5; // higher bits chSysLock(); PortD |= GPIOD->ODR & 0x1FUL; // Get values of lower bits of ODR GPIOE->ODR = PortE; GPIOD->ODR = PortD; chSysUnlock(); } uint32_t Get() { return IReg; } void Init() { // GPIOE PinClockEnable(GPIOE); GPIOE->OTYPER = 0; // Push-Pull GPIOE->PUPDR = 0; // no PullUp/PullDown GPIOE->OSPEEDR = 0x55555555; // Medium speed GPIOE->MODER = 0x55555555; // Mode = output // GPIOD PinClockEnable(GPIOD); GPIOD->OTYPER = (GPIOD->OTYPER & 0x001F); // Clear bits [5;15], do not touch [0;4] GPIOD->PUPDR = (GPIOD->PUPDR & 0x000003FF); // Clear bits [5;15], do not touch [0;4]. No PullUp/PullDown GPIOD->OSPEEDR = (GPIOD->OSPEEDR & 0x000003FF) | 0x55555400; // Medium speed GPIOD->MODER = (GPIOD->MODER & 0x000003FF) | 0x55555400; // Mode = output } } GpioReg; #define SPI_BUF_SZ 32 class DevSpi_t { private: SPI_TypeDef *PSpi; uint8_t TxBuf[SPI_BUF_SZ]; uint8_t RxBuf[SPI_BUF_SZ]; GPIO_TypeDef *PGpio; uint32_t Sck, Miso, Mosi, Cs; AlterFunc_t AF; public: DevSpi_t(SPI_TypeDef *ASpi, GPIO_TypeDef *AGpio, uint32_t ASck, uint32_t AMiso, uint32_t AMosi, uint32_t ACs, AlterFunc_t AAF) : PSpi(ASpi), PGpio(AGpio), Sck(ASck), Miso(AMiso), Mosi(AMosi), Cs(ACs), AF(AAF) {} void Init(bool CsActiveLowIdleHi) { if (PSpi == SPI1) { rccEnableSPI1(FALSE); } else if (PSpi == SPI2) { rccEnableSPI2(FALSE); } PinSetupOut(PGpio, Cs, omPushPull); // Deactivate CS if(CsActiveLowIdleHi) PinSetHi(PGpio, Cs); else PinSetLo(PGpio, Cs); PinSetupAlterFunc(PGpio, Sck, omPushPull, pudNone, AF, psVeryHigh); PinSetupAlterFunc(PGpio, Miso, omPushPull, pudNone, AF, psVeryHigh); PinSetupAlterFunc(PGpio, Mosi, omPushPull, pudNone, AF, psVeryHigh); } void Transmit(uint8_t Params, uint8_t *ptr, uint32_t Len) { bool CsActiveLowIdleHi = (Params & 0x08) == 0; // Activate CS if(CsActiveLowIdleHi) PinSetLo(PGpio, Cs); else PinSetHi(PGpio, Cs); // Setup SPI PSpi->CR1 = SPI_CR1_SSM | SPI_CR1_SSI | SPI_CR1_MSTR; if(Params & 0x80) PSpi->CR1 |= SPI_CR1_LSBFIRST; // 0 = MSB, 1 = LSB if(Params & 0x40) PSpi->CR1 |= SPI_CR1_CPOL; // 0 = IdleLow, 1 = IdleHigh if(Params & 0x20) PSpi->CR1 |= SPI_CR1_CPHA; // 0 = FirstEdge, 1 = SecondEdge PSpi->CR1 |= (Params & 0x07) << 3; // Setup divider PSpi->CR2 = ((uint16_t)0b0111 << 8) | SPI_CR2_FRXTH; // 8 bit, RXNE generated when 8 bit is received (void)PSpi->SR; // Read Status reg to clear some flags // Do it PSpi->CR1 |= SPI_CR1_SPE; // Enable SPI while(Len) { *((volatile uint8_t*)&PSpi->DR) = *ptr; while(!(PSpi->SR & SPI_SR_RXNE)); // Wait for SPI transmission to complete *ptr = *((volatile uint8_t*)&PSpi->DR); ptr++; Len--; } // Deactivate CS if(CsActiveLowIdleHi) PinSetHi(PGpio, Cs); else PinSetLo(PGpio, Cs); PSpi->CR1 &= ~SPI_CR1_SPE; // Disable SPI } }; DevSpi_t Spi1{SPI1, GPIOA, 5,6,7,4, AF5}; DevSpi_t Spi2{SPI2, GPIOB, 13,14,15,12, AF5}; class Power_t { public: uint32_t Current = 0; } Power; class Hmc821_t { private: PinOutput_t SEN{GPIOA, 4, omPushPull}; // Serial port enable, Active High (!) Spi_t ISpi{SPI1}; public: void Init() { // Init GPIOs SEN.Init(); PinSetupOut(GPIOA, 5, omPushPull); // SCK must be low first chThdSleepMilliseconds(45); // let it wake // Rise SEN before SCK: select HMC Serial Mode SEN.SetHi(); chThdSleepMilliseconds(4); PinSetHi(GPIOA, 5); // SCK HI chThdSleepMilliseconds(4); PinSetLo(GPIOA, 5); // SCK Lo SEN.SetLo(); // SEN Active High chThdSleepMilliseconds(4); // Init SPI PinSetupAlterFunc(GPIOA, 5, omPushPull, pudNone, AF5, psVeryHigh); // SCK // PinSetupAlterFunc(GPIOA, 6, omPushPull, pudNone, AF5, psVeryHigh); // MISO PinSetupAlterFunc(GPIOA, 7, omPushPull, pudNone, AF5, psVeryHigh); // MOSI rccEnableSPI1(FALSE); ISpi.Setup(boMSB, cpolIdleLow, cphaFirstEdge, 1000000, bitn16); ISpi.Enable(); } void WriteReg(uint32_t Addr, uint32_t Value) { uint32_t Word = ((Addr & 0x3FUL) << 25) | ((Value & 0xFFFFFFUL) << 1); // 0=wr, 6xAddr, 24xValue, 1xDontCare SEN.SetHi(); // SEN is active hi ISpi.ReadWriteWord((Word >> 16) & 0xFFFF); ISpi.ReadWriteWord(Word & 0xFFFF); SEN.SetLo(); // Printf("HMC: %X = %X; %X\r", Addr, Value, Word); } } Hmc821; Adf5356_t Adf5356; #endif int main(void) { #if 1 // ==== Setup clock frequency ==== Clk.EnablePrefetch(); Clk.SwitchToMSI(); Clk.SetVoltageRange(mvrHiPerf); Clk.SetupFlashLatency(48, mvrHiPerf); // Try quartz if(Clk.EnableHSE() == retvOk) { Clk.SetupPllSrc(pllsrcHse); Clk.SetupPll(8, 2, 2); // 12MHz / 1 = 12; 12 * 8 / 2 => 48 } else { // Quartz failed Clk.SetupPllSrc(pllsrcMsi); Clk.SetupPll(24, 2, 2); // 4MHz / 1 = 4; 4 * 24 / 2 => 48 } // Try start PLL if(Clk.EnablePLL() == retvOk) { Clk.EnablePllROut(); Clk.EnablePllQOut(); Clk.SwitchToPLL(); Clk.SetupPllQas48MhzSrc(); } Clk.UpdateFreqValues(); #endif // Init OS halInit(); chSysInit(); OsIsInitialized = true; // ==== Init hardware ==== EvtQMain.Init(); Uart.Init(); Printf("\r%S %S\r", APP_NAME, XSTRINGIFY(BUILD_TIME)); if(Clk.GetPllSrc() == pllsrcHse) Printf("Quartz ok\r\n"); else Printf("No Quartz\r\n"); Printf("%S\r\n", (FLASH->OPTR & FLASH_OPTR_BFB2)? "BankB" : "BankA"); Clk.PrintFreqs(); if(sizeof(Settings_t) > SETTINGS_MAX_SZ) Printf("*** Too large Settings ***\r\n"); // Printf("sz of Settings_t: %u; max: %u\r", sizeof(Settings_t), SETTINGS_MAX_SZ); Led.Init(); Led.StartOrRestart(lsqCmd); // I2C and sns power PinSetupOut(SNS_PWR_CTRL, omPushPull); PinSetLo(SNS_PWR_CTRL); i2c1.Init(); // i2c1.ScanBus(); SelfInfo.Load(EE_SELF_ADDR); DevList.Load(); Settings.Load(); // Printf("SavedRegsCnt: %u, %u\r", Settings.SavedRegsCnt, Settings.RegsAreSaved()); // Uarts RS485Ext.Init(); RS485Int.Init(); RS232.Init(); UsbCDC.Init(); Crc::InitHWDMA(); SimpleSensors::Init(); // T control tControl.Init(); if(SelfInfo.Type == devtLNA or SelfInfo.Type == devtTriplexer) { if(Settings.TControlEnabled) tControl.StartControl(); else tControl.StartMeasure(); } // Always GpioReg.Init(); GpioReg.Set(Settings.PowerOnGPIO); Spi2.Init(Settings.SpiSetup.CS2ActiveLow); // Spi1 utilized by MRL and KuKonv, init it if type id another if(SelfInfo.Type == devtMRL) { Hmc821.Init(); // Load regs if they are saved if(Settings.WhatSaved == SAVED_REGS_FLAG and Settings.SavedRegsCnt <= REG_CNT) { for(uint32_t i=0; i<Settings.SavedRegsCnt; i++) { Hmc821.WriteReg(Settings.Hmc821.Regs[i].Addr, Settings.Hmc821.Regs[i].Value); } } } else if(SelfInfo.Type == devtKUKonv or SelfInfo.Type == devtIKS) { Adf5356.Init(); // Load regs if they are saved if(Settings.WhatSaved == SAVED_REGS_FLAG and Settings.SavedRegsCnt <= REG_CNT) { for(uint32_t i=0; i<Settings.SavedRegsCnt; i++) { Adf5356.WriteReg(Settings.Adf5356.Regs[i]); // Printf("%X\r", Settings.Adf5356.Regs[i]); } } // Or calc and set regs if params were saved else if(Settings.WhatSaved == SAVED_PARAMS_FLAG) { Adf5356.fref = Settings.Adf5356.fref; Adf5356.step = Settings.Adf5356.step; Adf5356.fd = Settings.Adf5356.fd; Adf5356.fvco = Settings.Adf5356.fvco; Adf5356.CalcRegs(); Adf5356.SetRegs(); // Adf5356.PrintRegs(); } } else Spi1.Init(Settings.SpiSetup.CS1ActiveLow); // Main cycle ITask(); } __noreturn void ITask() { while(true) { EvtMsg_t Msg = EvtQMain.Fetch(TIME_INFINITE); switch(Msg.ID) { case evtIdUartCmdRcvd: if(((CmdUart_t*)Msg.Ptr)->TryParseRxBuff() == retvOk) OnCmd((Shell_t*)((CmdUart_t*)Msg.Ptr)); break; case evtIdUsbCmdRcvd: OnCmd((Shell_t*)&UsbCDC); UsbCDC.SignalCmdProcessed(); break; case evtIdEverySecond: Printf("Second\r"); break; #if 1 // ======= USB ======= case evtIdUsbConnect: Printf("USB connect\r"); UsbCDC.Connect(); break; case evtIdUsbDisconnect: UsbCDC.Disconnect(); Printf("USB disconnect\r"); break; case evtIdUsbReady: Printf("USB ready\r"); break; #endif default: break; } // switch } // while true } void ProcessUsbConnect(PinSnsState_t *PState, uint32_t Len) { if((*PState == pssRising or *PState == pssHi) and !UsbIsConnected) { UsbIsConnected = true; EvtQMain.SendNowOrExit(EvtMsg_t(evtIdUsbConnect)); } else if((*PState == pssFalling or *PState == pssLo) and UsbIsConnected) { UsbIsConnected = false; EvtQMain.SendNowOrExit(EvtMsg_t(evtIdUsbDisconnect)); } } #if 1 // ======================= Command processing ============================ void TryToSaveSelfInfo(Shell_t *PShell) { if(SelfInfo.Save(EE_SELF_ADDR) == retvOk) PShell->Ok(); else PShell->Failure(); } void SetType(DevType_t NewType, Shell_t *PShell) { SelfInfo.Type = NewType; // Reset everything Settings.Reset(); Spi1.Init(true); tControl.Stop(); // Stop TStating switch(NewType) { case devtHFBlock: break; case devtLNA: tControl.StartMeasure(); break; case devtKUKonv: Adf5356.Init(); break; case devtMRL: Hmc821.Init(); break; case devtTriplexer: tControl.StartMeasure(); break; case devtIKS: Adf5356.Init(); break; default: break; } // switch TryToSaveSelfInfo(PShell); } void OnCmd(Shell_t *PShell) { Led.StartOrRestart(lsqCmd); Cmd_t *PCmd = &PShell->Cmd; // Printf("Cmd: %S\r", PCmd->Name); #if 1 // ==== Direct commands ==== if(PCmd->NameIs("Version")) PShell->Print("%S %S\r\n", APP_NAME, XSTRINGIFY(BUILD_TIME)); else if(PCmd->NameIs("mem")) PrintMemoryInfo(); else if(PCmd->NameIs("bfbsw")) { Printf("%X\r", FLASH->OPTR); chThdSleepMilliseconds(99); Flash::ToggleBootBankAndReset(); } else if(PCmd->NameIs("SetTemp")) { // float t; // if(PCmd->Get("%f") == 1) } else if(PCmd->NameIs("htr")) { uint32_t v; if(PCmd->GetNext<uint32_t>(&v) == retvOk) { tControl.SetHeater(v); PShell->Ok(); } else PShell->BadParam(); } else if(PCmd->NameIs("SetAddr")) { uint8_t Addr; if(PCmd->GetNext<uint8_t>(&Addr) != retvOk or !AddrIsOk(Addr)) { PShell->Print("BadParam\r\n"); return; } SelfInfo.Addr = Addr; TryToSaveSelfInfo(PShell); } else if(PCmd->NameIs("SetType")) { uint8_t Type; if(PCmd->GetNext<uint8_t>(&Type) != retvOk or !TypeIsOk(Type)) { PShell->Print("BadParam\r\n"); return; } SetType((DevType_t)Type, PShell); } else if(PCmd->NameIs("SetName")) { char *S =PCmd->GetNextString(); if(!S or strlen(S) > DEV_NAME_LEN) { PShell->BadParam(); return; } strcpy(SelfInfo.Name, S); TryToSaveSelfInfo(PShell); } else if(PCmd->NameIs("GetInfo")) { SelfInfo.Print(PShell, "\r\n"); } #endif else { // Command is not direct uint8_t FAddr; if(SelfInfo.Type == devtHFBlock) { // if we are master if(ProcessMasterCmd(PShell, PCmd) != retvOk) { // if cmd was not found in master cmds if(PCmd->GetNext<uint8_t>(&FAddr) == retvOk) { // Got address if(FAddr == ADDR_MASTER) OnSlaveCmd(PShell, PCmd); // Universal or slave cmd else ProcessCmdForSlave(PShell, PCmd, FAddr); } else PShell->BadParam(); } } else { // We are slave if(PCmd->GetNext<uint8_t>(&FAddr) == retvOk) { // Printf("Addr: %u\r", FAddr); if(FAddr == SelfInfo.Addr) OnSlaveCmd(PShell, PCmd); } } } // not direct } void TryToChangeRealDeviceParams(Cmd_t *PCmd, uint8_t Addr, uint8_t Type, char *PName) { if(RS485Int.SendCmd(TIMEOUT_SHORT_ms, "GetTypeName", Addr) == retvOk) { uint8_t CurType; if(RS485Int.Reply.GetNext<uint8_t>(&CurType) == retvOk) { char *CurName = RS485Int.Reply.GetNextString(); if(strcmp(CurName, PName) != 0) RS485Int.SendCmd(TIMEOUT_SHORT_ms, "ChangeName", Addr, "%S", PName); if(CurType != Type) RS485Int.SendCmd(TIMEOUT_SHORT_ms, "ChangeType", Addr, "%u", Type); } } // If device replied. Do nothing if not. } uint8_t ProcessMasterCmd(Shell_t *PShell, Cmd_t *PCmd) { if(PCmd->NameIs("Scan")) { PShell->Print("Addr Type Name\n"); bool SomeoneFound = false; for(uint32_t i=ADDR_MIN; i<=ADDR_MAX; i++) { if(i == ADDR_MASTER) continue; if(RS485Int.SendCmd(TIMEOUT_SHORT_ms, "GetTypeName", i) == retvOk) { PShell->Print("%4u %S %S\n", i, RS485Int.Reply.GetNextString(), RS485Int.Reply.GetNextString()); SomeoneFound = true; } } if(SomeoneFound) PShell->EOL(); else PShell->Print("NoDevices\r\n"); } else if(PCmd->NameIs("GetDeviceList")) { if(DevList.Cnt() == 0) PShell->Print("NoDevices\r\n"); else { uint32_t LongestNameLen = DevList.GetLongestNameLen(); PShell->Print("Addr Type %*S State\n", LongestNameLen, "Name"); for(int32_t i=0; i<DevList.Cnt(); i++) { PShell->Print("%4u %4u %*S ", DevList[i].Addr, DevList[i].Type, LongestNameLen, DevList[i].Name); if(RS485Int.SendCmd(TIMEOUT_SHORT_ms, "GetTypeName", DevList[i].Addr) == retvOk) { // Check if type and name are same uint8_t Type = 0; if(RS485Int.Reply.GetNext<uint8_t>(&Type) == retvOk and Type == DevList[i].Type) { if(strcmp(RS485Int.Reply.GetNextString(), DevList[i].Name) == 0) { PShell->Print("OK\n"); continue; } } PShell->Print("DifferentParams\n"); } else PShell->Print("NoAnswer\n"); // Notice \n here } // for PShell->EOL(); } } else if(PCmd->NameIs("AddDevice")) { if(DevList.Cnt() >= DEV_CNT_MAX) { PShell->Print("TableFull\r\n"); return retvOk; } uint8_t Addr = 0, Type = 0; if(PCmd->GetNext<uint8_t>(&Addr) != retvOk or !AddrIsOk(Addr)) { PShell->BadParam(); return retvOk; } if(PCmd->GetNext<uint8_t>(&Type) != retvOk or !TypeIsOk(Type)) { PShell->BadParam(); return retvOk; } if(DevList.ContainsAddr(Addr)) { PShell->Print("DeviceExists\r\n"); return retvOk; } char *PName = PCmd->GetNextString(); if(!PName) { PShell->BadParam(); return retvOk; } int Len = strlen(PName); if(Len > DEV_NAME_LEN) { PShell->BadParam(); return retvOk; } // All is finally ok DevList.Add(Addr, (DevType_t)Type, PName); TryToChangeRealDeviceParams(PCmd, Addr, Type, PName); PShell->Ok(); DevList.Save(); } else if(PCmd->NameIs("PutDevice")) { uint8_t Addr = 0, Type = 0; if(PCmd->GetNext<uint8_t>(&Addr) != retvOk or !AddrIsOk(Addr)) { PShell->BadParam(); return retvOk; } if(PCmd->GetNext<uint8_t>(&Type) != retvOk or !TypeIsOk(Type)) { PShell->BadParam(); return retvOk; } char *PName = PCmd->GetNextString(); if(!PName) { PShell->BadParam(); return retvOk; } int Len = strlen(PName); if(Len > DEV_NAME_LEN) { PShell->BadParam(); return retvOk; } // Params are ok Device_t* PDev = DevList.GetByAddr(Addr); if(PDev) { // Exists PDev->Type = (DevType_t)Type; strcpy(PDev->Name, PName); } else { // Not exists, try to add if(DevList.Cnt() >= DEV_CNT_MAX) { PShell->Print("TableFull\r\n"); return retvOk; } DevList.Add(Addr, (DevType_t)Type, PName); } TryToChangeRealDeviceParams(PCmd, Addr, Type, PName); PShell->Ok(); DevList.Save(); } else if(PCmd->NameIs("DelDevice")) { uint8_t Addr = 0; if(PCmd->GetNext<uint8_t>(&Addr) != retvOk) { PShell->BadParam(); return retvOk; } if(DevList.Delete(Addr) == retvOk) { PShell->Ok(); DevList.Save(); } else PShell->Print("NoDevices\r\n"); } else if(PCmd->NameIs("GetAllStates")) { uint32_t LongestNameLen = DevList.GetLongestNameLen(); PShell->Print("Addr Type %*S State\n", LongestNameLen, "Name"); PShell->Print("%4u %4u %*S %S GPIO=0x%X\n", ADDR_MASTER, SelfInfo.Type, LongestNameLen, SelfInfo.Name, XSTRINGIFY(BUILD_TIME), GpioReg.Get()); for(int32_t i=0; i<DevList.Cnt(); i++) { PShell->Print("%4u %4u %*S ", DevList[i].Addr, DevList[i].Type, LongestNameLen, DevList[i].Name); if(RS485Int.SendCmd(TIMEOUT_SHORT_ms, "GetTypeName", DevList[i].Addr) == retvOk) { // Check if type and name are same uint8_t Type = 0; if(RS485Int.Reply.GetNext<uint8_t>(&Type) == retvOk and Type == DevList[i].Type) { if(RS485Int.SendCmd(TIMEOUT_SHORT_ms, "GetState", DevList[i].Addr) == retvOk) { PShell->Print("%S\n", RS485Int.Reply.GetRemainder()); continue; } else { PShell->Print("NoAnswer\n"); continue; } // Notice \n here } PShell->Print("DifferentParams\n"); } else PShell->Print("NoAnswer\n"); // Notice \n here } // for PShell->EOL(); } else return retvNotFound; return retvOk; } void OnSlaveCmd(Shell_t *PShell, Cmd_t *PCmd) { #if 1 // ==== Addr, type, name ==== if(PCmd->NameIs("Ping")) PShell->Ok(); else if(PCmd->NameIs("ChangeAddr")) { uint8_t Addr; if(PCmd->GetNext<uint8_t>(&Addr) != retvOk or !AddrIsOk(Addr)) { PShell->Print("BadParam\r\n"); return; } SelfInfo.Addr = Addr; TryToSaveSelfInfo(PShell); } else if(PCmd->NameIs("ChangeType")) { uint8_t Type; if(PCmd->GetNext<uint8_t>(&Type) != retvOk or !TypeIsOk(Type)) { PShell->Print("BadParam\r\n"); return; } SetType((DevType_t)Type, PShell); } else if(PCmd->NameIs("ChangeName")) { char *S = PCmd->GetNextString(); if(!S or strlen(S) > DEV_NAME_LEN) { PShell->BadParam(); return; } strcpy(SelfInfo.Name, S); TryToSaveSelfInfo(PShell); } else if(PCmd->NameIs("GetTypeName")) { PShell->Print("RGetTypeName %u %S\r\n", SelfInfo.Type, SelfInfo.Name); } #endif #if 1 // ==== GPIO Reg ==== else if(PCmd->NameIs("SetGPIO")) { uint32_t Reg; if(PCmd->GetNext<uint32_t>(&Reg) != retvOk) { PShell->BadParam(); return; } GpioReg.Set(Reg); PShell->Ok(); } else if(PCmd->NameIs("GetGPIO")) { PShell->Print("RGetGPIO 0x%X\r\n", GpioReg.Get()); } else if(PCmd->NameIs("SetPowerOnGPIO")) { uint32_t Reg; if(PCmd->GetNext<uint32_t>(&Reg) != retvOk) { PShell->BadParam(); return; } Settings.PowerOnGPIO = Reg; if(Settings.Save() == retvOk) PShell->Ok(); else PShell->Failure(); } else if(PCmd->NameIs("GetPowerOnGPIO")) { PShell->Print("RGetPowerOnGPIO 0x%X\r\n", Settings.PowerOnGPIO); } #endif #if 1 // ==== SPI ==== else if(PCmd->NameIs("WRSPI")) { uint8_t Params; if(PCmd->GetNext<uint8_t>(&Params) != retvOk) { PShell->BadParam(); return; } // SPI1 is not allowed for direct writing if((SelfInfo.Type == devtMRL or SelfInfo.Type == devtKUKonv) and ((Params & 0x10) == 0)) { PShell->BadParam(); return; } uint8_t *p = FileBuf; while(PCmd->GetNext<uint8_t>(p) == retvOk) p++; // Get what to send uint32_t Len = p - FileBuf; if(Params & 0x10) Spi2.Transmit(Params, FileBuf, Len); else Spi1.Transmit(Params, FileBuf, Len); // Reply p = FileBuf; PShell->Print("RWRSPI"); while(Len--) PShell->Print(" 0x%02X", *p++); PShell->EOL(); } else if(PCmd->NameIs("wSPIFile")) { uint8_t Params; if(PCmd->GetNext<uint8_t>(&Params) != retvOk) { PShell->BadParam(); return; } // SPI1 is not allowed for direct writing if((SelfInfo.Type == devtMRL or SelfInfo.Type == devtKUKonv) and ((Params & 0x10) == 0)) { PShell->BadParam(); return; } uint32_t Len; if(PCmd->GetNext<uint32_t>(&Len) != retvOk or Len > FILEBUF_SZ) { PShell->BadParam(); return; } Led.StartOrRestart(lsqWriting); // Receive data if(PShell->ReceiveBinaryToBuf(FileBuf, Len, TIMEOUT_LONG_ms) == retvOk) { if(Params & 0x10) Spi2.Transmit(Params, FileBuf, Len); else Spi1.Transmit(Params, FileBuf, Len); PShell->Ok(); } else PShell->Timeout(); Led.StartOrRestart(lsqCmd); } else if(PCmd->NameIs("rSpiFile")) { uint32_t Len; if(PCmd->GetNext<uint32_t>(&Len) == retvOk and Len <= FILEBUF_SZ) { Led.StartOrRestart(lsqWriting); if(PShell->TransmitBinaryFromBuf(FileBuf, Len, TIMEOUT_LONG_ms) != retvOk) PShell->Timeout(); Led.StartOrRestart(lsqCmd); } else PShell->BadParam(); } else if(PCmd->NameIs("SetCS1")) { uint32_t CsActiveLow; if(PCmd->GetNext<uint32_t>(&CsActiveLow) == retvOk) { Settings.SpiSetup.CS1ActiveLow = (bool)CsActiveLow; Spi1.Init(CsActiveLow); if(Settings.Save() == retvOk) PShell->Ok(); else PShell->Failure(); } else PShell->BadParam(); } else if(PCmd->NameIs("SetCS2")) { uint32_t CsActiveLow; if(PCmd->GetNext<uint32_t>(&CsActiveLow) == retvOk) { Settings.SpiSetup.CS2ActiveLow = (bool)CsActiveLow; Spi2.Init(CsActiveLow); if(Settings.Save() == retvOk) PShell->Ok(); else PShell->Failure(); } else PShell->BadParam(); } else if(PCmd->NameIs("GetCS1")) { PShell->Print("RGetCS1 %u\r\n", Settings.SpiSetup.CS1ActiveLow); } else if(PCmd->NameIs("GetCS2")) { PShell->Print("RGetCS2 %u\r\n", Settings.SpiSetup.CS2ActiveLow); } #endif else if(PCmd->NameIs("UpdateFW")) { uint32_t Len, CrcIn; if(PCmd->GetNext<uint32_t>(&Len) != retvOk or Len > FILEBUF_SZ) { PShell->BadParam(); return; } if(PCmd->GetNext<uint32_t>(&CrcIn) != retvOk) { PShell->BadParam(); return; } // Receive data Led.StartOrRestart(lsqWriting); if(PShell->ReceiveBinaryToBuf(FileBuf, Len, TIMEOUT_LONG_ms) == retvOk) { uint8_t rslt = UpdateFw(FileBuf, Len, CrcIn); if(rslt == retvOk) { PShell->Ok(); chThdSleepMilliseconds(72); // Let it end transmisison Flash::ToggleBootBankAndReset(); } else if(rslt == retvCRCError) PShell->CRCError(); else PShell->Failure(); } else PShell->Timeout(); Led.StartOrRestart(lsqCmd); } else if(PCmd->NameIs("GetState")) { PShell->Print("RGetState %S GPIO=0x%X", XSTRINGIFY(BUILD_TIME), GpioReg.Get()); switch(SelfInfo.Type) { case devtNone: case devtHFBlock: break; case devtLNA: case devtTriplexer: PShell->Print(" t=%.1f TStating=%d", tControl.tAvg, Settings.TControlEnabled); for(auto &Sns : tControl.Sensors) { if(Sns.IsOk) PShell->Print(" %S=%.1f", Sns.Name, Sns.t); else PShell->Print(" %S=err", Sns.Name); } break; case devtKUKonv: break; case devtMRL: break; case devtIKS: break; } PShell->EOL(); } #if 1 // ==== Thermostating ==== else if(PCmd->NameIs("SetTTS")) { float t; if(PCmd->GetNextFloat(&t) != retvOk) { PShell->BadParam(); return; } if(t < 0 or t > 125) { PShell->BadParam(); return; } Settings.TargetT = t; if(Settings.Save() == retvOk) PShell->Ok(); else PShell->Failure(); } else if(PCmd->NameIs("GetTTS")) { PShell->Print("RGetTTS %.1f\r\n", Settings.TargetT); } else if(PCmd->NameIs("SetTstating")) { if(SelfInfo.Type == devtLNA or SelfInfo.Type == devtTriplexer) { uint8_t OnOff; if(PCmd->Get("%u8", &OnOff) != 1) { PShell->BadParam(); return; } if(OnOff > 0) OnOff = 1; Settings.TControlEnabled = OnOff; if(OnOff) tControl.StartControl(); else tControl.StartMeasure(); if(Settings.Save() == retvOk) PShell->Ok(); else PShell->Failure(); } else PShell->CmdError(); } else if(PCmd->NameIs("GetTstating")) { PShell->Print("RGetTstating %u\r\n", Settings.TControlEnabled); } #endif #if 1 // ==== HMC821 ==== else if(SelfInfo.Type == devtMRL) { if(PCmd->NameIs("SetRegs")) { uint32_t Cnt = 0, Addr, Value; while(true) { if(PCmd->GetNext<uint32_t>(&Addr) != retvOk) break; if(PCmd->GetNext<uint32_t>(&Value) != retvOk) { PShell->BadParam(); return; } // Addr exsits, value does not Hmc821.WriteReg(Addr, Value); Cnt++; } if(Cnt) PShell->Ok(); else PShell->BadParam(); } else if(PCmd->NameIs("SaveRegs")) { uint32_t Cnt = 0, Addr[REG_CNT], Value[REG_CNT]; // Get regs while(true) { if(Cnt >= REG_CNT) { PShell->BadParam(); return; } if(PCmd->GetNext<uint32_t>(&Addr[Cnt]) != retvOk) break; if(PCmd->GetNext<uint32_t>(&Value[Cnt]) != retvOk) { PShell->BadParam(); return; } // Addr exsits, value is not Cnt++; } if(!Cnt) { PShell->BadParam(); return; } // Put regs to settings for(uint32_t i=0; i<Cnt; i++) { Settings.Hmc821.Regs[i].Addr = Addr[i]; Settings.Hmc821.Regs[i].Value = Value[i]; } // Save settings Settings.WhatSaved = SAVED_REGS_FLAG; Settings.SavedRegsCnt = Cnt; if(Settings.Save() == retvOk) PShell->Ok(); else PShell->Failure(); } else if(PCmd->NameIs("GetRegs")) { if(Settings.WhatSaved == SAVED_REGS_FLAG and Settings.SavedRegsCnt <= REG_CNT) { PShell->Print("RGetRegs "); for(uint32_t i=0; i<Settings.SavedRegsCnt; i++) { PShell->Print("0x%X 0x%X, ", Settings.Hmc821.Regs[i].Addr, Settings.Hmc821.Regs[i].Value); } PShell->EOL(); } else PShell->Print("RGetRegs Empty\r\n"); } else if(PCmd->NameIs("ClearRegs")) { Settings.WhatSaved = SAVED_NONE_FLAG; if(Settings.Save() == retvOk) PShell->Ok(); else PShell->Failure(); } else if(PCmd->NameIs("ReloadRegs")) { if(Settings.WhatSaved == SAVED_REGS_FLAG and Settings.SavedRegsCnt <= REG_CNT) { for(uint32_t i=0; i<Settings.SavedRegsCnt; i++) { Hmc821.WriteReg(Settings.Hmc821.Regs[i].Addr, Settings.Hmc821.Regs[i].Value); } PShell->Ok(); } else PShell->Failure(); } } #endif #if 1 // ==== ADF5356 (KuKonv & IKS) ==== else if(SelfInfo.Type == devtKUKonv or SelfInfo.Type == devtIKS) { if(PCmd->NameIs("SetRegs")) { uint32_t Cnt = 0, Value; while(true) { if(PCmd->GetNext<uint32_t>(&Value) != retvOk) break; Adf5356.WriteReg(Value); Cnt++; } if(Cnt) PShell->Ok(); else PShell->BadParam(); } else if(PCmd->NameIs("SaveRegs")) { uint32_t Cnt = 0, Value[REG_CNT]; // Get regs while(true) { if(Cnt >= REG_CNT) { PShell->BadParam(); return; } if(PCmd->GetNext<uint32_t>(&Value[Cnt]) != retvOk) break; Cnt++; } if(!Cnt) { PShell->BadParam(); return; } // Put regs to settings for(uint32_t i=0; i<Cnt; i++) { Settings.Adf5356.Regs[i] = Value[i]; // Printf("%X\r", Value[i]); } // Save settings Settings.WhatSaved = SAVED_REGS_FLAG; Settings.SavedRegsCnt = Cnt; if(Settings.Save() == retvOk) PShell->Ok(); else PShell->Failure(); } else if(PCmd->NameIs("GetRegs")) { if(Settings.WhatSaved == SAVED_REGS_FLAG and Settings.SavedRegsCnt <= REG_CNT) { PShell->Print("RGetRegs "); for(uint32_t i=0; i<Settings.SavedRegsCnt; i++) { PShell->Print("0x%X ", Settings.Adf5356.Regs[i]); } PShell->EOL(); } else PShell->Print("RGetRegs Empty\r\n"); } else if(PCmd->NameIs("ClearRegs")) { Settings.WhatSaved = SAVED_NONE_FLAG; if(Settings.Save() == retvOk) PShell->Ok(); else PShell->Failure(); } else if(PCmd->NameIs("CalcRegs")) { if(PCmd->GetNextDouble(&Adf5356.fref) != retvOk) { PShell->BadParam(); return; } if(PCmd->GetNextDouble(&Adf5356.step) != retvOk) { PShell->BadParam(); return; } if(PCmd->GetNextDouble(&Adf5356.fd ) != retvOk) { PShell->BadParam(); return; } if(PCmd->GetNextDouble(&Adf5356.fvco) != retvOk) { PShell->BadParam(); return; } Adf5356.CalcRegs(); Adf5356.PrintRegs(); PShell->Ok(); } else if(PCmd->NameIs("CalcRegsAndSet")) { if(PCmd->GetNextDouble(&Adf5356.fref) != retvOk) { PShell->BadParam(); return; } if(PCmd->GetNextDouble(&Adf5356.step) != retvOk) { PShell->BadParam(); return; } if(PCmd->GetNextDouble(&Adf5356.fd ) != retvOk) { PShell->BadParam(); return; } if(PCmd->GetNextDouble(&Adf5356.fvco) != retvOk) { PShell->BadParam(); return; } Adf5356.CalcRegs(); Adf5356.SetRegs(); PShell->Ok(); } else if(PCmd->NameIs("SaveSynthParams")) { double fref, step, fd, fvco; if(PCmd->GetNextDouble(&fref) != retvOk) { PShell->BadParam(); return; } if(PCmd->GetNextDouble(&step) != retvOk) { PShell->BadParam(); return; } if(PCmd->GetNextDouble(&fd ) != retvOk) { PShell->BadParam(); return; } if(PCmd->GetNextDouble(&fvco) != retvOk) { PShell->BadParam(); return; } Settings.Adf5356.fref = fref; Settings.Adf5356.step = step; Settings.Adf5356.fd = fd; Settings.Adf5356.fvco = fvco; Settings.WhatSaved = SAVED_PARAMS_FLAG; if(Settings.Save() == retvOk) PShell->Ok(); else PShell->Failure(); } else if(PCmd->NameIs("ReloadRegs")) { if(Settings.WhatSaved == SAVED_REGS_FLAG and Settings.SavedRegsCnt <= REG_CNT) { for(uint32_t i=0; i<Settings.SavedRegsCnt; i++) { Adf5356.WriteReg(Settings.Adf5356.Regs[i]); } PShell->Ok(); } else PShell->Failure(); } } #endif } uint8_t Ping(uint8_t Addr) { if(RS485Int.SendCmd(TIMEOUT_MID_ms, "Ping", Addr) == retvOk) { if(RS485Int.Reply.NameIs("Ok")) return retvOk; } return retvNoAnswer; } void ProcessCmdForSlave(Shell_t *PShell, Cmd_t *PCmd, uint32_t Addr) { // Do not waste time if there is no device on the bus if(Ping(Addr) != retvOk) { PShell->NoAnswer(); return; } // ==== Special cases ==== if(PCmd->NameIs("wSPIFile")) { uint8_t Params; if(PCmd->GetNext<uint8_t>(&Params) != retvOk) { PShell->BadParam(); return; } uint32_t Len; if(PCmd->GetNext<uint32_t>(&Len) != retvOk or Len > FILEBUF_SZ) { PShell->BadParam(); return; } // Receive data from host if(PShell->ReceiveBinaryToBuf(FileBuf, Len, TIMEOUT_LONG_ms) == retvOk) { // PShell->Print("File rcvd\r\n"); // Send data away if(RS485Int.SendCmdAndTransmitBuf(TIMEOUT_LONG_ms, FileBuf, Len, PCmd->Name, Addr, "%u %u", Params, Len) == retvOk) { if(RS485Int.Reply.NameIs("Ok")) PShell->Ok(); else PShell->Failure(); } else PShell->Timeout(); } else PShell->Timeout(); } else if(PCmd->NameIs("rSpiFile")) { uint32_t Len; if(PCmd->GetNext<uint32_t>(&Len) != retvOk or Len > FILEBUF_SZ) { PShell->BadParam(); return; } // Get data from there if(RS485Int.SendCmdAndReceiveBuf(TIMEOUT_LONG_ms, FileBuf, Len, PCmd->Name, Addr, "%u", Len) == retvOk) { // Send data to host if(PShell->TransmitBinaryFromBuf(FileBuf, Len, TIMEOUT_LONG_ms) != retvOk) PShell->Timeout(); } else PShell->Timeout(); } if(PCmd->NameIs("UpdateFW")) { uint32_t Len, CrcIn; if(PCmd->GetNext<uint32_t>(&Len) != retvOk or Len > FILEBUF_SZ) { PShell->BadParam(); return; } if(PCmd->GetNext<uint32_t>(&CrcIn) != retvOk) { PShell->BadParam(); return; } // Receive data Led.StartOrRestart(lsqWriting); if(PShell->ReceiveBinaryToBuf(FileBuf, Len, TIMEOUT_LONG_ms) == retvOk) { PShell->Print("FileRcvd\r\n"); // Check CRC uint16_t crc = Crc::CalculateCRC16HWDMA(FileBuf, Len); if(crc == CrcIn) { // Send data away if(RS485Int.SendCmdAndTransmitBuf(TIMEOUT_LONG_ms, FileBuf, Len, PCmd->Name, Addr, "%u 0x%X", Len, CrcIn) == retvOk) { if(RS485Int.Reply.NameIs("Ok")) PShell->Ok(); else PShell->Failure(); } else PShell->Timeout(); } else PShell->CRCError(); } else PShell->Timeout(); Led.StartOrRestart(lsqCmd); } // ==== Non-special command ==== else { if(RS485Int.SendCmd(TIMEOUT_MID_ms, PCmd->Name, Addr, PCmd->GetRemainder()) == retvOk) { PShell->Print("%S %S\r\n", RS485Int.Reply.Name, RS485Int.Reply.GetRemainder()); } else PShell->NoAnswer(); } } #endif
[ "laystoll@yandex.ru" ]
laystoll@yandex.ru
13bb9c1f1634dfe150810d3d9c18417ba4832218
6813b2690adb4015282c22108184b4e2229d9da3
/Tetris.cpp
d458b29cad2c518ef90b6cd6d198f3da44f57d95
[]
no_license
Toumash/2d-tetris-game
da722032bf777f1c1c58860c6339e6c1871d5070
e4b7cb28776561125f8078198b8fa85ef1513878
refs/heads/master
2022-12-08T04:22:49.183840
2020-08-29T11:22:31
2020-08-29T11:22:31
109,607,349
0
0
null
null
null
null
UTF-8
C++
false
false
5,818
cpp
#include <cstdlib> #include "main.h" #include <cstdio> #ifndef __TETRIS__ #define __TETRIS__ struct Tetris { private: int PlayerX; int PlayerY; public: // standard tetris dimensions static const int WIDTH = 10; static const int HEIGHT = 22; char** Matrix; char** Player; int Width; int Height; bool canRotate; int score = 0, level = 0; double worldTime = 0; int LastPlayerX = 0; int LastPlayerY = 0; int saves = 0; Tetris(int width, int height) { ResetPlayerPosition(); this->Width = width; this->Height = height; this->Player = NULL; this->canRotate = true; Matrix = (char**)malloc(height * sizeof(char*)); for (int y = 0; y < height; y++) { Matrix[y] = (char*)malloc(width* sizeof(char)); for (int x = 0; x < width; x++) { Matrix[y][x] = I_FREE; } } } void ResetPlayerPosition() { PlayerX = WIDTH / 2 - 2; PlayerY = 0; } /*worldTime score level saves width height map playerX playerY lastX lastY playerShape */ static bool LoadFromFile(Tetris* game, const char * name) { FILE* f = fopen(name, "r"); if (!f) { return false; } double wT; int score, level, saves; fscanf(f, "%lf %d %d %d", &wT, &score, &level, &saves); int width, height; fscanf(f, "%d %d", &width, &height); game->worldTime = wT; game->score = score; game->level = level; game->saves = saves; game->Width = width; game->Height = height; game->Matrix = (char**)malloc(height + 2 * sizeof(char*)); int tmp; for (int y = 0; y < height; y++) { game->Matrix[y] = (char*)malloc(width* sizeof(char)); for (int x = 0; x < width; x++) { fscanf(f, "%d", &tmp); game->Matrix[y][x] = (char)tmp; } } fscanf(f, "%d %d", &game->PlayerX, &game->PlayerY); fscanf(f, "%d %d", &game->LastPlayerX, &game->LastPlayerY); game->Player = (char**)malloc(SHAPE_SIZE * sizeof(char*)); for (int y = 0; y < SHAPE_SIZE; y++) { game->Player[y] = (char*)malloc(SHAPE_SIZE * sizeof(char)); for (int x = 0; x < SHAPE_SIZE; x++) { fscanf(f, "%d", &tmp); game->Player[y][x] = tmp; } } fclose(f); f = NULL; return true; } static bool SaveGame(const char * saveFile, Tetris& game) { FILE* f = fopen(saveFile, "w+"); if (!f) { return false; } fprintf(f, "%f %i %i %i\n", game.worldTime, game.score, game.level, game.saves); fprintf(f, "%i %i\n", game.Width, game.Height); for (int y = 0; y < game.Height; y++) { for (int x = 0; x < game.Width; x++) { fprintf(f, "%i ", game.Matrix[y][x]); } fprintf(f, "\n"); } fprintf(f, "%i %i\n", game.PlayerX, game.PlayerY); fprintf(f, "%i %i\n", game.LastPlayerX, game.LastPlayerY); for (int y = 0; y < SHAPE_SIZE; y++) { for (int x = 0; x < SHAPE_SIZE; x++) { fprintf(f, "%i ", game.Player[y][x]); } fprintf(f, "\n"); } fflush(f); fclose(f); return true; } int GetPlayerX() const { return this->PlayerX; } int GetPlayerY() const { return this->PlayerY; } void SetPlayerX(int x) { LastPlayerX = PlayerX; PlayerX = x; } void SetPlayerY(int y) { LastPlayerY = PlayerY; PlayerY = y; } bool isColliding(int dstX, int dstY, char** player) const { char** matrix = this->Matrix; int height = this->Height; int width = this->Width; for (int y = 0; y < SHAPE_SIZE; y++) { for (int x = 0; x < SHAPE_SIZE; x++) { if (player[y][x] != I_FREE) { // checks agains bounds (canvas) if ((y - SHAPE_PIVOT + dstY >= height) || (x - SHAPE_PIVOT + dstX >= width) || (x - SHAPE_PIVOT + dstX < 0)) { return true; } // checks agains other fields if (dstY - SHAPE_PIVOT + y >= 2 && dstX - SHAPE_PIVOT + x >= 0) { if (matrix[dstY - SHAPE_PIVOT + y][dstX - SHAPE_PIVOT + x] != I_FREE) { return true; } } } } } return false; } // returns the amount of deleted lines int DeleteFullLines() { int deletedAmount = 0; for (int row = Height - 1; row > 0; row--) { bool full = true; for (int x = 0; x < Width; x++) { if (Matrix[row][x] == I_FREE) { full = false; } } if (full) { deletedAmount++; //removing process // Moves all the upper lines one row down for (int y = row; y > 0; y--) { for (int x = 0; x < Width; x++) { Matrix[y][x] = Matrix[y - 1][x]; } } } } return deletedAmount; } int previouslyRemovedRows = 0; void PlaceTetronimo() { for (int y = 0; y < SHAPE_SIZE; y++) { for (int x = 0; x < SHAPE_SIZE; x++) { if (PlayerY - SHAPE_PIVOT + y >= 0 && PlayerY - SHAPE_PIVOT + y < Height && Player[y][x] != I_FREE) { Matrix[PlayerY - SHAPE_PIVOT + y][PlayerX - SHAPE_PIVOT + x] = Player[y][x]; } } } // calculate point int deletedRows = DeleteFullLines(); score += calculatePoints(level, deletedRows, previouslyRemovedRows); previouslyRemovedRows = deletedRows; } static int calculatePoints(int level, int removedAmount, int previousRemoved) { switch (removedAmount) { case 1: return 100 * (level + 1); case 2: return 200 * (level + 1); case 3: return 400 * (level + 1); case 4: return (previousRemoved > 4 ? 1200 : 800)*(level + 1); default: return 0; } } void DisposePlayer() { if (Player != NULL) { for (int i = 0; i < SHAPE_SIZE; i++) { free(Player[i]); } free(Player); } } void Dispose() { for (int i = 0; i < Height; i++) { free(Matrix[i]); } free(Matrix); } bool CanRotate() const { return this->canRotate; } void NextShape(char** new_shape) { DisposePlayer(); this->Player = new_shape; } bool IsOver() const { bool over = false; for (int x = 0; x < Width; x++) { if (Matrix[2][x] != I_FREE) { over = true; } } return over; } }; #endif
[ "mr.toumash@gmail.com" ]
mr.toumash@gmail.com
6c7d3976c88fa24a30538ee4fa957928f711ac99
5c2a066016f9e9ee56a24251709bcd6fc777c153
/GLTestsApp/GLTestsApp/Classes/AppTestCArm/AppTestCArm.cpp
31eb2290b6bc42df5828e4b143b83ea023db6eb0
[]
no_license
cleonro/ObjLoader
33f9969c4f7fd0a954f7fec10c447c191e215e51
d7483cd89376ed53684e5415d8a09be0df691228
refs/heads/master
2016-09-15T19:15:28.497983
2014-01-23T21:46:50
2014-01-23T21:46:50
25,855,975
0
0
null
null
null
null
UTF-8
C++
false
false
1,999
cpp
#include "AppTestCArm.h" OAppTestCArm::OAppTestCArm() { c_arm_ = new OTestCArm(50.0f); data_for_input_.camera = &camera_; data_for_input_.c_arm = c_arm_; } OAppTestCArm::~OAppTestCArm() { delete c_arm_; } OAppTestCArm& OAppTestCArm::GetInstance() { static OAppTestCArm instance; return instance; }; void* OAppTestCArm::GetDataForInput() { return (void*)&data_for_input_; } void OAppTestCArm::Init(void* data) { OAppBaseState::Init(data); } void OAppTestCArm::Update(void* data) { OAppBaseState::Update(data); c_arm_->ComputeQuat(); OQuaternion qrot = c_arm_->Quat(); OQuaternion q_z_axis(0, 0, 1, 0); q_z_axis = qrot * q_z_axis * qrot.Transpose(); z_axis_ = q_z_axis.V3(); z_axis_ = 1.2f * c_arm_->Size() * z_axis_; xz_proj_ = OVector3(z_axis_.X(), 0, z_axis_.Z()); yz_proj_ = OVector3(0, z_axis_.Y(), z_axis_.Z()); } void OAppTestCArm::Update2(void* data) { OAppBaseState::Update2(data); } void OAppTestCArm::Draw() { glUseProgram(0); LightOn(); //DrawAxes(100.0f); VDraws->DrawAxes(110.0f, 1.0f); glEnable(GL_NORMALIZE); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_NORMAL_ARRAY); glEnableClientState(GL_COLOR_ARRAY); glPushMatrix(); glScalef(5.0f, 5.0f, 5.0f); c_arm_->Draw(); glPopMatrix(); glDisableClientState(GL_COLOR_ARRAY); glColor4f(1, 1, 1, 1); ///draw_axis(OVector3(0, 0, 0), xz_proj_, xz_proj_.Norm()); glColor4f(1, 1, 1, 1); //draw_axis(OVector3(0, 0, 0), yz_proj_, yz_proj_.Norm()); ///VDraws->DrawBox(OVector3(0, 0, 0), z_axis_); //OVector3 vxz = xz_proj_ + (-1.0f) * z_axis_; //OVector3 vyz = yz_proj_ + (-1.0f) * z_axis_; //draw_axis(z_axis_, vxz, vxz.Norm(), false); //draw_axis(z_axis_, vyz, vyz.Norm(), false); ///VDraws->DrawHorizontalQuad(35.0f, 100.0f); LightOff(); }
[ "cleon_ro@yahoo.com" ]
cleon_ro@yahoo.com
e1cab3c46ba46231868b383d2a9ce8a12566ae5a
9fb82f793f8dabc2625a6784c19ae6cdbfa5a40f
/CreditCardValidation/Validator.h
4a575bf3e51cd633ca6c092ea2542642706f6800
[]
no_license
DominicLightbody/CreditCardValidation-Project
c715121c7be079f8da64c5da368f15c9e3635da5
aabbf345302de153c7ceba9bbbb7c73ac1b16d3a
refs/heads/master
2021-07-20T00:21:22.131333
2017-10-29T03:38:07
2017-10-29T03:38:07
108,702,587
0
0
null
null
null
null
UTF-8
C++
false
false
505
h
#pragma once #include <iostream> #include <string> using namespace std; const string testCard[] = { "4686006570307405", "4686006570307407", "4093650457937474", "4340423439668810", "1234567812345670", "5509415774265347", "X234567812345670", "4539281167952835", "4532528637398511", "4653549906803760" }; class CreditCardValidation { private: static int convertChartoInt(const char digit); public: static bool validatecardNumber(const string cardNumber); bool digitValidation(string cardNumber); };
[ "dlightbody02@qub.ac.uk" ]
dlightbody02@qub.ac.uk
fb7ffe69689513ae8dd451f6b56201833d78393b
b4fa3d1e6354087762cc17ac652e7fc39c7dce82
/src/Graph.h
76d25b50e949980d8a635fc457461ab2496dbed4
[]
no_license
jbagot/search-best-hotel-place
b0cce5db3965967910fb9bd3f81195a5df2f4ae4
d29f2dd0a9e193aba658a7c14d4a193f1bc3cd50
refs/heads/master
2021-01-25T00:46:32.083630
2017-06-18T13:41:23
2017-06-18T13:41:23
94,687,549
0
0
null
null
null
null
UTF-8
C++
false
false
1,233
h
// // Created by jordi on 15/05/16. // #ifndef REPO_CPP_GRAPH_H #define REPO_CPP_GRAPH_H #include <iostream> #include <stdio.h> #include <time.h> #include <list> #include <queue> #include <map> #include <GL/glut.h> #include "Node.h" using namespace std; class Graph { public: static Graph* Instance(); ~Graph() {} void addNode(Node); void deleteNode(Node); Node& getNode(long); bool existNode(long); list<Node> getTourismNodes(); list<Node> getUndeletedNodes(); list<Node> getDeletedNodes(); map<long, Node> getAllNodes(); void toString(); //Getters double getXMax(); double getYMax(); double getXMin(); double getYMin(); double getMaxDistance(); double getMinDistance(); double getMaxScore(); //Setters void setXMax(double); void setYMax(double); void setXMin(double); void setYMin(double); void setMaxDistance(double); void setMinDistance(double); void calculateMaxMinDistance(); private: static Graph* _instance; Graph() {} map<long, Node> _nodes; double _x_max; double _y_max; double _x_min; double _y_min; double _maxDistance; double _minDistance; }; #endif //REPO_CPP_GRAPH_H
[ "jbagotsoler@gmail.com" ]
jbagotsoler@gmail.com
6389e582d14a33e3e31d0c59fe808e6b6b8f8b10
3d424a8d682d4e056668b5903206ccc603f6e997
/NeoLoader/Common/Caffeine/Caffeine_win.cpp
e2d1967bbad4d150bbe95f8e4069fd0578ef5ba3
[]
no_license
markus851/NeoLoader
515e238b385354b83bbc4f7399a85524d5b03d12
67c9b642054ead500832406a9c301a7b4cbfffd3
refs/heads/master
2022-04-22T07:51:15.418184
2015-05-08T11:37:53
2015-05-08T11:37:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
581
cpp
#include "Caffeine.h" #include <windows.h> #include <winbase.h> class CCaffeinePrivate { public: CCaffeinePrivate() { bRunning = false; } bool bRunning; }; CCaffeine::CCaffeine(QObject* parent) : QObject(parent) , d(new CCaffeinePrivate()) { } CCaffeine::~CCaffeine() { if(IsRunning()) Stop(); } void CCaffeine::Start() { d->bRunning = true; SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED); } bool CCaffeine::IsRunning() { return d->bRunning; } void CCaffeine::Stop() { SetThreadExecutionState(ES_CONTINUOUS); d->bRunning = false; }
[ "David@X.com" ]
David@X.com
1d8e3d72e0a96db106492f7f5ba5cf63335c8d16
1e2eb6e815b1b966ec4c56b5e01bdf4809ddf77e
/include/Util/Callback.hpp
6967e25bda173996091f7833cf56796cef1d6469
[]
no_license
d-kowalik/pathfinding-visualizer
ec5fa35aaabdadbe5dafd3bdf94fa1de8f64f6d4
732d4fd351d06ace1db87080cf9f3bbf714ecece
refs/heads/master
2020-12-20T14:30:11.655226
2020-02-14T01:35:09
2020-02-14T01:35:09
236,107,027
0
0
null
null
null
null
UTF-8
C++
false
false
953
hpp
#pragma once #include <functional> namespace sge::Util { template<typename ...Args> class Callback { public: using Event = std::function<void(Args...)>; private: std::vector<Event> _events; public: static size_t GetAddress(Event f) { typedef void(fnType)(Args...); fnType** fnPointer = f.template target<fnType*>(); return (size_t)*fnPointer; } void operator()(Args... args) const { for (const auto& event : _events) { event(args...); } } Callback<Args...>& operator+=(const Event& rhs) { _events.push_back(rhs); return *this; } Callback<Args...>& operator-=(const Event& rhs) { auto it = std::find_if( _events.begin(), _events.end(), [&](const Event& event) { return Callback::GetAddress(event) == Callback::GetAddress(rhs); }); if (it != _events.end()) _events.erase(it); return *this; } }; }
[ "dev.damian.kowalik@gmail.com" ]
dev.damian.kowalik@gmail.com
33120c79be190dd90bd10f98815ac20f92aabb8e
bf2775c10af37ed30e6797aaea4fb319bd868161
/src/middleffwatermarker.cpp
8940bf774b65778db0179a7af78fea633120dd64
[]
no_license
ppva/Image_watermarking
a67073f9cf91a37617d1008c242f085ac2a512ed
ce01b1816a2f59b1ff5d10900d9f4724369acbeb
refs/heads/master
2021-09-24T01:38:27.603273
2018-10-01T07:45:38
2018-10-01T07:45:38
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,272
cpp
/*** Parallel version of the program using FastFlow (see @ https://github.com/fastflow/fastflow). Loading and saving are not parallelized and put in a pipeline, but rather preloaded in memory. Parallelization is done on the marking stage only (the emitter simply sends out the pre-loaded images). ***/ #include <ff/farm.hpp> #include <ff/pipeline.hpp> #include <dirent.h> #include <sstream> #include "queue.h" #include "my_utils.h" std::atomic<int> processed; // Watermark cimg_library::CImg<float> * wmark; std::vector<task*> tasks; struct Img_save{ std::string save_path; cimg_library::CImg<float> *img; }; // Node that emits the image paths (that have been pre-loaded) struct Emitter : public ff::ff_node_t<task, std::string>{ Emitter(std::string dir) : src_path(dir) { } std::string* svc(task*) { for (task *t:tasks) ff_send_out(t); return EOS; } private: std::string src_path; }; // Node that marks the chunks of the images struct Marker : public ff::ff_node_t<task, std::string>{ Marker(float intensity) : _intensity(intensity){}; std::string *svc(task * t){ mark_chunk(t -> img, t -> chunk, wmark, _intensity); delete(t -> chunk); return GO_ON; } private: float _intensity; }; int main(int argc, char* argv[]){ std::string src_path, wmark_file; int sflag = -1, wflag = -1; int c, n_workers = 1, n_chunks = 0; float intensity = 0.3; char * end; const char * USAGE = "Usage -s <src_path> -w <watermark_file> -c <chunks> -n <parallelism degree> -i <intensity>\n" "-s src_path --- Directory containing the images to be watermarked\n" "-w watermark_file --- Path of the watermark to be used\n" "-c chunks --- Number of chunks to divide each image in, defaults to parallelism degree\n" "-n parallelism degree --- Parallelism degree to be used\n" "-i intensity --- Intensity of the watermark image, from 0 (completely transparent) to 100 (completely opaque)\n"; std::vector<std::thread> workers; std::vector<Img_save> images; // Parse command line arguments while ((c = getopt (argc, argv, "s:w:n:i:c:")) != -1) switch (c){ case 's': sflag = 1; src_path = optarg; mkdir(&(src_path+"watermarked")[0u], 0700); break; case 'w': wflag = 1; wmark_file = optarg; break; case 'n': n_workers = strtol(optarg, &end, 10); if (*end != '\0') { std::cerr << "Invalid number of workers.\n"; std::cerr << USAGE << std::endl; exit(1); } break; case 'c': n_chunks = strtol(optarg, &end, 10); if (*end != '\0') { std::cerr << "Invalid number of chunks.\n"; std::cerr << USAGE << std::endl; exit(1); } if (n_chunks <= 0){ std::cerr << "Invalid number of chunks.\n"; std::cerr << USAGE << std::endl; exit(1); } break; case 'i': intensity = strtol(optarg, &end, 10); if (*end != '\0') { std::cerr << "Invalid intensity.\n"; std::cerr << USAGE << std::endl; exit(1); } intensity = intensity/100; if (intensity < 0 or intensity > 1){ intensity = 0.3; std::cerr << "Intensity set to default " << intensity << " cause given value was out of range (0,100)" << std::endl; } break; case '?': if (optopt == 's' || optopt =='w') std::cerr << USAGE << std::endl; else if (isprint (optopt)) std::cerr << USAGE << std::endl; else std::cerr << USAGE << std::endl; return 1; default: exit(1); } // Make sure all the required paths have been set if (sflag == -1 || wflag == -1){ std::cerr << USAGE << std::endl; return 1; } // Load the watermark wmark = new cimg_library::CImg<float>; try{ wmark -> load(&(wmark_file)[0u]); }catch (const cimg_library::CImgIOException& e) { std::cerr << "Error loading watermark " << wmark_file << ": " << e.what() << "\nExiting.." <<std::endl; exit(1); } std::cout << "Watermark size: (" << wmark -> width() <<", " << wmark -> height() << ")" << std::endl; // If number of chunks has not been specified then set it to the parallelism degree if(n_chunks == 0) n_chunks = n_workers; // Open the directory containing the images to be watermarked DIR *dirp; struct dirent *directory; dirp = opendir(&src_path[0u]); if (dirp){ while ((directory = readdir(dirp)) != NULL){ if (strendswith(directory->d_name, ".jpg")){ cimg_library::CImg<float> * img = new cimg_library::CImg<float>; try{ img -> load(&(src_path +"/" + directory->d_name)[0u]); // Split the image into chunks std::vector<img_chunk*> chunks = chunker(img, n_chunks); Img_save is; is.img = img; is.save_path = src_path+"/watermarked/" + directory->d_name; images.push_back(is); // Push the chunks into a queue for (unsigned int i = 0; i < chunks.size(); i++){ task *t = new task; t -> img = img; t -> save_path = src_path+"/watermarked/" + directory->d_name; t -> chunk = chunks.at(i); tasks.push_back(t); } }catch (const cimg_library::CImgIOException& e) { std::cerr << "Error loading image " << (src_path +"/" + directory->d_name) << ": " << e.what() << std::endl; } } } } closedir(dirp); delete(directory); std::vector<std::unique_ptr<ff::ff_node>> pipes; for (int i = 0; i < n_workers; i++) { pipes.push_back(ff::make_unique<Marker>(intensity)); } ff::ff_Pipe<task> pipe( ff::make_unique<Emitter>(src_path), ff::make_unique<ff::ff_Farm<task>>(std::move(pipes)) ); auto start = std::chrono::high_resolution_clock::now(); pipe.run_and_wait_end(); auto msec = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - start).count(); std::cout << "Elapsed time is " << msec << " msecs " << std::endl; // Save the images for (Img_save is : images){ try{ is.img -> save(&(is.save_path)[0u]); processed += 1; } catch (const std::exception& e) { std::cerr << "Error saving image " << is.save_path << ": " << e.what() << std::endl; } delete(is.img); } for (std::vector<task *>::iterator i = tasks.begin(); i != tasks.end(); ++i) { delete *i; } std::cout << "Processed a total of " << processed << " images" << std::endl; delete wmark; }
[ "v.pandelea@studenti.unipi.it" ]
v.pandelea@studenti.unipi.it
c586e539f29260edca44a1ba3c4fd51ff01792f9
f1dfa37d76f2cde5523b47668914ceb10116af53
/AtCoder Contest/C - Tsundoku.cpp
4af659f46e80e7ca7cbb9d7db875a1b289fc74d3
[]
no_license
Muzahid037/Online-Judge-Problems
d7fffd8daad60d9c5801882be1678cd851d54c29
5f14253f70c178c373f9b926a825bd82354ff10c
refs/heads/master
2022-03-15T00:45:38.384365
2022-02-24T13:56:40
2022-02-24T13:56:40
236,151,466
0
0
null
null
null
null
UTF-8
C++
false
false
2,761
cpp
///-----Bismillahir Rahmanir Rahim-----/// #include<bits/stdc++.h> using namespace std; ///---FAST I/O---/// #define Boost() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); ///---DATA TYPE---/// typedef long long ll; typedef long long int lli; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<vi> vvi; typedef vector<vl> vvl; typedef pair<int,int> pii; typedef pair<double, double> pdd; typedef pair<ll, ll> pll; typedef vector<pii> vii; typedef vector<pll> vll; typedef vector<int>::iterator vit; typedef set<int>::iterator sit; ///---LOOP---/// #define rep0(i,n) for(i=0;i<n;i++) #define rep1(i,n) for(i=1;i<=n;i++) ///---I/O---/// #define sf scanf #define pf printf ///---OTHERS---/// #define pb push_back #define all(c) c.begin(),c.end() #define MK make_pair #define F first #define S second #define endl '\n' ///---INITIALIZATION---// #define mem(a,b) memset(a, b, sizeof(a) ) ///---CALCULATE---/// #define gcd(a,b) __gcd(a,b) #define lcm(a,b) (a*(b/gcd(a,b))) #define sqr(a) ((a) * (a)) ///---BIT OPERATION---/// inline bool checkBit(ll n, int i) { return n&(1LL<<i); } inline ll setBit(ll n, int i) { return n|(1LL<<i);; } inline ll resetBit(ll n, int i) { return n&(~(1LL<<i)); } ///------String/Char Related Functions-----/// string makeintString(int x) { stringstream ss; ss << x; string str = ss.str(); ///cout<<str<<endl; return str; } string makellString(ll x) { stringstream ss; ss << x; string str = ss.str(); ///cout<<str<<endl; return str; } char cpp(char c) { return static_cast<char>(c + 1); } ///------------Sorting STL----------/// struct func { //this is a sample overloading function for sorting stl bool operator()(pii const &a, pii const &b) { if(a.F==b.F) return (a.S<b.S); return (a.F<b.F); } }; ///---CONSTANT---/// const double PI = acos(-1); const double eps = 1e-9; const int inf = 2000000000; const ll infLL = 9000000000000000000; #define MOD 1000000007 int main() { Boost(); int t; t=1; //cin>>t; while(t--) { ll n,m,k,x,ans=0; cin>>n>>m>>k; vector<ll>a(n+1,0); for(ll i=1; i<=n; i++) { cin>>a[i]; a[i]+=a[i-1]; } vector<ll>b(m+1,0); for(ll i=1; i<=m; i++) { cin>>b[i]; b[i]+=b[i-1]; } for(ll i=0; i<=n; i++) { if(a[i]>k) break; ll baki=k-a[i]; ll lb=upper_bound(b.begin(),b.end(),baki)-b.begin(); lb--; //cout<<" baki: "<<baki<<"lb: "<<lb<<endl; ans=max(ans,i+lb); //cout<<ans<<endl; } cout<<ans<<endl; } return 0; }
[ "48602232+Muzahid037@users.noreply.github.com" ]
48602232+Muzahid037@users.noreply.github.com
e4fb9bdbec365931615e483b27f4fda57ee5afba
f1ae49086a9de49f84b9e828e9cd54b6f964c0d3
/ver201604template.sdk/test_sd/src/markstat/Frame/x0Vector.h
cfbaf8d83afe1ee3875c7d12bc223666f869425b
[]
no_license
vivozhang/zynq_zturn_template_prj
ccb43d69a782062a2e54146c31043567ba9d7876
f370466cce75f814223d0c3a0c225a7e4baf6117
refs/heads/master
2021-01-20T07:20:46.081080
2017-08-26T17:09:45
2017-08-26T17:09:45
89,991,870
0
0
null
null
null
null
UTF-8
C++
false
false
7,058
h
/////////////////////////////////////////////////////////////////////////////// // // TITLE: // // DESCRIPTION: // Elemental vector transformations between the three-phase stator // coordinate system (A-B-C) and the rotating reference frame (X-Y) // // COPYRIGHT: Copyright (c) 2004 // by GENERAL ELECTRIC COMPANY U.S.A. // // DOCUMENTATION: // /////////////////////////////////////////////////////////////////////////////// #ifndef __X0_VECTOR_H__ #define __X0_VECTOR_H__ // Includes: //---------- // system #include <math.h> // framework #include "x0FrameWork.h" /////////////////////////////////////////////////////////////////////////////// // // DESCRIPTION: // // Class to provide elemental vector transformations between the three-phase // stator coordinate system (A-B-C) and the rotating reference frame (X-Y) // // The methods are "static" so that this class does not have to be instanced. // // The methods are defined inside the H file to force the compiler to inline. // // Include this H file to access these methods. // // Example Usage: cVectorf::Modulot2Pi(angle); // /////////////////////////////////////////////////////////////////////////////// class cVectorf { //----------------------------------------------------------------------------- public: //------------------------------------------------------------------------- // Modulo2Pi: returns equivalent angle in range [0 .. 2 * PI) //------------------------------------------------------------------------- static float Modulo2Pi(float angle) { return fmodf( angle, (2.0F * PI) ); } //------------------------------------------------------------------------- // SineCosine: fills a structure with the sine and cosine of the input angle. // The intent is to compute these values once, then re-use them // multiple times in the vector transformations. //------------------------------------------------------------------------- static void SineCosine(float angle, SinCosTyp* sincos) { sincos->sin = sinf(angle); sincos->cos = cosf(angle); } //------------------------------------------------------------------------- // DemodLN: Demodulate, Line-to-Neutral. Nothing fancy, just the usual vector math. //------------------------------------------------------------------------- static void DemodLN(float A, float B, SinCosTyp* sincos, float* X, float* Y) { *X = A * (sincos->cos + (float)(1.0 / SQRT3) * sincos->sin) + B * (float)(2.0 / SQRT3) * sincos->sin; *Y = A * ((float)(1.0 / SQRT3) * sincos->cos - sincos->sin) + B * (float)(2.0 / SQRT3) * sincos->cos; } //------------------------------------------------------------------------- // DemodLN3: Demodulate, Line-to-Neutral, using A, B and phase C. //------------------------------------------------------------------------- static void DemodLN3(float A, float B, float C, SinCosTyp* sincos, float* X, float* Y) { *X = A * ( (float)( 2.0 / 3.0) * sincos->cos ) + B * ( (float)(-1.0 / 3.0) * sincos->cos + (float)(1.0 / SQRT3) * sincos->sin ) + C * ( (float)(-1.0 / 3.0) * sincos->cos - (float)(1.0 / SQRT3) * sincos->sin ); *Y = A * ( (float)(-2.0 / 3.0) * sincos->sin ) + B * ( (float)( 1.0 / 3.0) * sincos->sin + (float)(1.0 / SQRT3) * sincos->cos ) + C * ( (float)( 1.0 / 3.0) * sincos->sin - (float)(1.0 / SQRT3) * sincos->cos ); } //------------------------------------------------------------------------- // ABCToAlphaBeta: Transform A, B, C to alpha-beta. //------------------------------------------------------------------------- static void ABCToAlphaBeta(float A, float B, float C, float* Alpha, float* Beta) { *Alpha = A * (float)(2.0 / 3.0) - B * (float)(1.0 / 3.0) - C * (float)(1.0 / 3.0); *Beta = B * (float)(1.0 / SQRT3) - C * (float)(1.0 / SQRT3); } //------------------------------------------------------------------------- // AlphaBetaToXY: Transform alpha-beta to XY. //------------------------------------------------------------------------- static void AlphaBetaToXY(float Alpha, float Beta, SinCosTyp* sincos, float* X, float* Y) { *X = Alpha * sincos->cos + Beta * sincos->sin; *Y = Beta * sincos->cos - Alpha * sincos->sin; } //------------------------------------------------------------------------- // AlphaBetaToABC: Transform alpha-beta to A, B, C //------------------------------------------------------------------------- static void AlphaBetaToABC(float Alpha, float Beta, float* A, float* B, float* C) { *A = Alpha; *B = Alpha * (float)(-1.0 / 2.0) + Beta * (float)(SQRT3 / 2.0); *C = Alpha * (float)(-1.0 / 2.0) - Beta * (float)(SQRT3 / 2.0); } //------------------------------------------------------------------------- // DemodLL: Demodulate, Line-to-Line. More of the same. //------------------------------------------------------------------------- static void DemodLL(float AB, float BC, SinCosTyp* sincos, float* X, float* Y) { *X = AB * (float)(2.0 / 3.0) * sincos->cos + BC * ((float)(1.0 / 3.0) * sincos->cos + (float)(1.0 / SQRT3) * sincos->sin); *Y = AB * -(float)(2.0 / 3.0) * sincos->sin + BC * ((float)(1.0 / SQRT3) * sincos->cos - (float)(1.0 / 3.0) * sincos->sin); } //------------------------------------------------------------------------- // RotateLN: Rotate, Line-to-Neutral. More of the same. //------------------------------------------------------------------------- static void RotateLN(float X, float Y, SinCosTyp* sincos, float* A, float* B) { *A = X * sincos->cos - Y * sincos->sin; *B = X * (-(float)( 1.0 / 2.0) * sincos->cos + (float)(SQRT3 / 2.0) * sincos->sin) + Y * ( (float)(SQRT3 / 2.0) * sincos->cos + (float)( 1.0 / 2.0) * sincos->sin); } //------------------------------------------------------------------------- // RotateLL: Rotate, Line-to-Line. Are you through, yet? //------------------------------------------------------------------------- static void RotateLL(float X, float Y, SinCosTyp* sincos, float* AB, float* BC) { *AB = X * ( (float)( 3.0 / 2.0) * sincos->cos - (float)(SQRT3 / 2.0) * sincos->sin) + Y * (-(float)(SQRT3 / 2.0) * sincos->cos - (float)( 3.0 / 2.0) * sincos->sin); *BC = X * (float)SQRT3 * sincos->sin + Y * (float)SQRT3 * sincos->cos; } //------------------------------------------------------------------------- // Discrim: Discriminate a scalar. //------------------------------------------------------------------------- static void Discrim(float A, SinCosTyp* sincos, float* X, float* Y) { *X = A * (sincos->cos); *Y = A * -(sincos->sin); } }; #endif // __X0_VECTOR_H__
[ "zjxx79009387" ]
zjxx79009387
cfc9ab77756e827d9af4d5f450456f3993898e8b
4f159bcb108a9f85852e4abb8fc52e1e6e275c2c
/src/converters.cpp
7913434aeb0af5c3d42d0c80cbf6dea189196ff9
[]
no_license
marekkijo/CanonControl
5dad3fa01de1a0cb83fb3463d213f9157132495d
45da4577bfec93f7a0d1a16673b6dd291e059b0e
refs/heads/master
2021-08-30T08:10:18.133925
2017-12-16T23:42:54
2017-12-16T23:42:54
114,497,381
0
0
null
null
null
null
UTF-8
C++
false
false
1,432
cpp
#include "converters.hpp" #include <array> #include "eos/enums.hpp" namespace Converters { namespace ISO { const static int kMinValue{0}; const static int kMaxValue{29}; const static std::array<std::string, 30> kValueToString{ "A", "L", "100", "125", "160", "200", "250", "320", "400", "500", "640", "800", "1000", "1250", "1600", "2000", "2500", "3200", "4000", "5000", "6400", "8000", "10000", "12800", "16000", "20000", "25600", "32000", "H1", "H2" }; int minValue() { return kMinValue; } int maxValue() { return kMaxValue; } std::string valueToString(int value) { if (value < minValue() || value > maxValue()) throw std::invalid_argument("Converters::ISO::valueToString()"); return kValueToString[value]; } int stringToValue(std::string str) { auto it = std::find(kValueToString.begin(), kValueToString.end(), str); if (it == kValueToString.end()) throw std::invalid_argument("Converters::ISO::stringToValue()"); return std::distance(kValueToString.begin(), it); } EOS::ISOValue valueToEnum(int value) { if (value < minValue() || value > maxValue()) throw std::invalid_argument("Converters::ISO::valueToEnum()"); return static_cast<EOS::ISOValue>(value); } int enumToValue(EOS::ISOValue iso_value) { return static_cast<int>(iso_value); } } }
[ "marekkijo@gmail.com" ]
marekkijo@gmail.com
977d9e50ce7f2efb96d838ebec5b7f07af3520af
3cf9e141cc8fee9d490224741297d3eca3f5feff
/C++ Benchmark Programs/Benchmark Files 1/classtester/autogen-sources/source-8787.cpp
4eafe3998aa0098ac19e23621dfbded7b6e39fca
[]
no_license
TeamVault/tauCFI
e0ac60b8106fc1bb9874adc515fc01672b775123
e677d8cc7acd0b1dd0ac0212ff8362fcd4178c10
refs/heads/master
2023-05-30T20:57:13.450360
2021-06-14T09:10:24
2021-06-14T09:10:24
154,563,655
0
1
null
null
null
null
UTF-8
C++
false
false
2,999
cpp
struct c0; void __attribute__ ((noinline)) tester0(c0* p); struct c0 { bool active0; c0() : active0(true) {} virtual ~c0() { tester0(this); active0 = false; } virtual void f0(){} }; void __attribute__ ((noinline)) tester0(c0* p) { p->f0(); } struct c1; void __attribute__ ((noinline)) tester1(c1* p); struct c1 { bool active1; c1() : active1(true) {} virtual ~c1() { tester1(this); active1 = false; } virtual void f1(){} }; void __attribute__ ((noinline)) tester1(c1* p) { p->f1(); } struct c2; void __attribute__ ((noinline)) tester2(c2* p); struct c2 : virtual c0, virtual c1 { bool active2; c2() : active2(true) {} virtual ~c2() { tester2(this); c0 *p0_0 = (c0*)(c2*)(this); tester0(p0_0); c1 *p1_0 = (c1*)(c2*)(this); tester1(p1_0); active2 = false; } virtual void f2(){} }; void __attribute__ ((noinline)) tester2(c2* p) { p->f2(); if (p->active0) p->f0(); if (p->active1) p->f1(); } struct c3; void __attribute__ ((noinline)) tester3(c3* p); struct c3 : c2, virtual c1 { bool active3; c3() : active3(true) {} virtual ~c3() { tester3(this); c0 *p0_0 = (c0*)(c2*)(c3*)(this); tester0(p0_0); c1 *p1_0 = (c1*)(c2*)(c3*)(this); tester1(p1_0); c1 *p1_1 = (c1*)(c3*)(this); tester1(p1_1); c2 *p2_0 = (c2*)(c3*)(this); tester2(p2_0); active3 = false; } virtual void f3(){} }; void __attribute__ ((noinline)) tester3(c3* p) { p->f3(); if (p->active2) p->f2(); if (p->active0) p->f0(); if (p->active1) p->f1(); } struct c4; void __attribute__ ((noinline)) tester4(c4* p); struct c4 : virtual c0, virtual c1, c2 { bool active4; c4() : active4(true) {} virtual ~c4() { tester4(this); c0 *p0_0 = (c0*)(c4*)(this); tester0(p0_0); c0 *p0_1 = (c0*)(c2*)(c4*)(this); tester0(p0_1); c1 *p1_0 = (c1*)(c4*)(this); tester1(p1_0); c1 *p1_1 = (c1*)(c2*)(c4*)(this); tester1(p1_1); c2 *p2_0 = (c2*)(c4*)(this); tester2(p2_0); active4 = false; } virtual void f4(){} }; void __attribute__ ((noinline)) tester4(c4* p) { p->f4(); if (p->active2) p->f2(); if (p->active0) p->f0(); if (p->active1) p->f1(); } int __attribute__ ((noinline)) inc(int v) {return ++v;} int main() { c0* ptrs0[25]; ptrs0[0] = (c0*)(new c0()); ptrs0[1] = (c0*)(c2*)(new c2()); ptrs0[2] = (c0*)(c2*)(c3*)(new c3()); ptrs0[3] = (c0*)(c4*)(new c4()); ptrs0[4] = (c0*)(c2*)(c4*)(new c4()); for (int i=0;i<5;i=inc(i)) { tester0(ptrs0[i]); delete ptrs0[i]; } c1* ptrs1[25]; ptrs1[0] = (c1*)(new c1()); ptrs1[1] = (c1*)(c2*)(new c2()); ptrs1[2] = (c1*)(c2*)(c3*)(new c3()); ptrs1[3] = (c1*)(c3*)(new c3()); ptrs1[4] = (c1*)(c4*)(new c4()); ptrs1[5] = (c1*)(c2*)(c4*)(new c4()); for (int i=0;i<6;i=inc(i)) { tester1(ptrs1[i]); delete ptrs1[i]; } c2* ptrs2[25]; ptrs2[0] = (c2*)(new c2()); ptrs2[1] = (c2*)(c3*)(new c3()); ptrs2[2] = (c2*)(c4*)(new c4()); for (int i=0;i<3;i=inc(i)) { tester2(ptrs2[i]); delete ptrs2[i]; } c3* ptrs3[25]; ptrs3[0] = (c3*)(new c3()); for (int i=0;i<1;i=inc(i)) { tester3(ptrs3[i]); delete ptrs3[i]; } c4* ptrs4[25]; ptrs4[0] = (c4*)(new c4()); for (int i=0;i<1;i=inc(i)) { tester4(ptrs4[i]); delete ptrs4[i]; } return 0; }
[ "ga72foq@mytum.de" ]
ga72foq@mytum.de
06bdcd260ae421eedbf89cd07cbfbfdeb5ac1d0d
3f4fa79e7c05b649180c141d1f2d036d546199cc
/sensors/dsps/libhalsensors/src/Gravity.cpp
1b3676479ea54e84e1cdbde42f05de684614cc8c
[]
no_license
rx78gp01/sc20_vendor_qcom_proprietary
6f0a2a51d5d31dec39651d7061809231d5fb26ee
d1a681b6e76bbd1e46ca33fbf218cf8cca207cdd
refs/heads/master
2023-05-28T22:50:41.548547
2019-10-16T07:22:46
2019-10-16T07:22:46
null
0
0
null
null
null
null
UTF-8
C++
false
false
22,172
cpp
/*============================================================================ @file Gravity.cpp @brief Gravity class implementation. Copyright (c) 2014-2015 Qualcomm Technologies, Inc. All Rights Reserved. Confidential and Proprietary - Qualcomm Technologies, Inc. ============================================================================*/ #include <cutils/properties.h> #define __STDC_FORMAT_MACROS #include <inttypes.h> #include <stdlib.h> #include "TimeSyncService.h" #include "Gravity.h" #include "SensorsContext.h" /*============================================================================ Gravity Constructor ============================================================================*/ Gravity::Gravity(int handle) :SAMSensor(handle) { if ((getAttribOK() == true)) { if (Utility::isGyroAvailable()) { svc_num = SNS_SAM_GRAVITY_VECTOR_SVC_ID_V01; } else { svc_num = SNS_SAM_ORIENTATION_SVC_ID_V01; } trigger_mode = SENSOR_MODE_CONT; batch_support = true; HAL_LOG_INFO("%s: handle:%d", __FUNCTION__, handle); setName("Gravity"); setVendor("QTI"); setType(SENSOR_TYPE_GRAVITY); if(handle == HANDLE_GRAVITY_WAKE_UP){ bWakeUp = true; setName("Gravity -Wakeup"); setFlags(SENSOR_FLAG_CONTINUOUS_MODE|SENSOR_FLAG_WAKE_UP); } else if (handle == HANDLE_GRAVITY) { bWakeUp = false; setFlags(SENSOR_FLAG_CONTINUOUS_MODE); } /* Send Algo Attributes Request */ sendAlgoAttribReq(); } } /*============================================================================ Gravity Destructor ============================================================================*/ Gravity::~Gravity() { } /*=========================================================================== setSensorInfo ===========================================================================*/ void Gravity::setSensorInfo() { SensorsContext *context = SensorsContext::getInstance(); Sensor *mSensor = context->getSensor(HANDLE_ACCELERATION); HAL_LOG_INFO("%s: handle=%d", __FUNCTION__, handle); if (mSensor != NULL) { setMaxRange(mSensor->getMaxRange()); setResolution(mSensor->getResolution()); } else { HAL_LOG_ERROR("The mSensor handle %d is NULL!", HANDLE_ACCELERATION); } } /*============================================================================ enable ============================================================================*/ int Gravity::enable(int en) { int err; sensor1_error_e error; sensor1_msg_header_s req_hdr; sns_sam_gravity_enable_req_msg_v01 *sam_req; if ( !Utility::isGyroAvailable() ) { sns_sam_orientation_enable_req_msg_v01 *sam_req; } if (enabled == en) { HAL_LOG_INFO("Gravity is already enabled/disabled %d", enabled); return 0; } /* store the en value */ enabled = en; HAL_LOG_DEBUG("%s: handle=%d", __FUNCTION__, handle); if (en) { pthread_mutex_lock(&sensor1_cb->cb_mutex); HAL_LOG_DEBUG("%s: handle=%d, freq=%f report_rate=%d batch_rate=%u \ batched=%d wakeup %d",__FUNCTION__, handle, freq, report_rate, batch_rate, batching, bWakeUp); if ( Utility::isGyroAvailable() ) { error = sensor1_alloc_msg_buf(sensor1_cb->sensor1_handle, sizeof(sns_sam_gravity_enable_req_msg_v01), (void**)&sam_req ); } else { error = sensor1_alloc_msg_buf(sensor1_cb->sensor1_handle, sizeof(sns_sam_orientation_enable_req_msg_v01), (void**)&sam_req ); } if (SENSOR1_SUCCESS != error) { HAL_LOG_ERROR("%s:sensor1_alloc_msg_buf error:%d", __FUNCTION__, error); pthread_mutex_unlock(&sensor1_cb->cb_mutex); enabled = 0; return -1; } req_hdr.service_number = svc_num; if ( Utility::isGyroAvailable() ) { req_hdr.msg_id = SNS_SAM_GRAVITY_ENABLE_REQ_V01; req_hdr.msg_size = sizeof(sns_sam_gravity_enable_req_msg_v01); } else { req_hdr.msg_id = SNS_SAM_ORIENTATION_ENABLE_REQ_V01; req_hdr.msg_size = sizeof(sns_sam_orientation_enable_req_msg_v01); } req_hdr.txn_id = 0; /* If periodic request for QFusion sensors is enabled through system property always request for periodic data. Otherwise check for minimum sampling frequency and ask for periodic data */ if (!strncmp("true", qfusion_use_report_period, 4) || freq < min_sample_freq) { HAL_LOG_DEBUG("%s: handle=%d periodic req with report_rate %d Q16 secs", __FUNCTION__, handle, report_rate); sam_req->report_period = report_rate; } else { /* Set the request to synchronous mode */ HAL_LOG_DEBUG("%s: handle=%d synchronous req with sample_rate %d Hz", __FUNCTION__, handle, report_rate); sam_req->report_period = 0; sam_req->sample_rate_valid = true; sam_req->sample_rate = FX_CONV_Q16(report_rate, 0); } /* set default behavior for indications during suspend */ sam_req->notify_suspend_valid = true; sam_req->notify_suspend.proc_type = SNS_PROC_APPS_V01; sam_req->notify_suspend.send_indications_during_suspend = bWakeUp; /* Send Enable Request */ err = sendEnableReq(&req_hdr, (void *)sam_req); if (err) { HAL_LOG_ERROR("send the SAM sensor Enable message failed!"); pthread_mutex_unlock(&sensor1_cb->cb_mutex); enabled = 0; return -1; } HAL_LOG_DEBUG("%s: Received Response: %d", __FUNCTION__, sensor1_cb->error); /* Send batch request */ if( batching ) { sendBatchReq(); } pthread_mutex_unlock(&sensor1_cb->cb_mutex); } else { /* Disable sensor */ HAL_LOG_DEBUG("%s: Disabling sensor handle=%d", __FUNCTION__, handle); sendCancel(); } return 0; } int Gravity::sendBatchReq() { sensor1_error_e error; sensor1_msg_header_s req_hdr; sns_sam_gravity_batch_req_msg_v01 *sam_req; if ( !Utility::isGyroAvailable() ) { sns_sam_orientation_batch_req_msg_v01 *sam_req; } float batch_rate_in_hz; HAL_LOG_DEBUG("%s: batching: %d, batch_rate=%f (Hz)", __FUNCTION__, batching, FX_FIXTOFLT_Q16(batch_rate)); if ( Utility::isGyroAvailable() ) { error = sensor1_alloc_msg_buf(sensor1_cb->sensor1_handle, sizeof(sns_sam_gravity_batch_req_msg_v01), (void**)&sam_req); } else { error = sensor1_alloc_msg_buf(sensor1_cb->sensor1_handle, sizeof(sns_sam_orientation_batch_req_msg_v01), (void**)&sam_req ); } if(SENSOR1_SUCCESS != error) { HAL_LOG_ERROR( "%s: sensor1_alloc_msg_buf() error: %d", __FUNCTION__, error ); return -1; } req_hdr.service_number = svc_num; if ( Utility::isGyroAvailable() ) { req_hdr.msg_id = SNS_SAM_GRAVITY_BATCH_REQ_V01; req_hdr.msg_size = sizeof( sns_sam_gravity_batch_req_msg_v01 ); } else { req_hdr.msg_id = SNS_SAM_ORIENTATION_BATCH_REQ_V01; req_hdr.msg_size = sizeof(sns_sam_orientation_batch_req_msg_v01); } req_hdr.txn_id = TXN_ID_NO_RESP_SIGNALLED; sam_req->instance_id = instance_id; sam_req->req_type_valid = true; sam_req->req_type = bWakeUp ? SNS_BATCH_WAKE_UPON_FIFO_FULL_V01: SNS_BATCH_NO_WAKE_UP_V01; /* convert batch rate from Hz in Q16 to batch period in seconds in Q16 */ batch_rate_in_hz = FX_FIXTOFLT_Q16( batch_rate ); sam_req->batch_period = batching ? FX_FLTTOFIX_Q16( 1.0 / batch_rate_in_hz ) : 0 ; /* Rate of 0 means disabled */ /* Send Request */ sensor1_cb->error = false; if( (error = sensor1_write( sensor1_cb->sensor1_handle, &req_hdr, sam_req )) != SENSOR1_SUCCESS ) { /* free the message buffer */ sensor1_free_msg_buf( sensor1_cb->sensor1_handle, sam_req ); HAL_LOG_ERROR("%s: sensor1_write() error: %d", __FUNCTION__, error); return -1; } return sensor1_cb->error ? -1 : 0; } /*=========================================================================== FUNCTION: processResp ===========================================================================*/ void Gravity::processResp(sensor1_msg_header_s *msg_hdr, void *msg_ptr) { const sns_common_resp_s_v01* crsp_ptr = (sns_common_resp_s_v01 *)msg_ptr; bool error = false; HAL_LOG_INFO("%s: handle:%d msg_id=%d", __FUNCTION__, handle, msg_hdr->msg_id); if (crsp_ptr->sns_result_t != 0) { HAL_LOG_ERROR("%s: Msg %i; Result: %u, Error: %u", __FUNCTION__, msg_hdr->msg_id, crsp_ptr->sns_result_t, crsp_ptr->sns_err_t); error = true; if ( Utility::isGyroAvailable() ) { if (msg_hdr->msg_id == SNS_SAM_GRAVITY_BATCH_RESP_V01 && (crsp_ptr->sns_err_t == SENSOR1_EBAD_SVC_ID || crsp_ptr->sns_err_t == SENSOR1_EUNKNOWN)) { /* Proceed if batching is not supported */ error = false; } } else { if (msg_hdr->msg_id == SNS_SAM_ORIENTATION_BATCH_RESP_V01 && (crsp_ptr->sns_err_t != SENSOR1_SUCCESS)) { /* Proceed if batching is not supported */ error = false; } } } if(true != error ) { if ( Utility::isGyroAvailable() ) { switch (msg_hdr->msg_id) { case SNS_SAM_GRAVITY_ENABLE_RESP_V01: HAL_LOG_DEBUG("%s: Received SNS_SAM_GRAVITY_ENABLE_RESP_V01", __FUNCTION__); instance_id = ((sns_sam_gravity_enable_resp_msg_v01 *)msg_ptr)->instance_id; break; case SNS_SAM_GRAVITY_CANCEL_RESP_V01: case SNS_SAM_GRAVITY_DISABLE_RESP_V01: HAL_LOG_DEBUG("%s: Received SNS_SAM_GRAVITY_CANCEL/DISABLE_RESP_V01", __FUNCTION__); /* Reset instance ID */ instance_id = 0xFF; break; case SNS_SAM_GRAV_GET_ATTRIBUTES_RESP_V01: HAL_LOG_DEBUG("%s: Received SNS_SAM_GRAV_GET_ATTRIBUTES_RESP_V01", __FUNCTION__); processAlgoAttribResp(msg_hdr, msg_ptr); break; case SNS_SAM_GRAVITY_BATCH_RESP_V01: HAL_LOG_DEBUG("%s: Received SNS_SAM_GRAVITY_BATCH_RESP_V01", __FUNCTION__); if(((sns_sam_gravity_batch_resp_msg_v01*)msg_ptr)->max_batch_size_valid ) { int max_samples = ((sns_sam_gravity_batch_resp_msg_v01*)msg_ptr)->max_batch_size; setMaxBufferedSamples(max_samples); } pthread_mutex_lock(&data_cb->data_mutex); flushSendCmplt(); pthread_mutex_unlock(&data_cb->data_mutex); break; default: HAL_LOG_ERROR("%s: Unknown msg id: %d", __FUNCTION__, msg_hdr->msg_id ); return; } } else { switch (msg_hdr->msg_id) { case SNS_SAM_ORIENTATION_ENABLE_RESP_V01: HAL_LOG_DEBUG("%s: Received SNS_SAM_ORIENTATION_ENABLE_RESP_V01", __FUNCTION__); instance_id = ((sns_sam_orientation_enable_resp_msg_v01 *)msg_ptr)->instance_id; break; case SNS_SAM_ORIENTATION_CANCEL_RESP_V01: case SNS_SAM_ORIENTATION_DISABLE_RESP_V01: HAL_LOG_DEBUG("%s: Received SNS_SAM_ORIENTATION_CANCEL/DISABLE_RESP_V01", __FUNCTION__); /* Reset instance ID */ instance_id = 0xFF; break; case SNS_SAM_ORIENT_GET_ATTRIBUTES_RESP_V01: HAL_LOG_DEBUG("%s: Received SNS_SAM_ORIENT_GET_ATTRIBUTES_RESP_V01", __FUNCTION__); processAlgoAttribResp(msg_hdr, msg_ptr); break; case SNS_SAM_ORIENTATION_BATCH_RESP_V01: HAL_LOG_DEBUG("%s: Received SNS_SAM_ORIENTATION_BATCH_RESP_V01", __FUNCTION__); if( ((sns_sam_orientation_batch_resp_msg_v01*)msg_ptr)->max_batch_size_valid ) { int max_samples = ((sns_sam_orientation_batch_resp_msg_v01*)msg_ptr)->max_batch_size; setMaxBufferedSamples(max_samples); } pthread_mutex_lock(&data_cb->data_mutex); flushSendCmplt(); pthread_mutex_unlock(&data_cb->data_mutex); break; default: HAL_LOG_ERROR("%s: Unknown msg id: %d", __FUNCTION__, msg_hdr->msg_id); return; } } } if (msg_hdr->txn_id != TXN_ID_NO_RESP_SIGNALLED) { pthread_mutex_lock(&sensor1_cb->cb_mutex); Utility::signalResponse(error, sensor1_cb); pthread_mutex_unlock(&sensor1_cb->cb_mutex); } } /*=========================================================================== FUNCTION: processInd ===========================================================================*/ void Gravity::processInd(sensor1_msg_header_s *msg_hdr, void *msg_ptr) { hal_sam_sample_t *sample_list = NULL; hal_sam_sample_t *curr_sample = NULL; sensors_event_t la_sample; uint32_t i = 0; uint32_t count = 0; HAL_LOG_INFO("%s: handle:%d", __FUNCTION__, handle); if ( Utility::isGyroAvailable() ) { if (SNS_SAM_GRAVITY_REPORT_IND_V01 == msg_hdr->msg_id) { HAL_LOG_DEBUG("%s: SNS_SAM_GRAVITY_REPORT_IND_V01", __FUNCTION__); sns_sam_gravity_report_ind_msg_v01* sam_ind = (sns_sam_gravity_report_ind_msg_v01*)msg_ptr; sample_list = (hal_sam_sample_t *)malloc(sizeof(hal_sam_sample_t)); if (NULL == sample_list) { HAL_LOG_ERROR("%s: Malloc error", __FUNCTION__); } else { count = 1; sample_list->data[4] = sam_ind->result.lin_accel[0]; sample_list->data[5] = sam_ind->result.lin_accel[1]; sample_list->data[6] = sam_ind->result.lin_accel[2]; sample_list->data[7] = sam_ind->result.gravity[0]; sample_list->data[8] = sam_ind->result.gravity[1]; sample_list->data[9] = sam_ind->result.gravity[2]; sample_list->accuracy = sam_ind->result.accuracy; sample_list->timestamp = sam_ind->timestamp; } } else if( SNS_SAM_GRAVITY_BATCH_IND_V01 == msg_hdr->msg_id ) { HAL_LOG_DEBUG("%s: SNS_SAM_GRAVITY_BATCH_IND_V01", __FUNCTION__); sns_sam_gravity_batch_ind_msg_v01* sam_ind = (sns_sam_gravity_batch_ind_msg_v01*)msg_ptr; sample_list = (hal_sam_sample_t *)malloc(sam_ind->reports_len * sizeof(hal_sam_sample_t)); if( NULL == sample_list ) { HAL_LOG_ERROR("%s: Malloc error", __FUNCTION__); } else { hal_sam_sample_t *curr_sample = sample_list; uint32_t curr_ts = sam_ind->first_report_timestamp; count = sam_ind->reports_len; for( i = 0; i < sam_ind->reports_len; i++ ) { curr_ts += sam_ind->timestamp_offsets[ i ]; curr_sample->data[4] = sam_ind->reports[ i ].result.lin_accel[0]; curr_sample->data[5] = sam_ind->reports[ i ].result.lin_accel[1]; curr_sample->data[6] = sam_ind->reports[ i ].result.lin_accel[2]; curr_sample->data[7] = sam_ind->reports[ i ].result.gravity[0]; curr_sample->data[8] = sam_ind->reports[ i ].result.gravity[1]; curr_sample->data[9] = sam_ind->reports[ i ].result.gravity[2]; curr_sample->accuracy = sam_ind->reports[ i ].result.accuracy; curr_sample->timestamp = curr_ts; curr_sample++; } } } else { HAL_LOG_ERROR("%s: Unknown message ID = %d", __FUNCTION__, msg_hdr->msg_id); } } else { if (SNS_SAM_ORIENTATION_REPORT_IND_V01 == msg_hdr->msg_id) { HAL_LOG_DEBUG("%s: SNS_SAM_ORIENTATION_REPORT_IND_V01", __FUNCTION__); sns_sam_orientation_report_ind_msg_v01* sam_ind = (sns_sam_orientation_report_ind_msg_v01*)msg_ptr; sample_list = (hal_sam_sample_t *)malloc(sizeof(hal_sam_sample_t)); if (NULL == sample_list) { HAL_LOG_ERROR( "%s: Malloc error", __FUNCTION__ ); } else { count = 1; sample_list->data[0] = sam_ind->result.rotation_vector[0]; sample_list->data[1] = sam_ind->result.rotation_vector[1]; sample_list->data[2] = sam_ind->result.rotation_vector[2]; sample_list->data[3] = sam_ind->result.rotation_vector[3]; sample_list->data[4] = sam_ind->result.lin_accel[0]; sample_list->data[5] = sam_ind->result.lin_accel[1]; sample_list->data[6] = sam_ind->result.lin_accel[2]; sample_list->data[7] = sam_ind->result.gravity[0]; sample_list->data[8] = sam_ind->result.gravity[1]; sample_list->data[9] = sam_ind->result.gravity[2]; sample_list->accuracy = sam_ind->result.rotation_vector_accuracy; sample_list->timestamp = sam_ind->timestamp; } } else if( SNS_SAM_ORIENTATION_BATCH_IND_V01 == msg_hdr->msg_id ) { HAL_LOG_DEBUG("%s: SNS_SAM_ORIENTATION_BATCH_IND_V01", __FUNCTION__); sns_sam_orientation_batch_ind_msg_v01* sam_ind = (sns_sam_orientation_batch_ind_msg_v01*)msg_ptr; sample_list = (hal_sam_sample_t *)malloc(sam_ind->reports_len * sizeof(hal_sam_sample_t)); if( NULL == sample_list ) { HAL_LOG_ERROR( "%s: Malloc error", __FUNCTION__ ); } else { hal_sam_sample_t *curr_sample = sample_list; uint32_t curr_ts = sam_ind->first_report_timestamp; count = sam_ind->reports_len; for( i = 0; i < sam_ind->reports_len; i++ ) { curr_ts += sam_ind->timestamp_offsets[ i ]; curr_sample->data[0] = sam_ind->reports[ i ].rotation_vector[0]; curr_sample->data[1] = sam_ind->reports[ i ].rotation_vector[1]; curr_sample->data[2] = sam_ind->reports[ i ].rotation_vector[2]; curr_sample->data[3] = sam_ind->reports[ i ].rotation_vector[3]; curr_sample->data[4] = sam_ind->reports[ i ].lin_accel[0]; curr_sample->data[5] = sam_ind->reports[ i ].lin_accel[1]; curr_sample->data[6] = sam_ind->reports[ i ].lin_accel[2]; curr_sample->data[7] = sam_ind->reports[ i ].gravity[0]; curr_sample->data[8] = sam_ind->reports[ i ].gravity[1]; curr_sample->data[9] = sam_ind->reports[ i ].gravity[2]; curr_sample->accuracy = sam_ind->reports[ i ].rotation_vector_accuracy; curr_sample->timestamp = curr_ts; curr_sample++; } } } else { HAL_LOG_ERROR( "%s: Unknown message ID = %d", __FUNCTION__, msg_hdr->msg_id ); } } if(count == 0) { pthread_mutex_lock(&data_cb->data_mutex); /* Release wakelock if held */ if (getFlags() & SENSOR_FLAG_WAKE_UP) { Utility::release_sensor_wake_lock(data_cb, __FUNCTION__); } pthread_mutex_unlock(&data_cb->data_mutex); } for (i = 0; i < count; i++) { HAL_LOG_DEBUG("%s: handle %d, count=%d", __FUNCTION__, handle, count); curr_sample = &sample_list[i]; la_sample.type = SENSOR_TYPE_GRAVITY; if(bWakeUp == false) { la_sample.sensor = HANDLE_GRAVITY; HAL_LOG_VERBOSE("%s:sensor %s ",__FUNCTION__, Utility::SensorTypeToSensorString(getType())); } else { la_sample.sensor = HANDLE_GRAVITY_WAKE_UP; HAL_LOG_VERBOSE("%s:sensor %s (wake_up)",__FUNCTION__, Utility::SensorTypeToSensorString(getType())); } la_sample.acceleration.x = curr_sample->data[8]; la_sample.acceleration.y = curr_sample->data[7]; la_sample.acceleration.z = -curr_sample->data[9]; la_sample.acceleration.status = curr_sample->accuracy; la_sample.version = sizeof(sensors_event_t); la_sample.timestamp = time_service->timestampCalc( (uint64_t)curr_sample->timestamp, la_sample.sensor); HAL_LOG_VERBOSE("%s: GravityX: %f GravityY: %f GravityZ: %f acc: %d SAM TS: %u HAL TS:%lld elapsedRealtimeNano:%lld", __FUNCTION__, la_sample.data[0], la_sample.data[1], la_sample.data[2], curr_sample->accuracy, curr_sample->timestamp, la_sample.timestamp, android::elapsedRealtimeNano()); pthread_mutex_lock(&data_cb->data_mutex); if (Utility::insertQueue(&la_sample)) { Utility::signalInd(data_cb); } pthread_mutex_unlock(&data_cb->data_mutex); } free(sample_list); }
[ "richucjalpy@gmail.com" ]
richucjalpy@gmail.com
5b912f3df73d304488a365a0dcca46ad11afcb00
37fbda86bdce49f6db52b9a238e5830dcd636ca3
/零錢.cpp
db84a7bded91adf64e50301330de572c19c325cc
[]
no_license
nanshan-high-school/cs50-problem-set-1-cash-A6M5-Zero
7d480f1ba254f34db86e840c283a2a81579916de
fd05d0f4c6513af837223865060b5dd08e639b33
refs/heads/master
2020-04-04T02:54:18.665870
2018-11-01T11:00:47
2018-11-01T11:00:47
155,700,335
0
0
null
null
null
null
UTF-8
C++
false
false
740
cpp
#include <iostream> using namespace std; int main() { int money = 0; int fifty = 0; int twenty = 0; int ten = 0; int five = 0; int one = 0; cout << "How much money do U have?"; cin >> money; while (money >= 50) { money = money - 50; fifty++; } while (money >= 20) { money = money - 20; twenty++; } while (money >= 10) { money = money - 10; ten++; } while (money >= 5) { money = money - 5; five++; } while (money >= 1) { money = money - 1; one++; } cout << "五十元"<< fifty << "個\n" << "二十元" << twenty << "個\n" << "十元" << ten << "個\n" << "五元" << five << "個\n" << "一元" << one << "個"; }
[ "noreply@github.com" ]
noreply@github.com
4a1971bd4be6a195eafe6bdd0357b82185292dc5
c27104231043fdc86de2886e88fcbd44d29579d8
/HUAWEI/run.h
1becab91a34a4b332d3aeee7cbade9aa790daa61
[]
no_license
07216/huawei
1b6c376d2623320dfcfe5b4fa37058cfcaf81edc
d6f36a82c3b4cbe8b5771a4f555e62d99e97e18f
refs/heads/master
2021-01-10T18:26:08.076875
2016-11-11T03:05:34
2016-11-11T03:05:34
73,437,329
0
0
null
null
null
null
UTF-8
C++
false
false
289
h
#pragma once #include"data.h" #include"way.h" class run { public: run(); data data_; way *way_best; int best; const int waysum=6; std::vector<way *> way_list; bool optimize(int i); std::vector<bool >way_flag; bool main_loop(); void the_world(int argc, char** argv); ~run(); };
[ "linzhan@mail.ustc.edu.cn" ]
linzhan@mail.ustc.edu.cn
3ecd570d0779133811afa5479c9c33afc408b5cf
bb7d0ba5c784a8565e9a026e6fb03d0685e9cd42
/PixImgLib/pix_ImageDualSet.cpp
842a007470dcb85ea35a1c59abf15eebb3c9227d
[]
no_license
ryocchin/pixRectify
eda86a6e9a426fe04a239fa9eda1ab1f40f7f187
81f07767bdaccc6f2b5ee73e5a0bf648c607eb89
refs/heads/master
2020-03-08T12:54:08.363347
2018-04-10T03:31:18
2018-04-10T03:31:18
128,142,258
0
0
null
null
null
null
UTF-8
C++
false
false
8,471
cpp
#include <pixqt_common.h> #include <piximg_common.h> #include <pixqtlib.h> using namespace _pix_plot_qt_framework; #include <piximglib.h> using namespace _pix_plot_img_framework; #include "pix_ImageDualSet.h" pixq_ImageDualSet::pixq_ImageDualSet(void) { Clear( ); return; } bool pixq_ImageDualSet::Valid( void ) const { bool bValid = false;; switch( _sSelectMode ) { case PixDualSetPair: case PixDualSetDirectory: bValid = true; break; case PixDualSetNone: default: bValid = true; break; } return bValid; } pixq_ImageDualSet::~pixq_ImageDualSet( void ) { Clear( ); return; } void pixq_ImageDualSet::Clear( void ) { int k; _sSelectMode = PixDualSetNone; for( k = 0 ; k < 2 ; k++ ) { _strImgDirs[k].clear( ); _strImgFiles[k].clear( ); } _iCurrentFrame = -1; return; } // // copy constructor // pixq_ImageDualSet &pixq_ImageDualSet::operator=( const pixq_ImageDualSet &that ) { int k; _sSelectMode = that._sSelectMode; for( k = 0 ; k < 2 ; k++ ) { _strImgDirs[k] = that._strImgDirs[k]; _strImgFiles[k] = that._strImgFiles[k]; } _iCurrentFrame = that._iCurrentFrame; // --- Done --- return *this; } int pixq_ImageDualSet::getFilesSize(int iSide) const { int nFrame; switch( _sSelectMode ) { case PixDualSetPair: nFrame = 1; break; case PixDualSetDirectory: nFrame = _strImgFiles[iSide].size( ); break; case PixDualSetNone: default: nFrame = -1; break; } return nFrame; } // // returns the number of frames in the set // for two dir mode, number of larger list is returned // int pixq_ImageDualSet::getFilesSize(void) const { int nFrames; int nFrames0 = getFilesSize(0); int nFrames1 = getFilesSize(1); switch( _sSelectMode ) { case PixDualSetPair: nFrames = 1; break; case PixDualSetDirectory: nFrames0 = getFilesSize(0); nFrames1 = getFilesSize(1); nFrames = max( nFrames0, nFrames1 ); break; case PixDualSetNone: default: nFrames = -1; break; } return nFrames; } bool pixq_ImageDualSet::getCurrentFiles(QString *strFile0, // [o] QString *strFile1 )// [o] ) const { bool bRetCode = false; if (!getCurrentFile(0, strFile0)) { goto PIX_EXIT; } if (!getCurrentFile(1, strFile1)) { goto PIX_EXIT; } // --- Done --- bRetCode = true; PIX_EXIT: return bRetCode; } // // notes: // in dir mode, if there is no file for the current frame number on this side, // strFile is set to null // bool pixq_ImageDualSet::getCurrentFile(int iSide, // [i] side QString *strFile ) // [o] file name const { bool bRetCode = false; int nFrames, iFrame; strFile->clear( ); switch( iSide ) { case 0: case 1: break; default: goto PIX_EXIT; } switch( _sSelectMode ) { case PixDualSetPair: *strFile = _strImgFiles[iSide].at( 0 ); break; case PixDualSetDirectory: iFrame = _iCurrentFrame; nFrames = _strImgFiles[iSide].size( ); if( 0 > iFrame || iFrame >= nFrames ) { strFile->clear( ); } else { *strFile = _strImgFiles[iSide].at( iFrame ); } break; case PixDualSetNone: default: strFile->clear( ); goto PIX_EXIT; break; } // --- Done --- bRetCode = true; PIX_EXIT: return bRetCode; } // // notes: // in dir mode, if there is no file for the current frame number on this side, // strFile is set to null // bool pixq_ImageDualSet::getFrameFile(int iSide, // [i] side int iFrame, // [i] frame number QString *strFile ) // [o] file name const { bool bRetCode = false; int nFrames; strFile->clear( ); switch( iSide ) { case 0: case 1: break; default: goto PIX_EXIT; } switch( _sSelectMode ) { case PixDualSetPair: case PixDualSetDirectory: nFrames = _strImgFiles[iSide].size( ); if( 0 > iFrame || iFrame >= nFrames ) { goto PIX_EXIT; } *strFile = _strImgFiles[iSide].at( iFrame ); break; case PixDualSetNone: default: goto PIX_EXIT; break; } // --- Done --- bRetCode = true; PIX_EXIT: return bRetCode; } QString pixq_ImageDualSet::getFrameString(void) const { int nFrames; QString strFrame; switch( _sSelectMode ) { case PixDualSetPair: strFrame = "Image Pair"; break; case PixDualSetDirectory: nFrames = getFilesSize(); strFrame.sprintf( "Two Dirs: Frame %d-[%d]-%d", 1, _iCurrentFrame+1, nFrames+1 ); break; case PixDualSetNone: default: strFrame = "--------"; break; } return strFrame; } bool pixq_ImageDualSet::ShiftCurrentFrame( int iShift ) // [i] frame number increment { bool bRetCode = false; int iNewFrame, iCurrentFrame, nFrames; // --- check conditions --- switch( _sSelectMode ) { case PixDualSetDirectory: break; case PixDualSetPair: case PixDualSetNone: default: goto PIX_EXIT; break; } // iCurrentFrame = getCurrentFrame(); nFrames = getFilesSize(); if( 0 > iCurrentFrame ) { goto PIX_EXIT; } iNewFrame = iCurrentFrame + iShift; if( 0 > iNewFrame ) { iNewFrame = nFrames - 1; } if( nFrames <= iNewFrame ) { iNewFrame = 0; } SetCurrentFrame( iNewFrame ); // --- Done --- bRetCode = true; PIX_EXIT: return bRetCode; } bool pixq_ImageDualSet::SetCurrentFrame( int iFrame ) { bool bRetCode = false; int nFrames; // --- check conditions --- switch( _sSelectMode ) { case PixDualSetDirectory: case PixDualSetPair: break; case PixDualSetNone: default: goto PIX_EXIT; break; } // nFrames = getFilesSize(); if( 0 > iFrame ) { goto PIX_EXIT; } if( nFrames <= iFrame ) { goto PIX_EXIT; } _iCurrentFrame = iFrame; // --- Done --- bRetCode = true; PIX_EXIT: return bRetCode; } void pixq_ImageDualSet::setImagePair(const QString strFile0, const QString strFile1 ) { _sSelectMode = PixDualSetPair; _iCurrentFrame = 0; _strImgFiles[0].clear( ); _strImgFiles[1].clear( ); _strImgFiles[0].push_back( strFile0 ); _strImgFiles[1].push_back( strFile1 ); _strImgDirs[0].clear( ); _strImgDirs[1].clear( ); return; } // // make lists of all image files in selected directories // bool pixq_ImageDualSet::setImageDirs( const QString strDir0, const QString strDir1 ) { bool bRetCode = false; QStringList nameFilters; QFileInfoList files[2]; QFileInfo info; QString strFile; QDir path[2]; int k, i, nFiles[2]; path[0].setPath( strDir0 ); path[1].setPath( strDir1 ); imageMagickDirFilter_PI(true, nameFilters); // make list of all image files in both dir for( k = 0 ; k < 2 ; k++ ) { files[k] = path[k].entryInfoList( nameFilters, QDir::Files | QDir::Readable, QDir::Name ); nFiles[k] = (int)files[k].size( ); // set the list of files in data qDebug() << path[k].absolutePath( ) << "--------"; _strImgFiles[k].clear( ); for( i = 0 ; i < nFiles[k] ; i++ ) { info = files[k].at( i ); strFile = info.absoluteFilePath( ); _strImgFiles[k].push_back( strFile ); qDebug() << k << i+1 << "/" << nFiles[k] << ":" << strFile; } // sort list by file name _strImgFiles[k].sort( Qt::CaseSensitive ); } qDebug() << "Number of Files in Dirs: " << nFiles[0] << "," << nFiles[1]; // if( 0 >= nFiles[0] || 0 >= nFiles[1] ) { // no file in one or both directories _sSelectMode = PixDualSetNone; _iCurrentFrame = -1; goto PIX_EXIT; } // _strImgDirs[0] = strDir0; _strImgDirs[1] = strDir1; _sSelectMode = PixDualSetDirectory; _iCurrentFrame = 0; // --- Done --- bRetCode = true; PIX_EXIT: return bRetCode; }
[ "pixtopo@gmail.com" ]
pixtopo@gmail.com
14bda41dfa3444beae692f7442cfc784739301bf
7c518db51e67a8fb1129db9abf61403f7765a682
/src/wasm/module-decoder.cc
7028a463ed1ac2f22b84d756a07f863dfad9d9bb
[ "BSD-3-Clause", "bzip2-1.0.6", "SunPro" ]
permissive
astocko/v8
eefe76ef65d3ba0ac7a1b77a1b22a18c46a63b48
87332fdf677f1b53f71be7c05d025a285e5a5c73
refs/heads/master
2020-12-24T06:03:52.854073
2016-11-08T18:19:01
2016-11-08T18:19:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
46,684
cc
// Copyright 2015 the V8 project 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 "src/wasm/module-decoder.h" #include "src/base/functional.h" #include "src/base/platform/platform.h" #include "src/flags.h" #include "src/macro-assembler.h" #include "src/objects.h" #include "src/v8.h" #include "src/wasm/decoder.h" namespace v8 { namespace internal { namespace wasm { #if DEBUG #define TRACE(...) \ do { \ if (FLAG_trace_wasm_decoder) PrintF(__VA_ARGS__); \ } while (false) #else #define TRACE(...) #endif namespace { const char* kNameString = "name"; const size_t kNameStringLength = 4; LocalType TypeOf(const WasmModule* module, const WasmInitExpr& expr) { switch (expr.kind) { case WasmInitExpr::kNone: return kAstStmt; case WasmInitExpr::kGlobalIndex: return expr.val.global_index < module->globals.size() ? module->globals[expr.val.global_index].type : kAstStmt; case WasmInitExpr::kI32Const: return kAstI32; case WasmInitExpr::kI64Const: return kAstI64; case WasmInitExpr::kF32Const: return kAstF32; case WasmInitExpr::kF64Const: return kAstF64; default: UNREACHABLE(); return kAstStmt; } } // An iterator over the sections in a WASM binary module. // Automatically skips all unknown sections. class WasmSectionIterator { public: explicit WasmSectionIterator(Decoder& decoder) : decoder_(decoder), section_code_(kUnknownSectionCode), section_start_(decoder.pc()), section_end_(decoder.pc()) { next(); } inline bool more() const { return section_code_ != kUnknownSectionCode && decoder_.more(); } inline WasmSectionCode section_code() const { return section_code_; } inline const byte* section_start() const { return section_start_; } inline uint32_t section_length() const { return static_cast<uint32_t>(section_end_ - section_start_); } inline const byte* payload_start() const { return payload_start_; } inline uint32_t payload_length() const { return static_cast<uint32_t>(section_end_ - payload_start_); } inline const byte* section_end() const { return section_end_; } // Advances to the next section, checking that decoding the current section // stopped at {section_end_}. void advance() { if (decoder_.pc() != section_end_) { const char* msg = decoder_.pc() < section_end_ ? "shorter" : "longer"; decoder_.error(decoder_.pc(), decoder_.pc(), "section was %s than expected size " "(%u bytes expected, %zu decoded)", msg, section_length(), static_cast<size_t>(decoder_.pc() - section_start_)); } next(); } private: Decoder& decoder_; WasmSectionCode section_code_; const byte* section_start_; const byte* payload_start_; const byte* section_end_; // Reads the section code/name at the current position and sets up // the internal fields. void next() { while (true) { if (!decoder_.more()) { section_code_ = kUnknownSectionCode; return; } uint8_t section_code = decoder_.consume_u8("section code"); // Read and check the section size. uint32_t section_length = decoder_.consume_u32v("section length"); section_start_ = decoder_.pc(); payload_start_ = section_start_; if (decoder_.checkAvailable(section_length)) { // Get the limit of the section within the module. section_end_ = section_start_ + section_length; } else { // The section would extend beyond the end of the module. section_end_ = section_start_; } if (section_code == kUnknownSectionCode) { // Check for the known "name" section. uint32_t string_length = decoder_.consume_u32v("section name length"); const byte* section_name_start = decoder_.pc(); decoder_.consume_bytes(string_length, "section name"); if (decoder_.failed() || decoder_.pc() > section_end_) { TRACE("Section name of length %u couldn't be read\n", string_length); section_code_ = kUnknownSectionCode; return; } payload_start_ = decoder_.pc(); TRACE(" +%d section name : \"%.*s\"\n", static_cast<int>(section_name_start - decoder_.start()), string_length < 20 ? string_length : 20, section_name_start); if (string_length == kNameStringLength && strncmp(reinterpret_cast<const char*>(section_name_start), kNameString, kNameStringLength) == 0) { section_code = kNameSectionCode; } else { section_code = kUnknownSectionCode; } } else if (!IsValidSectionCode(section_code)) { decoder_.error(decoder_.pc(), decoder_.pc(), "unknown section code #0x%02x", section_code); section_code = kUnknownSectionCode; } section_code_ = static_cast<WasmSectionCode>(section_code); TRACE("Section: %s\n", SectionName(section_code_)); if (section_code_ == kUnknownSectionCode && section_end_ > decoder_.pc()) { // skip to the end of the unknown section. uint32_t remaining = static_cast<uint32_t>(section_end_ - decoder_.pc()); decoder_.consume_bytes(remaining, "section payload"); // fall through and continue to the next section. } else { return; } } } }; // The main logic for decoding the bytes of a module. class ModuleDecoder : public Decoder { public: ModuleDecoder(Zone* zone, const byte* module_start, const byte* module_end, ModuleOrigin origin) : Decoder(module_start, module_end), module_zone(zone), origin_(origin) { result_.start = start_; if (limit_ < start_) { error(start_, "end is less than start"); limit_ = start_; } } virtual void onFirstError() { pc_ = limit_; // On error, terminate section decoding loop. } static void DumpModule(WasmModule* module, const ModuleResult& result) { std::string path; if (FLAG_dump_wasm_module_path) { path = FLAG_dump_wasm_module_path; if (path.size() && !base::OS::isDirectorySeparator(path[path.size() - 1])) { path += base::OS::DirectorySeparator(); } } // File are named `HASH.{ok,failed}.wasm`. size_t hash = base::hash_range(module->module_start, module->module_end); char buf[32] = {'\0'}; #if V8_OS_WIN && _MSC_VER < 1900 #define snprintf sprintf_s #endif snprintf(buf, sizeof(buf) - 1, "%016zx.%s.wasm", hash, result.ok() ? "ok" : "failed"); std::string name(buf); if (FILE* wasm_file = base::OS::FOpen((path + name).c_str(), "wb")) { fwrite(module->module_start, module->module_end - module->module_start, 1, wasm_file); fclose(wasm_file); } } // Decodes an entire module. ModuleResult DecodeModule(WasmModule* module, bool verify_functions = true) { pc_ = start_; module->module_start = start_; module->module_end = limit_; module->min_mem_pages = 0; module->max_mem_pages = 0; module->mem_export = false; module->origin = origin_; const byte* pos = pc_; uint32_t magic_word = consume_u32("wasm magic"); #define BYTES(x) (x & 0xff), (x >> 8) & 0xff, (x >> 16) & 0xff, (x >> 24) & 0xff if (magic_word != kWasmMagic) { error(pos, pos, "expected magic word %02x %02x %02x %02x, " "found %02x %02x %02x %02x", BYTES(kWasmMagic), BYTES(magic_word)); } pos = pc_; { uint32_t magic_version = consume_u32("wasm version"); if (magic_version != kWasmVersion) { error(pos, pos, "expected version %02x %02x %02x %02x, " "found %02x %02x %02x %02x", BYTES(kWasmVersion), BYTES(magic_version)); } } WasmSectionIterator section_iter(*this); // ===== Type section ==================================================== if (section_iter.section_code() == kTypeSectionCode) { uint32_t signatures_count = consume_u32v("signatures count"); module->signatures.reserve(SafeReserve(signatures_count)); for (uint32_t i = 0; ok() && i < signatures_count; ++i) { TRACE("DecodeSignature[%d] module+%d\n", i, static_cast<int>(pc_ - start_)); FunctionSig* s = consume_sig(); module->signatures.push_back(s); } section_iter.advance(); } // ===== Import section ================================================== if (section_iter.section_code() == kImportSectionCode) { uint32_t import_table_count = consume_u32v("import table count"); module->import_table.reserve(SafeReserve(import_table_count)); for (uint32_t i = 0; ok() && i < import_table_count; ++i) { TRACE("DecodeImportTable[%d] module+%d\n", i, static_cast<int>(pc_ - start_)); module->import_table.push_back({ 0, // module_name_length 0, // module_name_offset 0, // field_name_offset 0, // field_name_length kExternalFunction, // kind 0 // index }); WasmImport* import = &module->import_table.back(); const byte* pos = pc_; import->module_name_offset = consume_string(&import->module_name_length, true); if (import->module_name_length == 0) { error(pos, "import module name cannot be NULL"); } import->field_name_offset = consume_string(&import->field_name_length, true); import->kind = static_cast<WasmExternalKind>(consume_u8("import kind")); switch (import->kind) { case kExternalFunction: { // ===== Imported function ======================================= import->index = static_cast<uint32_t>(module->functions.size()); module->num_imported_functions++; module->functions.push_back({nullptr, // sig import->index, // func_index 0, // sig_index 0, // name_offset 0, // name_length 0, // code_start_offset 0, // code_end_offset true, // imported false}); // exported WasmFunction* function = &module->functions.back(); function->sig_index = consume_sig_index(module, &function->sig); break; } case kExternalTable: { // ===== Imported table ========================================== import->index = static_cast<uint32_t>(module->function_tables.size()); module->function_tables.push_back({0, 0, false, std::vector<int32_t>(), true, false, SignatureMap()}); expect_u8("element type", kWasmAnyFunctionTypeForm); WasmIndirectFunctionTable* table = &module->function_tables.back(); consume_resizable_limits( "element count", "elements", WasmModule::kV8MaxTableSize, &table->min_size, &table->has_max, WasmModule::kV8MaxTableSize, &table->max_size); break; } case kExternalMemory: { // ===== Imported memory ========================================= bool has_max = false; consume_resizable_limits("memory", "pages", WasmModule::kV8MaxPages, &module->min_mem_pages, &has_max, WasmModule::kSpecMaxPages, &module->max_mem_pages); break; } case kExternalGlobal: { // ===== Imported global ========================================= import->index = static_cast<uint32_t>(module->globals.size()); module->globals.push_back( {kAstStmt, false, WasmInitExpr(), 0, true, false}); WasmGlobal* global = &module->globals.back(); global->type = consume_value_type(); global->mutability = consume_u8("mutability") != 0; if (global->mutability) { error("mutable globals cannot be imported"); } break; } default: error(pos, pos, "unknown import kind 0x%02x", import->kind); break; } } section_iter.advance(); } // ===== Function section ================================================ if (section_iter.section_code() == kFunctionSectionCode) { uint32_t functions_count = consume_u32v("functions count"); module->functions.reserve(SafeReserve(functions_count)); module->num_declared_functions = functions_count; for (uint32_t i = 0; ok() && i < functions_count; ++i) { uint32_t func_index = static_cast<uint32_t>(module->functions.size()); module->functions.push_back({nullptr, // sig func_index, // func_index 0, // sig_index 0, // name_offset 0, // name_length 0, // code_start_offset 0, // code_end_offset false, // imported false}); // exported WasmFunction* function = &module->functions.back(); function->sig_index = consume_sig_index(module, &function->sig); } section_iter.advance(); } // ===== Table section =================================================== if (section_iter.section_code() == kTableSectionCode) { const byte* pos = pc_; uint32_t table_count = consume_u32v("table count"); // Require at most one table for now. if (table_count > 1) { error(pos, pos, "invalid table count %d, maximum 1", table_count); } if (module->function_tables.size() < 1) { module->function_tables.push_back({0, 0, false, std::vector<int32_t>(), false, false, SignatureMap()}); } for (uint32_t i = 0; ok() && i < table_count; i++) { WasmIndirectFunctionTable* table = &module->function_tables.back(); expect_u8("table type", kWasmAnyFunctionTypeForm); consume_resizable_limits("table elements", "elements", WasmModule::kV8MaxTableSize, &table->min_size, &table->has_max, WasmModule::kV8MaxTableSize, &table->max_size); } section_iter.advance(); } // ===== Memory section ================================================== if (section_iter.section_code() == kMemorySectionCode) { const byte* pos = pc_; uint32_t memory_count = consume_u32v("memory count"); // Require at most one memory for now. if (memory_count > 1) { error(pos, pos, "invalid memory count %d, maximum 1", memory_count); } for (uint32_t i = 0; ok() && i < memory_count; i++) { bool has_max = false; consume_resizable_limits( "memory", "pages", WasmModule::kV8MaxPages, &module->min_mem_pages, &has_max, WasmModule::kSpecMaxPages, &module->max_mem_pages); } section_iter.advance(); } // ===== Global section ================================================== if (section_iter.section_code() == kGlobalSectionCode) { uint32_t globals_count = consume_u32v("globals count"); uint32_t imported_globals = static_cast<uint32_t>(module->globals.size()); if (!IsWithinLimit(std::numeric_limits<int32_t>::max(), globals_count, imported_globals)) { error(pos, pos, "too many imported+defined globals: %u + %u", imported_globals, globals_count); } module->globals.reserve(SafeReserve(imported_globals + globals_count)); for (uint32_t i = 0; ok() && i < globals_count; ++i) { TRACE("DecodeGlobal[%d] module+%d\n", i, static_cast<int>(pc_ - start_)); // Add an uninitialized global and pass a pointer to it. module->globals.push_back( {kAstStmt, false, WasmInitExpr(), 0, false, false}); WasmGlobal* global = &module->globals.back(); DecodeGlobalInModule(module, i + imported_globals, global); } section_iter.advance(); } // ===== Export section ================================================== if (section_iter.section_code() == kExportSectionCode) { uint32_t export_table_count = consume_u32v("export table count"); module->export_table.reserve(SafeReserve(export_table_count)); for (uint32_t i = 0; ok() && i < export_table_count; ++i) { TRACE("DecodeExportTable[%d] module+%d\n", i, static_cast<int>(pc_ - start_)); module->export_table.push_back({ 0, // name_length 0, // name_offset kExternalFunction, // kind 0 // index }); WasmExport* exp = &module->export_table.back(); exp->name_offset = consume_string(&exp->name_length, true); const byte* pos = pc(); exp->kind = static_cast<WasmExternalKind>(consume_u8("export kind")); switch (exp->kind) { case kExternalFunction: { WasmFunction* func = nullptr; exp->index = consume_func_index(module, &func); module->num_exported_functions++; if (func) func->exported = true; break; } case kExternalTable: { WasmIndirectFunctionTable* table = nullptr; exp->index = consume_table_index(module, &table); if (table) table->exported = true; break; } case kExternalMemory: { uint32_t index = consume_u32v("memory index"); if (index != 0) error("invalid memory index != 0"); module->mem_export = true; break; } case kExternalGlobal: { WasmGlobal* global = nullptr; exp->index = consume_global_index(module, &global); if (global) { if (global->mutability) { error("mutable globals cannot be exported"); } global->exported = true; } break; } default: error(pos, pos, "invalid export kind 0x%02x", exp->kind); break; } } // Check for duplicate exports. if (ok() && module->export_table.size() > 1) { std::vector<WasmExport> sorted_exports(module->export_table); const byte* base = start_; auto cmp_less = [base](const WasmExport& a, const WasmExport& b) { // Return true if a < b. if (a.name_length != b.name_length) { return a.name_length < b.name_length; } return memcmp(base + a.name_offset, base + b.name_offset, a.name_length) < 0; }; std::stable_sort(sorted_exports.begin(), sorted_exports.end(), cmp_less); auto it = sorted_exports.begin(); WasmExport* last = &*it++; for (auto end = sorted_exports.end(); it != end; last = &*it++) { DCHECK(!cmp_less(*it, *last)); // Vector must be sorted. if (!cmp_less(*last, *it)) { const byte* pc = start_ + it->name_offset; error(pc, pc, "Duplicate export name '%.*s' for functions %d and %d", it->name_length, pc, last->index, it->index); break; } } } section_iter.advance(); } // ===== Start section =================================================== if (section_iter.section_code() == kStartSectionCode) { WasmFunction* func; const byte* pos = pc_; module->start_function_index = consume_func_index(module, &func); if (func && (func->sig->parameter_count() > 0 || func->sig->return_count() > 0)) { error(pos, "invalid start function: non-zero parameter or return count"); } section_iter.advance(); } // ===== Elements section ================================================ if (section_iter.section_code() == kElementSectionCode) { uint32_t element_count = consume_u32v("element count"); for (uint32_t i = 0; ok() && i < element_count; ++i) { const byte* pos = pc(); uint32_t table_index = consume_u32v("table index"); if (table_index != 0) { error(pos, pos, "illegal table index %u != 0", table_index); } WasmIndirectFunctionTable* table = nullptr; if (table_index >= module->function_tables.size()) { error(pos, pos, "out of bounds table index %u", table_index); } else { table = &module->function_tables[table_index]; } WasmInitExpr offset = consume_init_expr(module, kAstI32); uint32_t num_elem = consume_u32v("number of elements"); std::vector<uint32_t> vector; module->table_inits.push_back({table_index, offset, vector}); WasmTableInit* init = &module->table_inits.back(); init->entries.reserve(SafeReserve(num_elem)); for (uint32_t j = 0; ok() && j < num_elem; j++) { WasmFunction* func = nullptr; uint32_t index = consume_func_index(module, &func); init->entries.push_back(index); if (table && index < module->functions.size()) { // Canonicalize signature indices during decoding. // TODO(titzer): suboptimal, redundant when verifying only. table->map.FindOrInsert(module->functions[index].sig); } } } section_iter.advance(); } // ===== Code section ==================================================== if (section_iter.section_code() == kCodeSectionCode) { const byte* pos = pc_; uint32_t functions_count = consume_u32v("functions count"); if (functions_count != module->num_declared_functions) { error(pos, pos, "function body count %u mismatch (%u expected)", functions_count, module->num_declared_functions); } for (uint32_t i = 0; ok() && i < functions_count; ++i) { WasmFunction* function = &module->functions[i + module->num_imported_functions]; uint32_t size = consume_u32v("body size"); function->code_start_offset = pc_offset(); function->code_end_offset = pc_offset() + size; consume_bytes(size, "function body"); } section_iter.advance(); } // ===== Data section ==================================================== if (section_iter.section_code() == kDataSectionCode) { uint32_t data_segments_count = consume_u32v("data segments count"); module->data_segments.reserve(SafeReserve(data_segments_count)); for (uint32_t i = 0; ok() && i < data_segments_count; ++i) { TRACE("DecodeDataSegment[%d] module+%d\n", i, static_cast<int>(pc_ - start_)); module->data_segments.push_back({ WasmInitExpr(), // dest_addr 0, // source_offset 0 // source_size }); WasmDataSegment* segment = &module->data_segments.back(); DecodeDataSegmentInModule(module, segment); } section_iter.advance(); } // ===== Name section ==================================================== if (section_iter.section_code() == kNameSectionCode) { const byte* pos = pc_; uint32_t functions_count = consume_u32v("functions count"); if (functions_count != module->num_declared_functions) { error(pos, pos, "function name count %u mismatch (%u expected)", functions_count, module->num_declared_functions); } for (uint32_t i = 0; ok() && i < functions_count; ++i) { WasmFunction* function = &module->functions[i + module->num_imported_functions]; function->name_offset = consume_string(&function->name_length, false); uint32_t local_names_count = consume_u32v("local names count"); for (uint32_t j = 0; ok() && j < local_names_count; j++) { skip_string(); } } section_iter.advance(); } // ===== Remaining sections ============================================== if (section_iter.more() && ok()) { error(pc(), pc(), "unexpected section: %s", SectionName(section_iter.section_code())); } if (ok()) { CalculateGlobalOffsets(module); } const WasmModule* finished_module = module; ModuleResult result = toResult(finished_module); if (FLAG_dump_wasm_module) DumpModule(module, result); return result; } uint32_t SafeReserve(uint32_t count) { // Avoid OOM by only reserving up to a certain size. const uint32_t kMaxReserve = 20000; return count < kMaxReserve ? count : kMaxReserve; } // Decodes a single anonymous function starting at {start_}. FunctionResult DecodeSingleFunction(ModuleEnv* module_env, WasmFunction* function) { pc_ = start_; function->sig = consume_sig(); // read signature function->name_offset = 0; // ---- name function->name_length = 0; // ---- name length function->code_start_offset = off(pc_); // ---- code start function->code_end_offset = off(limit_); // ---- code end if (ok()) VerifyFunctionBody(0, module_env, function); FunctionResult result; result.MoveFrom(result_); // Copy error code and location. result.val = function; return result; } // Decodes a single function signature at {start}. FunctionSig* DecodeFunctionSignature(const byte* start) { pc_ = start; FunctionSig* result = consume_sig(); return ok() ? result : nullptr; } WasmInitExpr DecodeInitExpr(const byte* start) { pc_ = start; return consume_init_expr(nullptr, kAstStmt); } private: Zone* module_zone; ModuleResult result_; ModuleOrigin origin_; uint32_t off(const byte* ptr) { return static_cast<uint32_t>(ptr - start_); } // Decodes a single global entry inside a module starting at {pc_}. void DecodeGlobalInModule(WasmModule* module, uint32_t index, WasmGlobal* global) { global->type = consume_value_type(); global->mutability = consume_u8("mutability") != 0; const byte* pos = pc(); global->init = consume_init_expr(module, kAstStmt); switch (global->init.kind) { case WasmInitExpr::kGlobalIndex: { uint32_t other_index = global->init.val.global_index; if (other_index >= index) { error(pos, pos, "invalid global index in init expression, " "index %u, other_index %u", index, other_index); } else if (module->globals[other_index].type != global->type) { error(pos, pos, "type mismatch in global initialization " "(from global #%u), expected %s, got %s", other_index, WasmOpcodes::TypeName(global->type), WasmOpcodes::TypeName(module->globals[other_index].type)); } break; } default: if (global->type != TypeOf(module, global->init)) { error(pos, pos, "type error in global initialization, expected %s, got %s", WasmOpcodes::TypeName(global->type), WasmOpcodes::TypeName(TypeOf(module, global->init))); } } } bool IsWithinLimit(uint32_t limit, uint32_t offset, uint32_t size) { if (offset > limit) return false; if ((offset + size) < offset) return false; // overflow return (offset + size) <= limit; } // Decodes a single data segment entry inside a module starting at {pc_}. void DecodeDataSegmentInModule(WasmModule* module, WasmDataSegment* segment) { const byte* start = pc_; expect_u8("linear memory index", 0); segment->dest_addr = consume_init_expr(module, kAstI32); segment->source_size = consume_u32v("source size"); segment->source_offset = static_cast<uint32_t>(pc_ - start_); // Validate the data is in the module. uint32_t module_limit = static_cast<uint32_t>(limit_ - start_); if (!IsWithinLimit(module_limit, segment->source_offset, segment->source_size)) { error(start, "segment out of bounds of module"); } consume_bytes(segment->source_size, "segment data"); } // Calculate individual global offsets and total size of globals table. void CalculateGlobalOffsets(WasmModule* module) { uint32_t offset = 0; if (module->globals.size() == 0) { module->globals_size = 0; return; } for (WasmGlobal& global : module->globals) { byte size = WasmOpcodes::MemSize(WasmOpcodes::MachineTypeFor(global.type)); offset = (offset + size - 1) & ~(size - 1); // align global.offset = offset; offset += size; } module->globals_size = offset; } // Verifies the body (code) of a given function. void VerifyFunctionBody(uint32_t func_num, ModuleEnv* menv, WasmFunction* function) { if (FLAG_trace_wasm_decoder || FLAG_trace_wasm_decode_time) { OFStream os(stdout); os << "Verifying WASM function " << WasmFunctionName(function, menv) << std::endl; } FunctionBody body = {menv, function->sig, start_, start_ + function->code_start_offset, start_ + function->code_end_offset}; DecodeResult result = VerifyWasmCode(module_zone->allocator(), body); if (result.failed()) { // Wrap the error message from the function decoder. std::ostringstream str; str << "in function " << WasmFunctionName(function, menv) << ": "; str << result; std::string strval = str.str(); const char* raw = strval.c_str(); size_t len = strlen(raw); char* buffer = new char[len]; strncpy(buffer, raw, len); buffer[len - 1] = 0; // Copy error code and location. result_.MoveFrom(result); result_.error_msg.reset(buffer); } } // Reads a length-prefixed string, checking that it is within bounds. Returns // the offset of the string, and the length as an out parameter. uint32_t consume_string(uint32_t* length, bool validate_utf8) { *length = consume_u32v("string length"); uint32_t offset = pc_offset(); const byte* string_start = pc_; // Consume bytes before validation to guarantee that the string is not oob. if (*length > 0) consume_bytes(*length, "string"); if (ok() && validate_utf8 && !unibrow::Utf8::Validate(string_start, *length)) { error(string_start, "no valid UTF-8 string"); } return offset; } // Skips over a length-prefixed string, but checks that it is within bounds. void skip_string() { uint32_t length = consume_u32v("string length"); consume_bytes(length, "string"); } uint32_t consume_sig_index(WasmModule* module, FunctionSig** sig) { const byte* pos = pc_; uint32_t sig_index = consume_u32v("signature index"); if (sig_index >= module->signatures.size()) { error(pos, pos, "signature index %u out of bounds (%d signatures)", sig_index, static_cast<int>(module->signatures.size())); *sig = nullptr; return 0; } *sig = module->signatures[sig_index]; return sig_index; } uint32_t consume_func_index(WasmModule* module, WasmFunction** func) { return consume_index("function index", module->functions, func); } uint32_t consume_global_index(WasmModule* module, WasmGlobal** global) { return consume_index("global index", module->globals, global); } uint32_t consume_table_index(WasmModule* module, WasmIndirectFunctionTable** table) { return consume_index("table index", module->function_tables, table); } template <typename T> uint32_t consume_index(const char* name, std::vector<T>& vector, T** ptr) { const byte* pos = pc_; uint32_t index = consume_u32v(name); if (index >= vector.size()) { error(pos, pos, "%s %u out of bounds (%d entries)", name, index, static_cast<int>(vector.size())); *ptr = nullptr; return 0; } *ptr = &vector[index]; return index; } void consume_resizable_limits(const char* name, const char* units, uint32_t max_initial, uint32_t* initial, bool* has_max, uint32_t max_maximum, uint32_t* maximum) { uint32_t flags = consume_u32v("resizable limits flags"); const byte* pos = pc(); *initial = consume_u32v("initial size"); *has_max = false; if (*initial > max_initial) { error(pos, pos, "initial %s size (%u %s) is larger than implementation limit (%u)", name, *initial, units, max_initial); } if (flags & 1) { *has_max = true; pos = pc(); *maximum = consume_u32v("maximum size"); if (*maximum > max_maximum) { error( pos, pos, "maximum %s size (%u %s) is larger than implementation limit (%u)", name, *maximum, units, max_maximum); } if (*maximum < *initial) { error(pos, pos, "maximum %s size (%u %s) is less than initial (%u %s)", name, *maximum, units, *initial, units); } } else { *has_max = false; *maximum = max_initial; } } bool expect_u8(const char* name, uint8_t expected) { const byte* pos = pc(); uint8_t value = consume_u8(name); if (value != expected) { error(pos, pos, "expected %s 0x%02x, got 0x%02x", name, expected, value); return false; } return true; } WasmInitExpr consume_init_expr(WasmModule* module, LocalType expected) { const byte* pos = pc(); uint8_t opcode = consume_u8("opcode"); WasmInitExpr expr; unsigned len = 0; switch (opcode) { case kExprGetGlobal: { GlobalIndexOperand operand(this, pc() - 1); expr.kind = WasmInitExpr::kGlobalIndex; expr.val.global_index = operand.index; len = operand.length; break; } case kExprI32Const: { ImmI32Operand operand(this, pc() - 1); expr.kind = WasmInitExpr::kI32Const; expr.val.i32_const = operand.value; len = operand.length; break; } case kExprF32Const: { ImmF32Operand operand(this, pc() - 1); expr.kind = WasmInitExpr::kF32Const; expr.val.f32_const = operand.value; len = operand.length; break; } case kExprI64Const: { ImmI64Operand operand(this, pc() - 1); expr.kind = WasmInitExpr::kI64Const; expr.val.i64_const = operand.value; len = operand.length; break; } case kExprF64Const: { ImmF64Operand operand(this, pc() - 1); expr.kind = WasmInitExpr::kF64Const; expr.val.f64_const = operand.value; len = operand.length; break; } default: { error("invalid opcode in initialization expression"); expr.kind = WasmInitExpr::kNone; expr.val.i32_const = 0; } } consume_bytes(len, "init code"); if (!expect_u8("end opcode", kExprEnd)) { expr.kind = WasmInitExpr::kNone; } if (expected != kAstStmt && TypeOf(module, expr) != kAstI32) { error(pos, pos, "type error in init expression, expected %s, got %s", WasmOpcodes::TypeName(expected), WasmOpcodes::TypeName(TypeOf(module, expr))); } return expr; } // Reads a single 8-bit integer, interpreting it as a local type. LocalType consume_value_type() { byte val = consume_u8("value type"); LocalTypeCode t = static_cast<LocalTypeCode>(val); switch (t) { case kLocalI32: return kAstI32; case kLocalI64: return kAstI64; case kLocalF32: return kAstF32; case kLocalF64: return kAstF64; case kLocalS128: if (origin_ != kAsmJsOrigin && FLAG_wasm_simd_prototype) { return kAstS128; } else { error(pc_ - 1, "invalid local type"); return kAstStmt; } default: error(pc_ - 1, "invalid local type"); return kAstStmt; } } // Parses a type entry, which is currently limited to functions only. FunctionSig* consume_sig() { if (!expect_u8("type form", kWasmFunctionTypeForm)) return nullptr; // parse parameter types uint32_t param_count = consume_u32v("param count"); std::vector<LocalType> params; for (uint32_t i = 0; ok() && i < param_count; ++i) { LocalType param = consume_value_type(); params.push_back(param); } // parse return types const byte* pt = pc_; uint32_t return_count = consume_u32v("return count"); if (return_count > kMaxReturnCount) { error(pt, pt, "return count of %u exceeds maximum of %u", return_count, kMaxReturnCount); return nullptr; } std::vector<LocalType> returns; for (uint32_t i = 0; ok() && i < return_count; ++i) { LocalType ret = consume_value_type(); returns.push_back(ret); } if (failed()) { // Decoding failed, return void -> void return new (module_zone) FunctionSig(0, 0, nullptr); } // FunctionSig stores the return types first. LocalType* buffer = module_zone->NewArray<LocalType>(param_count + return_count); uint32_t b = 0; for (uint32_t i = 0; i < return_count; ++i) buffer[b++] = returns[i]; for (uint32_t i = 0; i < param_count; ++i) buffer[b++] = params[i]; return new (module_zone) FunctionSig(return_count, param_count, buffer); } }; // Helpers for nice error messages. class ModuleError : public ModuleResult { public: explicit ModuleError(const char* msg) { error_code = kError; size_t len = strlen(msg) + 1; char* result = new char[len]; strncpy(result, msg, len); result[len - 1] = 0; error_msg.reset(result); } }; // Helpers for nice error messages. class FunctionError : public FunctionResult { public: explicit FunctionError(const char* msg) { error_code = kError; size_t len = strlen(msg) + 1; char* result = new char[len]; strncpy(result, msg, len); result[len - 1] = 0; error_msg.reset(result); } }; // Find section with given section code. Return Vector of the payload, or null // Vector if section is not found or module bytes are invalid. Vector<const byte> FindSection(const byte* module_start, const byte* module_end, WasmSectionCode code) { Decoder decoder(module_start, module_end); uint32_t magic_word = decoder.consume_u32("wasm magic"); if (magic_word != kWasmMagic) decoder.error("wrong magic word"); uint32_t magic_version = decoder.consume_u32("wasm version"); if (magic_version != kWasmVersion) decoder.error("wrong wasm version"); WasmSectionIterator section_iter(decoder); while (section_iter.more()) { if (section_iter.section_code() == code) { return Vector<const uint8_t>(section_iter.payload_start(), section_iter.payload_length()); } decoder.consume_bytes(section_iter.payload_length(), "section payload"); section_iter.advance(); } return Vector<const uint8_t>(); } } // namespace ModuleResult DecodeWasmModule(Isolate* isolate, const byte* module_start, const byte* module_end, bool verify_functions, ModuleOrigin origin) { HistogramTimerScope wasm_decode_module_time_scope( isolate->counters()->wasm_decode_module_time()); size_t size = module_end - module_start; if (module_start > module_end) return ModuleError("start > end"); if (size >= kMaxModuleSize) return ModuleError("size > maximum module size"); // TODO(bradnelson): Improve histogram handling of size_t. isolate->counters()->wasm_module_size_bytes()->AddSample( static_cast<int>(size)); // Signatures are stored in zone memory, which have the same lifetime // as the {module}. Zone* zone = new Zone(isolate->allocator(), ZONE_NAME); WasmModule* module = new WasmModule(zone, module_start); ModuleDecoder decoder(zone, module_start, module_end, origin); ModuleResult result = decoder.DecodeModule(module, verify_functions); // TODO(bradnelson): Improve histogram handling of size_t. // TODO(titzer): this isn't accurate, since it doesn't count the data // allocated on the C++ heap. // https://bugs.chromium.org/p/chromium/issues/detail?id=657320 isolate->counters()->wasm_decode_module_peak_memory_bytes()->AddSample( static_cast<int>(zone->allocation_size())); return result; } FunctionSig* DecodeWasmSignatureForTesting(Zone* zone, const byte* start, const byte* end) { ModuleDecoder decoder(zone, start, end, kWasmOrigin); return decoder.DecodeFunctionSignature(start); } WasmInitExpr DecodeWasmInitExprForTesting(const byte* start, const byte* end) { AccountingAllocator allocator; Zone zone(&allocator, ZONE_NAME); ModuleDecoder decoder(&zone, start, end, kWasmOrigin); return decoder.DecodeInitExpr(start); } FunctionResult DecodeWasmFunction(Isolate* isolate, Zone* zone, ModuleEnv* module_env, const byte* function_start, const byte* function_end) { HistogramTimerScope wasm_decode_function_time_scope( isolate->counters()->wasm_decode_function_time()); size_t size = function_end - function_start; if (function_start > function_end) return FunctionError("start > end"); if (size > kMaxFunctionSize) return FunctionError("size > maximum function size"); isolate->counters()->wasm_function_size_bytes()->AddSample( static_cast<int>(size)); WasmFunction* function = new WasmFunction(); ModuleDecoder decoder(zone, function_start, function_end, kWasmOrigin); return decoder.DecodeSingleFunction(module_env, function); } FunctionOffsetsResult DecodeWasmFunctionOffsets( const byte* module_start, const byte* module_end, uint32_t num_imported_functions) { // Find and decode the code section. Vector<const byte> code_section = FindSection(module_start, module_end, kCodeSectionCode); Decoder decoder(code_section.start(), code_section.end()); FunctionOffsets table; if (!code_section.start()) { decoder.error("no code section"); return decoder.toResult(std::move(table)); } uint32_t functions_count = decoder.consume_u32v("functions count"); // Reserve space for the entries, taking care of invalid input. if (functions_count < static_cast<unsigned>(code_section.length()) / 2) { table.reserve(num_imported_functions + functions_count); } // Add null entries for the imported functions. table.resize(num_imported_functions); int section_offset = static_cast<int>(code_section.start() - module_start); DCHECK_LE(0, section_offset); for (uint32_t i = 0; i < functions_count && decoder.ok(); ++i) { uint32_t size = decoder.consume_u32v("body size"); int offset = static_cast<int>(section_offset + decoder.pc_offset()); table.push_back(std::make_pair(offset, static_cast<int>(size))); DCHECK(table.back().first >= 0 && table.back().second >= 0); decoder.consume_bytes(size); } if (decoder.more()) decoder.error("unexpected additional bytes"); return decoder.toResult(std::move(table)); } AsmJsOffsetsResult DecodeAsmJsOffsets(const byte* tables_start, const byte* tables_end, uint32_t num_imported_functions) { AsmJsOffsets table; Decoder decoder(tables_start, tables_end); uint32_t functions_count = decoder.consume_u32v("functions count"); // Reserve space for the entries, taking care of invalid input. if (functions_count < static_cast<unsigned>(tables_end - tables_start)) { table.reserve(num_imported_functions + functions_count); } // Add null entries for the imported functions. table.resize(num_imported_functions); for (uint32_t i = 0; i < functions_count && decoder.ok(); ++i) { uint32_t size = decoder.consume_u32v("table size"); if (size == 0) { table.push_back(std::vector<std::pair<int, int>>()); continue; } if (!decoder.checkAvailable(size)) { decoder.error("illegal asm function offset table size"); } const byte* table_end = decoder.pc() + size; uint32_t locals_size = decoder.consume_u32("locals size"); int last_byte_offset = locals_size; int last_asm_position = 0; std::vector<std::pair<int, int>> func_asm_offsets; func_asm_offsets.reserve(size / 4); // conservative estimation while (decoder.ok() && decoder.pc() < table_end) { last_byte_offset += decoder.consume_u32v("byte offset delta"); last_asm_position += decoder.consume_i32v("asm position delta"); func_asm_offsets.push_back({last_byte_offset, last_asm_position}); } if (decoder.pc() != table_end) { decoder.error("broken asm offset table"); } table.push_back(std::move(func_asm_offsets)); } if (decoder.more()) decoder.error("unexpected additional bytes"); return decoder.toResult(std::move(table)); } } // namespace wasm } // namespace internal } // namespace v8
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
c810ba33cecca96de5d960c0098830cee9e5d25e
a4a686015b5efbf04f03c20333282a014a8dc58d
/Temp/StagingArea/Data/Managed/UnityICallRegistration.cpp
e75afdafaaade477c6b93e4c31e1576e5d447711
[]
no_license
Maninder786/soldier
427e3006df6ab0495150791b343e025dbc5813c4
bd45d90a7861d0600598ccc52aaf001f37524d17
refs/heads/master
2021-04-26T22:48:58.422978
2018-03-07T00:55:22
2018-03-07T00:55:22
124,150,240
0
0
null
null
null
null
UTF-8
C++
false
false
120,540
cpp
void RegisterAllStrippedInternalCalls() { //Start Registrations for type : UnityEngine.Analytics.CustomEventData //System.Boolean UnityEngine.Analytics.CustomEventData::AddBool(System.String,System.Boolean) void Register_UnityEngine_Analytics_CustomEventData_AddBool(); Register_UnityEngine_Analytics_CustomEventData_AddBool(); //System.Boolean UnityEngine.Analytics.CustomEventData::AddByte(System.String,System.Byte) void Register_UnityEngine_Analytics_CustomEventData_AddByte(); Register_UnityEngine_Analytics_CustomEventData_AddByte(); //System.Boolean UnityEngine.Analytics.CustomEventData::AddChar(System.String,System.Char) void Register_UnityEngine_Analytics_CustomEventData_AddChar(); Register_UnityEngine_Analytics_CustomEventData_AddChar(); //System.Boolean UnityEngine.Analytics.CustomEventData::AddDouble(System.String,System.Double) void Register_UnityEngine_Analytics_CustomEventData_AddDouble(); Register_UnityEngine_Analytics_CustomEventData_AddDouble(); //System.Boolean UnityEngine.Analytics.CustomEventData::AddInt16(System.String,System.Int16) void Register_UnityEngine_Analytics_CustomEventData_AddInt16(); Register_UnityEngine_Analytics_CustomEventData_AddInt16(); //System.Boolean UnityEngine.Analytics.CustomEventData::AddInt32(System.String,System.Int32) void Register_UnityEngine_Analytics_CustomEventData_AddInt32(); Register_UnityEngine_Analytics_CustomEventData_AddInt32(); //System.Boolean UnityEngine.Analytics.CustomEventData::AddInt64(System.String,System.Int64) void Register_UnityEngine_Analytics_CustomEventData_AddInt64(); Register_UnityEngine_Analytics_CustomEventData_AddInt64(); //System.Boolean UnityEngine.Analytics.CustomEventData::AddSByte(System.String,System.SByte) void Register_UnityEngine_Analytics_CustomEventData_AddSByte(); Register_UnityEngine_Analytics_CustomEventData_AddSByte(); //System.Boolean UnityEngine.Analytics.CustomEventData::AddString(System.String,System.String) void Register_UnityEngine_Analytics_CustomEventData_AddString(); Register_UnityEngine_Analytics_CustomEventData_AddString(); //System.Boolean UnityEngine.Analytics.CustomEventData::AddUInt16(System.String,System.UInt16) void Register_UnityEngine_Analytics_CustomEventData_AddUInt16(); Register_UnityEngine_Analytics_CustomEventData_AddUInt16(); //System.Boolean UnityEngine.Analytics.CustomEventData::AddUInt32(System.String,System.UInt32) void Register_UnityEngine_Analytics_CustomEventData_AddUInt32(); Register_UnityEngine_Analytics_CustomEventData_AddUInt32(); //System.Boolean UnityEngine.Analytics.CustomEventData::AddUInt64(System.String,System.UInt64) void Register_UnityEngine_Analytics_CustomEventData_AddUInt64(); Register_UnityEngine_Analytics_CustomEventData_AddUInt64(); //System.Void UnityEngine.Analytics.CustomEventData::InternalCreate(System.String) void Register_UnityEngine_Analytics_CustomEventData_InternalCreate(); Register_UnityEngine_Analytics_CustomEventData_InternalCreate(); //System.Void UnityEngine.Analytics.CustomEventData::InternalDestroy() void Register_UnityEngine_Analytics_CustomEventData_InternalDestroy(); Register_UnityEngine_Analytics_CustomEventData_InternalDestroy(); //End Registrations for type : UnityEngine.Analytics.CustomEventData //Start Registrations for type : UnityEngine.Analytics.UnityAnalyticsHandler //System.Void UnityEngine.Analytics.UnityAnalyticsHandler::InternalCreate() void Register_UnityEngine_Analytics_UnityAnalyticsHandler_InternalCreate(); Register_UnityEngine_Analytics_UnityAnalyticsHandler_InternalCreate(); //System.Void UnityEngine.Analytics.UnityAnalyticsHandler::InternalDestroy() void Register_UnityEngine_Analytics_UnityAnalyticsHandler_InternalDestroy(); Register_UnityEngine_Analytics_UnityAnalyticsHandler_InternalDestroy(); //UnityEngine.Analytics.AnalyticsResult UnityEngine.Analytics.UnityAnalyticsHandler::SendCustomEvent(UnityEngine.Analytics.CustomEventData) void Register_UnityEngine_Analytics_UnityAnalyticsHandler_SendCustomEvent(); Register_UnityEngine_Analytics_UnityAnalyticsHandler_SendCustomEvent(); //UnityEngine.Analytics.AnalyticsResult UnityEngine.Analytics.UnityAnalyticsHandler::SendCustomEventName(System.String) void Register_UnityEngine_Analytics_UnityAnalyticsHandler_SendCustomEventName(); Register_UnityEngine_Analytics_UnityAnalyticsHandler_SendCustomEventName(); //End Registrations for type : UnityEngine.Analytics.UnityAnalyticsHandler //Start Registrations for type : UnityEngine.AnimationClip //System.Boolean UnityEngine.AnimationClip::get_empty() void Register_UnityEngine_AnimationClip_get_empty(); Register_UnityEngine_AnimationClip_get_empty(); //System.Boolean UnityEngine.AnimationClip::get_hasRootMotion() void Register_UnityEngine_AnimationClip_get_hasRootMotion(); Register_UnityEngine_AnimationClip_get_hasRootMotion(); //System.Boolean UnityEngine.AnimationClip::get_legacy() void Register_UnityEngine_AnimationClip_get_legacy(); Register_UnityEngine_AnimationClip_get_legacy(); //System.Single UnityEngine.AnimationClip::get_frameRate() void Register_UnityEngine_AnimationClip_get_frameRate(); Register_UnityEngine_AnimationClip_get_frameRate(); //System.Single UnityEngine.AnimationClip::get_length() void Register_UnityEngine_AnimationClip_get_length(); Register_UnityEngine_AnimationClip_get_length(); //System.Void UnityEngine.AnimationClip::Internal_CreateAnimationClip(UnityEngine.AnimationClip) void Register_UnityEngine_AnimationClip_Internal_CreateAnimationClip(); Register_UnityEngine_AnimationClip_Internal_CreateAnimationClip(); //End Registrations for type : UnityEngine.AnimationClip //Start Registrations for type : UnityEngine.AnimationCurve //System.Int32 UnityEngine.AnimationCurve::get_length() void Register_UnityEngine_AnimationCurve_get_length(); Register_UnityEngine_AnimationCurve_get_length(); //System.Single UnityEngine.AnimationCurve::Evaluate(System.Single) void Register_UnityEngine_AnimationCurve_Evaluate(); Register_UnityEngine_AnimationCurve_Evaluate(); //System.Void UnityEngine.AnimationCurve::Cleanup() void Register_UnityEngine_AnimationCurve_Cleanup(); Register_UnityEngine_AnimationCurve_Cleanup(); //System.Void UnityEngine.AnimationCurve::Init(UnityEngine.Keyframe[]) void Register_UnityEngine_AnimationCurve_Init(); Register_UnityEngine_AnimationCurve_Init(); //System.Void UnityEngine.AnimationCurve::SetKeys(UnityEngine.Keyframe[]) void Register_UnityEngine_AnimationCurve_SetKeys(); Register_UnityEngine_AnimationCurve_SetKeys(); //UnityEngine.Keyframe[] UnityEngine.AnimationCurve::GetKeys() void Register_UnityEngine_AnimationCurve_GetKeys(); Register_UnityEngine_AnimationCurve_GetKeys(); //End Registrations for type : UnityEngine.AnimationCurve //Start Registrations for type : UnityEngine.Animations.AnimationClipPlayable //System.Boolean UnityEngine.Animations.AnimationClipPlayable::INTERNAL_CALL_CreateHandleInternal(UnityEngine.Playables.PlayableGraph&,UnityEngine.AnimationClip,UnityEngine.Playables.PlayableHandle&) void Register_UnityEngine_Animations_AnimationClipPlayable_INTERNAL_CALL_CreateHandleInternal(); Register_UnityEngine_Animations_AnimationClipPlayable_INTERNAL_CALL_CreateHandleInternal(); //System.Boolean UnityEngine.Animations.AnimationClipPlayable::INTERNAL_CALL_GetApplyFootIKInternal(UnityEngine.Playables.PlayableHandle&) void Register_UnityEngine_Animations_AnimationClipPlayable_INTERNAL_CALL_GetApplyFootIKInternal(); Register_UnityEngine_Animations_AnimationClipPlayable_INTERNAL_CALL_GetApplyFootIKInternal(); //System.Boolean UnityEngine.Animations.AnimationClipPlayable::INTERNAL_CALL_GetRemoveStartOffsetInternal(UnityEngine.Playables.PlayableHandle&) void Register_UnityEngine_Animations_AnimationClipPlayable_INTERNAL_CALL_GetRemoveStartOffsetInternal(); Register_UnityEngine_Animations_AnimationClipPlayable_INTERNAL_CALL_GetRemoveStartOffsetInternal(); //System.Void UnityEngine.Animations.AnimationClipPlayable::INTERNAL_CALL_SetRemoveStartOffsetInternal(UnityEngine.Playables.PlayableHandle&,System.Boolean) void Register_UnityEngine_Animations_AnimationClipPlayable_INTERNAL_CALL_SetRemoveStartOffsetInternal(); Register_UnityEngine_Animations_AnimationClipPlayable_INTERNAL_CALL_SetRemoveStartOffsetInternal(); //UnityEngine.AnimationClip UnityEngine.Animations.AnimationClipPlayable::INTERNAL_CALL_GetAnimationClipInternal(UnityEngine.Playables.PlayableHandle&) void Register_UnityEngine_Animations_AnimationClipPlayable_INTERNAL_CALL_GetAnimationClipInternal(); Register_UnityEngine_Animations_AnimationClipPlayable_INTERNAL_CALL_GetAnimationClipInternal(); //End Registrations for type : UnityEngine.Animations.AnimationClipPlayable //Start Registrations for type : UnityEngine.Animations.AnimationLayerMixerPlayable //System.Boolean UnityEngine.Animations.AnimationLayerMixerPlayable::INTERNAL_CALL_CreateHandleInternal(UnityEngine.Playables.PlayableGraph&,UnityEngine.Playables.PlayableHandle&) void Register_UnityEngine_Animations_AnimationLayerMixerPlayable_INTERNAL_CALL_CreateHandleInternal(); Register_UnityEngine_Animations_AnimationLayerMixerPlayable_INTERNAL_CALL_CreateHandleInternal(); //System.Void UnityEngine.Animations.AnimationLayerMixerPlayable::INTERNAL_CALL_SetLayerMaskFromAvatarMaskInternal(UnityEngine.Playables.PlayableHandle&,System.UInt32,UnityEngine.AvatarMask) void Register_UnityEngine_Animations_AnimationLayerMixerPlayable_INTERNAL_CALL_SetLayerMaskFromAvatarMaskInternal(); Register_UnityEngine_Animations_AnimationLayerMixerPlayable_INTERNAL_CALL_SetLayerMaskFromAvatarMaskInternal(); //End Registrations for type : UnityEngine.Animations.AnimationLayerMixerPlayable //Start Registrations for type : UnityEngine.Animations.AnimationMixerPlayable //System.Boolean UnityEngine.Animations.AnimationMixerPlayable::INTERNAL_CALL_CreateHandleInternal(UnityEngine.Playables.PlayableGraph&,System.Int32,System.Boolean,UnityEngine.Playables.PlayableHandle&) void Register_UnityEngine_Animations_AnimationMixerPlayable_INTERNAL_CALL_CreateHandleInternal(); Register_UnityEngine_Animations_AnimationMixerPlayable_INTERNAL_CALL_CreateHandleInternal(); //End Registrations for type : UnityEngine.Animations.AnimationMixerPlayable //Start Registrations for type : UnityEngine.Animations.AnimationOffsetPlayable //System.Boolean UnityEngine.Animations.AnimationOffsetPlayable::INTERNAL_CALL_CreateHandleInternal(UnityEngine.Playables.PlayableGraph&,UnityEngine.Vector3&,UnityEngine.Quaternion&,UnityEngine.Playables.PlayableHandle&) void Register_UnityEngine_Animations_AnimationOffsetPlayable_INTERNAL_CALL_CreateHandleInternal(); Register_UnityEngine_Animations_AnimationOffsetPlayable_INTERNAL_CALL_CreateHandleInternal(); //System.Void UnityEngine.Animations.AnimationOffsetPlayable::INTERNAL_CALL_GetPositionInternal(UnityEngine.Playables.PlayableHandle&,UnityEngine.Vector3&) void Register_UnityEngine_Animations_AnimationOffsetPlayable_INTERNAL_CALL_GetPositionInternal(); Register_UnityEngine_Animations_AnimationOffsetPlayable_INTERNAL_CALL_GetPositionInternal(); //System.Void UnityEngine.Animations.AnimationOffsetPlayable::INTERNAL_CALL_GetRotationInternal(UnityEngine.Playables.PlayableHandle&,UnityEngine.Quaternion&) void Register_UnityEngine_Animations_AnimationOffsetPlayable_INTERNAL_CALL_GetRotationInternal(); Register_UnityEngine_Animations_AnimationOffsetPlayable_INTERNAL_CALL_GetRotationInternal(); //End Registrations for type : UnityEngine.Animations.AnimationOffsetPlayable //Start Registrations for type : UnityEngine.Animations.AnimationPlayableExtensions //System.Void UnityEngine.Animations.AnimationPlayableExtensions::INTERNAL_CALL_SetAnimatedPropertiesInternal(UnityEngine.Playables.PlayableHandle&,UnityEngine.AnimationClip) void Register_UnityEngine_Animations_AnimationPlayableExtensions_INTERNAL_CALL_SetAnimatedPropertiesInternal(); Register_UnityEngine_Animations_AnimationPlayableExtensions_INTERNAL_CALL_SetAnimatedPropertiesInternal(); //End Registrations for type : UnityEngine.Animations.AnimationPlayableExtensions //Start Registrations for type : UnityEngine.Animations.AnimationPlayableGraphExtensions //System.Boolean UnityEngine.Animations.AnimationPlayableGraphExtensions::INTERNAL_CALL_InternalCreateAnimationMotionXToDeltaPlayable(UnityEngine.Playables.PlayableGraph&,UnityEngine.Playables.PlayableHandle&) void Register_UnityEngine_Animations_AnimationPlayableGraphExtensions_INTERNAL_CALL_InternalCreateAnimationMotionXToDeltaPlayable(); Register_UnityEngine_Animations_AnimationPlayableGraphExtensions_INTERNAL_CALL_InternalCreateAnimationMotionXToDeltaPlayable(); //System.Boolean UnityEngine.Animations.AnimationPlayableGraphExtensions::INTERNAL_CALL_InternalCreateAnimationOutput(UnityEngine.Playables.PlayableGraph&,System.String,UnityEngine.Playables.PlayableOutputHandle&) void Register_UnityEngine_Animations_AnimationPlayableGraphExtensions_INTERNAL_CALL_InternalCreateAnimationOutput(); Register_UnityEngine_Animations_AnimationPlayableGraphExtensions_INTERNAL_CALL_InternalCreateAnimationOutput(); //End Registrations for type : UnityEngine.Animations.AnimationPlayableGraphExtensions //Start Registrations for type : UnityEngine.Animations.AnimationPlayableOutput //System.Void UnityEngine.Animations.AnimationPlayableOutput::INTERNAL_CALL_InternalSetTarget(UnityEngine.Playables.PlayableOutputHandle&,UnityEngine.Animator) void Register_UnityEngine_Animations_AnimationPlayableOutput_INTERNAL_CALL_InternalSetTarget(); Register_UnityEngine_Animations_AnimationPlayableOutput_INTERNAL_CALL_InternalSetTarget(); //UnityEngine.Animator UnityEngine.Animations.AnimationPlayableOutput::INTERNAL_CALL_InternalGetTarget(UnityEngine.Playables.PlayableOutputHandle&) void Register_UnityEngine_Animations_AnimationPlayableOutput_INTERNAL_CALL_InternalGetTarget(); Register_UnityEngine_Animations_AnimationPlayableOutput_INTERNAL_CALL_InternalGetTarget(); //End Registrations for type : UnityEngine.Animations.AnimationPlayableOutput //Start Registrations for type : UnityEngine.Animator //System.Boolean UnityEngine.Animator::IsInTransition(System.Int32) void Register_UnityEngine_Animator_IsInTransition(); Register_UnityEngine_Animator_IsInTransition(); //System.Boolean UnityEngine.Animator::get_hasBoundPlayables() void Register_UnityEngine_Animator_get_hasBoundPlayables(); Register_UnityEngine_Animator_get_hasBoundPlayables(); //System.Int32 UnityEngine.Animator::GetCurrentAnimatorClipInfoCount(System.Int32) void Register_UnityEngine_Animator_GetCurrentAnimatorClipInfoCount(); Register_UnityEngine_Animator_GetCurrentAnimatorClipInfoCount(); //System.Int32 UnityEngine.Animator::GetNextAnimatorClipInfoCount(System.Int32) void Register_UnityEngine_Animator_GetNextAnimatorClipInfoCount(); Register_UnityEngine_Animator_GetNextAnimatorClipInfoCount(); //System.Int32 UnityEngine.Animator::StringToHash(System.String) void Register_UnityEngine_Animator_StringToHash(); Register_UnityEngine_Animator_StringToHash(); //System.Int32 UnityEngine.Animator::get_layerCount() void Register_UnityEngine_Animator_get_layerCount(); Register_UnityEngine_Animator_get_layerCount(); //System.Void UnityEngine.Animator::GetAnimatorClipInfoInternal(System.Int32,System.Boolean,System.Object) void Register_UnityEngine_Animator_GetAnimatorClipInfoInternal(); Register_UnityEngine_Animator_GetAnimatorClipInfoInternal(); //System.Void UnityEngine.Animator::ResetTriggerString(System.String) void Register_UnityEngine_Animator_ResetTriggerString(); Register_UnityEngine_Animator_ResetTriggerString(); //System.Void UnityEngine.Animator::SetBoolString(System.String,System.Boolean) void Register_UnityEngine_Animator_SetBoolString(); Register_UnityEngine_Animator_SetBoolString(); //System.Void UnityEngine.Animator::SetTriggerString(System.String) void Register_UnityEngine_Animator_SetTriggerString(); Register_UnityEngine_Animator_SetTriggerString(); //UnityEngine.AnimatorStateInfo UnityEngine.Animator::GetCurrentAnimatorStateInfo(System.Int32) void Register_UnityEngine_Animator_GetCurrentAnimatorStateInfo(); Register_UnityEngine_Animator_GetCurrentAnimatorStateInfo(); //UnityEngine.AnimatorStateInfo UnityEngine.Animator::GetNextAnimatorStateInfo(System.Int32) void Register_UnityEngine_Animator_GetNextAnimatorStateInfo(); Register_UnityEngine_Animator_GetNextAnimatorStateInfo(); //UnityEngine.RuntimeAnimatorController UnityEngine.Animator::get_runtimeAnimatorController() void Register_UnityEngine_Animator_get_runtimeAnimatorController(); Register_UnityEngine_Animator_get_runtimeAnimatorController(); //End Registrations for type : UnityEngine.Animator //Start Registrations for type : UnityEngine.AnimatorClipInfo //UnityEngine.AnimationClip UnityEngine.AnimatorClipInfo::ClipInstanceToScriptingObject(System.Int32) void Register_UnityEngine_AnimatorClipInfo_ClipInstanceToScriptingObject(); Register_UnityEngine_AnimatorClipInfo_ClipInstanceToScriptingObject(); //End Registrations for type : UnityEngine.AnimatorClipInfo //Start Registrations for type : UnityEngine.Application //System.Boolean UnityEngine.Application::get_isEditor() void Register_UnityEngine_Application_get_isEditor(); Register_UnityEngine_Application_get_isEditor(); //System.Boolean UnityEngine.Application::get_isPlaying() void Register_UnityEngine_Application_get_isPlaying(); Register_UnityEngine_Application_get_isPlaying(); //UnityEngine.RuntimePlatform UnityEngine.Application::get_platform() void Register_UnityEngine_Application_get_platform(); Register_UnityEngine_Application_get_platform(); //End Registrations for type : UnityEngine.Application //Start Registrations for type : UnityEngine.AsyncOperation //System.Void UnityEngine.AsyncOperation::InternalDestroy() void Register_UnityEngine_AsyncOperation_InternalDestroy(); Register_UnityEngine_AsyncOperation_InternalDestroy(); //End Registrations for type : UnityEngine.AsyncOperation //Start Registrations for type : UnityEngine.Audio.AudioClipPlayable //System.Boolean UnityEngine.Audio.AudioClipPlayable::INTERNAL_CALL_GetIsPlayingInternal(UnityEngine.Playables.PlayableHandle&) void Register_UnityEngine_Audio_AudioClipPlayable_INTERNAL_CALL_GetIsPlayingInternal(); Register_UnityEngine_Audio_AudioClipPlayable_INTERNAL_CALL_GetIsPlayingInternal(); //System.Boolean UnityEngine.Audio.AudioClipPlayable::INTERNAL_CALL_GetLoopedInternal(UnityEngine.Playables.PlayableHandle&) void Register_UnityEngine_Audio_AudioClipPlayable_INTERNAL_CALL_GetLoopedInternal(); Register_UnityEngine_Audio_AudioClipPlayable_INTERNAL_CALL_GetLoopedInternal(); //System.Boolean UnityEngine.Audio.AudioClipPlayable::INTERNAL_CALL_InternalCreateAudioClipPlayable(UnityEngine.Playables.PlayableGraph&,UnityEngine.AudioClip,System.Boolean,UnityEngine.Playables.PlayableHandle&) void Register_UnityEngine_Audio_AudioClipPlayable_INTERNAL_CALL_InternalCreateAudioClipPlayable(); Register_UnityEngine_Audio_AudioClipPlayable_INTERNAL_CALL_InternalCreateAudioClipPlayable(); //System.Double UnityEngine.Audio.AudioClipPlayable::INTERNAL_CALL_GetPauseDelayInternal(UnityEngine.Playables.PlayableHandle&) void Register_UnityEngine_Audio_AudioClipPlayable_INTERNAL_CALL_GetPauseDelayInternal(); Register_UnityEngine_Audio_AudioClipPlayable_INTERNAL_CALL_GetPauseDelayInternal(); //System.Double UnityEngine.Audio.AudioClipPlayable::INTERNAL_CALL_GetStartDelayInternal(UnityEngine.Playables.PlayableHandle&) void Register_UnityEngine_Audio_AudioClipPlayable_INTERNAL_CALL_GetStartDelayInternal(); Register_UnityEngine_Audio_AudioClipPlayable_INTERNAL_CALL_GetStartDelayInternal(); //System.Void UnityEngine.Audio.AudioClipPlayable::INTERNAL_CALL_SetPauseDelayInternal(UnityEngine.Playables.PlayableHandle&,System.Double) void Register_UnityEngine_Audio_AudioClipPlayable_INTERNAL_CALL_SetPauseDelayInternal(); Register_UnityEngine_Audio_AudioClipPlayable_INTERNAL_CALL_SetPauseDelayInternal(); //System.Void UnityEngine.Audio.AudioClipPlayable::INTERNAL_CALL_SetStartDelayInternal(UnityEngine.Playables.PlayableHandle&,System.Double) void Register_UnityEngine_Audio_AudioClipPlayable_INTERNAL_CALL_SetStartDelayInternal(); Register_UnityEngine_Audio_AudioClipPlayable_INTERNAL_CALL_SetStartDelayInternal(); //UnityEngine.AudioClip UnityEngine.Audio.AudioClipPlayable::INTERNAL_CALL_GetClipInternal(UnityEngine.Playables.PlayableHandle&) void Register_UnityEngine_Audio_AudioClipPlayable_INTERNAL_CALL_GetClipInternal(); Register_UnityEngine_Audio_AudioClipPlayable_INTERNAL_CALL_GetClipInternal(); //End Registrations for type : UnityEngine.Audio.AudioClipPlayable //Start Registrations for type : UnityEngine.Audio.AudioMixerPlayable //System.Boolean UnityEngine.Audio.AudioMixerPlayable::INTERNAL_CALL_CreateAudioMixerPlayableInternal(UnityEngine.Playables.PlayableGraph&,System.Int32,System.Boolean,UnityEngine.Playables.PlayableHandle&) void Register_UnityEngine_Audio_AudioMixerPlayable_INTERNAL_CALL_CreateAudioMixerPlayableInternal(); Register_UnityEngine_Audio_AudioMixerPlayable_INTERNAL_CALL_CreateAudioMixerPlayableInternal(); //System.Boolean UnityEngine.Audio.AudioMixerPlayable::INTERNAL_CALL_GetAutoNormalizeInternal(UnityEngine.Playables.PlayableHandle&) void Register_UnityEngine_Audio_AudioMixerPlayable_INTERNAL_CALL_GetAutoNormalizeInternal(); Register_UnityEngine_Audio_AudioMixerPlayable_INTERNAL_CALL_GetAutoNormalizeInternal(); //End Registrations for type : UnityEngine.Audio.AudioMixerPlayable //Start Registrations for type : UnityEngine.Audio.AudioPlayableOutput //System.Void UnityEngine.Audio.AudioPlayableOutput::INTERNAL_CALL_InternalSetTarget(UnityEngine.Playables.PlayableOutputHandle&,UnityEngine.AudioSource) void Register_UnityEngine_Audio_AudioPlayableOutput_INTERNAL_CALL_InternalSetTarget(); Register_UnityEngine_Audio_AudioPlayableOutput_INTERNAL_CALL_InternalSetTarget(); //UnityEngine.AudioSource UnityEngine.Audio.AudioPlayableOutput::INTERNAL_CALL_InternalGetTarget(UnityEngine.Playables.PlayableOutputHandle&) void Register_UnityEngine_Audio_AudioPlayableOutput_INTERNAL_CALL_InternalGetTarget(); Register_UnityEngine_Audio_AudioPlayableOutput_INTERNAL_CALL_InternalGetTarget(); //End Registrations for type : UnityEngine.Audio.AudioPlayableOutput //Start Registrations for type : UnityEngine.AudioClip //System.Boolean UnityEngine.AudioClip::get_ambisonic() void Register_UnityEngine_AudioClip_get_ambisonic(); Register_UnityEngine_AudioClip_get_ambisonic(); //System.Int32 UnityEngine.AudioClip::get_frequency() void Register_UnityEngine_AudioClip_get_frequency(); Register_UnityEngine_AudioClip_get_frequency(); //System.Int32 UnityEngine.AudioClip::get_samples() void Register_UnityEngine_AudioClip_get_samples(); Register_UnityEngine_AudioClip_get_samples(); //System.Single UnityEngine.AudioClip::get_length() void Register_UnityEngine_AudioClip_get_length(); Register_UnityEngine_AudioClip_get_length(); //End Registrations for type : UnityEngine.AudioClip //Start Registrations for type : UnityEngine.AudioExtensionManager //UnityEngine.Object UnityEngine.AudioExtensionManager::GetAudioListener() void Register_UnityEngine_AudioExtensionManager_GetAudioListener(); Register_UnityEngine_AudioExtensionManager_GetAudioListener(); //End Registrations for type : UnityEngine.AudioExtensionManager //Start Registrations for type : UnityEngine.AudioListener //System.Int32 UnityEngine.AudioListener::GetNumExtensionProperties() void Register_UnityEngine_AudioListener_GetNumExtensionProperties(); Register_UnityEngine_AudioListener_GetNumExtensionProperties(); //System.Single UnityEngine.AudioListener::ReadExtensionPropertyValue(System.Int32) void Register_UnityEngine_AudioListener_ReadExtensionPropertyValue(); Register_UnityEngine_AudioListener_ReadExtensionPropertyValue(); //System.Void UnityEngine.AudioListener::INTERNAL_CALL_ClearExtensionProperties(UnityEngine.AudioListener,UnityEngine.PropertyName&) void Register_UnityEngine_AudioListener_INTERNAL_CALL_ClearExtensionProperties(); Register_UnityEngine_AudioListener_INTERNAL_CALL_ClearExtensionProperties(); //System.Void UnityEngine.AudioListener::INTERNAL_CALL_ReadExtensionName(UnityEngine.AudioListener,System.Int32,UnityEngine.PropertyName&) void Register_UnityEngine_AudioListener_INTERNAL_CALL_ReadExtensionName(); Register_UnityEngine_AudioListener_INTERNAL_CALL_ReadExtensionName(); //System.Void UnityEngine.AudioListener::INTERNAL_CALL_ReadExtensionPropertyName(UnityEngine.AudioListener,System.Int32,UnityEngine.PropertyName&) void Register_UnityEngine_AudioListener_INTERNAL_CALL_ReadExtensionPropertyName(); Register_UnityEngine_AudioListener_INTERNAL_CALL_ReadExtensionPropertyName(); //End Registrations for type : UnityEngine.AudioListener //Start Registrations for type : UnityEngine.AudioSettings //System.String UnityEngine.AudioSettings::GetAmbisonicDecoderPluginName() void Register_UnityEngine_AudioSettings_GetAmbisonicDecoderPluginName(); Register_UnityEngine_AudioSettings_GetAmbisonicDecoderPluginName(); //System.String UnityEngine.AudioSettings::GetSpatializerPluginName() void Register_UnityEngine_AudioSettings_GetSpatializerPluginName(); Register_UnityEngine_AudioSettings_GetSpatializerPluginName(); //End Registrations for type : UnityEngine.AudioSettings //Start Registrations for type : UnityEngine.AudioSource //System.Boolean UnityEngine.AudioSource::get_isPlaying() void Register_UnityEngine_AudioSource_get_isPlaying(); Register_UnityEngine_AudioSource_get_isPlaying(); //System.Boolean UnityEngine.AudioSource::get_spatializeInternal() void Register_UnityEngine_AudioSource_get_spatializeInternal(); Register_UnityEngine_AudioSource_get_spatializeInternal(); //System.Int32 UnityEngine.AudioSource::GetNumExtensionProperties() void Register_UnityEngine_AudioSource_GetNumExtensionProperties(); Register_UnityEngine_AudioSource_GetNumExtensionProperties(); //System.Single UnityEngine.AudioSource::ReadExtensionPropertyValue(System.Int32) void Register_UnityEngine_AudioSource_ReadExtensionPropertyValue(); Register_UnityEngine_AudioSource_ReadExtensionPropertyValue(); //System.Void UnityEngine.AudioSource::INTERNAL_CALL_ClearExtensionProperties(UnityEngine.AudioSource,UnityEngine.PropertyName&) void Register_UnityEngine_AudioSource_INTERNAL_CALL_ClearExtensionProperties(); Register_UnityEngine_AudioSource_INTERNAL_CALL_ClearExtensionProperties(); //System.Void UnityEngine.AudioSource::INTERNAL_CALL_ReadExtensionName(UnityEngine.AudioSource,System.Int32,UnityEngine.PropertyName&) void Register_UnityEngine_AudioSource_INTERNAL_CALL_ReadExtensionName(); Register_UnityEngine_AudioSource_INTERNAL_CALL_ReadExtensionName(); //System.Void UnityEngine.AudioSource::INTERNAL_CALL_ReadExtensionPropertyName(UnityEngine.AudioSource,System.Int32,UnityEngine.PropertyName&) void Register_UnityEngine_AudioSource_INTERNAL_CALL_ReadExtensionPropertyName(); Register_UnityEngine_AudioSource_INTERNAL_CALL_ReadExtensionPropertyName(); //System.Void UnityEngine.AudioSource::Play(System.UInt64) void Register_UnityEngine_AudioSource_Play(); Register_UnityEngine_AudioSource_Play(); //System.Void UnityEngine.AudioSource::PlayOneShotHelper(UnityEngine.AudioClip,System.Single) void Register_UnityEngine_AudioSource_PlayOneShotHelper(); Register_UnityEngine_AudioSource_PlayOneShotHelper(); //UnityEngine.AudioClip UnityEngine.AudioSource::get_clip() void Register_UnityEngine_AudioSource_get_clip(); Register_UnityEngine_AudioSource_get_clip(); //End Registrations for type : UnityEngine.AudioSource //Start Registrations for type : UnityEngine.Behaviour //System.Boolean UnityEngine.Behaviour::get_enabled() void Register_UnityEngine_Behaviour_get_enabled(); Register_UnityEngine_Behaviour_get_enabled(); //System.Boolean UnityEngine.Behaviour::get_isActiveAndEnabled() void Register_UnityEngine_Behaviour_get_isActiveAndEnabled(); Register_UnityEngine_Behaviour_get_isActiveAndEnabled(); //System.Void UnityEngine.Behaviour::set_enabled(System.Boolean) void Register_UnityEngine_Behaviour_set_enabled(); Register_UnityEngine_Behaviour_set_enabled(); //End Registrations for type : UnityEngine.Behaviour //Start Registrations for type : UnityEngine.Camera //System.Boolean UnityEngine.Camera::get_orthographic() void Register_UnityEngine_Camera_get_orthographic(); Register_UnityEngine_Camera_get_orthographic(); //System.Int32 UnityEngine.Camera::GetAllCameras(UnityEngine.Camera[]) void Register_UnityEngine_Camera_GetAllCameras(); Register_UnityEngine_Camera_GetAllCameras(); //System.Int32 UnityEngine.Camera::get_allCamerasCount() void Register_UnityEngine_Camera_get_allCamerasCount(); Register_UnityEngine_Camera_get_allCamerasCount(); //System.Int32 UnityEngine.Camera::get_cullingMask() void Register_UnityEngine_Camera_get_cullingMask(); Register_UnityEngine_Camera_get_cullingMask(); //System.Int32 UnityEngine.Camera::get_eventMask() void Register_UnityEngine_Camera_get_eventMask(); Register_UnityEngine_Camera_get_eventMask(); //System.Int32 UnityEngine.Camera::get_targetDisplay() void Register_UnityEngine_Camera_get_targetDisplay(); Register_UnityEngine_Camera_get_targetDisplay(); //System.Single UnityEngine.Camera::get_aspect() void Register_UnityEngine_Camera_get_aspect(); Register_UnityEngine_Camera_get_aspect(); //System.Single UnityEngine.Camera::get_depth() void Register_UnityEngine_Camera_get_depth(); Register_UnityEngine_Camera_get_depth(); //System.Single UnityEngine.Camera::get_farClipPlane() void Register_UnityEngine_Camera_get_farClipPlane(); Register_UnityEngine_Camera_get_farClipPlane(); //System.Single UnityEngine.Camera::get_fieldOfView() void Register_UnityEngine_Camera_get_fieldOfView(); Register_UnityEngine_Camera_get_fieldOfView(); //System.Single UnityEngine.Camera::get_nearClipPlane() void Register_UnityEngine_Camera_get_nearClipPlane(); Register_UnityEngine_Camera_get_nearClipPlane(); //System.Single UnityEngine.Camera::get_orthographicSize() void Register_UnityEngine_Camera_get_orthographicSize(); Register_UnityEngine_Camera_get_orthographicSize(); //System.Void UnityEngine.Camera::INTERNAL_CALL_ScreenPointToRay(UnityEngine.Camera,UnityEngine.Vector3&,UnityEngine.Ray&) void Register_UnityEngine_Camera_INTERNAL_CALL_ScreenPointToRay(); Register_UnityEngine_Camera_INTERNAL_CALL_ScreenPointToRay(); //System.Void UnityEngine.Camera::INTERNAL_CALL_ScreenToViewportPoint(UnityEngine.Camera,UnityEngine.Vector3&,UnityEngine.Vector3&) void Register_UnityEngine_Camera_INTERNAL_CALL_ScreenToViewportPoint(); Register_UnityEngine_Camera_INTERNAL_CALL_ScreenToViewportPoint(); //System.Void UnityEngine.Camera::INTERNAL_get_pixelRect(UnityEngine.Rect&) void Register_UnityEngine_Camera_INTERNAL_get_pixelRect(); Register_UnityEngine_Camera_INTERNAL_get_pixelRect(); //System.Void UnityEngine.Camera::set_farClipPlane(System.Single) void Register_UnityEngine_Camera_set_farClipPlane(); Register_UnityEngine_Camera_set_farClipPlane(); //System.Void UnityEngine.Camera::set_fieldOfView(System.Single) void Register_UnityEngine_Camera_set_fieldOfView(); Register_UnityEngine_Camera_set_fieldOfView(); //System.Void UnityEngine.Camera::set_nearClipPlane(System.Single) void Register_UnityEngine_Camera_set_nearClipPlane(); Register_UnityEngine_Camera_set_nearClipPlane(); //System.Void UnityEngine.Camera::set_orthographicSize(System.Single) void Register_UnityEngine_Camera_set_orthographicSize(); Register_UnityEngine_Camera_set_orthographicSize(); //UnityEngine.Camera UnityEngine.Camera::get_main() void Register_UnityEngine_Camera_get_main(); Register_UnityEngine_Camera_get_main(); //UnityEngine.CameraClearFlags UnityEngine.Camera::get_clearFlags() void Register_UnityEngine_Camera_get_clearFlags(); Register_UnityEngine_Camera_get_clearFlags(); //UnityEngine.GameObject UnityEngine.Camera::INTERNAL_CALL_RaycastTry(UnityEngine.Camera,UnityEngine.Ray&,System.Single,System.Int32) void Register_UnityEngine_Camera_INTERNAL_CALL_RaycastTry(); Register_UnityEngine_Camera_INTERNAL_CALL_RaycastTry(); //UnityEngine.GameObject UnityEngine.Camera::INTERNAL_CALL_RaycastTry2D(UnityEngine.Camera,UnityEngine.Ray&,System.Single,System.Int32) void Register_UnityEngine_Camera_INTERNAL_CALL_RaycastTry2D(); Register_UnityEngine_Camera_INTERNAL_CALL_RaycastTry2D(); //UnityEngine.RenderTexture UnityEngine.Camera::get_targetTexture() void Register_UnityEngine_Camera_get_targetTexture(); Register_UnityEngine_Camera_get_targetTexture(); //End Registrations for type : UnityEngine.Camera //Start Registrations for type : UnityEngine.Canvas //System.Boolean UnityEngine.Canvas::get_isRootCanvas() void Register_UnityEngine_Canvas_get_isRootCanvas(); Register_UnityEngine_Canvas_get_isRootCanvas(); //System.Boolean UnityEngine.Canvas::get_overrideSorting() void Register_UnityEngine_Canvas_get_overrideSorting(); Register_UnityEngine_Canvas_get_overrideSorting(); //System.Boolean UnityEngine.Canvas::get_pixelPerfect() void Register_UnityEngine_Canvas_get_pixelPerfect(); Register_UnityEngine_Canvas_get_pixelPerfect(); //System.Int32 UnityEngine.Canvas::get_renderOrder() void Register_UnityEngine_Canvas_get_renderOrder(); Register_UnityEngine_Canvas_get_renderOrder(); //System.Int32 UnityEngine.Canvas::get_sortingLayerID() void Register_UnityEngine_Canvas_get_sortingLayerID(); Register_UnityEngine_Canvas_get_sortingLayerID(); //System.Int32 UnityEngine.Canvas::get_sortingOrder() void Register_UnityEngine_Canvas_get_sortingOrder(); Register_UnityEngine_Canvas_get_sortingOrder(); //System.Int32 UnityEngine.Canvas::get_targetDisplay() void Register_UnityEngine_Canvas_get_targetDisplay(); Register_UnityEngine_Canvas_get_targetDisplay(); //System.Single UnityEngine.Canvas::get_referencePixelsPerUnit() void Register_UnityEngine_Canvas_get_referencePixelsPerUnit(); Register_UnityEngine_Canvas_get_referencePixelsPerUnit(); //System.Single UnityEngine.Canvas::get_scaleFactor() void Register_UnityEngine_Canvas_get_scaleFactor(); Register_UnityEngine_Canvas_get_scaleFactor(); //System.Void UnityEngine.Canvas::set_overrideSorting(System.Boolean) void Register_UnityEngine_Canvas_set_overrideSorting(); Register_UnityEngine_Canvas_set_overrideSorting(); //System.Void UnityEngine.Canvas::set_referencePixelsPerUnit(System.Single) void Register_UnityEngine_Canvas_set_referencePixelsPerUnit(); Register_UnityEngine_Canvas_set_referencePixelsPerUnit(); //System.Void UnityEngine.Canvas::set_scaleFactor(System.Single) void Register_UnityEngine_Canvas_set_scaleFactor(); Register_UnityEngine_Canvas_set_scaleFactor(); //System.Void UnityEngine.Canvas::set_sortingLayerID(System.Int32) void Register_UnityEngine_Canvas_set_sortingLayerID(); Register_UnityEngine_Canvas_set_sortingLayerID(); //System.Void UnityEngine.Canvas::set_sortingOrder(System.Int32) void Register_UnityEngine_Canvas_set_sortingOrder(); Register_UnityEngine_Canvas_set_sortingOrder(); //UnityEngine.Camera UnityEngine.Canvas::get_worldCamera() void Register_UnityEngine_Canvas_get_worldCamera(); Register_UnityEngine_Canvas_get_worldCamera(); //UnityEngine.Canvas UnityEngine.Canvas::get_rootCanvas() void Register_UnityEngine_Canvas_get_rootCanvas(); Register_UnityEngine_Canvas_get_rootCanvas(); //UnityEngine.Material UnityEngine.Canvas::GetDefaultCanvasMaterial() void Register_UnityEngine_Canvas_GetDefaultCanvasMaterial(); Register_UnityEngine_Canvas_GetDefaultCanvasMaterial(); //UnityEngine.Material UnityEngine.Canvas::GetETC1SupportedCanvasMaterial() void Register_UnityEngine_Canvas_GetETC1SupportedCanvasMaterial(); Register_UnityEngine_Canvas_GetETC1SupportedCanvasMaterial(); //UnityEngine.RenderMode UnityEngine.Canvas::get_renderMode() void Register_UnityEngine_Canvas_get_renderMode(); Register_UnityEngine_Canvas_get_renderMode(); //End Registrations for type : UnityEngine.Canvas //Start Registrations for type : UnityEngine.CanvasGroup //System.Boolean UnityEngine.CanvasGroup::get_blocksRaycasts() void Register_UnityEngine_CanvasGroup_get_blocksRaycasts(); Register_UnityEngine_CanvasGroup_get_blocksRaycasts(); //System.Boolean UnityEngine.CanvasGroup::get_ignoreParentGroups() void Register_UnityEngine_CanvasGroup_get_ignoreParentGroups(); Register_UnityEngine_CanvasGroup_get_ignoreParentGroups(); //System.Boolean UnityEngine.CanvasGroup::get_interactable() void Register_UnityEngine_CanvasGroup_get_interactable(); Register_UnityEngine_CanvasGroup_get_interactable(); //System.Single UnityEngine.CanvasGroup::get_alpha() void Register_UnityEngine_CanvasGroup_get_alpha(); Register_UnityEngine_CanvasGroup_get_alpha(); //System.Void UnityEngine.CanvasGroup::set_alpha(System.Single) void Register_UnityEngine_CanvasGroup_set_alpha(); Register_UnityEngine_CanvasGroup_set_alpha(); //End Registrations for type : UnityEngine.CanvasGroup //Start Registrations for type : UnityEngine.CanvasRenderer //System.Boolean UnityEngine.CanvasRenderer::get_cull() void Register_UnityEngine_CanvasRenderer_get_cull(); Register_UnityEngine_CanvasRenderer_get_cull(); //System.Boolean UnityEngine.CanvasRenderer::get_hasMoved() void Register_UnityEngine_CanvasRenderer_get_hasMoved(); Register_UnityEngine_CanvasRenderer_get_hasMoved(); //System.Int32 UnityEngine.CanvasRenderer::get_absoluteDepth() void Register_UnityEngine_CanvasRenderer_get_absoluteDepth(); Register_UnityEngine_CanvasRenderer_get_absoluteDepth(); //System.Int32 UnityEngine.CanvasRenderer::get_materialCount() void Register_UnityEngine_CanvasRenderer_get_materialCount(); Register_UnityEngine_CanvasRenderer_get_materialCount(); //System.Void UnityEngine.CanvasRenderer::Clear() void Register_UnityEngine_CanvasRenderer_Clear(); Register_UnityEngine_CanvasRenderer_Clear(); //System.Void UnityEngine.CanvasRenderer::CreateUIVertexStreamInternal(System.Object,System.Object,System.Object,System.Object,System.Object,System.Object,System.Object,System.Object,System.Object,System.Object) void Register_UnityEngine_CanvasRenderer_CreateUIVertexStreamInternal(); Register_UnityEngine_CanvasRenderer_CreateUIVertexStreamInternal(); //System.Void UnityEngine.CanvasRenderer::DisableRectClipping() void Register_UnityEngine_CanvasRenderer_DisableRectClipping(); Register_UnityEngine_CanvasRenderer_DisableRectClipping(); //System.Void UnityEngine.CanvasRenderer::INTERNAL_CALL_EnableRectClipping(UnityEngine.CanvasRenderer,UnityEngine.Rect&) void Register_UnityEngine_CanvasRenderer_INTERNAL_CALL_EnableRectClipping(); Register_UnityEngine_CanvasRenderer_INTERNAL_CALL_EnableRectClipping(); //System.Void UnityEngine.CanvasRenderer::INTERNAL_CALL_GetColor(UnityEngine.CanvasRenderer,UnityEngine.Color&) void Register_UnityEngine_CanvasRenderer_INTERNAL_CALL_GetColor(); Register_UnityEngine_CanvasRenderer_INTERNAL_CALL_GetColor(); //System.Void UnityEngine.CanvasRenderer::INTERNAL_CALL_SetColor(UnityEngine.CanvasRenderer,UnityEngine.Color&) void Register_UnityEngine_CanvasRenderer_INTERNAL_CALL_SetColor(); Register_UnityEngine_CanvasRenderer_INTERNAL_CALL_SetColor(); //System.Void UnityEngine.CanvasRenderer::SetAlphaTexture(UnityEngine.Texture) void Register_UnityEngine_CanvasRenderer_SetAlphaTexture(); Register_UnityEngine_CanvasRenderer_SetAlphaTexture(); //System.Void UnityEngine.CanvasRenderer::SetMaterial(UnityEngine.Material,System.Int32) void Register_UnityEngine_CanvasRenderer_SetMaterial(); Register_UnityEngine_CanvasRenderer_SetMaterial(); //System.Void UnityEngine.CanvasRenderer::SetMesh(UnityEngine.Mesh) void Register_UnityEngine_CanvasRenderer_SetMesh(); Register_UnityEngine_CanvasRenderer_SetMesh(); //System.Void UnityEngine.CanvasRenderer::SetPopMaterial(UnityEngine.Material,System.Int32) void Register_UnityEngine_CanvasRenderer_SetPopMaterial(); Register_UnityEngine_CanvasRenderer_SetPopMaterial(); //System.Void UnityEngine.CanvasRenderer::SetTexture(UnityEngine.Texture) void Register_UnityEngine_CanvasRenderer_SetTexture(); Register_UnityEngine_CanvasRenderer_SetTexture(); //System.Void UnityEngine.CanvasRenderer::SplitIndicesStreamsInternal(System.Object,System.Object) void Register_UnityEngine_CanvasRenderer_SplitIndicesStreamsInternal(); Register_UnityEngine_CanvasRenderer_SplitIndicesStreamsInternal(); //System.Void UnityEngine.CanvasRenderer::SplitUIVertexStreamsInternal(System.Object,System.Object,System.Object,System.Object,System.Object,System.Object,System.Object,System.Object,System.Object) void Register_UnityEngine_CanvasRenderer_SplitUIVertexStreamsInternal(); Register_UnityEngine_CanvasRenderer_SplitUIVertexStreamsInternal(); //System.Void UnityEngine.CanvasRenderer::set_cull(System.Boolean) void Register_UnityEngine_CanvasRenderer_set_cull(); Register_UnityEngine_CanvasRenderer_set_cull(); //System.Void UnityEngine.CanvasRenderer::set_hasPopInstruction(System.Boolean) void Register_UnityEngine_CanvasRenderer_set_hasPopInstruction(); Register_UnityEngine_CanvasRenderer_set_hasPopInstruction(); //System.Void UnityEngine.CanvasRenderer::set_materialCount(System.Int32) void Register_UnityEngine_CanvasRenderer_set_materialCount(); Register_UnityEngine_CanvasRenderer_set_materialCount(); //System.Void UnityEngine.CanvasRenderer::set_popMaterialCount(System.Int32) void Register_UnityEngine_CanvasRenderer_set_popMaterialCount(); Register_UnityEngine_CanvasRenderer_set_popMaterialCount(); //End Registrations for type : UnityEngine.CanvasRenderer //Start Registrations for type : UnityEngine.Collider //System.Boolean UnityEngine.Collider::INTERNAL_CALL_Internal_Raycast(UnityEngine.Collider,UnityEngine.Ray&,UnityEngine.RaycastHit&,System.Single) void Register_UnityEngine_Collider_INTERNAL_CALL_Internal_Raycast(); Register_UnityEngine_Collider_INTERNAL_CALL_Internal_Raycast(); //System.Void UnityEngine.Collider::INTERNAL_CALL_ClosestPoint(UnityEngine.Collider,UnityEngine.Vector3&,UnityEngine.Vector3&) void Register_UnityEngine_Collider_INTERNAL_CALL_ClosestPoint(); Register_UnityEngine_Collider_INTERNAL_CALL_ClosestPoint(); //System.Void UnityEngine.Collider::INTERNAL_get_bounds(UnityEngine.Bounds&) void Register_UnityEngine_Collider_INTERNAL_get_bounds(); Register_UnityEngine_Collider_INTERNAL_get_bounds(); //End Registrations for type : UnityEngine.Collider //Start Registrations for type : UnityEngine.Collider2D //System.Boolean UnityEngine.Collider2D::INTERNAL_CALL_OverlapPoint(UnityEngine.Collider2D,UnityEngine.Vector2&) void Register_UnityEngine_Collider2D_INTERNAL_CALL_OverlapPoint(); Register_UnityEngine_Collider2D_INTERNAL_CALL_OverlapPoint(); //End Registrations for type : UnityEngine.Collider2D //Start Registrations for type : UnityEngine.Collision2D //UnityEngine.ContactPoint2D[] UnityEngine.Collision2D::CreateCollisionContacts(UnityEngine.Collider2D,UnityEngine.Collider2D,UnityEngine.Rigidbody2D,UnityEngine.Rigidbody2D,System.Boolean) void Register_UnityEngine_Collision2D_CreateCollisionContacts(); Register_UnityEngine_Collision2D_CreateCollisionContacts(); //End Registrations for type : UnityEngine.Collision2D //Start Registrations for type : UnityEngine.Component //System.Void UnityEngine.Component::GetComponentsForListInternal(System.Type,System.Object) void Register_UnityEngine_Component_GetComponentsForListInternal(); Register_UnityEngine_Component_GetComponentsForListInternal(); //UnityEngine.GameObject UnityEngine.Component::get_gameObject() void Register_UnityEngine_Component_get_gameObject(); Register_UnityEngine_Component_get_gameObject(); //UnityEngine.Transform UnityEngine.Component::get_transform() void Register_UnityEngine_Component_get_transform(); Register_UnityEngine_Component_get_transform(); //End Registrations for type : UnityEngine.Component //Start Registrations for type : UnityEngine.CompositeCollider2D //System.Int32 UnityEngine.CompositeCollider2D::Internal_GetPath(System.Int32,UnityEngine.Vector2[]) void Register_UnityEngine_CompositeCollider2D_Internal_GetPath(); Register_UnityEngine_CompositeCollider2D_Internal_GetPath(); //System.Int32 UnityEngine.CompositeCollider2D::get_pathCount() void Register_UnityEngine_CompositeCollider2D_get_pathCount(); Register_UnityEngine_CompositeCollider2D_get_pathCount(); //System.Int32 UnityEngine.CompositeCollider2D::get_pointCount() void Register_UnityEngine_CompositeCollider2D_get_pointCount(); Register_UnityEngine_CompositeCollider2D_get_pointCount(); //End Registrations for type : UnityEngine.CompositeCollider2D //Start Registrations for type : UnityEngine.Coroutine //System.Void UnityEngine.Coroutine::ReleaseCoroutine() void Register_UnityEngine_Coroutine_ReleaseCoroutine(); Register_UnityEngine_Coroutine_ReleaseCoroutine(); //End Registrations for type : UnityEngine.Coroutine //Start Registrations for type : UnityEngine.CullingGroup //System.Void UnityEngine.CullingGroup::Dispose() void Register_UnityEngine_CullingGroup_Dispose(); Register_UnityEngine_CullingGroup_Dispose(); //System.Void UnityEngine.CullingGroup::FinalizerFailure() void Register_UnityEngine_CullingGroup_FinalizerFailure(); Register_UnityEngine_CullingGroup_FinalizerFailure(); //End Registrations for type : UnityEngine.CullingGroup //Start Registrations for type : UnityEngine.Cursor //UnityEngine.CursorLockMode UnityEngine.Cursor::get_lockState() void Register_UnityEngine_Cursor_get_lockState(); Register_UnityEngine_Cursor_get_lockState(); //End Registrations for type : UnityEngine.Cursor //Start Registrations for type : UnityEngine.DebugLogHandler //System.Void UnityEngine.DebugLogHandler::Internal_Log(UnityEngine.LogType,System.String,UnityEngine.Object) void Register_UnityEngine_DebugLogHandler_Internal_Log(); Register_UnityEngine_DebugLogHandler_Internal_Log(); //System.Void UnityEngine.DebugLogHandler::Internal_LogException(System.Exception,UnityEngine.Object) void Register_UnityEngine_DebugLogHandler_Internal_LogException(); Register_UnityEngine_DebugLogHandler_Internal_LogException(); //End Registrations for type : UnityEngine.DebugLogHandler //Start Registrations for type : UnityEngine.Display //System.Int32 UnityEngine.Display::RelativeMouseAtImpl(System.Int32,System.Int32,System.Int32&,System.Int32&) void Register_UnityEngine_Display_RelativeMouseAtImpl(); Register_UnityEngine_Display_RelativeMouseAtImpl(); //System.Void UnityEngine.Display::GetRenderingExtImpl(System.IntPtr,System.Int32&,System.Int32&) void Register_UnityEngine_Display_GetRenderingExtImpl(); Register_UnityEngine_Display_GetRenderingExtImpl(); //System.Void UnityEngine.Display::GetSystemExtImpl(System.IntPtr,System.Int32&,System.Int32&) void Register_UnityEngine_Display_GetSystemExtImpl(); Register_UnityEngine_Display_GetSystemExtImpl(); //End Registrations for type : UnityEngine.Display //Start Registrations for type : UnityEngine.Event //System.Boolean UnityEngine.Event::PopEvent(UnityEngine.Event) void Register_UnityEngine_Event_PopEvent(); Register_UnityEngine_Event_PopEvent(); //System.Char UnityEngine.Event::get_character() void Register_UnityEngine_Event_get_character(); Register_UnityEngine_Event_get_character(); //System.String UnityEngine.Event::get_commandName() void Register_UnityEngine_Event_get_commandName(); Register_UnityEngine_Event_get_commandName(); //System.Void UnityEngine.Event::Cleanup() void Register_UnityEngine_Event_Cleanup(); Register_UnityEngine_Event_Cleanup(); //System.Void UnityEngine.Event::Init(System.Int32) void Register_UnityEngine_Event_Init(); Register_UnityEngine_Event_Init(); //System.Void UnityEngine.Event::Internal_GetMousePosition(UnityEngine.Vector2&) void Register_UnityEngine_Event_Internal_GetMousePosition(); Register_UnityEngine_Event_Internal_GetMousePosition(); //System.Void UnityEngine.Event::Internal_SetNativeEvent(System.IntPtr) void Register_UnityEngine_Event_Internal_SetNativeEvent(); Register_UnityEngine_Event_Internal_SetNativeEvent(); //System.Void UnityEngine.Event::set_displayIndex(System.Int32) void Register_UnityEngine_Event_set_displayIndex(); Register_UnityEngine_Event_set_displayIndex(); //UnityEngine.EventModifiers UnityEngine.Event::get_modifiers() void Register_UnityEngine_Event_get_modifiers(); Register_UnityEngine_Event_get_modifiers(); //UnityEngine.EventType UnityEngine.Event::get_rawType() void Register_UnityEngine_Event_get_rawType(); Register_UnityEngine_Event_get_rawType(); //UnityEngine.EventType UnityEngine.Event::get_type() void Register_UnityEngine_Event_get_type(); Register_UnityEngine_Event_get_type(); //UnityEngine.KeyCode UnityEngine.Event::get_keyCode() void Register_UnityEngine_Event_get_keyCode(); Register_UnityEngine_Event_get_keyCode(); //End Registrations for type : UnityEngine.Event //Start Registrations for type : UnityEngine.Font //System.Boolean UnityEngine.Font::HasCharacter(System.Char) void Register_UnityEngine_Font_HasCharacter(); Register_UnityEngine_Font_HasCharacter(); //System.Boolean UnityEngine.Font::get_dynamic() void Register_UnityEngine_Font_get_dynamic(); Register_UnityEngine_Font_get_dynamic(); //System.Int32 UnityEngine.Font::get_fontSize() void Register_UnityEngine_Font_get_fontSize(); Register_UnityEngine_Font_get_fontSize(); //UnityEngine.Material UnityEngine.Font::get_material() void Register_UnityEngine_Font_get_material(); Register_UnityEngine_Font_get_material(); //End Registrations for type : UnityEngine.Font //Start Registrations for type : UnityEngine.GameObject //System.Array UnityEngine.GameObject::GetComponentsInternal(System.Type,System.Boolean,System.Boolean,System.Boolean,System.Boolean,System.Object) void Register_UnityEngine_GameObject_GetComponentsInternal(); Register_UnityEngine_GameObject_GetComponentsInternal(); //System.Boolean UnityEngine.GameObject::CompareTag(System.String) void Register_UnityEngine_GameObject_CompareTag(); Register_UnityEngine_GameObject_CompareTag(); //System.Boolean UnityEngine.GameObject::get_activeInHierarchy() void Register_UnityEngine_GameObject_get_activeInHierarchy(); Register_UnityEngine_GameObject_get_activeInHierarchy(); //System.Boolean UnityEngine.GameObject::get_activeSelf() void Register_UnityEngine_GameObject_get_activeSelf(); Register_UnityEngine_GameObject_get_activeSelf(); //System.Int32 UnityEngine.GameObject::get_layer() void Register_UnityEngine_GameObject_get_layer(); Register_UnityEngine_GameObject_get_layer(); //System.String UnityEngine.GameObject::get_tag() void Register_UnityEngine_GameObject_get_tag(); Register_UnityEngine_GameObject_get_tag(); //System.Void UnityEngine.GameObject::Internal_CreateGameObject(UnityEngine.GameObject,System.String) void Register_UnityEngine_GameObject_Internal_CreateGameObject(); Register_UnityEngine_GameObject_Internal_CreateGameObject(); //System.Void UnityEngine.GameObject::SendMessage(System.String,System.Object,UnityEngine.SendMessageOptions) void Register_UnityEngine_GameObject_SendMessage(); Register_UnityEngine_GameObject_SendMessage(); //System.Void UnityEngine.GameObject::SetActive(System.Boolean) void Register_UnityEngine_GameObject_SetActive(); Register_UnityEngine_GameObject_SetActive(); //System.Void UnityEngine.GameObject::set_layer(System.Int32) void Register_UnityEngine_GameObject_set_layer(); Register_UnityEngine_GameObject_set_layer(); //UnityEngine.Component UnityEngine.GameObject::GetComponent(System.Type) void Register_UnityEngine_GameObject_GetComponent(); Register_UnityEngine_GameObject_GetComponent(); //UnityEngine.Component UnityEngine.GameObject::GetComponentInChildren(System.Type,System.Boolean) void Register_UnityEngine_GameObject_GetComponentInChildren(); Register_UnityEngine_GameObject_GetComponentInChildren(); //UnityEngine.Component UnityEngine.GameObject::GetComponentInParent(System.Type) void Register_UnityEngine_GameObject_GetComponentInParent(); Register_UnityEngine_GameObject_GetComponentInParent(); //UnityEngine.Component UnityEngine.GameObject::Internal_AddComponentWithType(System.Type) void Register_UnityEngine_GameObject_Internal_AddComponentWithType(); Register_UnityEngine_GameObject_Internal_AddComponentWithType(); //UnityEngine.GameObject UnityEngine.GameObject::Find(System.String) void Register_UnityEngine_GameObject_Find(); Register_UnityEngine_GameObject_Find(); //UnityEngine.Transform UnityEngine.GameObject::get_transform() void Register_UnityEngine_GameObject_get_transform(); Register_UnityEngine_GameObject_get_transform(); //End Registrations for type : UnityEngine.GameObject //Start Registrations for type : UnityEngine.Gradient //System.Void UnityEngine.Gradient::Cleanup() void Register_UnityEngine_Gradient_Cleanup(); Register_UnityEngine_Gradient_Cleanup(); //System.Void UnityEngine.Gradient::Init() void Register_UnityEngine_Gradient_Init(); Register_UnityEngine_Gradient_Init(); //End Registrations for type : UnityEngine.Gradient //Start Registrations for type : UnityEngine.GUI //System.Void UnityEngine.GUI::set_changed(System.Boolean) void Register_UnityEngine_GUI_set_changed(); Register_UnityEngine_GUI_set_changed(); //End Registrations for type : UnityEngine.GUI //Start Registrations for type : UnityEngine.GUILayer //UnityEngine.GUIElement UnityEngine.GUILayer::INTERNAL_CALL_HitTest(UnityEngine.GUILayer,UnityEngine.Vector3&) void Register_UnityEngine_GUILayer_INTERNAL_CALL_HitTest(); Register_UnityEngine_GUILayer_INTERNAL_CALL_HitTest(); //End Registrations for type : UnityEngine.GUILayer //Start Registrations for type : UnityEngine.GUILayoutUtility //System.Void UnityEngine.GUILayoutUtility::INTERNAL_CALL_Internal_GetWindowRect(System.Int32,UnityEngine.Rect&) void Register_UnityEngine_GUILayoutUtility_INTERNAL_CALL_Internal_GetWindowRect(); Register_UnityEngine_GUILayoutUtility_INTERNAL_CALL_Internal_GetWindowRect(); //System.Void UnityEngine.GUILayoutUtility::INTERNAL_CALL_Internal_MoveWindow(System.Int32,UnityEngine.Rect&) void Register_UnityEngine_GUILayoutUtility_INTERNAL_CALL_Internal_MoveWindow(); Register_UnityEngine_GUILayoutUtility_INTERNAL_CALL_Internal_MoveWindow(); //End Registrations for type : UnityEngine.GUILayoutUtility //Start Registrations for type : UnityEngine.GUIStyle //System.Boolean UnityEngine.GUIStyle::get_stretchHeight() void Register_UnityEngine_GUIStyle_get_stretchHeight(); Register_UnityEngine_GUIStyle_get_stretchHeight(); //System.Boolean UnityEngine.GUIStyle::get_stretchWidth() void Register_UnityEngine_GUIStyle_get_stretchWidth(); Register_UnityEngine_GUIStyle_get_stretchWidth(); //System.Single UnityEngine.GUIStyle::get_fixedHeight() void Register_UnityEngine_GUIStyle_get_fixedHeight(); Register_UnityEngine_GUIStyle_get_fixedHeight(); //System.Single UnityEngine.GUIStyle::get_fixedWidth() void Register_UnityEngine_GUIStyle_get_fixedWidth(); Register_UnityEngine_GUIStyle_get_fixedWidth(); //System.String UnityEngine.GUIStyle::get_name() void Register_UnityEngine_GUIStyle_get_name(); Register_UnityEngine_GUIStyle_get_name(); //System.Void UnityEngine.GUIStyle::Cleanup() void Register_UnityEngine_GUIStyle_Cleanup(); Register_UnityEngine_GUIStyle_Cleanup(); //System.Void UnityEngine.GUIStyle::INTERNAL_CALL_GetRectOffsetPtr(UnityEngine.GUIStyle,System.Int32,System.IntPtr&) void Register_UnityEngine_GUIStyle_INTERNAL_CALL_GetRectOffsetPtr(); Register_UnityEngine_GUIStyle_INTERNAL_CALL_GetRectOffsetPtr(); //System.Void UnityEngine.GUIStyle::Init() void Register_UnityEngine_GUIStyle_Init(); Register_UnityEngine_GUIStyle_Init(); //System.Void UnityEngine.GUIStyle::Internal_CalcSize(System.IntPtr,UnityEngine.GUIContent,UnityEngine.Vector2&) void Register_UnityEngine_GUIStyle_Internal_CalcSize(); Register_UnityEngine_GUIStyle_Internal_CalcSize(); //System.Void UnityEngine.GUIStyle::SetDefaultFont(UnityEngine.Font) void Register_UnityEngine_GUIStyle_SetDefaultFont(); Register_UnityEngine_GUIStyle_SetDefaultFont(); //System.Void UnityEngine.GUIStyle::set_stretchWidth(System.Boolean) void Register_UnityEngine_GUIStyle_set_stretchWidth(); Register_UnityEngine_GUIStyle_set_stretchWidth(); //End Registrations for type : UnityEngine.GUIStyle //Start Registrations for type : UnityEngine.GUIStyleState //System.Void UnityEngine.GUIStyleState::Cleanup() void Register_UnityEngine_GUIStyleState_Cleanup(); Register_UnityEngine_GUIStyleState_Cleanup(); //System.Void UnityEngine.GUIStyleState::Init() void Register_UnityEngine_GUIStyleState_Init(); Register_UnityEngine_GUIStyleState_Init(); //End Registrations for type : UnityEngine.GUIStyleState //Start Registrations for type : UnityEngine.GUIUtility //System.Int32 UnityEngine.GUIUtility::Internal_GetGUIDepth() void Register_UnityEngine_GUIUtility_Internal_GetGUIDepth(); Register_UnityEngine_GUIUtility_Internal_GetGUIDepth(); //System.Single UnityEngine.GUIUtility::Internal_GetPixelsPerPoint() void Register_UnityEngine_GUIUtility_Internal_GetPixelsPerPoint(); Register_UnityEngine_GUIUtility_Internal_GetPixelsPerPoint(); //System.String UnityEngine.GUIUtility::get_systemCopyBuffer() void Register_UnityEngine_GUIUtility_get_systemCopyBuffer(); Register_UnityEngine_GUIUtility_get_systemCopyBuffer(); //System.Void UnityEngine.GUIUtility::Internal_ExitGUI() void Register_UnityEngine_GUIUtility_Internal_ExitGUI(); Register_UnityEngine_GUIUtility_Internal_ExitGUI(); //System.Void UnityEngine.GUIUtility::set_systemCopyBuffer(System.String) void Register_UnityEngine_GUIUtility_set_systemCopyBuffer(); Register_UnityEngine_GUIUtility_set_systemCopyBuffer(); //UnityEngine.GUISkin UnityEngine.GUIUtility::Internal_GetDefaultSkin(System.Int32) void Register_UnityEngine_GUIUtility_Internal_GetDefaultSkin(); Register_UnityEngine_GUIUtility_Internal_GetDefaultSkin(); //End Registrations for type : UnityEngine.GUIUtility //Start Registrations for type : UnityEngine.Input //System.Boolean UnityEngine.Input::GetButton(System.String) void Register_UnityEngine_Input_GetButton(); Register_UnityEngine_Input_GetButton(); //System.Boolean UnityEngine.Input::GetButtonDown(System.String) void Register_UnityEngine_Input_GetButtonDown(); Register_UnityEngine_Input_GetButtonDown(); //System.Boolean UnityEngine.Input::GetKeyDownInt(System.Int32) void Register_UnityEngine_Input_GetKeyDownInt(); Register_UnityEngine_Input_GetKeyDownInt(); //System.Boolean UnityEngine.Input::GetMouseButton(System.Int32) void Register_UnityEngine_Input_GetMouseButton(); Register_UnityEngine_Input_GetMouseButton(); //System.Boolean UnityEngine.Input::GetMouseButtonDown(System.Int32) void Register_UnityEngine_Input_GetMouseButtonDown(); Register_UnityEngine_Input_GetMouseButtonDown(); //System.Boolean UnityEngine.Input::GetMouseButtonUp(System.Int32) void Register_UnityEngine_Input_GetMouseButtonUp(); Register_UnityEngine_Input_GetMouseButtonUp(); //System.Boolean UnityEngine.Input::get_mousePresent() void Register_UnityEngine_Input_get_mousePresent(); Register_UnityEngine_Input_get_mousePresent(); //System.Boolean UnityEngine.Input::get_touchSupported() void Register_UnityEngine_Input_get_touchSupported(); Register_UnityEngine_Input_get_touchSupported(); //System.Int32 UnityEngine.Input::get_touchCount() void Register_UnityEngine_Input_get_touchCount(); Register_UnityEngine_Input_get_touchCount(); //System.Single UnityEngine.Input::GetAxis(System.String) void Register_UnityEngine_Input_GetAxis(); Register_UnityEngine_Input_GetAxis(); //System.Single UnityEngine.Input::GetAxisRaw(System.String) void Register_UnityEngine_Input_GetAxisRaw(); Register_UnityEngine_Input_GetAxisRaw(); //System.String UnityEngine.Input::get_compositionString() void Register_UnityEngine_Input_get_compositionString(); Register_UnityEngine_Input_get_compositionString(); //System.Void UnityEngine.Input::INTERNAL_CALL_GetTouch(System.Int32,UnityEngine.Touch&) void Register_UnityEngine_Input_INTERNAL_CALL_GetTouch(); Register_UnityEngine_Input_INTERNAL_CALL_GetTouch(); //System.Void UnityEngine.Input::INTERNAL_get_compositionCursorPos(UnityEngine.Vector2&) void Register_UnityEngine_Input_INTERNAL_get_compositionCursorPos(); Register_UnityEngine_Input_INTERNAL_get_compositionCursorPos(); //System.Void UnityEngine.Input::INTERNAL_get_mousePosition(UnityEngine.Vector3&) void Register_UnityEngine_Input_INTERNAL_get_mousePosition(); Register_UnityEngine_Input_INTERNAL_get_mousePosition(); //System.Void UnityEngine.Input::INTERNAL_get_mouseScrollDelta(UnityEngine.Vector2&) void Register_UnityEngine_Input_INTERNAL_get_mouseScrollDelta(); Register_UnityEngine_Input_INTERNAL_get_mouseScrollDelta(); //System.Void UnityEngine.Input::INTERNAL_set_compositionCursorPos(UnityEngine.Vector2&) void Register_UnityEngine_Input_INTERNAL_set_compositionCursorPos(); Register_UnityEngine_Input_INTERNAL_set_compositionCursorPos(); //System.Void UnityEngine.Input::set_imeCompositionMode(UnityEngine.IMECompositionMode) void Register_UnityEngine_Input_set_imeCompositionMode(); Register_UnityEngine_Input_set_imeCompositionMode(); //UnityEngine.IMECompositionMode UnityEngine.Input::get_imeCompositionMode() void Register_UnityEngine_Input_get_imeCompositionMode(); Register_UnityEngine_Input_get_imeCompositionMode(); //End Registrations for type : UnityEngine.Input //Start Registrations for type : UnityEngine.LayerMask //System.Int32 UnityEngine.LayerMask::NameToLayer(System.String) void Register_UnityEngine_LayerMask_NameToLayer(); Register_UnityEngine_LayerMask_NameToLayer(); //End Registrations for type : UnityEngine.LayerMask //Start Registrations for type : UnityEngine.Material //System.Boolean UnityEngine.Material::HasProperty(System.Int32) void Register_UnityEngine_Material_HasProperty(); Register_UnityEngine_Material_HasProperty(); //System.Void UnityEngine.Material::DisableKeyword(System.String) void Register_UnityEngine_Material_DisableKeyword(); Register_UnityEngine_Material_DisableKeyword(); //System.Void UnityEngine.Material::EnableKeyword(System.String) void Register_UnityEngine_Material_EnableKeyword(); Register_UnityEngine_Material_EnableKeyword(); //System.Void UnityEngine.Material::Internal_CreateWithMaterial(UnityEngine.Material,UnityEngine.Material) void Register_UnityEngine_Material_Internal_CreateWithMaterial(); Register_UnityEngine_Material_Internal_CreateWithMaterial(); //System.Void UnityEngine.Material::SetIntImpl(System.Int32,System.Int32) void Register_UnityEngine_Material_SetIntImpl(); Register_UnityEngine_Material_SetIntImpl(); //UnityEngine.Texture UnityEngine.Material::GetTextureImpl(System.Int32) void Register_UnityEngine_Material_GetTextureImpl(); Register_UnityEngine_Material_GetTextureImpl(); //End Registrations for type : UnityEngine.Material //Start Registrations for type : UnityEngine.Mathf //System.Single UnityEngine.Mathf::PerlinNoise(System.Single,System.Single) void Register_UnityEngine_Mathf_PerlinNoise(); Register_UnityEngine_Mathf_PerlinNoise(); //End Registrations for type : UnityEngine.Mathf //Start Registrations for type : UnityEngine.Matrix4x4 //System.Void UnityEngine.Matrix4x4::INTERNAL_CALL_Inverse(UnityEngine.Matrix4x4&,UnityEngine.Matrix4x4&) void Register_UnityEngine_Matrix4x4_INTERNAL_CALL_Inverse(); Register_UnityEngine_Matrix4x4_INTERNAL_CALL_Inverse(); //System.Void UnityEngine.Matrix4x4::INTERNAL_CALL_Perspective(System.Single,System.Single,System.Single,System.Single,UnityEngine.Matrix4x4&) void Register_UnityEngine_Matrix4x4_INTERNAL_CALL_Perspective(); Register_UnityEngine_Matrix4x4_INTERNAL_CALL_Perspective(); //System.Void UnityEngine.Matrix4x4::INTERNAL_CALL_TRS(UnityEngine.Vector3&,UnityEngine.Quaternion&,UnityEngine.Vector3&,UnityEngine.Matrix4x4&) void Register_UnityEngine_Matrix4x4_INTERNAL_CALL_TRS(); Register_UnityEngine_Matrix4x4_INTERNAL_CALL_TRS(); //End Registrations for type : UnityEngine.Matrix4x4 //Start Registrations for type : UnityEngine.Mesh //System.Array UnityEngine.Mesh::ExtractArrayFromList(System.Object) void Register_UnityEngine_Mesh_ExtractArrayFromList(); Register_UnityEngine_Mesh_ExtractArrayFromList(); //System.Array UnityEngine.Mesh::GetAllocArrayFromChannelImpl(UnityEngine.Mesh/InternalShaderChannel,UnityEngine.Mesh/InternalVertexChannelType,System.Int32) void Register_UnityEngine_Mesh_GetAllocArrayFromChannelImpl(); Register_UnityEngine_Mesh_GetAllocArrayFromChannelImpl(); //System.Boolean UnityEngine.Mesh::HasChannel(UnityEngine.Mesh/InternalShaderChannel) void Register_UnityEngine_Mesh_HasChannel(); Register_UnityEngine_Mesh_HasChannel(); //System.Boolean UnityEngine.Mesh::get_canAccess() void Register_UnityEngine_Mesh_get_canAccess(); Register_UnityEngine_Mesh_get_canAccess(); //System.Int32 UnityEngine.Mesh::get_subMeshCount() void Register_UnityEngine_Mesh_get_subMeshCount(); Register_UnityEngine_Mesh_get_subMeshCount(); //System.Int32[] UnityEngine.Mesh::GetIndicesImpl(System.Int32) void Register_UnityEngine_Mesh_GetIndicesImpl(); Register_UnityEngine_Mesh_GetIndicesImpl(); //System.Void UnityEngine.Mesh::ClearImpl(System.Boolean) void Register_UnityEngine_Mesh_ClearImpl(); Register_UnityEngine_Mesh_ClearImpl(); //System.Void UnityEngine.Mesh::Internal_Create(UnityEngine.Mesh) void Register_UnityEngine_Mesh_Internal_Create(); Register_UnityEngine_Mesh_Internal_Create(); //System.Void UnityEngine.Mesh::PrintErrorCantAccessChannel(UnityEngine.Mesh/InternalShaderChannel) void Register_UnityEngine_Mesh_PrintErrorCantAccessChannel(); Register_UnityEngine_Mesh_PrintErrorCantAccessChannel(); //System.Void UnityEngine.Mesh::RecalculateBoundsImpl() void Register_UnityEngine_Mesh_RecalculateBoundsImpl(); Register_UnityEngine_Mesh_RecalculateBoundsImpl(); //System.Void UnityEngine.Mesh::SetArrayForChannelImpl(UnityEngine.Mesh/InternalShaderChannel,UnityEngine.Mesh/InternalVertexChannelType,System.Int32,System.Array,System.Int32) void Register_UnityEngine_Mesh_SetArrayForChannelImpl(); Register_UnityEngine_Mesh_SetArrayForChannelImpl(); //System.Void UnityEngine.Mesh::SetTrianglesImpl(System.Int32,System.Array,System.Int32,System.Boolean) void Register_UnityEngine_Mesh_SetTrianglesImpl(); Register_UnityEngine_Mesh_SetTrianglesImpl(); //End Registrations for type : UnityEngine.Mesh //Start Registrations for type : UnityEngine.MonoBehaviour //System.Void UnityEngine.MonoBehaviour::StopCoroutineViaEnumerator_Auto(System.Collections.IEnumerator) void Register_UnityEngine_MonoBehaviour_StopCoroutineViaEnumerator_Auto(); Register_UnityEngine_MonoBehaviour_StopCoroutineViaEnumerator_Auto(); //System.Void UnityEngine.MonoBehaviour::StopCoroutine_Auto(UnityEngine.Coroutine) void Register_UnityEngine_MonoBehaviour_StopCoroutine_Auto(); Register_UnityEngine_MonoBehaviour_StopCoroutine_Auto(); //UnityEngine.Coroutine UnityEngine.MonoBehaviour::StartCoroutine_Auto_Internal(System.Collections.IEnumerator) void Register_UnityEngine_MonoBehaviour_StartCoroutine_Auto_Internal(); Register_UnityEngine_MonoBehaviour_StartCoroutine_Auto_Internal(); //End Registrations for type : UnityEngine.MonoBehaviour //Start Registrations for type : UnityEngine.Motion //System.Boolean UnityEngine.Motion::get_isLooping() void Register_UnityEngine_Motion_get_isLooping(); Register_UnityEngine_Motion_get_isLooping(); //End Registrations for type : UnityEngine.Motion //Start Registrations for type : UnityEngine.Object //System.Int32 UnityEngine.Object::GetOffsetOfInstanceIDInCPlusPlusObject() void Register_UnityEngine_Object_GetOffsetOfInstanceIDInCPlusPlusObject(); Register_UnityEngine_Object_GetOffsetOfInstanceIDInCPlusPlusObject(); //System.String UnityEngine.Object::ToString() void Register_UnityEngine_Object_ToString(); Register_UnityEngine_Object_ToString(); //System.String UnityEngine.Object::get_name() void Register_UnityEngine_Object_get_name(); Register_UnityEngine_Object_get_name(); //System.Void UnityEngine.Object::Destroy(UnityEngine.Object,System.Single) void Register_UnityEngine_Object_Destroy(); Register_UnityEngine_Object_Destroy(); //System.Void UnityEngine.Object::DestroyImmediate(UnityEngine.Object,System.Boolean) void Register_UnityEngine_Object_DestroyImmediate(); Register_UnityEngine_Object_DestroyImmediate(); //System.Void UnityEngine.Object::set_hideFlags(UnityEngine.HideFlags) void Register_UnityEngine_Object_set_hideFlags(); Register_UnityEngine_Object_set_hideFlags(); //System.Void UnityEngine.Object::set_name(System.String) void Register_UnityEngine_Object_set_name(); Register_UnityEngine_Object_set_name(); //UnityEngine.HideFlags UnityEngine.Object::get_hideFlags() void Register_UnityEngine_Object_get_hideFlags(); Register_UnityEngine_Object_get_hideFlags(); //UnityEngine.Object UnityEngine.Object::INTERNAL_CALL_Internal_InstantiateSingle(UnityEngine.Object,UnityEngine.Vector3&,UnityEngine.Quaternion&) void Register_UnityEngine_Object_INTERNAL_CALL_Internal_InstantiateSingle(); Register_UnityEngine_Object_INTERNAL_CALL_Internal_InstantiateSingle(); //UnityEngine.Object UnityEngine.Object::Internal_CloneSingle(UnityEngine.Object) void Register_UnityEngine_Object_Internal_CloneSingle(); Register_UnityEngine_Object_Internal_CloneSingle(); //UnityEngine.Object UnityEngine.Object::Internal_CloneSingleWithParent(UnityEngine.Object,UnityEngine.Transform,System.Boolean) void Register_UnityEngine_Object_Internal_CloneSingleWithParent(); Register_UnityEngine_Object_Internal_CloneSingleWithParent(); //End Registrations for type : UnityEngine.Object //Start Registrations for type : UnityEngine.ParticleSystem //System.Single UnityEngine.ParticleSystem::get_time() void Register_UnityEngine_ParticleSystem_get_time(); Register_UnityEngine_ParticleSystem_get_time(); //System.UInt32 UnityEngine.ParticleSystem::get_randomSeed() void Register_UnityEngine_ParticleSystem_get_randomSeed(); Register_UnityEngine_ParticleSystem_get_randomSeed(); //System.Void UnityEngine.ParticleSystem::Simulate(System.Single,System.Boolean,System.Boolean,System.Boolean) void Register_UnityEngine_ParticleSystem_Simulate(); Register_UnityEngine_ParticleSystem_Simulate(); //System.Void UnityEngine.ParticleSystem::Stop(System.Boolean,UnityEngine.ParticleSystemStopBehavior) void Register_UnityEngine_ParticleSystem_Stop(); Register_UnityEngine_ParticleSystem_Stop(); //System.Void UnityEngine.ParticleSystem::set_randomSeed(System.UInt32) void Register_UnityEngine_ParticleSystem_set_randomSeed(); Register_UnityEngine_ParticleSystem_set_randomSeed(); //System.Void UnityEngine.ParticleSystem::set_useAutoRandomSeed(System.Boolean) void Register_UnityEngine_ParticleSystem_set_useAutoRandomSeed(); Register_UnityEngine_ParticleSystem_set_useAutoRandomSeed(); //End Registrations for type : UnityEngine.ParticleSystem //Start Registrations for type : UnityEngine.ParticleSystem/MainModule //System.Boolean UnityEngine.ParticleSystem/MainModule::GetLoop(UnityEngine.ParticleSystem) void Register_UnityEngine_ParticleSystem_MainModule_GetLoop(); Register_UnityEngine_ParticleSystem_MainModule_GetLoop(); //System.Single UnityEngine.ParticleSystem/MainModule::GetDuration(UnityEngine.ParticleSystem) void Register_UnityEngine_ParticleSystem_MainModule_GetDuration(); Register_UnityEngine_ParticleSystem_MainModule_GetDuration(); //End Registrations for type : UnityEngine.ParticleSystem/MainModule //Start Registrations for type : UnityEngine.Physics //System.Boolean UnityEngine.Physics::INTERNAL_CALL_ComputePenetration(UnityEngine.Collider,UnityEngine.Vector3&,UnityEngine.Quaternion&,UnityEngine.Collider,UnityEngine.Vector3&,UnityEngine.Quaternion&,UnityEngine.Vector3&,System.Single&) void Register_UnityEngine_Physics_INTERNAL_CALL_ComputePenetration(); Register_UnityEngine_Physics_INTERNAL_CALL_ComputePenetration(); //System.Boolean UnityEngine.Physics::INTERNAL_CALL_Internal_Raycast(UnityEngine.Vector3&,UnityEngine.Vector3&,UnityEngine.RaycastHit&,System.Single,System.Int32,UnityEngine.QueryTriggerInteraction) void Register_UnityEngine_Physics_INTERNAL_CALL_Internal_Raycast(); Register_UnityEngine_Physics_INTERNAL_CALL_Internal_Raycast(); //System.Boolean UnityEngine.Physics::INTERNAL_CALL_Internal_RaycastTest(UnityEngine.Vector3&,UnityEngine.Vector3&,System.Single,System.Int32,UnityEngine.QueryTriggerInteraction) void Register_UnityEngine_Physics_INTERNAL_CALL_Internal_RaycastTest(); Register_UnityEngine_Physics_INTERNAL_CALL_Internal_RaycastTest(); //System.Int32 UnityEngine.Physics::INTERNAL_CALL_CapsuleCastNonAlloc(UnityEngine.Vector3&,UnityEngine.Vector3&,System.Single,UnityEngine.Vector3&,UnityEngine.RaycastHit[],System.Single,System.Int32,UnityEngine.QueryTriggerInteraction) void Register_UnityEngine_Physics_INTERNAL_CALL_CapsuleCastNonAlloc(); Register_UnityEngine_Physics_INTERNAL_CALL_CapsuleCastNonAlloc(); //System.Int32 UnityEngine.Physics::INTERNAL_CALL_OverlapSphereNonAlloc(UnityEngine.Vector3&,System.Single,UnityEngine.Collider[],System.Int32,UnityEngine.QueryTriggerInteraction) void Register_UnityEngine_Physics_INTERNAL_CALL_OverlapSphereNonAlloc(); Register_UnityEngine_Physics_INTERNAL_CALL_OverlapSphereNonAlloc(); //UnityEngine.RaycastHit[] UnityEngine.Physics::INTERNAL_CALL_RaycastAll(UnityEngine.Vector3&,UnityEngine.Vector3&,System.Single,System.Int32,UnityEngine.QueryTriggerInteraction) void Register_UnityEngine_Physics_INTERNAL_CALL_RaycastAll(); Register_UnityEngine_Physics_INTERNAL_CALL_RaycastAll(); //End Registrations for type : UnityEngine.Physics //Start Registrations for type : UnityEngine.Physics2D //System.Boolean UnityEngine.Physics2D::get_queriesHitTriggers() void Register_UnityEngine_Physics2D_get_queriesHitTriggers(); Register_UnityEngine_Physics2D_get_queriesHitTriggers(); //System.Int32 UnityEngine.Physics2D::INTERNAL_CALL_Internal_RaycastNonAlloc(UnityEngine.Vector2&,UnityEngine.Vector2&,System.Single,UnityEngine.ContactFilter2D&,UnityEngine.RaycastHit2D[]) void Register_UnityEngine_Physics2D_INTERNAL_CALL_Internal_RaycastNonAlloc(); Register_UnityEngine_Physics2D_INTERNAL_CALL_Internal_RaycastNonAlloc(); //System.Void UnityEngine.Physics2D::INTERNAL_CALL_Internal_Raycast(UnityEngine.Vector2&,UnityEngine.Vector2&,System.Single,UnityEngine.ContactFilter2D&,UnityEngine.RaycastHit2D&) void Register_UnityEngine_Physics2D_INTERNAL_CALL_Internal_Raycast(); Register_UnityEngine_Physics2D_INTERNAL_CALL_Internal_Raycast(); //UnityEngine.Collider2D UnityEngine.Physics2D::GetColliderFromInstanceID(System.Int32) void Register_UnityEngine_Physics2D_GetColliderFromInstanceID(); Register_UnityEngine_Physics2D_GetColliderFromInstanceID(); //UnityEngine.Collider2D[] UnityEngine.Physics2D::INTERNAL_CALL_Internal_OverlapCircleAll(UnityEngine.Vector2&,System.Single,UnityEngine.ContactFilter2D&) void Register_UnityEngine_Physics2D_INTERNAL_CALL_Internal_OverlapCircleAll(); Register_UnityEngine_Physics2D_INTERNAL_CALL_Internal_OverlapCircleAll(); //UnityEngine.RaycastHit2D[] UnityEngine.Physics2D::INTERNAL_CALL_GetRayIntersectionAll(UnityEngine.Ray&,System.Single,System.Int32) void Register_UnityEngine_Physics2D_INTERNAL_CALL_GetRayIntersectionAll(); Register_UnityEngine_Physics2D_INTERNAL_CALL_GetRayIntersectionAll(); //UnityEngine.Rigidbody2D UnityEngine.Physics2D::GetRigidbodyFromInstanceID(System.Int32) void Register_UnityEngine_Physics2D_GetRigidbodyFromInstanceID(); Register_UnityEngine_Physics2D_GetRigidbodyFromInstanceID(); //End Registrations for type : UnityEngine.Physics2D //Start Registrations for type : UnityEngine.Playables.AudioPlayableGraphExtensions //System.Boolean UnityEngine.Playables.AudioPlayableGraphExtensions::INTERNAL_CALL_InternalCreateAudioOutput(UnityEngine.Playables.PlayableGraph&,System.String,UnityEngine.Playables.PlayableOutputHandle&) void Register_UnityEngine_Playables_AudioPlayableGraphExtensions_INTERNAL_CALL_InternalCreateAudioOutput(); Register_UnityEngine_Playables_AudioPlayableGraphExtensions_INTERNAL_CALL_InternalCreateAudioOutput(); //End Registrations for type : UnityEngine.Playables.AudioPlayableGraphExtensions //Start Registrations for type : UnityEngine.Playables.PlayableDirector //System.Double UnityEngine.Playables.PlayableDirector::get_time() void Register_UnityEngine_Playables_PlayableDirector_get_time(); Register_UnityEngine_Playables_PlayableDirector_get_time(); //System.Void UnityEngine.Playables.PlayableDirector::Evaluate() void Register_UnityEngine_Playables_PlayableDirector_Evaluate(); Register_UnityEngine_Playables_PlayableDirector_Evaluate(); //System.Void UnityEngine.Playables.PlayableDirector::INTERNAL_CALL_InternalGetCurrentGraph(UnityEngine.Playables.PlayableDirector,UnityEngine.Playables.PlayableGraph&) void Register_UnityEngine_Playables_PlayableDirector_INTERNAL_CALL_InternalGetCurrentGraph(); Register_UnityEngine_Playables_PlayableDirector_INTERNAL_CALL_InternalGetCurrentGraph(); //System.Void UnityEngine.Playables.PlayableDirector::Pause() void Register_UnityEngine_Playables_PlayableDirector_Pause(); Register_UnityEngine_Playables_PlayableDirector_Pause(); //System.Void UnityEngine.Playables.PlayableDirector::Play() void Register_UnityEngine_Playables_PlayableDirector_Play(); Register_UnityEngine_Playables_PlayableDirector_Play(); //System.Void UnityEngine.Playables.PlayableDirector::set_time(System.Double) void Register_UnityEngine_Playables_PlayableDirector_set_time(); Register_UnityEngine_Playables_PlayableDirector_set_time(); //UnityEngine.Object UnityEngine.Playables.PlayableDirector::GetGenericBinding(UnityEngine.Object) void Register_UnityEngine_Playables_PlayableDirector_GetGenericBinding(); Register_UnityEngine_Playables_PlayableDirector_GetGenericBinding(); //UnityEngine.Object UnityEngine.Playables.PlayableDirector::INTERNAL_CALL_GetReferenceValue(UnityEngine.Playables.PlayableDirector,UnityEngine.PropertyName&,System.Boolean&) void Register_UnityEngine_Playables_PlayableDirector_INTERNAL_CALL_GetReferenceValue(); Register_UnityEngine_Playables_PlayableDirector_INTERNAL_CALL_GetReferenceValue(); //UnityEngine.Playables.DirectorWrapMode UnityEngine.Playables.PlayableDirector::get_extrapolationMode() void Register_UnityEngine_Playables_PlayableDirector_get_extrapolationMode(); Register_UnityEngine_Playables_PlayableDirector_get_extrapolationMode(); //UnityEngine.ScriptableObject UnityEngine.Playables.PlayableDirector::GetPlayableAssetInternal() void Register_UnityEngine_Playables_PlayableDirector_GetPlayableAssetInternal(); Register_UnityEngine_Playables_PlayableDirector_GetPlayableAssetInternal(); //End Registrations for type : UnityEngine.Playables.PlayableDirector //Start Registrations for type : UnityEngine.Playables.PlayableGraph //System.Boolean UnityEngine.Playables.PlayableGraph::INTERNAL_CALL_ConnectInternal(UnityEngine.Playables.PlayableGraph&,UnityEngine.Playables.PlayableHandle&,System.Int32,UnityEngine.Playables.PlayableHandle&,System.Int32) void Register_UnityEngine_Playables_PlayableGraph_INTERNAL_CALL_ConnectInternal(); Register_UnityEngine_Playables_PlayableGraph_INTERNAL_CALL_ConnectInternal(); //System.Boolean UnityEngine.Playables.PlayableGraph::INTERNAL_CALL_CreatePlayableHandleInternal(UnityEngine.Playables.PlayableGraph&,UnityEngine.Playables.PlayableHandle&) void Register_UnityEngine_Playables_PlayableGraph_INTERNAL_CALL_CreatePlayableHandleInternal(); Register_UnityEngine_Playables_PlayableGraph_INTERNAL_CALL_CreatePlayableHandleInternal(); //System.Boolean UnityEngine.Playables.PlayableGraph::INTERNAL_CALL_CreateScriptOutputInternal(UnityEngine.Playables.PlayableGraph&,System.String,UnityEngine.Playables.PlayableOutputHandle&) void Register_UnityEngine_Playables_PlayableGraph_INTERNAL_CALL_CreateScriptOutputInternal(); Register_UnityEngine_Playables_PlayableGraph_INTERNAL_CALL_CreateScriptOutputInternal(); //System.Boolean UnityEngine.Playables.PlayableGraph::INTERNAL_CALL_IsValidInternal(UnityEngine.Playables.PlayableGraph&) void Register_UnityEngine_Playables_PlayableGraph_INTERNAL_CALL_IsValidInternal(); Register_UnityEngine_Playables_PlayableGraph_INTERNAL_CALL_IsValidInternal(); //System.Int32 UnityEngine.Playables.PlayableGraph::INTERNAL_CALL_GetPlayableCountInternal(UnityEngine.Playables.PlayableGraph&) void Register_UnityEngine_Playables_PlayableGraph_INTERNAL_CALL_GetPlayableCountInternal(); Register_UnityEngine_Playables_PlayableGraph_INTERNAL_CALL_GetPlayableCountInternal(); //System.Int32 UnityEngine.Playables.PlayableGraph::INTERNAL_CALL_GetRootPlayableCountInternal(UnityEngine.Playables.PlayableGraph&) void Register_UnityEngine_Playables_PlayableGraph_INTERNAL_CALL_GetRootPlayableCountInternal(); Register_UnityEngine_Playables_PlayableGraph_INTERNAL_CALL_GetRootPlayableCountInternal(); //System.Void UnityEngine.Playables.PlayableGraph::INTERNAL_CALL_GetRootPlayableInternal(System.Int32,UnityEngine.Playables.PlayableGraph&,UnityEngine.Playables.PlayableHandle&) void Register_UnityEngine_Playables_PlayableGraph_INTERNAL_CALL_GetRootPlayableInternal(); Register_UnityEngine_Playables_PlayableGraph_INTERNAL_CALL_GetRootPlayableInternal(); //UnityEngine.IExposedPropertyTable UnityEngine.Playables.PlayableGraph::INTERNAL_CALL_GetResolverInternal(UnityEngine.Playables.PlayableGraph&) void Register_UnityEngine_Playables_PlayableGraph_INTERNAL_CALL_GetResolverInternal(); Register_UnityEngine_Playables_PlayableGraph_INTERNAL_CALL_GetResolverInternal(); //End Registrations for type : UnityEngine.Playables.PlayableGraph //Start Registrations for type : UnityEngine.Playables.PlayableHandle //System.Boolean UnityEngine.Playables.PlayableHandle::INTERNAL_CALL_IsValidInternal(UnityEngine.Playables.PlayableHandle&) void Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_IsValidInternal(); Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_IsValidInternal(); //System.Double UnityEngine.Playables.PlayableHandle::INTERNAL_CALL_GetTimeInternal(UnityEngine.Playables.PlayableHandle&) void Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_GetTimeInternal(); Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_GetTimeInternal(); //System.Int32 UnityEngine.Playables.PlayableHandle::INTERNAL_CALL_GetInputCountInternal(UnityEngine.Playables.PlayableHandle&) void Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_GetInputCountInternal(); Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_GetInputCountInternal(); //System.Object UnityEngine.Playables.PlayableHandle::INTERNAL_CALL_GetScriptInstance(UnityEngine.Playables.PlayableHandle&) void Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_GetScriptInstance(); Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_GetScriptInstance(); //System.Single UnityEngine.Playables.PlayableHandle::INTERNAL_CALL_GetInputWeightFromIndexInternal(UnityEngine.Playables.PlayableHandle&,System.Int32) void Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_GetInputWeightFromIndexInternal(); Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_GetInputWeightFromIndexInternal(); //System.Type UnityEngine.Playables.PlayableHandle::INTERNAL_CALL_GetPlayableTypeOf(UnityEngine.Playables.PlayableHandle&) void Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_GetPlayableTypeOf(); Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_GetPlayableTypeOf(); //System.Void UnityEngine.Playables.PlayableHandle::INTERNAL_CALL_GetInputInternal(UnityEngine.Playables.PlayableHandle&,System.Int32,UnityEngine.Playables.PlayableHandle&) void Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_GetInputInternal(); Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_GetInputInternal(); //System.Void UnityEngine.Playables.PlayableHandle::INTERNAL_CALL_SetDurationInternal(UnityEngine.Playables.PlayableHandle&,System.Double) void Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_SetDurationInternal(); Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_SetDurationInternal(); //System.Void UnityEngine.Playables.PlayableHandle::INTERNAL_CALL_SetInputCountInternal(UnityEngine.Playables.PlayableHandle&,System.Int32) void Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_SetInputCountInternal(); Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_SetInputCountInternal(); //System.Void UnityEngine.Playables.PlayableHandle::INTERNAL_CALL_SetInputWeightFromIndexInternal(UnityEngine.Playables.PlayableHandle&,System.Int32,System.Single) void Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_SetInputWeightFromIndexInternal(); Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_SetInputWeightFromIndexInternal(); //System.Void UnityEngine.Playables.PlayableHandle::INTERNAL_CALL_SetInputWeightInternal(UnityEngine.Playables.PlayableHandle&,UnityEngine.Playables.PlayableHandle&,System.Single) void Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_SetInputWeightInternal(); Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_SetInputWeightInternal(); //System.Void UnityEngine.Playables.PlayableHandle::INTERNAL_CALL_SetPlayStateInternal(UnityEngine.Playables.PlayableHandle&,UnityEngine.Playables.PlayState) void Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_SetPlayStateInternal(); Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_SetPlayStateInternal(); //System.Void UnityEngine.Playables.PlayableHandle::INTERNAL_CALL_SetPropagateSetTimeInternal(UnityEngine.Playables.PlayableHandle&,System.Boolean) void Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_SetPropagateSetTimeInternal(); Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_SetPropagateSetTimeInternal(); //System.Void UnityEngine.Playables.PlayableHandle::INTERNAL_CALL_SetScriptInstance(UnityEngine.Playables.PlayableHandle&,System.Object) void Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_SetScriptInstance(); Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_SetScriptInstance(); //System.Void UnityEngine.Playables.PlayableHandle::INTERNAL_CALL_SetSpeedInternal(UnityEngine.Playables.PlayableHandle&,System.Double) void Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_SetSpeedInternal(); Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_SetSpeedInternal(); //System.Void UnityEngine.Playables.PlayableHandle::INTERNAL_CALL_SetTimeInternal(UnityEngine.Playables.PlayableHandle&,System.Double) void Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_SetTimeInternal(); Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_SetTimeInternal(); //UnityEngine.Playables.PlayState UnityEngine.Playables.PlayableHandle::INTERNAL_CALL_GetPlayStateInternal(UnityEngine.Playables.PlayableHandle&) void Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_GetPlayStateInternal(); Register_UnityEngine_Playables_PlayableHandle_INTERNAL_CALL_GetPlayStateInternal(); //End Registrations for type : UnityEngine.Playables.PlayableHandle //Start Registrations for type : UnityEngine.Playables.PlayableOutputHandle //System.Boolean UnityEngine.Playables.PlayableOutputHandle::INTERNAL_CALL_IsValidInternal(UnityEngine.Playables.PlayableOutputHandle&) void Register_UnityEngine_Playables_PlayableOutputHandle_INTERNAL_CALL_IsValidInternal(); Register_UnityEngine_Playables_PlayableOutputHandle_INTERNAL_CALL_IsValidInternal(); //System.Int32 UnityEngine.Playables.PlayableOutputHandle::INTERNAL_CALL_GetSourceInputPortInternal(UnityEngine.Playables.PlayableOutputHandle&) void Register_UnityEngine_Playables_PlayableOutputHandle_INTERNAL_CALL_GetSourceInputPortInternal(); Register_UnityEngine_Playables_PlayableOutputHandle_INTERNAL_CALL_GetSourceInputPortInternal(); //System.Type UnityEngine.Playables.PlayableOutputHandle::INTERNAL_CALL_GetPlayableOutputTypeOf(UnityEngine.Playables.PlayableOutputHandle&) void Register_UnityEngine_Playables_PlayableOutputHandle_INTERNAL_CALL_GetPlayableOutputTypeOf(); Register_UnityEngine_Playables_PlayableOutputHandle_INTERNAL_CALL_GetPlayableOutputTypeOf(); //System.Void UnityEngine.Playables.PlayableOutputHandle::INTERNAL_CALL_GetSourcePlayableInternal(UnityEngine.Playables.PlayableOutputHandle&,UnityEngine.Playables.PlayableHandle&) void Register_UnityEngine_Playables_PlayableOutputHandle_INTERNAL_CALL_GetSourcePlayableInternal(); Register_UnityEngine_Playables_PlayableOutputHandle_INTERNAL_CALL_GetSourcePlayableInternal(); //System.Void UnityEngine.Playables.PlayableOutputHandle::INTERNAL_CALL_SetInternalReferenceObject(UnityEngine.Playables.PlayableOutputHandle&,UnityEngine.Object) void Register_UnityEngine_Playables_PlayableOutputHandle_INTERNAL_CALL_SetInternalReferenceObject(); Register_UnityEngine_Playables_PlayableOutputHandle_INTERNAL_CALL_SetInternalReferenceObject(); //System.Void UnityEngine.Playables.PlayableOutputHandle::INTERNAL_CALL_SetSourceInputPortInternal(UnityEngine.Playables.PlayableOutputHandle&,System.Int32) void Register_UnityEngine_Playables_PlayableOutputHandle_INTERNAL_CALL_SetSourceInputPortInternal(); Register_UnityEngine_Playables_PlayableOutputHandle_INTERNAL_CALL_SetSourceInputPortInternal(); //System.Void UnityEngine.Playables.PlayableOutputHandle::INTERNAL_CALL_SetSourcePlayableInternal(UnityEngine.Playables.PlayableOutputHandle&,UnityEngine.Playables.PlayableHandle&) void Register_UnityEngine_Playables_PlayableOutputHandle_INTERNAL_CALL_SetSourcePlayableInternal(); Register_UnityEngine_Playables_PlayableOutputHandle_INTERNAL_CALL_SetSourcePlayableInternal(); //System.Void UnityEngine.Playables.PlayableOutputHandle::INTERNAL_CALL_SetWeightInternal(UnityEngine.Playables.PlayableOutputHandle&,System.Single) void Register_UnityEngine_Playables_PlayableOutputHandle_INTERNAL_CALL_SetWeightInternal(); Register_UnityEngine_Playables_PlayableOutputHandle_INTERNAL_CALL_SetWeightInternal(); //End Registrations for type : UnityEngine.Playables.PlayableOutputHandle //Start Registrations for type : UnityEngine.PolygonCollider2D //System.Int32 UnityEngine.PolygonCollider2D::get_pathCount() void Register_UnityEngine_PolygonCollider2D_get_pathCount(); Register_UnityEngine_PolygonCollider2D_get_pathCount(); //UnityEngine.Vector2[] UnityEngine.PolygonCollider2D::GetPath(System.Int32) void Register_UnityEngine_PolygonCollider2D_GetPath(); Register_UnityEngine_PolygonCollider2D_GetPath(); //End Registrations for type : UnityEngine.PolygonCollider2D //Start Registrations for type : UnityEngine.PropertyNameUtils //System.Void UnityEngine.PropertyNameUtils::PropertyNameFromString_Injected(System.String,UnityEngine.PropertyName&) void Register_UnityEngine_PropertyNameUtils_PropertyNameFromString_Injected(); Register_UnityEngine_PropertyNameUtils_PropertyNameFromString_Injected(); //End Registrations for type : UnityEngine.PropertyNameUtils //Start Registrations for type : UnityEngine.Quaternion //System.Void UnityEngine.Quaternion::INTERNAL_CALL_AngleAxis(System.Single,UnityEngine.Vector3&,UnityEngine.Quaternion&) void Register_UnityEngine_Quaternion_INTERNAL_CALL_AngleAxis(); Register_UnityEngine_Quaternion_INTERNAL_CALL_AngleAxis(); //System.Void UnityEngine.Quaternion::INTERNAL_CALL_FromToRotation(UnityEngine.Vector3&,UnityEngine.Vector3&,UnityEngine.Quaternion&) void Register_UnityEngine_Quaternion_INTERNAL_CALL_FromToRotation(); Register_UnityEngine_Quaternion_INTERNAL_CALL_FromToRotation(); //System.Void UnityEngine.Quaternion::INTERNAL_CALL_Internal_FromEulerRad(UnityEngine.Vector3&,UnityEngine.Quaternion&) void Register_UnityEngine_Quaternion_INTERNAL_CALL_Internal_FromEulerRad(); Register_UnityEngine_Quaternion_INTERNAL_CALL_Internal_FromEulerRad(); //System.Void UnityEngine.Quaternion::INTERNAL_CALL_Internal_ToEulerRad(UnityEngine.Quaternion&,UnityEngine.Vector3&) void Register_UnityEngine_Quaternion_INTERNAL_CALL_Internal_ToEulerRad(); Register_UnityEngine_Quaternion_INTERNAL_CALL_Internal_ToEulerRad(); //System.Void UnityEngine.Quaternion::INTERNAL_CALL_Inverse(UnityEngine.Quaternion&,UnityEngine.Quaternion&) void Register_UnityEngine_Quaternion_INTERNAL_CALL_Inverse(); Register_UnityEngine_Quaternion_INTERNAL_CALL_Inverse(); //System.Void UnityEngine.Quaternion::INTERNAL_CALL_LookRotation(UnityEngine.Vector3&,UnityEngine.Vector3&,UnityEngine.Quaternion&) void Register_UnityEngine_Quaternion_INTERNAL_CALL_LookRotation(); Register_UnityEngine_Quaternion_INTERNAL_CALL_LookRotation(); //System.Void UnityEngine.Quaternion::INTERNAL_CALL_Slerp(UnityEngine.Quaternion&,UnityEngine.Quaternion&,System.Single,UnityEngine.Quaternion&) void Register_UnityEngine_Quaternion_INTERNAL_CALL_Slerp(); Register_UnityEngine_Quaternion_INTERNAL_CALL_Slerp(); //End Registrations for type : UnityEngine.Quaternion //Start Registrations for type : UnityEngine.Random //System.Int32 UnityEngine.Random::RandomRangeInt(System.Int32,System.Int32) void Register_UnityEngine_Random_RandomRangeInt(); Register_UnityEngine_Random_RandomRangeInt(); //System.Single UnityEngine.Random::Range(System.Single,System.Single) void Register_UnityEngine_Random_Range(); Register_UnityEngine_Random_Range(); //End Registrations for type : UnityEngine.Random //Start Registrations for type : UnityEngine.RectOffset //System.Int32 UnityEngine.RectOffset::get_bottom() void Register_UnityEngine_RectOffset_get_bottom(); Register_UnityEngine_RectOffset_get_bottom(); //System.Int32 UnityEngine.RectOffset::get_horizontal() void Register_UnityEngine_RectOffset_get_horizontal(); Register_UnityEngine_RectOffset_get_horizontal(); //System.Int32 UnityEngine.RectOffset::get_left() void Register_UnityEngine_RectOffset_get_left(); Register_UnityEngine_RectOffset_get_left(); //System.Int32 UnityEngine.RectOffset::get_right() void Register_UnityEngine_RectOffset_get_right(); Register_UnityEngine_RectOffset_get_right(); //System.Int32 UnityEngine.RectOffset::get_top() void Register_UnityEngine_RectOffset_get_top(); Register_UnityEngine_RectOffset_get_top(); //System.Int32 UnityEngine.RectOffset::get_vertical() void Register_UnityEngine_RectOffset_get_vertical(); Register_UnityEngine_RectOffset_get_vertical(); //System.Void UnityEngine.RectOffset::Cleanup() void Register_UnityEngine_RectOffset_Cleanup(); Register_UnityEngine_RectOffset_Cleanup(); //System.Void UnityEngine.RectOffset::Init() void Register_UnityEngine_RectOffset_Init(); Register_UnityEngine_RectOffset_Init(); //System.Void UnityEngine.RectOffset::set_bottom(System.Int32) void Register_UnityEngine_RectOffset_set_bottom(); Register_UnityEngine_RectOffset_set_bottom(); //System.Void UnityEngine.RectOffset::set_left(System.Int32) void Register_UnityEngine_RectOffset_set_left(); Register_UnityEngine_RectOffset_set_left(); //System.Void UnityEngine.RectOffset::set_right(System.Int32) void Register_UnityEngine_RectOffset_set_right(); Register_UnityEngine_RectOffset_set_right(); //System.Void UnityEngine.RectOffset::set_top(System.Int32) void Register_UnityEngine_RectOffset_set_top(); Register_UnityEngine_RectOffset_set_top(); //End Registrations for type : UnityEngine.RectOffset //Start Registrations for type : UnityEngine.RectTransform //System.Void UnityEngine.RectTransform::INTERNAL_get_anchorMax(UnityEngine.Vector2&) void Register_UnityEngine_RectTransform_INTERNAL_get_anchorMax(); Register_UnityEngine_RectTransform_INTERNAL_get_anchorMax(); //System.Void UnityEngine.RectTransform::INTERNAL_get_anchorMin(UnityEngine.Vector2&) void Register_UnityEngine_RectTransform_INTERNAL_get_anchorMin(); Register_UnityEngine_RectTransform_INTERNAL_get_anchorMin(); //System.Void UnityEngine.RectTransform::INTERNAL_get_anchoredPosition(UnityEngine.Vector2&) void Register_UnityEngine_RectTransform_INTERNAL_get_anchoredPosition(); Register_UnityEngine_RectTransform_INTERNAL_get_anchoredPosition(); //System.Void UnityEngine.RectTransform::INTERNAL_get_pivot(UnityEngine.Vector2&) void Register_UnityEngine_RectTransform_INTERNAL_get_pivot(); Register_UnityEngine_RectTransform_INTERNAL_get_pivot(); //System.Void UnityEngine.RectTransform::INTERNAL_get_rect(UnityEngine.Rect&) void Register_UnityEngine_RectTransform_INTERNAL_get_rect(); Register_UnityEngine_RectTransform_INTERNAL_get_rect(); //System.Void UnityEngine.RectTransform::INTERNAL_get_sizeDelta(UnityEngine.Vector2&) void Register_UnityEngine_RectTransform_INTERNAL_get_sizeDelta(); Register_UnityEngine_RectTransform_INTERNAL_get_sizeDelta(); //System.Void UnityEngine.RectTransform::INTERNAL_set_anchorMax(UnityEngine.Vector2&) void Register_UnityEngine_RectTransform_INTERNAL_set_anchorMax(); Register_UnityEngine_RectTransform_INTERNAL_set_anchorMax(); //System.Void UnityEngine.RectTransform::INTERNAL_set_anchorMin(UnityEngine.Vector2&) void Register_UnityEngine_RectTransform_INTERNAL_set_anchorMin(); Register_UnityEngine_RectTransform_INTERNAL_set_anchorMin(); //System.Void UnityEngine.RectTransform::INTERNAL_set_anchoredPosition(UnityEngine.Vector2&) void Register_UnityEngine_RectTransform_INTERNAL_set_anchoredPosition(); Register_UnityEngine_RectTransform_INTERNAL_set_anchoredPosition(); //System.Void UnityEngine.RectTransform::INTERNAL_set_pivot(UnityEngine.Vector2&) void Register_UnityEngine_RectTransform_INTERNAL_set_pivot(); Register_UnityEngine_RectTransform_INTERNAL_set_pivot(); //System.Void UnityEngine.RectTransform::INTERNAL_set_sizeDelta(UnityEngine.Vector2&) void Register_UnityEngine_RectTransform_INTERNAL_set_sizeDelta(); Register_UnityEngine_RectTransform_INTERNAL_set_sizeDelta(); //End Registrations for type : UnityEngine.RectTransform //Start Registrations for type : UnityEngine.RectTransformUtility //System.Boolean UnityEngine.RectTransformUtility::INTERNAL_CALL_RectangleContainsScreenPoint(UnityEngine.RectTransform,UnityEngine.Vector2&,UnityEngine.Camera) void Register_UnityEngine_RectTransformUtility_INTERNAL_CALL_RectangleContainsScreenPoint(); Register_UnityEngine_RectTransformUtility_INTERNAL_CALL_RectangleContainsScreenPoint(); //System.Void UnityEngine.RectTransformUtility::INTERNAL_CALL_PixelAdjustPoint(UnityEngine.Vector2&,UnityEngine.Transform,UnityEngine.Canvas,UnityEngine.Vector2&) void Register_UnityEngine_RectTransformUtility_INTERNAL_CALL_PixelAdjustPoint(); Register_UnityEngine_RectTransformUtility_INTERNAL_CALL_PixelAdjustPoint(); //System.Void UnityEngine.RectTransformUtility::INTERNAL_CALL_PixelAdjustRect(UnityEngine.RectTransform,UnityEngine.Canvas,UnityEngine.Rect&) void Register_UnityEngine_RectTransformUtility_INTERNAL_CALL_PixelAdjustRect(); Register_UnityEngine_RectTransformUtility_INTERNAL_CALL_PixelAdjustRect(); //End Registrations for type : UnityEngine.RectTransformUtility //Start Registrations for type : UnityEngine.Renderer //System.Int32 UnityEngine.Renderer::get_sortingLayerID() void Register_UnityEngine_Renderer_get_sortingLayerID(); Register_UnityEngine_Renderer_get_sortingLayerID(); //System.Int32 UnityEngine.Renderer::get_sortingOrder() void Register_UnityEngine_Renderer_get_sortingOrder(); Register_UnityEngine_Renderer_get_sortingOrder(); //System.Void UnityEngine.Renderer::set_enabled(System.Boolean) void Register_UnityEngine_Renderer_set_enabled(); Register_UnityEngine_Renderer_set_enabled(); //End Registrations for type : UnityEngine.Renderer //Start Registrations for type : UnityEngine.RenderTexture //System.Int32 UnityEngine.RenderTexture::Internal_GetHeight(UnityEngine.RenderTexture) void Register_UnityEngine_RenderTexture_Internal_GetHeight(); Register_UnityEngine_RenderTexture_Internal_GetHeight(); //System.Int32 UnityEngine.RenderTexture::Internal_GetWidth(UnityEngine.RenderTexture) void Register_UnityEngine_RenderTexture_Internal_GetWidth(); Register_UnityEngine_RenderTexture_Internal_GetWidth(); //End Registrations for type : UnityEngine.RenderTexture //Start Registrations for type : UnityEngine.Resources //UnityEngine.Object UnityEngine.Resources::GetBuiltinResource(System.Type,System.String) void Register_UnityEngine_Resources_GetBuiltinResource(); Register_UnityEngine_Resources_GetBuiltinResource(); //End Registrations for type : UnityEngine.Resources //Start Registrations for type : UnityEngine.Rigidbody //System.Void UnityEngine.Rigidbody::INTERNAL_get_velocity(UnityEngine.Vector3&) void Register_UnityEngine_Rigidbody_INTERNAL_get_velocity(); Register_UnityEngine_Rigidbody_INTERNAL_get_velocity(); //End Registrations for type : UnityEngine.Rigidbody //Start Registrations for type : UnityEngine.Rigidbody2D //System.Void UnityEngine.Rigidbody2D::INTERNAL_CALL_AddForce(UnityEngine.Rigidbody2D,UnityEngine.Vector2&,UnityEngine.ForceMode2D) void Register_UnityEngine_Rigidbody2D_INTERNAL_CALL_AddForce(); Register_UnityEngine_Rigidbody2D_INTERNAL_CALL_AddForce(); //System.Void UnityEngine.Rigidbody2D::INTERNAL_get_velocity(UnityEngine.Vector2&) void Register_UnityEngine_Rigidbody2D_INTERNAL_get_velocity(); Register_UnityEngine_Rigidbody2D_INTERNAL_get_velocity(); //System.Void UnityEngine.Rigidbody2D::INTERNAL_set_velocity(UnityEngine.Vector2&) void Register_UnityEngine_Rigidbody2D_INTERNAL_set_velocity(); Register_UnityEngine_Rigidbody2D_INTERNAL_set_velocity(); //End Registrations for type : UnityEngine.Rigidbody2D //Start Registrations for type : UnityEngine.SceneManagement.SceneManager //UnityEngine.AsyncOperation UnityEngine.SceneManagement.SceneManager::LoadSceneAsyncNameIndexInternal(System.String,System.Int32,System.Boolean,System.Boolean) void Register_UnityEngine_SceneManagement_SceneManager_LoadSceneAsyncNameIndexInternal(); Register_UnityEngine_SceneManagement_SceneManager_LoadSceneAsyncNameIndexInternal(); //End Registrations for type : UnityEngine.SceneManagement.SceneManager //Start Registrations for type : UnityEngine.Screen //System.Int32 UnityEngine.Screen::get_height() void Register_UnityEngine_Screen_get_height(); Register_UnityEngine_Screen_get_height(); //System.Int32 UnityEngine.Screen::get_width() void Register_UnityEngine_Screen_get_width(); Register_UnityEngine_Screen_get_width(); //System.Single UnityEngine.Screen::get_dpi() void Register_UnityEngine_Screen_get_dpi(); Register_UnityEngine_Screen_get_dpi(); //End Registrations for type : UnityEngine.Screen //Start Registrations for type : UnityEngine.ScriptableObject //System.Void UnityEngine.ScriptableObject::Internal_CreateScriptableObject(UnityEngine.ScriptableObject) void Register_UnityEngine_ScriptableObject_Internal_CreateScriptableObject(); Register_UnityEngine_ScriptableObject_Internal_CreateScriptableObject(); //UnityEngine.ScriptableObject UnityEngine.ScriptableObject::CreateInstanceFromType(System.Type) void Register_UnityEngine_ScriptableObject_CreateInstanceFromType(); Register_UnityEngine_ScriptableObject_CreateInstanceFromType(); //End Registrations for type : UnityEngine.ScriptableObject //Start Registrations for type : UnityEngine.Shader //System.Int32 UnityEngine.Shader::PropertyToID(System.String) void Register_UnityEngine_Shader_PropertyToID(); Register_UnityEngine_Shader_PropertyToID(); //End Registrations for type : UnityEngine.Shader //Start Registrations for type : UnityEngine.SortingLayer //System.Int32 UnityEngine.SortingLayer::GetLayerValueFromID(System.Int32) void Register_UnityEngine_SortingLayer_GetLayerValueFromID(); Register_UnityEngine_SortingLayer_GetLayerValueFromID(); //End Registrations for type : UnityEngine.SortingLayer //Start Registrations for type : UnityEngine.SphereCollider //System.Void UnityEngine.SphereCollider::set_radius(System.Single) void Register_UnityEngine_SphereCollider_set_radius(); Register_UnityEngine_SphereCollider_set_radius(); //End Registrations for type : UnityEngine.SphereCollider //Start Registrations for type : UnityEngine.Sprite //System.Boolean UnityEngine.Sprite::get_packed() void Register_UnityEngine_Sprite_get_packed(); Register_UnityEngine_Sprite_get_packed(); //System.Single UnityEngine.Sprite::get_pixelsPerUnit() void Register_UnityEngine_Sprite_get_pixelsPerUnit(); Register_UnityEngine_Sprite_get_pixelsPerUnit(); //System.Void UnityEngine.Sprite::INTERNAL_get_border(UnityEngine.Vector4&) void Register_UnityEngine_Sprite_INTERNAL_get_border(); Register_UnityEngine_Sprite_INTERNAL_get_border(); //System.Void UnityEngine.Sprite::INTERNAL_get_rect(UnityEngine.Rect&) void Register_UnityEngine_Sprite_INTERNAL_get_rect(); Register_UnityEngine_Sprite_INTERNAL_get_rect(); //System.Void UnityEngine.Sprite::INTERNAL_get_textureRect(UnityEngine.Rect&) void Register_UnityEngine_Sprite_INTERNAL_get_textureRect(); Register_UnityEngine_Sprite_INTERNAL_get_textureRect(); //UnityEngine.Texture2D UnityEngine.Sprite::get_associatedAlphaSplitTexture() void Register_UnityEngine_Sprite_get_associatedAlphaSplitTexture(); Register_UnityEngine_Sprite_get_associatedAlphaSplitTexture(); //UnityEngine.Texture2D UnityEngine.Sprite::get_texture() void Register_UnityEngine_Sprite_get_texture(); Register_UnityEngine_Sprite_get_texture(); //End Registrations for type : UnityEngine.Sprite //Start Registrations for type : UnityEngine.Sprites.DataUtility //System.Void UnityEngine.Sprites.DataUtility::INTERNAL_CALL_GetInnerUV(UnityEngine.Sprite,UnityEngine.Vector4&) void Register_UnityEngine_Sprites_DataUtility_INTERNAL_CALL_GetInnerUV(); Register_UnityEngine_Sprites_DataUtility_INTERNAL_CALL_GetInnerUV(); //System.Void UnityEngine.Sprites.DataUtility::INTERNAL_CALL_GetOuterUV(UnityEngine.Sprite,UnityEngine.Vector4&) void Register_UnityEngine_Sprites_DataUtility_INTERNAL_CALL_GetOuterUV(); Register_UnityEngine_Sprites_DataUtility_INTERNAL_CALL_GetOuterUV(); //System.Void UnityEngine.Sprites.DataUtility::INTERNAL_CALL_GetPadding(UnityEngine.Sprite,UnityEngine.Vector4&) void Register_UnityEngine_Sprites_DataUtility_INTERNAL_CALL_GetPadding(); Register_UnityEngine_Sprites_DataUtility_INTERNAL_CALL_GetPadding(); //System.Void UnityEngine.Sprites.DataUtility::Internal_GetMinSize(UnityEngine.Sprite,UnityEngine.Vector2&) void Register_UnityEngine_Sprites_DataUtility_Internal_GetMinSize(); Register_UnityEngine_Sprites_DataUtility_Internal_GetMinSize(); //End Registrations for type : UnityEngine.Sprites.DataUtility //Start Registrations for type : UnityEngine.SystemInfo //UnityEngine.OperatingSystemFamily UnityEngine.SystemInfo::get_operatingSystemFamily() void Register_UnityEngine_SystemInfo_get_operatingSystemFamily(); Register_UnityEngine_SystemInfo_get_operatingSystemFamily(); //End Registrations for type : UnityEngine.SystemInfo //Start Registrations for type : UnityEngine.TextGenerator //System.Boolean UnityEngine.TextGenerator::INTERNAL_CALL_Populate_Internal_cpp(UnityEngine.TextGenerator,System.String,UnityEngine.Font,UnityEngine.Color&,System.Int32,System.Single,System.Single,UnityEngine.FontStyle,System.Boolean,System.Boolean,System.Int32,System.Int32,System.Int32,System.Int32,System.Boolean,UnityEngine.TextAnchor,System.Single,System.Single,System.Single,System.Single,System.Boolean,System.Boolean,System.UInt32&) void Register_UnityEngine_TextGenerator_INTERNAL_CALL_Populate_Internal_cpp(); Register_UnityEngine_TextGenerator_INTERNAL_CALL_Populate_Internal_cpp(); //System.Int32 UnityEngine.TextGenerator::get_characterCount() void Register_UnityEngine_TextGenerator_get_characterCount(); Register_UnityEngine_TextGenerator_get_characterCount(); //System.Int32 UnityEngine.TextGenerator::get_lineCount() void Register_UnityEngine_TextGenerator_get_lineCount(); Register_UnityEngine_TextGenerator_get_lineCount(); //System.Void UnityEngine.TextGenerator::Dispose_cpp() void Register_UnityEngine_TextGenerator_Dispose_cpp(); Register_UnityEngine_TextGenerator_Dispose_cpp(); //System.Void UnityEngine.TextGenerator::GetCharactersInternal(System.Object) void Register_UnityEngine_TextGenerator_GetCharactersInternal(); Register_UnityEngine_TextGenerator_GetCharactersInternal(); //System.Void UnityEngine.TextGenerator::GetLinesInternal(System.Object) void Register_UnityEngine_TextGenerator_GetLinesInternal(); Register_UnityEngine_TextGenerator_GetLinesInternal(); //System.Void UnityEngine.TextGenerator::GetVerticesInternal(System.Object) void Register_UnityEngine_TextGenerator_GetVerticesInternal(); Register_UnityEngine_TextGenerator_GetVerticesInternal(); //System.Void UnityEngine.TextGenerator::INTERNAL_get_rectExtents(UnityEngine.Rect&) void Register_UnityEngine_TextGenerator_INTERNAL_get_rectExtents(); Register_UnityEngine_TextGenerator_INTERNAL_get_rectExtents(); //System.Void UnityEngine.TextGenerator::Init() void Register_UnityEngine_TextGenerator_Init(); Register_UnityEngine_TextGenerator_Init(); //End Registrations for type : UnityEngine.TextGenerator //Start Registrations for type : UnityEngine.Texture //System.Int32 UnityEngine.Texture::Internal_GetHeight(UnityEngine.Texture) void Register_UnityEngine_Texture_Internal_GetHeight(); Register_UnityEngine_Texture_Internal_GetHeight(); //System.Int32 UnityEngine.Texture::Internal_GetWidth(UnityEngine.Texture) void Register_UnityEngine_Texture_Internal_GetWidth(); Register_UnityEngine_Texture_Internal_GetWidth(); //System.Void UnityEngine.Texture::INTERNAL_get_texelSize(UnityEngine.Vector2&) void Register_UnityEngine_Texture_INTERNAL_get_texelSize(); Register_UnityEngine_Texture_INTERNAL_get_texelSize(); //UnityEngine.TextureWrapMode UnityEngine.Texture::get_wrapMode() void Register_UnityEngine_Texture_get_wrapMode(); Register_UnityEngine_Texture_get_wrapMode(); //End Registrations for type : UnityEngine.Texture //Start Registrations for type : UnityEngine.Texture2D //System.Void UnityEngine.Texture2D::INTERNAL_CALL_GetPixelBilinear(UnityEngine.Texture2D,System.Single,System.Single,UnityEngine.Color&) void Register_UnityEngine_Texture2D_INTERNAL_CALL_GetPixelBilinear(); Register_UnityEngine_Texture2D_INTERNAL_CALL_GetPixelBilinear(); //UnityEngine.Texture2D UnityEngine.Texture2D::get_whiteTexture() void Register_UnityEngine_Texture2D_get_whiteTexture(); Register_UnityEngine_Texture2D_get_whiteTexture(); //End Registrations for type : UnityEngine.Texture2D //Start Registrations for type : UnityEngine.Time //System.Int32 UnityEngine.Time::get_frameCount() void Register_UnityEngine_Time_get_frameCount(); Register_UnityEngine_Time_get_frameCount(); //System.Single UnityEngine.Time::get_deltaTime() void Register_UnityEngine_Time_get_deltaTime(); Register_UnityEngine_Time_get_deltaTime(); //System.Single UnityEngine.Time::get_fixedDeltaTime() void Register_UnityEngine_Time_get_fixedDeltaTime(); Register_UnityEngine_Time_get_fixedDeltaTime(); //System.Single UnityEngine.Time::get_maximumDeltaTime() void Register_UnityEngine_Time_get_maximumDeltaTime(); Register_UnityEngine_Time_get_maximumDeltaTime(); //System.Single UnityEngine.Time::get_realtimeSinceStartup() void Register_UnityEngine_Time_get_realtimeSinceStartup(); Register_UnityEngine_Time_get_realtimeSinceStartup(); //System.Single UnityEngine.Time::get_time() void Register_UnityEngine_Time_get_time(); Register_UnityEngine_Time_get_time(); //System.Single UnityEngine.Time::get_timeScale() void Register_UnityEngine_Time_get_timeScale(); Register_UnityEngine_Time_get_timeScale(); //System.Single UnityEngine.Time::get_unscaledDeltaTime() void Register_UnityEngine_Time_get_unscaledDeltaTime(); Register_UnityEngine_Time_get_unscaledDeltaTime(); //System.Single UnityEngine.Time::get_unscaledTime() void Register_UnityEngine_Time_get_unscaledTime(); Register_UnityEngine_Time_get_unscaledTime(); //System.Void UnityEngine.Time::set_timeScale(System.Single) void Register_UnityEngine_Time_set_timeScale(); Register_UnityEngine_Time_set_timeScale(); //End Registrations for type : UnityEngine.Time //Start Registrations for type : UnityEngine.Transform //System.Boolean UnityEngine.Transform::IsChildOf(UnityEngine.Transform) void Register_UnityEngine_Transform_IsChildOf(); Register_UnityEngine_Transform_IsChildOf(); //System.Int32 UnityEngine.Transform::get_childCount() void Register_UnityEngine_Transform_get_childCount(); Register_UnityEngine_Transform_get_childCount(); //System.Void UnityEngine.Transform::INTERNAL_CALL_InverseTransformPoint(UnityEngine.Transform,UnityEngine.Vector3&,UnityEngine.Vector3&) void Register_UnityEngine_Transform_INTERNAL_CALL_InverseTransformPoint(); Register_UnityEngine_Transform_INTERNAL_CALL_InverseTransformPoint(); //System.Void UnityEngine.Transform::INTERNAL_CALL_TransformDirection(UnityEngine.Transform,UnityEngine.Vector3&,UnityEngine.Vector3&) void Register_UnityEngine_Transform_INTERNAL_CALL_TransformDirection(); Register_UnityEngine_Transform_INTERNAL_CALL_TransformDirection(); //System.Void UnityEngine.Transform::INTERNAL_CALL_TransformPoint(UnityEngine.Transform,UnityEngine.Vector3&,UnityEngine.Vector3&) void Register_UnityEngine_Transform_INTERNAL_CALL_TransformPoint(); Register_UnityEngine_Transform_INTERNAL_CALL_TransformPoint(); //System.Void UnityEngine.Transform::INTERNAL_get_localPosition(UnityEngine.Vector3&) void Register_UnityEngine_Transform_INTERNAL_get_localPosition(); Register_UnityEngine_Transform_INTERNAL_get_localPosition(); //System.Void UnityEngine.Transform::INTERNAL_get_localRotation(UnityEngine.Quaternion&) void Register_UnityEngine_Transform_INTERNAL_get_localRotation(); Register_UnityEngine_Transform_INTERNAL_get_localRotation(); //System.Void UnityEngine.Transform::INTERNAL_get_localScale(UnityEngine.Vector3&) void Register_UnityEngine_Transform_INTERNAL_get_localScale(); Register_UnityEngine_Transform_INTERNAL_get_localScale(); //System.Void UnityEngine.Transform::INTERNAL_get_localToWorldMatrix(UnityEngine.Matrix4x4&) void Register_UnityEngine_Transform_INTERNAL_get_localToWorldMatrix(); Register_UnityEngine_Transform_INTERNAL_get_localToWorldMatrix(); //System.Void UnityEngine.Transform::INTERNAL_get_position(UnityEngine.Vector3&) void Register_UnityEngine_Transform_INTERNAL_get_position(); Register_UnityEngine_Transform_INTERNAL_get_position(); //System.Void UnityEngine.Transform::INTERNAL_get_rotation(UnityEngine.Quaternion&) void Register_UnityEngine_Transform_INTERNAL_get_rotation(); Register_UnityEngine_Transform_INTERNAL_get_rotation(); //System.Void UnityEngine.Transform::INTERNAL_get_worldToLocalMatrix(UnityEngine.Matrix4x4&) void Register_UnityEngine_Transform_INTERNAL_get_worldToLocalMatrix(); Register_UnityEngine_Transform_INTERNAL_get_worldToLocalMatrix(); //System.Void UnityEngine.Transform::INTERNAL_set_localPosition(UnityEngine.Vector3&) void Register_UnityEngine_Transform_INTERNAL_set_localPosition(); Register_UnityEngine_Transform_INTERNAL_set_localPosition(); //System.Void UnityEngine.Transform::INTERNAL_set_localRotation(UnityEngine.Quaternion&) void Register_UnityEngine_Transform_INTERNAL_set_localRotation(); Register_UnityEngine_Transform_INTERNAL_set_localRotation(); //System.Void UnityEngine.Transform::INTERNAL_set_localScale(UnityEngine.Vector3&) void Register_UnityEngine_Transform_INTERNAL_set_localScale(); Register_UnityEngine_Transform_INTERNAL_set_localScale(); //System.Void UnityEngine.Transform::INTERNAL_set_position(UnityEngine.Vector3&) void Register_UnityEngine_Transform_INTERNAL_set_position(); Register_UnityEngine_Transform_INTERNAL_set_position(); //System.Void UnityEngine.Transform::INTERNAL_set_rotation(UnityEngine.Quaternion&) void Register_UnityEngine_Transform_INTERNAL_set_rotation(); Register_UnityEngine_Transform_INTERNAL_set_rotation(); //System.Void UnityEngine.Transform::SetAsFirstSibling() void Register_UnityEngine_Transform_SetAsFirstSibling(); Register_UnityEngine_Transform_SetAsFirstSibling(); //System.Void UnityEngine.Transform::SetParent(UnityEngine.Transform,System.Boolean) void Register_UnityEngine_Transform_SetParent(); Register_UnityEngine_Transform_SetParent(); //System.Void UnityEngine.Transform::set_parentInternal(UnityEngine.Transform) void Register_UnityEngine_Transform_set_parentInternal(); Register_UnityEngine_Transform_set_parentInternal(); //UnityEngine.Transform UnityEngine.Transform::Find(System.String) void Register_UnityEngine_Transform_Find(); Register_UnityEngine_Transform_Find(); //UnityEngine.Transform UnityEngine.Transform::GetChild(System.Int32) void Register_UnityEngine_Transform_GetChild(); Register_UnityEngine_Transform_GetChild(); //UnityEngine.Transform UnityEngine.Transform::get_parentInternal() void Register_UnityEngine_Transform_get_parentInternal(); Register_UnityEngine_Transform_get_parentInternal(); //End Registrations for type : UnityEngine.Transform //Start Registrations for type : UnityEngine.U2D.SpriteAtlasManager //System.Void UnityEngine.U2D.SpriteAtlasManager::Register(UnityEngine.U2D.SpriteAtlas) void Register_UnityEngine_U2D_SpriteAtlasManager_Register(); Register_UnityEngine_U2D_SpriteAtlasManager_Register(); //End Registrations for type : UnityEngine.U2D.SpriteAtlasManager //Start Registrations for type : UnityEngine.UISystemProfilerApi //System.Void UnityEngine.UISystemProfilerApi::AddMarker(System.String,UnityEngine.Object) void Register_UnityEngine_UISystemProfilerApi_AddMarker(); Register_UnityEngine_UISystemProfilerApi_AddMarker(); //System.Void UnityEngine.UISystemProfilerApi::BeginSample(UnityEngine.UISystemProfilerApi/SampleType) void Register_UnityEngine_UISystemProfilerApi_BeginSample(); Register_UnityEngine_UISystemProfilerApi_BeginSample(); //System.Void UnityEngine.UISystemProfilerApi::EndSample(UnityEngine.UISystemProfilerApi/SampleType) void Register_UnityEngine_UISystemProfilerApi_EndSample(); Register_UnityEngine_UISystemProfilerApi_EndSample(); //End Registrations for type : UnityEngine.UISystemProfilerApi //Start Registrations for type : UnityEngine.Vector3 //System.Void UnityEngine.Vector3::INTERNAL_CALL_Slerp(UnityEngine.Vector3&,UnityEngine.Vector3&,System.Single,UnityEngine.Vector3&) void Register_UnityEngine_Vector3_INTERNAL_CALL_Slerp(); Register_UnityEngine_Vector3_INTERNAL_CALL_Slerp(); //End Registrations for type : UnityEngine.Vector3 }
[ "Maninder786@users.noreply.github.com" ]
Maninder786@users.noreply.github.com
df20a6b673aa871d0b13e121e1be6b7e1ca52dec
2c4897b8b977e066a3cc546d36d2dd1c52a72462
/src/hashstring.h
9f67c70f92fb68119557dc875ed445b5cfcf29d6
[ "Apache-2.0" ]
permissive
Vethanis/image_decompiler
fa7ead61e139f200207f63e27a3c19928a58867f
0bc471a0d4ab83c8a9a77a12b0fe601b57b6c133
refs/heads/master
2023-07-20T13:55:57.038723
2018-08-27T08:31:48
2018-08-27T08:31:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,262
h
#pragma once #define _CRT_SECURE_NO_WARNINGS #include <cstdio> #include <cassert> #include <cstring> struct HashString{ unsigned m_hash; const char* str() const; bool valid()const{ return m_hash != 0; } HashString(){m_hash = 0;} HashString(unsigned hash){m_hash = hash;} HashString(const char* str); HashString operator = (HashString o) { m_hash = o.m_hash; return *this; } HashString operator = (const char* str) { *this = HashString(str); return *this; } HashString operator = (unsigned hash) { m_hash = hash; return *this; } operator unsigned () const { return m_hash; } operator const char* () const { return str(); } bool operator==(HashString other)const{ return m_hash == other.m_hash; } template<typename T> operator T* () const; void serialize(FILE* pFile){ const char* s = str(); assert(s); const unsigned len = (unsigned)strlen(s); fwrite(&len, sizeof(unsigned), 1, pFile); fwrite(s, 1, len, pFile); } void load(FILE* pFile){ unsigned len = 0; fread(&len, sizeof(unsigned), 1, pFile); char* buf = new char[len + 1]; fread(buf, 1, len, pFile); buf[len] = 0; *this = HashString(buf); } };
[ "lh0xfb@gmail.com" ]
lh0xfb@gmail.com
dba0e763aaaa079a37c39dc32599e7a7b14229f1
de96cb2f51ba7e2fb8ff1a86fff42b1ee6dd813f
/ebbFlood/ebbFlood.ino
f0051770251e2cf536a99259b8d490caa6f9c50a
[]
no_license
mauricebasement/sketchbook
cd222497845dd7f671d8de47306310968328eecf
8fc72a48ec566460788277436b1b9a1eb06f5e19
refs/heads/master
2021-01-10T07:25:47.405121
2018-08-24T11:43:06
2018-08-24T11:43:06
54,292,802
0
0
null
null
null
null
UTF-8
C++
false
false
680
ino
#define RELAY_PIN 2 #define SENSOR_PIN A0 #define COUNT 21600 #define DELAY 1000 int counter = 0; void setup() { Serial.begin(115200); //debugging pinMode(RELAY_PIN,OUTPUT); pinMode(SENSOR_PIN,INPUT); digitalWrite(RELAY_PIN,HIGH); } void loop() { if (counter==COUNT) { counter = 0; flooding(); } else { counter++; } delay(DELAY); } boolean checkSensor() { int sensor = analogRead(SENSOR_PIN); Serial.println(sensor); if(sensor>200) { return true; } else { return false; } } void flooding() { digitalWrite(RELAY_PIN,LOW); while (checkSensor() == false) { Serial.println("Flooding"); } digitalWrite(RELAY_PIN,HIGH); }
[ "makers@posteo.ch" ]
makers@posteo.ch
2ab81787e685e40a7b7da71d4e552a2513de7db3
e2fc091e990a0647ad9bd066c8cb879b9572102b
/nhd2-exp/src/gui/channellist.cpp
cfa1b62b6befe7805c2ef37818a625eadedcee18
[]
no_license
crayzy13/neutrinohd2
65c69d46df28df61d1617457f25d25ae00dfa5a8
ca2a9998d69b81b61893d697f3b8c054c83f6aa7
refs/heads/master
2021-06-21T13:51:31.119937
2017-08-27T10:34:28
2017-08-27T10:34:28
110,340,174
0
1
null
2017-11-11T11:29:38
2017-11-11T11:29:38
null
UTF-8
C++
false
false
55,907
cpp
/* Neutrino-GUI - DBoxII-Project $Id: channellist.cpp 2013/10/12 mohousch Exp $ Copyright (C) 2001 Steffen Hehn 'McClean' Homepage: http://dbox.cyberphoria.org/ Kommentar: Diese GUI wurde von Grund auf neu programmiert und sollte nun vom Aufbau und auch den Ausbaumoeglichkeiten gut aussehen. Neutrino basiert auf der Client-Server Idee, diese GUI ist also von der direkten DBox- Steuerung getrennt. Diese wird dann von Daemons uebernommen. License: GPL 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. */ #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <gui/channellist.h> #include <global.h> #include <neutrino.h> #include <driver/fontrenderer.h> #include <driver/screen_max.h> #include <driver/rcinput.h> #include <gui/color.h> #include <gui/eventlist.h> #include <gui/infoviewer.h> #include <gui/widget/buttons.h> #include <gui/widget/icons.h> #include <gui/widget/menue.h> #include <gui/widget/messagebox.h> #include <gui/widget/items2detailsline.h> #include <system/settings.h> #include <system/lastchannel.h> #include "gui/filebrowser.h" #include <gui/bouquetlist.h> #include <daemonc/remotecontrol.h> #include <driver/vcrcontrol.h> #include <gui/pictureviewer.h> // #include <bouquets.h> #include <satconfig.h> #include <getservices.h> #include <frontend_c.h> #include <gui/epgplus.h> #include <system/debug.h> #include <video_cs.h> #include <misc_setup.h> extern CBouquetList * bouquetList; // neutrino.cpp extern CRemoteControl * g_RemoteControl; // neutrino.cpp // defined in neutrino extern CBouquetList * TVbouquetList; extern CBouquetList * TVsatList; extern CBouquetList * TVfavList; extern CBouquetList * TVallList; extern CBouquetList * RADIObouquetList; extern CBouquetList * RADIOsatList; extern CBouquetList * RADIOfavList; extern CBouquetList * RADIOallList; extern t_channel_id rec_channel_id; extern t_channel_id live_channel_id; bool pip_selected = false; extern bool autoshift; int info_height = 0; bool new_mode_active = 0; extern int FrontendCount; // defined in zapit.cpp extern bool CanZap(CZapitChannel * thischannel); extern CBouquetManager * g_bouquetManager; extern cVideo * videoDecoder; extern CZapitChannel * live_channel; /* events */ void sectionsd_getChannelEvents(CChannelEventList &eList, const bool tv_mode, t_channel_id *chidlist, int clen); void sectionsd_getEventsServiceKey(t_channel_id serviceUniqueKey, CChannelEventList &eList, char search = 0, std::string search_text = ""); // void addChannelToBouquet(const unsigned int bouquet, const t_channel_id channel_id); // defined in zapit.cpp extern int old_b_id; CChannelList::CChannelList(const char * const Name, bool _historyMode, bool _vlist) { frameBuffer = CFrameBuffer::getInstance(); name = Name; selected = 0; liststart = 0; tuned = 0xfffffff; zapProtection = NULL; this->historyMode = _historyMode; vlist = _vlist; //buttonHeight icons (red) frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_RED, &icon_footer_w, &icon_footer_h); // head icons (zap_mute) frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_MUTE_ZAP_INACTIVE, &icon_head_w, &icon_head_h); // scrambled frameBuffer->getIconSize(NEUTRINO_ICON_SCRAMBLED, &icon_ca_w, &icon_ca_h); // hd frameBuffer->getIconSize(NEUTRINO_ICON_HD, &icon_hd_w, &icon_hd_h); // icon help frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_HELP, &icon_help_w, &icon_help_h); // icon setup icon_setup_h = 16; frameBuffer->getIconSize(NEUTRINO_ICON_BUTTON_SETUP, &icon_setup_w, &icon_setup_h); } CChannelList::~CChannelList() { chanlist.clear(); } void CChannelList::ClearList(void) { chanlist.clear(); chanlist.resize(1); } void CChannelList::setSize(int newsize) { chanlist.reserve(newsize); } void CChannelList::addChannel(CZapitChannel * channel, int num) { if(num) channel->number = num; chanlist.push_back(channel); } void CChannelList::putChannel(CZapitChannel * channel) { int num = channel->number - 1; if(num < 0) { return; } if(num >= (int) chanlist.size()) { chanlist.resize((unsigned) num + 1); } chanlist[num] = channel; } void CChannelList::updateEvents(void) { CChannelEventList events; if (displayNext) { if (chanlist.size()) { time_t atime = time(NULL); unsigned int count; for (count = 0; count < chanlist.size(); count++) { // events.clear(); sectionsd_getEventsServiceKey(chanlist[count]->channel_id, events); chanlist[count]->nextEvent.startTime = (long)0x7fffffff; for ( CChannelEventList::iterator e = events.begin(); e != events.end(); ++e ) { if (((long)(e->startTime) > atime) && ((e->startTime) < (long)(chanlist[count]->nextEvent.startTime))) { chanlist[count]->nextEvent= *e; break; } } } } } else { t_channel_id * p_requested_channels = NULL; int size_requested_channels = 0; if (chanlist.size()) { size_requested_channels = chanlist.size()*sizeof(t_channel_id); p_requested_channels = (t_channel_id*)malloc(size_requested_channels); for (uint32_t count = 0; count < chanlist.size(); count++) { p_requested_channels[count] = chanlist[count]->channel_id&0xFFFFFFFFFFFFULL; } CChannelEventList pevents; sectionsd_getChannelEvents(pevents, (CNeutrinoApp::getInstance()->getMode()) != NeutrinoMessages::mode_radio, p_requested_channels, size_requested_channels); for (uint32_t count = 0; count < chanlist.size(); count++) { chanlist[count]->currentEvent = CChannelEvent(); for ( CChannelEventList::iterator e = pevents.begin(); e != pevents.end(); ++e ) { if ((chanlist[count]->channel_id&0xFFFFFFFFFFFFULL) == e->get_channel_id()) { chanlist[count]->currentEvent= *e; break; } } } if (p_requested_channels != NULL) free(p_requested_channels); } } events.clear(); } struct CmpChannelBySat: public binary_function <const CZapitChannel * const, const CZapitChannel * const, bool> { static bool comparetolower(const char a, const char b) { return tolower(a) < tolower(b); }; bool operator() (const CZapitChannel * const c1, const CZapitChannel * const c2) { if(c1->getSatellitePosition() == c2->getSatellitePosition()) return std::lexicographical_compare(c1->getName().begin(), c1->getName().end(), c2->getName().begin(), c2->getName().end(), comparetolower); else return c1->getSatellitePosition() < c2->getSatellitePosition(); ; }; }; struct CmpChannelByFreq: public binary_function <const CZapitChannel * const, const CZapitChannel * const, bool> { static bool comparetolower(const char a, const char b) { return tolower(a) < tolower(b); }; bool operator() (const CZapitChannel * const c1, const CZapitChannel * const c2) { if(c1->getFreqId() == c2->getFreqId()) return std::lexicographical_compare(c1->getName().begin(), c1->getName().end(), c2->getName().begin(), c2->getName().end(), comparetolower); else return c1->getFreqId() < c2->getFreqId(); ; }; }; void CChannelList::SortAlpha(void) { sort(chanlist.begin(), chanlist.end(), CmpChannelByChName()); } void CChannelList::SortSat(void) { sort(chanlist.begin(), chanlist.end(), CmpChannelBySat()); } CZapitChannel * CChannelList::getChannel(int number) { for (uint32_t i = 0; i< chanlist.size();i++) { if (chanlist[i]->number == number) return chanlist[i]; } return(NULL); } CZapitChannel * CChannelList::getChannel(t_channel_id channel_id) { for (uint32_t i = 0; i< chanlist.size();i++) { if (chanlist[i]->channel_id == channel_id) return chanlist[i]; } return(NULL); } int CChannelList::getKey(int id) { return chanlist[id]->number; } static const std::string empty_string; const std::string & CChannelList::getActiveChannelName(void) const { if (selected < chanlist.size()) return chanlist[selected]->name; else return empty_string; } t_satellite_position CChannelList::getActiveSatellitePosition(void) const { if (selected < chanlist.size()) return chanlist[selected]->getSatellitePosition(); else return 0; } t_channel_id CChannelList::getActiveChannel_ChannelID(void) const { if (selected < chanlist.size()) { //printf("CChannelList::getActiveChannel_ChannelID me %x selected = %d %llx\n", (int) this, selected, chanlist[selected]->channel_id); return chanlist[selected]->channel_id; } else return 0; } int CChannelList::getActiveChannelNumber(void) const { return (selected + 1); } int CChannelList::doChannelMenu(void) { int i = 0; int select = -1; static int old_selected = 0; signed int bouquet_id, old_bouquet_id, new_bouquet_id; int result; char cnt[5]; t_channel_id channel_id; if( !bouquetList ) return 0; CMenuWidget * menu = new CMenuWidget(LOCALE_CHANNELLIST_EDIT, NEUTRINO_ICON_SETTINGS); menu->enableSaveScreen(true); menu->disableMenuPosition(); CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select); sprintf(cnt, "%d", i); menu->addItem(new CMenuForwarder(LOCALE_BOUQUETEDITOR_DELETE, true, NULL, selector, cnt, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED), old_selected == i++); sprintf(cnt, "%d", i); menu->addItem(new CMenuForwarder(LOCALE_BOUQUETEDITOR_MOVE, true, NULL, selector, cnt, CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN), old_selected == i++); sprintf(cnt, "%d", i); menu->addItem(new CMenuForwarder(LOCALE_EXTRA_ADD_TO_BOUQUET, true, NULL, selector, cnt, CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW), old_selected == i++); sprintf(cnt, "%d", i); menu->addItem(new CMenuForwarder(LOCALE_FAVORITES_MENUEADD, true, NULL, selector, cnt, CRCInput::RC_blue, NEUTRINO_ICON_BUTTON_BLUE), old_selected == i++); menu->exec(NULL, ""); delete menu; delete selector; if(select >= 0) { hide(); old_selected = select; channel_id = chanlist[selected]->channel_id; switch(select) { case 0: //delete //hide(); result = MessageBox( LOCALE_BOUQUETEDITOR_DELETE, "Delete channel from bouquet?", CMessageBox::mbrNo, CMessageBox::mbYes | CMessageBox::mbNo ); if(result == CMessageBox::mbrYes) { bouquet_id = bouquetList->getActiveBouquetNumber(); bouquet_id = g_bouquetManager->existsBouquet(bouquetList->Bouquets[bouquet_id]->channelList->getName()); if (bouquet_id == -1) return 0; if(g_bouquetManager->existsChannelInBouquet(bouquet_id, channel_id)) { g_bouquetManager->Bouquets[bouquet_id]->removeService(channel_id); return 1; } } break; case 1: // move old_bouquet_id = bouquetList->getActiveBouquetNumber(); old_bouquet_id = g_bouquetManager->existsBouquet(bouquetList->Bouquets[old_bouquet_id]->channelList->getName()); do { new_bouquet_id = bouquetList->exec(false); } while(new_bouquet_id == -3); hide(); if(new_bouquet_id < 0) return 0; new_bouquet_id = g_bouquetManager->existsBouquet(bouquetList->Bouquets[new_bouquet_id]->channelList->getName()); if ((new_bouquet_id == -1) || (new_bouquet_id == old_bouquet_id)) return 0; if(!g_bouquetManager->existsChannelInBouquet(new_bouquet_id, channel_id)) { addChannelToBouquet(new_bouquet_id, channel_id); } if(g_bouquetManager->existsChannelInBouquet(old_bouquet_id, channel_id)) { g_bouquetManager->Bouquets[old_bouquet_id]->removeService(channel_id); } return 1; break; case 2: // add to do { bouquet_id = bouquetList->exec(false); } while(bouquet_id == -3); hide(); if(bouquet_id < 0) return 0; bouquet_id = g_bouquetManager->existsBouquet(bouquetList->Bouquets[bouquet_id]->channelList->getName()); if (bouquet_id == -1) return 0; if(!g_bouquetManager->existsChannelInBouquet(bouquet_id, channel_id)) { addChannelToBouquet(bouquet_id, channel_id); return 1; } break; case 3: // add to my favorites bouquet_id = g_bouquetManager->existsUBouquet(g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME), true); if(bouquet_id == -1) { g_bouquetManager->addBouquet(g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME), true); bouquet_id = g_bouquetManager->existsUBouquet(g_Locale->getText(LOCALE_FAVORITES_BOUQUETNAME), true); } if(!g_bouquetManager->existsChannelInBouquet(bouquet_id, channel_id)) { addChannelToBouquet(bouquet_id, channel_id); return 1; } break; default: break; } } return 0; } int CChannelList::exec() { dprintf(DEBUG_NORMAL, "CChannelList::exec\n"); displayNext = 0; // always start with current events int nNewChannel = show(); // zapto if ( nNewChannel > -1 && nNewChannel < (int) chanlist.size()) CNeutrinoApp::getInstance()->channelList->zapTo(getKey(nNewChannel)-1); return nNewChannel; } #define CHANNEL_SMSKEY_TIMEOUT 800 //return: >= 0 to zap, -1 on cancel, -3 on list mode change, -4 list edited, -2 zap but no restore old list/chan int CChannelList::show() { dprintf(DEBUG_NORMAL, "CChannelList::show\n"); neutrino_msg_t msg; neutrino_msg_data_t data; bool actzap = 0; int res = -1; new_mode_active = 0; // windows size width = w_max( (frameBuffer->getScreenWidth() / 20 * 17), (frameBuffer->getScreenWidth() / 20 )); height = h_max( (frameBuffer->getScreenHeight() / 20 * 16), (frameBuffer->getScreenHeight() / 20)); // display channame in vfd CVFD::getInstance()->setMode(CVFD::MODE_MENU_UTF8 ); //buttonHeight buttonHeight = std::max(icon_footer_h, g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL]->getHeight()) + 10; // title height theight = std::max(icon_head_h, g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight()) + 6; //item/listbox iheight = std::max(icon_ca_h, g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight()) + 2; listmaxshow = (height - theight - buttonHeight)/iheight; // recalculate height height = theight + buttonHeight + listmaxshow * iheight; // info height info_height = 5 + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight() + 5 + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getHeight() + 5; x = frameBuffer->getScreenX() + (frameBuffer->getScreenWidth() - (width + ConnectLineBox_Width)) / 2 + ConnectLineBox_Width; y = frameBuffer->getScreenY() + (frameBuffer->getScreenHeight() - (height + info_height)) / 2; displayNext = false; // head paintHead(); // update events updateEvents(); // paint all paint(); frameBuffer->blit(); int oldselected = selected; int zapOnExit = false; bool bShowBouquetList = false; // add sec timer sec_timer_id = g_RCInput->addTimer(1*1000*1000, false); // loop control unsigned long long timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_CHANLIST]); bool loop = true; while (loop) { g_RCInput->getMsgAbsoluteTimeout(&msg, &data, &timeoutEnd ); if ( msg <= CRCInput::RC_MaxRC ) timeoutEnd = CRCInput::calcTimeoutEnd(g_settings.timing[SNeutrinoSettings::TIMING_CHANLIST]); if ( ( msg == CRCInput::RC_timeout ) || ( msg == (neutrino_msg_t)g_settings.key_channelList_cancel) ) { if(!actzap) selected = oldselected; loop = false; res = -1; } else if ((msg == CRCInput::RC_red) || (msg == CRCInput::RC_epg)) // epg { hide(); if ( g_EventList->exec(chanlist[selected]->channel_id, chanlist[selected]->name) == menu_return::RETURN_EXIT_ALL) { res = -2; loop = false; } paintHead(); paint(); } else if ( msg == CRCInput::RC_yellow && ( bouquetList != NULL ) ) //bouquets { //FIXME: show bqt list bShowBouquetList = true; loop = false; } else if( msg == CRCInput::RC_blue ) //epgplus { hide(); CEPGplusHandler eplus; eplus.exec(NULL, ""); //FIXME: think about this ??? //loop = false; paintHead(); updateEvents(); paint(); } else if ( msg == CRCInput::RC_sat || msg == CRCInput::RC_favorites) { g_RCInput->postMsg (msg, 0); loop = false; res = -1; } else if ( msg == CRCInput::RC_setup ) { // chan list setup (add/move) old_b_id = bouquetList->getActiveBouquetNumber(); int ret = doChannelMenu(); if(ret) { res = -4; loop = false; } else { old_b_id = -1; paintHead(); paint(); } } else if (msg == (neutrino_msg_t) g_settings.key_list_start) { selected = 0; liststart = (selected/listmaxshow)*listmaxshow; paint(); if(new_mode_active) { actzap = true; zapTo(selected); } } else if (msg == (neutrino_msg_t) g_settings.key_list_end) { selected=chanlist.size()-1; liststart = (selected/listmaxshow)*listmaxshow; paint(); if(new_mode_active) { actzap = true; zapTo(selected); } } else if ( msg == CRCInput::RC_up || (int) msg == g_settings.key_channelList_pageup ) { int step = 0; int prev_selected = selected; step = ((int) msg == g_settings.key_channelList_pageup) ? listmaxshow : 1; // browse or step 1 selected -= step; if((prev_selected-step) < 0) // because of uint selected = chanlist.size() - 1; paintItem(prev_selected - liststart); unsigned int oldliststart = liststart; liststart = (selected/listmaxshow)*listmaxshow; if(oldliststart!=liststart) paint(); else paintItem(selected - liststart); if(new_mode_active) { actzap = true; zapTo(selected); } } else if ( msg == CRCInput::RC_down || (int) msg == g_settings.key_channelList_pagedown ) { unsigned int step = 0; int prev_selected = selected; step = ((int) msg == g_settings.key_channelList_pagedown) ? listmaxshow : 1; // browse or step 1 selected += step; if(selected >= chanlist.size()) { if (((chanlist.size() / listmaxshow) + 1) * listmaxshow == chanlist.size() + listmaxshow) // last page has full entries selected = 0; else selected = ((step == listmaxshow) && (selected < (((chanlist.size() / listmaxshow)+1) * listmaxshow))) ? (chanlist.size() - 1) : 0; } paintItem(prev_selected - liststart); unsigned int oldliststart = liststart; liststart = (selected/listmaxshow)*listmaxshow; if(oldliststart!=liststart) paint(); else paintItem(selected - liststart); if(new_mode_active) { actzap = true; zapTo(selected); } } else if ((msg == (neutrino_msg_t)g_settings.key_bouquet_up) && (bouquetList != NULL)) { if (bouquetList->Bouquets.size() > 0) { bool found = true; uint32_t nNext = (bouquetList->getActiveBouquetNumber()+1) % bouquetList->Bouquets.size(); if(bouquetList->Bouquets[nNext]->channelList->getSize() <= 0) { found = false; nNext = nNext < bouquetList->Bouquets.size() - 1 ? nNext + 1 : 0; for(uint32_t i = nNext; i < bouquetList->Bouquets.size(); i++) { if(bouquetList->Bouquets[i]->channelList->getSize() > 0) { found = true; nNext = i; break; } } } if(found) { bouquetList->activateBouquet(nNext, false); res = bouquetList->showChannelList(); loop = false; } } } else if ((msg == (neutrino_msg_t)g_settings.key_bouquet_down) && (bouquetList != NULL)) { if (bouquetList->Bouquets.size() > 0) { bool found = true; int nNext = (bouquetList->getActiveBouquetNumber()+bouquetList->Bouquets.size()-1) % bouquetList->Bouquets.size(); if(bouquetList->Bouquets[nNext]->channelList->getSize() <= 0) { found = false; nNext = nNext > 0 ? nNext-1 : bouquetList->Bouquets.size()-1; for(int i = nNext; i > 0; i--) { if(bouquetList->Bouquets[i]->channelList->getSize() > 0) { found = true; nNext = i; break; } } } if(found) { bouquetList->activateBouquet(nNext, false); res = bouquetList->showChannelList(); loop = false; } } } else if ( msg == CRCInput::RC_ok ) { zapOnExit = true; loop = false; } else if ( msg == CRCInput::RC_spkr ) { new_mode_active = (new_mode_active ? 0 : 1); paintHead(); } else if (CRCInput::isNumeric(msg) && ( this->historyMode || g_settings.sms_channel)) { if (this->historyMode) { selected = CRCInput::getNumericValue(msg); zapOnExit = true; loop = false; } else if(g_settings.sms_channel) { uint32_t i; unsigned char smsKey = 0; c_SMSKeyInput.setTimeout(CHANNEL_SMSKEY_TIMEOUT); do { smsKey = c_SMSKeyInput.handleMsg(msg); dprintf(DEBUG_INFO, "SMS new key: %c\n", smsKey); g_RCInput->getMsg_ms(&msg, &data, CHANNEL_SMSKEY_TIMEOUT - 100); } while ((msg >= CRCInput::RC_1) && (msg <= CRCInput::RC_9)); if (msg == CRCInput::RC_timeout || msg == CRCInput::RC_nokey) { for(i = selected + 1; i < chanlist.size(); i++) { char firstCharOfTitle = chanlist[i]->name.c_str()[0]; if(tolower(firstCharOfTitle) == smsKey) { break; } } if(i >= chanlist.size()) { for(i = 0; i < chanlist.size(); i++) { char firstCharOfTitle = chanlist[i]->name.c_str()[0]; if(tolower(firstCharOfTitle) == smsKey) { break; } } } if(i < chanlist.size()) { int prevselected = selected; selected = i; paintItem(prevselected - liststart); unsigned int oldliststart = liststart; liststart = (selected/listmaxshow)*listmaxshow; if(oldliststart!=liststart) { paint(); } else { paintItem(selected - liststart); } } c_SMSKeyInput.resetOldKey(); } } } else if(CRCInput::isNumeric(msg)) { //pushback key if... selected = oldselected; g_RCInput->postMsg( msg, data ); loop = false; } else if ( msg == CRCInput::RC_green ) //next { displayNext = !displayNext; paintHead(); // update button bar updateEvents(); paint(); } else if ( (msg == CRCInput::RC_info) ) { hide(); g_EpgData->show(chanlist[selected]->channel_id); paintHead(); paint(); } else if ( (msg == NeutrinoMessages::EVT_TIMER) && (data == sec_timer_id) ) { // head paintHead(); // update events //updateEvents(); // paint all //paint(); } else { if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all ) { loop = false; res = - 2; } } frameBuffer->blit(); } hide(); // g_RCInput->killTimer(sec_timer_id); sec_timer_id = 0; // bouquets mode if (bShowBouquetList) res = bouquetList->exec(true); CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO); new_mode_active = 0; if(NeutrinoMessages::mode_ts == CNeutrinoApp::getInstance()->getMode()) return -1; if(zapOnExit) res = selected; printf("CChannelList::show res %d\n", res); return(res); } void CChannelList::hide() { frameBuffer->paintBackgroundBoxRel(x, y, width, height + info_height); clearItem2DetailsLine(); frameBuffer->blit(); } bool CChannelList::showInfo(int pos, int epgpos) { if((pos >= (signed int) chanlist.size()) || (pos < 0)) return false; CZapitChannel * chan = chanlist[pos]; // channel infobar g_InfoViewer->show(pos + 1, chan->name, chan->getSatellitePosition(), chan->channel_id, true, epgpos); // UTF-8 return true; } int CChannelList::handleMsg(const neutrino_msg_t msg, neutrino_msg_data_t data) { if ( msg == NeutrinoMessages::EVT_PROGRAMLOCKSTATUS) { // 0x100 als FSK-Status zeigt an, dass (noch) kein EPG zu einem Kanal der NICHT angezeigt // werden sollte (vorgesperrt) da ist // oder das bouquet des Kanals ist vorgesperrt printf("CChannelList::handleMsg: program-lock-status: %d\n", data); if ((g_settings.parentallock_prompt == PARENTALLOCK_PROMPT_ONSIGNAL) || (g_settings.parentallock_prompt == PARENTALLOCK_PROMPT_CHANGETOLOCKED)) { if ( zapProtection != NULL ) zapProtection->fsk = data; else { // require password if either // CHANGETOLOCK mode and channel/bouquet is pre locked (0x100) // ONSIGNAL mode and fsk(data) is beyond configured value // if programm has already been unlocked, dont require pin if ((data >= (neutrino_msg_data_t)g_settings.parentallock_lockage) && ((chanlist[selected]->last_unlocked_EPGid != g_RemoteControl->current_EPGid) || (g_RemoteControl->current_EPGid == 0)) && ((g_settings.parentallock_prompt != PARENTALLOCK_PROMPT_CHANGETOLOCKED) || (data >= 0x100))) { g_RemoteControl->stopvideo(); zapProtection = new CZapProtection( g_settings.parentallock_pincode, data ); if ( zapProtection->check() ) { g_RemoteControl->startvideo(); // remember it for the next time chanlist[selected]->last_unlocked_EPGid = g_RemoteControl->current_EPGid; } delete zapProtection; zapProtection = NULL; } else g_RemoteControl->startvideo(); } } else g_RemoteControl->startvideo(); return messages_return::handled; } else return messages_return::unhandled; } /* bToo default to true */ bool CChannelList::adjustToChannelID(const t_channel_id channel_id, bool bToo) { unsigned int i; //printf("CChannelList::adjustToChannelID me %x list size %d channel_id %llx\n", (int) this, chanlist.size(), channel_id);fflush(stdout); for (i = 0; i < chanlist.size(); i++) { if(chanlist[i] == NULL) { //printf("CChannelList::adjustToChannelID REPORT BUG !! %d is NULL !!\n", i); continue; } if (chanlist[i]->channel_id == channel_id) { selected = i; lastChList.store(selected, channel_id, false); tuned = i; if (bToo && (bouquetList != NULL)) { //FIXME if(CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_tv) { TVbouquetList->adjustToChannelID(channel_id); TVsatList->adjustToChannelID(channel_id); TVfavList->adjustToChannelID(channel_id); TVallList->adjustToChannelID(channel_id); } else if(CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_radio) { RADIObouquetList->adjustToChannelID(channel_id); RADIOsatList->adjustToChannelID(channel_id); RADIOfavList->adjustToChannelID(channel_id); RADIOallList->adjustToChannelID(channel_id); } } //printf("CChannelList::adjustToChannelID me %x to %llx bToo %s OK: %d\n", (int) this, channel_id, bToo ? "yes" : "no", i);fflush(stdout); return true; } } //printf("CChannelList::adjustToChannelID me %x to %llx bToo %s FAILED\n", (int) this, channel_id, bToo ? "yes" : "no");fflush(stdout); return false; } int CChannelList::hasChannel(int nChannelNr) { for (uint32_t i = 0; i < chanlist.size(); i++) { if (getKey(i) == nChannelNr) return(i); } return(-1); } int CChannelList::hasChannelID(t_channel_id channel_id) { for (uint32_t i = 0; i < chanlist.size(); i++) { if (chanlist[i]->channel_id == channel_id) return i; } return -1; } // for adjusting bouquet's channel list after numzap or quickzap void CChannelList::setSelected( int nChannelNr) { selected = nChannelNr; } // -- Zap to channel with channel_id bool CChannelList::zapTo_ChannelID(const t_channel_id channel_id) { dprintf(DEBUG_NORMAL, "CChannelList::zapTo_ChannelID %llx\n", channel_id); for (unsigned int i = 0; i < chanlist.size(); i++) { if (chanlist[i]->channel_id == channel_id) { zapTo(i); return true; } } return false; } // forceStoreToLastChannels defaults to false void CChannelList::zapTo(int pos, bool /*forceStoreToLastChannels*/) { // show emty channellist error msg if (chanlist.empty()) { if (FrontendCount >= 1) MessageBox(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_CHANNELLIST_NONEFOUND), CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); return; } if ( (pos >= (signed int) chanlist.size()) || (pos < 0) ) { pos = 0; } CZapitChannel * chan = chanlist[pos]; dprintf(DEBUG_NORMAL, "CChannelList::zapTo me %s tuned %d new %d %s -> %llx\n", name.c_str(), tuned, pos, chan->name.c_str(), chan->channel_id); if ( pos != (int)tuned ) { if ((g_settings.radiotext_enable) && ((CNeutrinoApp::getInstance()->getMode()) == NeutrinoMessages::mode_radio) && (g_Radiotext)) { // stop radiotext PES decoding before zapping g_Radiotext->radiotext_stop(); } tuned = pos; g_RemoteControl->zapTo_ChannelID(chan->channel_id, chan->name, !chan->bAlwaysLocked); // UTF-8 // TODO check is it possible bouquetList is NULL ? if (bouquetList != NULL) { CNeutrinoApp::getInstance()->channelList->adjustToChannelID(chan->channel_id); } if(new_mode_active) selected = pos; } if(!new_mode_active) { selected = pos; /* remove recordModeActive from infobar */ if(g_settings.auto_timeshift && !CNeutrinoApp::getInstance()->recordingstatus) { g_InfoViewer->handleMsg(NeutrinoMessages::EVT_RECORDMODE, 0); } g_RCInput->postMsg( NeutrinoMessages::SHOW_INFOBAR, 0 ); } } // -1: channellist not found int CChannelList::numericZap(int key) { neutrino_msg_t msg; neutrino_msg_data_t data; int res = -1; if (chanlist.empty()) { if (FrontendCount >= 1) MessageBox(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_CHANNELLIST_NONEFOUND), CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); return res; } // -- quickzap "0" (recall) to last seen channel... if (key == g_settings.key_lastchannel) { t_channel_id channel_id = lastChList.getlast(1); if(channel_id) { lastChList.clear_storedelay(); // ignore store delay zapTo_ChannelID(channel_id); } return res; } if (key == g_settings.key_zaphistory) { // recording status if(!autoshift && CNeutrinoApp::getInstance()->recordingstatus) { CChannelList * orgList = bouquetList->orgChannelList; CChannelList * channelList = new CChannelList(g_Locale->getText(LOCALE_CHANNELLIST_CURRENT_TP), false, true); t_channel_id recid = rec_channel_id >> 16; // get channels from the same tp as recording channel for ( unsigned int i = 0 ; i < orgList->chanlist.size(); i++) { if((orgList->chanlist[i]->channel_id >> 16) == recid) { channelList->addChannel(orgList->chanlist[i]); } } if (channelList->getSize() != 0) { channelList->adjustToChannelID(orgList->getActiveChannel_ChannelID(), false); this->frameBuffer->paintBackground(); this->frameBuffer->blit(); res = channelList->exec(); } delete channelList; return res; } // -- zap history bouquet, similar to "0" quickzap, but shows a menue of last channels if (this->lastChList.size() > 1) { CChannelList * channelList = new CChannelList(g_Locale->getText(LOCALE_CHANNELLIST_HISTORY), true, true); for(unsigned int i = 1 ; i < this->lastChList.size() ; ++i) { t_channel_id channel_id = this->lastChList.getlast(i); if(channel_id) { CZapitChannel * channel = getChannel(channel_id); if(channel) channelList->addChannel(channel); } } if (channelList->getSize() != 0) { this->frameBuffer->paintBackground(); this->frameBuffer->blit(); res = channelList->exec(); } delete channelList; } return res; } //TEST: PiP if(key == g_settings.key_pip ) { CChannelList * orgList = bouquetList->orgChannelList; CChannelList * channelList = new CChannelList(g_Locale->getText(LOCALE_CHANNELLIST_CURRENT_TP), false, true); t_channel_id pipid = live_channel_id >> 16; for ( unsigned int i = 0 ; i < orgList->chanlist.size(); i++) { if((orgList->chanlist[i]->channel_id >> 16) == pipid) { channelList->addChannel(orgList->chanlist[i]); } } pip_selected = true; if (channelList->getSize() != 0) { channelList->adjustToChannelID(orgList->getActiveChannel_ChannelID(), false); this->frameBuffer->paintBackground(); this->frameBuffer->blit(); res = channelList->exec(); } delete channelList; return res; } // int sx = 4 * g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->getRenderWidth(widest_number) + 14; int sy = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->getHeight() + 6; int ox = frameBuffer->getScreenX() + (frameBuffer->getScreenWidth() - sx)/2; int oy = frameBuffer->getScreenY() + (frameBuffer->getScreenHeight() - sy)/2; char valstr[10]; int chn = CRCInput::getNumericValue(key); int pos = 1; int lastchan= -1; bool doZap = true; bool showEPG = false; while(1) { if (lastchan != chn) { sprintf((char*) &valstr, "%d", chn); while(strlen(valstr)<4) strcat(valstr,"-"); //"_" frameBuffer->paintBoxRel(ox, oy, sx, sy, COL_INFOBAR_PLUS_0); for (int i = 3; i >= 0; i--) { valstr[i+ 1]= 0; g_Font[SNeutrinoSettings::FONT_TYPE_CHANNEL_NUM_ZAP]->RenderString(ox + 7 + i*((sx - 14)>>2), oy + sy - 3, sx, &valstr[i], COL_INFOBAR); } frameBuffer->blit(); // show infobar showInfo(chn - 1); lastchan = chn; } g_RCInput->getMsg( &msg, &data, g_settings.timing[SNeutrinoSettings::TIMING_NUMERICZAP] * 10 ); if ( msg == CRCInput::RC_timeout ) { if ( ( chn > (int)chanlist.size() ) || (chn == 0) ) chn = tuned + 1; break; } else if (CRCInput::isNumeric(msg)) { if (pos == 4) { chn = 0; pos = 1; } else { chn *= 10; pos++; } chn += CRCInput::getNumericValue(msg); } else if ( msg == CRCInput::RC_ok ) { if ( ( chn > (signed int) chanlist.size() ) || ( chn == 0 ) ) { chn = tuned + 1; } break; } else if ( msg == (neutrino_msg_t)g_settings.key_quickzap_down ) { if ( chn == 1 ) chn = chanlist.size(); else { chn--; if (chn > (int)chanlist.size()) chn = (int)chanlist.size(); } } else if ( msg == (neutrino_msg_t)g_settings.key_quickzap_up ) { chn++; if (chn > (int)chanlist.size()) chn = 1; } else if ( ( msg == CRCInput::RC_home ) || ( msg == CRCInput::RC_left ) || ( msg == CRCInput::RC_right) ) { doZap = false; break; } else if ( msg == CRCInput::RC_red ) { if ( ( chn <= (signed int) chanlist.size() ) && ( chn != 0 ) ) { doZap = false; showEPG = true; break; } } else if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all ) { doZap = false; break; } } frameBuffer->paintBackgroundBoxRel(ox, oy, sx, sy); frameBuffer->blit(); chn--; if (chn < 0) chn = 0; if ( doZap ) { // kill infobar if(g_settings.timing[SNeutrinoSettings::TIMING_INFOBAR] == 0) g_InfoViewer->killTitle(); // zapto selected channel zapTo( chn ); } else { // show infobar showInfo(tuned); // kill infobar g_InfoViewer->killTitle(); if ( showEPG ) g_EventList->exec(chanlist[chn]->channel_id, chanlist[chn]->name); } return res; } void CChannelList::virtual_zap_mode(bool up) { dprintf(DEBUG_NORMAL, "CChannelList::virtual_zap_mode\n"); neutrino_msg_t msg; neutrino_msg_data_t data; if (chanlist.empty()) { if (FrontendCount >= 1) MessageBox(LOCALE_MESSAGEBOX_ERROR, g_Locale->getText(LOCALE_CHANNELLIST_NONEFOUND), CMessageBox::mbrCancel, CMessageBox::mbCancel, NEUTRINO_ICON_ERROR); return; } int chn = getActiveChannelNumber() + (up ? 1 : -1); if (chn > (int)chanlist.size()) chn = 1; if (chn == 0) chn = (int)chanlist.size(); int lastchan = -1; bool doZap = true; bool showEPG = false; int epgpos = 0; while(1) { if (lastchan != chn || (epgpos != 0)) { showInfo(chn - 1, epgpos); lastchan = chn; } epgpos = 0; g_RCInput->getMsg( &msg, &data, 15*10 ); // 15 seconds, not user changable //printf("%u %u %u\n", msg, NeutrinoMessages::EVT_TIMER, CRCInput::RC_timeout); if ( msg == CRCInput::RC_ok ) { if ( ( chn > (signed int) chanlist.size() ) || ( chn == 0 ) ) { chn = tuned + 1; } break; } else if ( msg == CRCInput::RC_left ) { if ( chn == 1 ) chn = chanlist.size(); else { chn--; if (chn > (int)chanlist.size()) chn = (int)chanlist.size(); } } else if ( msg == CRCInput::RC_right ) { chn++; if (chn > (int)chanlist.size()) chn = 1; } else if ( msg == CRCInput::RC_up ) { epgpos = -1; } else if ( msg == CRCInput::RC_down ) { epgpos = 1; } else if ( ( msg == CRCInput::RC_home ) || ( msg == CRCInput::RC_timeout ) ) { // Abbruch ohne Channel zu wechseln doZap = false; break; } else if ( msg == CRCInput::RC_red ) { // Rote Taste zeigt EPG fuer gewaehlten Kanal an if ( ( chn <= (signed int) chanlist.size() ) && ( chn != 0 ) ) { doZap = false; showEPG = true; break; } } else if ( CNeutrinoApp::getInstance()->handleMsg( msg, data ) & messages_return::cancel_all ) { doZap = false; break; } } g_InfoViewer->clearVirtualZapMode(); chn--; if (chn < 0) chn = 0; if ( doZap ) { if(g_settings.timing[SNeutrinoSettings::TIMING_INFOBAR] == 0) g_InfoViewer->killTitle(); zapTo(chn); } else { showInfo(tuned); g_InfoViewer->killTitle(); // Rote Taste zeigt EPG fuer gewaehlten Kanal an if ( showEPG ) g_EventList->exec(chanlist[chn]->channel_id, chanlist[chn]->name); } } void CChannelList::quickZap(int key, bool cycle) { if(chanlist.size() == 0) return; if ( (key == g_settings.key_quickzap_down) || (key == CRCInput::RC_left) ) { if(selected == 0) selected = chanlist.size() - 1; else selected--; } else if ((key == g_settings.key_quickzap_up) || (key == CRCInput::RC_right) ) { selected = (selected + 1)%chanlist.size(); } dprintf(DEBUG_NORMAL, "CChannelList::quickZap: quick zap selected = %d getActiveBouquetNumber %d\n", selected, bouquetList->getActiveBouquetNumber()); if(cycle) bouquetList->orgChannelList->zapTo(bouquetList->Bouquets[bouquetList->getActiveBouquetNumber()]->channelList->getKey(selected)-1); else zapTo(selected); g_RCInput->clearRCMsg(); //FIXME test for n.103 } void CChannelList::paintDetails(int index) { if (chanlist.empty()) return; CChannelEvent * p_event = NULL; if (displayNext) { p_event = &chanlist[index]->nextEvent; } else { p_event = &chanlist[index]->currentEvent; } if ( p_event != NULL && !p_event->description.empty()) { char cNoch[50]; // UTF-8 char cSeit[50]; // UTF-8 struct tm * pStartZeit = localtime(&p_event->startTime); unsigned seit = ( time(NULL) - p_event->startTime ) / 60; if (displayNext) { sprintf(cNoch, "(%d min)", p_event->duration / 60); sprintf(cSeit, g_Locale->getText(LOCALE_CHANNELLIST_START), pStartZeit->tm_hour, pStartZeit->tm_min); } else { sprintf(cSeit, g_Locale->getText(LOCALE_CHANNELLIST_SINCE), pStartZeit->tm_hour, pStartZeit->tm_min); int noch = (p_event->startTime + p_event->duration - time(NULL)) / 60; if ((noch < 0) || (noch >= 10000)) noch = 0; sprintf(cNoch, "(%d / %d min)", seit, noch); } int seit_len = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getRenderWidth(cSeit, true); // UTF-8 int noch_len = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getRenderWidth(cNoch, true); // UTF-8 std::string text1 = p_event->description; std::string text2 = p_event->text; int xstart = 10; if (g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getRenderWidth(text1, true) > (width - 30 - seit_len) ) { // zu breit, Umbruch versuchen... int pos; do { pos = text1.find_last_of("[ -.]+"); if ( pos!=-1 ) text1 = text1.substr( 0, pos ); } while ( ( pos != -1 ) && (g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getRenderWidth(text1, true) > (width - 30 - seit_len) ) ); std::string text3 = p_event->description.substr(text1.length() + 1); if (!(text2.empty())) text3 = text3 + " - "; xstart += g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getRenderWidth(text3, true); g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x + BORDER_LEFT, y + height + 5 + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight() + 5 + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getHeight(), width - 30 - noch_len, text3, COL_MENUFOOT_INFO, 0, true); } if (!(text2.empty())) { while ( text2.find_first_of("[ -.+*#?=!$%&/]+") == 0 ) text2 = text2.substr( 1 ); text2 = text2.substr( 0, text2.find('\n') ); g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x + xstart, y + height + 5 + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight() + 5 + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getHeight(), width - xstart- 20- noch_len, text2, COL_MENUFOOT_INFO, 0, true); } g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x + 10, y + height + 5 + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight(), width - 30 - seit_len, text1, COL_MENUFOOT_INFO, 0, true); g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString (x + width - 10 - seit_len, y + height + 5 + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight(), seit_len, cSeit, COL_MENUFOOT_INFO, 0, true); // UTF-8 g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->RenderString(x + width - 10 - noch_len, y + height + 5 + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight() + 5 + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getHeight() - 2, noch_len, cNoch, COL_MENUFOOT_INFO, 0, true); // UTF-8 } } void CChannelList::clearItem2DetailsLine() { ::clearItem2DetailsLine(x, y, width, height, info_height); } void CChannelList::paintItem2DetailsLine(int pos) { ::paintItem2DetailsLine(x, y, width, height, info_height, theight, iheight, pos); } bool CChannelList::canZap(CZapitChannel * channel) { bool iscurrent = true; if(!autoshift && CNeutrinoApp::getInstance()->recordingstatus) { if(channel == NULL) channel = chanlist[selected]; iscurrent = CanZap(channel); } return iscurrent; } void CChannelList::paintItem(int pos) { int ypos = y + theight + pos*iheight; uint8_t color; fb_pixel_t bgcolor; bool iscurrent = true; unsigned int curr = liststart + pos; bool logo_ok = false; if(curr < chanlist.size()) iscurrent = canZap(chanlist[curr]); if (curr == selected) { color = COL_MENUCONTENTSELECTED; bgcolor = COL_MENUCONTENTSELECTED_PLUS_0; // itemlines paintItem2DetailsLine(pos); // details paintDetails(curr); } else { color = iscurrent ? COL_MENUCONTENT : COL_MENUCONTENTINACTIVE; bgcolor = iscurrent ? COL_MENUCONTENT_PLUS_0 : COL_MENUCONTENTINACTIVE_PLUS_0; } // itembox frameBuffer->paintBoxRel(x, ypos, width - SCROLLBAR_WIDTH, iheight, bgcolor); //name and description if(curr < chanlist.size()) { char nameAndDescription[255]; char tmp[10]; CZapitChannel * chan = chanlist[curr]; int prg_offset = 0; int title_offset = 0; uint8_t tcolor = (liststart + pos == selected) ? color : COL_MENUCONTENTINACTIVE; // due to extended info if(g_settings.channellist_extended) { prg_offset = 42; title_offset = 6; } sprintf((char*) tmp, "%d", this->historyMode ? pos : chan->number); CChannelEvent * p_event = NULL; int pBarWidth = 35; int pBarHeight = iheight/3; CProgressBar timescale(pBarWidth, pBarHeight); if (displayNext) { p_event = &chan->nextEvent; } else { p_event = &chan->currentEvent; } // hd/scrambled icons if (g_settings.channellist_ca) { // scrambled icon if(chan->scrambled) frameBuffer->paintIcon(NEUTRINO_ICON_SCRAMBLED, x + width - SCROLLBAR_WIDTH - 2 - icon_ca_w, ypos + (iheight - icon_ca_h)/2); // hd icon if(chan->isHD()) frameBuffer->paintIcon(NEUTRINO_ICON_HD, x + width - SCROLLBAR_WIDTH - 2 - icon_ca_w - 2 - icon_hd_w, ypos + (iheight - icon_hd_h)/2); // uhd icon else if(chan->isUHD()) frameBuffer->paintIcon(NEUTRINO_ICON_UHD, x + width - SCROLLBAR_WIDTH - 2 - icon_ca_w - 2 - icon_hd_w, ypos + (iheight - icon_hd_h)/2); } // channel number int numpos = x + ICON_OFFSET + numwidth - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getRenderWidth(tmp); g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->RenderString(numpos, ypos + (iheight - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getHeight())/2 + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getHeight(), numwidth + 5, tmp, color, 0, true); // name and description int l = 0; if (this->historyMode) l = snprintf(nameAndDescription, sizeof(nameAndDescription), ": %d %s", chan->number, chan->name.c_str()); else l = snprintf(nameAndDescription, sizeof(nameAndDescription), "%s", chan->name.c_str()); if (!(p_event->description.empty())) { snprintf(nameAndDescription + l, sizeof(nameAndDescription)-l," - "); unsigned int ch_name_len = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getRenderWidth(nameAndDescription, true); unsigned int ch_desc_len = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getRenderWidth(p_event->description, true); if ( (width - numwidth - 60 - SCROLLBAR_WIDTH - prg_offset - ch_name_len - icon_ca_w - icon_hd_w - 4) < ch_desc_len ) //60:??? ch_desc_len = (width - numwidth - 60 - SCROLLBAR_WIDTH - icon_ca_w - icon_hd_w - 4 - ch_name_len - prg_offset); //30: hd icon width if (ch_desc_len <= 0) ch_desc_len = 0; if(g_settings.channellist_extended) { // next infos if(displayNext) { struct tm *pStartZeit = localtime(&p_event->startTime); sprintf((char*) tmp, "%02d:%02d", pStartZeit->tm_hour, pStartZeit->tm_min); g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->RenderString(x + 5 + numwidth + 6, ypos + (iheight - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getHeight())/2 + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getHeight(), width - numwidth - 20 - 15 - prg_offset, tmp, tcolor, 0, true); } else { time_t jetzt = time(NULL); int runningPercent = 0; if (((jetzt - p_event->startTime + 30) / 60) < 0 ) { runningPercent = 0; } else { runningPercent = (jetzt-p_event->startTime) * 30 / p_event->duration; if (runningPercent > 30) // this would lead to negative value in paintBoxRel runningPercent = 30; // later on which can be fatal... } // timescale.reset(); timescale.paint(x + ICON_OFFSET + numwidth + title_offset, ypos + (iheight - pBarHeight)/2, runningPercent); } } // name and description g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x + 5 + numwidth + 10 + prg_offset, ypos + (iheight - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight())/2 + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight(), width - numwidth - 40 - 15 - prg_offset, nameAndDescription, color, 0, true); // epg-txt (left) g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->RenderString(x + 5 + numwidth + 10 + ch_name_len + 5 + prg_offset, ypos + (iheight - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getHeight())/2 + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_DESCR]->getHeight(), ch_desc_len, p_event->description, (curr == selected)?COL_MENUCONTENTSELECTED:(!displayNext ? COL_COLORED_EVENTS_CHANNELLIST : COL_MENUCONTENTINACTIVE) , 0, true); } else { if(g_settings.channellist_extended) { // short runningPercent = 0; timescale.reset(); timescale.paint(x + ICON_OFFSET + numwidth + title_offset, ypos + (iheight - pBarHeight)/2, runningPercent); } //name g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->RenderString(x + 5 + numwidth+ 10 + prg_offset, ypos + (iheight - g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight())/2 + g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST]->getHeight(), width- numwidth- 40- 15-prg_offset, nameAndDescription, color, 0, true); // UTF-8 } // show channame/event info in vfd if (curr == selected) { if (!(chan->currentEvent.description.empty())) { snprintf(nameAndDescription, sizeof(nameAndDescription), "%s - %s", chan->name.c_str(), p_event->description.c_str()); } else { snprintf(nameAndDescription, sizeof(nameAndDescription), "%s", chan->name.c_str() ); } if (!CVFD::getInstance()->is4digits) CVFD::getInstance()->ShowText(nameAndDescription); // UTF-8 } } } #define NUM_LIST_BUTTONS 4 struct button_label CChannelListButtons[NUM_LIST_BUTTONS] = { { NEUTRINO_ICON_BUTTON_RED, LOCALE_INFOVIEWER_EVENTLIST, NULL}, { NEUTRINO_ICON_BUTTON_GREEN, LOCALE_INFOVIEWER_NEXT, NULL}, { NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_BOUQUETLIST_HEAD, NULL}, { NEUTRINO_ICON_BUTTON_BLUE, LOCALE_EPGMENU_EPGPLUS, NULL}, }; #define NUM_VLIST_BUTTONS 4 const struct button_label CChannelVListButtons[NUM_VLIST_BUTTONS] = { { NEUTRINO_ICON_BUTTON_RED, LOCALE_INFOVIEWER_EVENTLIST, NULL}, { NEUTRINO_ICON_BUTTON_GREEN, LOCALE_INFOVIEWER_NEXT, NULL}, { NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_BOUQUETLIST_HEAD, NULL}, { NEUTRINO_ICON_BUTTON_BLUE, LOCALE_EPGMENU_EPGPLUS, NULL} }; void CChannelList::paintHead() { // head frameBuffer->paintBoxRel(x, y, width, theight, COL_MENUHEAD_PLUS_0, RADIUS_MID, CORNER_TOP, g_settings.Head_gradient); //round int ButtonWidth = (width - BORDER_LEFT - BORDER_RIGHT) / 4; // foot if (displayNext) { CChannelListButtons[1].locale = LOCALE_INFOVIEWER_NOW; } else { CChannelListButtons[1].locale = LOCALE_INFOVIEWER_NEXT; } // foot int f_x = x; int f_y = y + (height - buttonHeight); frameBuffer->paintBoxRel(f_x, f_y, width, buttonHeight, COL_MENUHEAD_PLUS_0, RADIUS_MID, CORNER_BOTTOM, g_settings.Foot_gradient); //round // foot buttons ::paintButtons(frameBuffer, g_Font[SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL], g_Locale, f_x + BORDER_RIGHT, f_y, ButtonWidth, vlist ? NUM_VLIST_BUTTONS : NUM_LIST_BUTTONS, vlist ? CChannelVListButtons : CChannelListButtons, buttonHeight); // help icon frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_HELP, x + width - BORDER_RIGHT - icon_help_w , y + (theight - icon_help_h)/2 ); // setup icon if (bouquetList != NULL) { frameBuffer->paintIcon(NEUTRINO_ICON_BUTTON_SETUP, x + width - BORDER_RIGHT - icon_setup_w - 2 - icon_help_w, y + (theight - icon_setup_h)/2); // icon for bouquet list button } // mute zap frameBuffer->paintIcon(new_mode_active ? NEUTRINO_ICON_BUTTON_MUTE_ZAP_ACTIVE : NEUTRINO_ICON_BUTTON_MUTE_ZAP_INACTIVE, x + width - BORDER_RIGHT - icon_help_w - 2 - icon_setup_w - 2 - icon_head_w, y + (theight - icon_head_h)/2); // paint time/date int timestr_len = 0; char timestr[18]; time_t now = time(NULL); struct tm * tm = localtime(&now); strftime(timestr, 18, "%d.%m.%Y %H:%M", tm); timestr_len = g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMLARGE]->getRenderWidth(timestr, true); // UTF-8 g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMLARGE]->RenderString(x + width - BORDER_RIGHT - icon_help_w - 2 - icon_setup_w - 2 - icon_head_w - 2 - timestr_len, y + (theight - g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMLARGE]->getHeight())/2 + g_Font[SNeutrinoSettings::FONT_TYPE_EVENTLIST_ITEMLARGE]->getHeight(), timestr_len+1, timestr, COL_MENUHEAD, 0, true); // UTF-8 //title g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->RenderString(x + 10, y + (theight - g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight())/2 + g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight(), width - 10 - icon_help_w - 2 - icon_setup_w - 2 - icon_head_w - 2 - timestr_len, name, COL_MENUHEAD, 0, true); // UTF-8 } void CChannelList::paint() { dprintf(DEBUG_NORMAL, "CChannelList::paint\n"); liststart = (selected/listmaxshow)*listmaxshow; //FIXME do we need to find biggest chan number in list ? numwidth = g_Font[SNeutrinoSettings::FONT_TYPE_CHANNELLIST_NUMBER]->getRenderWidth("0000"); // channellist boby frameBuffer->paintBoxRel(x, y + theight, width, height - buttonHeight - theight, COL_MENUCONTENT_PLUS_0); // paint item for(unsigned int count = 0; count < listmaxshow; count++) { paintItem(count); } // scroll bar int ypos = y + theight; int sb = iheight*listmaxshow; frameBuffer->paintBoxRel(x + width - SCROLLBAR_WIDTH, ypos, SCROLLBAR_WIDTH, sb, COL_MENUCONTENT_PLUS_1); int sbc = ((chanlist.size()- 1)/ listmaxshow)+ 1; int sbs = (selected/listmaxshow); frameBuffer->paintBoxRel(x + width - 13, ypos + 2 + sbs*(sb - 4)/sbc, 11, (sb - 4)/sbc, COL_MENUCONTENT_PLUS_3); } int CChannelList::getSize() const { return this->chanlist.size(); } int CChannelList::getSelectedChannelIndex() const { return this->selected; }
[ "mohousch@gmail.com" ]
mohousch@gmail.com