blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
3
264
content_id
stringlengths
40
40
detected_licenses
listlengths
0
85
license_type
stringclasses
2 values
repo_name
stringlengths
5
140
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
905 values
visit_date
timestamp[us]date
2015-08-09 11:21:18
2023-09-06 10:45:07
revision_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-17 19:19:19
committer_date
timestamp[us]date
1997-09-14 05:04:47
2023-09-06 06:22:19
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
22 values
gha_event_created_at
timestamp[us]date
2012-06-07 00:51:45
2023-09-14 21:58:39
gha_created_at
timestamp[us]date
2008-03-27 23:40:48
2023-08-21 23:17:38
gha_language
stringclasses
141 values
src_encoding
stringclasses
34 values
language
stringclasses
1 value
is_vendor
bool
1 class
is_generated
bool
2 classes
length_bytes
int64
3
10.4M
extension
stringclasses
115 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
1a50c239b0c65c07b8752ffe5d6e0535ecbdd0c5
78a3cc861b46d0385c7efc54ceda9d62818e12a2
/src/skland/graphic/internal/canvas_private.hpp
fe40382d403b29e89f86b4f475c57ed22c85e1ce
[ "Apache-2.0" ]
permissive
zhanggyb/skland
90f618ae713996b115170860092703bb2099f348
055d91a6830b95d248d407c37a8a2fa20b148efd
refs/heads/master
2020-06-15T17:17:37.258046
2017-11-12T15:04:19
2017-11-12T15:04:19
75,276,770
20
3
null
null
null
null
UTF-8
C++
false
false
1,347
hpp
/* * Copyright 2016 Freeman Zhang <zhanggyb@gmail.com> * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef SKLAND_GRAPHIC_INTERNAL_CANVAS_PRIVATE_HPP_ #define SKLAND_GRAPHIC_INTERNAL_CANVAS_PRIVATE_HPP_ #include "skland/graphic/canvas.hpp" #include "bitmap_private.hpp" #include "skland/core/deque.hpp" #include "SkCanvas.h" namespace skland { namespace graphic { /** * @ingroup graphic_intern * @brief The private structure used in Canvas */ struct Canvas::Private { Private() = default; explicit Private(const SkBitmap &bitmap) : sk_canvas(bitmap) { } ~Private() = default; SkCanvas sk_canvas; core::PointF origin; size_t lock_count = 0; core::Deque<LockGuardNode> lock_guard_deque; }; } // namespace graphic } // namespace skland #endif // SKLAND_GRAPHIC_INTERNAL_CANVAS_PRIVATE_HPP_
[ "zhanggyb@gmail.com" ]
zhanggyb@gmail.com
8c7c4615ceb3da08fd39c9c0b72f0326a50ddabe
6b40e9cba1dd06cd31a289adff90e9ea622387ac
/Develop/Game/ClientResourceValidator/VSoundDataValidator.h
14da6ab178a7af2351a3763ecfe1066e2541c03e
[]
no_license
AmesianX/SHZPublicDev
c70a84f9170438256bc9b2a4d397d22c9c0e1fb9
0f53e3b94a34cef1bc32a06c80730b0d8afaef7d
refs/heads/master
2022-02-09T07:34:44.339038
2014-06-09T09:20:04
2014-06-09T09:20:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,250
h
#pragma once #include "VDataValidator.h" #include "XEffectBaseInvoker.h" class VCheckEffectBaseInvoker : public XEffectBaseInvoker { private: vector<string> m_vecWeaponType_SS; vector<string> m_vecArmorType_SS; vector<string> m_vecFootStepMaterialName; vector<string> m_vecArmorType_AS; vector<string> m_vecSoundType_SD; private: bool CheckResrvedEffectData_SS(string strPre, string strSoundName); bool CheckResrvedEffectData_FootStep(string strSoundResourceName, string strSoundName); bool CheckResrvedEffectData_AS(string strSoundResourceName, string strSoundName); bool CheckResrvedEffectData_SD(string strSoundName); public: VCheckEffectBaseInvoker(); virtual ~VCheckEffectBaseInvoker() {} bool CheckResrvedEffectData(string strSoundName); }; class VSoundDataValidator : VDataValidator { private: int m_nSoundCount; VCheckEffectBaseInvoker m_CheckEffectBaseInvoker; public: VErrorMsg m_SoundInfoValidatorError; private: bool CheckSoundFileName(VSoundInfoMgr* pSoundInfoMgr, string strFileName); bool CheckSoundUsableFromEffectInfo(VEffectInfoMgr* pEffectInfoMgr, string strSoundName); bool CheckSoundUsableFromTalentInfo(VTalentInfoMgr* pTalentInfoMgr, string strSoundName); bool CheckSoundUsableFromMeshInfo(VMeshInfoMgr* pMeshInfoMgr, string strSoundName); bool CheckSoundUsableFromNpcInfo(VNpcInfoMgr* pNpcInfoMgr, string strSoundName); bool CheckSoundUsableFromItemInfo(VItemInfoMgr* pItemInfoMgr, string strSoundName); bool CheckSoundUsableFromFieldInfo(string strSoundName); bool CheckSoundUsableFromSystemInfo(VValidatorInfoMgr* vInfoMgr, string strSoundName); public: VSoundDataValidator(); virtual ~VSoundDataValidator(); virtual void Init(VValidatorInfoMgr* vInfoMgr); virtual void CheckStart(VValidatorInfoMgr* vInfoMgr); void CheckSoundInfo(VSoundInfoMgr* pSoundInfoMgr, string& strName, RSampleInfo* pSoundInfo, VValidatorInfoMgr* vInfoMgr); void CheckSoundUsable(string& strName, VValidatorInfoMgr* vInfoMgr); virtual int GetCheckCount() { return m_nSoundCount; } };
[ "shzdev@8fd9ef21-cdc5-48af-8625-ea2f38c673c4" ]
shzdev@8fd9ef21-cdc5-48af-8625-ea2f38c673c4
626df647365b745a1bed7e4e3cd433cb16ed4760
173abb9f709b3e64cb5fd093e8717b73d2edf672
/src/InforMation.h
d7637a066c833cdcc4d06dcd55795e6a98d8c7bc
[]
no_license
nohda/CodeEditor
f642dbf8d4848c9fde5199292bddef57efc90952
d2469a64f24492f93e996a203794bc3114f440dd
refs/heads/master
2023-04-29T05:38:34.366703
2023-04-19T07:11:16
2023-04-19T07:11:16
214,812,408
0
0
null
null
null
null
UTF-8
C++
false
false
698
h
#pragma once #ifndef _INFORMATION_H #define _INFORMATION_H #define STATUS_SUCCESS (0x00000000) #include "resource.h" #include <afxwin.h> typedef signed long int Long; typedef LONG NTSTATUS, * PNTSTATUS; typedef NTSTATUS(WINAPI* RtlGetVersionPtr)(PRTL_OSVERSIONINFOW); class CodeEditorForm; class InforMation : public CDialog { public: enum { IDD = IDR_INFORMATIONDIALOG }; public: InforMation(CodeEditorForm* codeEditorForm = NULL); virtual BOOL OnInitDialog(); protected: afx_msg void OnClose(); RTL_OSVERSIONINFOW GetRealOSVersion(); DECLARE_MESSAGE_MAP(); private: CodeEditorForm* codeEditorForm; public: afx_msg void OnStnClickedStaticInformationText(); }; #endif //_INFORMATION_H
[ "49062739+nohda@users.noreply.github.com" ]
49062739+nohda@users.noreply.github.com
32fb73b5a369527ab2eb6675b7eacccd2ac40bb9
39d93eafa28e773b4a29c78b6ce2459d97a4f60b
/C Code/nodemcu_jetBotDataLogger/servo/servo.ino
88057849aaf4c873bfcee8c1017e052b1436ae6e
[]
no_license
yashj3010/jetBot
cb9ebec71f93600aebccbf076a73cd1ae0f525ac
a95882756d0fa477f31c4ef46616b34d342710a8
refs/heads/main
2023-06-21T03:17:55.883578
2021-07-13T13:55:35
2021-07-13T13:55:35
351,413,276
0
0
null
null
null
null
UTF-8
C++
false
false
1,156
ino
/* Sweep by BARRAGAN <http://barraganstudio.com> This example code is in the public domain. modified 28 May 2015 by Michael C. Miller modified 8 Nov 2013 by Scott Fitzgerald http://arduino.cc/en/Tutorial/Sweep */ #include <Servo.h> Servo servoDown; Servo servoUp; // create servo object to control a servo // twelve servo objects can be created on most boards void setup() { servoDown.attach(12); // attaches the servo on GIO2 to the servo object servoUp.attach(14); // attaches the servo on GIO2 to the servo object } void loop() { int pos; for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees // in steps of 1 degree servoDown.write(pos); servoUp.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees servoDown.write(pos); servoUp.write(pos);// tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } }
[ "yashj1030@gmail.com" ]
yashj1030@gmail.com
3f64fdd48985302586d0e30d199a1d15163d8e63
6d87c0163ddf245d7f4190a9be7cb4a22192abb7
/WifiBodyWeightScale/src/nabton/GpsModule.cpp
b10fe8a31fb5db6018248dab4851d908ba51a373
[]
no_license
asaxen/Codeterrific
16796458c373f09f037102bd42fb3c9fad973ba4
fd6cf4c44ab5ecfe52d9f7434273fb67abbb1004
refs/heads/master
2021-01-01T04:12:25.945369
2020-04-13T13:27:43
2020-04-13T13:27:43
56,341,588
1
3
null
2018-02-11T19:01:10
2016-04-15T18:33:35
C++
UTF-8
C++
false
false
720
cpp
#include "GpsModule.h" #include "Logger.h" namespace nabton { bool GpsModule::getGpsData(GpsModule::GpsData& gpsResult) { bool result = false; //TODO Implement a way to brake while loop if GPS fails while (true) { delay(5); if (gps_.encode(Serial.read())) { unsigned long fix_age; float flat, flon; gps_.f_get_position(&flat, &flon, &fix_age); WLOG_INFO << flat << "," << flon; gpsResult.latitude = flat; gpsResult.longitude = flon; result = true; break; } } return result; } }
[ "adam@asaxen.com" ]
adam@asaxen.com
a44c196590fb16340cc9c1e2dbaaf8d0a1d1392c
d49614ec5101d96aca1340da8016496d360e49e6
/pxr/imaging/hgi/buffer.h
7e8fab426fa2e35464b31a81c69bfc90d8a403f2
[ "MIT" ]
permissive
cyhunter/hgiVk
cc07f605af708b9ead3e3744ea7d3e1582f835b8
e0c060477efa645c5cac566846da793a1e94b3a1
refs/heads/master
2021-01-05T02:12:46.953095
2020-02-05T22:21:10
2020-02-05T22:21:10
240,841,293
2
0
MIT
2020-02-16T06:08:49
2020-02-16T06:08:48
null
UTF-8
C++
false
false
2,481
h
#ifndef PXR_IMAGING_HGI_BUFFER_H #define PXR_IMAGING_HGI_BUFFER_H #include <stdlib.h> #include <string> #include <vector> #include "pxr/pxr.h" #include "pxr/imaging/hgi/api.h" #include "pxr/imaging/hgi/enums.h" #include "pxr/imaging/hgi/types.h" PXR_NAMESPACE_OPEN_SCOPE struct HgiBufferDesc; /// /// \class HgiBuffer /// /// Represents a buffer (vertex, index, storage, etc) /// class HgiBuffer { public: HGI_API HgiBuffer(HgiBufferDesc const& desc); HGI_API virtual ~HgiBuffer(); /// Update the buffer with new data (eg. uniform or shader storage buffers). /// This requires that the buffer was created with HgiBufferUsageCpuToGpu. /// Do not use this if the buffer only needs to receive data one time, for /// example a vertex buffer. For one-time upload use `HgiBufferDesc.data` /// during buffer construction. /// Note that UpdateBufferData happens 'immediately'. It is up to the caller /// to ensure that the GPU is not currently consuming the portion of the /// buffer that is being updated. E.g. tripple-buffer/cycle between several /// buffer objects. Or make a buffer that is 3x the needed size and cycle /// between portions of the buffer. HGI_API virtual void UpdateBufferData( uint32_t byteOffset, size_t byteSize, const void* data) = 0; private: HgiBuffer() = delete; HgiBuffer & operator=(const HgiBuffer&) = delete; HgiBuffer(const HgiBuffer&) = delete; }; typedef HgiBuffer* HgiBufferHandle; typedef std::vector<HgiBufferHandle> HgiBufferHandleVector; /// \struct HgiBufferDesc /// /// Describes the properties needed to create a GPU buffer. /// /// <ul> /// <li>usage: /// Bits describing the intended usage and properties of the buffer.</li> /// <li>byteSize: /// Byte size (length) of buffer</li> /// <li>data: /// CPU pointer to initialization data of buffer. /// The memory is consumed immediately during the creation of the HgiBuffer. /// The application may alter or free this memory as soon as the constructor /// of the HgiBuffer has returned.</li> /// </ul> /// struct HgiBufferDesc { HGI_API HgiBufferDesc(); std::string debugName; HgiBufferUsage usage; size_t byteSize; void const* data; }; HGI_API bool operator==( const HgiBufferDesc& lhs, const HgiBufferDesc& rhs); HGI_API bool operator!=( const HgiBufferDesc& lhs, const HgiBufferDesc& rhs); PXR_NAMESPACE_CLOSE_SCOPE #endif
[ "shaderfx@gmail.com" ]
shaderfx@gmail.com
575679dee5028d7c056b907f78835f9dbfa8b7ce
abff3f461cd7d740cfc1e675b23616ee638e3f1e
/opencascade/AIS_ViewController.hxx
7c566b2dccc8784edb53def6c7b4991c2c17b8e8
[ "Apache-2.0" ]
permissive
CadQuery/pywrap
4f93a4191d3f033f67e1fc209038fc7f89d53a15
f3bcde70fd66a2d884fa60a7a9d9f6aa7c3b6e16
refs/heads/master
2023-04-27T04:49:58.222609
2023-02-10T07:56:06
2023-02-10T07:56:06
146,502,084
22
25
Apache-2.0
2023-05-01T12:14:52
2018-08-28T20:18:59
C++
UTF-8
C++
false
false
36,239
hxx
// Copyright (c) 2016-2019 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // // This library is free software; you can redistribute it and/or modify it under // the terms of the GNU Lesser General Public License version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. // // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. #ifndef _AIS_ViewController_HeaderFile #define _AIS_ViewController_HeaderFile #include <Aspect_VKeySet.hxx> #include <Aspect_TouchMap.hxx> #include <AIS_DragAction.hxx> #include <AIS_MouseGesture.hxx> #include <AIS_NavigationMode.hxx> #include <AIS_ViewInputBuffer.hxx> #include <AIS_RotationMode.hxx> #include <AIS_WalkDelta.hxx> #include <gp_Pnt.hxx> #include <Graphic3d_Vec3.hxx> #include <NCollection_Array1.hxx> #include <OSD_Timer.hxx> #include <Precision.hxx> #include <Standard_Mutex.hxx> class AIS_AnimationCamera; class AIS_InteractiveObject; class AIS_InteractiveContext; class AIS_Point; class AIS_RubberBand; class V3d_View; //! Auxiliary structure for handling viewer events between GUI and Rendering threads. //! //! Class implements the following features: //! - Buffers storing the state of user input (mouse, touches and keyboard). //! - Mapping mouse/multi-touch input to View camera manipulations (panning/rotating/zooming). //! - Input events are not applied immediately but queued for separate processing from two working threads //! UI thread receiving user input and Rendering thread for OCCT 3D Viewer drawing. class AIS_ViewController { public: //! Empty constructor. Standard_EXPORT AIS_ViewController(); //! Return input buffer. const AIS_ViewInputBuffer& InputBuffer (AIS_ViewInputBufferType theType) const { return theType == AIS_ViewInputBufferType_UI ? myUI : myGL; } //! Return input buffer. AIS_ViewInputBuffer& ChangeInputBuffer (AIS_ViewInputBufferType theType) { return theType == AIS_ViewInputBufferType_UI ? myUI : myGL; } //! Return view animation; empty (but not NULL) animation by default. const Handle(AIS_AnimationCamera)& ViewAnimation() const { return myViewAnimation; } //! Set view animation to be handled within handleViewRedraw(). void SetViewAnimation (const Handle(AIS_AnimationCamera)& theAnimation) { myViewAnimation = theAnimation; } //! Interrupt active view animation. Standard_EXPORT void AbortViewAnimation(); public: //! @name global parameters //! Return camera rotation mode, AIS_RotationMode_BndBoxActive by default. AIS_RotationMode RotationMode() const { return myRotationMode; } //! Set camera rotation mode. void SetRotationMode (AIS_RotationMode theMode) { myRotationMode = theMode; } //! Return camera navigation mode; AIS_NavigationMode_Orbit by default. AIS_NavigationMode NavigationMode() const { return myNavigationMode; } //! Set camera navigation mode. Standard_EXPORT void SetNavigationMode (AIS_NavigationMode theMode); //! Return mouse input acceleration ratio in First Person mode; 1.0 by default. float MouseAcceleration() const { return myMouseAccel; } //! Set mouse input acceleration ratio. void SetMouseAcceleration (float theRatio) { myMouseAccel = theRatio; } //! Return orbit rotation acceleration ratio; 1.0 by default. float OrbitAcceleration() const { return myOrbitAccel; } //! Set orbit rotation acceleration ratio. void SetOrbitAcceleration (float theRatio) { myOrbitAccel = theRatio; } //! Return TRUE if panning anchor point within perspective projection should be displayed in 3D Viewer; TRUE by default. bool ToShowPanAnchorPoint() const { return myToShowPanAnchorPoint; } //! Set if panning anchor point within perspective projection should be displayed in 3D Viewer. void SetShowPanAnchorPoint (bool theToShow) { myToShowPanAnchorPoint = theToShow; } //! Return TRUE if rotation point should be displayed in 3D Viewer; TRUE by default. bool ToShowRotateCenter() const { return myToShowRotateCenter; } //! Set if rotation point should be displayed in 3D Viewer. void SetShowRotateCenter (bool theToShow) { myToShowRotateCenter = theToShow; } //! Return TRUE if camera up orientation within AIS_NavigationMode_Orbit rotation mode should be forced Z up; FALSE by default. bool ToLockOrbitZUp() const { return myToLockOrbitZUp; } //! Set if camera up orientation within AIS_NavigationMode_Orbit rotation mode should be forced Z up. void SetLockOrbitZUp (bool theToForceUp) { myToLockOrbitZUp = theToForceUp; } //! Return TRUE if z-rotation via two-touches gesture is enabled; FALSE by default. bool ToAllowTouchZRotation() const { return myToAllowTouchZRotation; } //! Set if z-rotation via two-touches gesture is enabled. void SetAllowTouchZRotation (bool theToEnable) { myToAllowTouchZRotation = theToEnable; } //! Return TRUE if camera rotation is allowed; TRUE by default. bool ToAllowRotation() const { return myToAllowRotation; } //! Set if camera rotation is allowed. void SetAllowRotation (bool theToEnable) { myToAllowRotation = theToEnable; } //! Return TRUE if panning is allowed; TRUE by default. bool ToAllowPanning() const { return myToAllowPanning; } //! Set if panning is allowed. void SetAllowPanning (bool theToEnable) { myToAllowPanning = theToEnable; } //! Return TRUE if zooming is allowed; TRUE by default. bool ToAllowZooming() const { return myToAllowZooming; } //! Set if zooming is allowed. void SetAllowZooming (bool theToEnable) { myToAllowZooming = theToEnable; } //! Return TRUE if ZFocus change is allowed; TRUE by default. bool ToAllowZFocus() const { return myToAllowZFocus; } //! Set if ZFocus change is allowed. void SetAllowZFocus (bool theToEnable) { myToAllowZFocus = theToEnable; } //! Return TRUE if dynamic highlight on mouse move is allowed; TRUE by default. bool ToAllowHighlight() const { return myToAllowHighlight; } //! Set if dragging object is allowed. void SetAllowHighlight (bool theToEnable) { myToAllowHighlight = theToEnable; } //! Return TRUE if dragging object is allowed; TRUE by default. bool ToAllowDragging() const { return myToAllowDragging; } //! Set if dynamic highlight on mouse move is allowed. void SetAllowDragging (bool theToEnable) { myToAllowDragging = theToEnable; } //! Return TRUE if picked point should be projected to picking ray on zooming at point; TRUE by default. bool ToStickToRayOnZoom() const { return myToStickToRayOnZoom; } //! Set if picked point should be projected to picking ray on zooming at point. void SetStickToRayOnZoom (bool theToEnable) { myToStickToRayOnZoom = theToEnable; } //! Return TRUE if picked point should be projected to picking ray on rotating around point; TRUE by default. bool ToStickToRayOnRotation() const { return myToStickToRayOnRotation; } //! Set if picked point should be projected to picking ray on rotating around point. void SetStickToRayOnRotation (bool theToEnable) { myToStickToRayOnRotation = theToEnable; } //! Return TRUE if pitch direction should be inverted while processing Aspect_VKey_NavLookUp/Aspect_VKey_NavLookDown; FALSE by default. bool ToInvertPitch() const { return myToInvertPitch; } //! Set flag inverting pitch direction. void SetInvertPitch (bool theToInvert) { myToInvertPitch = theToInvert; } //! Return normal walking speed, in m/s; 1.5 by default. float WalkSpeedAbsolute() const { return myWalkSpeedAbsolute; } //! Set normal walking speed, in m/s; 1.5 by default. void SetWalkSpeedAbsolute (float theSpeed) { myWalkSpeedAbsolute = theSpeed; } //! Return walking speed relative to scene bounding box; 0.1 by default. float WalkSpeedRelative() const { return myWalkSpeedRelative; } //! Set walking speed relative to scene bounding box. void SetWalkSpeedRelative (float theFactor) { myWalkSpeedRelative = theFactor; } //! Return active thrust value; 0.0f by default. float ThrustSpeed() const { return myThrustSpeed; } //! Set active thrust value. void SetThrustSpeed (float theSpeed) { myThrustSpeed = theSpeed; } //! Return TRUE if previous position of MoveTo has been defined. bool HasPreviousMoveTo() const { return myPrevMoveTo != Graphic3d_Vec2i (-1); } //! Return previous position of MoveTo event in 3D viewer. const Graphic3d_Vec2i& PreviousMoveTo() const { return myPrevMoveTo; } //! Reset previous position of MoveTo. void ResetPreviousMoveTo() { myPrevMoveTo = Graphic3d_Vec2i (-1); } public: //! @name keyboard input //! Return keyboard state. const Aspect_VKeySet& Keys() const { return myKeys; } //! Return keyboard state. Aspect_VKeySet& ChangeKeys() { return myKeys; } //! Press key. //! @param theKey key pressed //! @param theTime event timestamp Standard_EXPORT virtual void KeyDown (Aspect_VKey theKey, double theTime, double thePressure = 1.0); //! Release key. //! @param theKey key pressed //! @param theTime event timestamp Standard_EXPORT virtual void KeyUp (Aspect_VKey theKey, double theTime); //! Simulate key up/down events from axis value. Standard_EXPORT virtual void KeyFromAxis (Aspect_VKey theNegative, Aspect_VKey thePositive, double theTime, double thePressure); //! Fetch active navigation actions. Standard_EXPORT AIS_WalkDelta FetchNavigationKeys (Standard_Real theCrouchRatio, Standard_Real theRunRatio); public: //! @name mouse input //! Return map defining mouse gestures. const AIS_MouseGestureMap& MouseGestureMap() const { return myMouseGestureMap; } //! Return map defining mouse gestures. AIS_MouseGestureMap& ChangeMouseGestureMap() { return myMouseGestureMap; } //! Return double click interval in seconds; 0.4 by default. double MouseDoubleClickInterval() const { return myMouseDoubleClickInt; } //! Set double click interval in seconds. void SetMouseDoubleClickInterval (double theSeconds) { myMouseDoubleClickInt = theSeconds; } //! Perform selection in 3D viewer. //! This method is expected to be called from UI thread. //! @param thePnt picking point //! @param theIsXOR XOR selection flag Standard_EXPORT virtual void SelectInViewer (const Graphic3d_Vec2i& thePnt, const bool theIsXOR = false); //! Perform selection in 3D viewer. //! This method is expected to be called from UI thread. //! @param thePnts picking point //! @param theIsXOR XOR selection flag Standard_EXPORT virtual void SelectInViewer (const NCollection_Sequence<Graphic3d_Vec2i>& thePnts, const bool theIsXOR = false); //! Update rectangle selection tool. //! This method is expected to be called from UI thread. //! @param thePntFrom rectangle first corner //! @param thePntTo rectangle another corner //! @param theIsXOR XOR selection flag Standard_EXPORT virtual void UpdateRubberBand (const Graphic3d_Vec2i& thePntFrom, const Graphic3d_Vec2i& thePntTo, const bool theIsXOR = false); //! Update polygonal selection tool. //! This method is expected to be called from UI thread. //! @param thePnt new point to add to polygon //! @param theToAppend append new point or update the last point Standard_EXPORT virtual void UpdatePolySelection (const Graphic3d_Vec2i& thePnt, bool theToAppend); //! Update zoom event (e.g. from mouse scroll). //! This method is expected to be called from UI thread. //! @param theDelta mouse cursor position to zoom at and zoom delta //! @return TRUE if new zoom event has been created or FALSE if existing one has been updated Standard_EXPORT virtual bool UpdateZoom (const Aspect_ScrollDelta& theDelta); //! Update Z rotation event. //! @param theAngle rotation angle, in radians. //! @return TRUE if new zoom event has been created or FALSE if existing one has been updated Standard_EXPORT virtual bool UpdateZRotation (double theAngle); //! Update mouse scroll event; redirects to UpdateZoom by default. //! This method is expected to be called from UI thread. //! @param theDelta mouse cursor position and delta //! @return TRUE if new event has been created or FALSE if existing one has been updated Standard_EXPORT virtual bool UpdateMouseScroll (const Aspect_ScrollDelta& theDelta); //! Handle mouse button press/release event. //! This method is expected to be called from UI thread. //! @param thePoint mouse cursor position //! @param theButtons pressed buttons //! @param theModifiers key modifiers //! @param theIsEmulated if TRUE then mouse event comes NOT from real mouse //! but emulated from non-precise input like touch on screen //! @return TRUE if View should be redrawn Standard_EXPORT virtual bool UpdateMouseButtons (const Graphic3d_Vec2i& thePoint, Aspect_VKeyMouse theButtons, Aspect_VKeyFlags theModifiers, bool theIsEmulated); //! Handle mouse cursor movement event. //! This method is expected to be called from UI thread. //! @param thePoint mouse cursor position //! @param theButtons pressed buttons //! @param theModifiers key modifiers //! @param theIsEmulated if TRUE then mouse event comes NOT from real mouse //! but emulated from non-precise input like touch on screen //! @return TRUE if View should be redrawn Standard_EXPORT virtual bool UpdateMousePosition (const Graphic3d_Vec2i& thePoint, Aspect_VKeyMouse theButtons, Aspect_VKeyFlags theModifiers, bool theIsEmulated); //! Handle mouse button press event. //! This method is expected to be called from UI thread. //! @param thePoint mouse cursor position //! @param theButton pressed button //! @param theModifiers key modifiers //! @param theIsEmulated if TRUE then mouse event comes NOT from real mouse //! but emulated from non-precise input like touch on screen //! @return TRUE if View should be redrawn bool PressMouseButton (const Graphic3d_Vec2i& thePoint, Aspect_VKeyMouse theButton, Aspect_VKeyFlags theModifiers, bool theIsEmulated) { return UpdateMouseButtons (thePoint, myMousePressed | theButton, theModifiers, theIsEmulated); } //! Handle mouse button release event. //! This method is expected to be called from UI thread. //! @param thePoint mouse cursor position //! @param theButton released button //! @param theModifiers key modifiers //! @param theIsEmulated if TRUE then mouse event comes NOT from real mouse //! but emulated from non-precise input like touch on screen //! @return TRUE if View should be redrawn bool ReleaseMouseButton (const Graphic3d_Vec2i& thePoint, Aspect_VKeyMouse theButton, Aspect_VKeyFlags theModifiers, bool theIsEmulated) { Aspect_VKeyMouse aButtons = myMousePressed & (~theButton); return UpdateMouseButtons (thePoint, aButtons, theModifiers, theIsEmulated); } //! Handle mouse button click event (emulated by UpdateMouseButtons() while releasing single button). //! Note that as this method is called by UpdateMouseButtons(), it should be executed from UI thread. //! Default implementation redirects to SelectInViewer(). //! This method is expected to be called from UI thread. //! @param thePoint mouse cursor position //! @param theButton clicked button //! @param theModifiers key modifiers //! @param theIsDoubleClick flag indicating double mouse click //! @return TRUE if View should be redrawn Standard_EXPORT virtual bool UpdateMouseClick (const Graphic3d_Vec2i& thePoint, Aspect_VKeyMouse theButton, Aspect_VKeyFlags theModifiers, bool theIsDoubleClick); //! Return currently pressed mouse buttons. Aspect_VKeyMouse PressedMouseButtons() const { return myMousePressed; } //! Return active key modifiers passed with last mouse event. Aspect_VKeyFlags LastMouseFlags() const { return myMouseModifiers; } //! Return last mouse position. const Graphic3d_Vec2i& LastMousePosition() const { return myMousePositionLast; } public: //! @name multi-touch input //! Return scale factor for adjusting tolerances for starting multi-touch gestures; 1.0 by default //! This scale factor is expected to be computed from touch screen resolution. float TouchToleranceScale() const { return myTouchToleranceScale; } //! Set scale factor for adjusting tolerances for starting multi-touch gestures. void SetTouchToleranceScale (float theTolerance) { myTouchToleranceScale = theTolerance; } //! Return TRUE if touches map is not empty. bool HasTouchPoints() const { return !myTouchPoints.IsEmpty(); } //! Add touch point with the given ID. //! This method is expected to be called from UI thread. //! @param theId touch unique identifier //! @param thePnt touch coordinates //! @param theClearBefore if TRUE previously registered touches will be removed Standard_EXPORT virtual void AddTouchPoint (Standard_Size theId, const Graphic3d_Vec2d& thePnt, Standard_Boolean theClearBefore = false); //! Remove touch point with the given ID. //! This method is expected to be called from UI thread. //! @param theId touch unique identifier //! @param theClearSelectPnts if TRUE will initiate clearing of selection points //! @return TRUE if point has been removed Standard_EXPORT virtual bool RemoveTouchPoint (Standard_Size theId, Standard_Boolean theClearSelectPnts = false); //! Update touch point with the given ID. //! If point with specified ID was not registered before, it will be added. //! This method is expected to be called from UI thread. //! @param theId touch unique identifier //! @param thePnt touch coordinates Standard_EXPORT virtual void UpdateTouchPoint (Standard_Size theId, const Graphic3d_Vec2d& thePnt); public: //! Return event time (e.g. current time). double EventTime() const { return myEventTimer.ElapsedTime(); } //! Reset input state (pressed keys, mouse buttons, etc.) e.g. on window focus loss. //! This method is expected to be called from UI thread. Standard_EXPORT virtual void ResetViewInput(); //! Reset view orientation. //! This method is expected to be called from UI thread. Standard_EXPORT virtual void UpdateViewOrientation (V3d_TypeOfOrientation theOrientation, bool theToFitAll); //! Update buffer for rendering thread. //! This method is expected to be called within synchronization barrier between GUI //! and Rendering threads (e.g. GUI thread should be locked beforehand to avoid data races). //! @param theCtx interactive context //! @param theView active view //! @param theToHandle if TRUE, the HandleViewEvents() will be called Standard_EXPORT virtual void FlushViewEvents (const Handle(AIS_InteractiveContext)& theCtx, const Handle(V3d_View)& theView, Standard_Boolean theToHandle = Standard_False); //! Process events within rendering thread. Standard_EXPORT virtual void HandleViewEvents (const Handle(AIS_InteractiveContext)& theCtx, const Handle(V3d_View)& theView); public: //! Callback called by handleMoveTo() on Selection in 3D Viewer. //! This method is expected to be called from rendering thread. Standard_EXPORT virtual void OnSelectionChanged (const Handle(AIS_InteractiveContext)& theCtx, const Handle(V3d_View)& theView); //! Callback called by handleMoveTo() on dragging object in 3D Viewer. //! This method is expected to be called from rendering thread. Standard_EXPORT virtual void OnObjectDragged (const Handle(AIS_InteractiveContext)& theCtx, const Handle(V3d_View)& theView, AIS_DragAction theAction); //! Pick closest point under mouse cursor. //! This method is expected to be called from rendering thread. //! @param thePnt [out] result point //! @param theCtx [in] interactive context //! @param theView [in] active view //! @param theCursor [in] mouse cursor //! @param theToStickToPickRay [in] when TRUE, the result point will lie on picking ray //! @return TRUE if result has been found Standard_EXPORT virtual bool PickPoint (gp_Pnt& thePnt, const Handle(AIS_InteractiveContext)& theCtx, const Handle(V3d_View)& theView, const Graphic3d_Vec2i& theCursor, bool theToStickToPickRay); //! Compute rotation gravity center point depending on rotation mode. //! This method is expected to be called from rendering thread. Standard_EXPORT virtual gp_Pnt GravityPoint (const Handle(AIS_InteractiveContext)& theCtx, const Handle(V3d_View)& theView); public: //! Perform camera actions. //! This method is expected to be called from rendering thread. Standard_EXPORT virtual void handleCameraActions (const Handle(AIS_InteractiveContext)& theCtx, const Handle(V3d_View)& theView, const AIS_WalkDelta& theWalk); //! Perform moveto/selection/dragging. //! This method is expected to be called from rendering thread. Standard_EXPORT virtual void handleMoveTo (const Handle(AIS_InteractiveContext)& theCtx, const Handle(V3d_View)& theView); //! Return TRUE if another frame should be drawn right after this one. bool toAskNextFrame() const { return myToAskNextFrame; } //! Set if another frame should be drawn right after this one. void setAskNextFrame (bool theToDraw = true) { myToAskNextFrame = theToDraw; } //! Return if panning anchor point has been defined. bool hasPanningAnchorPoint() const { return !Precision::IsInfinite (myPanPnt3d.X()); } //! Return active panning anchor point. const gp_Pnt& panningAnchorPoint() const { return myPanPnt3d; } //! Set active panning anchor point. void setPanningAnchorPoint (const gp_Pnt& thePnt) { myPanPnt3d = thePnt; } //! Handle panning event myGL.Panning. Standard_EXPORT virtual void handlePanning (const Handle(V3d_View)& theView); //! Handle Z rotation event myGL.ZRotate. Standard_EXPORT virtual void handleZRotate (const Handle(V3d_View)& theView); //! Return minimal camera distance for zoom operation. double MinZoomDistance() const { return myMinCamDistance; } //! Set minimal camera distance for zoom operation. void SetMinZoomDistance (double theDist) { myMinCamDistance = theDist; } //! Handle zoom event myGL.ZoomActions. //! This method is expected to be called from rendering thread. Standard_EXPORT virtual void handleZoom (const Handle(V3d_View)& theView, const Aspect_ScrollDelta& theParams, const gp_Pnt* thePnt); //! Handle ZScroll event myGL.ZoomActions. //! This method is expected to be called from rendering thread. Standard_EXPORT virtual void handleZFocusScroll (const Handle(V3d_View)& theView, const Aspect_ScrollDelta& theParams); //! Handle orbital rotation events myGL.OrbitRotation. //! @param theView view to modify //! @param thePnt 3D point to rotate around //! @param theToLockZUp amend camera to exclude roll angle (put camera Up vector to plane containing global Z and view direction) Standard_EXPORT virtual void handleOrbitRotation (const Handle(V3d_View)& theView, const gp_Pnt& thePnt, bool theToLockZUp); //! Handle view direction rotation events myGL.ViewRotation. //! This method is expected to be called from rendering thread. //! @param theView camera to modify //! @param theYawExtra extra yaw increment //! @param thePitchExtra extra pitch increment //! @param theRoll roll value //! @param theToRestartOnIncrement flag indicating flight mode Standard_EXPORT virtual void handleViewRotation (const Handle(V3d_View)& theView, double theYawExtra, double thePitchExtra, double theRoll, bool theToRestartOnIncrement); //! Handle view redraw. //! This method is expected to be called from rendering thread. Standard_EXPORT virtual void handleViewRedraw (const Handle(AIS_InteractiveContext)& theCtx, const Handle(V3d_View)& theView); protected: //! Flush buffers. Standard_EXPORT virtual void flushBuffers (const Handle(AIS_InteractiveContext)& theCtx, const Handle(V3d_View)& theView); //! Flush touch gestures. Standard_EXPORT virtual void flushGestures (const Handle(AIS_InteractiveContext)& theCtx, const Handle(V3d_View)& theView); //! Return current and previously fetched event times. //! This callback is intended to compute delta between sequentially processed events. //! @param thePrevTime [out] events time fetched previous time by this method //! @param theCurrTime [out] actual events time void updateEventsTime (double& thePrevTime, double& theCurrTime) { thePrevTime = myLastEventsTime; myLastEventsTime = EventTime(); theCurrTime = myLastEventsTime; } //! Perform selection via mouse click. //! This method is expected to be called from rendering thread. Standard_EXPORT virtual void handleSelectionPick (const Handle(AIS_InteractiveContext)& theCtx, const Handle(V3d_View)& theView); //! Perform dynamic highlight on mouse move. //! This method is expected to be called from rendering thread. Standard_EXPORT virtual void handleDynamicHighlight (const Handle(AIS_InteractiveContext)& theCtx, const Handle(V3d_View)& theView); //! Perform rubber-band selection. //! This method is expected to be called from rendering thread. Standard_EXPORT virtual void handleSelectionPoly (const Handle(AIS_InteractiveContext)& theCtx, const Handle(V3d_View)& theView); //! Lazy AIS_InteractiveContext::MoveTo() with myPrevMoveTo check. Standard_EXPORT virtual void contextLazyMoveTo (const Handle(AIS_InteractiveContext)& theCtx, const Handle(V3d_View)& theView, const Graphic3d_Vec2i& thePnt); protected: AIS_ViewInputBuffer myUI; //!< buffer for UI thread AIS_ViewInputBuffer myGL; //!< buffer for rendering thread OSD_Timer myEventTimer; //!< timer for timestamping events Standard_Real myLastEventsTime; //!< last fetched events timer value for computing delta/progress Standard_Boolean myToAskNextFrame; //!< flag indicating that another frame should be drawn right after this one Standard_Real myMinCamDistance; //!< minimal camera distance for zoom operation AIS_RotationMode myRotationMode; //!< rotation mode AIS_NavigationMode myNavigationMode; //!< navigation mode (orbit rotation / first person) Standard_ShortReal myMouseAccel; //!< mouse input acceleration ratio in First Person mode Standard_ShortReal myOrbitAccel; //!< Orbit rotation acceleration ratio Standard_Boolean myToShowPanAnchorPoint; //!< option displaying panning anchor point Standard_Boolean myToShowRotateCenter; //!< option displaying rotation center point Standard_Boolean myToLockOrbitZUp; //!< force camera up orientation within AIS_NavigationMode_Orbit rotation mode Standard_Boolean myToInvertPitch; //!< flag inverting pitch direction while processing Aspect_VKey_NavLookUp/Aspect_VKey_NavLookDown Standard_Boolean myToAllowTouchZRotation; //!< enable z-rotation two-touches gesture; FALSE by default Standard_Boolean myToAllowRotation; //!< enable rotation; TRUE by default Standard_Boolean myToAllowPanning; //!< enable panning; TRUE by default Standard_Boolean myToAllowZooming; //!< enable zooming; TRUE by default Standard_Boolean myToAllowZFocus; //!< enable ZFocus change; TRUE by default Standard_Boolean myToAllowHighlight; //!< enable dynamic highlight on mouse move; TRUE by default Standard_Boolean myToAllowDragging; //!< enable dragging object; TRUE by default Standard_Boolean myToStickToRayOnZoom; //!< project picked point to ray while zooming at point, TRUE by default Standard_Boolean myToStickToRayOnRotation; //!< project picked point to ray while rotating around point; TRUE by default Standard_ShortReal myWalkSpeedAbsolute; //!< normal walking speed, in m/s; 1.5 by default Standard_ShortReal myWalkSpeedRelative; //!< walking speed relative to scene bounding box; 0.1 by default Standard_ShortReal myThrustSpeed; //!< active thrust value Standard_Boolean myHasThrust; //!< flag indicating active thrust Handle(AIS_AnimationCamera) myViewAnimation; //!< view animation Handle(AIS_RubberBand) myRubberBand; //!< Rubber-band presentation Handle(AIS_InteractiveObject) myDragObject; //!< currently dragged object Graphic3d_Vec2i myPrevMoveTo; //!< previous position of MoveTo event in 3D viewer Standard_Boolean myHasHlrOnBeforeRotation; //!< flag for restoring Computed mode after rotation protected: //! @name keyboard input variables Aspect_VKeySet myKeys; //!< keyboard state protected: //! @name mouse input variables Standard_Real myMouseClickThreshold; //!< mouse click threshold in pixels; 3 by default Standard_Real myMouseDoubleClickInt; //!< double click interval in seconds; 0.4 by default Standard_ShortReal myScrollZoomRatio; //!< distance ratio for mapping mouse scroll event to zoom; 15.0 by default AIS_MouseGestureMap myMouseGestureMap; //!< map defining mouse gestures AIS_MouseGesture myMouseActiveGesture; //!< initiated mouse gesture (by pressing mouse button) Standard_Boolean myMouseActiveIdleRotation; //!< flag indicating view idle rotation state Graphic3d_Vec2i myMousePositionLast; //!< last mouse position Graphic3d_Vec2i myMousePressPoint; //!< mouse position where active gesture was been initiated Graphic3d_Vec2i myMouseProgressPoint; //!< gesture progress OSD_Timer myMouseClickTimer; //!< timer for handling double-click event Standard_Integer myMouseClickCounter; //!< counter for handling double-click event Aspect_VKeyMouse myMousePressed; //!< active mouse buttons Aspect_VKeyFlags myMouseModifiers; //!< active key modifiers passed with last mouse event Standard_Integer myMouseSingleButton; //!< index of mouse button pressed alone (>0) protected: //! @name multi-touch input variables Standard_ShortReal myTouchToleranceScale; //!< tolerance scale factor; 1.0 by default Standard_ShortReal myTouchRotationThresholdPx; //!< threshold for starting one-touch rotation gesture in pixels; 6 by default Standard_ShortReal myTouchZRotationThreshold; //!< threshold for starting two-touch Z-rotation gesture in radians; 2 degrees by default Standard_ShortReal myTouchPanThresholdPx; //!< threshold for starting two-touch panning gesture in pixels; 4 by default Standard_ShortReal myTouchZoomThresholdPx; //!< threshold for starting two-touch zoom (pitch) gesture in pixels; 6 by default Standard_ShortReal myTouchZoomRatio; //!< distance ratio for mapping two-touch zoom (pitch) gesture from pixels to zoom; 0.13 by default Aspect_TouchMap myTouchPoints; //!< map of active touches Graphic3d_Vec2d myStartPanCoord; //!< touch coordinates at the moment of starting panning gesture Graphic3d_Vec2d myStartRotCoord; //!< touch coordinates at the moment of starting rotating gesture Standard_Integer myNbTouchesLast; //!< number of touches within previous gesture flush to track gesture changes Standard_Boolean myUpdateStartPointPan; //!< flag indicating that new anchor point should be picked for starting panning gesture Standard_Boolean myUpdateStartPointRot; //!< flag indicating that new gravity point should be picked for starting rotation gesture Standard_Boolean myUpdateStartPointZRot; //!< flag indicating that new gravity point should be picked for starting Z-rotation gesture protected: //! @name rotation/panning transient state variables Handle(AIS_Point) myAnchorPointPrs1; //!< anchor point presentation (Graphic3d_ZLayerId_Top) Handle(AIS_Point) myAnchorPointPrs2; //!< anchor point presentation (Graphic3d_ZLayerId_Topmost) gp_Pnt myPanPnt3d; //!< active panning anchor point gp_Pnt myRotatePnt3d; //!< active rotation center of gravity gp_Dir myCamStartOpUp; //!< camera Up direction at the beginning of rotation gp_Dir myCamStartOpDir; //!< camera View direction at the beginning of rotation gp_Pnt myCamStartOpEye; //!< camera Eye position at the beginning of rotation gp_Pnt myCamStartOpCenter; //!< camera Center position at the beginning of rotation gp_Vec myCamStartOpToCenter; //!< vector from rotation gravity point to camera Center at the beginning of rotation gp_Vec myCamStartOpToEye; //!< vector from rotation gravity point to camera Eye at the beginning of rotation Graphic3d_Vec3d myRotateStartYawPitchRoll; //!< camera yaw pitch roll at the beginning of rotation }; #endif // _AIS_ViewController_HeaderFile
[ "adam.jan.urbanczyk@gmail.com" ]
adam.jan.urbanczyk@gmail.com
c20f68abf26ea7fd52a9ee00e33356ab81e0465c
b8f7e16f46381b4b9cbea872869bce0a79f9559d
/openr/fib/tests/FibTest.cpp
2f189f559b9848f77f511a80f783e7d10b0344e2
[ "MIT", "LicenseRef-scancode-proprietary-license" ]
permissive
terrorizer1980/openr
17520b30f762199e69df54b412a9f38dbde29ae2
d896b804552cf2c48be489b4d22ce2614bdccd3a
refs/heads/master
2023-04-07T04:20:09.765402
2020-08-16T12:54:46
2020-08-17T01:25:04
288,077,434
0
0
MIT
2023-04-04T01:47:11
2020-08-17T03:46:02
null
UTF-8
C++
false
false
42,179
cpp
/** * Copyright (c) 2014-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #include <chrono> #include <thread> #include <fbzmq/zmq/Zmq.h> #include <folly/futures/Future.h> #include <folly/gen/Base.h> #include <folly/init/Init.h> #include <glog/logging.h> #include <gmock/gmock.h> #include <gtest/gtest.h> #include <thrift/lib/cpp2/protocol/Serializer.h> #include <thrift/lib/cpp2/server/ThriftServer.h> #include <thrift/lib/cpp2/util/ScopedServerThread.h> #include <openr/common/NetworkUtil.h> #include <openr/config/Config.h> #include <openr/config/tests/Utils.h> #include <openr/fib/Fib.h> #include <openr/if/gen-cpp2/Fib_types.h> #include <openr/if/gen-cpp2/Lsdb_types.h> #include <openr/if/gen-cpp2/Network_types.h> #include <openr/messaging/ReplicateQueue.h> #include <openr/tests/OpenrThriftServerWrapper.h> #include <openr/tests/mocks/MockNetlinkFibHandler.h> using namespace std; using namespace openr; using apache::thrift::BaseThriftServer; using apache::thrift::FRAGILE; using apache::thrift::ThriftServer; using apache::thrift::util::ScopedServerThread; const int16_t kFibId{static_cast<int16_t>(thrift::FibClient::OPENR)}; const auto prefix1 = toIpPrefix("::ffff:10.1.1.1/128"); const auto prefix2 = toIpPrefix("::ffff:10.2.2.2/128"); const auto prefix3 = toIpPrefix("::ffff:10.3.3.3/128"); const auto prefix4 = toIpPrefix("::ffff:10.4.4.4/128"); const auto label1{1}; const auto label2{2}; const auto label3{3}; const auto path1_2_1 = createNextHop( toBinaryAddress(folly::IPAddress("fe80::2")), std::string("iface_1_2_1"), 1); const auto path1_2_2 = createNextHop( toBinaryAddress(folly::IPAddress("fe80::2")), std::string("iface_1_2_2"), 2); const auto path1_2_3 = createNextHop( toBinaryAddress(folly::IPAddress("fe80::2")), std::string("iface_1_2_3"), 1); const auto path1_3_1 = createNextHop( toBinaryAddress(folly::IPAddress("fe80::3")), std::string("iface_1_3_1"), 2); const auto path1_3_2 = createNextHop( toBinaryAddress(folly::IPAddress("fe80::3")), std::string("iface_1_3_2"), 2); const auto path3_2_1 = createNextHop( toBinaryAddress(folly::IPAddress("fe80::2")), std::string("iface_3_2_1"), 1); const auto path3_2_2 = createNextHop( toBinaryAddress(folly::IPAddress("fe80::2")), std::string("iface_3_2_2"), 2); const auto path3_4_1 = createNextHop( toBinaryAddress(folly::IPAddress("fe80::4")), std::string("iface_3_4_1"), 2); const auto path3_4_2 = createNextHop( toBinaryAddress(folly::IPAddress("fe80::4")), std::string("iface_3_4_2"), 2); const auto mpls_path1_2_1 = createNextHop( toBinaryAddress(folly::IPAddress("fe80::2")), std::string("iface_1_2_1"), 2, createMplsAction(thrift::MplsActionCode::SWAP, 2), true /* useNonShortestPath */); const auto mpls_path1_2_2 = createNextHop( toBinaryAddress(folly::IPAddress("fe80::2")), std::string("iface_1_2_2"), 2, createMplsAction(thrift::MplsActionCode::SWAP, 2), true /* useNonShortestPath */); bool checkEqualRoutes(thrift::RouteDatabase lhs, thrift::RouteDatabase rhs) { if (lhs.unicastRoutes_ref()->size() != rhs.unicastRoutes_ref()->size()) { return false; } std::unordered_map<thrift::IpPrefix, std::set<thrift::NextHopThrift>> lhsRoutes; std::unordered_map<thrift::IpPrefix, std::set<thrift::NextHopThrift>> rhsRoutes; for (auto const& route : *lhs.unicastRoutes_ref()) { lhsRoutes.emplace( route.dest, std::set<thrift::NextHopThrift>( route.nextHops_ref()->begin(), route.nextHops_ref()->end())); } for (auto const& route : *rhs.unicastRoutes_ref()) { rhsRoutes.emplace( route.dest, std::set<thrift::NextHopThrift>( route.nextHops_ref()->begin(), route.nextHops_ref()->end())); } for (auto const& kv : lhsRoutes) { if (rhsRoutes.count(kv.first) == 0) { return false; } if (rhsRoutes.at(kv.first) != kv.second) { return false; } } for (auto const& kv : rhsRoutes) { if (lhsRoutes.count(kv.first) == 0) { return false; } if (lhsRoutes.at(kv.first) != kv.second) { return false; } } return true; } bool checkEqualMplsRoutes(thrift::RouteDatabase lhs, thrift::RouteDatabase rhs) { if (lhs.mplsRoutes_ref()->size() != rhs.mplsRoutes_ref()->size()) { return false; } std::unordered_map<int32_t, std::set<thrift::NextHopThrift>> lhsRoutes; std::unordered_map<int32_t, std::set<thrift::NextHopThrift>> rhsRoutes; for (auto const& route : *lhs.mplsRoutes_ref()) { lhsRoutes.emplace( route.topLabel, std::set<thrift::NextHopThrift>( route.nextHops_ref()->begin(), route.nextHops_ref()->end())); } for (auto const& route : *rhs.mplsRoutes_ref()) { rhsRoutes.emplace( route.topLabel, std::set<thrift::NextHopThrift>( route.nextHops_ref()->begin(), route.nextHops_ref()->end())); } for (auto const& kv : lhsRoutes) { if (rhsRoutes.count(kv.first) == 0) { return false; } if (rhsRoutes.at(kv.first) != kv.second) { return false; } } for (auto const& kv : rhsRoutes) { if (lhsRoutes.count(kv.first) == 0) { return false; } if (lhsRoutes.at(kv.first) != kv.second) { return false; } } return true; } class FibTestFixture : public ::testing::Test { public: explicit FibTestFixture(bool waitOnDecision = false) : waitOnDecision_(waitOnDecision) {} void SetUp() override { mockFibHandler = std::make_shared<MockNetlinkFibHandler>(); server = make_shared<ThriftServer>(); server->setNumIOWorkerThreads(1); server->setNumAcceptThreads(1); server->setPort(0); server->setInterface(mockFibHandler); fibThriftThread.start(server); port = fibThriftThread.getAddress()->getPort(); auto tConfig = getBasicOpenrConfig( "node-1", "domain", {}, /* area config */ true, /* enableV4 */ true /*enableSegmentRouting*/, false /*orderedFibProgramming*/, false /*dryrun*/); if (waitOnDecision_) { tConfig.eor_time_s_ref() = 1; } config = make_shared<Config>(tConfig); fib = std::make_shared<Fib>( config, port, /* thrift port */ std::chrono::seconds(2), /* coldStartDuration */ routeUpdatesQueue.getReader(), interfaceUpdatesQueue.getReader(), fibUpdatesQueue, MonitorSubmitUrl{"inproc://monitor-sub"}, nullptr, /* KvStore module ptr */ context); fibThread = std::make_unique<std::thread>([this]() { LOG(INFO) << "Fib thread starting"; fib->run(); LOG(INFO) << "Fib thread finishing"; }); fib->waitUntilRunning(); // spin up an openrThriftServer openrThriftServerWrapper_ = std::make_shared<OpenrThriftServerWrapper>( "node-1", nullptr /* decision */, fib.get() /* fib */, nullptr /* kvStore */, nullptr /* linkMonitor */, nullptr /* configStore */, nullptr /* prefixManager */, config /* config */, MonitorSubmitUrl{"inproc://monitor-rep"}, context); openrThriftServerWrapper_->run(); } void TearDown() override { LOG(INFO) << "Stopping openr-ctrl thrift server"; fibUpdatesQueue.close(); openrThriftServerWrapper_->stop(); LOG(INFO) << "Openr-ctrl thrift server got stopped"; routeUpdatesQueue.close(); interfaceUpdatesQueue.close(); // this will be invoked before Fib's d-tor LOG(INFO) << "Stopping the Fib thread"; fib->stop(); fibThread->join(); fib.reset(); // stop mocked nl platform mockFibHandler->stop(); fibThriftThread.stop(); LOG(INFO) << "Mock fib platform is stopped"; } thrift::RouteDatabase getRouteDb() { auto resp = openrThriftServerWrapper_->getOpenrCtrlHandler() ->semifuture_getRouteDb() .get(); EXPECT_TRUE(resp); return std::move(*resp); } std::vector<thrift::UnicastRoute> getUnicastRoutesFiltered(std::unique_ptr<std::vector<std::string>> prefixes) { auto resp = openrThriftServerWrapper_->getOpenrCtrlHandler() ->semifuture_getUnicastRoutesFiltered(std::move(prefixes)) .get(); EXPECT_TRUE(resp); return *resp; } std::vector<thrift::UnicastRoute> getUnicastRoutes() { auto resp = openrThriftServerWrapper_->getOpenrCtrlHandler() ->semifuture_getUnicastRoutes() .get(); EXPECT_TRUE(resp); return *resp; } std::vector<thrift::MplsRoute> getMplsRoutesFiltered(std::unique_ptr<std::vector<int32_t>> labels) { auto resp = openrThriftServerWrapper_->getOpenrCtrlHandler() ->semifuture_getMplsRoutesFiltered(std::move(labels)) .get(); EXPECT_TRUE(resp); return *resp; } std::vector<thrift::MplsRoute> getMplsRoutes() { auto resp = openrThriftServerWrapper_->getOpenrCtrlHandler() ->semifuture_getMplsRoutes() .get(); EXPECT_TRUE(resp); return *resp; } int port{0}; std::shared_ptr<ThriftServer> server; ScopedServerThread fibThriftThread; messaging::ReplicateQueue<DecisionRouteUpdate> routeUpdatesQueue; messaging::ReplicateQueue<thrift::InterfaceDatabase> interfaceUpdatesQueue; messaging::ReplicateQueue<thrift::RouteDatabaseDelta> fibUpdatesQueue; fbzmq::Context context{}; // Create the serializer for write/read apache::thrift::CompactSerializer serializer; std::shared_ptr<Config> config; std::shared_ptr<Fib> fib; std::unique_ptr<std::thread> fibThread; std::shared_ptr<MockNetlinkFibHandler> mockFibHandler; private: // thriftServer to talk to Fib std::shared_ptr<OpenrThriftServerWrapper> openrThriftServerWrapper_{nullptr}; bool waitOnDecision_{false}; }; TEST_F(FibTestFixture, processRouteDb) { // Make sure fib starts with clean route database std::vector<thrift::UnicastRoute> routes; std::vector<thrift::MplsRoute> mplsRoutes; mockFibHandler->getRouteTableByClient(routes, kFibId); EXPECT_EQ(routes.size(), 0); mockFibHandler->getMplsRouteTableByClient(mplsRoutes, kFibId); EXPECT_EQ(mplsRoutes.size(), 0); // initial syncFib debounce mockFibHandler->waitForSyncFib(); mockFibHandler->waitForSyncMplsFib(); // Mimic decision pub sock publishing RouteDatabaseDelta thrift::RouteDatabase routeDb; *routeDb.thisNodeName_ref() = "node-1"; routeDb.unicastRoutes_ref()->emplace_back( createUnicastRoute(prefix2, {path1_2_1, path1_2_2})); { DecisionRouteUpdate routeUpdate; routeUpdate.unicastRoutesToUpdate.emplace_back( RibUnicastEntry(toIPNetwork(prefix2), {path1_2_1, path1_2_2})); routeUpdatesQueue.push(std::move(routeUpdate)); } int64_t countAdd = mockFibHandler->getAddRoutesCount(); // add routes mockFibHandler->waitForUpdateUnicastRoutes(); EXPECT_EQ(mockFibHandler->getAddRoutesCount(), 1); EXPECT_EQ(mockFibHandler->getDelRoutesCount(), 0); mockFibHandler->getRouteTableByClient(routes, kFibId); EXPECT_EQ(routes.size(), 1); EXPECT_TRUE(checkEqualRoutes(routeDb, getRouteDb())); // Update routes countAdd = mockFibHandler->getAddRoutesCount(); int64_t countDel = mockFibHandler->getDelRoutesCount(); routeDb.unicastRoutes_ref()->emplace_back( RibUnicastEntry(toIPNetwork(prefix3), {path1_3_1, path1_3_2}).toThrift()); { DecisionRouteUpdate routeUpdate; routeUpdate.unicastRoutesToUpdate.emplace_back( RibUnicastEntry(toIPNetwork(prefix3), {path1_3_1, path1_3_2})); routeUpdatesQueue.push(std::move(routeUpdate)); } // syncFib debounce mockFibHandler->waitForUpdateUnicastRoutes(); EXPECT_GT(mockFibHandler->getAddRoutesCount(), countAdd); EXPECT_EQ(mockFibHandler->getDelRoutesCount(), countDel); mockFibHandler->getRouteTableByClient(routes, kFibId); EXPECT_EQ(routes.size(), 2); EXPECT_TRUE(checkEqualRoutes(routeDb, getRouteDb())); // Update routes by removing some nextHop countAdd = mockFibHandler->getAddRoutesCount(); routeDb.unicastRoutes_ref()->clear(); routeDb.unicastRoutes_ref()->emplace_back( createUnicastRoute(prefix2, {path1_2_2, path1_2_3})); routeDb.unicastRoutes_ref()->emplace_back( createUnicastRoute(prefix3, {path1_3_2})); { DecisionRouteUpdate routeUpdate; routeUpdate.unicastRoutesToUpdate.emplace_back( RibUnicastEntry(toIPNetwork(prefix2), {path1_2_2, path1_2_3})); routeUpdate.unicastRoutesToUpdate.emplace_back( RibUnicastEntry(toIPNetwork(prefix3), {path1_3_2})); routeUpdatesQueue.push(std::move(routeUpdate)); } // syncFib debounce mockFibHandler->waitForUpdateUnicastRoutes(); EXPECT_GT(mockFibHandler->getAddRoutesCount(), countAdd); EXPECT_EQ(mockFibHandler->getDelRoutesCount(), countDel); mockFibHandler->getRouteTableByClient(routes, kFibId); EXPECT_EQ(routes.size(), 2); EXPECT_TRUE(checkEqualRoutes(routeDb, getRouteDb())); } TEST_F(FibTestFixture, processInterfaceDb) { // Make sure fib starts with clean route database std::vector<thrift::UnicastRoute> routes; std::vector<thrift::MplsRoute> mplsRoutes; mockFibHandler->getRouteTableByClient(routes, kFibId); EXPECT_EQ(routes.size(), 0); mockFibHandler->getMplsRouteTableByClient(mplsRoutes, kFibId); EXPECT_EQ(mplsRoutes.size(), 0); // initial syncFib debounce mockFibHandler->waitForSyncFib(); mockFibHandler->waitForSyncMplsFib(); // Mimic interface initially coming up thrift::InterfaceDatabase intfDb( FRAGILE, "node-1", { { path1_2_1.address_ref()->ifName_ref().value(), createThriftInterfaceInfo(true, 121, {}), }, { path1_2_2.address_ref()->ifName_ref().value(), createThriftInterfaceInfo(true, 122, {}), }, }, thrift::PerfEvents()); intfDb.perfEvents_ref().reset(); LOG(INFO) << "Pushing interface update"; interfaceUpdatesQueue.push(intfDb); // Mimic decision pub sock publishing RouteDatabaseDelta { DecisionRouteUpdate routeUpdate; routeUpdate.unicastRoutesToUpdate.emplace_back( RibUnicastEntry(toIPNetwork(prefix2), {path1_2_1, path1_2_2})); routeUpdate.unicastRoutesToUpdate.emplace_back( RibUnicastEntry(toIPNetwork(prefix1), {path1_2_1})); routeUpdate.mplsRoutesToUpdate.emplace_back( RibMplsEntry(label2, {mpls_path1_2_1, mpls_path1_2_2})); routeUpdate.mplsRoutesToUpdate.emplace_back( RibMplsEntry(label1, {mpls_path1_2_1})); routeUpdatesQueue.push(std::move(routeUpdate)); } mockFibHandler->waitForUpdateUnicastRoutes(); mockFibHandler->waitForUpdateMplsRoutes(); EXPECT_EQ(mockFibHandler->getAddRoutesCount(), 2); EXPECT_EQ(mockFibHandler->getAddMplsRoutesCount(), 2); mockFibHandler->getRouteTableByClient(routes, kFibId); EXPECT_EQ(routes.size(), 2); mockFibHandler->getMplsRouteTableByClient(mplsRoutes, kFibId); EXPECT_EQ(mplsRoutes.size(), 2); // Mimic interface going down thrift::InterfaceDatabase intfChange_1( FRAGILE, "node-1", { { path1_2_1.address_ref()->ifName_ref().value(), createThriftInterfaceInfo(false, 121, {}), }, }, thrift::PerfEvents()); intfChange_1.perfEvents_ref().reset(); LOG(INFO) << "Pushing interface update"; interfaceUpdatesQueue.push(intfChange_1); mockFibHandler->waitForDeleteUnicastRoutes(); mockFibHandler->waitForUpdateUnicastRoutes(); mockFibHandler->waitForDeleteMplsRoutes(); mockFibHandler->waitForUpdateMplsRoutes(); EXPECT_EQ(mockFibHandler->getAddRoutesCount(), 3); EXPECT_EQ(mockFibHandler->getDelRoutesCount(), 1); EXPECT_EQ(mockFibHandler->getAddMplsRoutesCount(), 3); EXPECT_EQ(mockFibHandler->getDelMplsRoutesCount(), 1); mockFibHandler->getRouteTableByClient(routes, kFibId); EXPECT_EQ(routes.size(), 1); mockFibHandler->getMplsRouteTableByClient(mplsRoutes, kFibId); EXPECT_EQ(mplsRoutes.size(), 1); // // Send new route for prefix2 (see it gets updated right through) // { DecisionRouteUpdate routeUpdate; routeUpdate.unicastRoutesToUpdate.emplace_back( RibUnicastEntry(toIPNetwork(prefix1), {path1_2_2})); routeUpdate.mplsRoutesToUpdate.emplace_back( RibMplsEntry(label1, {mpls_path1_2_2})); routeUpdatesQueue.push(std::move(routeUpdate)); } mockFibHandler->waitForUpdateUnicastRoutes(); mockFibHandler->waitForUpdateMplsRoutes(); EXPECT_EQ(mockFibHandler->getAddRoutesCount(), 4); EXPECT_EQ(mockFibHandler->getDelRoutesCount(), 1); EXPECT_EQ(mockFibHandler->getAddMplsRoutesCount(), 4); EXPECT_EQ(mockFibHandler->getDelMplsRoutesCount(), 1); mockFibHandler->getRouteTableByClient(routes, kFibId); EXPECT_EQ(routes.size(), 2); mockFibHandler->getMplsRouteTableByClient(mplsRoutes, kFibId); EXPECT_EQ(mplsRoutes.size(), 2); // Mimic interface going down // the route entry associated with the prefix shall be removed this time thrift::InterfaceDatabase intfChange_2( FRAGILE, "node-1", { { path1_2_2.address_ref()->ifName_ref().value(), createThriftInterfaceInfo(false, 122, {}), }, }, thrift::PerfEvents()); intfChange_2.perfEvents_ref().reset(); LOG(INFO) << "Pushing interface update"; interfaceUpdatesQueue.push(intfChange_2); mockFibHandler->waitForDeleteUnicastRoutes(); mockFibHandler->waitForDeleteMplsRoutes(); EXPECT_EQ(mockFibHandler->getAddRoutesCount(), 4); EXPECT_EQ(mockFibHandler->getDelRoutesCount(), 3); EXPECT_EQ(mockFibHandler->getAddMplsRoutesCount(), 4); EXPECT_EQ(mockFibHandler->getDelMplsRoutesCount(), 3); mockFibHandler->getRouteTableByClient(routes, kFibId); EXPECT_EQ(routes.size(), 0); mockFibHandler->getMplsRouteTableByClient(mplsRoutes, kFibId); EXPECT_EQ(mplsRoutes.size(), 0); // // Bring up both of these interfaces and verify that route appears back // LOG(INFO) << "Pushing interface update"; interfaceUpdatesQueue.push(intfDb); mockFibHandler->waitForUpdateUnicastRoutes(); mockFibHandler->waitForUpdateMplsRoutes(); EXPECT_EQ(mockFibHandler->getAddRoutesCount(), 6); EXPECT_EQ(mockFibHandler->getDelRoutesCount(), 3); EXPECT_EQ(mockFibHandler->getAddMplsRoutesCount(), 6); EXPECT_EQ(mockFibHandler->getDelMplsRoutesCount(), 3); mockFibHandler->getRouteTableByClient(routes, kFibId); EXPECT_EQ(routes.size(), 2); mockFibHandler->getMplsRouteTableByClient(mplsRoutes, kFibId); EXPECT_EQ(mplsRoutes.size(), 2); } // verify when iterface goes down, the nexthop of unicast route with // no interface name specified won't get dropped. TEST_F(FibTestFixture, processInterfaceDbWithNoIfnameNexthop) { // Make sure fib starts with clean route database std::vector<thrift::UnicastRoute> routes; std::vector<thrift::MplsRoute> mplsRoutes; mockFibHandler->getRouteTableByClient(routes, kFibId); EXPECT_EQ(routes.size(), 0); mockFibHandler->getMplsRouteTableByClient(mplsRoutes, kFibId); EXPECT_EQ(mplsRoutes.size(), 0); // initial syncFib debounce mockFibHandler->waitForSyncFib(); mockFibHandler->waitForSyncMplsFib(); // Mimic interface initially coming up thrift::InterfaceDatabase intfDb( FRAGILE, "node-1", { { path1_2_1.address_ref()->ifName_ref().value(), createThriftInterfaceInfo(true, 121, {}), }, }, thrift::PerfEvents()); intfDb.perfEvents_ref().reset(); LOG(INFO) << "Pushing interface update"; interfaceUpdatesQueue.push(intfDb); // Mimic decision pub sock publishing RouteDatabaseDelta DecisionRouteUpdate routeUpdate; auto path1_2_1_no_if_name = path1_2_1; path1_2_1_no_if_name.address_ref()->ifName_ref().reset(); routeUpdate.unicastRoutesToUpdate.emplace_back( RibUnicastEntry(toIPNetwork(prefix2), {path1_2_1_no_if_name})); routeUpdate.unicastRoutesToUpdate.emplace_back( RibUnicastEntry(toIPNetwork(prefix1), {path1_2_1})); routeUpdatesQueue.push(std::move(routeUpdate)); mockFibHandler->waitForUpdateUnicastRoutes(); EXPECT_EQ(mockFibHandler->getAddRoutesCount(), 2); mockFibHandler->getRouteTableByClient(routes, kFibId); LOG(INFO) << toString(routes[0]); LOG(INFO) << toString(routes[1]); EXPECT_EQ(routes.size(), 2); // Mimic interface going down thrift::InterfaceDatabase intfChange_1( FRAGILE, "node-1", { { path1_2_1.address_ref()->ifName_ref().value(), createThriftInterfaceInfo(false, 121, {}), }, }, thrift::PerfEvents()); intfChange_1.perfEvents_ref().reset(); LOG(INFO) << "Pushing interface update"; interfaceUpdatesQueue.push(intfChange_1); mockFibHandler->waitForDeleteUnicastRoutes(); EXPECT_EQ(mockFibHandler->getAddRoutesCount(), 2); EXPECT_EQ(mockFibHandler->getDelRoutesCount(), 1); mockFibHandler->getRouteTableByClient(routes, kFibId); EXPECT_EQ(routes.size(), 1); // verify that the nexthop without interface name is still there EXPECT_EQ(routes[0].nextHops_ref()->size(), 1); } TEST_F(FibTestFixture, basicAddAndDelete) { // Make sure fib starts with clean route database std::vector<thrift::UnicastRoute> routes; std::vector<thrift::MplsRoute> mplsRoutes; mockFibHandler->getRouteTableByClient(routes, kFibId); EXPECT_EQ(routes.size(), 0); mockFibHandler->getMplsRouteTableByClient(mplsRoutes, kFibId); EXPECT_EQ(mplsRoutes.size(), 0); // initial syncFib debounce mockFibHandler->waitForSyncFib(); mockFibHandler->waitForSyncMplsFib(); // Mimic decision pub sock publishing RouteDatabaseDelta { DecisionRouteUpdate routeUpdate; routeUpdate.unicastRoutesToUpdate.emplace_back( RibUnicastEntry(toIPNetwork(prefix1), {path1_2_1, path1_2_2})); routeUpdate.unicastRoutesToUpdate.emplace_back( RibUnicastEntry(toIPNetwork(prefix3), {path1_3_1, path1_3_2})); routeUpdate.mplsRoutesToUpdate.emplace_back( RibMplsEntry(label1, {mpls_path1_2_1, mpls_path1_2_2})); routeUpdate.mplsRoutesToUpdate.emplace_back( RibMplsEntry(label2, {mpls_path1_2_2})); routeUpdate.mplsRoutesToUpdate.emplace_back( RibMplsEntry(label3, {mpls_path1_2_1})); routeUpdatesQueue.push(std::move(routeUpdate)); } // wait mockFibHandler->waitForUpdateUnicastRoutes(); mockFibHandler->waitForUpdateMplsRoutes(); // verify routes mockFibHandler->getRouteTableByClient(routes, kFibId); EXPECT_EQ(routes.size(), 2); EXPECT_EQ(mockFibHandler->getAddRoutesCount(), 2); EXPECT_EQ(mockFibHandler->getDelRoutesCount(), 0); mockFibHandler->getMplsRouteTableByClient(mplsRoutes, kFibId); EXPECT_EQ(mplsRoutes.size(), 3); EXPECT_EQ(mockFibHandler->getAddMplsRoutesCount(), 3); EXPECT_EQ(mockFibHandler->getDelMplsRoutesCount(), 0); // delete one route { DecisionRouteUpdate routeUpdate; routeUpdate.unicastRoutesToDelete = {toIPNetwork(prefix3)}; routeUpdate.mplsRoutesToDelete = {label1, label3}; routeUpdatesQueue.push(std::move(routeUpdate)); } mockFibHandler->waitForDeleteUnicastRoutes(); mockFibHandler->waitForDeleteMplsRoutes(); mockFibHandler->getRouteTableByClient(routes, kFibId); EXPECT_EQ(routes.size(), 1); EXPECT_EQ(routes.at(0).dest, prefix1); EXPECT_EQ(mockFibHandler->getAddRoutesCount(), 2); EXPECT_EQ(mockFibHandler->getDelRoutesCount(), 1); mockFibHandler->getMplsRouteTableByClient(mplsRoutes, kFibId); EXPECT_EQ(mplsRoutes.size(), 1); EXPECT_EQ(mplsRoutes.at(0).topLabel, label2); EXPECT_EQ(mockFibHandler->getAddMplsRoutesCount(), 3); EXPECT_EQ(mockFibHandler->getDelMplsRoutesCount(), 2); // add back that route { DecisionRouteUpdate routeUpdate; routeUpdate.unicastRoutesToUpdate.emplace_back( RibUnicastEntry(toIPNetwork(prefix3), {path1_3_1, path1_3_2})); routeUpdate.mplsRoutesToUpdate.emplace_back( RibMplsEntry(label1, {mpls_path1_2_1, mpls_path1_2_2})); routeUpdatesQueue.push(std::move(routeUpdate)); } mockFibHandler->waitForUpdateUnicastRoutes(); mockFibHandler->waitForUpdateMplsRoutes(); mockFibHandler->getRouteTableByClient(routes, kFibId); EXPECT_EQ(routes.size(), 2); EXPECT_EQ(mockFibHandler->getAddRoutesCount(), 3); EXPECT_EQ(mockFibHandler->getDelRoutesCount(), 1); mockFibHandler->getMplsRouteTableByClient(mplsRoutes, kFibId); EXPECT_EQ(mplsRoutes.size(), 2); EXPECT_EQ(mockFibHandler->getAddMplsRoutesCount(), 4); EXPECT_EQ(mockFibHandler->getDelMplsRoutesCount(), 2); } TEST_F(FibTestFixture, fibRestart) { // Make sure fib starts with clean route database std::vector<thrift::UnicastRoute> routes; std::vector<thrift::MplsRoute> mplsRoutes; mockFibHandler->getRouteTableByClient(routes, kFibId); EXPECT_EQ(routes.size(), 0); mockFibHandler->getMplsRouteTableByClient(mplsRoutes, kFibId); EXPECT_EQ(mplsRoutes.size(), 0); // Mimic decision pub sock publishing RouteDatabaseDelta DecisionRouteUpdate routeUpdate; routeUpdate.unicastRoutesToUpdate.emplace_back( RibUnicastEntry(toIPNetwork(prefix1), {path1_2_1, path1_2_2})); routeUpdate.mplsRoutesToUpdate.emplace_back( RibMplsEntry(label1, {mpls_path1_2_1, mpls_path1_2_2})); routeUpdate.mplsRoutesToUpdate.emplace_back( RibMplsEntry(label2, {mpls_path1_2_2})); routeUpdatesQueue.push(std::move(routeUpdate)); // initial syncFib debounce mockFibHandler->waitForSyncFib(); mockFibHandler->waitForSyncMplsFib(); mockFibHandler->getRouteTableByClient(routes, kFibId); EXPECT_EQ(routes.size(), 1); mockFibHandler->getMplsRouteTableByClient(mplsRoutes, kFibId); EXPECT_EQ(mplsRoutes.size(), 2); // Restart mockFibHandler->restart(); mockFibHandler->getRouteTableByClient(routes, kFibId); EXPECT_EQ(routes.size(), 0); mockFibHandler->getMplsRouteTableByClient(mplsRoutes, kFibId); EXPECT_EQ(mplsRoutes.size(), 0); // syncFib debounce mockFibHandler->waitForSyncFib(); mockFibHandler->waitForSyncMplsFib(); mockFibHandler->getRouteTableByClient(routes, kFibId); EXPECT_EQ(routes.size(), 1); mockFibHandler->getMplsRouteTableByClient(mplsRoutes, kFibId); EXPECT_EQ(mplsRoutes.size(), 2); } class FibTestFixtureWaitOnDecision : public FibTestFixture { public: FibTestFixtureWaitOnDecision() : FibTestFixture(true) {} }; TEST_F(FibTestFixtureWaitOnDecision, WaitOnDecision) { // Make sure fib starts with clean route database std::vector<thrift::UnicastRoute> routes; std::vector<thrift::MplsRoute> mplsRoutes; mockFibHandler->getRouteTableByClient(routes, kFibId); EXPECT_EQ(routes.size(), 0); mockFibHandler->getMplsRouteTableByClient(mplsRoutes, kFibId); EXPECT_EQ(mplsRoutes.size(), 0); // Mimic decision pub sock publishing RouteDatabaseDelta DecisionRouteUpdate routeUpdate; routeUpdate.unicastRoutesToUpdate.emplace_back( RibUnicastEntry(toIPNetwork(prefix1), {path1_2_1, path1_2_2})); routeUpdate.mplsRoutesToUpdate.emplace_back( RibMplsEntry(label1, {mpls_path1_2_1, mpls_path1_2_2})); routeUpdate.mplsRoutesToUpdate.emplace_back( RibMplsEntry(label2, {mpls_path1_2_2})); routeUpdatesQueue.push(std::move(routeUpdate)); // initial syncFib debounce mockFibHandler->waitForSyncFib(); mockFibHandler->waitForSyncMplsFib(); // ensure no other calls occured EXPECT_EQ(mockFibHandler->getFibSyncCount(), 1); EXPECT_EQ(mockFibHandler->getAddRoutesCount(), 0); EXPECT_EQ(mockFibHandler->getDelRoutesCount(), 0); EXPECT_EQ(mockFibHandler->getFibMplsSyncCount(), 2); EXPECT_EQ(mockFibHandler->getAddMplsRoutesCount(), 0); EXPECT_EQ(mockFibHandler->getDelMplsRoutesCount(), 0); } TEST_F(FibTestFixture, getMslpRoutesFilteredTest) { // Make sure fib starts with clean route database std::vector<thrift::UnicastRoute> routes; std::vector<thrift::MplsRoute> mplsRoutes; mockFibHandler->getRouteTableByClient(routes, kFibId); mockFibHandler->getMplsRouteTableByClient(mplsRoutes, kFibId); EXPECT_EQ(routes.size(), 0); EXPECT_EQ(mplsRoutes.size(), 0); // initial syncFib debounce mockFibHandler->waitForSyncFib(); mockFibHandler->waitForSyncMplsFib(); // Mimic decision pub sock publishing RouteDatabaseDelta auto route1 = RibMplsEntry(label1, {mpls_path1_2_1, mpls_path1_2_2}); auto route2 = RibMplsEntry(label2, {mpls_path1_2_2}); auto route3 = RibMplsEntry(label3, {mpls_path1_2_1}); const auto& tRoute1 = route1.toThrift(); const auto& tRoute2 = route2.toThrift(); const auto& tRoute3 = route3.toThrift(); DecisionRouteUpdate routeUpdate; routeUpdate.mplsRoutesToUpdate.emplace_back(std::move(route1)); routeUpdate.mplsRoutesToUpdate.emplace_back(std::move(route2)); routeUpdate.mplsRoutesToUpdate.emplace_back(std::move(route3)); routeUpdatesQueue.push(std::move(routeUpdate)); // wait for mpls mockFibHandler->waitForUpdateMplsRoutes(); // verify mpls routes in DB mockFibHandler->getMplsRouteTableByClient(mplsRoutes, kFibId); EXPECT_EQ(mplsRoutes.size(), 3); EXPECT_EQ(mockFibHandler->getAddMplsRoutesCount(), 3); EXPECT_EQ(mockFibHandler->getDelMplsRoutesCount(), 0); // 1. check the MPLS filtering API auto labels = std::unique_ptr<std::vector<int32_t>>( new std::vector<int32_t>({1, 1, 3})); // matching route1 and route3 thrift::RouteDatabase responseDb; const auto& filteredRoutes = getMplsRoutesFiltered(std::move(labels)); *responseDb.mplsRoutes_ref() = filteredRoutes; // expected routesDB after filtering - delete duplicate entries thrift::RouteDatabase expectedDb; *expectedDb.thisNodeName_ref() = "node-1"; *expectedDb.mplsRoutes_ref() = {tRoute1, tRoute3}; EXPECT_TRUE(checkEqualMplsRoutes(responseDb, expectedDb)); // 2. check getting all MPLS routes API thrift::RouteDatabase allRoutesDb; *allRoutesDb.mplsRoutes_ref() = getMplsRoutes(); // expected routesDB for all MPLS Routes thrift::RouteDatabase allRoutesExpectedDb; *allRoutesExpectedDb.thisNodeName_ref() = "node-1"; *allRoutesExpectedDb.mplsRoutes_ref() = {tRoute1, tRoute2, tRoute3}; *expectedDb.mplsRoutes_ref() = {tRoute1, tRoute2, tRoute3}; EXPECT_TRUE(checkEqualMplsRoutes(allRoutesDb, allRoutesExpectedDb)); // 3. check filtering API with empty input list - return all MPLS routes auto emptyLabels = std::unique_ptr<std::vector<int32_t>>(new std::vector<int32_t>({})); thrift::RouteDatabase responseAllDb; *responseAllDb.mplsRoutes_ref() = getMplsRoutesFiltered(std::move(emptyLabels)); EXPECT_TRUE(checkEqualMplsRoutes(responseAllDb, allRoutesExpectedDb)); // 4. check if no result found auto notFoundFilter = std::unique_ptr<std::vector<std::int32_t>>( new std::vector<std::int32_t>({4, 5})); const auto& notFoundResp = getMplsRoutesFiltered(std::move(notFoundFilter)); EXPECT_EQ(notFoundResp.size(), 0); } TEST_F(FibTestFixture, getUnicastRoutesFilteredTest) { // Make sure fib starts with clean route database std::vector<thrift::UnicastRoute> routes; mockFibHandler->getRouteTableByClient(routes, kFibId); EXPECT_EQ(routes.size(), 0); // initial syncFib debounce mockFibHandler->waitForSyncFib(); const auto prefix1 = toIpPrefix("192.168.20.16/28"); const auto prefix2 = toIpPrefix("192.168.0.0/16"); const auto prefix3 = toIpPrefix("fd00::48:2:0/128"); const auto prefix4 = toIpPrefix("fd00::48:2:0/126"); auto route1 = RibUnicastEntry(toIPNetwork(prefix1), {}); auto route2 = RibUnicastEntry(toIPNetwork(prefix2), {}); auto route3 = RibUnicastEntry(toIPNetwork(prefix3), {}); auto route4 = RibUnicastEntry(toIPNetwork(prefix4), {}); const auto& tRoute1 = route1.toThrift(); const auto& tRoute2 = route2.toThrift(); const auto& tRoute3 = route3.toThrift(); const auto& tRoute4 = route4.toThrift(); // add routes to DB and update DB DecisionRouteUpdate routeUpdate; routeUpdate.unicastRoutesToUpdate.emplace_back(std::move(route1)); routeUpdate.unicastRoutesToUpdate.emplace_back(std::move(route2)); routeUpdate.unicastRoutesToUpdate.emplace_back(std::move(route3)); routeUpdate.unicastRoutesToUpdate.emplace_back(std::move(route4)); routeUpdatesQueue.push(std::move(routeUpdate)); mockFibHandler->waitForUpdateUnicastRoutes(); mockFibHandler->getRouteTableByClient(routes, kFibId); EXPECT_EQ(routes.size(), 4); // input filter prefix list auto filter = std::unique_ptr<std::vector<std::string>>(new std::vector<std::string>({ "192.168.20.16/28", // match prefix1 "192.168.20.19", // match prefix1 "192.168.0.0", // match prefix2 "192.168.0.0/18", // match prefix2 "10.46.8.0", // no match "fd00::48:2:0/127", // match prefix4 "fd00::48:2:0/125" // no match })); // expected routesDB after filtering - delete duplicate entries thrift::RouteDatabase expectedDb; *expectedDb.thisNodeName_ref() = "node-1"; expectedDb.unicastRoutes_ref()->emplace_back(tRoute1); expectedDb.unicastRoutes_ref()->emplace_back(tRoute2); expectedDb.unicastRoutes_ref()->emplace_back(tRoute4); // check if match correctly thrift::RouteDatabase responseDb; const auto& responseRoutes = getUnicastRoutesFiltered(std::move(filter)); *responseDb.unicastRoutes_ref() = responseRoutes; EXPECT_TRUE(checkEqualRoutes(expectedDb, responseDb)); // check when get empty input - return all unicast routes thrift::RouteDatabase allRouteDb; allRouteDb.unicastRoutes_ref()->emplace_back(tRoute1); allRouteDb.unicastRoutes_ref()->emplace_back(tRoute2); allRouteDb.unicastRoutes_ref()->emplace_back(tRoute3); allRouteDb.unicastRoutes_ref()->emplace_back(tRoute4); auto emptyParamRet = std::unique_ptr<std::vector<std::string>>(new std::vector<std::string>()); const auto& allRoutes = getUnicastRoutesFiltered(std::move(emptyParamRet)); thrift::RouteDatabase allRoutesRespDb; *allRoutesRespDb.unicastRoutes_ref() = allRoutes; EXPECT_TRUE(checkEqualRoutes(allRouteDb, allRoutesRespDb)); // check getUnicastRoutes() API - return all unicast routes const auto& allRoute = getUnicastRoutes(); thrift::RouteDatabase allRoutesApiDb; *allRoutesApiDb.unicastRoutes_ref() = allRoute; EXPECT_TRUE(checkEqualRoutes(allRouteDb, allRoutesApiDb)); // check when no result found auto notFoundFilter = std::unique_ptr<std::vector<std::string>>( new std::vector<std::string>({"10.46.8.0", "10.46.8.0/24"})); const auto& notFoundResp = getUnicastRoutesFiltered(std::move(notFoundFilter)); EXPECT_EQ(notFoundResp.size(), 0); } TEST_F(FibTestFixture, longestPrefixMatchTest) { std::unordered_map<thrift::IpPrefix, thrift::UnicastRoute> unicastRoutes; const auto& defaultRoute = toIpPrefix("::/0"); const auto& dbPrefix1 = toIpPrefix("192.168.0.0/16"); const auto& dbPrefix2 = toIpPrefix("192.168.0.0/20"); const auto& dbPrefix3 = toIpPrefix("192.168.0.0/24"); const auto& dbPrefix4 = toIpPrefix("192.168.20.16/28"); unicastRoutes[defaultRoute] = createUnicastRoute(defaultRoute, {}); unicastRoutes[dbPrefix1] = createUnicastRoute(dbPrefix1, {}); unicastRoutes[dbPrefix2] = createUnicastRoute(dbPrefix2, {}); unicastRoutes[dbPrefix3] = createUnicastRoute(dbPrefix3, {}); unicastRoutes[dbPrefix4] = createUnicastRoute(dbPrefix4, {}); const auto inputdefaultRoute = folly::IPAddress::tryCreateNetwork("::/0").value(); const auto inputPrefix1 = folly::IPAddress::tryCreateNetwork("192.168.20.19").value(); const auto inputPrefix2 = folly::IPAddress::tryCreateNetwork("192.168.20.16/28").value(); const auto inputPrefix3 = folly::IPAddress::tryCreateNetwork("192.168.0.0").value(); const auto inputPrefix4 = folly::IPAddress::tryCreateNetwork("192.168.0.0/14").value(); const auto inputPrefix5 = folly::IPAddress::tryCreateNetwork("192.168.0.0/18").value(); const auto inputPrefix6 = folly::IPAddress::tryCreateNetwork("192.168.0.0/22").value(); const auto inputPrefix7 = folly::IPAddress::tryCreateNetwork("192.168.0.0/26").value(); // default route matching const auto& result = Fib::longestPrefixMatch(inputdefaultRoute, unicastRoutes); EXPECT_TRUE(result.has_value()); EXPECT_EQ(result.value(), defaultRoute); // input 192.168.20.19 matched 192.168.20.16/28 const auto& result1 = Fib::longestPrefixMatch(inputPrefix1, unicastRoutes); EXPECT_TRUE(result1.has_value()); EXPECT_EQ(result1.value(), dbPrefix4); // input 192.168.20.16/28 matched 192.168.20.16/28 const auto& result2 = Fib::longestPrefixMatch(inputPrefix2, unicastRoutes); EXPECT_TRUE(result2.has_value()); EXPECT_EQ(result2.value(), dbPrefix4); // input 192.168.0.0 matched 192.168.0.0/24 const auto& result3 = Fib::longestPrefixMatch(inputPrefix3, unicastRoutes); EXPECT_TRUE(result3.has_value()); EXPECT_EQ(result3.value(), dbPrefix3); // // input 192.168.0.0/14 has no match const auto& result4 = Fib::longestPrefixMatch(inputPrefix4, unicastRoutes); EXPECT_TRUE(not result4.has_value()); // input 192.168.0.0/18 matched 192.168.0.0/16 const auto& result5 = Fib::longestPrefixMatch(inputPrefix5, unicastRoutes); EXPECT_TRUE(result5.has_value()); EXPECT_EQ(result5.value(), dbPrefix1); // input 192.168.0.0/22 matched 192.168.0.0/20 const auto& result6 = Fib::longestPrefixMatch(inputPrefix6, unicastRoutes); EXPECT_TRUE(result6.has_value()); EXPECT_EQ(result6.value(), dbPrefix2); // input 192.168.0.0/26 matched 192.168.0.0/24 const auto& result7 = Fib::longestPrefixMatch(inputPrefix7, unicastRoutes); EXPECT_TRUE(result7.has_value()); EXPECT_EQ(result7.value(), dbPrefix3); } TEST_F(FibTestFixture, doNotInstall) { // Make sure fib starts with clean route database std::vector<thrift::UnicastRoute> routes; mockFibHandler->getRouteTableByClient(routes, kFibId); EXPECT_EQ(routes.size(), 0); const auto prefix1 = toIpPrefix("192.168.20.16/28"); const auto prefix2 = toIpPrefix("192.168.0.0/16"); const auto prefix3 = toIpPrefix("fd00::48:2:0/128"); const auto prefix4 = toIpPrefix("fd00::48:2:0/126"); auto route1 = RibUnicastEntry(toIPNetwork(prefix1), {}); auto route2 = RibUnicastEntry(toIPNetwork(prefix2), {}); auto route3 = RibUnicastEntry(toIPNetwork(prefix3), {}); auto route4 = RibUnicastEntry(toIPNetwork(prefix4), {}); route1.doNotInstall = true; route3.doNotInstall = true; // add routes to DB and update DB { DecisionRouteUpdate routeUpdate; routeUpdate.unicastRoutesToUpdate.emplace_back(route1); routeUpdate.unicastRoutesToUpdate.emplace_back(route2); routeUpdatesQueue.push(std::move(routeUpdate)); } mockFibHandler->waitForSyncFib(); mockFibHandler->getRouteTableByClient(routes, kFibId); // only 1 route is installable EXPECT_EQ(routes.size(), 1); // add routes to DB and update DB { DecisionRouteUpdate routeUpdate; routeUpdate.unicastRoutesToUpdate.emplace_back(route3); routeUpdate.unicastRoutesToUpdate.emplace_back(route4); routeUpdatesQueue.push(std::move(routeUpdate)); } mockFibHandler->waitForUpdateUnicastRoutes(); mockFibHandler->getRouteTableByClient(routes, kFibId); // now 2 routes are installable EXPECT_EQ(routes.size(), 2); } /** * Introduce error in route programming by detaching interface * - Verify that routes are programmed serially * - Verify that routes are synced after encountering the error */ TEST_F(FibTestFixture, ThriftServerError) { // InterfaceUpdates - Send initial interface update thrift::InterfaceDatabase intfDb; *intfDb.thisNodeName_ref() = "node-1"; intfDb.interfaces_ref()->emplace( "iface_1_2_1", createThriftInterfaceInfo(true, 121, {})); intfDb.interfaces_ref()->emplace( "iface_1_2_2", createThriftInterfaceInfo(true, 122, {})); interfaceUpdatesQueue.push(intfDb); // Wait for route sync before starting rest of the UT mockFibHandler->waitForSyncFib(); mockFibHandler->waitForSyncMplsFib(); // // NOTE: Set the failure injection to throw ERROR on 50% of the requests // BaseThriftServer::FailureInjection failureInjection; failureInjection.errorFraction = 0.5; server->setFailureInjection(failureInjection); // RouteUpdates - Send route update for unicast & mpls routes DecisionRouteUpdate routeUpdate; routeUpdate.unicastRoutesToUpdate.emplace_back( RibUnicastEntry(toIPNetwork(prefix2), {path1_2_2})); routeUpdate.unicastRoutesToUpdate.emplace_back( RibUnicastEntry(toIPNetwork(prefix1), {path1_2_1})); routeUpdate.mplsRoutesToUpdate.emplace_back( RibMplsEntry(label2, {mpls_path1_2_2})); routeUpdate.mplsRoutesToUpdate.emplace_back( RibMplsEntry(label1, {mpls_path1_2_1})); routeUpdatesQueue.push(std::move(routeUpdate)); // InterfaceUpdates - Send interface down event intfDb.interfaces_ref()->at("iface_1_2_1").isUp_ref() = false; interfaceUpdatesQueue.push(intfDb); // // Wait for either success case or for failure // while (true) { if (mockFibHandler->getAddRoutesCount() == 2 && mockFibHandler->getAddMplsRoutesCount() == 2 && mockFibHandler->getDelRoutesCount() == 1 && mockFibHandler->getDelMplsRoutesCount() == 1) { // SUCCESS; nothing to do return; } int64_t failures = folly::get_default( facebook::fb303::fbData->getCounters(), "fib.thrift.failure.add_del_route.count", 0); if (failures > 0) { // FAILURE; wait for FibSync break; } std::this_thread::yield(); } // // Reset failure inject and wait for FibSync // server->setFailureInjection(BaseThriftServer::FailureInjection()); mockFibHandler->waitForSyncFib(); mockFibHandler->waitForSyncMplsFib(); } int main(int argc, char* argv[]) { // Parse command line flags testing::InitGoogleTest(&argc, argv); testing::InitGoogleMock(&argc, argv); folly::init(&argc, &argv); google::InstallFailureSignalHandler(); auto rc = RUN_ALL_TESTS(); // Run the tests return rc; }
[ "facebook-github-bot@users.noreply.github.com" ]
facebook-github-bot@users.noreply.github.com
af4250d3d3542bcb73ea9713a5235bd484028ace
00d4faf078aee606836b5be828abb7f6ddd59036
/Code/Source/Common/Geometry/vtkConstrainedBlend.cxx
98dce5879d1dd4b3e0291702ed464bd8045ca9f1
[]
no_license
osmsc/mytravis
843a605322c8833a429d4a4232c311283dd5f0bc
ad2214ae11794ff5d8b57fbd2e1bcca741091f40
refs/heads/master
2021-01-12T02:36:43.971963
2017-01-05T08:40:41
2017-01-05T08:40:41
78,076,412
1
0
null
null
null
null
UTF-8
C++
false
false
9,632
cxx
/*========================================================================= * * Copyright (c) 2015 The Regents of the University of California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject * to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * *=========================================================================*/ /** @file vtkConstrainedBlend.cxx * @brief This implements the vtkConstrainedBlend filter as a class * * @author Adam Updegrove * @author updega2@gmail.com * @author UC Berkeley * @author shaddenlab.berkeley.edu */ #include "vtkConstrainedBlend.h" #include "vtkInformation.h" #include "vtkInformationVector.h" #include "vtkObjectFactory.h" #include "vtkPolyData.h" #include "vtkUnstructuredGrid.h" #include "vtkSmartPointer.h" #include "vtkStreamingDemandDrivenPipeline.h" #include "vtkCellArray.h" #include "vtkIntArray.h" #include "vtkDoubleArray.h" #include "vtkCellData.h" #include "vtkPointData.h" #include "vtkSmoothPolyDataFilter.h" #include "vtkLocalQuadricDecimation.h" #include "vtkCGSmooth.h" #include "vtkFloatArray.h" #include "vtkPolyDataNormals.h" #include "vtkLocalLoopSubdivisionFilter.h" #include "vtkLocalSmoothPolyDataFilter.h" #include "vtkCellLocator.h" #include "vtkGenericCell.h" #include "vtkMath.h" #include "math.h" #include "sparse_matrix.h" #include <iostream> vtkCxxRevisionMacro(vtkConstrainedBlend, "$Revision: 0.0 $"); vtkStandardNewMacro(vtkConstrainedBlend); vtkConstrainedBlend::vtkConstrainedBlend() { this->CellArrayName = 0; this->PointArrayName = 0; this->Weight = 0.2; this->UsePointArray = 0; this->UseCellArray = 0; this->NumBlendOperations = 2; this->NumSubBlendOperations = 2; this->NumCGSmoothOperations = 3; this->NumLapSmoothOperations = 50; this->RelaxationFactor = 0.01; this->NumGradientSolves = 20; this->DecimationTargetReduction = 0.01; this->NumSubdivisionIterations = 1; } vtkConstrainedBlend::~vtkConstrainedBlend() { } void vtkConstrainedBlend::PrintSelf(ostream& os, vtkIndent indent) { } // Generate Separated Surfaces with Region ID Numbers int vtkConstrainedBlend::RequestData( vtkInformation *vtkNotUsed(request), vtkInformationVector **inputVector, vtkInformationVector *outputVector) { // get the input and output vtkPolyData *input = vtkPolyData::GetData(inputVector[0]); vtkPolyData *output = vtkPolyData::GetData(outputVector); // Define variables used by the algorithm vtkSmartPointer<vtkPoints> inpts = vtkSmartPointer<vtkPoints>::New(); vtkSmartPointer<vtkCellArray> inPolys = vtkSmartPointer<vtkCellArray>::New(); vtkIdType numPts, numPolys; vtkIdType newId, cellId,pointId; //Get input points, polys and set the up in the vtkPolyData mesh inpts = input->GetPoints(); inPolys = input->GetPolys(); //Get the number of Polys for scalar allocation numPolys = input->GetNumberOfPolys(); numPts = input->GetNumberOfPoints(); //Check the input to make sure it is there if (numPolys < 1) { vtkDebugMacro("No input!"); return 1; } if (this->UsePointArray) { if (this->GetArrays(input,0) != 1) { std::cout<<"No Point Array Named "<<this->PointArrayName<<" on surface"<<endl; return 0; } } if (this->UseCellArray) { if (this->GetArrays(input,1) != 1) { std::cout<<"No Cell Array Named "<<this->CellArrayName<<" on surface"<<endl; return 0; } } vtkSmartPointer<vtkPolyData> tmp = vtkSmartPointer<vtkPolyData>::New(); tmp->DeepCopy(input); for (int i=0;i<this->NumBlendOperations;i++) { for (int j=0;j<this->NumSubBlendOperations;j++) { std::cout<<"CGSmooth!"<<endl; this->CGSmooth(tmp); std::cout<<"LapSmooth!"<<endl; this->LaplacianSmooth(tmp); std::cout<<"Decimate!"<<endl; this->Decimate(tmp); } std::cout<<"Subdivide!"<<endl; this->Subdivide(tmp); } output->DeepCopy(tmp); return 1; } int vtkConstrainedBlend::GetArrays(vtkPolyData *object,int type) { vtkIdType i; int exists = 0; int numArrays; if (type == 0) { numArrays = object->GetPointData()->GetNumberOfArrays(); for (i=0;i<numArrays;i++) { if (!strcmp(object->GetPointData()->GetArrayName(i), this->PointArrayName)) { exists = 1; } } } else { numArrays = object->GetCellData()->GetNumberOfArrays(); for (i=0;i<numArrays;i++) { if (!strcmp(object->GetCellData()->GetArrayName(i), this->CellArrayName)) { exists = 1; } } } if (exists) { if (type == 0) { this->PointArray = vtkIntArray::SafeDownCast( object->GetPointData()->GetArray(this->PointArrayName)); } else { this->CellArray = vtkIntArray::SafeDownCast( object->GetCellData()->GetArray(this->CellArrayName)); } } return exists; } int vtkConstrainedBlend::Decimate(vtkPolyData *pd) { vtkSmartPointer<vtkLocalQuadricDecimation> decimator = vtkSmartPointer<vtkLocalQuadricDecimation>::New(); decimator->SetInputData(pd); if (this->UsePointArray) { decimator->SetDecimatePointArrayName(this->PointArrayName); decimator->UsePointArrayOn(); } if (this->UseCellArray) { decimator->SetDecimateCellArrayName(this->CellArrayName); decimator->UseCellArrayOn(); } decimator->SetTargetReduction(this->DecimationTargetReduction); decimator->Update(); pd->DeepCopy(decimator->GetOutput()); if (this->UsePointArray) { if (this->GetArrays(pd,0) != 1) { std::cout<<"No Point Array Named "<<this->PointArrayName<<" on surface"<<endl; return 0; } } if (this->UseCellArray) { if (this->GetArrays(pd,1) != 1) { std::cout<<"No Point Array Named "<<this->CellArrayName<<" on surface"<<endl; return 0; } } return 1; } int vtkConstrainedBlend::Subdivide(vtkPolyData *pd) { vtkSmartPointer<vtkLocalLoopSubdivisionFilter> subdivider = vtkSmartPointer<vtkLocalLoopSubdivisionFilter>::New(); subdivider->SetInputData(pd); subdivider->SetNumberOfSubdivisions(this->NumSubdivisionIterations); if (this->UseCellArray) { subdivider->SetSubdivideCellArrayName(this->CellArrayName); subdivider->UseCellArrayOn(); } if (this->UsePointArray) { subdivider->SetSubdividePointArrayName(this->PointArrayName); subdivider->UsePointArrayOn(); } subdivider->Update(); pd->DeepCopy(subdivider->GetOutput()); if (this->UsePointArray) { if (this->GetArrays(pd,0) != 1) { std::cout<<"No Point Array Named "<<this->PointArrayName<<" on surface"<<endl; return 0; } } if (this->UseCellArray) { if (this->GetArrays(pd,1) != 1) { std::cout<<"No Point Array Named "<<this->CellArrayName<<" on surface"<<endl; return 0; } } return 1; } int vtkConstrainedBlend::CGSmooth(vtkPolyData *pd) { vtkSmartPointer<vtkCGSmooth> smoother = vtkSmartPointer<vtkCGSmooth>::New(); smoother->SetInputData(pd); smoother->SetNumGradientSolves(this->NumGradientSolves); smoother->SetNumSmoothOperations(this->NumCGSmoothOperations); if (this->UsePointArray) { smoother->SetPointArrayName(this->PointArrayName); smoother->UsePointArrayOn(); } if (this->UseCellArray) { smoother->SetCellArrayName(this->CellArrayName); smoother->UseCellArrayOn(); } smoother->SetWeight(this->Weight); smoother->Update(); pd->DeepCopy(smoother->GetOutput()); return 1; } int vtkConstrainedBlend::LaplacianSmooth(vtkPolyData *pd) { vtkSmartPointer<vtkLocalSmoothPolyDataFilter> smoother = vtkSmartPointer<vtkLocalSmoothPolyDataFilter>::New(); smoother->SetInputData(pd); if (this->UsePointArray) { smoother->SetSmoothPointArrayName(this->PointArrayName); smoother->UsePointArrayOn(); } if (this->UseCellArray) { smoother->SetSmoothCellArrayName(this->CellArrayName); smoother->UseCellArrayOn(); } smoother->SetNumberOfIterations(this->NumLapSmoothOperations); smoother->SetRelaxationFactor(this->RelaxationFactor); smoother->BoundarySmoothingOff(); smoother->Update(); pd->DeepCopy(smoother->GetOutput()); return 1; }
[ "nwilson@osmsc.com" ]
nwilson@osmsc.com
99e983921c4c3980421cd3c97add01da500f65e3
996b7fe2a9725c4b0c97b583708437b8ec26ec2d
/src/util/report.h
0d5e69b8f3ba6268333f6a690dd2ed25bdd2b4f8
[ "BSD-3-Clause", "BSL-1.0", "BSD-2-Clause" ]
permissive
m00zh33/hyperscan
31bd229a2dcc61ae4657ec6e24110149cd33ec29
7dfaca66355e53de5c4f38602420b13a6af45206
refs/heads/master
2021-04-12T03:05:16.256948
2018-02-05T01:31:58
2018-02-05T01:31:58
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,626
h
/* * Copyright (c) 2015-2017, Intel Corporation * * 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 Intel Corporation nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 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. */ /** \file * \brief Report structure used to manage data associated with a report at * compile time. */ #ifndef UTIL_REPORT_H #define UTIL_REPORT_H #include "ue2common.h" #include "util/exhaust.h" // for INVALID_EKEY #include "util/hash.h" #include "util/order_check.h" #include <cassert> namespace ue2 { class ReportManager; enum ReportType { EXTERNAL_CALLBACK, EXTERNAL_CALLBACK_SOM_REL, INTERNAL_SOM_LOC_SET, INTERNAL_SOM_LOC_SET_IF_UNSET, INTERNAL_SOM_LOC_SET_IF_WRITABLE, INTERNAL_SOM_LOC_SET_SOM_REV_NFA, INTERNAL_SOM_LOC_SET_SOM_REV_NFA_IF_UNSET, INTERNAL_SOM_LOC_SET_SOM_REV_NFA_IF_WRITABLE, INTERNAL_SOM_LOC_COPY, INTERNAL_SOM_LOC_COPY_IF_WRITABLE, INTERNAL_SOM_LOC_MAKE_WRITABLE, EXTERNAL_CALLBACK_SOM_STORED, EXTERNAL_CALLBACK_SOM_ABS, EXTERNAL_CALLBACK_SOM_REV_NFA, INTERNAL_SOM_LOC_SET_FROM, INTERNAL_SOM_LOC_SET_FROM_IF_WRITABLE, INTERNAL_ROSE_CHAIN, EXTERNAL_CALLBACK_SOM_PASS }; /** * \brief All the data we use for handling a match. * * Includes extparam constraints and bounds, exhaustion/dedupe keys, offset * adjustment and SOM information. * * The data in this structure eventually becomes a list of Rose programs * instructions. */ struct Report { Report(ReportType type_in, u32 onmatch_in) : type(type_in), onmatch(onmatch_in) {} /** \brief True if this report has bounds from extended parameters, i.e. * min offset, max offset, min length. */ bool hasBounds() const { return minOffset > 0 || maxOffset < MAX_OFFSET || minLength > 0; } /** \brief Type of this report. */ ReportType type; /** \brief use SOM for minLength, but don't report it to user callback. */ bool quashSom = false; /** \brief min offset in the stream at which this report can match. */ u64a minOffset = 0; /** \brief max offset in the stream at which this report can match. */ u64a maxOffset = MAX_OFFSET; /** \brief min match length (start of match to current offset) */ u64a minLength = 0; /** \brief Exhaustion key. * * If exhaustible, the ekey to check before reporting a match. * Additionally after reporting a match the ekey will be set. If not * exhaustible, this will be INVALID_EKEY. */ u32 ekey = INVALID_EKEY; /** \brief Adjustment to add to the match offset when we report a match. * * This is usually used for reports attached to states that form part of a * zero-width assertion, like '$'. */ s32 offsetAdjust = 0; /** \brief Match report ID, for external reports. * * - external callback -> external report id * - internal_som_* -> som loc to modify * - INTERNAL_ROSE_CHAIN -> top event to push on * - otherwise -> target subnfa */ u32 onmatch; /** \brief Index of the reverse nfa. * * Used by EXTERNAL_CALLBACK_SOM_REV_NFA and * INTERNAL_SOM_LOC_SET_SOM_REV_NFA*. */ u32 revNfaIndex = 0; /** \brief SOM distance value, use varies according to type. * * - for EXTERNAL_CALLBACK_SOM_REL, from-offset is this many bytes * before the to-offset. * - for EXTERNAL_CALLBACK_SOM_ABS, set from-offset to this value. * - for INTERNAL_SOM_LOC_COPY*, som location read_from. */ u64a somDistance = 0; /** \brief Number of bytes behind us that we are allowed to squash * identical top events on the queue. * * Used by INTERNAL_ROSE_CHAIN. */ u64a topSquashDistance = 0; }; static inline bool isExternalReport(const Report &r) { switch (r.type) { case INTERNAL_SOM_LOC_SET: case INTERNAL_SOM_LOC_SET_IF_UNSET: case INTERNAL_SOM_LOC_SET_IF_WRITABLE: case INTERNAL_SOM_LOC_SET_SOM_REV_NFA: case INTERNAL_SOM_LOC_SET_SOM_REV_NFA_IF_UNSET: case INTERNAL_SOM_LOC_SET_SOM_REV_NFA_IF_WRITABLE: case INTERNAL_SOM_LOC_COPY: case INTERNAL_SOM_LOC_COPY_IF_WRITABLE: case INTERNAL_SOM_LOC_MAKE_WRITABLE: case INTERNAL_SOM_LOC_SET_FROM: case INTERNAL_SOM_LOC_SET_FROM_IF_WRITABLE: case INTERNAL_ROSE_CHAIN: return false; case EXTERNAL_CALLBACK: case EXTERNAL_CALLBACK_SOM_REL: case EXTERNAL_CALLBACK_SOM_STORED: case EXTERNAL_CALLBACK_SOM_ABS: case EXTERNAL_CALLBACK_SOM_REV_NFA: case EXTERNAL_CALLBACK_SOM_PASS: return true; default: break; // fall through } assert(0); // unknown? return true; } static inline bool isExternalSomReport(const Report &r) { return r.type != EXTERNAL_CALLBACK && isExternalReport(r); } static inline bool operator<(const Report &a, const Report &b) { ORDER_CHECK(type); ORDER_CHECK(quashSom); ORDER_CHECK(ekey); ORDER_CHECK(offsetAdjust); ORDER_CHECK(onmatch); ORDER_CHECK(minOffset); ORDER_CHECK(maxOffset); ORDER_CHECK(minLength); ORDER_CHECK(somDistance); ORDER_CHECK(revNfaIndex); ORDER_CHECK(topSquashDistance); return false; } inline bool operator==(const Report &a, const Report &b) { return a.type == b.type && a.quashSom == b.quashSom && a.minOffset == b.minOffset && a.maxOffset == b.maxOffset && a.minLength == b.minLength && a.ekey == b.ekey && a.offsetAdjust == b.offsetAdjust && a.onmatch == b.onmatch && a.revNfaIndex == b.revNfaIndex && a.somDistance == b.somDistance && a.topSquashDistance == b.topSquashDistance; } static inline Report makeECallback(u32 report, s32 offsetAdjust, u32 ekey) { Report ir(EXTERNAL_CALLBACK, report); ir.offsetAdjust = offsetAdjust; ir.ekey = ekey; return ir; } static inline Report makeCallback(u32 report, s32 offsetAdjust) { return makeECallback(report, offsetAdjust, INVALID_EKEY); } static inline Report makeSomRelativeCallback(u32 report, s32 offsetAdjust, u64a distance) { Report ir(EXTERNAL_CALLBACK_SOM_REL, report); ir.offsetAdjust = offsetAdjust; ir.ekey = INVALID_EKEY; ir.somDistance = distance; return ir; } static inline Report makeMpvTrigger(u32 event, u64a squashDistance) { Report ir(INTERNAL_ROSE_CHAIN, event); ir.ekey = INVALID_EKEY; ir.topSquashDistance = squashDistance; return ir; } /** simple exhaustible: exhaustible and if the first attempted match does not * succeed, no later matches will succeed either */ static inline bool isSimpleExhaustible(const Report &ir) { if (ir.ekey == INVALID_EKEY) { return false; } if (ir.hasBounds() && (ir.minOffset || ir.minLength)) { return false; } if (!isExternalReport(ir)) { return false; } return true; } } // namespace ue2 namespace std { template<> struct hash<ue2::Report> { std::size_t operator()(const ue2::Report &r) const { return ue2::hash_all(r.type, r.quashSom, r.minOffset, r.maxOffset, r.minLength, r.ekey, r.offsetAdjust, r.onmatch, r.revNfaIndex, r.somDistance, r.topSquashDistance); } }; } // namespace std #endif // UTIL_REPORT_H
[ "matthew.barr@intel.com" ]
matthew.barr@intel.com
2bd1385e1519882e7874fd6a4b157fcabd9fe94c
6a1c85f2342971896e538eb3089b76ef39afcdbb
/external/amdt_os_wrappers/src/win32/osStopWatch.cpp
39ee30e094e8b9f437caffe25c4b5c440db3e237
[ "MIT" ]
permissive
clayne/RGA
e5add6183c44df652c58383bfb5d78252660c926
6271d5636a790fa87d2c07f1c580cda9a84d3079
refs/heads/master
2023-06-25T10:54:27.363181
2023-06-13T22:48:25
2023-06-13T22:48:25
192,228,832
0
0
MIT
2019-06-16T19:27:49
2019-06-16T19:27:49
null
UTF-8
C++
false
false
8,526
cpp
//===================================================================== // Copyright 2016 (c), Advanced Micro Devices, Inc. All rights reserved. // /// \author AMD Developer Tools Team /// \file osStopWatch.cpp /// //===================================================================== //------------------------------ osStopWatch.cpp ------------------------------ // Standard C: #include "Limits.h" #include "math.h" // Infra: #include <amdt_base_tools/Include/gtAssert.h> // Local: #include <amdt_os_wrappers/Include/osStopWatch.h> // --------------------------------------------------------------------------- // Name: osStopWatch::osStopWatch // Description: Constructor // Author: AMD Developer Tools Team // Date: 28/2/2005 // --------------------------------------------------------------------------- osStopWatch::osStopWatch() : _timeInterval(0.0), _pastRunsTimeInterval(0.0), _isRunning(false) { // Initialize _startMeasureTime: _startMeasureTime = 0; // Query the system performance counter frequency: LARGE_INTEGER perfCounterFrequency; BOOL rc = ::QueryPerformanceFrequency(&perfCounterFrequency); GT_ASSERT(rc != FALSE); // Translate it to an (1 / amount of time units per second) resolution: // (The low part of the large integer is an unsigned long, therefore, the high // part, that represents the bits that are more significant than it should be // multiplied by ULONG_MAX): _stopWatchResolution = (double)perfCounterFrequency.HighPart * (double)ULONG_MAX; _stopWatchResolution += (double)perfCounterFrequency.LowPart; _stopWatchResolution = 1.0 / _stopWatchResolution; } // --------------------------------------------------------------------------- // Name: osStopWatch::~osStopWatch // Description: Destructor // Author: AMD Developer Tools Team // Date: 28/2/2005 // --------------------------------------------------------------------------- osStopWatch::~osStopWatch() { } // --------------------------------------------------------------------------- // Name: osStopWatch::start // Description: Starts / restarts the stop-watch run. // Author: AMD Developer Tools Team // Date: 28/2/2005 // --------------------------------------------------------------------------- bool osStopWatch::start() { bool retVal = false; // Store the start measure time: LARGE_INTEGER startMeasureTimeAsLI; BOOL rc = ::QueryPerformanceCounter(&startMeasureTimeAsLI); GT_IF_WITH_ASSERT(rc != FALSE) { _startMeasureTime = startMeasureTimeAsLI.QuadPart; _isRunning = true; retVal = true; } // "Start" resets the Pause / Resume mechanism: _pastRunsTimeInterval = 0.0; return retVal; } // --------------------------------------------------------------------------- // Name: osStopWatch::stop // Description: Stops the stop-watch run. // Author: AMD Developer Tools Team // Date: 28/2/2005 // --------------------------------------------------------------------------- bool osStopWatch::stop() { // Calculate the time interval passed since this stop-watch was activated: bool retVal = calculateTimeInterval(_timeInterval); // Mark that the stop-watch stopped: _isRunning = false; // "Stop" resets the Pause / Resume mechanism: _pastRunsTimeInterval = 0.0; return retVal; } // --------------------------------------------------------------------------- // Name: osStopWatch::pause // Description: "Pauses" the stop watch - storing its time for later use // Return Val: bool - Success / failure. // Author: AMD Developer Tools Team // Date: 7/12/2009 // --------------------------------------------------------------------------- bool osStopWatch::pause() { // Calculate the time interval passed since this stop-watch was activated: bool retVal = calculateTimeInterval(_pastRunsTimeInterval); _timeInterval = _pastRunsTimeInterval; // Mark that the stop-watch stopped: _isRunning = false; return retVal; } // --------------------------------------------------------------------------- // Name: osStopWatch::resume // Description: Resumes the stop watch after it was paused // Return Val: bool - Success / failure. // Author: AMD Developer Tools Team // Date: 7/12/2009 // --------------------------------------------------------------------------- bool osStopWatch::resume() { bool retVal = false; // Store the start measure time: LARGE_INTEGER startMeasureTimeAsLI; BOOL rc = ::QueryPerformanceCounter(&startMeasureTimeAsLI); GT_IF_WITH_ASSERT(rc != FALSE) { _startMeasureTime = startMeasureTimeAsLI.QuadPart; _isRunning = true; retVal = true; } return retVal; } // --------------------------------------------------------------------------- // Name: osStopWatch::isRunning // Description: Returns true iff the stop-watch is running. // Author: AMD Developer Tools Team // Date: 28/2/2005 // --------------------------------------------------------------------------- bool osStopWatch::isRunning() const { return _isRunning; } // --------------------------------------------------------------------------- // Name: osStopWatch::getTimeInterval // Description: Returns the time interval that this stop watch measured. // Arguments: timeInterval - Will get the time interval, measured in milliseconds. // Return Val: bool - Success / failure. // Author: AMD Developer Tools Team // Date: 28/2/2005 // --------------------------------------------------------------------------- bool osStopWatch::getTimeInterval(double& timeInterval) const { bool retVal = false; timeInterval = 0.0; // If the stop watch is still running: if (_isRunning) { // Calculate the time interval passed since this stop-watch was activated: retVal = calculateTimeInterval(timeInterval); } else { // No need to calculate the time interval, since the call to stop() already // calculated it. timeInterval = _timeInterval; retVal = true; } // Output the measured time interval: GT_RETURN_WITH_ASSERT(retVal); } // --------------------------------------------------------------------------- // Name: osStopWatch::calculateTimeInterval // Description: Calculates and returns the time passed since this stop-watch // was started (in seconds). // Author: AMD Developer Tools Team // Date: 28/2/2005 // --------------------------------------------------------------------------- bool osStopWatch::calculateTimeInterval(double& timeInterval) const { bool retVal = false; timeInterval = 0.0; // Get the current time: LARGE_INTEGER currentTimeAsLI; BOOL rc = ::QueryPerformanceCounter(&currentTimeAsLI); GT_IF_WITH_ASSERT(rc != FALSE) { // Calculate the time interval between the start measure time and the current time: gtUInt64 currentTime = currentTimeAsLI.QuadPart; timeInterval = (double)(currentTime - _startMeasureTime); timeInterval *= _stopWatchResolution; // Add the time from previous splits: timeInterval += _pastRunsTimeInterval; retVal = true; } GT_RETURN_WITH_ASSERT(retVal); } // --------------------------------------------------------------------------- // Name: osStopWatch::appendCurrentTimeAsString // Description: Get the current time milliseconds count, as string. // Arguments: gtString& timeStr // Return Val: void // Author: AMD Developer Tools Team // Date: 18/8/2010 // --------------------------------------------------------------------------- void osStopWatch::appendCurrentTimeAsString(gtString& timeStr) { // Get the time: LARGE_INTEGER startMeasureTimeAsLI; BOOL rc = ::QueryPerformanceCounter(&startMeasureTimeAsLI); GT_IF_WITH_ASSERT(rc != FALSE) { // Print only the last 4 digits: timeStr.appendFormattedString(L"%llu", (gtUInt64)startMeasureTimeAsLI.QuadPart); } } bool osGetCurrentTime(gtUInt64& currentTimeAsMilliseconds) { bool retVal = false; LARGE_INTEGER startMeasureTimeAsLI; BOOL rc = ::QueryPerformanceCounter(&startMeasureTimeAsLI); GT_IF_WITH_ASSERT(rc != FALSE) { retVal = true; currentTimeAsMilliseconds = (gtUInt64)startMeasureTimeAsLI.QuadPart; } return retVal; }
[ "amit.ben-moshe@amd.com" ]
amit.ben-moshe@amd.com
05eb312d42b9eb5acabe8c4a7f6abd28727f3ffa
5a2a95f96e7467b3178da704089b11bb37099892
/include/caffe/layers/mae_layer.hpp
69b8fed58148f57b516d63748c73f540d5b6fe55
[ "LicenseRef-scancode-public-domain", "BSD-2-Clause", "BSD-3-Clause", "LicenseRef-scancode-generic-cla" ]
permissive
soccergame/caffe-windows
b775effae9019d98af278deb5bd456c033cc02e7
6119495e8f174077fd6485c4d44ba63d7575f8c5
refs/heads/ms
2020-04-04T09:22:58.155842
2019-03-06T03:29:44
2019-03-06T03:29:44
155,815,787
0
0
NOASSERTION
2018-11-02T04:54:39
2018-11-02T04:54:39
null
UTF-8
C++
false
false
3,463
hpp
#ifndef CAFFE_ACCURACY_LAYER_HPP_ #define CAFFE_ACCURACY_LAYER_HPP_ #include <vector> #include "caffe/blob.hpp" #include "caffe/layer.hpp" #include "caffe/proto/caffe.pb.h" #include "caffe/layers/loss_layer.hpp" namespace caffe { /** * @brief Computes the classification accuracy for a one-of-many * classification task. */ template <typename Dtype> class MAELayer : public Layer<Dtype> { public: /** * @param param provides AccuracyParameter accuracy_param, * with AccuracyLayer options: * - top_k (\b optional, default 1). * Sets the maximum rank @f$ k @f$ at which a prediction is considered * correct. For example, if @f$ k = 5 @f$, a prediction is counted * correct if the correct label is among the top 5 predicted labels. */ explicit MAELayer(const LayerParameter& param) : Layer<Dtype>(param) {} virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top); virtual void Reshape(const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top); virtual inline const char* type() const { return "MAE"; } virtual inline int ExactNumBottomBlobs() const { return 2; } // If there are two top blobs, then the second blob will contain // accuracies per class. virtual inline int MinTopBlobs() const { return 1; } virtual inline int MaxTopBlos() const { return 2; } protected: /** * @param bottom input Blob vector (length 2) * -# @f$ (N \times C \times H \times W) @f$ * the predictions @f$ x @f$, a Blob with values in * @f$ [-\infty, +\infty] @f$ indicating the predicted score for each of * the @f$ K = CHW @f$ classes. Each @f$ x_n @f$ is mapped to a predicted * label @f$ \hat{l}_n @f$ given by its maximal index: * @f$ \hat{l}_n = \arg\max\limits_k x_{nk} @f$ * -# @f$ (N \times 1 \times 1 \times 1) @f$ * the labels @f$ l @f$, an integer-valued Blob with values * @f$ l_n \in [0, 1, 2, ..., K - 1] @f$ * indicating the correct class label among the @f$ K @f$ classes * @param top output Blob vector (length 1) * -# @f$ (1 \times 1 \times 1 \times 1) @f$ * the computed accuracy: @f$ * \frac{1}{N} \sum\limits_{n=1}^N \delta\{ \hat{l}_n = l_n \} * @f$, where @f$ * \delta\{\mathrm{condition}\} = \left\{ * \begin{array}{lr} * 1 & \mbox{if condition} \\ * 0 & \mbox{otherwise} * \end{array} \right. * @f$ */ virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top); /// @brief Not implemented -- AccuracyLayer cannot be used as a loss. virtual void Backward_cpu(const vector<Blob<Dtype>*>& top, const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom) { for (int i = 0; i < propagate_down.size(); ++i) { if (propagate_down[i]) { NOT_IMPLEMENTED; } } } int label_axis_, outer_num_, inner_num_; bool has_ignore_label_; int ignore_label_; }; } // namespace caffe #endif // CAFFE_ACCURACY_LAYER_HPP_
[ "247281309@qq.com" ]
247281309@qq.com
eac78613f6daaf65db7f95a06ebbe4bcfe9db2e9
995b70e7336d44659058e19751dc259a37916e04
/04-imu-calib/imu_tk/src/calibration.cpp
92c6870209eb5c5cb4cdc610bff8724cd5a1bcfd
[ "BSD-3-Clause" ]
permissive
koson/Multi-Sensor-Fusion
5299ba41c41dbd97775d058d0883107ec70b4af1
80b830937441a259c7e38366f2ff290f023bf7ab
refs/heads/master
2023-07-25T11:13:13.647767
2021-08-31T07:23:09
2021-08-31T07:23:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
22,156
cpp
/* * imu_tk - Inertial Measurement Unit Toolkit * * Copyright (c) 2014, Alberto Pretto <pretto@diag.uniroma1.it> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #include "imu_tk/calibration.h" #include "imu_tk/filters.h" #include "imu_tk/integration.h" #include "imu_tk/visualization.h" #include <limits> #include <iostream> #include "ceres/ceres.h" using namespace imu_tk; using namespace Eigen; using namespace std; template <typename _T1> class CaliAccCostFunction : public ceres::SizedCostFunction<1, 9> { public: //CaliAccCostFunction(const double &g_mag_, const Eigen::Matrix< double, 3 , 1> &sample_); CaliAccCostFunction(const _T1 &g_mag_, const Eigen::Matrix< _T1, 3 , 1> &sample_) : g_mag(g_mag_), sample(sample_) {} virtual ~CaliAccCostFunction() {} virtual bool Evaluate(double const *const *parameters, double *residuals, double **jacobians) const{ Eigen::Matrix<double, 3, 1> raw_samp( double(sample(0)), double(sample(1)), double(sample(2)) ); CalibratedTriad_<double> calib_triad( // // TODO: implement lower triad model here // // mis_yz, mis_zy, mis_zx: //params[0], params[1], params[2], double(0), double(0), double(0), // mis_xz, mis_xy, mis_yx: //_T2(0), _T2(0), _T2(0), parameters[0][0], parameters[0][1], parameters[0][2], // s_x, s_y, s_z: parameters[0][3], parameters[0][4], parameters[0][5], // b_x, b_y, b_z: parameters[0][6], parameters[0][7], parameters[0][8] ); // apply undistortion transform: Eigen::Matrix< double, 3 , 1> calib_samp = calib_triad.unbiasNormalize( raw_samp ); //residuals[0] = _T2 (g_mag_) - calib_samp.norm(); residuals[0] = double (g_mag) * double (g_mag) - calib_samp.norm() * calib_samp.norm(); if(jacobians != NULL){ if(jacobians[0] != NULL) { double mis_xz = parameters[0][0]; double mis_xy = parameters[0][1]; double mis_yx = parameters[0][2]; double s_x = parameters[0][3]; double s_y = parameters[0][4]; double s_z = parameters[0][5]; double b_x = parameters[0][6]; double b_y = parameters[0][7]; double b_z = parameters[0][8]; double A_x = sample(0); double A_y = sample(1); double A_z = sample(2); Eigen::Matrix<double, 3, 3> mis_mat; mis_mat<< 1, 0, 0, mis_xz, 1, 0, -mis_xy, mis_yx, 1; Eigen::Matrix<double, 3, 3> scale_mat; scale_mat<< s_x, 0, 0, 0, s_y, 0, 0, 0, s_z; Eigen::Vector3d bias_vec = {A_x - b_x, A_y - b_y, A_z - b_z}; Eigen::Vector3d a_vec = mis_mat * scale_mat * bias_vec; Eigen::Matrix<double, 3, 9> delta; delta << 0, 0, 0, A_x - b_x, 0, 0, -s_x, 0, 0, s_x * (A_x - b_x), 0, 0, mis_xz * (A_x - b_x), A_y - b_y, 0, -mis_xz * s_x, -s_y, 0, 0, -s_x * (A_x - b_x), s_y * (A_y - b_y), -mis_xy * (A_x - b_x), mis_yx * (A_y - b_y), (A_z - b_z), mis_xy * s_x, -mis_yx * s_y, -s_z; Eigen::Map<Eigen::Matrix<double, 1, 9, Eigen::RowMajor> > J_se3(jacobians[0]); J_se3.setZero(); //J_se3 = -2 * a_vec.transpose() * delta; J_se3 = -2 * calib_samp.transpose() * delta; } } return true; } const _T1 g_mag; const Eigen::Matrix< _T1, 3 , 1> sample; }; template <typename _T1> struct MultiPosAccResidual { MultiPosAccResidual( const _T1 &g_mag, const Eigen::Matrix< _T1, 3 , 1> &sample ) : g_mag_(g_mag), sample_(sample){} template <typename _T2> bool operator() ( const _T2* const params, _T2* residuals ) const { Eigen::Matrix<_T2, 3, 1> raw_samp( _T2(sample_(0)), _T2(sample_(1)), _T2(sample_(2)) ); /* Apply undistortion transform to accel measurements mis_mat_ << _T(1) , -mis_yz , mis_zy , mis_xz , _T(1) , -mis_zx , -mis_xy , mis_yx , _T(1) ; scale_mat_ << s_x , _T(0) , _T(0) , _T(0) , s_y , _T(0) , _T(0) , _T(0) , s_z ; bias_vec_ << b_x , b_y , b_z ; define: ms_mat_ = mis_mat_*scale_mat_ then the undistortion transform: X' = T*K*(X - B) can be implemented as: unbias_data = ms_mat_*(raw_data - bias_vec_) * assume body frame same as accelerometer frame, * so bottom left params in the misalignment matris are set to zero */ CalibratedTriad_<_T2> calib_triad( // // TODO: implement lower triad model here // // mis_yz, mis_zy, mis_zx: //params[0], params[1], params[2], _T2(0), _T2(0), _T2(0), // mis_xz, mis_xy, mis_yx: //_T2(0), _T2(0), _T2(0), params[0], params[1], params[2], // s_x, s_y, s_z: params[3], params[4], params[5], // b_x, b_y, b_z: params[6], params[7], params[8] ); // apply undistortion transform: Eigen::Matrix< _T2, 3 , 1> calib_samp = calib_triad.unbiasNormalize( raw_samp ); //residuals[0] = _T2 (g_mag_) - calib_samp.norm(); residuals[0] = _T2 (g_mag_) * _T2 (g_mag_) - calib_samp.norm() * calib_samp.norm(); return true; } static ceres::CostFunction* Create ( const _T1 &g_mag, const Eigen::Matrix< _T1, 3 , 1> &sample ) { return ( new ceres::AutoDiffCostFunction< MultiPosAccResidual, 1, 9 > ( new MultiPosAccResidual<_T1>( g_mag, sample ) ) ); } const _T1 g_mag_; const Eigen::Matrix< _T1, 3 , 1> sample_; }; template <typename _T1> struct MultiPosGyroResidual { MultiPosGyroResidual( const Eigen::Matrix< _T1, 3 , 1> &g_versor_pos0, const Eigen::Matrix< _T1, 3 , 1> &g_versor_pos1, const std::vector< TriadData_<_T1> > &gyro_samples, const DataInterval &gyro_interval_pos01, _T1 dt, bool optimize_bias) : g_versor_pos0_(g_versor_pos0), g_versor_pos1_(g_versor_pos1), gyro_samples_(gyro_samples), interval_pos01_(gyro_interval_pos01), dt_(dt), optimize_bias_(optimize_bias){} template <typename _T2> bool operator() ( const _T2* const params, _T2* residuals ) const { CalibratedTriad_<_T2> calib_triad( params[0], params[1], params[2], params[3], params[4], params[5], params[6], params[7], params[8], optimize_bias_?params[9]:_T2(0), optimize_bias_?params[10]:_T2(0), optimize_bias_?params[11]:_T2(0) ); std::vector< TriadData_<_T2> > calib_gyro_samples; calib_gyro_samples.reserve( interval_pos01_.end_idx - interval_pos01_.start_idx + 1 ); for( int i = interval_pos01_.start_idx; i <= interval_pos01_.end_idx; i++ ) calib_gyro_samples.push_back( TriadData_<_T2>( calib_triad.unbiasNormalize( gyro_samples_[i] ) ) ); Eigen::Matrix< _T2, 3 , 3> rot_mat; integrateGyroInterval( calib_gyro_samples, rot_mat, _T2(dt_) ); Eigen::Matrix< _T2, 3 , 1> diff = rot_mat.transpose()*g_versor_pos0_.template cast<_T2>() - g_versor_pos1_.template cast<_T2>(); residuals[0] = diff(0); residuals[1] = diff(1); residuals[2] = diff(2); return true; } static ceres::CostFunction* Create ( const Eigen::Matrix< _T1, 3 , 1> &g_versor_pos0, const Eigen::Matrix< _T1, 3 , 1> &g_versor_pos1, const std::vector< TriadData_<_T1> > &gyro_samples, const DataInterval &gyro_interval_pos01, _T1 dt, bool optimize_bias ) { if( optimize_bias ) return ( new ceres::AutoDiffCostFunction< MultiPosGyroResidual, 3, 12 > ( new MultiPosGyroResidual( g_versor_pos0, g_versor_pos1, gyro_samples, gyro_interval_pos01, dt, optimize_bias ) ) ); else return ( new ceres::AutoDiffCostFunction< MultiPosGyroResidual, 3, 9 > ( new MultiPosGyroResidual( g_versor_pos0, g_versor_pos1, gyro_samples, gyro_interval_pos01, dt, optimize_bias ) ) ); } const Eigen::Matrix< _T1, 3 , 1> g_versor_pos0_, g_versor_pos1_; const std::vector< TriadData_<_T1> > gyro_samples_; const DataInterval interval_pos01_; const _T1 dt_; const bool optimize_bias_; }; template <typename _T> MultiPosCalibration_<_T>::MultiPosCalibration_() : g_mag_(9.81), min_num_intervals_(12), init_interval_duration_(_T(30.0)), interval_n_samples_(100), acc_use_means_(false), gyro_dt_(-1.0), optimize_gyro_bias_(false), verbose_output_(false){} //double parameters[9] = {1, 1, 1, 1, 1, 1, 1, 1, 1}; template <typename _T> bool MultiPosCalibration_<_T>::calibrateAcc( const std::vector< TriadData_<_T> >& acc_samples ) { cout<<"Accelerometer Calibration: Calibrating..."<<endl; min_cost_static_intervals_.clear(); calib_acc_samples_.clear(); calib_gyro_samples_.clear(); int n_samps = acc_samples.size(); DataInterval init_static_interval = DataInterval::initialInterval( acc_samples, init_interval_duration_ ); Eigen::Matrix<_T, 3, 1> acc_variance = dataVariance( acc_samples, init_static_interval ); _T norm_th = acc_variance.norm(); _T min_cost = std::numeric_limits< _T >::max(); int min_cost_th = -1; std::vector< double > min_cost_calib_params; for (int th_mult = 2; th_mult <= 10; th_mult++) { std::vector< imu_tk::DataInterval > static_intervals; std::vector< imu_tk::TriadData_<_T> > static_samples; std::vector< double > acc_calib_params(9); // // TODO: implement lower triad model here // //acc_calib_params[0] = init_acc_calib_.misYZ(); //acc_calib_params[1] = init_acc_calib_.misZY(); //acc_calib_params[2] = init_acc_calib_.misZX(); acc_calib_params[0] = init_acc_calib_.misXZ(); acc_calib_params[1] = init_acc_calib_.misXY(); acc_calib_params[2] = init_acc_calib_.misYX(); acc_calib_params[3] = init_acc_calib_.scaleX(); acc_calib_params[4] = init_acc_calib_.scaleY(); acc_calib_params[5] = init_acc_calib_.scaleZ(); acc_calib_params[6] = init_acc_calib_.biasX(); acc_calib_params[7] = init_acc_calib_.biasY(); acc_calib_params[8] = init_acc_calib_.biasZ(); std::vector< DataInterval > extracted_intervals; staticIntervalsDetector ( acc_samples, th_mult*norm_th, static_intervals ); extractIntervalsSamples ( acc_samples, static_intervals, static_samples, extracted_intervals, interval_n_samples_, acc_use_means_ ); if(verbose_output_) { cout << "Accelerometers Calibration: Extracted "<< extracted_intervals.size() << " intervals using threshold multiplier "<< th_mult<<" -> "; } // TODO Perform here a quality test if( extracted_intervals.size() < min_num_intervals_) { if( verbose_output_) cout<<"Not enough intervals, calibration is not possible"<<endl; continue; } if( verbose_output_) cout<<"Trying calibrate... "<<endl; double parameters[9] = {0, 0, 0, 1, 1, 1, 0, 0, 0}; //ceres::LossFunction *loss_function = new ceres::HuberLoss(0.1); ceres::LossFunction *loss_function = NULL; ceres::Problem::Options problem_options; ceres::Problem problem(problem_options); problem.AddParameterBlock(parameters, 9); for( int i = 0; i < static_samples.size(); i++) { ceres::CostFunction *cost_function = new CaliAccCostFunction<_T>( g_mag_, static_samples[i].data() ); problem.AddResidualBlock(cost_function, NULL, acc_calib_params.data()); } /* ceres::Problem problem; for( int i = 0; i < static_samples.size(); i++) { ceres::CostFunction* cost_function = MultiPosAccResidual<_T>::Create ( g_mag_, static_samples[i].data() ); for(int j=0; j<9; j++) { cout<<acc_calib_params[j]<< " "; } cout<<endl; problem.AddResidualBlock ( cost_function, // error fuction NULL, // squared loss acc_calib_params.data() // accel deterministic error params ); } */ ceres::Solver::Options options; options.linear_solver_type = ceres::DENSE_QR; options.minimizer_progress_to_stdout = verbose_output_; ceres::Solver::Summary summary; ceres::Solve ( options, &problem, &summary ); if( summary.final_cost < min_cost) { min_cost = summary.final_cost; min_cost_th = th_mult; min_cost_static_intervals_ = static_intervals; min_cost_calib_params = acc_calib_params; } cout << "residual " << summary.final_cost << endl; } if( min_cost_th < 0 ) { if(verbose_output_) cout << "Accelerometers calibration: Can't obtain any calibratin with the current dataset" << endl; return false; } acc_calib_ = CalibratedTriad_<_T>( // // TODO: implement lower triad model here // /* min_cost_calib_params[0], min_cost_calib_params[1], min_cost_calib_params[2], 0,0,0, min_cost_calib_params[3], min_cost_calib_params[4], min_cost_calib_params[5], min_cost_calib_params[6], min_cost_calib_params[7], min_cost_calib_params[8] */ 0,0,0, min_cost_calib_params[0], min_cost_calib_params[1], min_cost_calib_params[2], min_cost_calib_params[3], min_cost_calib_params[4], min_cost_calib_params[5], min_cost_calib_params[6], min_cost_calib_params[7], min_cost_calib_params[8] ); calib_acc_samples_.reserve(n_samps); // Calibrate the input accelerometer data with the obtained calibration for( int i = 0; i < n_samps; i++) calib_acc_samples_.push_back( acc_calib_.unbiasNormalize( acc_samples[i]) ); if(verbose_output_) { Plot plot; plot.plotIntervals( calib_acc_samples_, min_cost_static_intervals_); cout << "Accelerometers calibration: Better calibration obtained using threshold multiplier " << min_cost_th << " with residual " << min_cost << endl << acc_calib_ << endl << "Accelerometers calibration: inverse scale factors:" << endl << 1.0/acc_calib_.scaleX() << endl << 1.0/acc_calib_.scaleY() << endl << 1.0/acc_calib_.scaleZ() << endl; waitForKey(); } return true; } template <typename _T> bool MultiPosCalibration_<_T>::calibrateAccGyro ( const vector< TriadData_<_T> >& acc_samples, const vector< TriadData_<_T> >& gyro_samples ) { if( !calibrateAcc( acc_samples ) ) return false; cout<<"Gyroscopes calibration: calibrating..."<<endl; std::vector< TriadData_<_T> > static_acc_means; std::vector< DataInterval > extracted_intervals; extractIntervalsSamples ( calib_acc_samples_, min_cost_static_intervals_, static_acc_means, extracted_intervals, interval_n_samples_, true ); int n_static_pos = static_acc_means.size(), n_samps = gyro_samples.size(); // Compute the gyroscopes biases in the (static) initialization interval DataInterval init_static_interval = DataInterval::initialInterval( gyro_samples, init_interval_duration_ ); Eigen::Matrix<_T, 3, 1> gyro_bias = dataMean( gyro_samples, init_static_interval ); gyro_calib_ = CalibratedTriad_<_T>(0, 0, 0, 0, 0, 0, 1.0, 1.0, 1.0, gyro_bias(0), gyro_bias(1), gyro_bias(2) ); // calib_gyro_samples_ already cleared in calibrateAcc() calib_gyro_samples_.reserve(n_samps); // Remove the bias for( int i = 0; i < n_samps; i++ ) calib_gyro_samples_.push_back(gyro_calib_.unbias(gyro_samples[i])); std::vector< double > gyro_calib_params(12); gyro_calib_params[0] = init_gyro_calib_.misYZ(); gyro_calib_params[1] = init_gyro_calib_.misZY(); gyro_calib_params[2] = init_gyro_calib_.misZX(); gyro_calib_params[3] = init_gyro_calib_.misXZ(); gyro_calib_params[4] = init_gyro_calib_.misXY(); gyro_calib_params[5] = init_gyro_calib_.misYX(); gyro_calib_params[6] = init_gyro_calib_.scaleX(); gyro_calib_params[7] = init_gyro_calib_.scaleY(); gyro_calib_params[8] = init_gyro_calib_.scaleZ(); // Bias has been estimated and removed in the initialization period gyro_calib_params[9] = 0.0; gyro_calib_params[10] = 0.0; gyro_calib_params[11] = 0.0; ceres::Problem problem; for( int i = 0, t_idx = 0; i < n_static_pos - 1; i++ ) { Eigen::Matrix<_T, 3, 1> g_versor_pos0 = static_acc_means[i].data(), g_versor_pos1 = static_acc_means[i + 1].data(); g_versor_pos0 /= g_versor_pos0.norm(); g_versor_pos1 /= g_versor_pos1.norm(); int gyro_idx0 = -1, gyro_idx1 = -1; _T ts0 = calib_acc_samples_[extracted_intervals[i].end_idx].timestamp(), ts1 = calib_acc_samples_[extracted_intervals[i + 1].start_idx].timestamp(); // Assume monotone signal time for( ; t_idx < n_samps; t_idx++ ) { if( gyro_idx0 < 0 ) { if( calib_gyro_samples_[t_idx].timestamp() >= ts0 ) gyro_idx0 = t_idx; } else { if( calib_gyro_samples_[t_idx].timestamp() >= ts1 ) { gyro_idx1 = t_idx - 1; break; } } } // cout<<"from "<<calib_gyro_samples_[gyro_idx0].timestamp()<<" to " // <<calib_gyro_samples_[gyro_idx1].timestamp() // <<" v0 : "<< g_versor_pos0(0)<<" "<< g_versor_pos0(1)<<" "<< g_versor_pos0(2) // <<" v1 : "<< g_versor_pos1(0)<<" "<< g_versor_pos1(1)<<" "<< g_versor_pos1(2)<<endl; DataInterval gyro_interval(gyro_idx0, gyro_idx1); ceres::CostFunction* cost_function = MultiPosGyroResidual<_T>::Create ( g_versor_pos0, g_versor_pos1, calib_gyro_samples_, gyro_interval, gyro_dt_, optimize_gyro_bias_ ); problem.AddResidualBlock ( cost_function, NULL /* squared loss */, gyro_calib_params.data() ); } ceres::Solver::Options options; options.linear_solver_type = ceres::DENSE_QR; options.minimizer_progress_to_stdout = verbose_output_; ceres::Solver::Summary summary; ceres::Solve ( options, &problem, &summary ); gyro_calib_ = CalibratedTriad_<_T>( gyro_calib_params[0], gyro_calib_params[1], gyro_calib_params[2], gyro_calib_params[3], gyro_calib_params[4], gyro_calib_params[5], gyro_calib_params[6], gyro_calib_params[7], gyro_calib_params[8], gyro_bias(0) + gyro_calib_params[9], gyro_bias(1) + gyro_calib_params[10], gyro_bias(2) + gyro_calib_params[11]); // Calibrate the input gyroscopes data with the obtained calibration for( int i = 0; i < n_samps; i++) calib_gyro_samples_.push_back( gyro_calib_.unbiasNormalize( gyro_samples[i]) ); if(verbose_output_) { cout<<summary.FullReport()<<endl; cout<<"Gyroscopes calibration: residual "<<summary.final_cost<<endl <<gyro_calib_<<endl <<"Gyroscopes calibration: inverse scale factors:"<<endl <<1.0/gyro_calib_.scaleX()<<endl <<1.0/gyro_calib_.scaleY()<<endl <<1.0/gyro_calib_.scaleZ()<<endl; } return true; } template class MultiPosCalibration_<double>; template class MultiPosCalibration_<float>;
[ "yungzhou@qq.com" ]
yungzhou@qq.com
ff42003cce5d48a238b2625c97bd331f6cc289e6
a81ef0380fbaee53abe0854c630b87146c5f0005
/ios/UnityLibrary/Classes/Native/mscorlib8.cpp
b7dcd20f040a2ddfa529ec215afb132cd1718118
[]
no_license
soundring/flutter_ar_sample
40658eb4949d09f340d8690574bd93e8daf5b4e9
51e77195d8abc5006cdd27f71fc54794cd79d63e
refs/heads/master
2023-07-31T09:36:34.106749
2021-09-12T09:57:07
2021-09-12T09:59:40
405,570,101
0
1
null
null
null
null
UTF-8
C++
false
false
132
cpp
version https://git-lfs.github.com/spec/v1 oid sha256:34f66e7fa9a0c2ba123be72ba8de254d8de3f58ce9142a83990dd898bbcf28c0 size 2070922
[ "soundringing@yahoo.co.jp" ]
soundringing@yahoo.co.jp
896c2db3186934f5dbd59869491d1d26a1916386
0a039f7fb231eacee6f08ad2159e1c37bc724ea3
/modules/system/include/moon/intern.h
6e998d9ed4ab49738319188a8e0569e89b0cf2af
[]
no_license
netsec/moon
1673c1fc0743da1d4343ffcacda8eccdc6ded96e
2c3bb54e89518072b0a8a68098c60dcc6f84e52e
refs/heads/master
2020-06-25T13:07:35.092363
2016-07-14T21:11:44
2016-07-14T21:11:44
199,316,802
0
0
null
2019-07-28T17:26:18
2019-07-28T17:23:05
C++
UTF-8
C++
false
false
400
h
#ifndef MOON_INTERN_H #define MOON_INTERN_H #include <string> #include <cstring> #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <dirent.h> #include <sys/stat.h> // _WIN32 is set for both 32 and 64 bit #ifdef _WIN32 # define stat _stat #endif static inline bool exists(const std::string& name) { struct stat buffer; return (stat(name.c_str(), &buffer) == 0); }; #endif
[ "mistdragon100@gmail.com" ]
mistdragon100@gmail.com
9b58f77e7c4167ded4d778f53d4c58d6077da9c3
d13290d4318b9ee7f2ae33145795d3cd528f072c
/src/chrono_fsi/ChSystemFsi.h
d093449063103ea73333160e3a21e56b6efb7837
[ "BSD-3-Clause" ]
permissive
fronron/chrono
9ae75f88e457c96701fba9431ab5bcf269af2eb9
8fa9d0564543996fc62dd5d61937fee7fe187710
refs/heads/develop
2021-01-25T08:19:35.928536
2017-06-06T09:01:41
2017-06-06T09:01:41
93,753,286
0
0
null
2017-06-08T13:35:38
2017-06-08T13:35:37
null
UTF-8
C++
false
false
5,044
h
// ============================================================================= // PROJECT CHRONO - http://projectchrono.org // // Copyright (c) 2014 projectchrono.org // All right reserved. // // Use of this source code is governed by a BSD-style license that can be found // in the LICENSE file at the top level of the distribution and at // http://projectchrono.org/license-chrono.txt. // // ============================================================================= // Author: Arman Pazouki // ============================================================================= // // Implementation of fsi system that includes all subclasses for proximity and // force calculation, and time integration // ============================================================================= #ifndef CH_SYSTEMFSI_H_ #define CH_SYSTEMFSI_H_ #include "chrono/ChConfig.h" #include "chrono/physics/ChSystem.h" #include "chrono_fsi/ChBce.cuh" #include "chrono_fsi/ChFluidDynamics.cuh" #include "chrono_fsi/ChFsiDataManager.cuh" #include "chrono_fsi/ChFsiInterface.h" #ifdef CHRONO_OPENGL #include "chrono_opengl/ChOpenGLWindow.h" #endif namespace chrono { namespace fsi { /// Physical system for fluid-solid interaction problem /// /// This class is used to represent a fluid-solid interaction problem consist of /// fluid dynamics and multibody system. Each of the two underlying physics are /// independent objects owned and instantiated by this class. Additionally, /// the fsi system owns other objects to handle the interface between the two /// systems, boundary condition enforcing markers, and data. class CH_FSI_API ChSystemFsi : public ChFsiGeneral { public: /// constructor for fsi system /// /// This class constructor instantiates all the member objects. Wherever /// relevant, the /// instantiation is handled by sending a pointer to other objects or data. /// Therefore, the sub-classes have pointers to the same data ChSystemFsi(ChSystem *other_physicalSystem, bool other_haveFluid); /// destructor for the fsi system ~ChSystemFsi(); /// function to integrate the fsi system in time. /// /// It uses a Runge-Kutta 2nd order algorithm to update both the fluid and /// multibody /// system dynamics. The midpoint data of MBS is needed for fluid dynamics /// update. virtual void DoStepDynamics_FSI(); /// function to integrate the multibody system dynamics based on Runge-Kutta /// 2nd /// order integration scheme virtual void DoStepDynamics_ChronoRK2(); /// function to initialize the midpoint device data of the fluid system by /// copying from the full step virtual void CopyDeviceDataToHalfStep(); /// Function to fill out the dependent data based on the independent one. For /// instance /// it copies the position of the rigid bodies from the multibody dynamics /// system /// to arrays in fsi system since they are needed for internal use. virtual void FinalizeData(); /// function to return the pointer to the data manager ChFsiDataManager *GetDataManager() { return fsiData; } /// function to return the pointer to the data SimParams *GetSimParams() { return paramsH; } /// function to return the pointer to the fsi bodies. The pointer to all fsi /// bodies, i.e. the bodies /// with two representation in fluid and multibody systems, are stored in a /// vector. std::vector<std::shared_ptr<ChBody>> *GetFsiBodiesPtr() { return &fsiBodeisPtr; } /// Initialize the graphics interface of the chrono system void InitializeChronoGraphics( chrono::ChVector<> CameraLocation = chrono::ChVector<>(1, 0, 0), chrono::ChVector<> CameraLookAt = chrono::ChVector<>(0, 0, 0)); /// Finzalize data by calling FinalizeData function and finalize fluid and bce /// objects if the /// system have fluid. virtual void Finalize(); private: /// Integrate the chrono system based on an explicit Euler scheme. int DoStepChronoSystem(Real dT, double mTime); ChFsiDataManager *fsiData; ///< pointer to data manager which holds all the data std::vector<std::shared_ptr<ChBody>> fsiBodeisPtr; ///< vector of a pointers to fsi bodies. fsi bodies /// are those that interact with fluid ChFluidDynamics *fluidDynamics; ///< pointer to the fluid system ChFsiInterface *fsiInterface; ///< pointer to the fsi interface system ChBce *bceWorker; ///< pointer to the bce workers chrono::ChSystem *mphysicalSystem; ///< pointer to the multibody system SimParams *paramsH; ///< pointer to the simulation parameters NumberOfObjects *numObjectsH; ///< pointer to the number of objects, fluid, ///bce, and boundary markers double mTime; ///< current real time of the simulation bool haveFluid; ///< boolean to check if the system have fluid or not #ifdef CHRONO_OPENGL chrono::opengl::ChOpenGLWindow *gl_window; ///< opengl graphics window if opengl exist #endif }; } // end namespace fsi } // end namespace chrono #endif
[ "apazouki@gmail.com" ]
apazouki@gmail.com
ff188c493aee5cec7467bad2f90d4dc95bfdec90
b84af0c9bf9255e85e0a89cef09590db95432fc4
/source/microbit/modradio.cpp
0fdd0ceb0f444d404b5275e3a2759a67c3f42684
[ "MIT" ]
permissive
dojofhain/micropython
d3fb577f1e2c1f638dfba02486dbb37d19a7ac0f
ba54edf933563ba17980de7a9f4d936c8e0cee65
refs/heads/master
2021-08-20T08:57:54.308596
2017-11-28T17:14:22
2017-11-28T17:14:22
111,574,121
0
0
null
2017-11-28T17:14:22
2017-11-21T16:31:51
C
UTF-8
C++
false
false
19,838
cpp
/* * This file is part of the MicroPython project, http://micropython.org/ * * The MIT License (MIT) * * Copyright (c) 2016 Damien P. George * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ extern "C" { #include <stdio.h> #include <string.h> #include "us_ticker_api.h" #include "py/runtime0.h" #include "py/runtime.h" #include "py/smallint.h" #include "microbit/modmicrobit.h" // Packets are stored in the queue as a sequence of bytes of the form: // // len - byte // data - "len" bytes // RSSI - byte // time - 4 bytes, little endian, microsecond timestamp // // "len" is first because it is written by the hardware, followed by the data. #define RADIO_PACKET_OVERHEAD (1 + 1 + 4) // 1 byte for len, 1 byte for RSSI, 4 bytes for time #define RADIO_DEFAULT_MAX_PAYLOAD (32) #define RADIO_DEFAULT_QUEUE_LEN (3) #define RADIO_DEFAULT_CHANNEL (7) #define RADIO_DEFAULT_POWER_DBM (0) #define RADIO_DEFAULT_BASE0 (0x75626974) // "uBit" #define RADIO_DEFAULT_PREFIX0 (0) #define RADIO_DEFAULT_DATA_RATE (RADIO_MODE_MODE_Nrf_1Mbit) #define RADIO_MAX_CHANNEL (83) // maximum allowed frequency is 2483.5 MHz typedef struct _radio_state_t { uint8_t max_payload; // 1-251 inclusive uint8_t queue_len; // 1-254 inclusive uint8_t channel; // 0-100 inclusive int8_t power_dbm; // one of: -30, -20, -16, -12, -8, -4, 0, 4 uint32_t base0; // for BASE0 register uint8_t prefix0; // for PREFIX0 register (lower 8 bits only) uint8_t data_rate; // one of: RADIO_MODE_MODE_Nrf_{250Kbit,1Mbit,2Mbit} } radio_state_t; static radio_state_t radio_state; static uint8_t *buf_end = NULL; static uint8_t *rx_buf = NULL; void RADIO_IRQHandler(void) { if (NRF_RADIO->EVENTS_READY) { NRF_RADIO->EVENTS_READY = 0; NRF_RADIO->TASKS_START = 1; } if (NRF_RADIO->EVENTS_END) { NRF_RADIO->EVENTS_END = 0; size_t max_len = NRF_RADIO->PCNF1 & 0xff; size_t len = rx_buf[0]; if (len > max_len) { len = max_len; rx_buf[0] = len; } //printf("radio end pos=%d len=%d [%d %d %d %d]\r\n", rx_buf - MP_STATE_PORT(radio_buf), len, rx_buf[0], rx_buf[1], rx_buf[2], rx_buf[3]); // if the CRC was valid then accept the packet if (NRF_RADIO->CRCSTATUS == 1) { // store RSSI as last byte in packet (needs to be negated to get actual dBm value) rx_buf[1 + len] = NRF_RADIO->RSSISAMPLE; // get and store the microsecond timestamp uint32_t time = us_ticker_read(); rx_buf[1 + len + 1] = time & 0xff; rx_buf[1 + len + 2] = (time >> 8) & 0xff; rx_buf[1 + len + 3] = (time >> 16) & 0xff; rx_buf[1 + len + 4] = (time >> 24) & 0xff; // only move the rx_buf pointer if there is enough room for another full packet if (rx_buf + RADIO_PACKET_OVERHEAD + len + RADIO_PACKET_OVERHEAD + max_len <= buf_end) { rx_buf += RADIO_PACKET_OVERHEAD + len; NRF_RADIO->PACKETPTR = (uint32_t)rx_buf; } } NRF_RADIO->TASKS_START = 1; } } static void ensure_enabled(void) { if (MP_STATE_PORT(radio_buf) == NULL) { mp_raise_ValueError("radio is not enabled"); } } static void radio_disable(void) { NVIC_DisableIRQ(RADIO_IRQn); NRF_RADIO->EVENTS_DISABLED = 0; NRF_RADIO->TASKS_DISABLE = 1; while (NRF_RADIO->EVENTS_DISABLED == 0); // free any old buffers if (MP_STATE_PORT(radio_buf) != NULL) { m_del(uint8_t, MP_STATE_PORT(radio_buf), buf_end - MP_STATE_PORT(radio_buf)); MP_STATE_PORT(radio_buf) = NULL; } } static void radio_enable(void) { radio_disable(); // allocate tx and rx buffers size_t max_payload = radio_state.max_payload + RADIO_PACKET_OVERHEAD; size_t queue_len = radio_state.queue_len + 1; // one extra for tx buffer MP_STATE_PORT(radio_buf) = m_new(uint8_t, max_payload * queue_len); buf_end = MP_STATE_PORT(radio_buf) + max_payload * queue_len; rx_buf = MP_STATE_PORT(radio_buf) + max_payload; // start is tx buffer // Enable the High Frequency clock on the processor. This is a pre-requisite for // the RADIO module. Without this clock, no communication is possible. NRF_CLOCK->EVENTS_HFCLKSTARTED = 0; NRF_CLOCK->TASKS_HFCLKSTART = 1; while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0); // power should be one of: -30, -20, -16, -12, -8, -4, 0, 4 NRF_RADIO->TXPOWER = radio_state.power_dbm; // should be between 0 and 100 inclusive (actual physical freq is 2400MHz + this register) NRF_RADIO->FREQUENCY = radio_state.channel; // configure data rate NRF_RADIO->MODE = radio_state.data_rate; // The radio supports filtering packets at the hardware level based on an address. // We use a 5-byte address comprised of 4 bytes (set by BALEN=4 below) from the BASEx // register, plus 1 byte from PREFIXm.APn. // The (x,m,n) values are selected by the logical address. We use logical address 0 // which means using BASE0 with PREFIX0.AP0. NRF_RADIO->BASE0 = radio_state.base0; NRF_RADIO->PREFIX0 = radio_state.prefix0; NRF_RADIO->TXADDRESS = 0; // transmit on logical address 0 NRF_RADIO->RXADDRESSES = 1; // a bit mask, listen only to logical address 0 // LFLEN=8 bits, S0LEN=0, S1LEN=0 NRF_RADIO->PCNF0 = 0x00000008; // STATLEN=0, BALEN=4, ENDIAN=0 (little), WHITEEN=1 NRF_RADIO->PCNF1 = 0x02040000 | radio_state.max_payload; // Enable automatic 16bit CRC generation and checking, and configure how the CRC is calculated. NRF_RADIO->CRCCNF = RADIO_CRCCNF_LEN_Two; NRF_RADIO->CRCINIT = 0xFFFF; NRF_RADIO->CRCPOLY = 0x11021; // Set the start random value of the data whitening algorithm. This can be any non zero number. NRF_RADIO->DATAWHITEIV = 0x18; // set receive buffer NRF_RADIO->PACKETPTR = (uint32_t)rx_buf; // configure interrupts NRF_RADIO->INTENSET = 0x00000008; NVIC_SetPriority(RADIO_IRQn, 3); NVIC_ClearPendingIRQ(RADIO_IRQn); NVIC_EnableIRQ(RADIO_IRQn); NRF_RADIO->SHORTS |= RADIO_SHORTS_ADDRESS_RSSISTART_Msk; // enable receiver NRF_RADIO->EVENTS_READY = 0; NRF_RADIO->TASKS_RXEN = 1; while (NRF_RADIO->EVENTS_READY == 0); NRF_RADIO->EVENTS_END = 0; NRF_RADIO->TASKS_START = 1; } void radio_send(const void *buf, size_t len, const void *buf2, size_t len2) { ensure_enabled(); // construct the packet // note: we must send from RAM size_t max_len = NRF_RADIO->PCNF1 & 0xff; if (len + len2 > max_len) { if (len > max_len) { len = max_len; len2 = 0; } else { len2 = max_len - len; } } MP_STATE_PORT(radio_buf)[0] = len + len2; memcpy(MP_STATE_PORT(radio_buf) + 1, buf, len); if (len2 != 0) { memcpy(MP_STATE_PORT(radio_buf) + 1 + len, buf2, len2); } // transmission will occur synchronously NVIC_DisableIRQ(RADIO_IRQn); // Turn off the transceiver. NRF_RADIO->EVENTS_DISABLED = 0; NRF_RADIO->TASKS_DISABLE = 1; while (NRF_RADIO->EVENTS_DISABLED == 0); // Configure the radio to send the buffer provided. NRF_RADIO->PACKETPTR = (uint32_t)MP_STATE_PORT(radio_buf); // Turn on the transmitter, and wait for it to signal that it's ready to use. NRF_RADIO->EVENTS_READY = 0; NRF_RADIO->TASKS_TXEN = 1; while (NRF_RADIO->EVENTS_READY == 0); // Start transmission and wait for end of packet. NRF_RADIO->TASKS_START = 1; NRF_RADIO->EVENTS_END = 0; while (NRF_RADIO->EVENTS_END == 0); // Return the radio to using the default receive buffer NRF_RADIO->PACKETPTR = (uint32_t)rx_buf; // Turn off the transmitter. NRF_RADIO->EVENTS_DISABLED = 0; NRF_RADIO->TASKS_DISABLE = 1; while (NRF_RADIO->EVENTS_DISABLED == 0); // Start listening for the next packet NRF_RADIO->EVENTS_READY = 0; NRF_RADIO->TASKS_RXEN = 1; while (NRF_RADIO->EVENTS_READY == 0); NRF_RADIO->EVENTS_END = 0; NRF_RADIO->TASKS_START = 1; NVIC_ClearPendingIRQ(RADIO_IRQn); NVIC_EnableIRQ(RADIO_IRQn); } static mp_obj_t radio_receive(uint8_t *header, mp_buffer_info_t *bufinfo, uint32_t *data_out) { ensure_enabled(); // disable the radio irq while we receive the packet NVIC_DisableIRQ(RADIO_IRQn); // get the pointer to the next packet uint8_t *buf = MP_STATE_PORT(radio_buf) + (NRF_RADIO->PCNF1 & 0xff) + RADIO_PACKET_OVERHEAD; // skip tx buf // return None if there are no packets waiting if (rx_buf == buf) { NVIC_EnableIRQ(RADIO_IRQn); return mp_const_none; } // convert the packet data into a Python object size_t len = buf[0]; mp_obj_t ret; if (header == NULL) { if (bufinfo == NULL) { ret = mp_obj_new_bytes(buf + 1, len); // if it raises the radio irq remains disabled... } else { memmove(bufinfo->buf, buf+1, len < bufinfo->len ? len : bufinfo->len); ret = MP_OBJ_NEW_SMALL_INT(len); } } else { memcpy(header, buf, 4); ret = mp_obj_new_str((char*)buf + 4, len - 3, false); // if it raises the radio irq remains disabled... } if (data_out != NULL) { // return the RSSI (to be interpreted as a signed value) *data_out = -buf[1 + len]; // return the timestamp data_out[1] = buf[1 + len + 1] | buf[1 + len + 2] << 8 | buf[1 + len + 3] << 16 | buf[1 + len + 4] << 24; } // copy the rest of the packets down and restart the radio memmove(buf, buf + RADIO_PACKET_OVERHEAD + len, rx_buf - (buf + RADIO_PACKET_OVERHEAD + len)); rx_buf -= RADIO_PACKET_OVERHEAD + len; NRF_RADIO->PACKETPTR = (uint32_t)rx_buf; NRF_RADIO->EVENTS_END = 0; NRF_RADIO->TASKS_START = 1; NVIC_EnableIRQ(RADIO_IRQn); return ret; } /*****************************************************************************/ // MicroPython bindings and module STATIC mp_obj_t mod_radio_reset(void) { radio_state.max_payload = RADIO_DEFAULT_MAX_PAYLOAD; radio_state.queue_len = RADIO_DEFAULT_QUEUE_LEN; radio_state.channel = RADIO_DEFAULT_CHANNEL; radio_state.power_dbm = RADIO_DEFAULT_POWER_DBM; radio_state.base0 = RADIO_DEFAULT_BASE0; radio_state.prefix0 = RADIO_DEFAULT_PREFIX0; radio_state.data_rate = RADIO_DEFAULT_DATA_RATE; return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_0(mod_radio_reset_obj, mod_radio_reset); STATIC mp_obj_t mod_radio_config(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { (void)pos_args; // unused if (n_args != 0) { mp_raise_TypeError("arguments must be keywords"); } // make a copy of the radio state so we don't change anything if there are value errors radio_state_t new_state = radio_state; qstr arg_name = MP_QSTR_; for (size_t i = 0; i < kw_args->alloc; ++i) { if (MP_MAP_SLOT_IS_FILLED(kw_args, i)) { mp_int_t value = mp_obj_get_int_truncated(kw_args->table[i].value); arg_name = mp_obj_str_get_qstr(kw_args->table[i].key); switch (arg_name) { case MP_QSTR_length: if (!(1 <= value && value <= 251)) { goto value_error; } new_state.max_payload = value; break; case MP_QSTR_queue: if (!(1 <= value && value <= 254)) { goto value_error; } new_state.queue_len = value; break; case MP_QSTR_channel: if (!(0 <= value && value <= RADIO_MAX_CHANNEL)) { goto value_error; } new_state.channel = value; break; case MP_QSTR_power: { if (!(0 <= value && value <= 7)) { goto value_error; } static int8_t power_dbm_table[8] = {-30, -20, -16, -12, -8, -4, 0, 4}; new_state.power_dbm = power_dbm_table[value]; break; } case MP_QSTR_data_rate: if (!(value == RADIO_MODE_MODE_Nrf_250Kbit || value == RADIO_MODE_MODE_Nrf_1Mbit || value == RADIO_MODE_MODE_Nrf_2Mbit)) { goto value_error; } new_state.data_rate = value; break; case MP_QSTR_address: new_state.base0 = value; break; case MP_QSTR_group: if (!(0 <= value && value <= 255)) { goto value_error; } new_state.prefix0 = value; break; default: nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "unknown argument '%q'", arg_name)); break; } } } // reconfigure the radio with the new state if (MP_STATE_PORT(radio_buf) == NULL) { // radio disabled, just copy state radio_state = new_state; } else { // radio eabled if (new_state.max_payload != radio_state.max_payload || new_state.queue_len != radio_state.queue_len) { // tx/rx buffer size changed which requires reallocating the buffers radio_disable(); radio_state = new_state; radio_enable(); } else { // only registers changed so make the changes go through efficiently // disable radio NVIC_DisableIRQ(RADIO_IRQn); NRF_RADIO->EVENTS_DISABLED = 0; NRF_RADIO->TASKS_DISABLE = 1; while (NRF_RADIO->EVENTS_DISABLED == 0); // change state radio_state = new_state; NRF_RADIO->TXPOWER = radio_state.power_dbm; NRF_RADIO->FREQUENCY = radio_state.channel; NRF_RADIO->MODE = radio_state.data_rate; NRF_RADIO->BASE0 = radio_state.base0; NRF_RADIO->PREFIX0 = radio_state.prefix0; // need to set RXEN for FREQUENCY decision point NRF_RADIO->EVENTS_READY = 0; NRF_RADIO->TASKS_RXEN = 1; while (NRF_RADIO->EVENTS_READY == 0); // need to set START for BASE0 and PREFIX0 decision point NRF_RADIO->EVENTS_END = 0; NRF_RADIO->TASKS_START = 1; NVIC_ClearPendingIRQ(RADIO_IRQn); NVIC_EnableIRQ(RADIO_IRQn); } } return mp_const_none; value_error: nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "value out of range for argument '%q'", arg_name)); } MP_DEFINE_CONST_FUN_OBJ_KW(mod_radio_config_obj, 0, mod_radio_config); STATIC mp_obj_t mod_radio_on(void) { radio_enable(); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_0(mod_radio_on_obj, mod_radio_on); STATIC mp_obj_t mod_radio_off(void) { radio_disable(); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_0(mod_radio_off_obj, mod_radio_off); STATIC mp_obj_t mod_radio_send_bytes(mp_obj_t buf_in) { mp_buffer_info_t bufinfo; mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_READ); radio_send(bufinfo.buf, bufinfo.len, NULL, 0); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_1(mod_radio_send_bytes_obj, mod_radio_send_bytes); STATIC mp_obj_t mod_radio_receive_bytes(void) { return radio_receive(NULL, NULL, NULL); } MP_DEFINE_CONST_FUN_OBJ_0(mod_radio_receive_bytes_obj, mod_radio_receive_bytes); STATIC mp_obj_t mod_radio_send(mp_obj_t buf_in) { mp_uint_t len; const char *data = mp_obj_str_get_data(buf_in, &len); radio_send("\x01\x00\x01", 3, data, len); return mp_const_none; } MP_DEFINE_CONST_FUN_OBJ_1(mod_radio_send_obj, mod_radio_send); STATIC mp_obj_t mod_radio_receive(void) { uint8_t header[4]; mp_obj_t obj = radio_receive(header, NULL, NULL); // verify header has the correct values if (obj != mp_const_none && !(header[0] >= 3 && header[1] == 1 && header[2] == 0 && header[3] == 1)) { mp_raise_ValueError("received packet is not a string"); } return obj; } MP_DEFINE_CONST_FUN_OBJ_0(mod_radio_receive_obj, mod_radio_receive); STATIC mp_obj_t mod_radio_receive_bytes_into(mp_obj_t buf_in) { mp_buffer_info_t bufinfo; mp_get_buffer_raise(buf_in, &bufinfo, MP_BUFFER_WRITE); return radio_receive(NULL, &bufinfo, NULL); } MP_DEFINE_CONST_FUN_OBJ_1(mod_radio_receive_bytes_into_obj, mod_radio_receive_bytes_into); STATIC mp_obj_t mod_radio_receive_full(void) { uint32_t data[2]; mp_obj_t bytes = radio_receive(NULL, NULL, data); if (bytes == mp_const_none) { return mp_const_none; } mp_obj_t t[3] = { bytes, MP_OBJ_NEW_SMALL_INT((int32_t)data[0]), MP_OBJ_NEW_SMALL_INT(data[1] & (MICROPY_PY_UTIME_TICKS_PERIOD - 1)) }; return mp_obj_new_tuple(3, t); } MP_DEFINE_CONST_FUN_OBJ_0(mod_radio_receive_full_obj, mod_radio_receive_full); STATIC const mp_map_elem_t radio_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_radio) }, { MP_OBJ_NEW_QSTR(MP_QSTR___init__), (mp_obj_t)&mod_radio_reset_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_reset), (mp_obj_t)&mod_radio_reset_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_config), (mp_obj_t)&mod_radio_config_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_on), (mp_obj_t)&mod_radio_on_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_off), (mp_obj_t)&mod_radio_off_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_send_bytes), (mp_obj_t)&mod_radio_send_bytes_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_receive_bytes), (mp_obj_t)&mod_radio_receive_bytes_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_send), (mp_obj_t)&mod_radio_send_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_receive), (mp_obj_t)&mod_radio_receive_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_receive_bytes_into), (mp_obj_t)&mod_radio_receive_bytes_into_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_receive_full), (mp_obj_t)&mod_radio_receive_full_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_RATE_250KBIT), MP_OBJ_NEW_SMALL_INT(RADIO_MODE_MODE_Nrf_250Kbit) }, { MP_OBJ_NEW_QSTR(MP_QSTR_RATE_1MBIT), MP_OBJ_NEW_SMALL_INT(RADIO_MODE_MODE_Nrf_1Mbit) }, { MP_OBJ_NEW_QSTR(MP_QSTR_RATE_2MBIT), MP_OBJ_NEW_SMALL_INT(RADIO_MODE_MODE_Nrf_2Mbit) }, }; STATIC MP_DEFINE_CONST_DICT(radio_module_globals, radio_module_globals_table); const mp_obj_module_t radio_module = { .base = { &mp_type_module }, .globals = (mp_obj_dict_t*)&radio_module_globals, }; }
[ "damien.p.george@gmail.com" ]
damien.p.george@gmail.com
5284164d54ee22ceef4c802ea3d40ad5a7461e7d
43ba15460293d7224a03eed5ecbb6569663d0837
/dev/main/ilecto_mysql.h
cecfdcdf3fcc4cc25da198fa86aade702507cfb8
[]
no_license
chlewey/ilecto-cpp
c9bb6cfde8e154b35c678b2bfc943a5462547ef4
8e3c01d6057c9813cce190117ab13b9249c875c2
refs/heads/master
2021-01-11T15:26:59.549702
2017-02-09T16:39:39
2017-02-09T16:39:39
80,345,263
0
0
null
null
null
null
UTF-8
C++
false
false
669
h
/*@ ilecto_mysql.h * * This header defines the xml::xml class * *@ author: Carlos E. Thompson P. *@ licence: copyleft, 2017 * */ #ifndef __ILECTO_MYSQL_H__ #define __ILECTO_MYSQL_H__ #include "ilecto_db.h" namespace mysql { typedef il::string string; typedef il::vstring vstring; class db_index: public il::db_index { public: }; class db_result: public il::db_result { public: }; class db: public il::db { public: db(const string&location,const string&user,const string&passwd,const string&database="",const string&prefix=""); ~db(); string& escape(const string&str); db_result& select(string&table, vstring&fields); }; }//namspace #endif
[ "chlewey@gmail.com" ]
chlewey@gmail.com
d7fc64e95e47ea327be891e527dd1d77a40a5e4b
0160490319cac0dfbe37834d0468aed63f2cd0c0
/include/ISgfcGoStone.h
ee7cf28f76ac33d7cdbadbfeeb17f7ce9656a76c
[ "Apache-2.0", "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference", "BSL-1.0" ]
permissive
herzbube/libsgfcplusplus
a6c9c11b05a13ca1f422b15e220efb84aeefb875
cd93b76c9044952a0067240cbebac7c535e0275a
refs/heads/develop
2021-07-14T20:04:24.516039
2021-02-23T19:16:12
2021-02-23T19:16:12
238,560,277
8
1
Apache-2.0
2021-02-13T16:53:57
2020-02-05T22:21:31
C++
UTF-8
C++
false
false
1,813
h
// ----------------------------------------------------------------------------- // Copyright 2020 Patrick Näf (herzbube@herzbube.ch) // // 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. // ----------------------------------------------------------------------------- #pragma once // Project includes #include "SgfcColor.h" // Project includes (generated) #include "SgfcPlusPlusExport.h" // C++ Standard Library includes #include <memory> namespace LibSgfcPlusPlus { class ISgfcGoPoint; /// @brief The ISgfcGoStone interface represents a Go stone. /// /// @ingroup public-api /// @ingroup go /// /// A Go stone on a Go board is defined by its color and by its location on /// the Go board. ISgfcGoStone stores an SgfcColor value and a reference to an /// ISgfcGoPoint object to record these two pieces of information. class SGFCPLUSPLUS_EXPORT ISgfcGoStone { public: /// @brief Initializes a newly constructed ISgfcGoStone object. ISgfcGoStone(); /// @brief Destroys and cleans up the ISgfcGoStone object. virtual ~ISgfcGoStone(); /// @brief Returns the color of the stone. virtual SgfcColor GetColor() const = 0; /// @brief Returns the location of the stone on the Go board. virtual std::shared_ptr<ISgfcGoPoint> GetLocation() const = 0; }; }
[ "herzbube@herzbube.ch" ]
herzbube@herzbube.ch
38590706a2c8cfadeb86216433f974036a8dde84
32bf62800dd64a417e67d460962a7e8b5a70d6f1
/hello/window.cc
745465980bce27c9b539e9936fe1b7885caac1c9
[]
no_license
kwamei/prog.qt
5ca608d3ab4a6c60e41f5747d0dfb9d4384a4384
efb90c6680053ccfdcb54e40b4f7a717a2155c72
refs/heads/master
2016-09-05T17:52:55.523262
2009-08-28T22:23:31
2009-08-28T22:23:31
null
0
0
null
null
null
null
UTF-8
C++
false
false
332
cc
#include <QLabel> #include <QVBoxLayout> #include "window.h" Window::Window(QWidget *parent) : QWidget(parent) { setWindowTitle("Hello"); QVBoxLayout *layout = new QVBoxLayout; setLayout(layout); QLabel *label = new QLabel("Hello world!"); label->setAlignment(Qt::AlignCenter); layout->addWidget(label); }
[ "lorenzo.cabrini@gmail.com" ]
lorenzo.cabrini@gmail.com
b40530cdaf4e302fe6b6c39acdb04ece20d83496
171bc11358f37d6347088572c5da3880676e5790
/test/test_maxpooling_layer.h
50b14151433fe29de300511e88e2cfeb3d5cf093
[ "LicenseRef-scancode-other-permissive", "MIT" ]
permissive
vonhachtaugust/simpleCNN
952d7bd3571450d81663cd0f9e6cb796f14a7473
3d809c71aeeacb9dcf6ea186768d0fc9712eb777
refs/heads/master
2021-01-19T18:54:17.668384
2017-07-07T08:36:48
2017-07-07T08:36:48
83,711,291
5
0
null
null
null
null
UTF-8
C++
false
false
3,552
h
// // Created by hacht on 4/4/17. // #pragma once #include "../simpleCNN/simpleCNN.h" #include "gtest/gtest.h" namespace simpleCNN { TEST(Maxpooling, forward_propagation) { size_t in_width = 4; size_t in_height = 4; size_t in_channels = 2; size_t batch_size = 2; size_t pooling_size_x = 2; size_t pooling_size_y = 2; Maxpooling_layer maxpool(in_width, in_height, in_channels, batch_size); vec_t in_data = {1, 1, 2, 4, 5, 6, 7, 8, 3, 2, 1, 0, 1, 2, 3, 4, 1, 1, 2, 4, 5, 6, 7, 8, 3, 2, 1, 0, 1, 2, 3, 4, 1, 1, 2, 4, 5, 6, 7, 8, 3, 2, 1, 0, 1, 2, 3, 4, 1, 1, 2, 4, 5, 6, 7, 8, 3, 2, 1, 0, 1, 2, 3, 4}; tensor_t img({batch_size, in_channels, in_height, in_width}); fill(in_data, img); // simple_info("In data: "); // std::cout << img << std::endl; tensor_t out({batch_size, in_channels, pooling_size_y, pooling_size_x}); // maxpool.set_in_data(img, component_t::IN_DATA); // maxpool.set_out_data(out, component_t::OUT_DATA); // maxpool.set_out_data(out, component_t::AUX); // data_ptrs_t input = {maxpool.in_component_data(component_t::IN_DATA)}; // data_ptrs_t output = {maxpool.out_component_data(component_t::OUT_DATA), // maxpool.out_component_data(component_t::AUX)}; data_ptrs_t input = {&img}; data_ptrs_t output = {&out}; maxpool.forward_propagation(input, output); // simple_info("Out data: "); // std::cout << out << std::endl; // print(img, "Image"); // print(out, "Output"); auto outIter = out.host_begin(); vec_t correctOutput = {6, 8, 3, 4, 6, 8, 3, 4, 6, 8, 3, 4, 6, 8, 3, 4}; for (const auto& d : correctOutput) { ASSERT_EQ(*outIter++, d); } } TEST(Maxpooling, back_propagation) { size_t in_width = 4; size_t in_height = 4; size_t in_channels = 1; size_t out_channels = in_channels; // for clarity size_t batch_size = 1; size_t pooling_size_x = 2; size_t pooling_size_y = 2; Maxpooling_layer maxpool(in_width, in_height, in_channels, batch_size); // In order to get max index tensor we have to perform activate forward pass first. vec_t in_data = {1, 1, 2, 4, 5, -1, 7, -1, 3, 5, 1, 0, 1, 2, 3, 4}; tensor_t img({batch_size, in_channels, in_height, in_width}); fill(in_data, img); // simple_info("In data: "); // std::cout << img << std::endl; tensor_t out({batch_size, in_channels, pooling_size_y, pooling_size_x}); data_ptrs_t input = {&img}; data_ptrs_t output = {&out}; maxpool.forward_propagation(input, output); // simple_info("Out data: "); // std::cout << out << std::endl; tensor_t curr_delta({batch_size, out_channels, pooling_size_y, pooling_size_x}); vec_t curr_delta_data = {1, 2, 3, 4}; fill(curr_delta_data, curr_delta); // simple_info("Current delta: "); // std::cout << curr_delta << std::endl; tensor_t prev_delta({batch_size, in_channels, in_height, in_width}); data_ptrs_t input_grad = {&prev_delta}; data_ptrs_t output_grad = {&curr_delta}; maxpool.back_propagation(input, output, input_grad, output_grad); // simple_info("Prev delta:"); // std::cout << prev_delta << std::endl; ASSERT_EQ(prev_delta.host_at(0, 0, 1, 0), curr_delta_data[0]); ASSERT_EQ(prev_delta.host_at(0, 0, 1, 2), curr_delta_data[1]); ASSERT_EQ(prev_delta.host_at(0, 0, 2, 1), curr_delta_data[2]); ASSERT_EQ(prev_delta.host_at(0, 0, 3, 3), curr_delta_data[3]); } }
[ "vonhachtaugust@gmail.com" ]
vonhachtaugust@gmail.com
34fdb63d0edc19d8d45e609b9c80e54340b51147
02eeb06de9156dbe4f126f5f06dc983b63ad559c
/test/test_general.cpp
b41a12a996bd1edc9277fc2109920521ceea3c0d
[ "MIT" ]
permissive
pgroke/saco
76c784919f093f0d63b68f3f7894b6249677541e
b30bdb294f4fd9d810f0ccc79ecc30f17f61d3a9
refs/heads/main
2023-04-01T04:31:46.110975
2021-04-06T18:49:19
2021-04-06T18:49:19
354,260,133
0
0
null
null
null
null
UTF-8
C++
false
false
6,126
cpp
#include "_common.h" #include <cstddef> #include <cstdint> #include <limits> #include <type_traits> #include "_poison_std_types_in_global_namespace.h" #include <saco/saco.h> namespace { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// SACO_NOINLINE void throw_out_of_range() { throw std::runtime_error("meh"); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template <class T, class Offset> class offset_ptr_base { static_assert(std::is_integral_v<Offset>); static_assert(std::is_signed_v<Offset>); public: offset_ptr_base(offset_ptr_base&&) = delete; offset_ptr_base() : m_offset{0} { } explicit offset_ptr_base(T* p) : m_offset{encode(p)} { } explicit operator bool() const { return m_offset != 0; } bool operator!() const { return m_offset == 0; } T* get() const { return decode(); } T* operator->() const { return decode(); } T& operator*() const { return *decode(); } private: T* decode() const { auto const my_addr = reinterpret_cast<std::uintptr_t>(&m_offset); auto const p_addr = my_addr + m_offset; return m_offset ? reinterpret_cast<T*>(p_addr) : nullptr; } Offset encode(T* p) { auto const p_addr = reinterpret_cast<std::uintptr_t>(p); auto const my_addr = reinterpret_cast<std::uintptr_t>(&m_offset); auto const offset = p ? static_cast<std::ptrdiff_t>(p_addr - my_addr) : 0; if (SACO_UNLIKELY(offset < std::numeric_limits<Offset>::min() || offset > std::numeric_limits<Offset>::max())) throw_out_of_range(); return static_cast<Offset>(offset); } Offset m_offset; }; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template <class Base, bool IS_TRIVIALLY_DESTRUCTIBLE> class inner_ptr_dtor_impl; template <class T> using target_type = std::decay_t<decltype(*std::declval<T>())>; template <class Base> class inner_ptr_dtor_impl<Base, true> : public Base { static_assert(std::is_trivially_destructible_v<target_type<Base>>); using Base::Base; }; template <class Base> class inner_ptr_dtor_impl<Base, false> : public Base { public: using Base::Base; ~inner_ptr_dtor_impl() { if (*this) { using T = target_type<Base>; this->get()->~T(); } } }; template <class T, class Offset> class unique_offset_ptr : public inner_ptr_dtor_impl<offset_ptr_base<T, Offset>, std::is_trivially_destructible_v<T>> { using _base = inner_ptr_dtor_impl<offset_ptr_base<T, Offset>, std::is_trivially_destructible_v<T>>; using _base::_base; }; template <class T> using unique_o8_ptr = unique_offset_ptr<T, std::int8_t>; template <class T> using unique_o16_ptr = unique_offset_ptr<T, std::int16_t>; template <class T> using unique_o32_ptr = unique_offset_ptr<T, std::int32_t>; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// struct bar { static thread_local std::uint32_t tls_instance_count; bar() { signature[0] = '^'; signature[1] = 'b'; signature[2] = 'a'; signature[3] = 'r'; signature[4] = 'B'; signature[5] = 'A'; signature[6] = 'R'; signature[7] = '$'; tls_instance_count++; } ~bar() { tls_instance_count--; } char signature[8]; }; thread_local std::uint32_t bar::tls_instance_count{0}; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// struct foo { static thread_local std::uint32_t tls_instance_count; foo(bar* bars, std::size_t bar_count, bar* bar2) : bars{bars}, bar_count{bar_count}, bar2{bar2} { tls_instance_count++; } ~foo() { tls_instance_count--; for (std::size_t i = 0; i < bar_count; i++) bars[i].~bar(); } char s0 = '0'; bar* bars; std::size_t bar_count; char s1 = '1'; unique_o16_ptr<bar> bar2; }; thread_local std::uint32_t foo::tls_instance_count{0}; #define CHECK_BAR_SIGNATURE(bar) \ do { \ CHECK((bar).signature[0] == '^'); \ CHECK((bar).signature[1] == 'b'); \ CHECK((bar).signature[2] == 'a'); \ CHECK((bar).signature[3] == 'r'); \ CHECK((bar).signature[4] == 'B'); \ CHECK((bar).signature[5] == 'A'); \ CHECK((bar).signature[6] == 'R'); \ CHECK((bar).signature[7] == '$'); \ } while (false) } // namespace template <> struct saco::builder<foo> { template <class Context, class... Args> static foo* build(void* memory, Context& ctx, std::size_t bar_count) { [[maybe_unused]] bar* bars = saco::place<bar[]>(bar_count, ctx); [[maybe_unused]] bar* bar2 = saco::place<bar>(ctx); if SACO_IF_CONSTRUCT_CONTEXT (Context) return ::new (memory) foo{bars, bar_count, bar2}; else return nullptr; } }; namespace { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// TEST_CASE("general-1") { foo::tls_instance_count = 0; bar::tls_instance_count = 0; { auto const f = saco::build_unique<foo>(3); CHECK(foo::tls_instance_count == 1); CHECK(bar::tls_instance_count == 4); CHECK(f->s0 == '0'); CHECK(f->s1 == '1'); REQUIRE(f->bars != nullptr); REQUIRE(f->bar_count == 3); CHECK_BAR_SIGNATURE(f->bars[0]); CHECK_BAR_SIGNATURE(f->bars[1]); CHECK_BAR_SIGNATURE(f->bars[2]); CHECK_BAR_SIGNATURE(*f->bar2); } CHECK(foo::tls_instance_count == 0); CHECK(bar::tls_instance_count == 0); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// TEST_CASE("alloc_raw") { for (std::size_t s = 0; s < 512; s++) for (std::size_t i = 0; i < 1000; i++) saco::detail::free_raw(saco::detail::alloc_raw(s)); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// } // namespace
[ "gjnzdnfkpp@snkmail.com" ]
gjnzdnfkpp@snkmail.com
d26f339727446b485963c43be040453817031214
f4adb303459fa4da5e4b6bb55f1d2848e0ddf396
/dependancies/include/gtkmm/glibmm/private/binding_p.h
6e3c8f900a10ca0e0d95af3aa4f79cf1a7fa5d1c
[ "MIT", "LGPL-2.0-or-later", "GPL-3.0-only" ]
permissive
Illation/synthesizer
9d81af54188f88812f4df1018d51b1360a3db3f7
da77d55c1c69829bbad76d0c14b9c56a5261b642
refs/heads/master
2020-05-17T05:30:58.827574
2019-06-30T23:04:40
2019-06-30T23:04:40
183,531,655
4
0
MIT
2019-06-30T23:04:41
2019-04-26T01:01:08
C++
UTF-8
C++
false
false
1,048
h
// Generated by gmmproc 2.52.1 -- DO NOT MODIFY! #ifndef _GLIBMM_BINDING_P_H #define _GLIBMM_BINDING_P_H #include <glibmm/private/object_p.h> #include <glibmm/class.h> namespace Glib { class Binding_Class : public Glib::Class { public: #ifndef DOXYGEN_SHOULD_SKIP_THIS using CppObjectType = Binding; using BaseObjectType = GBinding; using BaseClassType = GBindingClass; using CppClassParent = Glib::Object_Class; using BaseClassParent = GObjectClass; friend class Binding; #endif /* DOXYGEN_SHOULD_SKIP_THIS */ const Glib::Class& init(); static void class_init_function(void* g_class, void* class_data); static Glib::ObjectBase* wrap_new(GObject*); protected: //Callbacks (default signal handlers): //These will call the *_impl member methods, which will then call the existing default signal callbacks, if any. //You could prevent the original default signal handlers being called by overriding the *_impl method. //Callbacks (virtual functions): }; } // namespace Glib #endif /* _GLIBMM_BINDING_P_H */
[ "hello@leah-lindner.com" ]
hello@leah-lindner.com
191787764bf342304119bdc0d0d0ff00baf718ab
ef647be3eedf9567ea92829759d271e344b716dd
/RenderingX12/RenderingX.cpp
e71ff3241786995370825c006282d4491cae5628
[]
no_license
alexanderyyg/RenderingX12
7e0c96f39125259a5f269664b4c8de35861b728b
f4c63a89e9717acb2fafa5f2a52d12cd6ab84bfc
refs/heads/master
2020-09-22T01:55:46.753946
2019-11-30T08:48:03
2019-11-30T08:48:03
null
0
0
null
null
null
null
UTF-8
C++
false
false
22,954
cpp
//********************************************************* // // Copyright (c) Microsoft. All rights reserved. // This code is licensed under the MIT License (MIT). // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT. // //********************************************************* #include "RenderingX.h" #define POST_PROCESS 1 using namespace std; using namespace XUSG; RenderingX::RenderingX(uint32_t width, uint32_t height, std::wstring name) : DXFramework(width, height, name), m_frameParity(0), m_frameIndex(0), m_useIBL(true), m_isPaused(false), m_isTracking(false), m_sceneFile(L"Media/Scene.json") { #if defined (_DEBUG) _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); AllocConsole(); FILE* stream; freopen_s(&stream, "CONOUT$", "w+t", stdout); freopen_s(&stream, "CONIN$", "r+t", stdin); #endif } RenderingX::~RenderingX() { #if defined (_DEBUG) FreeConsole(); #endif } void RenderingX::OnInit() { LoadPipeline(); LoadAssets(); } // Load the rendering pipeline dependencies. void RenderingX::LoadPipeline() { auto dxgiFactoryFlags = 0u; #if defined(_DEBUG) // Enable the debug layer (requires the Graphics Tools "optional feature"). // NOTE: Enabling the debug layer after device creation will invalidate the active device. { com_ptr<ID3D12Debug> debugController; if (SUCCEEDED(D3D12GetDebugInterface(IID_PPV_ARGS(&debugController)))) { debugController->EnableDebugLayer(); // Enable additional debug layers. dxgiFactoryFlags |= DXGI_CREATE_FACTORY_DEBUG; } } #endif ThrowIfFailed(CreateDXGIFactory2(dxgiFactoryFlags, IID_PPV_ARGS(&m_factory))); DXGI_ADAPTER_DESC1 dxgiAdapterDesc; com_ptr<IDXGIAdapter1> dxgiAdapter; auto hr = DXGI_ERROR_UNSUPPORTED; for (auto i = 0u; hr == DXGI_ERROR_UNSUPPORTED; ++i) { dxgiAdapter = nullptr; ThrowIfFailed(m_factory->EnumAdapters1(i, &dxgiAdapter)); hr = D3D12CreateDevice(dxgiAdapter.get(), D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&m_device)); } dxgiAdapter->GetDesc1(&dxgiAdapterDesc); if (dxgiAdapterDesc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) m_title += dxgiAdapterDesc.VendorId == 0x1414 && dxgiAdapterDesc.DeviceId == 0x8c ? L" (WARP)" : L" (Software)"; ThrowIfFailed(hr); // Create the command queue. N_RETURN(m_device->GetCommandQueue(m_commandQueue, CommandListType::DIRECT, CommandQueueFlags::NONE), ThrowIfFailed(E_FAIL)); // Create the swap chain. CreateSwapchain(); // Reset the index to the current back buffer. m_frameIndex = m_swapChain->GetCurrentBackBufferIndex(); // Create a command allocator for each frame. for (auto n = 0u; n < FrameCount; ++n) N_RETURN(m_device->GetCommandAllocator(m_commandAllocators[n], CommandListType::DIRECT), ThrowIfFailed(E_FAIL)); // Create descriptor table cache. m_descriptorTableCache = make_shared<DescriptorTableCache>(m_device, L"DescriptorTableCache"); } // Load the sample assets. void RenderingX::LoadAssets() { m_shaderPool = make_shared<ShaderPool>(); m_graphicsPipelineCache = make_shared<Graphics::PipelineCache>(m_device); m_computePipelineCache = make_shared<Compute::PipelineCache>(m_device); m_pipelineLayoutCache = make_shared<PipelineLayoutCache>(m_device); // Create the command list. N_RETURN(m_device->GetCommandList(m_commandList.GetCommandList(), 0, CommandListType::DIRECT, m_commandAllocators[m_frameIndex], nullptr), ThrowIfFailed(E_FAIL)); // Load scene asset vector<Resource> uploaders; { Blob sceneFileBlob; D3DReadFileToBlob(m_sceneFile.c_str(), &sceneFileBlob); N_RETURN(sceneFileBlob, ThrowIfFailed(E_FAIL)); const string sceneString = reinterpret_cast<char*>(sceneFileBlob->GetBufferPointer()); tiny::TinyJson sceneReader; sceneReader.ReadJson(sceneString); // Create scene m_scene = make_unique<Scene>(m_device); //m_scene->SetRenderTarget(m_rtHDR, m_depth); N_RETURN(m_scene->LoadAssets(&sceneReader, m_commandList, m_shaderPool, m_graphicsPipelineCache, m_computePipelineCache, m_pipelineLayoutCache, m_descriptorTableCache, uploaders, FormatHDR, FormatDepth, m_useIBL), ThrowIfFailed(E_FAIL)); } #if POST_PROCESS { m_postprocess = make_unique<Postprocess>(m_device); N_RETURN(m_postprocess->Init(m_shaderPool, m_graphicsPipelineCache, m_computePipelineCache, m_pipelineLayoutCache, m_descriptorTableCache, FormatHDR, FormatLDR), ThrowIfFailed(E_FAIL)); } #else // Pipeline for simple tone mapping { // Create pipeline layout Util::PipelineLayout utilPipelineLayout; utilPipelineLayout.SetRange(0, DescriptorType::SRV, 1, 0); utilPipelineLayout.SetShaderStage(0, Shader::Stage::PS); X_RETURN(m_pipelineLayout, utilPipelineLayout.GetPipelineLayout(*m_pipelineLayoutCache, PipelineLayoutFlag::ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT, L"SimpleToneMapLayout"), ThrowIfFailed(E_FAIL)); // Load shader N_RETURN(m_shaderPool->CreateShader(Shader::Stage::PS, PS_TONE_MAP, L"PSSimpleToneMap.cso"), ThrowIfFailed(E_FAIL)); // Create pipeline Graphics::State state; state.SetPipelineLayout(m_pipelineLayout); state.SetShader(Shader::Stage::VS, m_shaderPool->GetShader(Shader::Stage::VS, VS_SCREEN_QUAD)); state.SetShader(Shader::Stage::PS, m_shaderPool->GetShader(Shader::Stage::PS, PS_TONE_MAP)); state.IASetPrimitiveTopologyType(PrimitiveTopologyType::TRIANGLE); state.DSSetState(Graphics::DepthStencilPreset::DEPTH_STENCIL_NONE, *m_graphicsPipelineCache); state.OMSetNumRenderTargets(1); state.OMSetRTVFormat(0, FormatLDR); X_RETURN(m_pipeline, state.GetPipeline(*m_graphicsPipelineCache, L"SimpleToneMap"), ThrowIfFailed(E_FAIL)); } #endif // Close the command list and execute it to begin the initial GPU setup. ThrowIfFailed(m_commandList.Close()); BaseCommandList* const ppCommandLists[] = { m_commandList.GetCommandList().get() }; m_commandQueue->ExecuteCommandLists(static_cast<uint32_t>(size(ppCommandLists)), ppCommandLists); // Create synchronization objects and wait until assets have been uploaded to the GPU. { N_RETURN(m_device->GetFence(m_fence, m_fenceValues[m_frameIndex]++, FenceFlag::NONE), ThrowIfFailed(E_FAIL)); // Create an event handle to use for frame synchronization. m_fenceEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); if (m_fenceEvent == nullptr) { ThrowIfFailed(HRESULT_FROM_WIN32(GetLastError())); } // Wait for the command list to execute; we are reusing the same command // list in our main loop but for now, we just want to wait for setup to // complete before continuing. WaitForGpu(); } // Setup the camera's view parameters { const auto focus_dist = m_scene->GetFocusAndDistance(); const auto viewDist = XMVectorGetW(focus_dist); const auto viewDisp = XMVectorSet(0.0f, 0.0f, viewDist, 0.0f); const auto eyePt = focus_dist - viewDisp; const auto view = XMMatrixLookAtLH(eyePt, focus_dist, XMVectorSet(0.0f, 1.0f, 0.0f, 1.0f)); XMStoreFloat3(&m_eyePt, eyePt); XMStoreFloat4x4(&m_view, view); } } void RenderingX::CreateSwapchain() { // Describe and create the swap chain. DXGI_SWAP_CHAIN_DESC1 swapChainDesc = {}; swapChainDesc.BufferCount = FrameCount; swapChainDesc.Width = m_width; swapChainDesc.Height = m_height; swapChainDesc.Format = static_cast<DXGI_FORMAT>(FormatLDR);; swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; swapChainDesc.SampleDesc.Count = 1; com_ptr<IDXGISwapChain1> swapChain; ThrowIfFailed(m_factory->CreateSwapChainForHwnd( m_commandQueue.get(), // Swap chain needs the queue so that it can force a flush on it. Win32Application::GetHwnd(), &swapChainDesc, nullptr, nullptr, &swapChain )); // Store the swap chain. ThrowIfFailed(swapChain.As(&m_swapChain)); // This class does not support exclusive full-screen mode and prevents DXGI from responding to the ALT+ENTER shortcut. ThrowIfFailed(m_factory->MakeWindowAssociation(Win32Application::GetHwnd(), DXGI_MWA_NO_ALT_ENTER)); } void RenderingX::CreateResources() { // Obtain the back buffers for this window which will be the final render targets // and create render target views for each of them. for (auto n = 0u; n < FrameCount; ++n) N_RETURN(m_renderTargets[n].CreateFromSwapChain(m_device, m_swapChain, n), ThrowIfFailed(E_FAIL)); // Create TAA RTs for (auto n = 0u; n < 2; ++n) N_RETURN(m_rtTAAs[n].Create(m_device, m_width, m_height, FormatLDR, 1, ResourceFlag::NONE, 1, 1, n != m_frameParity ? ResourceState::PIXEL_SHADER_RESOURCE : ResourceState::COMMON, nullptr, false, (L"TemporalAA_RT" + to_wstring(n)).c_str()), ThrowIfFailed(E_FAIL)); // Create HDR RT N_RETURN(m_rtHDR.Create(m_device, m_width, m_height, FormatHDR, 1, ResourceFlag::NONE, 1, 1, ResourceState::COMMON, nullptr, false, L"HDR_RT"), ThrowIfFailed(E_FAIL)); // Create LDR RT N_RETURN(m_rtLDR.Create(m_device, m_width, m_height, FormatLDR, 1, ResourceFlag::NONE, 1, 1, ResourceState::COMMON, nullptr, false, L"LDR_RT"), ThrowIfFailed(E_FAIL)); // Create a DSV N_RETURN(m_depth.Create(m_device, m_width, m_height, Format::UNKNOWN, ResourceFlag::NONE, 1, 1, 1, ResourceState::COMMON, 1.0f, 0, false, L"Depth"), ThrowIfFailed(E_FAIL)); // Set the 3D rendering viewport and scissor rectangle to target the entire window. m_viewport = Viewport(0.0f, 0.0f, static_cast<float>(m_width), static_cast<float>(m_height)); m_scissorRect = RectRange(0, 0, m_width, m_height); } void RenderingX::ResizeAssets() { ThrowIfFailed(m_commandAllocators[m_frameIndex]->Reset()); ThrowIfFailed(m_commandList.Reset(m_commandAllocators[m_frameIndex], nullptr)); // Scene vector<Resource> uploaders; N_RETURN(m_scene->ChangeWindowSize(m_commandList, uploaders, m_rtHDR, m_depth), ThrowIfFailed(E_FAIL)); // Post process #if POST_PROCESS { N_RETURN(m_postprocess->ChangeWindowSize(m_rtHDR, m_scene->GetGBufferSRV(Scene::ALBEDO_IDX)), ThrowIfFailed(E_FAIL)); // Create Descriptor tables Util::DescriptorTable srvTable; const Descriptor srvs[] = { m_rtHDR.GetSRV(), m_depth.GetSRV() }; srvTable.SetDescriptors(0, static_cast<uint32_t>(size(srvs)), srvs, Postprocess::RESIZABLE_POOL); X_RETURN(m_srvTables[SRV_HDR], srvTable.GetCbvSrvUavTable(*m_descriptorTableCache), ThrowIfFailed(E_FAIL)); for (auto n = 0u; n < 2; ++n) { X_RETURN(m_srvTables[SRV_AA_INPUT + n], m_postprocess->CreateTemporalAASRVTable( m_rtLDR.GetSRV(), m_rtTAAs[!n].GetSRV(), m_scene->GetGBufferSRV(Scene::MOTION_IDX), m_scene->GetGBufferSRV(Scene::MATENC_IDX)), ThrowIfFailed(E_FAIL)); Util::DescriptorTable srvTable; srvTable.SetDescriptors(0, 1, &m_rtTAAs[n].GetSRV(), Postprocess::RESIZABLE_POOL); X_RETURN(m_srvTables[SRV_ANTIALIASED + n], srvTable.GetCbvSrvUavTable(*m_descriptorTableCache), ThrowIfFailed(E_FAIL)); } } #else // Create Descriptor table Util::DescriptorTable srvTable; srvTable.SetDescriptors(0, 1, &m_rtHDR.GetSRV(), Postprocess::RESIZABLE_POOL); X_RETURN(m_srvTables[SRV_HDR], srvTable.GetCbvSrvUavTable(*m_descriptorTableCache), ThrowIfFailed(E_FAIL)); #endif // Close the command list and execute it to begin the initial GPU setup. ThrowIfFailed(m_commandList.Close()); BaseCommandList* const ppCommandLists[] = { m_commandList.GetCommandList().get() }; m_commandQueue->ExecuteCommandLists(static_cast<uint32_t>(size(ppCommandLists)), ppCommandLists); // Create synchronization objects and wait until assets have been uploaded to the GPU. { N_RETURN(m_device->GetFence(m_fence, m_fenceValues[m_frameIndex]++, FenceFlag::NONE), ThrowIfFailed(E_FAIL)); // Create an event handle to use for frame synchronization. m_fenceEvent = CreateEvent(nullptr, FALSE, FALSE, nullptr); if (m_fenceEvent == nullptr) { ThrowIfFailed(HRESULT_FROM_WIN32(GetLastError())); } // Wait for the command list to execute; we are reusing the same command // list in our main loop but for now, we just want to wait for setup to // complete before continuing. WaitForGpu(); } } // Update frame-based values. void RenderingX::OnUpdate() { // Timer static auto time = 0.0, pauseTime = 0.0; m_timer.Tick(); float timeStep; const auto totalTime = CalculateFrameStats(&timeStep); pauseTime = m_isPaused ? totalTime - time : pauseTime; timeStep = m_isPaused ? 0.0f : timeStep; time = totalTime - pauseTime; // Camera update for scene const auto eyePt = XMLoadFloat3(&m_eyePt); const auto view = XMLoadFloat4x4(&m_view); const auto proj = XMLoadFloat4x4(&m_proj); m_scene->Update(m_frameIndex, time, timeStep, view, proj, eyePt); #if POST_PROCESS m_postprocess->Update(m_scene->GetCBVTable(0), m_scene->GetCBVTable(Scene::CBV_PER_FRAME_PS + m_frameIndex), timeStep); #endif } // Render the scene. void RenderingX::OnRender() { // Record all the commands we need to render the scene into the command list. PopulateCommandList(); // Execute the command list. BaseCommandList* const ppCommandLists[] = { m_commandList.GetCommandList().get() }; m_commandQueue->ExecuteCommandLists(static_cast<uint32_t>(size(ppCommandLists)), ppCommandLists); // Present the frame. ThrowIfFailed(m_swapChain->Present(0, 0)); MoveToNextFrame(); } void RenderingX::OnDestroy() { // Ensure that the GPU is no longer referencing resources that are about to be // cleaned up by the destructor. WaitForGpu(); CloseHandle(m_fenceEvent); } void RenderingX::OnWindowSizeChanged(int width, int height) { if (!Win32Application::GetHwnd()) { throw std::exception("Call SetWindow with a valid Win32 window handle"); } // Wait until all previous GPU work is complete. WaitForGpu(); // Release resources that are tied to the swap chain and update fence values. for (auto n = 0u; n < FrameCount; ++n) { m_renderTargets[n] = RenderTarget(); m_fenceValues[n] = m_fenceValues[m_frameIndex]; } m_descriptorTableCache->ResetDescriptorPool(CBV_SRV_UAV_POOL, Postprocess::RESIZABLE_POOL); m_descriptorTableCache->ResetDescriptorPool(RTV_POOL, Postprocess::RESIZABLE_POOL); // Determine the render target size in pixels. m_width = (max)(width, 1); m_height = (max)(height, 1); // If the swap chain already exists, resize it, otherwise create one. if (m_swapChain) { // If the swap chain already exists, resize it. const auto hr = m_swapChain->ResizeBuffers(FrameCount, m_width, m_height, DXGI_FORMAT_B8G8R8A8_UNORM, 0); if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET) { #ifdef _DEBUG char buff[64] = {}; sprintf_s(buff, "Device Lost on ResizeBuffers: Reason code 0x%08X\n", (hr == DXGI_ERROR_DEVICE_REMOVED) ? m_device->GetDeviceRemovedReason() : hr); OutputDebugStringA(buff); #endif // If the device was removed for any reason, a new device and swap chain will need to be created. //HandleDeviceLost(); // Everything is set up now. Do not continue execution of this method. HandleDeviceLost will reenter this method // and correctly set up the new device. return; } else { ThrowIfFailed(hr); } } else CreateSwapchain(); // Reset the index to the current back buffer. m_frameIndex = m_swapChain->GetCurrentBackBufferIndex(); // Create window size dependent resources. CreateResources(); ResizeAssets(); // Projection { const auto aspectRatio = m_width / static_cast<float>(m_height); const auto proj = XMMatrixPerspectiveFovLH(g_FOVAngleY, aspectRatio, g_zNear, g_zFar); XMStoreFloat4x4(&m_proj, proj); } } // User hot-key interactions. void RenderingX::OnKeyUp(uint8_t key) { switch (key) { case 0x20: // case VK_SPACE: m_isPaused = !m_isPaused; break; } } // User camera interactions. void RenderingX::OnLButtonDown(float posX, float posY) { m_isTracking = true; m_mousePt = XMFLOAT2(posX, posY); } void RenderingX::OnLButtonUp(float posX, float posY) { m_isTracking = false; } void RenderingX::OnMouseMove(float posX, float posY) { if (m_isTracking) { const XMFLOAT2 dPos(m_mousePt.x - posX, m_mousePt.y - posY); const XMFLOAT2 radians(XM_2PI * dPos.y / m_height, XM_2PI * dPos.x / m_width); const auto focusPt = m_scene->GetFocusAndDistance(); auto eyePt = XMLoadFloat3(&m_eyePt); const auto len = XMVectorGetX(XMVector3Length(focusPt - eyePt)); auto transform = XMMatrixTranslation(0.0f, 0.0f, -len); transform *= XMMatrixRotationRollPitchYaw(radians.x, radians.y, 0.0f); transform *= XMMatrixTranslation(0.0f, 0.0f, len); const auto view = XMLoadFloat4x4(&m_view) * transform; const auto viewInv = XMMatrixInverse(nullptr, view); eyePt = viewInv.r[3]; XMStoreFloat3(&m_eyePt, eyePt); XMStoreFloat4x4(&m_view, view); m_mousePt = XMFLOAT2(posX, posY); } } void RenderingX::OnMouseWheel(float deltaZ, float posX, float posY) { const auto focusPt = m_scene->GetFocusAndDistance(); auto eyePt = XMLoadFloat3(&m_eyePt); const auto len = XMVectorGetX(XMVector3Length(focusPt - eyePt)); const auto transform = XMMatrixTranslation(0.0f, 0.0f, -len * deltaZ / 16.0f); const auto view = XMLoadFloat4x4(&m_view) * transform; const auto viewInv = XMMatrixInverse(nullptr, view); eyePt = viewInv.r[3]; XMStoreFloat3(&m_eyePt, eyePt); XMStoreFloat4x4(&m_view, view); } void RenderingX::OnMouseLeave() { m_isTracking = false; } void RenderingX::ParseCommandLineArgs(wchar_t* argv[], int argc) { DXFramework::ParseCommandLineArgs(argv, argc); auto specifyWindowSize = 0; for (auto i = 1; i < argc; ++i) { if (_wcsnicmp(argv[i], L"-scene", wcslen(argv[i])) == 0 || _wcsnicmp(argv[i], L"/scene", wcslen(argv[i])) == 0 && i + 1 < argc) m_sceneFile = argv[i + 1]; else if ((_wcsnicmp(argv[i], L"-width", wcslen(argv[i])) == 0 || _wcsnicmp(argv[i], L"/width", wcslen(argv[i])) == 0 || _wcsnicmp(argv[i], L"-w", wcslen(argv[i])) == 0 || _wcsnicmp(argv[i], L"/w", wcslen(argv[i])) == 0) && i + 1 < argc) specifyWindowSize = swscanf_s(argv[i + 1], L"%u", &m_width); else if ((_wcsnicmp(argv[i], L"-height", wcslen(argv[i])) == 0 || _wcsnicmp(argv[i], L"/height", wcslen(argv[i])) == 0 || _wcsnicmp(argv[i], L"-h", wcslen(argv[i])) == 0 || _wcsnicmp(argv[i], L"/h", wcslen(argv[i])) == 0) && i + 1 < argc) specifyWindowSize = swscanf_s(argv[i + 1], L"%u", &m_height); else if (_wcsnicmp(argv[i], L"-noIBL", wcslen(argv[i])) == 0 || _wcsnicmp(argv[i], L"/noIBL", wcslen(argv[i])) == 0) m_useIBL = false; } } void RenderingX::PopulateCommandList() { // Command list allocators can only be reset when the associated // command lists have finished execution on the GPU; apps should use // fences to determine GPU execution progress. ThrowIfFailed(m_commandAllocators[m_frameIndex]->Reset()); // However, when ExecuteCommandList() is called on a particular command // list, that command list can then be reset at any time and must be before // re-recording. ThrowIfFailed(m_commandList.Reset(m_commandAllocators[m_frameIndex], nullptr)); // Record commands. //const float clearColor[] = { 0.0f, 0.2f, 0.4f, 1.0f }; //m_commandList.ClearRenderTargetView(m_renderTargets[m_frameIndex].GetRTV(), clearColor); m_scene->Render(m_commandList); ResourceBarrier barriers[2]; #if POST_PROCESS // Postprocessing m_postprocess->Render(m_commandList, m_rtLDR, m_rtHDR, m_rtLDR.GetRTV(), m_srvTables[SRV_HDR]); // Temporal AA auto numBarriers = m_rtTAAs[m_frameParity].SetBarrier(barriers, ResourceState::RENDER_TARGET); numBarriers = m_rtLDR.SetBarrier(barriers, ResourceState::PIXEL_SHADER_RESOURCE, numBarriers); m_commandList.Barrier(numBarriers, barriers); m_postprocess->Antialias(m_commandList, &m_rtTAAs[m_frameParity].GetRTV(), m_srvTables[SRV_AA_INPUT + m_frameParity]); // Unsharp numBarriers = m_renderTargets[m_frameIndex].SetBarrier(barriers, ResourceState::RENDER_TARGET); numBarriers = m_rtTAAs[m_frameParity].SetBarrier(barriers, ResourceState::PIXEL_SHADER_RESOURCE, numBarriers); m_commandList.Barrier(numBarriers, barriers); m_postprocess->Unsharp(m_commandList, &m_renderTargets[m_frameIndex].GetRTV(), m_srvTables[SRV_ANTIALIASED + m_frameParity]); m_frameParity = !m_frameParity; #else auto numBarriers = m_rtHDR.SetBarrier(barriers, ResourceState::PIXEL_SHADER_RESOURCE); numBarriers = m_renderTargets[m_frameIndex].SetBarrier(barriers, ResourceState::RENDER_TARGET, numBarriers); m_commandList.Barrier(numBarriers, barriers); m_commandList.OMSetRenderTargets(1, m_rtvTables[RTV_SWC + m_frameIndex], nullptr); m_commandList.SetGraphicsPipelineLayout(m_pipelineLayout); m_commandList.SetGraphicsDescriptorTable(0, m_srvTables[SRV_HDR]); m_commandList.SetPipelineState(m_pipeline); m_commandList.IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); m_commandList.Draw(3, 1, 0, 0); #endif // Indicate that the back buffer will now be used to present. numBarriers = m_renderTargets[m_frameIndex].SetBarrier(barriers, ResourceState::PRESENT); m_commandList.Barrier(numBarriers, barriers); ThrowIfFailed(m_commandList.Close()); } // Wait for pending GPU work to complete. void RenderingX::WaitForGpu() { // Schedule a Signal command in the queue. ThrowIfFailed(m_commandQueue->Signal(m_fence.get(), m_fenceValues[m_frameIndex])); // Wait until the fence has been processed, and increment the fence value for the current frame. ThrowIfFailed(m_fence->SetEventOnCompletion(m_fenceValues[m_frameIndex]++, m_fenceEvent)); WaitForSingleObjectEx(m_fenceEvent, INFINITE, FALSE); } // Prepare to render the next frame. void RenderingX::MoveToNextFrame() { // Schedule a Signal command in the queue. const auto currentFenceValue = m_fenceValues[m_frameIndex]; ThrowIfFailed(m_commandQueue->Signal(m_fence.get(), currentFenceValue)); // Update the frame index. m_frameIndex = m_swapChain->GetCurrentBackBufferIndex(); // If the next frame is not ready to be rendered yet, wait until it is ready. if (m_fence->GetCompletedValue() < m_fenceValues[m_frameIndex]) { ThrowIfFailed(m_fence->SetEventOnCompletion(m_fenceValues[m_frameIndex], m_fenceEvent)); WaitForSingleObjectEx(m_fenceEvent, INFINITE, FALSE); } // Set the fence value for the next frame. m_fenceValues[m_frameIndex] = currentFenceValue + 1; } double RenderingX::CalculateFrameStats(float* pTimeStep) { static int frameCnt = 0; static double elapsedTime = 0.0; static double previousTime = 0.0; const auto totalTime = m_timer.GetTotalSeconds(); ++frameCnt; const auto timeStep = static_cast<float>(totalTime - elapsedTime); // Compute averages over one second period. if ((totalTime - elapsedTime) >= 1.0f) { float fps = static_cast<float>(frameCnt) / timeStep; // Normalize to an exact second. frameCnt = 0; elapsedTime = totalTime; wstringstream windowText; windowText << setprecision(2) << fixed << L" fps: " << fps; SetCustomWindowText(windowText.str().c_str()); } if (pTimeStep)* pTimeStep = static_cast<float>(totalTime - previousTime); previousTime = totalTime; return totalTime; }
[ "TianchenX@outlook.com" ]
TianchenX@outlook.com
e8021b4901442bfe7a6a45ab407c60dd278da84e
0b0fd394fceccefd6a36d0eaad5909dda85e9f68
/Amber/GameObject.h
c7d2d7cf63158be39e16da6ea4fda20896a8fec7
[]
no_license
mikolaj1310/Amber
68c4806e7d60663ad855688e74ba6a0ae7f89107
a96cb945bca81463173b33c65f691339f117ab7e
refs/heads/master
2022-12-08T06:14:09.493910
2020-08-31T02:04:33
2020-08-31T02:04:33
291,526,340
0
0
null
null
null
null
UTF-8
C++
false
false
1,367
h
#pragma once #include "SFML\Graphics.hpp" #include "Input.h" #include "Renderer.h" enum ObjectType { PLAYER, GROUND, CUBE, }; class GameObject : public sf::RectangleShape { public: GameObject(); ~GameObject(); virtual void update(float dt); // sprite speed and direction void setVelocity(sf::Vector2f vel); void setVelocity(float vx, float vy); sf::Vector2f getVelocity(); // sprite state void setAlive(bool live) { alive = live; }; bool isAlive() { return alive; }; // for sprite collision std::string isCollider() { return collider; }; void setCollider(std::string b) { collider = b; }; sf::FloatRect getCollisionBox(); void setCollisionBox(float x, float y, float width, float height) { collisionBox = sf::FloatRect(x, y, width, height); }; void setCollisionBox(sf::FloatRect fr) { collisionBox = fr; }; virtual void collisionResponse(GameObject* sp); void setType(ObjectType type) { objectType = type; }; enum ObjectType getType() { return objectType; }; void updateFromSimulation(const b2Body* body); // input component void setInput(Input* in) { input = in; }; protected: // Sprite properties sf::Vector2f velocity; bool alive; std::string name; ObjectType objectType; float angle; sf::Vector2f translation; // Collision vars sf::FloatRect collisionBox; std::string collider; // input component Input* input; };
[ "48795346+mikolaj1310@users.noreply.github.com" ]
48795346+mikolaj1310@users.noreply.github.com
8e97e20c8b67a61be0d5ce93cea36cb215ce279d
40ceb3a5941633430ec756197a5762fdeaee6d6b
/libs/blas/funcs/Csrot/Csrot_noincy.cpp
c94bc1a944a463dd8eb320202212898001ecafad
[ "Intel", "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
intel/clGPU
ed63000d09df832ddc0241dfe58e43b1b1b8c337
80907db4513482c29e190bbc20399d638b112fe8
refs/heads/master
2023-08-16T08:06:10.720093
2022-08-04T22:50:52
2022-08-04T22:50:52
121,812,422
65
20
null
null
null
null
UTF-8
C++
false
false
1,866
cpp
// Copyright (c) 2017-2018 Intel Corporation // // 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 "functions/Csrot.hpp" static const char* module_name = "Csrot_noincy"; static const char* kernel_name = "Csrot_noincy"; namespace iclgpu { namespace functions { namespace implementations { bool Csrot_noincy::accept(const Csrot::params& params, Csrot::score& score) { if (params.incx != 1 && params.incy == 1) { score.incx = 1.25f; score.incy = 1.25f; return true; } return false; } event Csrot_noincy::execute(const Csrot::params& params, const std::vector<event>& dep_events) { auto engine = context()->get_engine(); auto kernel = engine->get_kernel(kernel_name, module_name); auto x_buf_size = params.n * params.incx; auto y_buf_size = params.n; auto buf_x = engine->get_inout_buffer(params.x, x_buf_size); kernel->set_arg(0, buf_x); kernel->set_arg(1, params.incx); auto buf_y = engine->get_inout_buffer(params.y, y_buf_size); kernel->set_arg(2, buf_y); kernel->set_arg(3, params.c); kernel->set_arg(4, params.s); auto gws = nd_range(params.n); auto lws = null_range; auto options = kernel_options(gws, lws); kernel->set_options(options); return kernel->submit(dep_events); } } } } // namespace iclgpu::functions::implementations
[ "rafik.f.saliev@intel.com" ]
rafik.f.saliev@intel.com
a80eb676e57d3078459292438d5bddac3d48e5a9
9b30032b0c5becd6fb4094203f29f2e54e33680a
/Cnm%p递推.cpp
08a2dcd559805ba1f693762adacfe05ebb24dae1
[]
no_license
RainyDay7/Algorithm
10b887e0ea765d418220bfc2665e65c13f4b9cca
a234aeed342aeb240db59ef4a0f8f280d597ca89
refs/heads/master
2020-09-04T06:55:52.691492
2020-04-12T10:25:56
2020-04-12T10:25:56
219,680,269
0
0
null
null
null
null
GB18030
C++
false
false
527
cpp
//求Cnm % p //通过递推公示计算,算法可以支持m<=n<=1000的情况,p的大小没有额外限制 int res[1010][1010] = {0}; int C(int n, int m, int p){ if(m==0 ||m==n)return 1; if(res[n][m]!=0) return res[n][m]; return res[n][m] = (C(n-1,m)+C(n-1,m-1)%p); } void calC(){ for(int i=0; i<=n; i++){ res[i][0] = res[i][i] = 1;//初始化边界 } for(int i=2; i<=n; i++){ for(int j=1; j<=n/2; j++){ res[i][j] = (res[i-1][j-1]+res[i-1][j]%p; res[i][i-j] = res[i][j]; } } }
[ "1764682836@qq.com" ]
1764682836@qq.com
1ac0f1f287a0c150bfc17f636e7c4ce71a8f8ec2
08efd3804656dbe81d06fdc6d12f5a46ee7c8ecf
/MainServer/PK/PKSvcSS.h
34b452af5209278710fc917bee5bd3f4ec0865dc
[]
no_license
zhoushx1018/appsvrsrc.20110713
54f96cec5464b2e1651dd3eeb51e0e76d85374a5
f49eda9d6b385a4f7f6b96fc5e0a16f09e122c42
refs/heads/master
2021-01-25T07:40:18.939910
2012-05-16T01:27:03
2012-05-16T01:27:03
4,342,434
2
1
null
null
null
null
GB18030
C++
false
false
1,904
h
// S_S 业务处理 pk // #ifndef PKSVCSS_H #define PKSVCSS_H #include "SSServer.h" #include "ConnectionPool.h" #include <list> #include "List.h" #include "ArchvPK.h" #include "ArchvMap.h" class MainSvc; class ArchvPKEndInfo; class ArchvCreatureStatus; class ArchvPKReward; class PKEndInfo; class PKSvcSS { public: PKSvcSS(MainSvc * mainSvc, ConnectionPool *cp ); ~PKSvcSS(); void OnProcessPacket(Session& session,Packet& packet); protected: void ClientErrorAck(Session& session, Packet& packet, UInt32 RetCode); //------------S_S 交易----------------------------------------- //msgtype 201 pk结束 void ProcessPKEnd(Session& session,Packet& packet); void UpdateThedurability(list<RoleEquipToPk> roletype);//更新耐久度 void UpdatePet(list<PetInfoToPk> petinfo);//变化的Hp,MP //pk胜利方角色是否是 vip,返回1 是,0 不是 int VipExtraExpAndMoney(UInt32 roleID,UInt32 &Exp,UInt32 &Money,List<VipRole>licRoleVip); //------------子业务处理 ----------------------------------------- private: void DealKillMonsterTask( list<UInt32>& roleID,UInt32 creaturetype,UInt32 num); void GetInfoFromPkEnd2( List<ArchvPKEndInfo>& lei, List<ArchvCreatureStatus>& lcs, list<PKEndInfo>& lpkei ,UInt32 mapID,UInt32 pkID); void GetInfoFromPkEnd1( List<ArchvPKEndInfo>& lei,List<ArchvCreatureStatus>& lcs,list<PKEndInfo>& lpkei,UInt32 mapID,UInt32 pkID); void GetItemFromPkEnd(list<UInt32>& roleIDs,List<ArchvPKEndInfo>& lei,list<SenceMonster>& monsters,list<PKEndInfo>& lpkei,UInt32 mapID); void AddExpByExpRune(List<ArchvPKEndInfo>::iterator & itor, PKEndInfo & lrpk); UInt32 findtheLev(list<RoleInfopk>& lis,UInt32 roleID); void SetPetHPMPFullAfterPk(int petID); void WinPetAddExp(const list<UInt32> &winPets, const list<PKEndInfo> &lpkei); void PetAddExp(int petID, int exp, int maxLevel); private: MainSvc * _mainSvc; ConnectionPool *_cp; }; #endif
[ "zhoushx1018@gmail.com" ]
zhoushx1018@gmail.com
f1579d7d7d915efef25335f1d2712232d900752c
03b354385e5ea77e16d563acc6933d2d09bb59c9
/src/zimg/common/x86/avx2_util.h
7ea9551e911fcfb76e37ea104b0e9c4dc9ecd903
[ "WTFPL" ]
permissive
sekrit-twc/zimg
4588c673a7ec6d0a6dea271c157ffda5e996c658
71431815950664f1e11b9ee4e5d4ba23d6d997f1
refs/heads/master
2023-08-04T10:15:09.605309
2023-07-26T01:19:51
2023-07-26T01:20:12
23,723,043
366
82
WTFPL
2023-07-24T14:31:08
2014-09-06T00:53:50
C++
UTF-8
C++
false
false
4,280
h
#pragma once #ifdef ZIMG_X86 #ifndef ZIMG_X86_AVX2_UTIL_H_ #define ZIMG_X86_AVX2_UTIL_H_ #include "common/ccdep.h" #include "x86util.h" namespace zimg { namespace _avx2 { // Transpose two 8x8 matrices stored in the lower and upper 128-bit lanes of [row0]-[row7]. static inline FORCE_INLINE void mm256_transpose8_x2_epi16(__m256i &row0, __m256i &row1, __m256i &row2, __m256i &row3, __m256i &row4, __m256i &row5, __m256i &row6, __m256i &row7) { __m256i t0, t1, t2, t3, t4, t5, t6, t7; __m256i tt0, tt1, tt2, tt3, tt4, tt5, tt6, tt7; t0 = _mm256_unpacklo_epi16(row0, row1); t1 = _mm256_unpacklo_epi16(row2, row3); t2 = _mm256_unpacklo_epi16(row4, row5); t3 = _mm256_unpacklo_epi16(row6, row7); t4 = _mm256_unpackhi_epi16(row0, row1); t5 = _mm256_unpackhi_epi16(row2, row3); t6 = _mm256_unpackhi_epi16(row4, row5); t7 = _mm256_unpackhi_epi16(row6, row7); tt0 = _mm256_unpacklo_epi32(t0, t1); tt1 = _mm256_unpackhi_epi32(t0, t1); tt2 = _mm256_unpacklo_epi32(t2, t3); tt3 = _mm256_unpackhi_epi32(t2, t3); tt4 = _mm256_unpacklo_epi32(t4, t5); tt5 = _mm256_unpackhi_epi32(t4, t5); tt6 = _mm256_unpacklo_epi32(t6, t7); tt7 = _mm256_unpackhi_epi32(t6, t7); row0 = _mm256_unpacklo_epi64(tt0, tt2); row1 = _mm256_unpackhi_epi64(tt0, tt2); row2 = _mm256_unpacklo_epi64(tt1, tt3); row3 = _mm256_unpackhi_epi64(tt1, tt3); row4 = _mm256_unpacklo_epi64(tt4, tt6); row5 = _mm256_unpackhi_epi64(tt4, tt6); row6 = _mm256_unpacklo_epi64(tt5, tt7); row7 = _mm256_unpackhi_epi64(tt5, tt7); } // Exchange the upper 128-bit lane of [row0] with the lower 128-bit lane of [row1]. static inline FORCE_INLINE void mm256_exchange_lanes_si128(__m256i &row0, __m256i &row1) { __m256i tmp0 = _mm256_permute2f128_si256(row0, row1, 0x20); __m256i tmp1 = _mm256_permute2f128_si256(row0, row1, 0x31); row0 = tmp0; row1 = tmp1; } } // namespace _avx2 // Store from [x] into [dst] the 8-bit elements with index less than [idx]. static inline FORCE_INLINE void mm256_store_idxlo_epi8(__m256i *dst, __m256i x, unsigned idx) { __m256i orig = _mm256_load_si256(dst); __m256i mask = _mm256_load_si256((const __m256i *)(&ymm_mask_table[idx])); x = _mm256_blendv_epi8(orig, x, mask); _mm256_store_si256(dst, x); } // Store from [x] into [dst] the 8-bit elements with index greater than or equal to [idx]. static inline FORCE_INLINE void mm256_store_idxhi_epi8(__m256i *dst, __m256i x, unsigned idx) { __m256i orig = _mm256_load_si256(dst); __m256i mask = _mm256_load_si256((const __m256i *)(&ymm_mask_table[idx])); x = _mm256_blendv_epi8(x, orig, mask); _mm256_store_si256(dst, x); } // Store from [x] into [dst] the 16-bit elements with index less than [idx]. static inline FORCE_INLINE void mm256_store_idxlo_epi16(__m256i *dst, __m256i x, unsigned idx) { mm256_store_idxlo_epi8(dst, x, idx * 2); } // Store from [x] into [dst] the 16-bit elements with index greater than or equal to [idx]. static inline FORCE_INLINE void mm256_store_idxhi_epi16(__m256i *dst, __m256i x, unsigned idx) { mm256_store_idxhi_epi8(dst, x, idx * 2); } // Transpose in-place the 16x16 matrix stored in [row0]-[row15]. static inline FORCE_INLINE void mm256_transpose16_epi16(__m256i &row0, __m256i &row1, __m256i &row2, __m256i &row3, __m256i &row4, __m256i &row5, __m256i &row6, __m256i &row7, __m256i &row8, __m256i &row9, __m256i &row10, __m256i &row11, __m256i &row12, __m256i &row13, __m256i &row14, __m256i &row15) { _avx2::mm256_transpose8_x2_epi16(row0, row1, row2, row3, row4, row5, row6, row7); _avx2::mm256_transpose8_x2_epi16(row8, row9, row10, row11, row12, row13, row14, row15); _avx2::mm256_exchange_lanes_si128(row0, row8); _avx2::mm256_exchange_lanes_si128(row1, row9); _avx2::mm256_exchange_lanes_si128(row2, row10); _avx2::mm256_exchange_lanes_si128(row3, row11); _avx2::mm256_exchange_lanes_si128(row4, row12); _avx2::mm256_exchange_lanes_si128(row5, row13); _avx2::mm256_exchange_lanes_si128(row6, row14); _avx2::mm256_exchange_lanes_si128(row7, row15); } } // namespace zimg #endif // ZIMG_X86_AVX2_UTIL_H_ #endif // ZIMG_X86
[ "noreply@example.com" ]
noreply@example.com
6c364e41844784fb2817c496db017fd687a383d4
4d3400c2ead58e8fc2b25f685c1dbb7a9ce139ff
/service/type-analysis/LocalTypeAnalyzer.cpp
46eca524593bb882120d7c46a05a5ae6f94fca99
[ "MIT" ]
permissive
shining1984/redex
d05ce218c12be191a9b07073164bf1bbc4a24167
bca8ac9e96068ff84ab2a4c53595f7e53b31ec91
refs/heads/master
2022-11-27T22:51:39.059695
2020-08-05T20:22:03
2020-08-05T20:23:36
285,579,899
1
0
MIT
2020-08-06T13:33:12
2020-08-06T13:33:11
null
UTF-8
C++
false
false
11,812
cpp
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #include "LocalTypeAnalyzer.h" #include <ostream> #include <sstream> #include "Resolver.h" using namespace type_analyzer; namespace type_analyzer { namespace local { void traceEnvironment(DexTypeEnvironment* env) { std::ostringstream out; out << *env; TRACE(TYPE, 9, "%s", out.str().c_str()); } void LocalTypeAnalyzer::analyze_instruction(const IRInstruction* insn, DexTypeEnvironment* env) const { TRACE(TYPE, 9, "Analyzing instruction: %s", SHOW(insn)); m_insn_analyzer(insn, env); if (traceEnabled(TYPE, 9)) { traceEnvironment(env); } } bool RegisterTypeAnalyzer::analyze_default(const IRInstruction* insn, DexTypeEnvironment* env) { if (opcode::is_load_param(insn->opcode())) { return true; } if (insn->has_dest()) { env->set(insn->dest(), DexTypeDomain::top()); if (insn->dest_is_wide()) { env->set(insn->dest() + 1, DexTypeDomain::top()); } } else if (insn->has_move_result_any()) { env->set(RESULT_REGISTER, DexTypeDomain::top()); } return true; } bool RegisterTypeAnalyzer::analyze_const(const IRInstruction* insn, DexTypeEnvironment* env) { if (insn->opcode() != OPCODE_CONST) { return false; } if (insn->get_literal() == 0) { env->set(insn->dest(), DexTypeDomain::null()); } else { env->set(insn->dest(), DexTypeDomain(insn->get_literal())); } return true; } bool RegisterTypeAnalyzer::analyze_const_string(const IRInstruction*, DexTypeEnvironment* env) { env->set(RESULT_REGISTER, DexTypeDomain(type::java_lang_String())); return true; } bool RegisterTypeAnalyzer::analyze_const_class(const IRInstruction*, DexTypeEnvironment* env) { env->set(RESULT_REGISTER, DexTypeDomain(type::java_lang_Class())); return true; } bool RegisterTypeAnalyzer::analyze_aget(const IRInstruction* insn, DexTypeEnvironment* env) { if (insn->opcode() != OPCODE_AGET_OBJECT) { return false; } auto array_type = env->get(insn->src(0)).get_dex_type(); if (!array_type || !*array_type) { env->set(RESULT_REGISTER, DexTypeDomain::top()); return true; } always_assert_log( type::is_array(*array_type), "Wrong array type %s", SHOW(*array_type)); auto idx_opt = env->get(insn->src(1)).get_constant(); auto nullness = env->get(insn->src(0)).get_array_element_nullness(idx_opt); const auto ctype = type::get_array_component_type(*array_type); env->set(RESULT_REGISTER, DexTypeDomain(ctype, nullness.element())); return true; } /* * Only populating array nullness since we don't model array element types. */ bool RegisterTypeAnalyzer::analyze_aput(const IRInstruction* insn, DexTypeEnvironment* env) { if (insn->opcode() != OPCODE_APUT_OBJECT) { return false; } boost::optional<int64_t> idx_opt = env->get(insn->src(2)).get_constant(); auto nullness = env->get(insn->src(0)).get_nullness(); env->mutate_reg_environment([&](RegTypeEnvironment* env) { auto array_reg = insn->src(1); env->update(array_reg, [&](const DexTypeDomain& domain) { auto copy = domain; copy.set_array_element_nullness(idx_opt, nullness); return copy; }); }); return true; } bool RegisterTypeAnalyzer::analyze_array_length(const IRInstruction* insn, DexTypeEnvironment* env) { auto array_nullness = env->get(insn->src(0)).get_array_nullness(); if (array_nullness.is_top()) { env->set(RESULT_REGISTER, DexTypeDomain::top()); return true; } if (auto array_length = array_nullness.get_length()) { env->set(RESULT_REGISTER, DexTypeDomain(*array_length)); } else { env->set(RESULT_REGISTER, DexTypeDomain::top()); } return true; } bool RegisterTypeAnalyzer::analyze_binop_lit(const IRInstruction* insn, DexTypeEnvironment* env) { auto op = insn->opcode(); int32_t lit = insn->get_literal(); auto int_val = env->get(insn->src(0)).get_constant(); boost::optional<int64_t> result = boost::none; if (!int_val) { return analyze_default(insn, env); } bool use_result_reg = false; switch (op) { case OPCODE_ADD_INT_LIT16: case OPCODE_ADD_INT_LIT8: { result = (*int_val) + lit; break; } case OPCODE_RSUB_INT: case OPCODE_RSUB_INT_LIT8: { result = lit - (*int_val); break; } case OPCODE_MUL_INT_LIT16: case OPCODE_MUL_INT_LIT8: { result = (*int_val) * lit; break; } case OPCODE_DIV_INT_LIT16: case OPCODE_DIV_INT_LIT8: { if (lit != 0) { result = (*int_val) / lit; } use_result_reg = true; break; } case OPCODE_REM_INT_LIT16: case OPCODE_REM_INT_LIT8: { if (lit != 0) { result = (*int_val) % lit; } use_result_reg = true; break; } case OPCODE_AND_INT_LIT16: case OPCODE_AND_INT_LIT8: { result = (*int_val) & lit; break; } case OPCODE_OR_INT_LIT16: case OPCODE_OR_INT_LIT8: { result = (*int_val) | lit; break; } case OPCODE_XOR_INT_LIT16: case OPCODE_XOR_INT_LIT8: { result = (*int_val) ^ lit; break; } // as in https://source.android.com/devices/tech/dalvik/dalvik-bytecode // the following operations have the second operand masked. case OPCODE_SHL_INT_LIT8: { uint32_t ucst = *int_val; uint32_t uresult = ucst << (lit & 0x1f); result = (int32_t)uresult; break; } case OPCODE_SHR_INT_LIT8: { result = (*int_val) >> (lit & 0x1f); break; } case OPCODE_USHR_INT_LIT8: { uint32_t ucst = *int_val; // defined in dalvik spec result = ucst >> (lit & 0x1f); break; } default: break; } auto res_dom = DexTypeDomain::top(); if (result != boost::none) { int32_t result32 = (int32_t)(*result & 0xFFFFFFFF); res_dom = DexTypeDomain(result32); } env->set(use_result_reg ? RESULT_REGISTER : insn->dest(), res_dom); return true; } bool RegisterTypeAnalyzer::analyze_binop(const IRInstruction* insn, DexTypeEnvironment* env) { auto op = insn->opcode(); auto int_left = env->get(insn->src(0)).get_constant(); auto int_right = env->get(insn->src(1)).get_constant(); if (!int_left || !int_right) { return analyze_default(insn, env); } boost::optional<int64_t> result = boost::none; bool use_result_reg = false; switch (op) { case OPCODE_ADD_INT: case OPCODE_ADD_LONG: { result = (*int_left) + (*int_right); break; } case OPCODE_SUB_INT: case OPCODE_SUB_LONG: { result = (*int_left) - (*int_right); break; } case OPCODE_MUL_INT: case OPCODE_MUL_LONG: { result = (*int_left) * (*int_right); break; } case OPCODE_DIV_INT: case OPCODE_DIV_LONG: { if ((*int_right) != 0) { result = (*int_left) / (*int_right); } use_result_reg = true; break; } case OPCODE_REM_INT: case OPCODE_REM_LONG: { if ((*int_right) != 0) { result = (*int_left) % (*int_right); } use_result_reg = true; break; } case OPCODE_AND_INT: case OPCODE_AND_LONG: { result = (*int_left) & (*int_right); break; } case OPCODE_OR_INT: case OPCODE_OR_LONG: { result = (*int_left) | (*int_right); break; } case OPCODE_XOR_INT: case OPCODE_XOR_LONG: { result = (*int_left) ^ (*int_right); break; } default: return analyze_default(insn, env); } auto res_dom = DexTypeDomain::top(); if (result != boost::none) { if (opcode::is_binop64(op)) { res_dom = DexTypeDomain(*result); } else { int32_t result32 = (int32_t)(*result & 0xFFFFFFFF); res_dom = DexTypeDomain(result32); } } env->set(use_result_reg ? RESULT_REGISTER : insn->dest(), res_dom); return true; } bool RegisterTypeAnalyzer::analyze_move(const IRInstruction* insn, DexTypeEnvironment* env) { env->set(insn->dest(), env->get(insn->src(0))); return true; } bool RegisterTypeAnalyzer::analyze_move_result(const IRInstruction* insn, DexTypeEnvironment* env) { env->set(insn->dest(), env->get(RESULT_REGISTER)); return true; } bool RegisterTypeAnalyzer::analyze_move_exception(const IRInstruction* insn, DexTypeEnvironment* env) { // We don't know where to grab the type of the just-caught exception. // Simply set to j.l.Throwable here. env->set(insn->dest(), DexTypeDomain(type::java_lang_Throwable())); return true; } bool RegisterTypeAnalyzer::analyze_new_instance(const IRInstruction* insn, DexTypeEnvironment* env) { env->set(RESULT_REGISTER, DexTypeDomain(insn->get_type())); return true; } bool RegisterTypeAnalyzer::analyze_new_array(const IRInstruction* insn, DexTypeEnvironment* env) { auto length_opt = env->get(insn->src(0)).get_constant(); // If length is missing, drop array nullness. if (!ArrayNullnessDomain::is_valid_array_size(length_opt)) { env->set(RESULT_REGISTER, DexTypeDomain(insn->get_type())); } else { env->set(RESULT_REGISTER, DexTypeDomain(insn->get_type(), *length_opt)); } return true; } bool RegisterTypeAnalyzer::analyze_filled_new_array(const IRInstruction* insn, DexTypeEnvironment* env) { // TODO(zwei): proper array nullness domain population. env->set(RESULT_REGISTER, DexTypeDomain(insn->get_type(), 0)); return true; } namespace { bool field_get_helper(const DexType* class_under_init, const IRInstruction* insn, DexTypeEnvironment* env) { auto field = resolve_field(insn->get_field()); if (field == nullptr) { return false; } if (field->get_class() == class_under_init) { env->set(RESULT_REGISTER, env->get(field)); return true; } return false; } bool field_put_helper(const DexType* class_under_init, const IRInstruction* insn, DexTypeEnvironment* env) { auto field = resolve_field(insn->get_field()); if (field == nullptr) { return false; } if (field->get_class() == class_under_init) { env->set(field, env->get(insn->src(0))); return true; } return false; } } // namespace bool ClinitFieldAnalyzer::analyze_sget(const DexType* class_under_init, const IRInstruction* insn, DexTypeEnvironment* env) { return field_get_helper(class_under_init, insn, env); } bool ClinitFieldAnalyzer::analyze_sput(const DexType* class_under_init, const IRInstruction* insn, DexTypeEnvironment* env) { return field_put_helper(class_under_init, insn, env); } bool CtorFieldAnalyzer::analyze_iget(const DexType* class_under_init, const IRInstruction* insn, DexTypeEnvironment* env) { return field_get_helper(class_under_init, insn, env); } bool CtorFieldAnalyzer::analyze_iput(const DexType* class_under_init, const IRInstruction* insn, DexTypeEnvironment* env) { return field_put_helper(class_under_init, insn, env); } } // namespace local } // namespace type_analyzer
[ "facebook-github-bot@users.noreply.github.com" ]
facebook-github-bot@users.noreply.github.com
6d849763f2b42050b3ba9912a2d4af474ba8f734
45c59e5f456f11f1714b2ddf976b62dfebecfa7d
/Case19/system/decomposeParDict
59ce8818306eb2631dcf63a724833de6ffa295b6
[]
no_license
JoelWright24/Masters-Thesis-in-OpenFOAM
9224f71cdb38e96a378996996c5c86235db9ee13
b6c420b5054494a26a7d65a34835b27be9e0da4a
refs/heads/main
2023-02-20T17:18:13.067439
2021-01-22T19:30:36
2021-01-22T19:30:36
332,039,823
0
0
null
null
null
null
UTF-8
C++
false
false
1,159
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: dev | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; location "system"; object decomposeParDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // numberOfSubdomains 4; method hierarchical; simpleCoeffs { n (1 4 1); delta 0.001; } hierarchicalCoeffs { n (1 4 1); delta 0.001; order xyz; } manualCoeffs { dataFile "cellDecomposition"; } // ************************************************************************* //
[ "67100764+JoelWright24@users.noreply.github.com" ]
67100764+JoelWright24@users.noreply.github.com
951788fe8b6c8c6e240293800930b84cb574ba93
114cbe28dcb8f77f40dab9e4154c7655500cc51e
/src/tasks/export/modules/IModule.h
97f38937660b15bb7f7d6b9183fcd81609e0381d
[]
no_license
kubasejdak/graph-analyzer
fbd038999bc2957042ced15e59e86cb88ccd5d02
5d4f8841ca938e5c59a4cbc155a24e452e509690
refs/heads/master
2021-06-02T05:12:10.051249
2016-06-21T07:57:05
2016-06-21T07:57:05
61,611,748
1
0
null
null
null
null
UTF-8
C++
false
false
452
h
/* * Filename : IModule.h * Author : Kuba Sejdak * Created on : 21-07-2013 */ #ifndef EXPORT_IMODULE_H_ #define EXPORT_IMODULE_H_ #include <string> namespace Export { class IModule { public: IModule() {} virtual ~IModule() {} std::string name() { return m_name; } std::string description() { return m_description; } protected: std::string m_name; std::string m_description; }; } // namespace Export #endif /* EXPORT_IMODULE_H_ */
[ "kuba.sejdak@gmail.com" ]
kuba.sejdak@gmail.com
4738b9064d8366a22bf2c440a05f02279a76d82a
0a5f86852db40d05437ee238eca235308c25d661
/DXFramework/Texture.cpp
3cab5b5aee702c61c8415eb51cd317cb445d73e1
[]
no_license
happydpc/Ridged-Multifractal-Terrain
2ec1fb301e16ac878d5afa7e1ea898aa485a9334
6d59a1a1fec7672aa62675bd5adf229b598b0dcb
refs/heads/master
2021-10-19T13:50:02.704106
2019-02-21T14:53:18
2019-02-21T14:53:18
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,303
cpp
// texture.cpp #include "texture.h" Texture::Texture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, WCHAR* filename) { HRESULT result; // check if file exists if (!filename) { filename = L"../res/DefaultDiffuse.png"; } // if not set default texture if (!does_file_exist(filename)) { // change default texture filename = L"../res/DefaultDiffuse.png"; } // check file extension for correct loading function. std::wstring fn(filename); std::string::size_type idx; std::wstring extension; idx = fn.rfind('.'); if (idx != std::string::npos) { extension = fn.substr(idx + 1); } else { // No extension found } // Load the texture in. if (extension == L"dds") { result = CreateDDSTextureFromFile(device, deviceContext, filename, NULL, &m_texture, 0, NULL); } else { result = CreateWICTextureFromFile(device, deviceContext, filename, NULL, &m_texture, 0); } if (FAILED(result)) { MessageBox(NULL, L"Texture loading error", L"ERROR", MB_OK); } } Texture::~Texture() { // Release the texture resource. if (m_texture) { m_texture->Release(); m_texture = 0; } } ID3D11ShaderResourceView* Texture::GetTexture() { return m_texture; } bool Texture::does_file_exist(const WCHAR *fname) { std::ifstream infile(fname); return infile.good(); }
[ "cameronmcpherson1996@hotmail.co.uk" ]
cameronmcpherson1996@hotmail.co.uk
d11820722e4f6fcaf429af60af84469ed0c12bfd
2b8d7fae4667577355f9bd987bc35cf277b24100
/Projects/Character/Character_v6/eexam.h
02877f6a74100fe51cf00e041b52420f02d8df65
[]
no_license
Jabonija99/JabonilloJarone_Csc17b_48037
c9af61ee87fd9c7ecde88dda75abd8531b304cfd
92b29e4c8be69a55a250f6021655c650c11495e2
refs/heads/master
2020-07-15T13:15:25.885806
2016-12-16T08:03:01
2016-12-16T08:03:01
67,096,840
0
0
null
null
null
null
UTF-8
C++
false
false
970
h
#ifndef EEXAM_H #define EEXAM_H #include "character.h" #include <cstdlib> //Enemy exam fiend class class eExam : public Character { private: int eExp; //Enemy exp worth public: //Param(player level) //Generates and scales stats based on the player lvl //Character constructor is empty // *Set stats in constructor // *Balance stats as necessary //Calls genInv(player lvl) for item creation eExam(int); //Sets exp worth(exp) //Accept values 0-999 void setExp(int); int getExp(){return eExp;} //Enemy attack functions //Calc/return dmg on character //See character class attack1() as an example int attack1(Character&); int attack2(Character&); //Generates a random number and returns an item based //on the result //Ex) See Char_v5 enemy.dropLoot() Item drop(); }; #endif // EEXAM_H
[ "jabonija99@yahoo.com" ]
jabonija99@yahoo.com
941657247155f9aaaade510186c361346462f507
590efdff6151a3ac070d6be3108ebf2e21f7cce1
/evtbin/Hist1D.h
637c54337ab1e47ce5190f4e95e543ad2f0ad5bc
[ "BSD-3-Clause" ]
permissive
fermi-lat/evtbin
5517fb23ee26524834b4111e8ea47e3448e86de2
f33346478b2fb039b6601997aa71ceaa3f9bbbc7
refs/heads/master
2023-08-31T20:15:32.125703
2022-04-28T02:13:26
2022-04-28T02:13:26
103,186,979
0
0
BSD-3-Clause
2020-04-20T21:41:11
2017-09-11T20:52:16
C++
UTF-8
C++
false
false
1,643
h
/** \file Hist1D.h \brief One dimensional histogram. */ #ifndef evtbin_Hist1D_h #define evtbin_Hist1D_h #include <vector> #include "evtbin/Hist.h" namespace evtbin { class Binner; /** \class Hist1D \brief One dimensional histogram. */ class Hist1D : public Hist { public: typedef std::vector<double> Cont_t; typedef Cont_t::const_iterator ConstIterator; /** \brief Create a one dimensional histogram which uses the given binner object: \param binner The binner object to use when filling bins. */ Hist1D(const Binner & binner); virtual ~Hist1D() throw(); /** \brief Increment the bin appropriate for the given value. This is generic for N-dimensional histograms. \param value Vector giving the value being binned. The vector must have at least as many values as the dimensionality of the histogram. */ virtual void fillBin(const std::vector<double> & value, double weight = 1.); /** \brief Increment the bin appropriate for the given value. \param value The value being binned. */ void fillBin(double value, double weight = 1.); const double & operator [](Cont_t::size_type index) const; ConstIterator begin() const; ConstIterator end() const; private: Cont_t m_data; }; inline const double & Hist1D::operator [](Cont_t::size_type index) const { return m_data[index]; } inline Hist1D::ConstIterator Hist1D::begin() const { return m_data.begin(); } inline Hist1D::ConstIterator Hist1D::end() const { return m_data.end(); } } #endif
[ "" ]
2a3eb3d3a1f73e7b869a54fba2088ab8dbbd359d
d96607cdf79c4f3818788cfe2bef9888a49d56a8
/Web Servers and APIs using C++/Chapter_3/crow_volume/main.cpp
7a2c829cd417f2ed6427064056c5fad599c82e29
[]
no_license
dasanchez/hellocpp
41646533ee826e59841b25961b5ff6dc93b3487d
3b37c21d4f864686ba0c5fe60f4939ea06d91cda
refs/heads/master
2021-06-02T08:56:46.201450
2020-09-28T03:16:20
2020-09-28T03:16:20
126,009,535
0
0
null
2018-08-12T21:02:20
2018-03-20T11:51:02
C++
UTF-8
C++
false
false
1,874
cpp
#include "crow_all.h" using namespace std; using namespace crow; void sendFile(response &res, string filename, string contentType) { ifstream in("../public/" + filename, ifstream::in); // cout << "INSIDE CROW ROUTE" << endl; if(in) { ostringstream contents; contents << in.rdbuf(); in.close(); res.set_header("Content-Type", contentType); res.write(contents.str()); } else { res.code = 404; res.write("FILE NOT FOUND!"); } res.end(); } void sendHtml(response &res, string filename) { sendFile(res, filename + ".html", "text/html"); } void sendImage(response &res, string filename) { sendFile(res, "images/" + filename, "image/jpeg"); } void sendScript(response &res, string filename) { sendFile(res, "scripts/" + filename, "text/javascript"); } void sendStyle(response &res, string filename) { sendFile(res, "styles/" + filename, "text/css"); } int main(int argc, char* argv[]) { SimpleApp app; CROW_ROUTE(app, "/styles/<string>") ([](const request &req, response &res, string filename){ sendStyle(res, filename); }); CROW_ROUTE(app, "/scripts/<string>") ([](const request &req, response &res, string filename){ sendScript(res, filename); }); CROW_ROUTE(app, "/images/<string>") ([](const request &req, response &res, string filename){ sendImage(res, filename); }); CROW_ROUTE(app, "/") ([](const request &req, response &res){ sendHtml(res, "index"); }); CROW_ROUTE(app, "/<string>") ([](const request &req, response &res, string filename){ sendHtml(res, filename); }); char* port = getenv("PORT"); uint16_t iPort = static_cast<uint16_t>(port != NULL ? stoi(port) : 18080); cout << "PORT = " << iPort << "\n"; app.port(iPort).multithreaded().run(); }
[ "dante.a.sanchez@gmail.com" ]
dante.a.sanchez@gmail.com
a58f8d26be46850f3391b3ff3622eb70d46eb0c7
89232783ffc0d62ab9d59635162738823fa67262
/Problems/Topic-specific/AdHoc/SearchingForNessy.cpp
6af7e5cbbced442f36438934765dbf8ccc11fb07
[]
no_license
JCiroR/Competitive-programming
d7987758c863dfa0bc20cc6397c11443005484a1
cd23f48dacd86e5fa0eb50f5b05c06926fec4f02
refs/heads/master
2021-08-19T09:25:17.252574
2020-07-05T23:32:12
2020-07-05T23:32:12
74,248,369
0
0
null
null
null
null
UTF-8
C++
false
false
215
cpp
#include <iostream> using namespace std; int main(void) { int a, b, testCases; cin >> testCases; while(testCases--) { cin >> a >> b; cout << (a/3) * (b/3) << endl; } return 0; }
[ "jcirore@eafit.edu.co" ]
jcirore@eafit.edu.co
20cbc43abfed6c3874a48e228e1fe65541937d7f
70f5f279e051360310f95be895320d8fa6cd8d93
/extraPackages/pyzmq-17.1.2/bundled/zeromq/src/err.cpp
6f545db9275991818ad84d7bd526241c26fdbb61
[ "GPL-3.0-only", "BSD-3-Clause", "LGPL-3.0-only", "LicenseRef-scancode-zeromq-exception-lgpl-3.0" ]
permissive
spacetime314/python3_ios
4b16ab3e81c31213b3db1e1eb00230621b0a7dc8
e149f1bc2e50046c8810f83dae7739a8dea939ee
refs/heads/master
2020-05-09T20:39:14.980041
2019-04-08T15:07:53
2019-04-08T15:07:53
181,415,024
2
0
BSD-3-Clause
2019-04-15T05:00:14
2019-04-15T05:00:12
null
UTF-8
C++
false
false
41,146
cpp
/* Copyright (c) 2007-2016 Contributors as noted in the AUTHORS file This file is part of libzmq, the ZeroMQ core engine in C++. libzmq is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License (LGPL) as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. As a special exception, the Contributors give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you must extend this exception to your version of the library. libzmq is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "precompiled.hpp" #include "err.hpp" const char *zmq::errno_to_string (int errno_) { switch (errno_) { #if defined ZMQ_HAVE_WINDOWS case ENOTSUP: return "Not supported"; case EPROTONOSUPPORT: return "Protocol not supported"; case ENOBUFS: return "No buffer space available"; case ENETDOWN: return "Network is down"; case EADDRINUSE: return "Address in use"; case EADDRNOTAVAIL: return "Address not available"; case ECONNREFUSED: return "Connection refused"; case EINPROGRESS: return "Operation in progress"; #endif case EFSM: return "Operation cannot be accomplished in current state"; case ENOCOMPATPROTO: return "The protocol is not compatible with the socket type"; case ETERM: return "Context was terminated"; case EMTHREAD: return "No thread available"; case EHOSTUNREACH: return "Host unreachable"; default: #if defined _MSC_VER #pragma warning(push) #pragma warning(disable : 4996) #endif return strerror (errno_); #if defined _MSC_VER #pragma warning(pop) #endif } } void zmq::zmq_abort (const char *errmsg_) { #if defined ZMQ_HAVE_WINDOWS // Raise STATUS_FATAL_APP_EXIT. ULONG_PTR extra_info[1]; extra_info[0] = (ULONG_PTR) errmsg_; RaiseException (0x40000015, EXCEPTION_NONCONTINUABLE, 1, extra_info); #else (void) errmsg_; print_backtrace (); abort (); #endif } #ifdef ZMQ_HAVE_WINDOWS const char *zmq::wsa_error () { return wsa_error_no (WSAGetLastError (), NULL); } const char *zmq::wsa_error_no (int no_, const char *wsae_wouldblock_string) { // TODO: It seems that list of Windows socket errors is longer than this. // Investigate whether there's a way to convert it into the string // automatically (wsaError->HRESULT->string?). return (no_ == WSABASEERR) ? "No Error" : (no_ == WSAEINTR) ? "Interrupted system call" : (no_ == WSAEBADF) ? "Bad file number" : (no_ == WSAEACCES) ? "Permission denied" : (no_ == WSAEFAULT) ? "Bad address" : (no_ == WSAEINVAL) ? "Invalid argument" : (no_ == WSAEMFILE) ? "Too many open files" : (no_ == WSAEWOULDBLOCK) ? wsae_wouldblock_string : (no_ == WSAEINPROGRESS) ? "Operation now in progress" : (no_ == WSAEALREADY) ? "Operation already in " "progress" : (no_ == WSAENOTSOCK) ? "Socket operation on " "non-socket" : (no_ == WSAEDESTADDRREQ) ? "Destination " "address required" : (no_ == WSAEMSGSIZE) ? "Message too " "long" : (no_ == WSAEPROTOTYPE) ? "Protocol " "wrong type " "for socket" : (no_ == WSAENOPROTOOPT) ? "Bad " "protoco" "l " "option" : (no_ == WSAEPROTONOSUPPORT) ? "Pro" "toc" "ol " "not" " su" "ppo" "rte" "d" : (no_ == WSAESOCKTNOSUPPORT) ? "Socket type not supported" : (no_ == WSAEOPNOTSUPP) ? "Operation not supported on socket" : (no_ == WSAEPFNOSUPPORT) ? "Protocol family not supported" : (no_ == WSAEAFNOSUPPORT) ? "Address family not supported by protocol family" : (no_ == WSAEADDRINUSE) ? "Address already in use" : (no_ == WSAEADDRNOTAVAIL) ? "Can't assign requested address" : (no_ == WSAENETDOWN) ? "Network is down" : (no_ == WSAENETUNREACH) ? "Network is unreachable" : (no_ == WSAENETRESET) ? "Net dropped connection or reset" : (no_ == WSAECONNABORTED) ? "Software caused connection abort" : (no_ == WSAECONNRESET) ? "Connection reset by peer" : (no_ == WSAENOBUFS) ? "No buffer space available" : (no_ == WSAEISCONN) ? "Socket is already connected" : (no_ == WSAENOTCONN) ? "Socket is not connected" : (no_ == WSAESHUTDOWN) ? "Can't send after socket shutdown" : (no_ == WSAETOOMANYREFS) ? "Too many references can't splice" : (no_ == WSAETIMEDOUT) ? "Connection timed out" : (no_ == WSAECONNREFUSED) ? "Connection refused" : (no_ == WSAELOOP) ? "Too many levels of symbolic links" : (no_ == WSAENAMETOOLONG) ? "File name too long" : (no_ == WSAEHOSTDOWN) ? "Host is down" : (no_ == WSAEHOSTUNREACH) ? "No Route to Host" : (no_ == WSAENOTEMPTY) ? "Directory not empty" : (no_ == WSAEPROCLIM) ? "Too many processes" : ( no_ == WSAEUSERS) ? "Too many users" : (no_ == WSAEDQUOT) ? "Disc Quota Exceeded" : (no_ == WSAESTALE) ? "Stale NFS file handle" : (no_ == WSAEREMOTE) ? "Too many levels of remote in path" : (no_ == WSASYSNOTREADY) ? "Network SubSystem is unavailable" : (no_ == WSAVERNOTSUPPORTED) ? "WINSOCK DLL Version out of range" : (no_ == WSANOTINITIALISED) ? "Successful WSASTARTUP not yet performed" : (no_ == WSAHOST_NOT_FOUND) ? "Host not found" : (no_ == WSATRY_AGAIN) ? "Non-Authoritative Host not found" : (no_ == WSANO_RECOVERY) ? "Non-Recoverable errors: FORMERR REFUSED NOTIMP" : (no_ == WSANO_DATA) ? "Valid name no data record of requested" : "error not defined"; } void zmq::win_error (char *buffer_, size_t buffer_size_) { DWORD errcode = GetLastError (); #if defined _WIN32_WCE DWORD rc = FormatMessageW ( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errcode, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR) buffer_, buffer_size_ / sizeof (wchar_t), NULL); #else DWORD rc = FormatMessageA ( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errcode, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT), buffer_, (DWORD) buffer_size_, NULL); #endif zmq_assert (rc); } int zmq::wsa_error_to_errno (int errcode) { switch (errcode) { // 10004 - Interrupted system call. case WSAEINTR: return EINTR; // 10009 - File handle is not valid. case WSAEBADF: return EBADF; // 10013 - Permission denied. case WSAEACCES: return EACCES; // 10014 - Bad address. case WSAEFAULT: return EFAULT; // 10022 - Invalid argument. case WSAEINVAL: return EINVAL; // 10024 - Too many open files. case WSAEMFILE: return EMFILE; // 10035 - Operation would block. case WSAEWOULDBLOCK: return EBUSY; // 10036 - Operation now in progress. case WSAEINPROGRESS: return EAGAIN; // 10037 - Operation already in progress. case WSAEALREADY: return EAGAIN; // 10038 - Socket operation on non-socket. case WSAENOTSOCK: return ENOTSOCK; // 10039 - Destination address required. case WSAEDESTADDRREQ: return EFAULT; // 10040 - Message too long. case WSAEMSGSIZE: return EMSGSIZE; // 10041 - Protocol wrong type for socket. case WSAEPROTOTYPE: return EFAULT; // 10042 - Bad protocol option. case WSAENOPROTOOPT: return EINVAL; // 10043 - Protocol not supported. case WSAEPROTONOSUPPORT: return EPROTONOSUPPORT; // 10044 - Socket type not supported. case WSAESOCKTNOSUPPORT: return EFAULT; // 10045 - Operation not supported on socket. case WSAEOPNOTSUPP: return EFAULT; // 10046 - Protocol family not supported. case WSAEPFNOSUPPORT: return EPROTONOSUPPORT; // 10047 - Address family not supported by protocol family. case WSAEAFNOSUPPORT: return EAFNOSUPPORT; // 10048 - Address already in use. case WSAEADDRINUSE: return EADDRINUSE; // 10049 - Cannot assign requested address. case WSAEADDRNOTAVAIL: return EADDRNOTAVAIL; // 10050 - Network is down. case WSAENETDOWN: return ENETDOWN; // 10051 - Network is unreachable. case WSAENETUNREACH: return ENETUNREACH; // 10052 - Network dropped connection on reset. case WSAENETRESET: return ENETRESET; // 10053 - Software caused connection abort. case WSAECONNABORTED: return ECONNABORTED; // 10054 - Connection reset by peer. case WSAECONNRESET: return ECONNRESET; // 10055 - No buffer space available. case WSAENOBUFS: return ENOBUFS; // 10056 - Socket is already connected. case WSAEISCONN: return EFAULT; // 10057 - Socket is not connected. case WSAENOTCONN: return ENOTCONN; // 10058 - Can't send after socket shutdown. case WSAESHUTDOWN: return EFAULT; // 10059 - Too many references can't splice. case WSAETOOMANYREFS: return EFAULT; // 10060 - Connection timed out. case WSAETIMEDOUT: return ETIMEDOUT; // 10061 - Connection refused. case WSAECONNREFUSED: return ECONNREFUSED; // 10062 - Too many levels of symbolic links. case WSAELOOP: return EFAULT; // 10063 - File name too long. case WSAENAMETOOLONG: return EFAULT; // 10064 - Host is down. case WSAEHOSTDOWN: return EAGAIN; // 10065 - No route to host. case WSAEHOSTUNREACH: return EHOSTUNREACH; // 10066 - Directory not empty. case WSAENOTEMPTY: return EFAULT; // 10067 - Too many processes. case WSAEPROCLIM: return EFAULT; // 10068 - Too many users. case WSAEUSERS: return EFAULT; // 10069 - Disc Quota Exceeded. case WSAEDQUOT: return EFAULT; // 10070 - Stale NFS file handle. case WSAESTALE: return EFAULT; // 10071 - Too many levels of remote in path. case WSAEREMOTE: return EFAULT; // 10091 - Network SubSystem is unavailable. case WSASYSNOTREADY: return EFAULT; // 10092 - WINSOCK DLL Version out of range. case WSAVERNOTSUPPORTED: return EFAULT; // 10093 - Successful WSASTARTUP not yet performed. case WSANOTINITIALISED: return EFAULT; // 11001 - Host not found. case WSAHOST_NOT_FOUND: return EFAULT; // 11002 - Non-Authoritative Host not found. case WSATRY_AGAIN: return EFAULT; // 11003 - Non-Recoverable errors: FORMERR REFUSED NOTIMP. case WSANO_RECOVERY: return EFAULT; // 11004 - Valid name no data record of requested. case WSANO_DATA: return EFAULT; default: wsa_assert (false); } // Not reachable return 0; } #endif #ifdef HAVE_LIBUNWIND #define UNW_LOCAL_ONLY #include <libunwind.h> #include <dlfcn.h> #include <cxxabi.h> #include "mutex.hpp" void zmq::print_backtrace (void) { static zmq::mutex_t mtx; mtx.lock (); Dl_info dl_info; unw_cursor_t cursor; unw_context_t ctx; unsigned frame_n = 0; unw_getcontext (&ctx); unw_init_local (&cursor, &ctx); while (unw_step (&cursor) > 0) { unw_word_t offset; unw_proc_info_t p_info; const char *file_name; char *demangled_name; char func_name[256] = ""; void *addr; int rc; if (unw_get_proc_info (&cursor, &p_info)) break; rc = unw_get_proc_name (&cursor, func_name, 256, &offset); if (rc == -UNW_ENOINFO) strcpy (func_name, "?"); addr = (void *) (p_info.start_ip + offset); if (dladdr (addr, &dl_info) && dl_info.dli_fname) file_name = dl_info.dli_fname; else file_name = "?"; demangled_name = abi::__cxa_demangle (func_name, NULL, NULL, &rc); printf ("#%u %p in %s (%s+0x%lx)\n", frame_n++, addr, file_name, rc ? func_name : demangled_name, (unsigned long) offset); free (demangled_name); } puts (""); fflush (stdout); mtx.unlock (); } #else void zmq::print_backtrace (void) { } #endif
[ "nicolas.holzschuch@inria.fr" ]
nicolas.holzschuch@inria.fr
738e6d29737d571fc3266f9059beae46162db939
702191129549fb9e28ed327b9eed344218e82496
/Problems/programmers_타겟넘버/programmers_타겟넘버.cpp
43b1776583cf0f458ae6f71b482c818887661d41
[]
no_license
Sunjae95/BOJ-Algorithm-Study
219997490c5098a34e7b9d008070e0799345ac92
8154101bd1c4b2ab0cea957f8bd7594d569cb517
refs/heads/master
2022-12-30T17:47:10.473181
2020-10-20T15:34:11
2020-10-20T15:34:11
null
0
0
null
null
null
null
UHC
C++
false
false
575
cpp
#include <string> #include <vector> using namespace std; int dfs(vector<int>& numbers, int target, int index, int sum, int count) { if (index == numbers.size()) { if (sum == target) { return 1; // 타겟 넘버를 만든 경우 } else { return 0; // 만들지 못한 경우 } } count = dfs(numbers, target, index + 1, sum + numbers[index], count) + dfs(numbers, target, index + 1, sum - numbers[index], count); return count; } int solution(vector<int> numbers, int target) { int answer = 0; answer = dfs(numbers, target, 0, 0, 0); return answer; }
[ "kyu9341@naver.com" ]
kyu9341@naver.com
b913aa5d9474ebc1393ca753d3697511ed072656
12a42054b156383ebbe3ccc5de4150633c66da5d
/problems/palindrome-number/solution.cpp
67159a83be60a761227fc4c86befd0adb1ed47b1
[]
no_license
cfoust/leetcode-problems
93c33029f74f32c64caf8294292226d199d6e272
f5ad7866906d0a2cf2250e5972ce910bf35ce526
refs/heads/master
2020-03-16T23:05:45.123781
2018-05-11T16:41:09
2018-05-11T16:41:09
133,064,772
1
1
null
null
null
null
UTF-8
C++
false
false
78
cpp
class Solution { public: bool isPalindrome(int x) { } };
[ "cfoust@sqweebloid.com" ]
cfoust@sqweebloid.com
27c49184a9c6b22d2beb28f9d8acaeab10e079e6
499a4f2c530023a39ed7a0d2d6077d570c37e651
/SDK/RoCo_SettingsInfo_BrightnessHandheld_classes.hpp
490056782faa3b691fd25cbefeca201f3038aab4
[]
no_license
zH4x/RoCo-SDK
e552653bb513b579ab0b1ea62343365db476f998
6019053276aecca48b75edd58171876570fc6342
refs/heads/master
2023-05-06T20:57:27.585479
2021-05-23T06:44:59
2021-05-23T06:44:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
795
hpp
#pragma once // Rogue Company (0.59) SDK #ifdef _MSC_VER #pragma pack(push, 0x8) #endif #include "RoCo_SettingsInfo_BrightnessHandheld_structs.hpp" namespace SDK { //--------------------------------------------------------------------------- //Classes //--------------------------------------------------------------------------- // BlueprintGeneratedClass SettingsInfo_BrightnessHandheld.SettingsInfo_BrightnessHandheld_C // 0x0000 (0x0108 - 0x0108) class USettingsInfo_BrightnessHandheld_C : public UKSSettingsInfo_Brightness { public: static UClass* StaticClass() { static auto ptr = UObject::FindObject<UClass>(_xor_("BlueprintGeneratedClass SettingsInfo_BrightnessHandheld.SettingsInfo_BrightnessHandheld_C")); return ptr; } }; } #ifdef _MSC_VER #pragma pack(pop) #endif
[ "30532128+pubgsdk@users.noreply.github.com" ]
30532128+pubgsdk@users.noreply.github.com
06726149a210009d547752e4dcb9f34ad405ff78
4c23be1a0ca76f68e7146f7d098e26c2bbfb2650
/ic8h18/0.0045/C3H6O1-3
4021090b4a3129908d87bd8b2025b8a578ea93cc
[]
no_license
labsandy/OpenFOAM_workspace
a74b473903ddbd34b31dc93917e3719bc051e379
6e0193ad9dabd613acf40d6b3ec4c0536c90aed4
refs/heads/master
2022-02-25T02:36:04.164324
2019-08-23T02:27:16
2019-08-23T02:27:16
null
0
0
null
null
null
null
UTF-8
C++
false
false
841
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 6 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "0.0045"; object C3H6O1-3; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 0 0 0 0 0 0]; internalField uniform 3.88603e-07; boundaryField { boundary { type empty; } } // ************************************************************************* //
[ "jfeatherstone123@gmail.com" ]
jfeatherstone123@gmail.com
2f9567ca3947362d589b27e6c8915c159940ec80
33b06320aeef69332daa5474b31b73dfbf790ad9
/Source/FineParticle/mysource/FineParticleEmitter.h
5115271d9d1616bf7bed1db95c3968c947149172
[]
no_license
dearshuto/FineParticleSimulation
5bd287df185cee8b8fc22aeef30fb3011c1fd9cc
c0c5abe430d6b9de70df53ae4c3c673d66ab5e72
refs/heads/master
2021-01-20T19:08:45.227215
2016-10-13T10:22:27
2016-10-13T10:22:27
64,927,366
0
0
null
null
null
null
UTF-8
C++
false
false
1,604
h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "ParticleStaticMeshActor.h" #include "fine_particle/simulation/fine_particle_world.hpp" #include "fine_particle/simulation/particle/particle.hpp" #include "GameFramework/Actor.h" #include "FineParticleEmitter.generated.h" UCLASS() class FINEPARTICLE_API AFineParticleEmitter : public AActor { GENERATED_BODY() public: // Sets default values for this actor's properties AFineParticleEmitter(); // Called when the game starts or when spawned virtual void BeginPlay() override; // Called every frame virtual void Tick( float DeltaSeconds ) override; UFUNCTION(BlueprintCallable, Category = "Actor") void CreateParticle(const FVector& Position); UFUNCTION(BlueprintCallable, Category = "Actor") void Terminate(); public: UFUNCTION(BlueprintCallable, Category = "Actor") void SetSimulationSpringK(const float SimulationSpringK); UFUNCTION(BlueprintCallable, Category = "Actor") void SetDashpodEnvelop(const float DashpodEnvelop); UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Edit") float SimulationTimeStep; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Edit") int SimulationCycle; private: void synchronizeRenderParticlePosition(); TArray<AParticleStaticMeshActor*> m_particles; fj::FineParticleWorld m_world; std::unique_ptr<btCollisionShape> m_plane; std::unique_ptr<btMotionState> m_planeMotionState; std::shared_ptr<fj::Particle::CollapseDetector> m_collapseDetector; };
[ "shuto.shikama@fj.ics.keio.ac.jp" ]
shuto.shikama@fj.ics.keio.ac.jp
ec6e1fd8c30534d5d651f7981be4bbde0f8b96f9
dadaa057480479e3796063c7f0ee03b5d7775642
/5. Cycles/20321040/9. Triangle/9. Triangle.cpp
e2aa12955e375cd3470a0fee89e477c2906ee59d
[ "MIT" ]
permissive
Mitaka01-eng/CS104
8c5f45cd70098d5f06764c022bc03eca52217250
5281b1519e0cf41f314003112a811747a2143bd4
refs/heads/main
2023-03-27T18:14:17.934925
2021-03-30T16:08:47
2021-03-30T16:08:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
181
cpp
#include <iostream> using namespace std; int main() { for (int i = 1; i <= 5; i++) { for (int j = 1; j <= i; j++) { cout << j << " "; } cout << endl; } return 0; }
[ "20321040@students.bfu.bg" ]
20321040@students.bfu.bg
060fb95b3f5e34817494bda8a1a334ab53f484ee
827c12e0820b3326f364438783a528e21c662672
/src/rpcdump.cpp
27a9a00fb8ad591dc5a90a3629253323a9aa03b5
[ "MIT" ]
permissive
samuraisam0/sam
0e3c95ef7db784dda677a40bcceceda77fa29204
b7443416c229ff7223971549068b8672a72fa1cc
refs/heads/master
2021-01-10T03:57:19.496522
2015-09-24T19:06:30
2015-09-24T19:06:30
43,087,097
1
1
null
null
null
null
UTF-8
C++
false
false
10,920
cpp
// Copyright (c) 2009-2012 Bitcoin Developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <iostream> #include <fstream> #include "init.h" // for pwalletMain #include "bitcoinrpc.h" #include "ui_interface.h" #include "base58.h" #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/variant/get.hpp> #include <boost/algorithm/string.hpp> #define printf OutputDebugStringF using namespace json_spirit; using namespace std; void EnsureWalletIsUnlocked(); namespace bt = boost::posix_time; // Extended DecodeDumpTime implementation, see this page for details: // http://stackoverflow.com/questions/3786201/parsing-of-date-time-from-string-boost const std::locale formats[] = { std::locale(std::locale::classic(),new bt::time_input_facet("%Y-%m-%dT%H:%M:%SZ")), std::locale(std::locale::classic(),new bt::time_input_facet("%Y-%m-%d %H:%M:%S")), std::locale(std::locale::classic(),new bt::time_input_facet("%Y/%m/%d %H:%M:%S")), std::locale(std::locale::classic(),new bt::time_input_facet("%d.%m.%Y %H:%M:%S")), std::locale(std::locale::classic(),new bt::time_input_facet("%Y-%m-%d")) }; const size_t formats_n = sizeof(formats)/sizeof(formats[0]); std::time_t pt_to_time_t(const bt::ptime& pt) { bt::ptime timet_start(boost::gregorian::date(1970,1,1)); bt::time_duration diff = pt - timet_start; return diff.ticks()/bt::time_duration::rep_type::ticks_per_second; } int64_t DecodeDumpTime(const std::string& s) { bt::ptime pt; for(size_t i=0; i<formats_n; ++i) { std::istringstream is(s); is.imbue(formats[i]); is >> pt; if(pt != bt::ptime()) break; } return pt_to_time_t(pt); } std::string static EncodeDumpTime(int64_t nTime) { return DateTimeStrFormat("%Y-%m-%dT%H:%M:%SZ", nTime); } std::string static EncodeDumpString(const std::string &str) { std::stringstream ret; BOOST_FOREACH(unsigned char c, str) { if (c <= 32 || c >= 128 || c == '%') { ret << '%' << HexStr(&c, &c + 1); } else { ret << c; } } return ret.str(); } std::string DecodeDumpString(const std::string &str) { std::stringstream ret; for (unsigned int pos = 0; pos < str.length(); pos++) { unsigned char c = str[pos]; if (c == '%' && pos+2 < str.length()) { c = (((str[pos+1]>>6)*9+((str[pos+1]-'0')&15)) << 4) | ((str[pos+2]>>6)*9+((str[pos+2]-'0')&15)); pos += 2; } ret << c; } return ret.str(); } class CTxDump { public: CBlockIndex *pindex; int64_t nValue; bool fSpent; CWalletTx* ptx; int nOut; CTxDump(CWalletTx* ptx = NULL, int nOut = -1) { pindex = NULL; nValue = 0; fSpent = false; this->ptx = ptx; this->nOut = nOut; } }; Value importprivkey(const Array& params, bool fHelp) { if (fHelp || params.size() < 1 || params.size() > 2) throw runtime_error( "importprivkey <samuraiprivkey> [label]\n" "Adds a private key (as returned by dumpprivkey) to your wallet."); string strSecret = params[0].get_str(); string strLabel = ""; if (params.size() > 1) strLabel = params[1].get_str(); CBitcoinSecret vchSecret; bool fGood = vchSecret.SetString(strSecret); if (!fGood) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid private key"); if (fWalletUnlockStakingOnly) throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Wallet is unlocked for staking only."); CKey key; bool fCompressed; CSecret secret = vchSecret.GetSecret(fCompressed); key.SetSecret(secret, fCompressed); CKeyID vchAddress = key.GetPubKey().GetID(); { LOCK2(cs_main, pwalletMain->cs_wallet); pwalletMain->MarkDirty(); pwalletMain->SetAddressBookName(vchAddress, strLabel); if (!pwalletMain->AddKey(key)) throw JSONRPCError(RPC_WALLET_ERROR, "Error adding key to wallet"); pwalletMain->ScanForWalletTransactions(pindexGenesisBlock, true); pwalletMain->ReacceptWalletTransactions(); } return Value::null; } Value importwallet(const Array& params, bool fHelp) { if (fHelp || params.size() != 1) throw runtime_error( "importwallet <filename>\n" "Imports keys from a wallet dump file (see dumpwallet)."); EnsureWalletIsUnlocked(); ifstream file; file.open(params[0].get_str().c_str()); if (!file.is_open()) throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file"); int64_t nTimeBegin = pindexBest->nTime; bool fGood = true; while (file.good()) { std::string line; std::getline(file, line); if (line.empty() || line[0] == '#') continue; std::vector<std::string> vstr; boost::split(vstr, line, boost::is_any_of(" ")); if (vstr.size() < 2) continue; CBitcoinSecret vchSecret; if (!vchSecret.SetString(vstr[0])) continue; bool fCompressed; CKey key; CSecret secret = vchSecret.GetSecret(fCompressed); key.SetSecret(secret, fCompressed); CKeyID keyid = key.GetPubKey().GetID(); if (pwalletMain->HaveKey(keyid)) { printf("Skipping import of %s (key already present)\n", CBitcoinAddress(keyid).ToString().c_str()); continue; } int64_t nTime = DecodeDumpTime(vstr[1]); std::string strLabel; bool fLabel = true; for (unsigned int nStr = 2; nStr < vstr.size(); nStr++) { if (boost::algorithm::starts_with(vstr[nStr], "#")) break; if (vstr[nStr] == "change=1") fLabel = false; if (vstr[nStr] == "reserve=1") fLabel = false; if (boost::algorithm::starts_with(vstr[nStr], "label=")) { strLabel = DecodeDumpString(vstr[nStr].substr(6)); fLabel = true; } } printf("Importing %s...\n", CBitcoinAddress(keyid).ToString().c_str()); if (!pwalletMain->AddKey(key)) { fGood = false; continue; } pwalletMain->mapKeyMetadata[keyid].nCreateTime = nTime; if (fLabel) pwalletMain->SetAddressBookName(keyid, strLabel); nTimeBegin = std::min(nTimeBegin, nTime); } file.close(); CBlockIndex *pindex = pindexBest; while (pindex && pindex->pprev && pindex->nTime > nTimeBegin - 7200) pindex = pindex->pprev; if (!pwalletMain->nTimeFirstKey || nTimeBegin < pwalletMain->nTimeFirstKey) pwalletMain->nTimeFirstKey = nTimeBegin; printf("Rescanning last %i blocks\n", pindexBest->nHeight - pindex->nHeight + 1); pwalletMain->ScanForWalletTransactions(pindex); pwalletMain->ReacceptWalletTransactions(); pwalletMain->MarkDirty(); if (!fGood) throw JSONRPCError(RPC_WALLET_ERROR, "Error adding some keys to wallet"); return Value::null; } Value dumpprivkey(const Array& params, bool fHelp) { if (fHelp || params.size() != 1) throw runtime_error( "dumpprivkey <samuraiaddress>\n" "Reveals the private key corresponding to <samuraiaddress>."); EnsureWalletIsUnlocked(); string strAddress = params[0].get_str(); CBitcoinAddress address; if (!address.SetString(strAddress)) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid samurai address"); if (fWalletUnlockStakingOnly) throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Wallet is unlocked for staking only."); CKeyID keyID; if (!address.GetKeyID(keyID)) throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to a key"); CSecret vchSecret; bool fCompressed; if (!pwalletMain->GetSecret(keyID, vchSecret, fCompressed)) throw JSONRPCError(RPC_WALLET_ERROR, "Private key for address " + strAddress + " is not known"); return CBitcoinSecret(vchSecret, fCompressed).ToString(); } Value dumpwallet(const Array& params, bool fHelp) { if (fHelp || params.size() != 1) throw runtime_error( "dumpwallet <filename>\n" "Dumps all wallet keys in a human-readable format."); EnsureWalletIsUnlocked(); ofstream file; file.open(params[0].get_str().c_str()); if (!file.is_open()) throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file"); std::map<CKeyID, int64_t> mapKeyBirth; std::set<CKeyID> setKeyPool; pwalletMain->GetKeyBirthTimes(mapKeyBirth); pwalletMain->GetAllReserveKeys(setKeyPool); // sort time/key pairs std::vector<std::pair<int64_t, CKeyID> > vKeyBirth; for (std::map<CKeyID, int64_t>::const_iterator it = mapKeyBirth.begin(); it != mapKeyBirth.end(); it++) { vKeyBirth.push_back(std::make_pair(it->second, it->first)); } mapKeyBirth.clear(); std::sort(vKeyBirth.begin(), vKeyBirth.end()); // produce output file << strprintf("# Wallet dump created by samurai %s (%s)\n", CLIENT_BUILD.c_str(), CLIENT_DATE.c_str()); file << strprintf("# * Created on %s\n", EncodeDumpTime(GetTime()).c_str()); file << strprintf("# * Best block at time of backup was %i (%s),\n", nBestHeight, hashBestChain.ToString().c_str()); file << strprintf("# mined on %s\n", EncodeDumpTime(pindexBest->nTime).c_str()); file << "\n"; for (std::vector<std::pair<int64_t, CKeyID> >::const_iterator it = vKeyBirth.begin(); it != vKeyBirth.end(); it++) { const CKeyID &keyid = it->second; std::string strTime = EncodeDumpTime(it->first); std::string strAddr = CBitcoinAddress(keyid).ToString(); bool IsCompressed; CKey key; if (pwalletMain->GetKey(keyid, key)) { if (pwalletMain->mapAddressBook.count(keyid)) { CSecret secret = key.GetSecret(IsCompressed); file << strprintf("%s %s label=%s # addr=%s\n", CBitcoinSecret(secret, IsCompressed).ToString().c_str(), strTime.c_str(), EncodeDumpString(pwalletMain->mapAddressBook[keyid]).c_str(), strAddr.c_str()); } else if (setKeyPool.count(keyid)) { CSecret secret = key.GetSecret(IsCompressed); file << strprintf("%s %s reserve=1 # addr=%s\n", CBitcoinSecret(secret, IsCompressed).ToString().c_str(), strTime.c_str(), strAddr.c_str()); } else { CSecret secret = key.GetSecret(IsCompressed); file << strprintf("%s %s change=1 # addr=%s\n", CBitcoinSecret(secret, IsCompressed).ToString().c_str(), strTime.c_str(), strAddr.c_str()); } } } file << "\n"; file << "# End of dump\n"; file.close(); return Value::null; }
[ "test@test.com" ]
test@test.com
54a84d2f459dff0793821bfb59e3d940fcb8c6ff
f6ad1c5e9736c548ee8d41a7aca36b28888db74a
/others/BZOJ/2005.cpp
279d29469f7f6c0d9edb817ada8f6ee4ef0bebf7
[]
no_license
cnyali-czy/code
7fabf17711e1579969442888efe3af6fedf55469
a86661dce437276979e8c83d8c97fb72579459dd
refs/heads/master
2021-07-22T18:59:15.270296
2021-07-14T08:01:13
2021-07-14T08:01:13
122,709,732
0
3
null
null
null
null
UTF-8
C++
false
false
749
cpp
#define DREP(i, s, e) for(int i = s; i >= e ;i--) #define REP(i, s, e) for(int i = s; i <= e ;i++) #define DEBUG fprintf(stderr, "Passing [%s] in Line %d\n", __FUNCTION__, __LINE__) #define chkmax(a, b) a = max(a, b) #define chkmin(a, b) a = min(a, b) #include <iostream> #include <cstdio> #define int long long using namespace std; const int maxn = 1e5 + 10; int n, m, ans, cnt[maxn]; //ans = \sum_i \sum_j (i,j) - nm signed main() { #ifdef CraZYali freopen("2005.in", "r", stdin); freopen("2005.out", "w", stdout); #endif cin >> n >> m; ans = -n * m; int N(min(n, m)); DREP(i, N, 1) { int &c = cnt[i]; c = (n/i) * (m/i); for (int j = i + i; j <= N;j += i) c -= cnt[j]; ans += i * c * 2; } cout << ans << endl; return 0; }
[ "1683053325@qq.com" ]
1683053325@qq.com
3f3b2a48cc6177a1879fa45fae9216869a405421
d303ebbcd17023a3ba03d4ea2fde5804fe6285fc
/Lathaan/src/txmempool.h
c7d06b46ef84c33c18b11e76fff4ceb1ba7d4a2f
[ "MIT" ]
permissive
Lathaan/Lathaan
f395c139925505e5eb81f4accff8f6b9b36ec7b4
f30375df2d36f7607bcafc021facc0b3d11f7f32
refs/heads/master
2021-01-01T04:50:52.005558
2016-04-29T13:42:37
2016-04-29T13:42:37
57,387,831
0
0
null
null
null
null
UTF-8
C++
false
false
1,568
h
// Copyright (c) 2015 Evoshi Un // Copyright (c) 2009-2013 The Lathaan developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef LATHAAN_TXMEMPOOL_H #define LATHAAN_TXMEMPOOL_H #include "core.h" /* * CTxMemPool stores valid-according-to-the-current-best-chain * transactions that may be included in the next block. * * Transactions are added when they are seen on the network * (or created by the local node), but not all transactions seen * are added to the pool: if a new transaction double-spends * an input of a transaction in the pool, it is dropped, * as are non-standard transactions. */ class CTxMemPool { private: unsigned int nTransactionsUpdated; public: mutable CCriticalSection cs; std::map<uint256, CTransaction> mapTx; std::map<COutPoint, CInPoint> mapNextTx; CTxMemPool(); bool addUnchecked(const uint256& hash, CTransaction &tx); bool remove(const CTransaction &tx, bool fRecursive = false); bool removeConflicts(const CTransaction &tx); void clear(); void queryHashes(std::vector<uint256>& vtxid); unsigned int GetTransactionsUpdated() const; void AddTransactionsUpdated(unsigned int n); unsigned long size() const { LOCK(cs); return mapTx.size(); } bool exists(uint256 hash) const { LOCK(cs); return (mapTx.count(hash) != 0); } bool lookup(uint256 hash, CTransaction& result) const; }; #endif /* LATHAAN_TXMEMPOOL_H */
[ "lathaan@outlook.com" ]
lathaan@outlook.com
2e58328685cc9f84f4fd5a9e371a3bdb9fabaa5b
fa99d6a0981510675c6abdff0a9dde1fc61c319b
/Software/esp-idf-customized/components/asio/asio/asio/src/tests/unit/use_future.cpp
c4de771bd1741dc3e71b3f2ccf18829d9a2cea12
[ "LicenseRef-scancode-unknown-license-reference", "MIT", "BSL-1.0", "Apache-2.0" ]
permissive
trichl/WildFiOpenSource
f29de95b208586061d6d7a75ffd9c317ed0a4679
2ac5e86c3619782c8582ce81065f267dce830f0b
refs/heads/main
2023-04-19T00:01:50.853085
2021-10-09T09:09:33
2021-10-09T09:09:33
368,456,988
7
3
MIT
2022-10-25T03:13:18
2021-05-18T08:31:23
C
UTF-8
C++
false
false
10,103
cpp
// // use_future.cpp // ~~~~~~~~~~~~~~ // // Copyright (c) 2003-2019 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // // Disable autolinking for unit tests. #if !defined(BOOST_ALL_NO_LIB) #define BOOST_ALL_NO_LIB 1 #endif // !defined(BOOST_ALL_NO_LIB) // Test that header file is self-contained. #include "asio/use_future.hpp" #include <string> #include "unit_test.hpp" #if defined(ASIO_HAS_STD_FUTURE) #include "archetypes/async_ops.hpp" void use_future_0_test() { using asio::use_future; using namespace archetypes; std::future<void> f; f = async_op_0(use_future); try { f.get(); } catch (...) { ASIO_CHECK(false); } f = async_op_ec_0(true, use_future); try { f.get(); } catch (...) { ASIO_CHECK(false); } f = async_op_ec_0(false, use_future); try { f.get(); ASIO_CHECK(false); } catch (asio::system_error& e) { ASIO_CHECK(e.code() == asio::error::operation_aborted); } catch (...) { ASIO_CHECK(false); } f = async_op_ex_0(true, use_future); try { f.get(); } catch (...) { ASIO_CHECK(false); } f = async_op_ex_0(false, use_future); try { f.get(); ASIO_CHECK(false); } catch (std::exception& e) { ASIO_CHECK(e.what() == std::string("blah")); } catch (...) { ASIO_CHECK(false); } } void use_future_1_test() { using asio::use_future; using namespace archetypes; std::future<int> f; f = async_op_1(use_future); try { int i = f.get(); ASIO_CHECK(i == 42); } catch (...) { ASIO_CHECK(false); } f = async_op_ec_1(true, use_future); try { int i = f.get(); ASIO_CHECK(i == 42); } catch (...) { ASIO_CHECK(false); } f = async_op_ec_1(false, use_future); try { int i = f.get(); ASIO_CHECK(false); (void)i; } catch (asio::system_error& e) { ASIO_CHECK(e.code() == asio::error::operation_aborted); } catch (...) { ASIO_CHECK(false); } f = async_op_ex_1(true, use_future); try { int i = f.get(); ASIO_CHECK(i == 42); } catch (...) { ASIO_CHECK(false); } f = async_op_ex_1(false, use_future); try { int i = f.get(); ASIO_CHECK(false); (void)i; } catch (std::exception& e) { ASIO_CHECK(e.what() == std::string("blah")); } catch (...) { ASIO_CHECK(false); } } void use_future_2_test() { using asio::use_future; using namespace archetypes; std::future<std::tuple<int, double>> f; f = async_op_2(use_future); try { int i; double d; std::tie(i, d) = f.get(); ASIO_CHECK(i == 42); ASIO_CHECK(d == 2.0); } catch (...) { ASIO_CHECK(false); } f = async_op_ec_2(true, use_future); try { int i; double d; std::tie(i, d) = f.get(); ASIO_CHECK(i == 42); ASIO_CHECK(d == 2.0); } catch (...) { ASIO_CHECK(false); } f = async_op_ec_2(false, use_future); try { std::tuple<int, double> t = f.get(); ASIO_CHECK(false); (void)t; } catch (asio::system_error& e) { ASIO_CHECK(e.code() == asio::error::operation_aborted); } catch (...) { ASIO_CHECK(false); } f = async_op_ex_2(true, use_future); try { int i; double d; std::tie(i, d) = f.get(); ASIO_CHECK(i == 42); ASIO_CHECK(d == 2.0); } catch (...) { ASIO_CHECK(false); } f = async_op_ex_2(false, use_future); try { std::tuple<int, double> t = f.get(); ASIO_CHECK(false); (void)t; } catch (std::exception& e) { ASIO_CHECK(e.what() == std::string("blah")); } catch (...) { ASIO_CHECK(false); } } void use_future_3_test() { using asio::use_future; using namespace archetypes; std::future<std::tuple<int, double, char>> f; f = async_op_3(use_future); try { int i; double d; char c; std::tie(i, d, c) = f.get(); ASIO_CHECK(i == 42); ASIO_CHECK(d == 2.0); ASIO_CHECK(c == 'a'); } catch (...) { ASIO_CHECK(false); } f = async_op_ec_3(true, use_future); try { int i; double d; char c; std::tie(i, d, c) = f.get(); ASIO_CHECK(i == 42); ASIO_CHECK(d == 2.0); ASIO_CHECK(c == 'a'); } catch (...) { ASIO_CHECK(false); } f = async_op_ec_3(false, use_future); try { std::tuple<int, double, char> t = f.get(); ASIO_CHECK(false); (void)t; } catch (asio::system_error& e) { ASIO_CHECK(e.code() == asio::error::operation_aborted); } catch (...) { ASIO_CHECK(false); } f = async_op_ex_3(true, use_future); try { int i; double d; char c; std::tie(i, d, c) = f.get(); ASIO_CHECK(i == 42); ASIO_CHECK(d == 2.0); ASIO_CHECK(c == 'a'); } catch (...) { ASIO_CHECK(false); } f = async_op_ex_3(false, use_future); try { std::tuple<int, double, char> t = f.get(); ASIO_CHECK(false); (void)t; } catch (std::exception& e) { ASIO_CHECK(e.what() == std::string("blah")); } catch (...) { ASIO_CHECK(false); } } int package_0() { return 42; } int package_ec_0(asio::error_code ec) { return ec ? 0 : 42; } int package_ex_0(std::exception_ptr ex) { return ex ? 0 : 42; } void use_future_package_0_test() { using asio::use_future; using namespace archetypes; std::future<int> f; f = async_op_0(use_future(package_0)); try { int i = f.get(); ASIO_CHECK(i == 42); } catch (...) { ASIO_CHECK(false); } f = async_op_ec_0(true, use_future(&package_ec_0)); try { int i = f.get(); ASIO_CHECK(i == 42); } catch (...) { ASIO_CHECK(false); } f = async_op_ec_0(false, use_future(package_ec_0)); try { int i = f.get(); ASIO_CHECK(i == 0); } catch (...) { ASIO_CHECK(false); } f = async_op_ex_0(true, use_future(package_ex_0)); try { int i = f.get(); ASIO_CHECK(i == 42); } catch (...) { ASIO_CHECK(false); } f = async_op_ex_0(false, use_future(package_ex_0)); try { int i = f.get(); ASIO_CHECK(i == 0); } catch (...) { ASIO_CHECK(false); } } int package_1(int i) { return i; } int package_ec_1(asio::error_code ec, int i) { return ec ? 0 : i; } int package_ex_1(std::exception_ptr ex, int i) { return ex ? 0 : i; } void use_future_package_1_test() { using asio::use_future; using namespace archetypes; std::future<int> f; f = async_op_1(use_future(package_1)); try { int i = f.get(); ASIO_CHECK(i == 42); } catch (...) { ASIO_CHECK(false); } f = async_op_ec_1(true, use_future(package_ec_1)); try { int i = f.get(); ASIO_CHECK(i == 42); } catch (...) { ASIO_CHECK(false); } f = async_op_ec_1(false, use_future(package_ec_1)); try { int i = f.get(); ASIO_CHECK(i == 0); } catch (...) { ASIO_CHECK(false); } f = async_op_ex_1(true, use_future(package_ex_1)); try { int i = f.get(); ASIO_CHECK(i == 42); } catch (...) { ASIO_CHECK(false); } f = async_op_ex_1(false, use_future(package_ex_1)); try { int i = f.get(); ASIO_CHECK(i == 0); } catch (...) { ASIO_CHECK(false); } } int package_2(int i, double) { return i; } int package_ec_2(asio::error_code ec, int i, double) { return ec ? 0 : i; } int package_ex_2(std::exception_ptr ex, int i, double) { return ex ? 0 : i; } void use_future_package_2_test() { using asio::use_future; using namespace archetypes; std::future<int> f; f = async_op_2(use_future(package_2)); try { int i = f.get(); ASIO_CHECK(i == 42); } catch (...) { ASIO_CHECK(false); } f = async_op_ec_2(true, use_future(package_ec_2)); try { int i = f.get(); ASIO_CHECK(i == 42); } catch (...) { ASIO_CHECK(false); } f = async_op_ec_2(false, use_future(package_ec_2)); try { int i = f.get(); ASIO_CHECK(i == 0); } catch (...) { ASIO_CHECK(false); } f = async_op_ex_2(true, use_future(package_ex_2)); try { int i = f.get(); ASIO_CHECK(i == 42); } catch (...) { ASIO_CHECK(false); } f = async_op_ex_2(false, use_future(package_ex_2)); try { int i = f.get(); ASIO_CHECK(i == 0); } catch (...) { ASIO_CHECK(false); } } int package_3(int i, double, char) { return i; } int package_ec_3(asio::error_code ec, int i, double, char) { return ec ? 0 : i; } int package_ex_3(std::exception_ptr ex, int i, double, char) { return ex ? 0 : i; } void use_future_package_3_test() { using asio::use_future; using namespace archetypes; std::future<int> f; f = async_op_3(use_future(package_3)); try { int i = f.get(); ASIO_CHECK(i == 42); } catch (...) { ASIO_CHECK(false); } f = async_op_ec_3(true, use_future(package_ec_3)); try { int i = f.get(); ASIO_CHECK(i == 42); } catch (...) { ASIO_CHECK(false); } f = async_op_ec_3(false, use_future(package_ec_3)); try { int i = f.get(); ASIO_CHECK(i == 0); } catch (...) { ASIO_CHECK(false); } f = async_op_ex_3(true, use_future(package_ex_3)); try { int i = f.get(); ASIO_CHECK(i == 42); } catch (...) { ASIO_CHECK(false); } f = async_op_ex_3(false, use_future(package_ex_3)); try { int i = f.get(); ASIO_CHECK(i == 0); } catch (...) { ASIO_CHECK(false); } } ASIO_TEST_SUITE ( "use_future", ASIO_TEST_CASE(use_future_0_test) ASIO_TEST_CASE(use_future_1_test) ASIO_TEST_CASE(use_future_2_test) ASIO_TEST_CASE(use_future_3_test) ASIO_TEST_CASE(use_future_package_0_test) ASIO_TEST_CASE(use_future_package_1_test) ASIO_TEST_CASE(use_future_package_2_test) ASIO_TEST_CASE(use_future_package_3_test) ) #else // defined(ASIO_HAS_STD_FUTURE) ASIO_TEST_SUITE ( "use_future", ASIO_TEST_CASE(null_test) ) #endif // defined(ASIO_HAS_STD_FUTURE)
[ "59619846+trichl@users.noreply.github.com" ]
59619846+trichl@users.noreply.github.com
1dd95bd6c2269b57c1dfb5686fc15770478cb05c
57db889255ffe5cea6d10994a141734ca5add88c
/clrTest/MyForm.h
4a19fd4b8c49058ae383ea73fe2280a1f9cce1dc
[]
no_license
SmartNetAR/microwave
26fa7a0dd1d2630169eac24f2dc60f678e76e7f7
1331c48e9e43e34b62354d9e288ce4f45c3a4398
refs/heads/master
2021-08-08T06:17:59.623461
2017-11-03T21:43:02
2017-11-03T21:43:02
109,009,880
0
0
null
2017-10-31T16:36:10
2017-10-31T14:46:25
null
ISO-8859-1
C++
false
false
6,085
h
#include "Microwave.h" #pragma once namespace clrTest { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; Microwave* mw = new Microwave; /// <summary> /// Resumen de MyForm /// </summary> public ref class MyForm : public System::Windows::Forms::Form { public: MyForm(void) { InitializeComponent(); // //TODO: agregar código de constructor aquí // } protected: /// <summary> /// Limpiar los recursos que se estén usando. /// </summary> ~MyForm() { if (components) { delete components; } } private: System::Windows::Forms::Button^ btnOpen; private: System::Windows::Forms::Button^ btnClose; protected: private: System::Windows::Forms::Label^ label1; private: System::Windows::Forms::Label^ lblState; private: System::Windows::Forms::Button^ btnRefresh; private: System::Windows::Forms::Label^ label2; private: System::Windows::Forms::Label^ lblLight; private: System::Windows::Forms::Button^ button1; protected: private: /// <summary> /// Variable del diseñador necesaria. /// </summary> System::ComponentModel::Container ^components; #pragma region Windows Form Designer generated code /// <summary> /// Método necesario para admitir el Diseñador. No se puede modificar /// el contenido de este método con el editor de código. /// </summary> void InitializeComponent(void) { this->btnOpen = (gcnew System::Windows::Forms::Button()); this->btnClose = (gcnew System::Windows::Forms::Button()); this->label1 = (gcnew System::Windows::Forms::Label()); this->lblState = (gcnew System::Windows::Forms::Label()); this->btnRefresh = (gcnew System::Windows::Forms::Button()); this->label2 = (gcnew System::Windows::Forms::Label()); this->lblLight = (gcnew System::Windows::Forms::Label()); this->button1 = (gcnew System::Windows::Forms::Button()); this->SuspendLayout(); // // btnOpen // this->btnOpen->Location = System::Drawing::Point(94, 75); this->btnOpen->Name = L"btnOpen"; this->btnOpen->Size = System::Drawing::Size(99, 47); this->btnOpen->TabIndex = 0; this->btnOpen->Text = L"Open"; this->btnOpen->UseVisualStyleBackColor = true; this->btnOpen->Click += gcnew System::EventHandler(this, &MyForm::btnOpen_Click); // // btnClose // this->btnClose->Location = System::Drawing::Point(211, 75); this->btnClose->Name = L"btnClose"; this->btnClose->Size = System::Drawing::Size(99, 47); this->btnClose->TabIndex = 1; this->btnClose->Text = L"Close"; this->btnClose->UseVisualStyleBackColor = true; this->btnClose->Click += gcnew System::EventHandler(this, &MyForm::btnClose_Click); // // label1 // this->label1->AutoSize = true; this->label1->Location = System::Drawing::Point(126, 13); this->label1->Name = L"label1"; this->label1->Size = System::Drawing::Size(35, 13); this->label1->TabIndex = 2; this->label1->Text = L"State:"; // // lblState // this->lblState->AutoSize = true; this->lblState->Location = System::Drawing::Point(193, 13); this->lblState->Name = L"lblState"; this->lblState->Size = System::Drawing::Size(0, 13); this->lblState->TabIndex = 3; // // btnRefresh // this->btnRefresh->Location = System::Drawing::Point(13, 8); this->btnRefresh->Name = L"btnRefresh"; this->btnRefresh->Size = System::Drawing::Size(75, 23); this->btnRefresh->TabIndex = 4; this->btnRefresh->Text = L"Refresh"; this->btnRefresh->UseVisualStyleBackColor = true; this->btnRefresh->Click += gcnew System::EventHandler(this, &MyForm::btnRefresh_Click); // // label2 // this->label2->AutoSize = true; this->label2->Location = System::Drawing::Point(13, 144); this->label2->Name = L"label2"; this->label2->Size = System::Drawing::Size(30, 13); this->label2->TabIndex = 5; this->label2->Text = L"Light"; // // lblLight // this->lblLight->AutoSize = true; this->lblLight->Location = System::Drawing::Point(52, 144); this->lblLight->Name = L"lblLight"; this->lblLight->Size = System::Drawing::Size(0, 13); this->lblLight->TabIndex = 6; // // button1 // this->button1->Location = System::Drawing::Point(211, 159); this->button1->Name = L"button1"; this->button1->Size = System::Drawing::Size(99, 44); this->button1->TabIndex = 7; this->button1->Text = L"Cook"; this->button1->UseVisualStyleBackColor = true; this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click); // // MyForm // this->AutoScaleDimensions = System::Drawing::SizeF(6, 13); this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font; this->ClientSize = System::Drawing::Size(467, 254); this->Controls->Add(this->button1); this->Controls->Add(this->lblLight); this->Controls->Add(this->label2); this->Controls->Add(this->btnRefresh); this->Controls->Add(this->lblState); this->Controls->Add(this->label1); this->Controls->Add(this->btnClose); this->Controls->Add(this->btnOpen); this->Name = L"MyForm"; this->Text = L"MyForm"; this->ResumeLayout(false); this->PerformLayout(); } #pragma endregion void RefreshControls() { String^ strNew = gcnew String(mw->GetStateName()); this->lblState->Text = strNew; if (mw->IsLightOn()) { lblLight->Text = "On"; } else { lblLight->Text = "Off"; } } private: System::Void btnOpen_Click(System::Object^ sender, System::EventArgs^ e) { mw->OpenDoor(); RefreshControls(); } private: System::Void btnRefresh_Click(System::Object^ sender, System::EventArgs^ e) { RefreshControls(); } private: System::Void btnClose_Click(System::Object^ sender, System::EventArgs^ e) { mw->CloseDoor(); RefreshControls(); } private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { mw->PressButton(); RefreshControls(); } }; }
[ "leonardo@smartnet.com.ar" ]
leonardo@smartnet.com.ar
cd4a450a57b27c3eca4f244b41ebc08067106955
660e531d35c6406e6e0f31d47e0ed0c3df21478d
/basecode/compiler/elements/map_type.cpp
7e102121ee2f897b164fb6eb2ce6f4899c9cec19
[ "MIT" ]
permissive
swills/bootstrap
d7a96f7d96c86da2debbe42683e22dca4902f51e
f49e86109d29430050dc237de40b24dc7a848718
refs/heads/master
2020-04-10T06:02:56.334916
2018-12-31T22:58:36
2018-12-31T22:58:36
160,844,343
0
0
null
2018-12-07T15:53:48
2018-12-07T15:53:47
null
UTF-8
C++
false
false
2,545
cpp
// ---------------------------------------------------------------------------- // // Basecode Bootstrap Compiler // Copyright (C) 2018 Jeff Panici // All rights reserved. // // This software source file is licensed under the terms of MIT license. // For details, please read the LICENSE file. // // ---------------------------------------------------------------------------- #include <compiler/session.h> #include "program.h" #include "map_type.h" #include "symbol_element.h" #include "type_reference.h" namespace basecode::compiler { std::string map_type::name_for_map( compiler::type_reference* key_type, compiler::type_reference* value_type) { return fmt::format("__map_{}_{}__", key_type->name(), value_type->name()); } map_type::map_type( compiler::module* module, compiler::block* parent_scope, compiler::block* scope, compiler::type_reference* key_type, compiler::type_reference* value_type) : compiler::composite_type( module, parent_scope, composite_types_t::struct_type, scope, nullptr, element_type_t::map_type), _key_type(key_type), _value_type(value_type) { } compiler::type_reference* map_type::key_type() { return _key_type; } compiler::type_reference* map_type::value_type() { return _value_type; } type_access_model_t map_type::on_access_model() const { return type_access_model_t::pointer; } bool map_type::on_initialize(compiler::session& session) { // auto& scope_manager = session.scope_manager(); auto& builder = session.builder(); auto type_symbol = builder.make_symbol( parent_scope(), name_for_map(_key_type, _value_type)); symbol(type_symbol); type_symbol->parent_element(this); // XXX: need to add fields to the map type return composite_type::on_initialize(session); } std::string map_type::name(const std::string& alias) const { return alias.empty() ? name_for_map(_key_type, _value_type) : alias; } };
[ "jeff.panici@panici-software.com" ]
jeff.panici@panici-software.com
2ca3e4b1f7bbcacfe00c8c802af543ee2a4d931d
007d63d4cb49676fd678840a3e1244ad63bdb121
/visiocyte_main/mozak/m_terafly/src/presentation/m_PAbout.cpp
b5b35c750e5c4f2f7ff46279852a385b66ba3337
[ "LicenseRef-scancode-warranty-disclaimer", "MIT" ]
permissive
satya-arjunan/visiocyte
1a09cc886b92ca10c80b21d43220b33c6009e079
891404d83d844ae94ee8f1cea1bb14deba588c4f
refs/heads/master
2020-04-23T02:07:33.357029
2019-04-08T06:40:03
2019-04-08T06:40:03
170,835,824
0
0
null
null
null
null
UTF-8
C++
false
false
3,838
cpp
#include "m_PAbout.h" using namespace teramanager; PAbout* PAbout::uniqueInstance = 0; PAbout::PAbout(QWidget *parent) : QDialog(parent) { /**/itm::debug(itm::LEV1, 0, __itm__current__function__); setWindowTitle("About TeraFly"); desc = new QLabel(); desc->setText( QString("<html><h3>Visiocyte-TeraFly v. ").append(teramanager::version.c_str()).append("</h3>" "<p>A tool designed for Teravoxel-sized datasets 3D navigation and Visiocyte-aided analysis.</p>" "<small><u>Developed by:</u><ul style=\"padding-left:5px\">" "<li><b>Alessandro Bria</b> (email: a.bria@unicas.it)<br>" "University of Cassino</li>" "<li><b>Giulio Iannello</b> (email: g.iannello@unicampus.it)<br>" "University Campus Bio-Medico of Rome</li>" "<li><b>Hanchuan Peng</b> (email: hanchuan.peng@gmail.com)<br>" "Allen Institute for Brain Science and Janelia @ HHMI</li></ul></small></html>")); desc->setWordWrap(true); logo = new QLabel(); QPixmap *logo_img = new QPixmap(":/icons/terafly.png"); logo->setPixmap(logo_img->scaled(150, 200, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); changelog = new QTextEdit(); changelog->setReadOnly(true); QFile file(":/changelog.txt"); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) return; QTextStream in(&file); changelog->setText(in.readAll()); QFont tinyFont = QFont("Courier New", 9); changelog->setFont(tinyFont); changelog->setWordWrapMode(QTextOption::NoWrap); changelog->setStyleSheet("QTextEdit {padding:5px; background-color: white}"); closeButton = new QPushButton("Close"); connect(closeButton, SIGNAL(clicked()), this, SLOT(close())); QGridLayout* layout = new QGridLayout(this); layout->setMargin(20); layout->setSpacing(20); layout->addWidget(logo, 0, 0, 1, 1); layout->addWidget(desc, 0, 1, 1, 1); layout->addWidget(changelog, 2, 0, 1, 2); layout->addWidget(closeButton, 3, 0, 1, 2, Qt::AlignRight); /*msgBox->setText( QString("<html><h1>TeraFly plugin v. ").append(CPlugin::getMajorVersion().c_str()).append("</h1>" "<big>An experimental tool designed for Teravoxel-sized datasets 3D navigation into Visiocyte.</big><br><br>" "<u>Developed by:</u><ul>" "<li style=\"margin-left: 0\"><b>Alessandro Bria</b> (email: a.bria@unicas.it)<br>" "University of Cassino</li>" "<li><b>Giulio Iannello</b> (email: g.iannello@unicampus.it)<br>" "University Campus Bio-Medico of Rome</li>" "<li><b>Hanchuan Peng</b> (email: hanchuan.peng@gmail.com)<br>" "Allen Institute for Brain Science and Janelia @ HHMI</li></ul><br>" "<u>Features:</u><ul>" "<li>Google Earth-like 3D navigation through multiresolution teravoxel-sized datasets</li>" "<li>computer-aided annotation of markers and curves</li>" "<li>low memory requirements (4 GB)</li></ul><br>" "<u>Supported input formats:</u><ul>" "<li>two-level directory structure with each tile containing a series of image slices (see documentation for further information)</li>" "<li>supported formats for image slices are BMP, DIB, JPEG, JPG, JPE, PNG, PBM, PGM, PPM, SR, RAS, TIFF, TIF</li>" "<li>no restriction on the bit depth</li>" "<li>no restriction on the number of channels</li></ul></html>" ));*/ setLayout(layout); setFixedWidth(550); }
[ "satya.arjunan@gmail.com" ]
satya.arjunan@gmail.com
222887a552a576f4576aab9b3a464764f4807d63
65376363a17ad357c42a4bab9ce7eda4028307d6
/personal4/Untitled5.cpp
31bc563e36216c1f7a03547da2f174c506509f90
[]
no_license
jitamm20081/ACM
bb86b731d58f49edc77f8846d6d9b4dd205cef92
22c95770666539ebc83680c6a12c765e9ee0aaa1
refs/heads/master
2020-03-19T20:23:22.760987
2018-08-14T12:44:58
2018-08-14T12:44:58
136,899,360
0
0
null
null
null
null
GB18030
C++
false
false
992
cpp
#include <stdio.h> #include <stdlib.h> #include <string.h> #define maxn 101 int cmp(const void *a, const void *b) { return *(int *)a - *(int *)b;//从小到大排序 } /* int cmp(const void *a, const void *b) { return *(int *)b- *(int *)a;//从大到小排序 } */ int main() { char a[maxn]; char b[maxn]; while(scanf("%s%s",&a,&b) != EOF) { int len = strlen(a); int cnt1[26],cnt2[26]; memset(cnt1,0,sizeof(cnt1)); memset(cnt2,0,sizeof(cnt2)); for(int i=0; i < len; i++) { cnt1[a[i] - 'A']++; //A-0 B-1..... cnt2[b[i] - 'A']++; } //排序 qsort(cnt1,26,sizeof(cnt1[0]),cmp);//qsort快速排序 qsort(cnt2,26,sizeof(cnt2[0]),cmp); for(int i=0; i < 26; i++) { if(cnt1[i] != cnt2[i]) { printf("NO\n"); return 0; } } printf("YES\n"); } return 0; }
[ "39211497+jitamm20081@users.noreply.github.com" ]
39211497+jitamm20081@users.noreply.github.com
0ce09e02f906fd824caa9d34b19d7d8d0a2699fa
95f5c38f8020654989aea5cd7337d242f7522637
/ast.hpp
a25afc4a873f3cb7a9258ddca7becafaef0ffb5f
[]
no_license
priyendra/dlox
291254089b455098731a0061b0fa2d1346e2c7e4
0abf356a73f43d498577eb77535ee78599adda36
refs/heads/master
2020-07-06T19:22:29.355493
2019-08-08T23:35:24
2019-08-09T09:31:36
203,115,692
0
0
null
null
null
null
UTF-8
C++
false
false
2,219
hpp
#pragma once #include <any> #include <memory> #include "token.hpp" namespace lox { namespace ast { class Visitor; struct Node { virtual ~Node() {} virtual std::any accept(Visitor* visitor) const = 0; }; struct Number : public Node { std::any accept(Visitor* visitor) const override; double val; }; struct String : public Node { std::any accept(Visitor* visitor) const override; std::string val; }; struct Bool : public Node { std::any accept(Visitor* visitor) const override; bool val; }; struct Nil : public Node { std::any accept(Visitor* visitor) const override; }; struct Unary : public Node { enum Operator { MINUS, BANG }; std::any accept(Visitor* visitor) const override; Operator op; Token opToken; // TODO: If Node is generic AstNode, then this should be Expr. We have not // defined a separate Expr class yet because our current goal is to only // parse expressions. So expressions are actually the highest point in our // AST heirarchy. std::unique_ptr<Node> operand; }; struct Binary : public Node { enum Operator { MINUS, PLUS, SLASH, STAR, BANG_EQUAL, EQUAL_EQUAL, GREATER, GREATER_EQUAL, LESS, LESS_EQUAL }; std::any accept(Visitor* visitor) const override; Operator op; Token opToken; std::unique_ptr<Node> first; std::unique_ptr<Node> second; }; class Visitor { public: virtual ~Visitor() {} virtual std::any visitNumber(const Number* obj) = 0; virtual std::any visitString(const String* obj) = 0; virtual std::any visitBool(const Bool* obj) = 0; virtual std::any visitNil(const Nil* nil) = 0; virtual std::any visitUnary(const Unary* unary) = 0; virtual std::any visitBinary(const Binary* binary) = 0; }; std::any Number::accept(Visitor* v) const { return v->visitNumber(this); } std::any String::accept(Visitor* v) const { return v->visitString(this); } std::any Bool::accept(Visitor* v) const { return v->visitBool(this); } std::any Nil::accept(Visitor* v) const { return v->visitNil(this); } std::any Unary::accept(Visitor* v) const { return v->visitUnary(this); } std::any Binary::accept(Visitor* v) const { return v->visitBinary(this); } } // namespace ast } // namespace lox
[ "priyendra@gmail.com" ]
priyendra@gmail.com
0566c7d58ae2cadcd53efdd608fc441e3e40ddb0
430a27ecb85827c64e852338220a1909f3815f40
/src/qt/receivecoinsdialog.h
97934c4d1be798cc37baf0d2ea77406d413eabd9
[ "MIT" ]
permissive
bayerman-rol/MagpieCoin
e3d4d2935d962d4fe969984969b6a27470c35347
411d364217a0ef5cd0e403881bd2edf5023d465a
refs/heads/main
2023-05-12T00:30:59.511945
2021-06-06T18:48:57
2021-06-06T18:48:57
374,305,398
0
0
MIT
2021-06-06T08:19:11
2021-06-06T08:19:10
null
UTF-8
C++
false
false
2,040
h
// Copyright (c) 2011-2018 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef MAGPIECOIN_QT_RECEIVECOINSDIALOG_H #define MAGPIECOIN_QT_RECEIVECOINSDIALOG_H #include <qt/guiutil.h> #include <QDialog> #include <QHeaderView> #include <QItemSelection> #include <QKeyEvent> #include <QMenu> #include <QPoint> #include <QVariant> class PlatformStyle; class WalletModel; namespace Ui { class ReceiveCoinsDialog; } QT_BEGIN_NAMESPACE class QModelIndex; QT_END_NAMESPACE /** Dialog for requesting payment of magpiecoins */ class ReceiveCoinsDialog : public QDialog { Q_OBJECT public: enum ColumnWidths { DATE_COLUMN_WIDTH = 130, LABEL_COLUMN_WIDTH = 120, AMOUNT_MINIMUM_COLUMN_WIDTH = 180, MINIMUM_COLUMN_WIDTH = 130 }; explicit ReceiveCoinsDialog(const PlatformStyle *platformStyle, QWidget *parent = 0); ~ReceiveCoinsDialog(); void setModel(WalletModel *model); public Q_SLOTS: void clear(); void reject(); void accept(); protected: virtual void keyPressEvent(QKeyEvent *event); private: Ui::ReceiveCoinsDialog *ui; GUIUtil::TableViewLastColumnResizingFixer *columnResizingFixer; WalletModel *model; QMenu *contextMenu; const PlatformStyle *platformStyle; QModelIndex selectedRow(); void copyColumnToClipboard(int column); virtual void resizeEvent(QResizeEvent *event); private Q_SLOTS: void on_receiveButton_clicked(); void on_showRequestButton_clicked(); void on_removeRequestButton_clicked(); void on_recentRequestsView_doubleClicked(const QModelIndex &index); void recentRequestsView_selectionChanged(const QItemSelection &selected, const QItemSelection &deselected); void updateDisplayUnit(); void showMenu(const QPoint &point); void copyURI(); void copyLabel(); void copyMessage(); void copyAmount(); }; #endif // MAGPIECOIN_QT_RECEIVECOINSDIALOG_H
[ "53425811+mgpc-lab@users.noreply.github.com" ]
53425811+mgpc-lab@users.noreply.github.com
c9da179ed879a6a253b0f585b386d0afc4ba6911
1af49694004c6fbc31deada5618dae37255ce978
/content/browser/font_access/font_access_test_utils.h
a7b28647be0eff07ef3907dfd365e4ec3f0c3fb7
[ "BSD-3-Clause" ]
permissive
sadrulhc/chromium
59682b173a00269ed036eee5ebfa317ba3a770cc
a4b950c23db47a0fdd63549cccf9ac8acd8e2c41
refs/heads/master
2023-02-02T07:59:20.295144
2020-12-01T21:32:32
2020-12-01T21:32:32
317,678,056
3
0
BSD-3-Clause
2020-12-01T21:56:26
2020-12-01T21:56:25
null
UTF-8
C++
false
false
1,655
h
// Copyright 2020 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 CONTENT_BROWSER_FONT_ACCESS_FONT_ACCESS_TEST_UTILS_H_ #define CONTENT_BROWSER_FONT_ACCESS_FONT_ACCESS_TEST_UTILS_H_ #include "content/public/test/mock_permission_manager.h" namespace content { class TestFontAccessPermissionManager : public MockPermissionManager { public: TestFontAccessPermissionManager(); ~TestFontAccessPermissionManager() override; using PermissionCallback = base::OnceCallback<void(blink::mojom::PermissionStatus)>; int RequestPermission(PermissionType permissions, RenderFrameHost* render_frame_host, const GURL& requesting_origin, bool user_gesture, PermissionCallback callback) override; blink::mojom::PermissionStatus GetPermissionStatusForFrame( PermissionType permission, RenderFrameHost* render_frame_host, const GURL& requesting_origin) override; void SetRequestCallback( base::RepeatingCallback<void(PermissionCallback)> request_callback) { request_callback_ = std::move(request_callback); } void SetPermissionStatusForFrame(blink::mojom::PermissionStatus status) { permission_status_for_frame_ = status; } private: base::RepeatingCallback<void(PermissionCallback)> request_callback_; blink::mojom::PermissionStatus permission_status_for_frame_ = blink::mojom::PermissionStatus::ASK; }; } // namespace content #endif // CONTENT_BROWSER_FONT_ACCESS_FONT_ACCESS_TEST_UTILS_H_
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
2cd8f9d5ac5b6a5428ce34cee678d6c860a12a0e
cff81ff659ad529706dc9ba1befbc68d8ae5ad26
/spoj_EC_CONB.cpp
e1bf675e8181cc82370b7af0ed135c2bc4f80488
[]
no_license
iishipatel/Competetive-Programming
9dafb3e49e60daee0f7dfca7f88ea23fd0777507
2ece5d282e753aee38d503bc5102baffa0141b2f
refs/heads/master
2020-08-05T23:03:48.027950
2019-10-08T12:02:27
2019-10-08T12:02:27
212,747,647
1
0
null
2019-10-04T06:12:08
2019-10-04T06:12:06
null
UTF-8
C++
false
false
821
cpp
/* Author : Abhinav Modified : 01-09-2018 01:35:30 AM */ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vi; typedef map<ll,ll> mllmp; typedef pair<int,int> PII; #define faster ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0); #define PB push_back #define MP make_pair # define INF 0x3f3f3f3f const ll mod = 1e9+7; #define rep(i,j,k) for(ll i=j; i<k; i++) #define repv(i,j,k) for(ll i=j; i>k; i--) int main(){ faster; ll t,x,n; cin >> t; while(t--){ cin >> x; if(x&1){ cout << x << "\n"; continue; } n = x; ll ct=0; while(n){ n = n>>1; ct++; } ll ans=0,k=1; n = x; while(n){ if(n&1){ //cout << ct << " " << k << "\n"; ans += pow(2,ct-k); } n = n>>1; k++; } cout << ans << "\n"; } return 0; }
[ "imabhinav.am@gmail.com" ]
imabhinav.am@gmail.com
adfc527a1f39a66135e2963de9404344adfa9fc9
8d2eb957732f79323e4b49fe37d0ef32725a8568
/src/timonel-mms-esp8266.cpp
622b494cc264336be3d83566eb18d4025d01e832
[ "MIT" ]
permissive
casanovg/timonel-mms-esp8266
fcc3540fdd3242510e96c07f7fe340f373471133
f6187c69955ba08d6782148254d4642d06bb10ac
refs/heads/master
2022-11-22T00:04:04.612328
2020-07-20T02:53:30
2020-07-20T02:53:30
280,937,436
0
0
MIT
2020-07-20T02:50:30
2020-07-19T19:38:32
null
UTF-8
C++
false
false
15,215
cpp
/* Timonel bootloader I2C-master multi slave application demo for ESP8266 ............................................................................ File: timonel-mms-esp8266.cpp (Application) ............................................................................ This demo shows how to control and update several Tiny85 microcontrollers running the Timonel bootloader from an ESP8266 master. It uses a serial console configured at 115200 N 8 1 for feedback. ............................................................................ Version: 1.5.0 / 2020-07-13 / gustavo.casanova@nicebots.com ............................................................................ */ /* Working routine: ---------------- 1) Scans the TWI bus in search of all devices running Timonel. 2) Creates an array of Timonel objects, one per device. 3) Deletes existing firmware of each device. 4) Uploads "avr-blink-twis.hex" application payload to each device. 5) Launches application on each device, let it run 10 seconds. 6) Sends reset command to the application: led blinking should stop on all devices. 7) Repeats the routine 3 times. */ #include "timonel-mms-esp8266.h" #include <NbMicro.h> #include <TimonelTwiM.h> #include <TwiBus.h> #include "payload.h" /* ___________________ | | | Setup block | |___________________| */ void setup() { // Initialize the serial port for debugging USE_SERIAL.begin(SERIAL_BPS); ClrScr(); PrintLogo(); ShowHeader(); /* ____________________ | | | Routine loop | |____________________| */ for (uint8_t loop = 0; loop < LOOP_COUNT; loop++) { USE_SERIAL.printf_P("\n\rPASS %d OF %d ...\n\r", loop + 1, LOOP_COUNT); // The bus device scanning it has to be made as fast as possible since each // discovered Timonel has to be initialized before launching the user apps TwiBus twi_bus(SDA, SCL); TwiBus::DeviceInfo dev_info_arr[HIG_TWI_ADDR - LOW_TWI_ADDR + 1]; // Scanning the TWI bus in search of devices ... uint8_t tml_count = 0; USE_SERIAL.printf_P("\n\r"); while (tml_count == 0) { USE_SERIAL.printf_P("\r\x1b[5mScanning TWI bus ...\x1b[0m"); twi_bus.ScanBus(dev_info_arr, HIG_TWI_ADDR - LOW_TWI_ADDR + 1, LOW_TWI_ADDR); uint8_t arr_size = (sizeof(dev_info_arr) / sizeof(dev_info_arr[0])); for (uint8_t i = 0; i < arr_size; i++) { if (dev_info_arr[i].firmware == "Timonel") { tml_count++; } } if (tml_count > 0) { USE_SERIAL.printf_P("\rTimonel devices found: %d\n\r", tml_count); } else { if (dev_info_arr[0].addr) { USE_SERIAL.printf_P("\rDevice found at address %d NOT responding, resetting both micros ...\n\r", dev_info_arr[0].addr); NbMicro *micro = new NbMicro(dev_info_arr[0].addr, SDA, SCL); micro->TwiCmdXmit(NO_OP, UNKNOWNC); micro->TwiCmdXmit(RESETMCU, ACKRESET); delete micro; delay(5000); ESP.restart(); } } delay(1000); } Timonel *tml_pool[tml_count]; // // ************************************************** // * Create and initialize bootloader objects found * // ************************************************** for (uint8_t i = 0; i <= (tml_count); i++) { if (dev_info_arr[i].firmware == "Timonel") { tml_pool[i] = new Timonel(dev_info_arr[i].addr, SDA, SCL); USE_SERIAL.printf_P("\n\rGetting status of Timonel device %d\n\r", dev_info_arr[i].addr); Timonel::Status sts = tml_pool[i]->GetStatus(); if ((sts.features_code >> F_APP_AUTORUN) & true) { USE_SERIAL.printf_P("\n\r ***************************************************************************************\n\r"); USE_SERIAL.printf_P(" * WARNING! The Timonel bootloader with TWI address %02d has the \"APP_AUTORUN\" feature. *\n\r", dev_info_arr[i].addr); USE_SERIAL.printf_P(" * enabled. This TWI master firmware can't control it properly! Please recompile it *\n\r"); USE_SERIAL.printf_P(" * using a configuration with that option disabled (e.g. \"tml-t85-small\"). *\n\r"); USE_SERIAL.printf_P(" ***************************************************************************************\n\r"); } } } USE_SERIAL.printf_P("\n\r"); ThreeStarDelay(); USE_SERIAL.printf_P("\n\n\r"); // // ********************************************* // * Delete user applications from all devices * // ********************************************* for (uint8_t i = 0; i <= (tml_count); i++) { if (dev_info_arr[i].firmware == "Timonel") { delay(10); USE_SERIAL.printf_P("Deleting application on device %d ", dev_info_arr[i].addr); uint8_t errors = tml_pool[i]->DeleteApplication(); // delay(500); // tml_pool[i]->TwiCmdXmit(RESETMCU, ACKRESET); // delay(500); if (errors == 0) { USE_SERIAL.printf_P("OK!\n\r"); } else { USE_SERIAL.printf_P("Error! (%d)\n\r", errors); //Wire.begin(SDA, SCL); } delay(1000); USE_SERIAL.printf_P("\n\rGetting status of device %d\n\r", dev_info_arr[i].addr); tml_pool[i]->GetStatus(); PrintStatus(tml_pool[i]); } } ThreeStarDelay(); USE_SERIAL.printf_P("\n\r"); // // *************************************************** // * Upload and run user applications on all devices * // *************************************************** for (uint8_t i = 0; i <= (tml_count); i++) { if (dev_info_arr[i].firmware == "Timonel") { USE_SERIAL.printf_P("\n\rUploading application to device %d, \x1b[5mPLEASE WAIT\x1b[0m ...", dev_info_arr[i].addr); uint8_t errors = tml_pool[i]->UploadApplication(payload, sizeof(payload)); if (errors == 0) { USE_SERIAL.printf_P("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b successful! \n\r"); } else { USE_SERIAL.printf_P("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b error! (%d) \n\r", errors); } delay(10); USE_SERIAL.printf_P("\n\rGetting status of device %d\n\r", dev_info_arr[i].addr); tml_pool[i]->GetStatus(); PrintStatus(tml_pool[i]); delay(10); // // If the Timonel features support it, dump the device memory // Timonel::Status sts = tml_pool[i]->GetStatus(); // if ((sts.features_code >> F_CMD_READFLASH) & true) { // USE_SERIAL.printf_P("\n\rDumping device %d flash memory\n\r", dev_info_arr[i].addr); // tml_pool[i]->DumpMemory(MCU_TOTAL_MEM, SLV_PACKET_SIZE, 32); // } USE_SERIAL.printf_P("Running application on device %d\n\r", dev_info_arr[i].addr); errors = tml_pool[i]->RunApplication(); delay(500); if (errors == 0) { USE_SERIAL.printf_P("User application should be running\n\r"); } else { USE_SERIAL.printf_P("Bootloader exit to app error! (%d) \n\r", errors); } delay(10); delete tml_pool[i]; delay(1500); } } // // ************************************************************************ // * Reset applications and prepare for another cycle, then clean objects * // ************************************************************************ if (loop < LOOP_COUNT - 1) { uint8_t dly = 10; USE_SERIAL.printf_P("\n\rLetting application run %d seconds before resetting and starting next cycle ", dly); while (dly--) { USE_SERIAL.printf_P("\b\b| "); delay(250); USE_SERIAL.printf_P("\b\b/ "); delay(250); USE_SERIAL.printf_P("\b\b- "); delay(250); USE_SERIAL.printf_P("\b\b\\ "); delay(250); } USE_SERIAL.printf_P("\b\b* "); USE_SERIAL.printf_P("\n\n\r"); // Resetting devices // NOTE: All devices share the same application, since the application TWI address is // set at compile time, this is shared across all devices when the app is running. // Once discovered, the app TWI address is used to send the reset command to all devices. uint8_t app_addr = twi_bus.ScanBus(); //NbMicro *micro = new NbMicro(0, SDA, SCL); NbMicro *micro = new NbMicro(app_addr, SDA, SCL); //micro->SetTwiAddress(app_addr); /* NOTE: All devices share the same TWI application address (44) */ USE_SERIAL.printf_P("Resetting devices running application at address %d\n\r", micro->GetTwiAddress()); micro->TwiCmdXmit(RESETMCU, ACKRESET); delay(1000); delete micro; Wire.begin(SDA, SCL); } else { USE_SERIAL.printf_P("\n\rCycle completed %d of %d passes! Letting application run ...\n\n\r", LOOP_COUNT, LOOP_COUNT); } // for (uint8_t i = 0; i < tml_count; i++) { // delete tml_pool[i]; // } } delay(3000); } /* _________________ | | | Main loop | |_________________| */ void loop() { // Nothing } // Determine if there is a user application update available bool CheckApplUpdate(void) { return false; } // Function clear screen void ClrScr() { USE_SERIAL.write(27); // ESC command USE_SERIAL.print("[2J"); // clear screen command USE_SERIAL.write(27); // ESC command USE_SERIAL.print("[H"); // cursor to home command } // Function PrintLogo void PrintLogo(void) { USE_SERIAL.printf_P(" _ _\n\r"); USE_SERIAL.printf_P(" _ (_) | |\n\r"); USE_SERIAL.printf_P(" _| |_ _ ____ ___ ____ _____| |\n\r"); USE_SERIAL.printf_P(" (_ _) | \\ / _ \\| _ \\| ___ | |\n\r"); USE_SERIAL.printf_P(" | |_| | | | | |_| | | | | ____| |\n\r"); USE_SERIAL.printf_P(" \\__)_|_|_|_|\\___/|_| |_|_____)\\_)\n\r"); } // Function print Timonel instance status Timonel::Status PrintStatus(Timonel *timonel) { Timonel::Status tml_status = timonel->GetStatus(); /* Get the instance id parameters received from the ATTiny85 */ uint8_t twi_address = timonel->GetTwiAddress(); uint8_t version_major = tml_status.version_major; uint8_t version_minor = tml_status.version_minor; uint16_t app_start = tml_status.application_start; uint8_t app_start_msb = ((tml_status.application_start >> 8) & 0xFF); uint8_t app_start_lsb = (tml_status.application_start & 0xFF); uint16_t trampoline = ((~(((app_start_lsb << 8) | app_start_msb) & 0xFFF)) + 1); trampoline = ((((tml_status.bootloader_start >> 1) - trampoline) & 0xFFF) << 1); if ((tml_status.signature == T_SIGNATURE) && ((version_major != 0) || (version_minor != 0))) { String version_mj_nick = ""; switch (version_major) { case 0: { version_mj_nick = "\"Pre-release\""; break; } case 1: { version_mj_nick = "\"Sandra\""; break; } default: { version_mj_nick = "\"Unknown\""; break; } } USE_SERIAL.printf_P("\n\r Timonel v%d.%d %s ", version_major, version_minor, version_mj_nick.c_str()); USE_SERIAL.printf_P("(TWI: %02d)\n\r", twi_address); USE_SERIAL.printf_P(" ====================================\n\r"); USE_SERIAL.printf_P(" Bootloader address: 0x%X\n\r", tml_status.bootloader_start); if (app_start != 0xFFFF) { USE_SERIAL.printf_P(" Application start: 0x%04X (0x%X)\n\r", app_start, trampoline); } else { USE_SERIAL.printf_P(" Application start: 0x%04X (Not Set)\n\r", app_start); } USE_SERIAL.printf_P(" Features code: %d | %d ", tml_status.features_code, tml_status.ext_features_code); if ((tml_status.ext_features_code >> E_AUTO_CLK_TWEAK) & true) { USE_SERIAL.printf_P("(Auto)"); } else { USE_SERIAL.printf_P("(Fixed)"); } USE_SERIAL.printf_P("\n\r"); USE_SERIAL.printf_P(" Low fuse: 0x%02X\n\r", tml_status.low_fuse_setting); USE_SERIAL.printf_P(" RC osc: 0x%02X", tml_status.oscillator_cal); #if ((defined EXT_FEATURES) && ((EXT_FEATURES >> E_CMD_READDEVS) & true)) if ((tml_status.ext_features_code >> E_CMD_READDEVS) & true) { Timonel::DevSettings dev_settings = timonel->GetDevSettings(); USE_SERIAL.printf_P("\n\r ....................................\n\r"); USE_SERIAL.printf_P(" Fuse settings: L=0x%02X H=0x%02X E=0x%02X\n\r", dev_settings.low_fuse_bits, dev_settings.high_fuse_bits, dev_settings.extended_fuse_bits); USE_SERIAL.printf_P(" Lock bits: 0x%02X\n\r", dev_settings.lock_bits); USE_SERIAL.printf_P(" Signature: 0x%02X 0x%02X 0x%02X\n\r", dev_settings.signature_byte_0, dev_settings.signature_byte_1, dev_settings.signature_byte_2); USE_SERIAL.printf_P(" Oscillator: 8.0Mhz=0x%02X, 6.4Mhz=0x%02X", dev_settings.calibration_0, dev_settings.calibration_1); } #endif // E_CMD_READDEVS USE_SERIAL.printf_P("\n\n\r"); } else { USE_SERIAL.printf_P("\n\r *************************************************\n\r"); USE_SERIAL.printf_P(" * User application running on TWI device %02d ... *\n\r", twi_address); USE_SERIAL.printf_P(" *************************************************\n\n\r"); } return tml_status; } // Function ThreeStarDelay void ThreeStarDelay(void) { delay(2000); for (uint8_t i = 0; i < 3; i++) { USE_SERIAL.printf_P("*"); delay(1000); } } // Function ShowHeader void ShowHeader(void) { delay(250); USE_SERIAL.printf_P("\n\r............................................................\n\r"); USE_SERIAL.printf_P(". Timonel I2C Bootloader and Application Test (v%d.%d.%d MMS) .\n\r", VER_MAJOR, VER_MINOR, VER_PATCH); USE_SERIAL.printf_P("............................................................\n\r"); }
[ "gustavo.casanova@nicebots.com" ]
gustavo.casanova@nicebots.com
ab5b1c128b1aee7851254293003423a6e181b0e1
9055c46b4e67e24ef7f3bad1cf0299a284f98dad
/Poker/Poker/cards.hpp
25164ad87dae54cfa2fe512f7fa84353046f0651
[]
no_license
JCBenR/For_Employers
534eba29547145290d8d2dddaa0835f3f40a8522
a77c13dfedef7b324ee9c0e8c753fd60920f7e9a
refs/heads/main
2023-06-01T17:43:52.230147
2021-06-10T22:33:56
2021-06-10T22:33:56
371,510,275
0
0
null
null
null
null
UTF-8
C++
false
false
1,215
hpp
// // cards.hpp // Poker // // Created by Justin Siebenhaar on 9/1/20. // Copyright © 2020 Justin Siebenhaar. All rights reserved. // #ifndef cards_hpp #define cards_hpp #include <stdio.h> #include <iostream> #include <vector> //each card has a rank, suit, and these two values for max nums struct Card { int rankNum; std::string rank; std::string suit; int num_suits = 4; int num_ranks = 13; }; //each deck is made up of a vector of cards, each item being the type of Card. it also has a max size of 52. struct Deck { std::vector<Card> cards; int maxSize = 52; }; //declaring our functions using references. void getDeck(Deck&); void printDeck(Deck&); void shuffle(Deck& deck); Deck hand(Deck& deck); void printHand(Deck& deck); bool isFlush(Deck& deck); int findMin(Deck& deck); bool Contains(Deck& deck, int lookFor); //bool compareCards (Card a, Card b); bool isStraight(Deck& deck); bool isStraight2(Deck& deck); bool isStraightFlush(Deck& deck); bool isRoyalFlush(Deck& deck); bool isFullHouse(Deck& deck); //HELPER FUNCTIONS void swap(Card& value1, Card& value2); int smallestIndex(Deck& deck, int startIdx); void selectionSortHand(Deck& deck); #endif /* cards_hpp */
[ "jsieb81@gmail.com" ]
jsieb81@gmail.com
81993f27a3fc96c8e2549da8cb17b5a4e39fbf92
ee2f5720459c9423a2ee771b6f86b8dd540f402e
/SDL-NetFramework/SDL-NetFramework/PaddleBehaviour.cpp
c46752742a601664825ef762bd5d36f25a6b3ed9
[]
no_license
dym99/SDL-NetFramework
a76124f9c90880572fe34e2bf322e8d75c61cb0d
ccff7856a600f3e268eee15d40a97cf3f9a71a37
refs/heads/master
2021-02-16T12:47:19.826304
2020-03-13T04:13:05
2020-03-13T04:13:05
245,006,861
0
0
null
null
null
null
UTF-8
C++
false
false
1,885
cpp
//Dylan Moore - 100662175 //Sydney Caldwell - 100652057 #include "PaddleBehaviour.h" #include "Sprite.h" #include "Events.h" #include "Time.h" #include "Debug.h" #include "Physics.h" #include "Net.h" #include "PuckBehaviour.h" #include <sstream> PaddleBehaviour::PaddleBehaviour(bool server, sockaddr* addrinfo, int namelen, Sprite* puck) { m_server = server; m_addrinfo = addrinfo; m_namelen = namelen; m_puck = puck; m_lastPos = glm::vec2(); m_speed = 0; } PaddleBehaviour::~PaddleBehaviour() { } void PaddleBehaviour::init() { } void PaddleBehaviour::update() { int x, y; EVENTS->getMousePosition(&x, &y); glm::vec2 position = { (float)x, (float)y }; std::stringstream message; message << "[paddle]" << position.x << "," << position.y; if (m_server) { Net::sendToUDP(m_addrinfo, m_namelen, message.str()); } else { Net::sendToUDP(m_addrinfo, m_namelen, message.str()); } //std::string message = Net::recvFromUDP(m_addrinfo, &m_namelen); //glm::vec2 position; //sscanf(message.c_str(), "%f,%f", &position.x, &position.y); m_lastPos = getSprite()->getPosition() + (getSprite()->getDimensions() * 0.5f); getSprite()->setPosition((position - getSprite()->getDimensions() * 0.5f)); m_speed = glm::distance(m_lastPos, position)/Time::deltaTime; glm::vec2 puckpos = m_puck->getPosition() + m_puck->getDimensions() * 0.5f; if (Physics::CollisionCircleCircle(position, 24.0f, puckpos, 16.0f)) { //Bounce glm::vec2 dir = glm::vec2(); dir = glm::normalize(puckpos - position) * m_speed; std::stringstream puckMessage; puckMessage << "[puck]" << puckpos.x << "," << puckpos.y << "," << dir.x << "," << dir.y; if (m_server) { Net::sendToUDP(m_addrinfo, m_namelen, puckMessage.str()); } else { Net::sendToUDP(m_addrinfo, m_namelen, puckMessage.str()); } m_puck->getBehaviour<PuckBehaviour>()->hit(puckpos, dir); } }
[ "dylan.moore@insanitycorr.com" ]
dylan.moore@insanitycorr.com
0abaf21b4e836837c9c98aa96139275e2c859868
778528e1b1edb0f91e39c8b5d9925054ece59c70
/resources/ui_newcharacter.h
fb0e3cab0321908d2e7dc83b6aafa6323efcd4ff
[]
no_license
sintell/AutoRPG
3812b5db3030c41e614ae3f8dbff2fc174093138
b924050fe38bbdc326eb24ec79c4204c1a5402e4
refs/heads/master
2016-09-05T14:59:28.414518
2013-04-25T21:24:14
2013-04-25T21:24:14
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,316
h
/******************************************************************************** ** Form generated from reading UI file 'newcharacter.ui' ** ** Created: Mon Apr 22 01:47:54 2013 ** by: Qt User Interface Compiler version 4.8.1 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ #ifndef UI_NEWCHARACTER_H #define UI_NEWCHARACTER_H #include <QtCore/QVariant> #include <QtGui/QAction> #include <QtGui/QApplication> #include <QtGui/QButtonGroup> #include <QtGui/QComboBox> #include <QtGui/QDialog> #include <QtGui/QDialogButtonBox> #include <QtGui/QFrame> #include <QtGui/QGridLayout> #include <QtGui/QGroupBox> #include <QtGui/QHeaderView> #include <QtGui/QLabel> #include <QtGui/QLineEdit> #include <QtGui/QPushButton> #include <QtGui/QSpinBox> #include <QtGui/QVBoxLayout> QT_BEGIN_NAMESPACE class Ui_NewCharacter { public: QVBoxLayout *verticalLayout; QGroupBox *groupBox; QGridLayout *gridLayout_2; QLabel *label_2; QComboBox *cb_chClass; QLabel *label; QLineEdit *le_chName; QComboBox *cb_chRace; QLabel *label_3; QGroupBox *groupBox_2; QGridLayout *gridLayout; QLabel *label_6; QSpinBox *sb_chStr; QLabel *label_4; QLabel *lb_PointsLeft; QSpinBox *sb_chCon; QLabel *label_5; QSpinBox *sb_chInt; QSpinBox *sb_chDex; QLabel *label_8; QFrame *line; QPushButton *pb_ResetStats; QLabel *label_7; QDialogButtonBox *buttonBox; void setupUi(QDialog *NewCharacter) { if (NewCharacter->objectName().isEmpty()) NewCharacter->setObjectName(QString::fromUtf8("NewCharacter")); NewCharacter->setWindowModality(Qt::WindowModal); NewCharacter->resize(347, 379); NewCharacter->setModal(true); verticalLayout = new QVBoxLayout(NewCharacter); verticalLayout->setObjectName(QString::fromUtf8("verticalLayout")); groupBox = new QGroupBox(NewCharacter); groupBox->setObjectName(QString::fromUtf8("groupBox")); gridLayout_2 = new QGridLayout(groupBox); gridLayout_2->setObjectName(QString::fromUtf8("gridLayout_2")); label_2 = new QLabel(groupBox); label_2->setObjectName(QString::fromUtf8("label_2")); gridLayout_2->addWidget(label_2, 1, 0, 1, 1); cb_chClass = new QComboBox(groupBox); cb_chClass->setObjectName(QString::fromUtf8("cb_chClass")); gridLayout_2->addWidget(cb_chClass, 2, 1, 1, 1); label = new QLabel(groupBox); label->setObjectName(QString::fromUtf8("label")); gridLayout_2->addWidget(label, 0, 0, 1, 1); le_chName = new QLineEdit(groupBox); le_chName->setObjectName(QString::fromUtf8("le_chName")); gridLayout_2->addWidget(le_chName, 0, 1, 1, 1); cb_chRace = new QComboBox(groupBox); cb_chRace->setObjectName(QString::fromUtf8("cb_chRace")); gridLayout_2->addWidget(cb_chRace, 1, 1, 1, 1); label_3 = new QLabel(groupBox); label_3->setObjectName(QString::fromUtf8("label_3")); gridLayout_2->addWidget(label_3, 2, 0, 1, 1); verticalLayout->addWidget(groupBox); groupBox_2 = new QGroupBox(NewCharacter); groupBox_2->setObjectName(QString::fromUtf8("groupBox_2")); gridLayout = new QGridLayout(groupBox_2); gridLayout->setObjectName(QString::fromUtf8("gridLayout")); label_6 = new QLabel(groupBox_2); label_6->setObjectName(QString::fromUtf8("label_6")); gridLayout->addWidget(label_6, 2, 0, 1, 1); sb_chStr = new QSpinBox(groupBox_2); sb_chStr->setObjectName(QString::fromUtf8("sb_chStr")); sb_chStr->setReadOnly(false); sb_chStr->setButtonSymbols(QAbstractSpinBox::UpDownArrows); gridLayout->addWidget(sb_chStr, 0, 1, 1, 2); label_4 = new QLabel(groupBox_2); label_4->setObjectName(QString::fromUtf8("label_4")); gridLayout->addWidget(label_4, 0, 0, 1, 1); lb_PointsLeft = new QLabel(groupBox_2); lb_PointsLeft->setObjectName(QString::fromUtf8("lb_PointsLeft")); QFont font; font.setPointSize(11); font.setBold(true); font.setItalic(true); font.setWeight(75); lb_PointsLeft->setFont(font); gridLayout->addWidget(lb_PointsLeft, 8, 1, 1, 1); sb_chCon = new QSpinBox(groupBox_2); sb_chCon->setObjectName(QString::fromUtf8("sb_chCon")); sb_chCon->setReadOnly(false); gridLayout->addWidget(sb_chCon, 2, 1, 1, 2); label_5 = new QLabel(groupBox_2); label_5->setObjectName(QString::fromUtf8("label_5")); gridLayout->addWidget(label_5, 1, 0, 1, 1); sb_chInt = new QSpinBox(groupBox_2); sb_chInt->setObjectName(QString::fromUtf8("sb_chInt")); sb_chInt->setMinimumSize(QSize(0, 27)); sb_chInt->setReadOnly(false); gridLayout->addWidget(sb_chInt, 3, 1, 1, 2); sb_chDex = new QSpinBox(groupBox_2); sb_chDex->setObjectName(QString::fromUtf8("sb_chDex")); sb_chDex->setMinimumSize(QSize(0, 27)); sb_chDex->setReadOnly(false); gridLayout->addWidget(sb_chDex, 1, 1, 1, 2); label_8 = new QLabel(groupBox_2); label_8->setObjectName(QString::fromUtf8("label_8")); label_8->setFont(font); label_8->setTextFormat(Qt::AutoText); label_8->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); gridLayout->addWidget(label_8, 8, 0, 1, 1); line = new QFrame(groupBox_2); line->setObjectName(QString::fromUtf8("line")); line->setFrameShape(QFrame::HLine); line->setFrameShadow(QFrame::Sunken); gridLayout->addWidget(line, 5, 0, 3, 3); pb_ResetStats = new QPushButton(groupBox_2); pb_ResetStats->setObjectName(QString::fromUtf8("pb_ResetStats")); gridLayout->addWidget(pb_ResetStats, 8, 2, 1, 1); label_7 = new QLabel(groupBox_2); label_7->setObjectName(QString::fromUtf8("label_7")); gridLayout->addWidget(label_7, 3, 0, 1, 1); verticalLayout->addWidget(groupBox_2); buttonBox = new QDialogButtonBox(NewCharacter); buttonBox->setObjectName(QString::fromUtf8("buttonBox")); buttonBox->setOrientation(Qt::Horizontal); buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); verticalLayout->addWidget(buttonBox); #ifndef QT_NO_SHORTCUT label_2->setBuddy(cb_chRace); label->setBuddy(le_chName); label_3->setBuddy(cb_chClass); label_6->setBuddy(sb_chCon); label_4->setBuddy(sb_chStr); label_5->setBuddy(sb_chDex); label_7->setBuddy(sb_chInt); #endif // QT_NO_SHORTCUT QWidget::setTabOrder(le_chName, cb_chRace); QWidget::setTabOrder(cb_chRace, cb_chClass); QWidget::setTabOrder(cb_chClass, sb_chStr); QWidget::setTabOrder(sb_chStr, sb_chDex); QWidget::setTabOrder(sb_chDex, sb_chCon); QWidget::setTabOrder(sb_chCon, sb_chInt); QWidget::setTabOrder(sb_chInt, buttonBox); QWidget::setTabOrder(buttonBox, pb_ResetStats); retranslateUi(NewCharacter); QObject::connect(buttonBox, SIGNAL(accepted()), NewCharacter, SLOT(accept())); QObject::connect(buttonBox, SIGNAL(rejected()), NewCharacter, SLOT(reject())); QMetaObject::connectSlotsByName(NewCharacter); } // setupUi void retranslateUi(QDialog *NewCharacter) { NewCharacter->setWindowTitle(QApplication::translate("NewCharacter", "Creane new character", 0, QApplication::UnicodeUTF8)); #ifndef QT_NO_WHATSTHIS NewCharacter->setWhatsThis(QApplication::translate("NewCharacter", "Character creation dialog", 0, QApplication::UnicodeUTF8)); #endif // QT_NO_WHATSTHIS groupBox->setTitle(QApplication::translate("NewCharacter", "Information", 0, QApplication::UnicodeUTF8)); label_2->setText(QApplication::translate("NewCharacter", "Race", 0, QApplication::UnicodeUTF8)); cb_chClass->clear(); cb_chClass->insertItems(0, QStringList() << QApplication::translate("NewCharacter", "Warrior", 0, QApplication::UnicodeUTF8) << QApplication::translate("NewCharacter", "Rogue", 0, QApplication::UnicodeUTF8) << QApplication::translate("NewCharacter", "Mage", 0, QApplication::UnicodeUTF8) ); label->setText(QApplication::translate("NewCharacter", "Name", 0, QApplication::UnicodeUTF8)); le_chName->setText(QString()); le_chName->setPlaceholderText(QApplication::translate("NewCharacter", "Leave blank to generate random name", 0, QApplication::UnicodeUTF8)); cb_chRace->clear(); cb_chRace->insertItems(0, QStringList() << QApplication::translate("NewCharacter", "Human", 0, QApplication::UnicodeUTF8) << QApplication::translate("NewCharacter", "Elf", 0, QApplication::UnicodeUTF8) << QApplication::translate("NewCharacter", "Orc", 0, QApplication::UnicodeUTF8) ); label_3->setText(QApplication::translate("NewCharacter", "Class", 0, QApplication::UnicodeUTF8)); groupBox_2->setTitle(QApplication::translate("NewCharacter", "Characteristics", 0, QApplication::UnicodeUTF8)); label_6->setText(QApplication::translate("NewCharacter", "Constitution", 0, QApplication::UnicodeUTF8)); label_4->setText(QApplication::translate("NewCharacter", "Strength", 0, QApplication::UnicodeUTF8)); lb_PointsLeft->setText(QApplication::translate("NewCharacter", "0", 0, QApplication::UnicodeUTF8)); label_5->setText(QApplication::translate("NewCharacter", "Dexterity", 0, QApplication::UnicodeUTF8)); label_8->setText(QApplication::translate("NewCharacter", "Points left to spend:", 0, QApplication::UnicodeUTF8)); pb_ResetStats->setText(QApplication::translate("NewCharacter", "Reset", 0, QApplication::UnicodeUTF8)); label_7->setText(QApplication::translate("NewCharacter", "Intelegence", 0, QApplication::UnicodeUTF8)); } // retranslateUi }; namespace Ui { class NewCharacter: public Ui_NewCharacter {}; } // namespace Ui QT_END_NAMESPACE #endif // UI_NEWCHARACTER_H
[ "uyiiio@gmail.com" ]
uyiiio@gmail.com
a47f72477aa37727ae44e786d210a367fe9dd3c4
dd9b5bdca831aa90b6572a59d15a314230cd4e45
/test4.cpp
55d453dcaf72ee0ddb15d5f96d5c6af3f432a96c
[]
no_license
kishankr7979/CP
62fdea662b391a132cdb2b55dc2a845e44790d53
150e304eea519a964d34e4e9ffd49cac5dad5198
refs/heads/main
2023-06-18T06:47:52.908559
2021-07-17T14:26:25
2021-07-17T14:26:25
null
0
0
null
null
null
null
UTF-8
C++
false
false
634
cpp
#include <bits/stdc++.h> using namespace std; using ll = long long; void solve(string s, int i, string r, string &prev, int &count) { if (i == s.size()) { if (r > prev) { prev = r; count++; cout << r << ' '; } return; } for (int j = i; j < s.size(); j++) { solve(s, i + 1, r + r.substr(i, j - i + 1), prev, count); } } int main() { ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int t; cin >> t; cin.ignore(); while (t--) { int n; cin >> n; string s; cin >> s; string r, prev; int count = 0; solve(s, 0, r, prev, count); cout << count << endl; } return 0; }
[ "umaidansari123@gmail.com" ]
umaidansari123@gmail.com
e19652ece8f7e0e4575398a71e5e838a494ad4cc
424d9d65e27cd204cc22e39da3a13710b163f4e7
/ash/login/ui/login_error_bubble.cc
13d4107ec935b361d3712e0b208eb0690ff92d0a
[ "BSD-3-Clause" ]
permissive
bigben0123/chromium
7c5f4624ef2dacfaf010203b60f307d4b8e8e76d
83d9cd5e98b65686d06368f18b4835adbab76d89
refs/heads/master
2023-01-10T11:02:26.202776
2020-10-30T09:47:16
2020-10-30T09:47:16
275,543,782
0
0
BSD-3-Clause
2020-10-30T09:47:18
2020-06-28T08:45:11
null
UTF-8
C++
false
false
2,178
cc
// Copyright 2018 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ash/login/ui/login_error_bubble.h" #include "ash/login/ui/non_accessible_view.h" #include "ash/login/ui/views_utils.h" #include "ash/public/cpp/shell_window_ids.h" #include "ash/resources/vector_icons/vector_icons.h" #include "ash/shell.h" #include "ui/accessibility/ax_enums.mojom.h" #include "ui/accessibility/ax_node_data.h" #include "ui/gfx/paint_vector_icon.h" #include "ui/views/controls/image_view.h" #include "ui/views/controls/label.h" #include "ui/views/layout/box_layout.h" #include "ui/views/layout/fill_layout.h" namespace ash { namespace { // The size of the alert icon in the error bubble. constexpr int kAlertIconSizeDp = 20; } // namespace LoginErrorBubble::LoginErrorBubble() : LoginErrorBubble(nullptr /*content*/, nullptr /*anchor_view*/) {} LoginErrorBubble::LoginErrorBubble(views::View* content, views::View* anchor_view) : LoginBaseBubbleView(anchor_view) { views::ImageView* alert_icon = new views::ImageView(); alert_icon->SetPreferredSize(gfx::Size(kAlertIconSizeDp, kAlertIconSizeDp)); alert_icon->SetImage( gfx::CreateVectorIcon(kLockScreenAlertIcon, SK_ColorWHITE)); AddChildView(alert_icon); if (content) { content_ = content; AddChildView(content); } } LoginErrorBubble::~LoginErrorBubble() = default; void LoginErrorBubble::SetContent(views::View* content) { if (content_) delete content_; content_ = content; AddChildView(content_); } void LoginErrorBubble::SetTextContent(const base::string16& message) { SetContent( login_views_utils::CreateBubbleLabel(message, gfx::kGoogleGrey200, this)); } void LoginErrorBubble::SetAccessibleName(const base::string16& name) { accessible_name_ = name; } const char* LoginErrorBubble::GetClassName() const { return "LoginErrorBubble"; } void LoginErrorBubble::GetAccessibleNodeData(ui::AXNodeData* node_data) { node_data->role = ax::mojom::Role::kAlertDialog; node_data->SetName(accessible_name_); } } // namespace ash
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
b7e264c6f811ad8a47a506b9ca95a25070240699
fd7223bfc36dfec1513abf9b0f8d8aef5f17956d
/Gunz/Stable/REALSPACE/Source/Profiler.cpp
9e295ef3ad194e3aaad8c0e9936d24c277d35a4d
[]
no_license
tehKaiN/node3d
6ca77ecb54a978d563a1e2fbafb70b75112193f7
b5a6c33986b4791fb5201cb30e6fbcb26b7eac4d
refs/heads/master
2020-09-01T17:44:45.291690
2018-10-17T08:58:25
2018-10-17T08:58:25
null
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
9,132
cpp
#include <stdio.h> #include "CMError.h" #include "CMErrorDef.h" #include "Profiler.h" #include "Libpak.h" BOOL Profiler::Load(char* szFileName) { FILE* fp = NULL; char strBuf[BUF_SIZE+1]; m_ProfileList.DeleteAll(); strcpy(m_strFileName, szFileName); fp = fopen(m_strFileName, "rt"); if (fp == NULL) { // SetError(CMERR_CANT_OPEN_FILE); return FALSE; } for (;;) { if (!ReadLine(fp, strBuf)) break; if (!*strBuf) break; if(strBuf[0]==';') continue; if(strBuf[0]=='/'&&strBuf[1]=='/') continue; Parse(strBuf); memset(strBuf, 0, BUF_SIZE+1); } fclose(fp); m_IdxFinded = -1; return TRUE; } /* char temp[BUF_SIZE+1]; do { if (!fgets(temp, BUF_SIZE, fl)) return FALSE; if (*temp) { temp[strlen(temp)] = '\0'; if (temp[strlen(temp)-1] == '\n') temp[strlen(temp)-1] = '\0'; } } while (!feof(fl) && (!*temp)); strcpy(buf, temp); return TRUE; */ int g_sp; bool sReadLine(char* str,char* data) { int c = g_sp; int len = strlen(str); if(c >= len) return false; while( str[c] ) { if( str[c] == 0x0d) if( str[c+1]== 0x0a) break; c++; if(c == 0) break; if(c > len) break; } int size = c - g_sp; if(size == 0) { data[0] = ';'; data[1] = 0; g_sp += (size + 2); return true; } memcpy(data,(str+g_sp),size); g_sp += (size + 2); data[size] = 0; return true; } // ÀÛ¼ºÁß~ BOOL Profiler::LoadPak(char* szPakFileName,char* szFileName) { Package tPak; tPak.Open(szPakFileName); PakData *pPakData; pPakData = tPak.GetPakData( szFileName ); if(!pPakData) return FALSE; int Len = pPakData->GetFileSize(); char* pData = new char [Len+1]; if( !pData ) return FALSE; pPakData->ReadFile( pData, Len ); pData[Len] = 0; // FILE* fp = NULL; char strBuf[BUF_SIZE+1]; m_ProfileList.DeleteAll(); strcpy(m_strFileName, szFileName); // fp = fopen(m_strFileName, "rt"); // if (fp == NULL) return FALSE; g_sp = 0; for (;;) { if (!sReadLine(pData, strBuf)) break; if (!*strBuf) break; if(strBuf[0]==';') continue; if(strBuf[0]=='/'&&strBuf[1]=='/') continue; Parse(strBuf); memset(strBuf, 0, BUF_SIZE+1); } // fclose(fp); m_IdxFinded = -1; delete pPakData; delete [] pData; return TRUE; } BOOL Profiler::Save() { FILE* fp = NULL; fp = fopen(m_strFileName, "wt"); if (fp == NULL) { // SetError(CMERR_CANT_SAVE_FILE); return FALSE; } for (int i=0; i<m_ProfileList.GetCount(); i++) { PROFILENODE* pPROFILENODE = m_ProfileList.Get(i); if ((pPROFILENODE->pName==NULL) || (*pPROFILENODE->pName==' ') || (!*pPROFILENODE->pName)) continue; if ((pPROFILENODE->pValue==NULL) || (*pPROFILENODE->pValue==' ') || (!*pPROFILENODE->pValue)) continue; fprintf(fp, "%s=%s\n", pPROFILENODE->pName, pPROFILENODE->pValue); } fclose(fp); return TRUE; } void Profiler::Parse(char* strBuf) { char* pName; char* pValue; char Line[1024]; strcpy(Line,strBuf); int len = strlen(strBuf); pName = strtok(strBuf,"= \t;"); pValue = strtok(NULL, "= \t;"); if ((pName==NULL) || (*pName==' ') || (!*pName)) return; if ((pValue==NULL) || (*pValue==' ') || (!*pValue)) return; int arg_start = (pValue - pName); int arg_len = len - arg_start; PROFILENODE* pPROFILENODE = new PROFILENODE; pPROFILENODE->pName = new char[strlen(pName)+1]; pPROFILENODE->pValue = new char[strlen(pValue)+1]; pPROFILENODE->pArg = new char[arg_len+1]; strcpy(pPROFILENODE->pName, pName); strcpy(pPROFILENODE->pValue, pValue); memcpy(pPROFILENODE->pArg,(Line+arg_start), arg_len); pPROFILENODE->pArg[arg_len] = 0; m_ProfileList.Add(pPROFILENODE); } BOOL Profiler::Write(const char* pName, const char* pValue) { if ((pName==NULL) || (*pName==' ') || (!*pName)) return FALSE; if ((pValue==NULL) || (*pValue==' ') || (!*pValue)) return FALSE; PROFILENODE* pPROFILENODE = NULL; BOOL bNameFinded = FALSE; for (int i=0; i<m_ProfileList.GetCount(); i++) { PROFILENODE* pTmpPROFILENODE = m_ProfileList.Get(i); if ((pTmpPROFILENODE->pName==NULL)) continue; if (!strcmp(pName, pTmpPROFILENODE->pName)) { pPROFILENODE = pTmpPROFILENODE; bNameFinded = TRUE; break; } } if ((pPROFILENODE == NULL) || (bNameFinded == FALSE)) { pPROFILENODE = new PROFILENODE; pPROFILENODE->pName = new char[strlen(pName)+1]; pPROFILENODE->pValue = new char[strlen(pValue)+1]; } if (bNameFinded == TRUE) { int nNewLen = strlen(pValue) + 1; char* pszNewBuffer = new char[nNewLen]; delete [] pPROFILENODE->pValue; pPROFILENODE->pValue = pszNewBuffer; } if (bNameFinded == FALSE) strcpy(pPROFILENODE->pName, pName); strcpy(pPROFILENODE->pValue, pValue); if (bNameFinded == FALSE) m_ProfileList.Add(pPROFILENODE); Save(); m_IdxFinded = -1; return TRUE; } BOOL Profiler::Read(const char* pName, char* pBuf, int nBufSize) { for (int i=0; i<m_ProfileList.GetCount(); i++) { PROFILENODE* pPROFILENODE = m_ProfileList.Get(i); if ((pPROFILENODE->pName==NULL) || (*pPROFILENODE->pName==' ') || (!*pPROFILENODE->pName)) continue; if ((pPROFILENODE->pValue==NULL) || (*pPROFILENODE->pValue==' ') || (!*pPROFILENODE->pValue)) continue; if (!stricmp(pName, pPROFILENODE->pName)) { strncpy(pBuf, pPROFILENODE->pValue, nBufSize); return TRUE; } } return FALSE; } BOOL Profiler::ReadArg(const char* pName, char* pBuf, int nBufSize) { for (int i=0; i<m_ProfileList.GetCount(); i++) { PROFILENODE* pPROFILENODE = m_ProfileList.Get(i); if ((pPROFILENODE->pName==NULL) || (*pPROFILENODE->pName==' ') || (!*pPROFILENODE->pName)) continue; if ((pPROFILENODE->pValue==NULL) || (*pPROFILENODE->pValue==' ') || (!*pPROFILENODE->pValue)) continue; if (!stricmp(pName, pPROFILENODE->pName)) { strncpy(pBuf, pPROFILENODE->pArg, nBufSize); // memcpy(pBuf,pPROFILENODE->pArg,nBufSize); return TRUE; } } return FALSE; } BOOL Profiler::Read(const char* pName, char** ppValue) { for (int i=0; i<m_ProfileList.GetCount(); i++) { PROFILENODE* pPROFILENODE = m_ProfileList.Get(i); if ((pPROFILENODE->pName==NULL) || (*pPROFILENODE->pName==' ') || (!*pPROFILENODE->pName)) continue; if ((pPROFILENODE->pValue==NULL) || (*pPROFILENODE->pValue==' ') || (!*pPROFILENODE->pValue)) continue; if (!stricmp(pName, pPROFILENODE->pName)) { *ppValue = pPROFILENODE->pValue; return TRUE; } } return FALSE; } BOOL Profiler::Delete(const char* pName) { for (int i=0; i<m_ProfileList.GetCount(); i++) { PROFILENODE* pPROFILENODE = m_ProfileList.Get(i); if ((pPROFILENODE->pName==NULL) || (*pPROFILENODE->pName==' ') || (!*pPROFILENODE->pName)) continue; if ((pPROFILENODE->pValue==NULL) || (*pPROFILENODE->pValue==' ') || (!*pPROFILENODE->pValue)) continue; if (!strcmp(pName, pPROFILENODE->pName)) { m_ProfileList.Delete(i); Save(); m_IdxFinded = -1; return TRUE; } } return FALSE; } int Profiler::Find(const char* pName, const char* pValue) { for (int i=0; i<m_ProfileList.GetCount(); i++) { PROFILENODE* pPROFILENODE = m_ProfileList.Get(i); if ((pPROFILENODE->pName==NULL) || (*pPROFILENODE->pName==' ') || (!*pPROFILENODE->pName)) continue; if ((pPROFILENODE->pValue==NULL) || (*pPROFILENODE->pValue==' ') || (!*pPROFILENODE->pValue)) continue; if (pName != NULL) { if (!strcmp(pName, pPROFILENODE->pName)) { if (pValue == NULL) { m_IdxFinded = i; return i; } else { if (!strcmp(pValue, pPROFILENODE->pValue)) { m_IdxFinded = i; return i; } } } } else { if (pValue != NULL) if (!strcmp(pValue, pPROFILENODE->pValue)) { m_IdxFinded = i; return i; } } } return -1; } int Profiler::FindNext(const char* pName, const char* pValue) { if ((m_IdxFinded == -1) || (m_IdxFinded >= m_ProfileList.GetCount())) return -1; for (int i=m_IdxFinded+1; i<m_ProfileList.GetCount(); i++) { PROFILENODE* pPROFILENODE = m_ProfileList.Get(i); if ((pPROFILENODE->pName==NULL) || (*pPROFILENODE->pName==' ') || (!*pPROFILENODE->pName)) continue; if ((pPROFILENODE->pValue==NULL) || (*pPROFILENODE->pValue==' ') || (!*pPROFILENODE->pValue)) continue; if (pName != NULL) { if (!strcmp(pName, pPROFILENODE->pName)) { if (pValue == NULL) { m_IdxFinded = i; return i; } else { if (!strcmp(pValue, pPROFILENODE->pValue)) { m_IdxFinded = i; return i; } } } } else { if (pValue != NULL) if (!strcmp(pValue, pPROFILENODE->pValue)) { m_IdxFinded = i; return i; } } } return -1; } BOOL ReadLine(FILE* fl, char *buf) { char temp[BUF_SIZE+1]; do { if (!fgets(temp, BUF_SIZE, fl)) return FALSE; if (*temp) { temp[strlen(temp)] = '\0'; if (temp[strlen(temp)-1] == '\n') temp[strlen(temp)-1] = '\0'; } } while (!feof(fl) && (!*temp)); strcpy(buf, temp); return TRUE; }
[ "huihui27@126.com@2d1ece96-c13f-8cac-2818-407c75b61fa3" ]
huihui27@126.com@2d1ece96-c13f-8cac-2818-407c75b61fa3
4e343f6df6b64018b27be9455ee4e4c57dc2925b
a03a7935a191d63bee76fd3b85a61ee27f98904a
/src/visitpy/visitpy/PyQueryAttributes.h
c457fee8c4d01ee96093b8a7ee21ed1ab1f356bf
[]
no_license
cchriste/visit
57091c4a512ab87efd17c64c7494aa4cf01b7e53
c72c413f571e56b52fb7221955219f11f4ba19e3
refs/heads/master
2020-04-12T06:25:27.458132
2015-10-12T15:41:49
2015-10-12T15:41:49
10,111,791
5
1
null
null
null
null
UTF-8
C++
false
false
3,494
h
/***************************************************************************** * * Copyright (c) 2000 - 2015, Lawrence Livermore National Security, LLC * Produced at the Lawrence Livermore National Laboratory * LLNL-CODE-442911 * All rights reserved. * * This file is part of VisIt. For details, see https://visit.llnl.gov/. The * full copyright notice is contained in the file COPYRIGHT located at the root * of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html. * * 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 disclaimer below. * - Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the disclaimer (as noted below) in the * documentation and/or other materials provided with the distribution. * - Neither the name of the LLNS/LLNL nor the names of its contributors may * be used to endorse or promote products derived from this software without * specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, * LLC, THE U.S. DEPARTMENT OF ENERGY 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. * *****************************************************************************/ #ifndef PY_QUERYATTRIBUTES_H #define PY_QUERYATTRIBUTES_H #include <Python.h> #include <QueryAttributes.h> #include <visitpy_exports.h> // // Functions exposed to the VisIt module. // #define QUERYATTRIBUTES_NMETH 18 void VISITPY_API PyQueryAttributes_StartUp(QueryAttributes *subj, void *data); void VISITPY_API PyQueryAttributes_CloseDown(); VISITPY_API PyMethodDef * PyQueryAttributes_GetMethodTable(int *nMethods); bool VISITPY_API PyQueryAttributes_Check(PyObject *obj); VISITPY_API QueryAttributes * PyQueryAttributes_FromPyObject(PyObject *obj); VISITPY_API PyObject * PyQueryAttributes_New(); VISITPY_API PyObject * PyQueryAttributes_Wrap(const QueryAttributes *attr); void VISITPY_API PyQueryAttributes_SetParent(PyObject *obj, PyObject *parent); void VISITPY_API PyQueryAttributes_SetDefaults(const QueryAttributes *atts); std::string VISITPY_API PyQueryAttributes_GetLogString(); std::string VISITPY_API PyQueryAttributes_ToString(const QueryAttributes *, const char *); VISITPY_API PyObject * PyQueryAttributes_getattr(PyObject *self, char *name); int VISITPY_API PyQueryAttributes_setattr(PyObject *self, char *name, PyObject *args); VISITPY_API extern PyMethodDef PyQueryAttributes_methods[QUERYATTRIBUTES_NMETH]; #endif
[ "bonnell@18c085ea-50e0-402c-830e-de6fd14e8384" ]
bonnell@18c085ea-50e0-402c-830e-de6fd14e8384
35742d8ab5c349476d8a89da1b3bc1af008bf20f
36e10bf1c40c33927b294bec5349c178ed80af1a
/voxgraph/include/voxgraph/tools/data_servers/submap_server.h
830f1e34199cf8db886b96ac7daba8c678b98744
[ "BSD-2-Clause" ]
permissive
arenas7307979/voxgraph
57882a30d4a9bf0398dc751866648449f2ef3677
74a46ff1e9b71feea73fc34a71b3a286792269ac
refs/heads/master
2022-06-05T13:44:19.009895
2020-04-27T23:56:05
2020-04-28T09:43:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,603
h
#ifndef VOXGRAPH_TOOLS_DATA_SERVERS_SUBMAP_SERVER_H_ #define VOXGRAPH_TOOLS_DATA_SERVERS_SUBMAP_SERVER_H_ #include <std_msgs/Header.h> #include <voxgraph_msgs/MapHeader.h> #include "voxgraph/common.h" #include "voxgraph/frontend/submap_collection/voxgraph_submap.h" namespace voxgraph { class SubmapServer { public: explicit SubmapServer(ros::NodeHandle nh_private); // Publish maps using the publishers that are members of this server instance void publishSubmap(const VoxgraphSubmap& submap, const ros::Time& timestamp); void publishSubmapTsdf(const VoxgraphSubmap& submap, const ros::Time& timestamp); void publishSubmapEsdf(const VoxgraphSubmap& submap, const ros::Time& timestamp); void publishSubmapSurfacePointcloud(const VoxgraphSubmap& submap, const ros::Time& timestamp); // "Bring your own publisher" methods // NOTE: These methods are provided s.t. they can be called using publishers // to custom topics and without requiring a SubmapServer instance. // They are therefore static. static void publishSubmapTsdf(const VoxgraphSubmap& submap, const ros::Time& timestamp, const ros::Publisher& submap_tsdf_publisher); static void publishSubmapEsdf(const VoxgraphSubmap& submap, const ros::Time& timestamp, const ros::Publisher& submap_esdf_publisher); static void publishSubmapSurfacePointcloud( const VoxgraphSubmap& submap, const ros::Time& timestamp, const ros::Publisher& submap_surface_pointcloud_publisher); private: ros::Publisher submap_tsdf_pub_; ros::Publisher submap_esdf_pub_; ros::Publisher submap_surface_pointcloud_pub_; static constexpr bool fake_6dof_transforms_ = true; // Convenience methods to generate the message and submap headers static std_msgs::Header generateHeaderMsg(const VoxgraphSubmap& submap, const ros::Time& timestamp); static voxgraph_msgs::MapHeader generateSubmapHeaderMsg( const VoxgraphSubmap& submap); // Conversion method from Kindr transforms to Eigen Affine3f transforms static void transformKindrToEigen(const Transformation& kindr, Eigen::Affine3f* eigen) { CHECK_NOTNULL(eigen); *eigen = Eigen::Translation3f(kindr.getPosition()) * kindr.getEigenQuaternion(); } }; } // namespace voxgraph #endif // VOXGRAPH_TOOLS_DATA_SERVERS_SUBMAP_SERVER_H_
[ "victor_reijgwart@hotmail.com" ]
victor_reijgwart@hotmail.com
f14faea8506d842e02385681b2785e4f534186e9
ab68c3b4b94b98b3355ab31ee3315cf5e2e57bd8
/genAbs/waveGeneration/multiPistonMovement/multiPistonMovement.H
8d52668bd725a988e83958c9141ab08308e7e0f9
[]
no_license
pp1565156/OLAFOAM
eee67e0851b99efeb64cc5ef46d83c0dffc8f60c
3a0373c426c732341f2951b6bcd943d12138d52e
refs/heads/master
2021-05-03T13:33:13.619450
2016-07-11T07:52:10
2016-07-11T07:52:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
8,457
h
/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM 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. OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>. Description fixedValue pointPatchField. - without state SourceFiles multiPistonMovement.C \*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*\ | olaFoam Project ll | | l l | | Coder: Pablo Higuera Caubilla ooo l l aa | | Bug reports: phicau@gmail.com o o l l a a | | o o ll l a aa aa | | ooo llll aa aa | | | | FFFFF OOOOO AAAAA M M | | F O O A A MM MM | | Formerly IHFOAM Project FFFF O O AAAAA M M M | | Work initially developed at IH Cantabria F O O A A M M | | F OOOOO A A M M | | ----------------------------------------------------------------------- | | References: | | | | - Realistic wave generation and active wave absorption for Navier-Stokes | | models: Application to OpenFOAM. | | Higuera, P., Lara, J.L. and Losada, I.J. (2013) | | Coastal Engineering, Vol. 71, 102-118. | | http://dx.doi.org/10.1016/j.coastaleng.2012.07.002 | | | | - Simulating coastal engineering processes with OpenFOAM | | Higuera, P., Lara, J.L. and Losada, I.J. (2013) | | Coastal Engineering, Vol. 71, 119-134. | | http://dx.doi.org/10.1016/j.coastaleng.2012.06.002 | | | | - Three-dimensional numerical wave generation with moving boundaries | | Higuera, P., Losada, I.J. and Lara, J.L. (2015) | | Coastal Engineering, Vol. 101, 35-47. | | http://dx.doi.org/10.1016/j.coastaleng.2015.04.003 | | | \*---------------------------------------------------------------------------*/ #ifndef fixedValuePointPatchTemplateVectorField_H #define fixedValuePointPatchTemplateVectorField_H #include "fixedValuePointPatchFields.H" #include "mathematicalConstants.H" #include "fixedValueFvPatchFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { class multiPistonMovement : #if OFFLAVOUR == 1 public FixedValuePointPatchField < pointPatchField, pointMesh, pointPatch, DummyMatrix, vector > #else public fixedValuePointPatchField<vector> #endif { // Private data //- Dictionary name word multiPistonDictName_; //- Time series for interpolation scalarList timeSeries_; //- Number of different paddles (for absorption) label nPaddles_; //- Paddle position series for interpolation List<List<scalar> > paddlePosition_; //- Free surface series at the paddle for interpolation List<List<scalar> > paddleEta_; //- Initial water depth (meters) scalar initialWaterDepth_; //- Perpendicular direction to the paddle vector meanAngle_; //- Generation + Absorption at the same time bool genAbs_; //- Drift Prevention System acting List<bool> DPS_; //- Maximum allowed stroke scalar maxStroke_; //- DPS period scalar DPST_; //- Drift Prevention System sign (+/-1) scalarList DPSsign_; //- DPS starting time scalarList DPStIni_; //- Instantaneous paddle position correction scalarList instDPSCorrection_; //- Cumulative paddle position correction scalarList cumDPSCorrection_; //- Cumulative paddle position correction scalarList cumAbsCorrection_; //- Fade in time (linear 0-1) scalar tSmooth_; //- Tuning factor scalar tuningFactor_; //- BC has been checked for first time bool allCheck_; public: //- Runtime type information TypeName("multiPistonMovement"); // Constructors //- Construct from patch and internal field multiPistonMovement ( const pointPatch&, const DimensionedField<vector, pointMesh>& ); //- Construct from patch, internal field and dictionary multiPistonMovement ( const pointPatch&, const DimensionedField<vector, pointMesh>&, const dictionary&, const bool valueRequired=true ); //- Construct by mapping a copy onto a new patch multiPistonMovement ( const multiPistonMovement&, const pointPatch&, const DimensionedField<vector, pointMesh>&, #if OFFLAVOUR == 1 const PointPatchFieldMapper& #else const pointPatchFieldMapper& #endif ); //- Construct as copy multiPistonMovement ( const multiPistonMovement& ); //- Construct and return a clone virtual autoPtr< pointPatchField<vector> > clone() const { return autoPtr< pointPatchField<vector> > ( new multiPistonMovement(*this) ); } //- Construct as copy setting internal field reference multiPistonMovement ( const multiPistonMovement&, const DimensionedField<vector, pointMesh>& ); //- Construct and return a clone setting internal field reference virtual autoPtr< pointPatchField<vector> > clone ( const DimensionedField<vector, pointMesh>& iF ) const { return autoPtr< pointPatchField<vector> > ( new multiPistonMovement(*this, iF) ); } //- Destructor virtual ~multiPistonMovement(); // Member functions //- Update the coefficients associated with the patch field virtual void updateCoeffs(); //- Write virtual void write(Ostream&) const; #include "pistonMemberFun.H" }; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif // ************************************************************************* //
[ "phicau@gmail.com" ]
phicau@gmail.com
a6d61c1c7fb28be4257634e6df5abcdcc40aed3d
d1892fb0ef8657972a9027fff940318852d4dc30
/Famous_algo/03_Tower-of-hannoi.cpp
bf4e0f83db6e82d9b30f7dc5fec1d7c7b3399c6d
[]
no_license
divesh-netizen/Love-Babbar-450-QA
10ee7bbe32f744144ab00e213c6087e2fcb1a884
d16abfe80c36d5faa87ee07ca0db52ab3750148d
refs/heads/master
2023-08-28T19:05:43.966591
2021-10-24T13:22:13
2021-10-24T13:22:13
345,329,292
0
0
null
null
null
null
UTF-8
C++
false
false
613
cpp
#include<bits/stdc++.h> using namespace std; long long toh(int N, int from, int to, int aux) { //Your code here long long moves = 0ll; if (N >= 1) { // recursive call to move top disk from "from" to aux in current call moves += toh(N - 1, from, aux, to); cout << "move disk " << N << " from rod " << from << " to rod " << to << endl; // increment moves moves++; // recursive call to move top disk from aux to "to" in current call moves += toh(N - 1, aux, to, from); } return moves; }
[ "61093504+divesh-netizen@users.noreply.github.com" ]
61093504+divesh-netizen@users.noreply.github.com
0ef6bcb3ed0c765fa503d43cc9a3ba79e5aaeaa4
332e48a38e977b2e51fa9e0a2fa1d65bec808ec4
/Convert/v0r2/src/PartGrnd_ROOT.cc
96f0d47b1e21f0f29eaf9343eeb14cef4e466f73
[]
no_license
jlzhang001/LHAASIM
69f81324706b7d7916114a58ec4928f3908dddd1
e23ae45a32106eafe939957ffdfae8ae46c5c309
refs/heads/master
2020-04-27T00:58:15.144556
2017-07-20T21:21:47
2017-07-20T21:21:47
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,337
cc
/*! \file PartGrnd_ROOT.cc \brief implementation file for \author Sylvie Dagoret-Campagne PartGrnd_ROOT.h \date april 2001 */ #include "PartGrnd_ROOT.h" #include "Globals.h" ClassImp(PartGrnd_ROOT) Int_t PartGrnd_ROOT::GetId() { return (Int_t) Id; } Float_t PartGrnd_ROOT::GetUX() { return (Float_t) UX; }; Float_t PartGrnd_ROOT::GetUY() { return (Float_t) UY; }; Float_t PartGrnd_ROOT::GetUZ() { return (Float_t) UZ; }; Float_t PartGrnd_ROOT::GetX() { return (Float_t) X; }; Float_t PartGrnd_ROOT::GetY() { return (Float_t) Y; }; Float_t PartGrnd_ROOT::GetZ() { return (Float_t) Z; }; Float_t PartGrnd_ROOT::GetT() { return (Float_t) T; }; Float_t PartGrnd_ROOT::GetW() { return (Float_t) W; }; Float_t PartGrnd_ROOT::GetE() { return (Float_t) E; }; Float_t PartGrnd_ROOT::Phi() { return (Float_t) atan2(Y, X); }; Float_t PartGrnd_ROOT::GetPhiDeg() { return RAD2DEG * Phi(); }; Float_t PartGrnd_ROOT::GetUR() { return sqrt(UX * UX + UY * UY); }; Float_t PartGrnd_ROOT::Theta() { Float_t Pz = GetUZ(); if (Pz == 0) return PI / 2.; else return (atan2(GetUR(), Pz)); }; Float_t PartGrnd_ROOT::GetCosTheta() { return TMath::Cos(this->Theta()); }; Float_t PartGrnd_ROOT::GetThetaDeg() { return RAD2DEG * Theta(); }; Float_t PartGrnd_ROOT::Azim() { return atan2(UY, UX); }; Float_t PartGrnd_ROOT::GetAzimDeg() { return RAD2DEG * Azim(); }; Float_t PartGrnd_ROOT::R() { return (Float_t) sqrt(X * X + Y * Y); }; Float_t PartGrnd_ROOT::GetR() { return R(); }; Float_t PartGrnd_ROOT::LogR() { return (Float_t) TMath::Log10(R()); }; Float_t PartGrnd_ROOT::LogW() { return TMath::Log10(GetW()); }; Float_t PartGrnd_ROOT::LogE() { return (Float_t) TMath::Log10(GetE()); }; Float_t PartGrnd_ROOT::LogT() { return (Float_t) TMath::Log10(GetT()); }; //------------------------------------------------------- void PartGrnd_ROOT::Print(ostream& s) const { s << "PartGrnd_ROOT:: Id = "<< Id << endl; s << " UX UY UZ " << UX <<" " << UY <<" "<< UZ << endl; s << " X Y Z " << X <<" " << Y <<" "<< Z << endl; s << " T W E " << T <<" " << W <<" "<< E << endl; s << endl; } //------------------------------------------------------- ostream& operator<<( ostream& s, const PartGrnd_ROOT& p) { p.Print(s); return s; } //-------------------------------------------------------
[ "diane.martraire@gmail.com" ]
diane.martraire@gmail.com
f97988b56e916ac74927c8912070add3f7bd7d95
d21743e55d9817467ba36b62ef84522acbad6e41
/CloudRunner/Player.cpp
94dd0f4dba67f896a1a09d3c3d19b5ae3469e915
[]
no_license
KatieMikhaltsova/CloudRunner
c91585cd0e629e594870636f2b79eb8d49a837d9
c9b774397833f5ab609b95570e3c4ce0bcf6b25e
refs/heads/master
2023-04-04T11:07:16.643071
2021-04-20T17:27:53
2021-04-20T17:27:53
359,538,560
0
0
null
null
null
null
UTF-8
C++
false
false
5,336
cpp
#include "Player.h" using namespace sf; Player::Player(Texture& texture, float x, float y, int xSprite, int ySprite, int wSprite, int hSprite,float animSpeed, int quantityOfFrame) :Entity(texture, x, y, xSprite, ySprite, wSprite, hSprite, animSpeed, quantityOfFrame) { playerState =RIGHT; quantityOfRebirth = 0; } void Player::update(float& time, RenderWindow& window) { switch (playerState) { case RIGHT: moveForward(time); break; case JUMP: moveUp(time); break; case CROUCH: moveDown(time); break; case REBIRTH: moveRebirth(time, window); break; case DEATH: endGame(time); break; }; setX(getX() + getDx() * time); setY(getY() + getDy() * time); setSpritePosition(getX(), getY()); setScoreCollision(getX(), getY(), 1, 100); if (getHealth() == 0) { setLife(false); } } void Player::control(float& time, Sound& soundJump, Sound& soundCrouch, Sound& soundDown) { if ((Keyboard::isKeyPressed(Keyboard::Up)) && (getOnGround())) { soundJump.play(); playerState =JUMP; setCurrentFrame(0); setOnGround(false); } if (Keyboard::isKeyPressed(Keyboard::Down) && (getOnGround())) { soundDown.play(); playerState = CROUCH; setCurrentFrame(0); setOnGround(false); } } void Player::moveForward(float& time) { setAnimSpeed(0.005); setDx(0.02); setDy(0); setCurrentFrame(getCurrentFrame() +getAnimSpeed() * time); if (getCurrentFrame() >getQuantityOfFrame()) { setCurrentFrame(0); } else { setSpriteTextureRect(100 * int(getCurrentFrame()), 200,getWSprite(), getHSprite()); setCollision(getX() + 40, getY(), 32, getHSprite()); } } void Player::moveUp(float& time) { setAnimSpeed(0.009); if (getCurrentFrame()==0) { setDy(0); setDx(0); setSpriteTextureRect(0, 300, getWSprite(), getHSprite()); setCurrentFrame(getCurrentFrame() + getAnimSpeed() * time); setCollision(getX() + 35, getY(), 32,getHSprite()); } else { setDy(-0.3); setDx(0.015); setCurrentFrame(getCurrentFrame() + getAnimSpeed() * time); if (getCurrentFrame() > 3) { setDy(0.65); setCurrentFrame(getCurrentFrame() + getAnimSpeed() * time); if (getY() > 200) { setCurrentFrame(0); setY(200); setDy(0); playerState = RIGHT; setOnGround(true); } } else { setSpriteTextureRect(100 * int(getCurrentFrame()), 300, getWSprite(), getHSprite()); setCollision(getX() + 35, getY(), 32, getHSprite()); } } } void Player::moveDown(float& time) { setDy(0); if (getX()>10) { setDx(-0.05); } else { setDx(0); } if (getCurrentFrame() <2.1) { setCurrentFrame(getCurrentFrame() + 0.003 * time); setSpriteTextureRect(100 * int(getCurrentFrame()), 400, 100, 100); setCollision(getX() +40, getY(), 32, 100); } if ((getCurrentFrame() > 2.1) && Keyboard::isKeyPressed(Keyboard::Down)) { setSpriteTextureRect(200, 400, 100,100); setCollision(getX() + 40, getY()+50, 32, 50); } else { if (getCurrentFrame() < 4) { setCurrentFrame(getCurrentFrame() + 0.008 * time); setSpriteTextureRect(100 * int(getCurrentFrame()), 400, 100, 100); setCollision(getX() + 40, getY()+50, 32, 50); } } if(getCurrentFrame() > 4) { setCurrentFrame(getCurrentFrame() - 4); playerState = RIGHT; setOnGround(true); } } void Player::moveRebirth(float& time, RenderWindow& window) { setAnimSpeed(0.2); if (getX() > 10) { setDy(getAnimSpeed()); setDx(0); setSpriteTextureRect(200, 300, getWSprite(), getHSprite()); if (getY() > window.getSize().y) { setSpritePosition(10, 0); } } if (getX()==10) { setDy(getAnimSpeed()); if (getY()>200) { setY(200); playerState = RIGHT; setOnGround(true); quantityOfRebirth ++; setScore(getScore() + quantityOfRebirth * 10); } } setCollision(getX() + 40, getY(), 32, getHSprite()); } void Player::endGame(float& time) { if (getCurrentFrame() < 8) { setAnimSpeed(0.005); setDx(-getAnimSpeed()); setDy(0); setSpriteTextureRect(300, 300, getWSprite(), getHSprite()); setY(202); setCurrentFrame(getCurrentFrame() + getAnimSpeed() * time); } } void Player::rebirth(Entity& enemy, RenderWindow& window) { if (getCollision().intersects(FloatRect(enemy.getX()-25,enemy.getY(), getWSprite(), getHSprite()))) { playerState = REBIRTH; setOnGround(false); } } int Player::getQuantityOfRebirth() { return quantityOfRebirth; } void Player::setQuantityOfRebirth(int quantityOfRebirth) { this->quantityOfRebirth = quantityOfRebirth; } void Player::setState(State playerState) { this->playerState = playerState; }
[ "emikhaltcova@gmail.com" ]
emikhaltcova@gmail.com
b743b9f0009e8f928d3853722050eeaed983512a
1942a0d16bd48962e72aa21fad8d034fa9521a6c
/aws-cpp-sdk-ec2/source/model/InternetGateway.cpp
ae211a76bb5bbc2f9f54136680f99e74a250a0b2
[ "Apache-2.0", "JSON", "MIT" ]
permissive
yecol/aws-sdk-cpp
1aff09a21cfe618e272c2c06d358cfa0fb07cecf
0b1ea31e593d23b5db49ee39d0a11e5b98ab991e
refs/heads/master
2021-01-20T02:53:53.557861
2018-02-11T11:14:58
2018-02-11T11:14:58
83,822,910
0
1
null
2017-03-03T17:17:00
2017-03-03T17:17:00
null
UTF-8
C++
false
false
4,182
cpp
/* * Copyright 2010-2016 Amazon.com, Inc. or its affiliates. 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. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file 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 <aws/ec2/model/InternetGateway.h> #include <aws/core/utils/xml/XmlSerializer.h> #include <aws/core/utils/StringUtils.h> #include <aws/core/utils/memory/stl/AWSStringStream.h> #include <utility> using namespace Aws::Utils::Xml; using namespace Aws::Utils; namespace Aws { namespace EC2 { namespace Model { InternetGateway::InternetGateway() : m_internetGatewayIdHasBeenSet(false), m_attachmentsHasBeenSet(false), m_tagsHasBeenSet(false) { } InternetGateway::InternetGateway(const XmlNode& xmlNode) : m_internetGatewayIdHasBeenSet(false), m_attachmentsHasBeenSet(false), m_tagsHasBeenSet(false) { *this = xmlNode; } InternetGateway& InternetGateway::operator =(const XmlNode& xmlNode) { XmlNode resultNode = xmlNode; if(!resultNode.IsNull()) { XmlNode internetGatewayIdNode = resultNode.FirstChild("internetGatewayId"); if(!internetGatewayIdNode.IsNull()) { m_internetGatewayId = StringUtils::Trim(internetGatewayIdNode.GetText().c_str()); m_internetGatewayIdHasBeenSet = true; } XmlNode attachmentsNode = resultNode.FirstChild("attachmentSet"); if(!attachmentsNode.IsNull()) { XmlNode attachmentsMember = attachmentsNode.FirstChild("item"); while(!attachmentsMember.IsNull()) { m_attachments.push_back(attachmentsMember); attachmentsMember = attachmentsMember.NextNode("item"); } m_attachmentsHasBeenSet = true; } XmlNode tagsNode = resultNode.FirstChild("tagSet"); if(!tagsNode.IsNull()) { XmlNode tagsMember = tagsNode.FirstChild("item"); while(!tagsMember.IsNull()) { m_tags.push_back(tagsMember); tagsMember = tagsMember.NextNode("item"); } m_tagsHasBeenSet = true; } } return *this; } void InternetGateway::OutputToStream(Aws::OStream& oStream, const char* location, unsigned index, const char* locationValue) const { if(m_internetGatewayIdHasBeenSet) { oStream << location << index << locationValue << ".InternetGatewayId=" << StringUtils::URLEncode(m_internetGatewayId.c_str()) << "&"; } if(m_attachmentsHasBeenSet) { unsigned attachmentsIdx = 1; for(auto& item : m_attachments) { Aws::StringStream attachmentsSs; attachmentsSs << location << index << locationValue << ".AttachmentSet." << attachmentsIdx++; item.OutputToStream(oStream, attachmentsSs.str().c_str()); } } if(m_tagsHasBeenSet) { unsigned tagsIdx = 1; for(auto& item : m_tags) { Aws::StringStream tagsSs; tagsSs << location << index << locationValue << ".TagSet." << tagsIdx++; item.OutputToStream(oStream, tagsSs.str().c_str()); } } } void InternetGateway::OutputToStream(Aws::OStream& oStream, const char* location) const { if(m_internetGatewayIdHasBeenSet) { oStream << location << ".InternetGatewayId=" << StringUtils::URLEncode(m_internetGatewayId.c_str()) << "&"; } if(m_attachmentsHasBeenSet) { unsigned attachmentsIdx = 1; for(auto& item : m_attachments) { Aws::StringStream attachmentsSs; attachmentsSs << location << ".Item." << attachmentsIdx++; item.OutputToStream(oStream, attachmentsSs.str().c_str()); } } if(m_tagsHasBeenSet) { unsigned tagsIdx = 1; for(auto& item : m_tags) { Aws::StringStream tagsSs; tagsSs << location << ".Item." << tagsIdx++; item.OutputToStream(oStream, tagsSs.str().c_str()); } } } } // namespace Model } // namespace EC2 } // namespace Aws
[ "henso@amazon.com" ]
henso@amazon.com
2dda11ecc5da4d1a2df180057349285ed0618879
d82170c160bcfb4fe2b1d32fe407e7322921069d
/xa_nnlib/test/android_nn/gemmlowp/internal/pack.h
4c9ec5b0856b56a5b5062dc6dcdb5288dc3bcb73
[ "LicenseRef-scancode-other-permissive" ]
permissive
weimingtom/nnlib-hifi4
5619cf9c0e1c83f8773a5112fed555200bcf4587
7af1e1996f1a366418467e58852e5d40992db783
refs/heads/master
2023-02-06T21:10:44.948824
2020-12-22T08:30:28
2020-12-22T08:30:28
null
0
0
null
null
null
null
UTF-8
C++
false
false
18,648
h
/******************************************************************************* * Copyright (c) 2018-2020 Cadence Design Systems, Inc. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to use this Software with Cadence processor cores only and * not with any other processors and platforms, subject to * the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ******************************************************************************/ // Copyright 2015 The Gemmlowp 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. // pack.h: packing blocks of the LHS and RHS into the data layout // that is expected by compute.h and eventually by kernels. // Because this data layout depends on the kernel format, code here // is templated in KernelLhsFormat/KernelRhsFormat. // // Readers note: an important theme around here is that we try hard // to handle both Lhs and Rhs with a single piece of code. We indifferently // refer to the Lhs and Rhs as a 'Side'. Instead of addressing matrices // by (row, column) indices, we address them by (width, depth), as explained // in kernel.h. This allows us to handle both Lhs and Rhs on an equal footing, // at once. #ifndef GEMMLOWP_INTERNAL_PACK_H_ #define GEMMLOWP_INTERNAL_PACK_H_ #include <cstring> #include "allocator.h" #include "block_params.h" #ifndef HIFI_BUILD #include "common.h" #else #include "gemm_common.h" #endif #include "kernel.h" namespace gemmlowp { // A PackedSideBlock instance is a packed block of either the LHS or RHS // (whence the generic 'Side' name). // // 'Packed' means that it is laid out in the storage order that // is expected by the specified kernel format. From a block of the input // LHS or RHS matrix, one obtains a PackedSideBlock by calling PackLhs() // or PackRhs(). template <typename tKernelSideFormat> class PackedSideBlock { public: typedef tKernelSideFormat KernelSideFormat; PackedSideBlock(Side side, Allocator* allocator, const BlockParams& block_params) : allocator_(allocator), pos_(0) { GetSideBlockParams(side, &params_, block_params); data_handle_ = allocator_->Reserve<std::uint8_t>(params_.l2_width * params_.l2_depth); sums_of_each_slice_handle_ = allocator_->Reserve<std::int32_t>(params_.l2_width); } ~PackedSideBlock() {} void seek_run(int start_width, int start_depth) const { int kernel_run_depth = std::min<int>(params_.l1_depth, params_.l2_depth - start_depth); pos_ = params_.l2_width * start_depth + start_width * kernel_run_depth; } void seek_next_cell() const { pos_ += KernelSideFormat::Cell::kSize; } void seek_forward_n_cells(int n) const { pos_ += n * KernelSideFormat::Cell::kSize; } const std::uint8_t* current_data() const { return allocator_->GetPointer<std::uint8_t>(data_handle_) + pos_; } std::uint8_t* current_data() { return allocator_->GetPointer<std::uint8_t>(data_handle_) + pos_; } std::int32_t* sums_of_each_slice() { return allocator_->GetPointer<std::int32_t>(sums_of_each_slice_handle_); } const std::int32_t* sums_of_each_slice() const { return allocator_->GetPointer<const std::int32_t>( sums_of_each_slice_handle_); } const SideBlockParams& params() const { return params_; } private: // The block size parameters that this PackedSizeBlock follows. // The L2 parameters determine its overall size, while the L1 parameters, // together with the kernel format template parameter, determine // the fine details of the storage/traversal order. SideBlockParams params_; // Pointer to the allocator provided by the caller. Not owned. // The Allocator is assumed to outlive the PackedSideBlock. Allocator* const allocator_; // Handle on the buffer backing this packed block. Owned. Allocator::Handle data_handle_; // Handle on the additional buffer backing the vector of sums of slices // associated with this block. Owned. Allocator::Handle sums_of_each_slice_handle_; // pos_ is the current position in the buffer, which we access // sequentially, like a file. // The idea is that we pack data in the same order as it is // going to be traversed during the computation, which for // cache-friendliness reasons is complicated to random-access, // as the offsets calculations would be intricate. So we // give up random-access addressing, and instead content ourselves // with sequential access. // // pos_ is mutable because during the computation we will want to // be able to iterate on the data in a const PackedSideBlock. mutable int pos_; }; // WidthMajor and DepthMajor are custom phrases modelled after the // standard terminology 'row-major' and 'column-major'. Their meaning // should be transparent once one has read the explanation in kernel.h: // for example, in the Lhs, the 'width' dimension is the rows dimension, // so there WidthMajor means RowMajor, while in the Rhs it is the opposite. // Another way to put it: WidthMajor means that contiguous storage is used // for entries having the same 'width' index. enum class SideMapOrder { WidthMajor, DepthMajor }; // Similar to MatrixMap from map.h, but in terms of width/depth instead of // rows/columns. Used to address blocks of the input LHS/RHS matrices when // packing them. template <typename tScalar, SideMapOrder tOrder> class SideMap { public: typedef tScalar Scalar; static const SideMapOrder kOrder = tOrder; SideMap(Scalar* data, int width, int depth, int stride) : data_(data), width_(width), depth_(depth), stride_(stride) {} SideMap(Scalar* data, int width, int depth) : data_(data), width_(width), depth_(depth) { stride_ = kOrder == SideMapOrder::WidthMajor ? depth_ : width_; } SideMap(const SideMap& other) : data_(other.data_), width_(other.width_), depth_(other.depth_), stride_(other.stride_) {} int width() const { return width_; } int depth() const { return depth_; } int stride() const { return stride_; } int width_stride() const { return kOrder == SideMapOrder::DepthMajor ? 1 : stride_; } int depth_stride() const { return kOrder == SideMapOrder::WidthMajor ? 1 : stride_; } Scalar* data() const { return data_; } Scalar* data(int w, int d) const { return data_ + w * width_stride() + d * depth_stride(); } Scalar operator()(int w, int d) const { return *data(w, d); } Scalar& operator()(int w, int d) { return *data(w, d); } SideMap block(int start_width, int start_depth, int block_width, int block_depth) const { assert(start_width >= 0); assert(start_width + block_width <= width_); assert(start_depth >= 0); assert(start_depth + block_depth <= depth_); return SideMap(data(start_width, start_depth), block_width, block_depth, stride_); } private: Scalar* data_; // not owned. int width_, depth_, stride_; }; // A PackingRegisterBlock is a small fixed-size block of a matrix being // packed. This class is the generic non-optimized implementation, // it is inherited by the generic implementation of PackingRegisterBlock, // which may be overriden by template specialization. Overriding it is how // one may provide optimized packing code paths. // // The packing of a block proceeds in two steps: // 1. Ensuring that we have a complete block of source data, i.e. a block of // the compile-time prescribed size. This is where we handle unaligned // boundaries: if we don't have a complete block of source data, then // we copy and zero-extend it into a local temporary (complete_src_), // see MakeCompleteSrc. In the generic case, we do have a complete block, // so we just use it in-place, see UseCompleteSrcInPlace. // 2. Packing a complete block into the destination, see Pack. This is the // most critical part, so it's convenient that unaligned boundaries have // already been handled in step 1. template <typename SrcMapType, typename PackedSideBlock> class PackingRegisterBlockBase { public: typedef typename PackedSideBlock::KernelSideFormat KernelSideFormat; typedef typename KernelSideFormat::Cell CellFormat; typedef typename KernelSideFormat::Scalar KernelScalar; static const int kCells = KernelSideFormat::kCells; static const int kCellWidth = CellFormat::kWidth; static const int kKernelWidth = CellFormat::kWidth * kCells; static const int kCellDepth = CellFormat::kDepth; static const int kCellSize = CellFormat::kSize; static const SideMapOrder kSrcOrder = SrcMapType::kOrder; static const int kZeroPointInputValue = ZeroPointInputValue<KernelScalar>::kValue; PackingRegisterBlockBase() : complete_src_(nullptr, 0, 0, 0) {} protected: // The source data that's ready for packing. May point to // in-place actual source data if it's already a complete block, // (see UseCompleteSrcInPlace) // or to the local buf_ below into which we copy incomplete blocks // (see MakeCompleteSrc) SrcMapType complete_src_; // Temporary buffer for loading incomplete blocks to, // in the source storage order std::uint8_t buf_[kKernelWidth * kRegisterSize]; public: // Selects a block if in-place source data that's already a complete block void UseCompleteSrcInPlace(const SrcMapType& src) { complete_src_ = src; } // Copies an incomplete block of source data into a local temporary // complete block by zero-extending it. void MakeCompleteSrc(const SrcMapType& src) { memset(buf_, kZeroPointInputValue, kKernelWidth * kRegisterSize); if (kSrcOrder == SideMapOrder::WidthMajor) { for (int w = 0; w < src.width(); w++) { memcpy(buf_ + w * kRegisterSize, src.data(w, 0), src.depth()); } } else { assert(kSrcOrder == SideMapOrder::DepthMajor); for (int d = 0; d < src.depth(); d++) { memcpy(buf_ + d * kKernelWidth, src.data(0, d), src.width()); } } complete_src_ = SrcMapType(buf_, kKernelWidth, kRegisterSize); } // Packs a complete block into the destination. This is the most // critical part and the part that we most typically want to // override in architecture-specific optimized specializations. void Pack(PackedSideBlock* dst, int start_width) { std::uint8_t* dst_ptr = dst->current_data(); for (int cell_start_depth = 0; cell_start_depth < kRegisterSize; cell_start_depth += kCellDepth) { for (int cell_start_width = 0; cell_start_width < kKernelWidth; cell_start_width += kCellWidth) { std::int32_t* cell_sums_of_each_slice_ptr = dst->sums_of_each_slice() + start_width + cell_start_width; const SideMap<const std::uint8_t, kSrcOrder> src_cell_map( complete_src_.block(cell_start_width, cell_start_depth, kCellWidth, kCellDepth)); for (int w = 0; w < kCellWidth; w++) { std::int32_t sum = 0; for (int d = 0; d < kCellDepth; d++) { const std::uint8_t src_val = src_cell_map(w, d); const std::int16_t kernel_val_unwrapped = src_val - kZeroPointInputValue; const std::uint8_t kernel_val_uint8 = kernel_val_unwrapped; dst_ptr[OffsetIntoCell<CellFormat>(w, d)] = kernel_val_uint8; sum += kernel_val_unwrapped; } cell_sums_of_each_slice_ptr[w] += sum; } dst_ptr += kCellSize; } } dst->seek_forward_n_cells(kCells * kRegisterSize / kCellDepth); } }; template <typename SrcMapType, typename PackedSideBlock> class PackingRegisterBlock : public PackingRegisterBlockBase<SrcMapType, PackedSideBlock> {}; // Large-scale implementation of packing. template <typename SrcMapType, typename PackedSideBlock> class PackSideBlockImpl { public: typedef typename PackedSideBlock::KernelSideFormat KernelSideFormat; typedef typename KernelSideFormat::Cell CellFormat; static const int kCells = KernelSideFormat::kCells; static const int kCellWidth = CellFormat::kWidth; static const int kKernelWidth = CellFormat::kWidth * kCells; static const int kCellDepth = CellFormat::kDepth; typedef PackingRegisterBlock<SrcMapType, PackedSideBlock> PackingRegisterBlockType; PackSideBlockImpl(PackedSideBlock* packed_side_block, const SrcMapType& src_map) : packed_side_block_(packed_side_block), src_map_(src_map) {} PackedSideBlock* packed_side_block() const { return packed_side_block_; } const SrcMapType& src_map() const { return src_map_; } // The public entry point to pack a block. void PackL2() { memset(packed_side_block_->sums_of_each_slice(), 0, sizeof(std::int32_t) * packed_side_block_->params().l2_width); for (int d = 0; d < src_map_.depth(); d += packed_side_block_->params().l1_depth) { int ds = std::min<int>(packed_side_block_->params().l1_depth, src_map_.depth() - d); for (int w = 0; w < src_map_.width(); w += packed_side_block_->params().l1_width) { int ws = std::min<int>(packed_side_block_->params().l1_width, src_map_.width() - w); PrefetchL1(w, ws, d, ds); PackL1(w, ws, d, ds); } } } protected: // The intermediate-level loops, between PackL2 and PackRun. void PackL1(int start_width, int width, int start_depth, int depth) { for (int w = 0; w < width; w += kKernelWidth) { int ws = std::min(+kKernelWidth, width - w); packed_side_block_->seek_run(start_width + w, start_depth); PackRun(start_width + w, ws, start_depth, depth); } } // Prefetches the data that will be read by PackL1 void PrefetchL1(int start_width, int width, int start_depth, int depth) { if (SrcMapType::kOrder == SideMapOrder::WidthMajor) { for (int d = 0; d < depth; d += kDefaultCacheLineSize) { for (int w = 0; w < width; w += 1) { Prefetch(src_map_.data(start_width + w, start_depth + d)); } } } else { for (int d = 0; d < depth; d++) { for (int w = 0; w < width; w += kDefaultCacheLineSize) { Prefetch(src_map_.data(start_width + w, start_depth + d)); } } } } // PackRun packs only a run i.e. is the inner loop in the depth dimension. void PackRun(int start_width, int width, int start_depth, int depth) { PackingRegisterBlockType b; if (width == kKernelWidth) { const int register_aligned_depth = RoundDown<kRegisterSize>(depth); if (register_aligned_depth) { for (int d = 0; d < register_aligned_depth; d += kRegisterSize) { b.UseCompleteSrcInPlace(src_map_.block(start_width, start_depth + d, width, kRegisterSize)); b.Pack(packed_side_block_, start_width); } } if (register_aligned_depth < depth) { b.MakeCompleteSrc( src_map_.block(start_width, start_depth + register_aligned_depth, width, depth - register_aligned_depth)); b.Pack(packed_side_block_, start_width); } } else { assert(width < kKernelWidth); for (int d = 0; d < depth; d += kRegisterSize) { const int ds = std::min(+kRegisterSize, depth - d); b.MakeCompleteSrc( src_map_.block(start_width, start_depth + d, width, ds)); b.Pack(packed_side_block_, start_width); } } } // The PackedSideBlock being packed, i.e. the 'destination'. PackedSideBlock* const packed_side_block_; // A map on the block of the original matrix block being packed, // i.e. the 'source'. const SrcMapType& src_map_; }; // Packs a block of the input LHS matrix, into a PackedSideBlock template <typename PackedSideBlock, typename MatrixMapType> void PackLhs(PackedSideBlock* dst, const MatrixMapType& src) { ScopedProfilingLabel label("pack LHS"); static const SideMapOrder kSideMapOrder = MatrixMapType::kOrder == MapOrder::RowMajor ? SideMapOrder::WidthMajor : SideMapOrder::DepthMajor; typedef typename MatrixMapType::Scalar Scalar; typedef SideMap<Scalar, kSideMapOrder> SideMapType; SideMapType src_side_map(src.data(), src.rows(), src.cols(), src.stride()); typedef PackSideBlockImpl<SideMapType, PackedSideBlock> ImplType; ImplType impl(dst, src_side_map); impl.PackL2(); } // Packs a block of the input RHS matrix, into a PackedSideBlock template <typename PackedSideBlock, typename MatrixMapType> void PackRhs(PackedSideBlock* dst, const MatrixMapType& src) { ScopedProfilingLabel label("pack RHS"); static const SideMapOrder kSideMapOrder = MatrixMapType::kOrder == MapOrder::ColMajor ? SideMapOrder::WidthMajor : SideMapOrder::DepthMajor; typedef typename MatrixMapType::Scalar Scalar; typedef SideMap<Scalar, kSideMapOrder> SideMapType; SideMapType src_side_map(src.data(), src.cols(), src.rows(), src.stride()); typedef PackSideBlockImpl<SideMapType, PackedSideBlock> ImplType; ImplType impl(dst, src_side_map); impl.PackL2(); } } // namespace gemmlowp #ifdef GEMMLOWP_NEON #include "pack_neon.h" #elif defined(GEMMLOWP_SSE4) #include "pack_sse.h" #elif defined(GEMMLOWP_AVX2) #include "pack_avx.h" #elif defined(GEMMLOWP_MSA) #include "pack_msa.h" #endif #endif // GEMMLOWP_INTERNAL_PACK_H_
[ "63298920+pnikam-cad@users.noreply.github.com" ]
63298920+pnikam-cad@users.noreply.github.com
1d56b5785ab346015bd8fb403f39697d077f6f03
38c25fa8df676c346c123e40435ce4eb742f72d0
/DataTree/interface/CaloMetFwd.h
dcb9a0d01953675c1b7a9c3f12f21b466809eab4
[]
no_license
cpausmit/MitAna
2193894edefcde9fa6353620e5a4222e82a618d2
20c4966fea8f4de6de3df9c5a7f257e0f706035b
refs/heads/master
2020-12-24T05:51:07.810074
2016-10-05T01:43:04
2016-10-05T01:43:04
14,059,251
1
7
null
2016-10-05T01:43:04
2013-11-02T02:50:30
C++
UTF-8
C++
false
false
440
h
// $Id:$ #ifndef MITANA_DATATREE_CALOMETFWD_H #define MITANA_DATATREE_CALOMETFWD_H #include "MitAna/DataCont/interface/CollectionFwd.h" #include "MitAna/DataCont/interface/ArrayFwd.h" #include "MitAna/DataCont/interface/ObjArrayFwd.h" namespace mithep { class CaloMet; typedef Collection<CaloMet> CaloMetCol; typedef Array<CaloMet> CaloMetArr; typedef ObjArray<CaloMet> CaloMetOArr; } #endif
[ "" ]
05e6990467e448e0d50f25f59d8db9c0ad375707
30e87cc45c81efb878541c0d31c55a7be58131b0
/Algo course/find_inversions.cpp
bca3c763c6dcb4f556d36f2e2edb05ea43b2f68c
[]
no_license
shivamgohri/ds_codes
d4df844e89e47758ae97bb98128b9efb0d0c1433
c7cd8d3cf9e0dc99bfa11c38c4ee6b0346ba3bc0
refs/heads/master
2021-05-26T23:30:30.968567
2020-12-12T15:03:34
2020-12-12T15:03:34
254,187,638
0
0
null
null
null
null
UTF-8
C++
false
false
1,199
cpp
#include <iostream> #include <vector> using namespace std; // O(NLOGN) long long merge( int arr[], int temp[], int left, int mid, int right ){ int i = left; int j = mid; int k = left; long long inv = 0; while ((i <= mid - 1) && (j <= right)) { if (arr[i] <= arr[j]) { temp[k++] = arr[i++]; } else { temp[k++] = arr[j++]; inv = inv + (mid - i); } } while (i <= mid - 1) temp[k++] = arr[i++]; while (j <= right) temp[k++] = arr[j++]; for (i = left; i <= right; i++) arr[i] = temp[i]; return inv; } long long _merge( int arr[], int temp[], int left, int right ){ int mid; long long inv = 0; if(right>left){ mid = (left+right)/2; inv += _merge(arr, temp, left, mid ); inv += _merge(arr, temp, mid+1, right); inv += merge( arr, temp, left, mid+1, right ); } return inv; } long long findInversions( int arr[], int n ){ int temp[n]; return _merge( arr, temp, 0 , n-1 ); } int main(){ int n; cin>> n; int arr[n]; for(int i=0; i<n; i++) cin>> arr[i]; long long result = findInversions( arr, n ); cout<< result <<endl; return 0; }
[ "shivamgohri93@gmail.com" ]
shivamgohri93@gmail.com
a8a189be96879a1fff2ca2471b9d33dcde34b7ac
32783ad2a0aecdbfae71be7a684e13887e038a28
/Hackerrank/Contest/WorldCodeSprint-8/ques3.cpp
d623591c7f65783010341fda2be950c5b9793653
[ "MIT" ]
permissive
malathidhandapani/Competitive-Coding
7c6fe2074bb8a171b54f633f84a69fceee6cd483
ffefe5f8b299c623af1ef01bf024af339401de0b
refs/heads/master
2020-04-02T02:50:01.341770
2017-12-19T09:07:53
2017-12-19T09:07:53
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,316
cpp
#include "bits/stdc++.h" using namespace std; # define MOD 1000000007 # define GETCHAR getchar_unlocked typedef long long ll; bool con[100001]; int lib,road; inline ll readllInt() { ll n = 0; char c; while (1){ c=GETCHAR(); if(c=='\n'||c==' ') break; n = n * 10 + c - '0'; } return n; } inline int readInt() { int n = 0; char c; while (1){ c=GETCHAR(); if(c=='\n'||c==' ') break; n = n * 10 + c - '0'; } return n; } ll sum=0; /class Graph { int V; // No. of vertices list<int> *adj; // Pointer to an array containing adjacency lists void DFSUtil(int v, bool visited[]); // A function used by DFS public: Graph(int V); // Constructor void addEdge(int v, int w); // function to add an edge to graph void DFS(); // prints DFS traversal of the complete graph }; Graph::Graph(int V) { this->V = V; adj = new list<int>[V]; } void Graph::addEdge(int v, int w) { adj[v].push_back(w); // Add w to v’s list. } void Graph::DFSUtil(int v, bool visited[]) { // Mark the current node as visited and print it visited[v] = true; con[v]=true; cout << v << " "; // Recur for all the vertices adjacent to this vertex list<int>::iterator i; for(i = adj[v].begin(); i != adj[v].end(); ++i) if(!visited[*i]) DFSUtil(*i, visited); } // The function to do DFS traversal. It uses recursive DFSUtil() void Graph::DFS() { // Mark all the vertices as not visited bool *visited = new bool[V]; for (int i = 0; i < V; i++) visited[i] = false; // Call the recursive helper function to print DFS traversal // starting from all vertices one by one for (int i = 0; i < V; i++) if (visited[i] == false) DFSUtil(i, visited); } int main() { int t=readInt(); while(t--){ int n,m,u,v; sum=0; cin >> n >> m >> lib >> road; Graph g(n); fill_n(con,100001,false); for(int i=0;i<m;i++){ cin >> u >> v; g.addEdge(u-1,v-1); g.addEdge(v-1,u-1); } if(road>= lib) { printf("%d\n",n*lib ); continue; } for(int i=0;i<n;i++) { if(!con[i]){ con[i]=true; sum+=lib; g.DFS(); } } printf("%lld\n",sum ); } return 0; }
[ "saurabhjn76@gmail.com" ]
saurabhjn76@gmail.com
8c631d00fffb597dd89accc1a8eeabc938f50c3e
6d89020fcd80e98018517b06382d9b59d5a7a2f3
/examples/curl/mcurl.cc
6375fd2864c5709ec916a32eb43c654c83f814de
[ "BSD-3-Clause" ]
permissive
huobingli/muduo
9ac65cef866e8597d194a2bed2bfb57044f17968
49037c3463c65001c440ea7acbbb73330f00444e
refs/heads/master
2020-04-08T23:31:57.467952
2020-02-09T08:06:22
2020-02-09T08:06:22
68,167,377
1
0
NOASSERTION
2020-02-09T08:06:23
2016-09-14T02:46:42
C++
UTF-8
C++
false
false
1,122
cc
#include "examples/curl/Curl.h" #include "muduo/net/EventLoop.h" #include <stdio.h> using namespace muduo::net; EventLoop* g_loop = NULL; void onData(const char* data, int len) { printf("len %d\n", len); } void done(curl::Request* c, int code) { printf("done %p %s %d\n", c, c->getEffectiveUrl(), code); } void done2(curl::Request* c, int code) { printf("done2 %p %s %d %d\n", c, c->getRedirectUrl(), c->getResponseCode(), code); // g_loop->quit(); } int main(int argc, char* argv[]) { EventLoop loop; g_loop = &loop; loop.runAfter(30.0, std::bind(&EventLoop::quit, &loop)); curl::Curl::initialize(curl::Curl::kCURLssl); curl::Curl curl(&loop); curl::RequestPtr req = curl.getUrl("http://chenshuo.com"); req->setDataCallback(onData); req->setDoneCallback(done); curl::RequestPtr req2 = curl.getUrl("https://github.com"); // req2->allowRedirect(5); req2->setDataCallback(onData); req2->setDoneCallback(done); curl::RequestPtr req3 = curl.getUrl("http://example.com"); // req3->allowRedirect(5); req3->setDataCallback(onData); req3->setDoneCallback(done2); loop.loop(); }
[ "chenshuo@chenshuo.com" ]
chenshuo@chenshuo.com
f36c74902d37d561443a514f67a4593a08c75fb3
4d77398fc24009f483f2b2abc028a135e09fc9eb
/Assignment4/Solid_convection/9.6/gradTz
a6c322e1912dc196c119bad93342ab5da529f42b
[]
permissive
Naveen-Surya/CFD-Lab-1
12c635b72c611d83080ed6dd316b1b0016f2f86f
c38b0bfe43c7135f4a10e744ea1ac6cf6e9d4a1a
refs/heads/master
2020-04-05T16:43:39.651232
2018-08-23T12:10:06
2018-08-23T12:10:06
157,026,052
0
1
MIT
2018-11-10T22:11:51
2018-11-10T22:11:51
null
UTF-8
C++
false
false
1,593
/*--------------------------------*- 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 volScalarField; location "9.6"; object gradTz; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 -1 0 1 0 0 0]; internalField uniform 0; boundaryField { hot { type calculated; value uniform 0; } cold { type calculated; value uniform 0; } interface_left { type calculated; value uniform 0; } interface_right { type calculated; value uniform 0; } interface_top { type calculated; value uniform 0; } interface_bottom { type calculated; value uniform 0; } defaultFaces { type empty; } } // ************************************************************************* //
[ "sarthakgarg1993@gmail.com" ]
sarthakgarg1993@gmail.com
670cc234ab065588ae7b283bfd1e108f4f7d7a89
c04d4dc09e6d1b0862fb2b3d7f9de7ec19633a1f
/Source/Plot/Extended/XY3DPlot/WaterfallPlot.cpp
ecf35415ad2240b0171c8ce376dac7a87f3b170f
[ "MIT" ]
permissive
Ben20013/CChart
6d4e7eb46ea37e870b27e702b0bde68acf8661da
436b97ca803d6c911d954437b1674b2537577654
refs/heads/master
2023-07-11T16:31:06.821801
2020-10-08T13:16:09
2020-10-08T13:16:09
null
0
0
null
null
null
null
GB18030
C++
false
false
1,790
cpp
/*============================================================================*/ /* */ /* C O P Y R I G H T */ /* */ /* (C) Copyright 2019 by */ /* Yang Guojun */ /* All Rights Reserved */ /* */ /* The author assumes no responsibility for the use or reliability of */ /* his software. */ /* */ /*============================================================================*/ //////////////////////////////////////////////////////////////////////////////// // 版权申明 // // 版权所有(C)2006-2019,杨国君 // // 保留全部权利 // //////////////////////////////////////////////////////////////////////////////// /* ############################################################################################################################## */ #include "WaterfallPlot.h" using namespace NsCChart; CWaterfallPlot::CWaterfallPlot() { SetDefaults(); } CWaterfallPlot::~CWaterfallPlot() { } void CWaterfallPlot::SetDefaults( ) { } void CWaterfallPlot::CopySettings( const CWaterfallPlot *plot ) { }
[ "baita00@hotmail.com" ]
baita00@hotmail.com
8d0d08cf9bd0f6c3d3d84b1a2c7c4240c5418c8d
ce56a2124f75c6172dfde643aa49c1773571b19b
/question561.cpp
3b8af952835c6c28b67966671e7eae3570d755e9
[]
no_license
Electromagnetism-dog-technology/jianzhioffer
91c3204d516e855ed4410aad631b87e96552bf3c
c5f20178bb9bb766e15aede7b2bc7dcc435db03e
refs/heads/main
2023-06-18T15:06:11.584122
2021-07-17T07:49:17
2021-07-17T07:49:17
343,697,767
0
0
null
null
null
null
GB18030
C++
false
false
870
cpp
#include<iostream> #include<vector> #include<map> using namespace std; //1、哈希表 class Solution1 { public: vector<int> singleNumbers(vector<int>& nums) { map<int, int>m; int n = nums.size(); vector<int>res(2, 0); for (int i = 0; i < n; i++) { m[nums[i]]++; } for (int i = 0; i < n; i++) { if (m[nums[i]] == 1) { res.push_back(nums[i]); } } return res; } }; //2、位运算 class Solution2 { public: vector<int> singleNumbers(vector<int>& nums) { int x = 0, y = 0,n=0,m=1; //异或操作,得到只出现一次的两个数 for (int num : nums) { n ^= num; } //找到两个数不相等的位 while ((n&m) == 0) { m <<= 1; } //分组异或 for (int num : nums) { if (num&m)x ^= num; else y ^= num; } return { x,y }; } }; int main() { system("pause"); return EXIT_SUCCESS; }
[ "346322521@qq.com" ]
346322521@qq.com
e182c32ed08aa0db51821e31c5e0a2b9aaf98bb6
6b2a8dd202fdce77c971c412717e305e1caaac51
/solutions_5640146288377856_0/C++/ahmedhamed/main.cpp
a2cee9f7ef506e3f447bd0afa5cbe75873e55caa
[]
no_license
alexandraback/datacollection
0bc67a9ace00abbc843f4912562f3a064992e0e9
076a7bc7693f3abf07bfdbdac838cb4ef65ccfcf
refs/heads/master
2021-01-24T18:27:24.417992
2017-05-23T09:23:38
2017-05-23T09:23:38
84,313,442
2
4
null
null
null
null
UTF-8
C++
false
false
403
cpp
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; int main() { freopen("A-small-attempt1.in", "rt", stdin); freopen("A-small-attempt1.out", "wt", stdout); int t, r, c, w; cin >> t; for (int tst = 1; tst <= t; ++tst) { cin >> r >> c >> w; cout << "Case #" << tst << ": " << w + c / w - (c % w == 0) << endl; } return 0; }
[ "eewestman@gmail.com" ]
eewestman@gmail.com
6768490c5c6b1ded72958aa13816daad9f990921
840484c6553cde4722e91904166eb8e0855555e0
/LAB nou/Lab 1/C++ Qt/QT date/24.09/build-DockWidg-Desktop_Qt_5_7_0_clang_64bit-Debug/ui_dialog.h
b1005ef2eb31ad361c737789efe1c1909bb4cb47
[]
no_license
raul7alex/TAP
db869b8074591026f54f3b5f0fe70e0f14b9e54d
d16bf6b23a8b0d875b074325ef4b32f4c1f8df53
refs/heads/master
2020-05-02T22:00:39.413700
2019-03-28T16:08:32
2019-03-28T16:08:32
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,721
h
/******************************************************************************** ** Form generated from reading UI file 'dialog.ui' ** ** Created by: Qt User Interface Compiler version 5.7.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ #ifndef UI_DIALOG_H #define UI_DIALOG_H #include <QtCore/QVariant> #include <QtWidgets/QAction> #include <QtWidgets/QApplication> #include <QtWidgets/QButtonGroup> #include <QtWidgets/QDialog> #include <QtWidgets/QDialogButtonBox> #include <QtWidgets/QHeaderView> QT_BEGIN_NAMESPACE class Ui_Dialog { public: QDialogButtonBox *buttonBox; void setupUi(QDialog *Dialog) { if (Dialog->objectName().isEmpty()) Dialog->setObjectName(QStringLiteral("Dialog")); Dialog->resize(729, 465); buttonBox = new QDialogButtonBox(Dialog); buttonBox->setObjectName(QStringLiteral("buttonBox")); buttonBox->setGeometry(QRect(180, 390, 341, 32)); buttonBox->setOrientation(Qt::Horizontal); buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); retranslateUi(Dialog); QObject::connect(buttonBox, SIGNAL(accepted()), Dialog, SLOT(accept())); QObject::connect(buttonBox, SIGNAL(rejected()), Dialog, SLOT(reject())); QMetaObject::connectSlotsByName(Dialog); } // setupUi void retranslateUi(QDialog *Dialog) { Dialog->setWindowTitle(QApplication::translate("Dialog", "Dialog", 0)); } // retranslateUi }; namespace Ui { class Dialog: public Ui_Dialog {}; } // namespace Ui QT_END_NAMESPACE #endif // UI_DIALOG_H
[ "raul7_alex@yahoo.com" ]
raul7_alex@yahoo.com
731805b7d95d3202a6c8c42b5e2e7130bcebea2d
8f996c253208cd84fcc54fba761aa4a02f12d08e
/print.cpp
3eaebdccb784e426fadab7994716baea17068ca3
[ "MIT" ]
permissive
WSU-4110/Math_Scriptum
848edec9e9fad1e3bab32d022be2bc15899377a6
b5f38aa56cb1ec4dab2d09524d144bd099c5c5fe
refs/heads/master
2020-07-25T04:40:36.449639
2019-12-13T23:42:23
2019-12-13T23:42:23
208,167,997
5
0
MIT
2019-12-06T18:12:47
2019-09-13T00:16:33
C++
UTF-8
C++
false
false
1,740
cpp
#include "print.h" #include "equationsarea.h" #include <QFileDialog> #include <QPrinter> #include <QTextDocument> #include <QTextImageFormat> #include <QTextCursor> #include <QTextCharFormat> print::print(QWidget *parent) : EquationsArea(parent) { } void print::printToPDF(QString text, QImage image) { ///Add new lines to the note area string some image of graph will be on its own line text = text + "\n\n"; ///Open dialog box to get file name and directory to save pdf to QString fileName = QFileDialog::getSaveFileName(this, tr("Create Save File"), "/home/jana/untitled.pdf", tr("Text (*.pdf)")); ///Create printer object QPrinter printer(QPrinter::PrinterResolution); ///explicitly set printer output to pdf printer.setOutputFormat(QPrinter::PdfFormat); ///set paper size to letter (8.5"*11") printer.setPaperSize(QPrinter::Letter); ///set file name to name defined in dialog box printer.setOutputFileName(fileName); ///set page margins printer.setPageMargins(QMargins(30,30,30,30)); ///set output font QFont textFont("Times New Roman", 12); ///create text format object QTextCharFormat txtfmt = QTextCharFormat(); ///create text document object QTextDocument doc; ///set page size to printer page size doc.setPageSize(printer.pageRect().size()); ///create text cursor object QTextCursor cursor(&doc); ///set font for text format txtfmt.setFont(textFont); ///insert note area text to text document cursor.insertText(text, txtfmt); ///insert graph from equation area on window cursor.insertImage(image); ///call print method to create pdf in user defined directory doc.print(&printer); }
[ "jack.mcginnis1@gmail.com" ]
jack.mcginnis1@gmail.com
2f30ea969192c8dd91efd493349cf6dfcc65348f
fa22fb5ce20440b4c82397bbc1784acd788214b4
/0.013/T
0a9fdc34c69b513034ad7dbfa953e597b23a6d80
[]
no_license
miaomiaomiao783/sheet
6f3c0cc070f6aedb6d463bd1e719ef88aefe543d
37291cca6131971482c9687dfaa88b1852753dff
refs/heads/master
2022-04-25T18:06:08.389703
2020-04-27T01:32:02
2020-04-27T01:32:02
258,936,999
0
0
null
null
null
null
UTF-8
C++
false
false
99,173
/*--------------------------------*- C++ -*----------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: 7 \\/ M anipulation | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class volScalarField; location "0.013"; object T; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 0 0 1 0 0 0]; internalField nonuniform List<scalar> 10000 ( 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 ) ; boundaryField { fixedWalls { type fixedGradient; gradient uniform 0; } down { type fixedGradient; gradient uniform 5000; } tao2 { type fixedGradient; gradient uniform 0; } tao3 { type uniformFixedGradient; gradient uniform 0; uniformGradient csvFile; uniformGradientCoeffs { nHeaderLine 1; refColumn 0; componentColumns List<label> 1(1); separator ","; mergeSeparators 0; file "/home/dyfluid/OpenFOAM/dyfluid-7/run/sheettest/constant/heatflux.csv"; } value nonuniform List<scalar> 2196 ( 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 459.029 ) ; } } // ************************************************************************* //
[ "chenq316@126.com" ]
chenq316@126.com
bb43d44c074a34c44c985cfd31ece4bdf8abf033
ac227cc22d5f5364e5d029a2cef83816a6954590
/applications/physbam/physbam-lib/External_Libraries/Archives/boost/boost/mpl/at.hpp
34ffecbe0d13f56826917a87747b9963f5bb3859
[ "BSL-1.0", "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause" ]
permissive
schinmayee/nimbus
597185bc8bac91a2480466cebc8b337f5d96bd2e
170cd15e24a7a88243a6ea80aabadc0fc0e6e177
refs/heads/master
2020-03-11T11:42:39.262834
2018-04-18T01:28:23
2018-04-18T01:28:23
129,976,755
0
0
BSD-3-Clause
2018-04-17T23:33:23
2018-04-17T23:33:23
null
UTF-8
C++
false
false
1,308
hpp
#ifndef BOOST_MPL_AT_HPP_INCLUDED #define BOOST_MPL_AT_HPP_INCLUDED // Copyright Aleksey Gurtovoy 2000-2004 // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // // See http://www.boost.org/libs/mpl for documentation. // $Source: /physbam_repository/External_Libraries/Archives/boost/boost/mpl/at.hpp,v $ // $Date: 2007/02/12 18:25:23 $ // $Revision: 1.1 $ #include <boost/mpl/at_fwd.hpp> #include <boost/mpl/aux_/at_impl.hpp> #include <boost/mpl/long.hpp> #include <boost/mpl/sequence_tag.hpp> #include <boost/mpl/aux_/na_spec.hpp> #include <boost/mpl/aux_/lambda_support.hpp> #include <boost/mpl/aux_/nttp_decl.hpp> namespace boost { namespace mpl { template< typename BOOST_MPL_AUX_NA_PARAM(Sequence) , typename BOOST_MPL_AUX_NA_PARAM(N) > struct at : at_impl< typename sequence_tag<Sequence>::type > ::template apply< Sequence,N > { BOOST_MPL_AUX_LAMBDA_SUPPORT(2,at,(Sequence,N)) }; template< typename Sequence , BOOST_MPL_AUX_NTTP_DECL(long, N) > struct at_c : at_impl< typename sequence_tag<Sequence>::type > ::template apply< Sequence,mpl::long_<N> > { }; BOOST_MPL_AUX_NA_SPEC(2, at) }} #endif // BOOST_MPL_AT_HPP_INCLUDED
[ "quhang@stanford.edu" ]
quhang@stanford.edu
21c96ec76156288fb0c8d7cb51289287c3b1b2bf
5e24635a702212739eb72d63ee9ac2175bb36c4d
/errormessage.h
7276067c91bf38c36134a7f53d82056b16c5adb6
[]
no_license
MATF-RS19/RS004-sudoku
4f63b7ef5d7a7215c4dbe6623aeefa99515ea78f
fbdc10b508e839ca524521c39f078ef47146f237
refs/heads/master
2020-04-04T22:55:18.584166
2019-01-12T23:48:28
2019-01-12T23:48:28
156,341,126
0
0
null
null
null
null
UTF-8
C++
false
false
481
h
#ifndef ERRORMESSAGE_H #define ERRORMESSAGE_H #include<QKeyEvent> #include <QWidget> class ErrorMessage : public QWidget { Q_OBJECT public: explicit ErrorMessage(QString s, QWidget *parent = nullptr); signals: public slots: /* Closes the current window */ void exit(); protected: /* Handles keyboard inputs * Only the escape key is defined and causes the window to close */ void keyPressEvent(QKeyEvent *e); }; #endif // ERRORMESSAGE_H
[ "radvuj@gmail.com" ]
radvuj@gmail.com
a62ac021d0e3c534e93fdb46d818c2d401cc440c
5f9b26a41102c38da28b8f757a5586f9bc7cf71a
/crates/zig_build_bin_windows_x86_64/zig-windows-x86_64-0.5.0+80ff549e2/lib/zig/libc/include/any-windows-any/commoncontrols.h
94272945cac0d3ba6d594056bc0a7802586c864f
[ "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-public-domain", "MIT" ]
permissive
jeremyBanks/zig_with_cargo
f8e65f14adf17ed8d477f0856257422c2158c63f
f8ee46b891bbcdca7ff20f5cad64aa94c5a1d2d1
refs/heads/master
2021-02-06T10:26:17.614138
2020-03-09T04:46:26
2020-03-09T04:46:26
243,905,553
4
1
null
null
null
null
UTF-8
C++
false
false
39,767
h
/*** Autogenerated by WIDL 4.12.1 from include/commoncontrols.idl - Do not edit ***/ #ifdef _WIN32 #ifndef __REQUIRED_RPCNDR_H_VERSION__ #define __REQUIRED_RPCNDR_H_VERSION__ 475 #endif #include <rpc.h> #include <rpcndr.h> #endif #ifndef COM_NO_WINDOWS_H #include <windows.h> #include <ole2.h> #endif #ifndef __commoncontrols_h__ #define __commoncontrols_h__ /* Forward declarations */ #ifndef __IImageList_FWD_DEFINED__ #define __IImageList_FWD_DEFINED__ typedef interface IImageList IImageList; #ifdef __cplusplus interface IImageList; #endif /* __cplusplus */ #endif #ifndef __IImageList2_FWD_DEFINED__ #define __IImageList2_FWD_DEFINED__ typedef interface IImageList2 IImageList2; #ifdef __cplusplus interface IImageList2; #endif /* __cplusplus */ #endif #ifndef __ImageList_FWD_DEFINED__ #define __ImageList_FWD_DEFINED__ #ifdef __cplusplus typedef class ImageList ImageList; #else typedef struct ImageList ImageList; #endif /* defined __cplusplus */ #endif /* defined __ImageList_FWD_DEFINED__ */ /* Headers for imported files */ #include <oaidl.h> #include <ocidl.h> #ifdef __cplusplus extern "C" { #endif /** * This file is part of the mingw-w64 runtime package. * No warranty is given; refer to the file DISCLAIMER within this package. */ #include <winapifamily.h> #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) #ifndef WINCOMMCTRLAPI #ifndef _COMCTL32_ #define WINCOMMCTRLAPI DECLSPEC_IMPORT #else #define WINCOMMCTRLAPI #endif #endif #ifdef __WIDL__ typedef DWORD RGBQUAD; typedef IUnknown *HIMAGELIST; typedef struct _IMAGELIST *HIMAGELIST; typedef struct _IMAGELISTDRAWPARAMS { DWORD cbSize; HIMAGELIST himl; int i; HDC hdcDst; int x; int y; int cx; int cy; int xBitmap; int yBitmap; COLORREF rgbBk; COLORREF rgbFg; UINT fStyle; DWORD dwRop; DWORD fState; DWORD Frame; COLORREF crEffect; } IMAGELISTDRAWPARAMS; typedef IMAGELISTDRAWPARAMS *LPIMAGELISTDRAWPARAMS; typedef struct tagIMAGEINFO { HBITMAP hbmImage; HBITMAP hbmMask; int Unused1; int Unused2; RECT rcImage; } IMAGEINFO; typedef IMAGEINFO *LPIMAGEINFO; #endif #define ILIF_ALPHA 0x1 #define ILIF_LOWQUALITY 0x2 #define ILDRF_IMAGELOWQUALITY 0x1 #define ILDRF_OVERLAYLOWQUALITY 0x10 #define ILR_DEFAULT 0x0 #define ILR_HORIZONTAL_LEFT 0x0 #define ILR_HORIZONTAL_CENTER 0x1 #define ILR_HORIZONTAL_RIGHT 0x2 #define ILR_VERTICAL_TOP 0x0 #define ILR_VERTICAL_CENTER 0x10 #define ILR_VERTICAL_BOTTOM 0x20 #define ILR_SCALE_CLIP 0x0 #define ILR_SCALE_ASPECTRATIO 0x100 #define ILGOS_ALWAYS 0x0 #define ILGOS_FROMSTANDBY 0x1 #define ILFIP_ALWAYS 0x0 #define ILFIP_FROMSTANDBY 0x1 #define ILDI_PURGE 0x1 #define ILDI_STANDBY 0x2 #define ILDI_RESETACCESS 0x4 #define ILDI_QUERYACCESS 0x8 #if NTDDI_VERSION >= 0x06000000 WINCOMMCTRLAPI HRESULT WINAPI ImageList_CoCreateInstance (REFCLSID rclsid, const IUnknown *punkOuter, REFIID riid, void **ppv); #endif typedef struct tagIMAGELISTSTATS { DWORD cbSize; int cAlloc; int cUsed; int cStandby; } IMAGELISTSTATS; /***************************************************************************** * IImageList interface */ #ifndef __IImageList_INTERFACE_DEFINED__ #define __IImageList_INTERFACE_DEFINED__ DEFINE_GUID(IID_IImageList, 0x46eb5926, 0x582e, 0x4017, 0x9f,0xdf, 0xe8,0x99,0x8d,0xaa,0x09,0x50); #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("46eb5926-582e-4017-9fdf-e8998daa0950") IImageList : public IUnknown { virtual HRESULT STDMETHODCALLTYPE Add( HBITMAP hbmImage, HBITMAP hbmMask, int *pi) = 0; virtual HRESULT STDMETHODCALLTYPE ReplaceIcon( int i, HICON hicon, int *pi) = 0; virtual HRESULT STDMETHODCALLTYPE SetOverlayImage( int iImage, int iOverlay) = 0; virtual HRESULT STDMETHODCALLTYPE Replace( int i, HBITMAP hbmImage, HBITMAP hbmMask) = 0; virtual HRESULT STDMETHODCALLTYPE AddMasked( HBITMAP hbmImage, COLORREF crMask, int *pi) = 0; virtual HRESULT STDMETHODCALLTYPE Draw( IMAGELISTDRAWPARAMS *pimldp) = 0; virtual HRESULT STDMETHODCALLTYPE Remove( int i) = 0; virtual HRESULT STDMETHODCALLTYPE GetIcon( int i, UINT flags, HICON *picon) = 0; virtual HRESULT STDMETHODCALLTYPE GetImageInfo( int i, IMAGEINFO *pImageInfo) = 0; virtual HRESULT STDMETHODCALLTYPE Copy( int iDst, IUnknown *punkSrc, int iSrc, UINT uFlags) = 0; virtual HRESULT STDMETHODCALLTYPE Merge( int i1, IUnknown *punk2, int i2, int dx, int dy, REFIID riid, void **ppv) = 0; virtual HRESULT STDMETHODCALLTYPE Clone( REFIID riid, void **ppv) = 0; virtual HRESULT STDMETHODCALLTYPE GetImageRect( int i, RECT *prc) = 0; virtual HRESULT STDMETHODCALLTYPE GetIconSize( int *cx, int *cy) = 0; virtual HRESULT STDMETHODCALLTYPE SetIconSize( int cx, int cy) = 0; virtual HRESULT STDMETHODCALLTYPE GetImageCount( int *pi) = 0; virtual HRESULT STDMETHODCALLTYPE SetImageCount( UINT uNewCount) = 0; virtual HRESULT STDMETHODCALLTYPE SetBkColor( COLORREF clrBk, COLORREF *pclr) = 0; virtual HRESULT STDMETHODCALLTYPE GetBkColor( COLORREF *pclr) = 0; virtual HRESULT STDMETHODCALLTYPE BeginDrag( int iTrack, int dxHotspot, int dyHotspot) = 0; virtual HRESULT STDMETHODCALLTYPE EndDrag( ) = 0; virtual HRESULT STDMETHODCALLTYPE DragEnter( HWND hwndLock, int x, int y) = 0; virtual HRESULT STDMETHODCALLTYPE DragLeave( HWND hwndLock) = 0; virtual HRESULT STDMETHODCALLTYPE DragMove( int x, int y) = 0; virtual HRESULT STDMETHODCALLTYPE SetDragCursorImage( IUnknown *punk, int iDrag, int dxHotspot, int dyHotspot) = 0; virtual HRESULT STDMETHODCALLTYPE DragShowNolock( WINBOOL fShow) = 0; virtual HRESULT STDMETHODCALLTYPE GetDragImage( POINT *ppt, POINT *pptHotspot, REFIID riid, void **ppv) = 0; virtual HRESULT STDMETHODCALLTYPE GetItemFlags( int i, DWORD *dwFlags) = 0; virtual HRESULT STDMETHODCALLTYPE GetOverlayImage( int iOverlay, int *piIndex) = 0; }; #ifdef __CRT_UUID_DECL __CRT_UUID_DECL(IImageList, 0x46eb5926, 0x582e, 0x4017, 0x9f,0xdf, 0xe8,0x99,0x8d,0xaa,0x09,0x50) #endif #else typedef struct IImageListVtbl { BEGIN_INTERFACE /*** IUnknown methods ***/ HRESULT (STDMETHODCALLTYPE *QueryInterface)( IImageList *This, REFIID riid, void **ppvObject); ULONG (STDMETHODCALLTYPE *AddRef)( IImageList *This); ULONG (STDMETHODCALLTYPE *Release)( IImageList *This); /*** IImageList methods ***/ HRESULT (STDMETHODCALLTYPE *Add)( IImageList *This, HBITMAP hbmImage, HBITMAP hbmMask, int *pi); HRESULT (STDMETHODCALLTYPE *ReplaceIcon)( IImageList *This, int i, HICON hicon, int *pi); HRESULT (STDMETHODCALLTYPE *SetOverlayImage)( IImageList *This, int iImage, int iOverlay); HRESULT (STDMETHODCALLTYPE *Replace)( IImageList *This, int i, HBITMAP hbmImage, HBITMAP hbmMask); HRESULT (STDMETHODCALLTYPE *AddMasked)( IImageList *This, HBITMAP hbmImage, COLORREF crMask, int *pi); HRESULT (STDMETHODCALLTYPE *Draw)( IImageList *This, IMAGELISTDRAWPARAMS *pimldp); HRESULT (STDMETHODCALLTYPE *Remove)( IImageList *This, int i); HRESULT (STDMETHODCALLTYPE *GetIcon)( IImageList *This, int i, UINT flags, HICON *picon); HRESULT (STDMETHODCALLTYPE *GetImageInfo)( IImageList *This, int i, IMAGEINFO *pImageInfo); HRESULT (STDMETHODCALLTYPE *Copy)( IImageList *This, int iDst, IUnknown *punkSrc, int iSrc, UINT uFlags); HRESULT (STDMETHODCALLTYPE *Merge)( IImageList *This, int i1, IUnknown *punk2, int i2, int dx, int dy, REFIID riid, void **ppv); HRESULT (STDMETHODCALLTYPE *Clone)( IImageList *This, REFIID riid, void **ppv); HRESULT (STDMETHODCALLTYPE *GetImageRect)( IImageList *This, int i, RECT *prc); HRESULT (STDMETHODCALLTYPE *GetIconSize)( IImageList *This, int *cx, int *cy); HRESULT (STDMETHODCALLTYPE *SetIconSize)( IImageList *This, int cx, int cy); HRESULT (STDMETHODCALLTYPE *GetImageCount)( IImageList *This, int *pi); HRESULT (STDMETHODCALLTYPE *SetImageCount)( IImageList *This, UINT uNewCount); HRESULT (STDMETHODCALLTYPE *SetBkColor)( IImageList *This, COLORREF clrBk, COLORREF *pclr); HRESULT (STDMETHODCALLTYPE *GetBkColor)( IImageList *This, COLORREF *pclr); HRESULT (STDMETHODCALLTYPE *BeginDrag)( IImageList *This, int iTrack, int dxHotspot, int dyHotspot); HRESULT (STDMETHODCALLTYPE *EndDrag)( IImageList *This); HRESULT (STDMETHODCALLTYPE *DragEnter)( IImageList *This, HWND hwndLock, int x, int y); HRESULT (STDMETHODCALLTYPE *DragLeave)( IImageList *This, HWND hwndLock); HRESULT (STDMETHODCALLTYPE *DragMove)( IImageList *This, int x, int y); HRESULT (STDMETHODCALLTYPE *SetDragCursorImage)( IImageList *This, IUnknown *punk, int iDrag, int dxHotspot, int dyHotspot); HRESULT (STDMETHODCALLTYPE *DragShowNolock)( IImageList *This, WINBOOL fShow); HRESULT (STDMETHODCALLTYPE *GetDragImage)( IImageList *This, POINT *ppt, POINT *pptHotspot, REFIID riid, void **ppv); HRESULT (STDMETHODCALLTYPE *GetItemFlags)( IImageList *This, int i, DWORD *dwFlags); HRESULT (STDMETHODCALLTYPE *GetOverlayImage)( IImageList *This, int iOverlay, int *piIndex); END_INTERFACE } IImageListVtbl; interface IImageList { CONST_VTBL IImageListVtbl* lpVtbl; }; #ifdef COBJMACROS #ifndef WIDL_C_INLINE_WRAPPERS /*** IUnknown methods ***/ #define IImageList_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject) #define IImageList_AddRef(This) (This)->lpVtbl->AddRef(This) #define IImageList_Release(This) (This)->lpVtbl->Release(This) /*** IImageList methods ***/ #define IImageList_Add(This,hbmImage,hbmMask,pi) (This)->lpVtbl->Add(This,hbmImage,hbmMask,pi) #define IImageList_ReplaceIcon(This,i,hicon,pi) (This)->lpVtbl->ReplaceIcon(This,i,hicon,pi) #define IImageList_SetOverlayImage(This,iImage,iOverlay) (This)->lpVtbl->SetOverlayImage(This,iImage,iOverlay) #define IImageList_Replace(This,i,hbmImage,hbmMask) (This)->lpVtbl->Replace(This,i,hbmImage,hbmMask) #define IImageList_AddMasked(This,hbmImage,crMask,pi) (This)->lpVtbl->AddMasked(This,hbmImage,crMask,pi) #define IImageList_Draw(This,pimldp) (This)->lpVtbl->Draw(This,pimldp) #define IImageList_Remove(This,i) (This)->lpVtbl->Remove(This,i) #define IImageList_GetIcon(This,i,flags,picon) (This)->lpVtbl->GetIcon(This,i,flags,picon) #define IImageList_GetImageInfo(This,i,pImageInfo) (This)->lpVtbl->GetImageInfo(This,i,pImageInfo) #define IImageList_Copy(This,iDst,punkSrc,iSrc,uFlags) (This)->lpVtbl->Copy(This,iDst,punkSrc,iSrc,uFlags) #define IImageList_Merge(This,i1,punk2,i2,dx,dy,riid,ppv) (This)->lpVtbl->Merge(This,i1,punk2,i2,dx,dy,riid,ppv) #define IImageList_Clone(This,riid,ppv) (This)->lpVtbl->Clone(This,riid,ppv) #define IImageList_GetImageRect(This,i,prc) (This)->lpVtbl->GetImageRect(This,i,prc) #define IImageList_GetIconSize(This,cx,cy) (This)->lpVtbl->GetIconSize(This,cx,cy) #define IImageList_SetIconSize(This,cx,cy) (This)->lpVtbl->SetIconSize(This,cx,cy) #define IImageList_GetImageCount(This,pi) (This)->lpVtbl->GetImageCount(This,pi) #define IImageList_SetImageCount(This,uNewCount) (This)->lpVtbl->SetImageCount(This,uNewCount) #define IImageList_SetBkColor(This,clrBk,pclr) (This)->lpVtbl->SetBkColor(This,clrBk,pclr) #define IImageList_GetBkColor(This,pclr) (This)->lpVtbl->GetBkColor(This,pclr) #define IImageList_BeginDrag(This,iTrack,dxHotspot,dyHotspot) (This)->lpVtbl->BeginDrag(This,iTrack,dxHotspot,dyHotspot) #define IImageList_EndDrag(This) (This)->lpVtbl->EndDrag(This) #define IImageList_DragEnter(This,hwndLock,x,y) (This)->lpVtbl->DragEnter(This,hwndLock,x,y) #define IImageList_DragLeave(This,hwndLock) (This)->lpVtbl->DragLeave(This,hwndLock) #define IImageList_DragMove(This,x,y) (This)->lpVtbl->DragMove(This,x,y) #define IImageList_SetDragCursorImage(This,punk,iDrag,dxHotspot,dyHotspot) (This)->lpVtbl->SetDragCursorImage(This,punk,iDrag,dxHotspot,dyHotspot) #define IImageList_DragShowNolock(This,fShow) (This)->lpVtbl->DragShowNolock(This,fShow) #define IImageList_GetDragImage(This,ppt,pptHotspot,riid,ppv) (This)->lpVtbl->GetDragImage(This,ppt,pptHotspot,riid,ppv) #define IImageList_GetItemFlags(This,i,dwFlags) (This)->lpVtbl->GetItemFlags(This,i,dwFlags) #define IImageList_GetOverlayImage(This,iOverlay,piIndex) (This)->lpVtbl->GetOverlayImage(This,iOverlay,piIndex) #else /*** IUnknown methods ***/ static FORCEINLINE HRESULT IImageList_QueryInterface(IImageList* This,REFIID riid,void **ppvObject) { return This->lpVtbl->QueryInterface(This,riid,ppvObject); } static FORCEINLINE ULONG IImageList_AddRef(IImageList* This) { return This->lpVtbl->AddRef(This); } static FORCEINLINE ULONG IImageList_Release(IImageList* This) { return This->lpVtbl->Release(This); } /*** IImageList methods ***/ static FORCEINLINE HRESULT IImageList_Add(IImageList* This,HBITMAP hbmImage,HBITMAP hbmMask,int *pi) { return This->lpVtbl->Add(This,hbmImage,hbmMask,pi); } static FORCEINLINE HRESULT IImageList_ReplaceIcon(IImageList* This,int i,HICON hicon,int *pi) { return This->lpVtbl->ReplaceIcon(This,i,hicon,pi); } static FORCEINLINE HRESULT IImageList_SetOverlayImage(IImageList* This,int iImage,int iOverlay) { return This->lpVtbl->SetOverlayImage(This,iImage,iOverlay); } static FORCEINLINE HRESULT IImageList_Replace(IImageList* This,int i,HBITMAP hbmImage,HBITMAP hbmMask) { return This->lpVtbl->Replace(This,i,hbmImage,hbmMask); } static FORCEINLINE HRESULT IImageList_AddMasked(IImageList* This,HBITMAP hbmImage,COLORREF crMask,int *pi) { return This->lpVtbl->AddMasked(This,hbmImage,crMask,pi); } static FORCEINLINE HRESULT IImageList_Draw(IImageList* This,IMAGELISTDRAWPARAMS *pimldp) { return This->lpVtbl->Draw(This,pimldp); } static FORCEINLINE HRESULT IImageList_Remove(IImageList* This,int i) { return This->lpVtbl->Remove(This,i); } static FORCEINLINE HRESULT IImageList_GetIcon(IImageList* This,int i,UINT flags,HICON *picon) { return This->lpVtbl->GetIcon(This,i,flags,picon); } static FORCEINLINE HRESULT IImageList_GetImageInfo(IImageList* This,int i,IMAGEINFO *pImageInfo) { return This->lpVtbl->GetImageInfo(This,i,pImageInfo); } static FORCEINLINE HRESULT IImageList_Copy(IImageList* This,int iDst,IUnknown *punkSrc,int iSrc,UINT uFlags) { return This->lpVtbl->Copy(This,iDst,punkSrc,iSrc,uFlags); } static FORCEINLINE HRESULT IImageList_Merge(IImageList* This,int i1,IUnknown *punk2,int i2,int dx,int dy,REFIID riid,void **ppv) { return This->lpVtbl->Merge(This,i1,punk2,i2,dx,dy,riid,ppv); } static FORCEINLINE HRESULT IImageList_Clone(IImageList* This,REFIID riid,void **ppv) { return This->lpVtbl->Clone(This,riid,ppv); } static FORCEINLINE HRESULT IImageList_GetImageRect(IImageList* This,int i,RECT *prc) { return This->lpVtbl->GetImageRect(This,i,prc); } static FORCEINLINE HRESULT IImageList_GetIconSize(IImageList* This,int *cx,int *cy) { return This->lpVtbl->GetIconSize(This,cx,cy); } static FORCEINLINE HRESULT IImageList_SetIconSize(IImageList* This,int cx,int cy) { return This->lpVtbl->SetIconSize(This,cx,cy); } static FORCEINLINE HRESULT IImageList_GetImageCount(IImageList* This,int *pi) { return This->lpVtbl->GetImageCount(This,pi); } static FORCEINLINE HRESULT IImageList_SetImageCount(IImageList* This,UINT uNewCount) { return This->lpVtbl->SetImageCount(This,uNewCount); } static FORCEINLINE HRESULT IImageList_SetBkColor(IImageList* This,COLORREF clrBk,COLORREF *pclr) { return This->lpVtbl->SetBkColor(This,clrBk,pclr); } static FORCEINLINE HRESULT IImageList_GetBkColor(IImageList* This,COLORREF *pclr) { return This->lpVtbl->GetBkColor(This,pclr); } static FORCEINLINE HRESULT IImageList_BeginDrag(IImageList* This,int iTrack,int dxHotspot,int dyHotspot) { return This->lpVtbl->BeginDrag(This,iTrack,dxHotspot,dyHotspot); } static FORCEINLINE HRESULT IImageList_EndDrag(IImageList* This) { return This->lpVtbl->EndDrag(This); } static FORCEINLINE HRESULT IImageList_DragEnter(IImageList* This,HWND hwndLock,int x,int y) { return This->lpVtbl->DragEnter(This,hwndLock,x,y); } static FORCEINLINE HRESULT IImageList_DragLeave(IImageList* This,HWND hwndLock) { return This->lpVtbl->DragLeave(This,hwndLock); } static FORCEINLINE HRESULT IImageList_DragMove(IImageList* This,int x,int y) { return This->lpVtbl->DragMove(This,x,y); } static FORCEINLINE HRESULT IImageList_SetDragCursorImage(IImageList* This,IUnknown *punk,int iDrag,int dxHotspot,int dyHotspot) { return This->lpVtbl->SetDragCursorImage(This,punk,iDrag,dxHotspot,dyHotspot); } static FORCEINLINE HRESULT IImageList_DragShowNolock(IImageList* This,WINBOOL fShow) { return This->lpVtbl->DragShowNolock(This,fShow); } static FORCEINLINE HRESULT IImageList_GetDragImage(IImageList* This,POINT *ppt,POINT *pptHotspot,REFIID riid,void **ppv) { return This->lpVtbl->GetDragImage(This,ppt,pptHotspot,riid,ppv); } static FORCEINLINE HRESULT IImageList_GetItemFlags(IImageList* This,int i,DWORD *dwFlags) { return This->lpVtbl->GetItemFlags(This,i,dwFlags); } static FORCEINLINE HRESULT IImageList_GetOverlayImage(IImageList* This,int iOverlay,int *piIndex) { return This->lpVtbl->GetOverlayImage(This,iOverlay,piIndex); } #endif #endif #endif #endif /* __IImageList_INTERFACE_DEFINED__ */ /***************************************************************************** * IImageList2 interface */ #ifndef __IImageList2_INTERFACE_DEFINED__ #define __IImageList2_INTERFACE_DEFINED__ DEFINE_GUID(IID_IImageList2, 0x192b9d83, 0x50fc, 0x457b, 0x90,0xa0, 0x2b,0x82,0xa8,0xb5,0xda,0xe1); #if defined(__cplusplus) && !defined(CINTERFACE) MIDL_INTERFACE("192b9d83-50fc-457b-90a0-2b82a8b5dae1") IImageList2 : public IImageList { virtual HRESULT STDMETHODCALLTYPE Resize( int cxNewIconSize, int cyNewIconSize) = 0; virtual HRESULT STDMETHODCALLTYPE GetOriginalSize( int iImage, DWORD dwFlags, int *pcx, int *pcy) = 0; virtual HRESULT STDMETHODCALLTYPE SetOriginalSize( int iImage, int cx, int cy) = 0; virtual HRESULT STDMETHODCALLTYPE SetCallback( IUnknown *punk) = 0; virtual HRESULT STDMETHODCALLTYPE GetCallback( REFIID riid, void **ppv) = 0; virtual HRESULT STDMETHODCALLTYPE ForceImagePresent( int iImage, DWORD dwFlags) = 0; virtual HRESULT STDMETHODCALLTYPE DiscardImages( int iFirstImage, int iLastImage, DWORD dwFlags) = 0; virtual HRESULT STDMETHODCALLTYPE PreloadImages( IMAGELISTDRAWPARAMS *pimldp) = 0; virtual HRESULT STDMETHODCALLTYPE GetStatistics( IMAGELISTSTATS *pils) = 0; virtual HRESULT STDMETHODCALLTYPE Initialize( int cx, int cy, UINT flags, int cInitial, int cGrow) = 0; virtual HRESULT STDMETHODCALLTYPE Replace2( int i, HBITMAP hbmImage, HBITMAP hbmMask, IUnknown *punk, DWORD dwFlags) = 0; virtual HRESULT STDMETHODCALLTYPE ReplaceFromImageList( int i, IImageList *pil, int iSrc, IUnknown *punk, DWORD dwFlags) = 0; }; #ifdef __CRT_UUID_DECL __CRT_UUID_DECL(IImageList2, 0x192b9d83, 0x50fc, 0x457b, 0x90,0xa0, 0x2b,0x82,0xa8,0xb5,0xda,0xe1) #endif #else typedef struct IImageList2Vtbl { BEGIN_INTERFACE /*** IUnknown methods ***/ HRESULT (STDMETHODCALLTYPE *QueryInterface)( IImageList2 *This, REFIID riid, void **ppvObject); ULONG (STDMETHODCALLTYPE *AddRef)( IImageList2 *This); ULONG (STDMETHODCALLTYPE *Release)( IImageList2 *This); /*** IImageList methods ***/ HRESULT (STDMETHODCALLTYPE *Add)( IImageList2 *This, HBITMAP hbmImage, HBITMAP hbmMask, int *pi); HRESULT (STDMETHODCALLTYPE *ReplaceIcon)( IImageList2 *This, int i, HICON hicon, int *pi); HRESULT (STDMETHODCALLTYPE *SetOverlayImage)( IImageList2 *This, int iImage, int iOverlay); HRESULT (STDMETHODCALLTYPE *Replace)( IImageList2 *This, int i, HBITMAP hbmImage, HBITMAP hbmMask); HRESULT (STDMETHODCALLTYPE *AddMasked)( IImageList2 *This, HBITMAP hbmImage, COLORREF crMask, int *pi); HRESULT (STDMETHODCALLTYPE *Draw)( IImageList2 *This, IMAGELISTDRAWPARAMS *pimldp); HRESULT (STDMETHODCALLTYPE *Remove)( IImageList2 *This, int i); HRESULT (STDMETHODCALLTYPE *GetIcon)( IImageList2 *This, int i, UINT flags, HICON *picon); HRESULT (STDMETHODCALLTYPE *GetImageInfo)( IImageList2 *This, int i, IMAGEINFO *pImageInfo); HRESULT (STDMETHODCALLTYPE *Copy)( IImageList2 *This, int iDst, IUnknown *punkSrc, int iSrc, UINT uFlags); HRESULT (STDMETHODCALLTYPE *Merge)( IImageList2 *This, int i1, IUnknown *punk2, int i2, int dx, int dy, REFIID riid, void **ppv); HRESULT (STDMETHODCALLTYPE *Clone)( IImageList2 *This, REFIID riid, void **ppv); HRESULT (STDMETHODCALLTYPE *GetImageRect)( IImageList2 *This, int i, RECT *prc); HRESULT (STDMETHODCALLTYPE *GetIconSize)( IImageList2 *This, int *cx, int *cy); HRESULT (STDMETHODCALLTYPE *SetIconSize)( IImageList2 *This, int cx, int cy); HRESULT (STDMETHODCALLTYPE *GetImageCount)( IImageList2 *This, int *pi); HRESULT (STDMETHODCALLTYPE *SetImageCount)( IImageList2 *This, UINT uNewCount); HRESULT (STDMETHODCALLTYPE *SetBkColor)( IImageList2 *This, COLORREF clrBk, COLORREF *pclr); HRESULT (STDMETHODCALLTYPE *GetBkColor)( IImageList2 *This, COLORREF *pclr); HRESULT (STDMETHODCALLTYPE *BeginDrag)( IImageList2 *This, int iTrack, int dxHotspot, int dyHotspot); HRESULT (STDMETHODCALLTYPE *EndDrag)( IImageList2 *This); HRESULT (STDMETHODCALLTYPE *DragEnter)( IImageList2 *This, HWND hwndLock, int x, int y); HRESULT (STDMETHODCALLTYPE *DragLeave)( IImageList2 *This, HWND hwndLock); HRESULT (STDMETHODCALLTYPE *DragMove)( IImageList2 *This, int x, int y); HRESULT (STDMETHODCALLTYPE *SetDragCursorImage)( IImageList2 *This, IUnknown *punk, int iDrag, int dxHotspot, int dyHotspot); HRESULT (STDMETHODCALLTYPE *DragShowNolock)( IImageList2 *This, WINBOOL fShow); HRESULT (STDMETHODCALLTYPE *GetDragImage)( IImageList2 *This, POINT *ppt, POINT *pptHotspot, REFIID riid, void **ppv); HRESULT (STDMETHODCALLTYPE *GetItemFlags)( IImageList2 *This, int i, DWORD *dwFlags); HRESULT (STDMETHODCALLTYPE *GetOverlayImage)( IImageList2 *This, int iOverlay, int *piIndex); /*** IImageList2 methods ***/ HRESULT (STDMETHODCALLTYPE *Resize)( IImageList2 *This, int cxNewIconSize, int cyNewIconSize); HRESULT (STDMETHODCALLTYPE *GetOriginalSize)( IImageList2 *This, int iImage, DWORD dwFlags, int *pcx, int *pcy); HRESULT (STDMETHODCALLTYPE *SetOriginalSize)( IImageList2 *This, int iImage, int cx, int cy); HRESULT (STDMETHODCALLTYPE *SetCallback)( IImageList2 *This, IUnknown *punk); HRESULT (STDMETHODCALLTYPE *GetCallback)( IImageList2 *This, REFIID riid, void **ppv); HRESULT (STDMETHODCALLTYPE *ForceImagePresent)( IImageList2 *This, int iImage, DWORD dwFlags); HRESULT (STDMETHODCALLTYPE *DiscardImages)( IImageList2 *This, int iFirstImage, int iLastImage, DWORD dwFlags); HRESULT (STDMETHODCALLTYPE *PreloadImages)( IImageList2 *This, IMAGELISTDRAWPARAMS *pimldp); HRESULT (STDMETHODCALLTYPE *GetStatistics)( IImageList2 *This, IMAGELISTSTATS *pils); HRESULT (STDMETHODCALLTYPE *Initialize)( IImageList2 *This, int cx, int cy, UINT flags, int cInitial, int cGrow); HRESULT (STDMETHODCALLTYPE *Replace2)( IImageList2 *This, int i, HBITMAP hbmImage, HBITMAP hbmMask, IUnknown *punk, DWORD dwFlags); HRESULT (STDMETHODCALLTYPE *ReplaceFromImageList)( IImageList2 *This, int i, IImageList *pil, int iSrc, IUnknown *punk, DWORD dwFlags); END_INTERFACE } IImageList2Vtbl; interface IImageList2 { CONST_VTBL IImageList2Vtbl* lpVtbl; }; #ifdef COBJMACROS #ifndef WIDL_C_INLINE_WRAPPERS /*** IUnknown methods ***/ #define IImageList2_QueryInterface(This,riid,ppvObject) (This)->lpVtbl->QueryInterface(This,riid,ppvObject) #define IImageList2_AddRef(This) (This)->lpVtbl->AddRef(This) #define IImageList2_Release(This) (This)->lpVtbl->Release(This) /*** IImageList methods ***/ #define IImageList2_Add(This,hbmImage,hbmMask,pi) (This)->lpVtbl->Add(This,hbmImage,hbmMask,pi) #define IImageList2_ReplaceIcon(This,i,hicon,pi) (This)->lpVtbl->ReplaceIcon(This,i,hicon,pi) #define IImageList2_SetOverlayImage(This,iImage,iOverlay) (This)->lpVtbl->SetOverlayImage(This,iImage,iOverlay) #define IImageList2_Replace(This,i,hbmImage,hbmMask) (This)->lpVtbl->Replace(This,i,hbmImage,hbmMask) #define IImageList2_AddMasked(This,hbmImage,crMask,pi) (This)->lpVtbl->AddMasked(This,hbmImage,crMask,pi) #define IImageList2_Draw(This,pimldp) (This)->lpVtbl->Draw(This,pimldp) #define IImageList2_Remove(This,i) (This)->lpVtbl->Remove(This,i) #define IImageList2_GetIcon(This,i,flags,picon) (This)->lpVtbl->GetIcon(This,i,flags,picon) #define IImageList2_GetImageInfo(This,i,pImageInfo) (This)->lpVtbl->GetImageInfo(This,i,pImageInfo) #define IImageList2_Copy(This,iDst,punkSrc,iSrc,uFlags) (This)->lpVtbl->Copy(This,iDst,punkSrc,iSrc,uFlags) #define IImageList2_Merge(This,i1,punk2,i2,dx,dy,riid,ppv) (This)->lpVtbl->Merge(This,i1,punk2,i2,dx,dy,riid,ppv) #define IImageList2_Clone(This,riid,ppv) (This)->lpVtbl->Clone(This,riid,ppv) #define IImageList2_GetImageRect(This,i,prc) (This)->lpVtbl->GetImageRect(This,i,prc) #define IImageList2_GetIconSize(This,cx,cy) (This)->lpVtbl->GetIconSize(This,cx,cy) #define IImageList2_SetIconSize(This,cx,cy) (This)->lpVtbl->SetIconSize(This,cx,cy) #define IImageList2_GetImageCount(This,pi) (This)->lpVtbl->GetImageCount(This,pi) #define IImageList2_SetImageCount(This,uNewCount) (This)->lpVtbl->SetImageCount(This,uNewCount) #define IImageList2_SetBkColor(This,clrBk,pclr) (This)->lpVtbl->SetBkColor(This,clrBk,pclr) #define IImageList2_GetBkColor(This,pclr) (This)->lpVtbl->GetBkColor(This,pclr) #define IImageList2_BeginDrag(This,iTrack,dxHotspot,dyHotspot) (This)->lpVtbl->BeginDrag(This,iTrack,dxHotspot,dyHotspot) #define IImageList2_EndDrag(This) (This)->lpVtbl->EndDrag(This) #define IImageList2_DragEnter(This,hwndLock,x,y) (This)->lpVtbl->DragEnter(This,hwndLock,x,y) #define IImageList2_DragLeave(This,hwndLock) (This)->lpVtbl->DragLeave(This,hwndLock) #define IImageList2_DragMove(This,x,y) (This)->lpVtbl->DragMove(This,x,y) #define IImageList2_SetDragCursorImage(This,punk,iDrag,dxHotspot,dyHotspot) (This)->lpVtbl->SetDragCursorImage(This,punk,iDrag,dxHotspot,dyHotspot) #define IImageList2_DragShowNolock(This,fShow) (This)->lpVtbl->DragShowNolock(This,fShow) #define IImageList2_GetDragImage(This,ppt,pptHotspot,riid,ppv) (This)->lpVtbl->GetDragImage(This,ppt,pptHotspot,riid,ppv) #define IImageList2_GetItemFlags(This,i,dwFlags) (This)->lpVtbl->GetItemFlags(This,i,dwFlags) #define IImageList2_GetOverlayImage(This,iOverlay,piIndex) (This)->lpVtbl->GetOverlayImage(This,iOverlay,piIndex) /*** IImageList2 methods ***/ #define IImageList2_Resize(This,cxNewIconSize,cyNewIconSize) (This)->lpVtbl->Resize(This,cxNewIconSize,cyNewIconSize) #define IImageList2_GetOriginalSize(This,iImage,dwFlags,pcx,pcy) (This)->lpVtbl->GetOriginalSize(This,iImage,dwFlags,pcx,pcy) #define IImageList2_SetOriginalSize(This,iImage,cx,cy) (This)->lpVtbl->SetOriginalSize(This,iImage,cx,cy) #define IImageList2_SetCallback(This,punk) (This)->lpVtbl->SetCallback(This,punk) #define IImageList2_GetCallback(This,riid,ppv) (This)->lpVtbl->GetCallback(This,riid,ppv) #define IImageList2_ForceImagePresent(This,iImage,dwFlags) (This)->lpVtbl->ForceImagePresent(This,iImage,dwFlags) #define IImageList2_DiscardImages(This,iFirstImage,iLastImage,dwFlags) (This)->lpVtbl->DiscardImages(This,iFirstImage,iLastImage,dwFlags) #define IImageList2_PreloadImages(This,pimldp) (This)->lpVtbl->PreloadImages(This,pimldp) #define IImageList2_GetStatistics(This,pils) (This)->lpVtbl->GetStatistics(This,pils) #define IImageList2_Initialize(This,cx,cy,flags,cInitial,cGrow) (This)->lpVtbl->Initialize(This,cx,cy,flags,cInitial,cGrow) #define IImageList2_Replace2(This,i,hbmImage,hbmMask,punk,dwFlags) (This)->lpVtbl->Replace2(This,i,hbmImage,hbmMask,punk,dwFlags) #define IImageList2_ReplaceFromImageList(This,i,pil,iSrc,punk,dwFlags) (This)->lpVtbl->ReplaceFromImageList(This,i,pil,iSrc,punk,dwFlags) #else /*** IUnknown methods ***/ static FORCEINLINE HRESULT IImageList2_QueryInterface(IImageList2* This,REFIID riid,void **ppvObject) { return This->lpVtbl->QueryInterface(This,riid,ppvObject); } static FORCEINLINE ULONG IImageList2_AddRef(IImageList2* This) { return This->lpVtbl->AddRef(This); } static FORCEINLINE ULONG IImageList2_Release(IImageList2* This) { return This->lpVtbl->Release(This); } /*** IImageList methods ***/ static FORCEINLINE HRESULT IImageList2_Add(IImageList2* This,HBITMAP hbmImage,HBITMAP hbmMask,int *pi) { return This->lpVtbl->Add(This,hbmImage,hbmMask,pi); } static FORCEINLINE HRESULT IImageList2_ReplaceIcon(IImageList2* This,int i,HICON hicon,int *pi) { return This->lpVtbl->ReplaceIcon(This,i,hicon,pi); } static FORCEINLINE HRESULT IImageList2_SetOverlayImage(IImageList2* This,int iImage,int iOverlay) { return This->lpVtbl->SetOverlayImage(This,iImage,iOverlay); } static FORCEINLINE HRESULT IImageList2_Replace(IImageList2* This,int i,HBITMAP hbmImage,HBITMAP hbmMask) { return This->lpVtbl->Replace(This,i,hbmImage,hbmMask); } static FORCEINLINE HRESULT IImageList2_AddMasked(IImageList2* This,HBITMAP hbmImage,COLORREF crMask,int *pi) { return This->lpVtbl->AddMasked(This,hbmImage,crMask,pi); } static FORCEINLINE HRESULT IImageList2_Draw(IImageList2* This,IMAGELISTDRAWPARAMS *pimldp) { return This->lpVtbl->Draw(This,pimldp); } static FORCEINLINE HRESULT IImageList2_Remove(IImageList2* This,int i) { return This->lpVtbl->Remove(This,i); } static FORCEINLINE HRESULT IImageList2_GetIcon(IImageList2* This,int i,UINT flags,HICON *picon) { return This->lpVtbl->GetIcon(This,i,flags,picon); } static FORCEINLINE HRESULT IImageList2_GetImageInfo(IImageList2* This,int i,IMAGEINFO *pImageInfo) { return This->lpVtbl->GetImageInfo(This,i,pImageInfo); } static FORCEINLINE HRESULT IImageList2_Copy(IImageList2* This,int iDst,IUnknown *punkSrc,int iSrc,UINT uFlags) { return This->lpVtbl->Copy(This,iDst,punkSrc,iSrc,uFlags); } static FORCEINLINE HRESULT IImageList2_Merge(IImageList2* This,int i1,IUnknown *punk2,int i2,int dx,int dy,REFIID riid,void **ppv) { return This->lpVtbl->Merge(This,i1,punk2,i2,dx,dy,riid,ppv); } static FORCEINLINE HRESULT IImageList2_Clone(IImageList2* This,REFIID riid,void **ppv) { return This->lpVtbl->Clone(This,riid,ppv); } static FORCEINLINE HRESULT IImageList2_GetImageRect(IImageList2* This,int i,RECT *prc) { return This->lpVtbl->GetImageRect(This,i,prc); } static FORCEINLINE HRESULT IImageList2_GetIconSize(IImageList2* This,int *cx,int *cy) { return This->lpVtbl->GetIconSize(This,cx,cy); } static FORCEINLINE HRESULT IImageList2_SetIconSize(IImageList2* This,int cx,int cy) { return This->lpVtbl->SetIconSize(This,cx,cy); } static FORCEINLINE HRESULT IImageList2_GetImageCount(IImageList2* This,int *pi) { return This->lpVtbl->GetImageCount(This,pi); } static FORCEINLINE HRESULT IImageList2_SetImageCount(IImageList2* This,UINT uNewCount) { return This->lpVtbl->SetImageCount(This,uNewCount); } static FORCEINLINE HRESULT IImageList2_SetBkColor(IImageList2* This,COLORREF clrBk,COLORREF *pclr) { return This->lpVtbl->SetBkColor(This,clrBk,pclr); } static FORCEINLINE HRESULT IImageList2_GetBkColor(IImageList2* This,COLORREF *pclr) { return This->lpVtbl->GetBkColor(This,pclr); } static FORCEINLINE HRESULT IImageList2_BeginDrag(IImageList2* This,int iTrack,int dxHotspot,int dyHotspot) { return This->lpVtbl->BeginDrag(This,iTrack,dxHotspot,dyHotspot); } static FORCEINLINE HRESULT IImageList2_EndDrag(IImageList2* This) { return This->lpVtbl->EndDrag(This); } static FORCEINLINE HRESULT IImageList2_DragEnter(IImageList2* This,HWND hwndLock,int x,int y) { return This->lpVtbl->DragEnter(This,hwndLock,x,y); } static FORCEINLINE HRESULT IImageList2_DragLeave(IImageList2* This,HWND hwndLock) { return This->lpVtbl->DragLeave(This,hwndLock); } static FORCEINLINE HRESULT IImageList2_DragMove(IImageList2* This,int x,int y) { return This->lpVtbl->DragMove(This,x,y); } static FORCEINLINE HRESULT IImageList2_SetDragCursorImage(IImageList2* This,IUnknown *punk,int iDrag,int dxHotspot,int dyHotspot) { return This->lpVtbl->SetDragCursorImage(This,punk,iDrag,dxHotspot,dyHotspot); } static FORCEINLINE HRESULT IImageList2_DragShowNolock(IImageList2* This,WINBOOL fShow) { return This->lpVtbl->DragShowNolock(This,fShow); } static FORCEINLINE HRESULT IImageList2_GetDragImage(IImageList2* This,POINT *ppt,POINT *pptHotspot,REFIID riid,void **ppv) { return This->lpVtbl->GetDragImage(This,ppt,pptHotspot,riid,ppv); } static FORCEINLINE HRESULT IImageList2_GetItemFlags(IImageList2* This,int i,DWORD *dwFlags) { return This->lpVtbl->GetItemFlags(This,i,dwFlags); } static FORCEINLINE HRESULT IImageList2_GetOverlayImage(IImageList2* This,int iOverlay,int *piIndex) { return This->lpVtbl->GetOverlayImage(This,iOverlay,piIndex); } /*** IImageList2 methods ***/ static FORCEINLINE HRESULT IImageList2_Resize(IImageList2* This,int cxNewIconSize,int cyNewIconSize) { return This->lpVtbl->Resize(This,cxNewIconSize,cyNewIconSize); } static FORCEINLINE HRESULT IImageList2_GetOriginalSize(IImageList2* This,int iImage,DWORD dwFlags,int *pcx,int *pcy) { return This->lpVtbl->GetOriginalSize(This,iImage,dwFlags,pcx,pcy); } static FORCEINLINE HRESULT IImageList2_SetOriginalSize(IImageList2* This,int iImage,int cx,int cy) { return This->lpVtbl->SetOriginalSize(This,iImage,cx,cy); } static FORCEINLINE HRESULT IImageList2_SetCallback(IImageList2* This,IUnknown *punk) { return This->lpVtbl->SetCallback(This,punk); } static FORCEINLINE HRESULT IImageList2_GetCallback(IImageList2* This,REFIID riid,void **ppv) { return This->lpVtbl->GetCallback(This,riid,ppv); } static FORCEINLINE HRESULT IImageList2_ForceImagePresent(IImageList2* This,int iImage,DWORD dwFlags) { return This->lpVtbl->ForceImagePresent(This,iImage,dwFlags); } static FORCEINLINE HRESULT IImageList2_DiscardImages(IImageList2* This,int iFirstImage,int iLastImage,DWORD dwFlags) { return This->lpVtbl->DiscardImages(This,iFirstImage,iLastImage,dwFlags); } static FORCEINLINE HRESULT IImageList2_PreloadImages(IImageList2* This,IMAGELISTDRAWPARAMS *pimldp) { return This->lpVtbl->PreloadImages(This,pimldp); } static FORCEINLINE HRESULT IImageList2_GetStatistics(IImageList2* This,IMAGELISTSTATS *pils) { return This->lpVtbl->GetStatistics(This,pils); } static FORCEINLINE HRESULT IImageList2_Initialize(IImageList2* This,int cx,int cy,UINT flags,int cInitial,int cGrow) { return This->lpVtbl->Initialize(This,cx,cy,flags,cInitial,cGrow); } static FORCEINLINE HRESULT IImageList2_Replace2(IImageList2* This,int i,HBITMAP hbmImage,HBITMAP hbmMask,IUnknown *punk,DWORD dwFlags) { return This->lpVtbl->Replace2(This,i,hbmImage,hbmMask,punk,dwFlags); } static FORCEINLINE HRESULT IImageList2_ReplaceFromImageList(IImageList2* This,int i,IImageList *pil,int iSrc,IUnknown *punk,DWORD dwFlags) { return This->lpVtbl->ReplaceFromImageList(This,i,pil,iSrc,punk,dwFlags); } #endif #endif #endif #endif /* __IImageList2_INTERFACE_DEFINED__ */ DEFINE_GUID(LIBID_CommonControlObjects, 0xbcada15b, 0xb428, 0x420c, 0x8d,0x28, 0x02,0x35,0x90,0x92,0x4c,0x9f); /***************************************************************************** * ImageList coclass */ DEFINE_GUID(CLSID_ImageList, 0x7c476ba2, 0x02b1, 0x48f4, 0x80,0x48, 0xb2,0x46,0x19,0xdd,0xc0,0x58); #ifdef __cplusplus class DECLSPEC_UUID("7c476ba2-02b1-48f4-8048-b24619ddc058") ImageList; #ifdef __CRT_UUID_DECL __CRT_UUID_DECL(ImageList, 0x7c476ba2, 0x02b1, 0x48f4, 0x80,0x48, 0xb2,0x46,0x19,0xdd,0xc0,0x58) #endif #endif #endif /* Begin additional prototypes for all interfaces */ /* End additional prototypes */ #ifdef __cplusplus } #endif #endif /* __commoncontrols_h__ */
[ "_@jeremy.ca" ]
_@jeremy.ca
3359bc75de3b1cf65e9ee892869ab19ed6d1c2c8
6175cb64ed4dabd5404f62833b6d82b7e8c6ebb9
/project5/sudoku.cc
1ee336b9a6c61ee196be5916a899f1f3d5f4fa8e
[]
no_license
jscacco/112
63f57a6a140bf0f185757878bfc0b93db811e031
cca2135704edc1023e117f28013c7d6d81c1bdc5
refs/heads/master
2020-04-28T01:33:54.223845
2019-03-10T18:21:07
2019-03-10T18:21:07
174,861,938
0
0
null
null
null
null
UTF-8
C++
false
false
6,882
cc
/****************************************************************************** * * Name: Jack Scacco * * Date: 10-24-17 * * Assignment:Project 5 * * File: sudoku.cc * * Purpose: To create a file that solves a sudoku puzzle * *****************************************************************************/ #include <iostream> #include <cassert> #include <SudokuBoard.h> #include "Stack.h" using namespace std; typedef Stack::Node Node; typedef Stack::Item Item; typedef cs112::SudokuBoard Board; bool canPlace(const Board& board, size_t& row, size_t& col, size_t& value){ // This method checks to see if a value can be placed in a certain location. for(size_t i = 0; i < board.BoardSize; i++){ // Check vertically for conflicts. if(!board.empty(i, col)) if(board.get(i, col) == value) return false; // Check horizontally for conflicts. if(!board.empty(row, i)) if(board.get(row, i) == value) return false; } //Check the smaller square for conflicts size_t baseRow = (row/3)*3; // These 3s are used because that is the size_t baseCol = (col/3)*3; // dimension of the smaller square. for(size_t r = baseRow; r < baseRow + 3; r++) for(size_t c = baseCol; c < baseCol + 3; c++) if(!board.empty(r, c)) if(board.get(r, c) == value) return false; // If there are no conflicts, we can place the number. return true; } bool mostConstrained(const Board& board, size_t& row, size_t& col){ // This method looks for the most constrained spot in the board. // If there are no moves that can possibly be made, false is returned. // Otherwise, true is returned and the passed row and col are updated // to be the most constrained spot. // Nothing can have a value higher than 10, so it is 'out of bounds'. size_t valueCounter = 10; // Check every position for(size_t r=0; r < board.BoardSize; r++) for(size_t c=0; c < board.BoardSize; c++) // If there isn't a value already there, if(board.empty(r, c)){ // check how many values could go there. size_t tempCount = 0; for(size_t val = 1; val <= board.BoardSize; val++) if(canPlace(board, r, c, val)) tempCount ++; // If this spot is more constrained than those already tested, if(tempCount < valueCounter){ // set the row and col to this position. row = r; col = c; valueCounter = tempCount; // Since 1 is the most constrained possible, return if we have it. if(valueCounter == 1) return true; } } // If values could actually go here, return true. if(valueCounter > 0 && valueCounter < 10) return true; // Otherwise, we cannot place any things. return false; } void makeMove(Board& board, Stack& stack, const size_t row, const size_t col, const size_t value){ // This method stores the location of the move in the passed stack // and places the passed value at that location // Store the row and col in the stack for later use. stack.push(row); stack.push(col); // Put the value into the board. board.put(value, row, col); } void undoMove(Board& board, Stack& stack, size_t& row, size_t& col, size_t& value){ // This method 'undoes' the last move by popping it out // of the stack and clearing that spot. // It sets the passed row and col equal to the position of the last move. //Remove the col and the row from the stack and store them. col = stack.top(); stack.pop(); row = stack.top(); stack.pop(); // Store the value in the board and then clear the board value = board.get(row, col); board.clear(row, col); } bool nextValue(Board& board, size_t row, size_t col, size_t& value){ // This method returns true if there is a value starting // at the inputed value that can be placed in the passed space. // It then sets value equal to that new value. // It returns false if nothing after the passed value can be // placed in the spot. // For each value, for(size_t val = value; val <= board.BoardSize; val++){ // Check if you can place the value. if(canPlace(board, row, col, val)){ // If you can place it, modify the passed value and return true. value = val; return true; } } // If you cannot place any value, return false. return false; } bool backtrack(Board& board, Stack& stack){ // This method undoes the last move and tries the // same spot with the next possible value. // If no value after the tested one works, return true. // If one of them does work, return false. // Create some local variables. size_t row = 0; size_t col = 0; size_t value = 0; // Undo the move and increase the val so we can check // all of the values after that one. undoMove(board, stack, row, col, value); value++; // If there is a value after the previous that we can place here, if(nextValue(board, row, col, value)){ // Make that move and return false. makeMove(board, stack, row, col, value); return false; } // If we cannot place any other values here, return true. return true; } bool solve(Board& board){ // This method uses all the others to actually solve the puzzle // Create a stack that will store all of the moves. Stack moves; // While there are empty spaces on the board, while(board.emptySpaces() > 0){ // Create some local variables. size_t row = 0; size_t col = 0; size_t value = 1; // If there is a spot that is empty, find the most constrained one. if(mostConstrained(board, row, col)){ // If there is a value we can put there, find the first one. if(nextValue(board, row, col, value)){ // Make the move using the next value in the most constrained square. makeMove(board, moves, row, col, value); } // If there is no next value, else{ // while we can keep backtracking, do { // return false if there are no moves in the stack. if(moves.empty()) return false; value ++; // Backtrack and try again with an incremented value. } while(backtrack(board, moves)); } } else { do{ if(moves.empty()) return false; value ++; } while(backtrack(board, moves)); } } // If we get through the entire loop, return true because // the board has been solved. return true; } int main(){ // The main method. //Input the sudoku board that needs to be solved Board board; cin >> board; // If we can solve the board, display it. if(solve(board)){ cout << board; } // If we can't, display 'Unsolvable'. else cout << "There is no solution" << endl << board; }
[ "jscacco@hamilton.edu" ]
jscacco@hamilton.edu
5631313bf76fd9829cdf34769561f3209094afeb
f22f1c9b9f0265295be7cb83433fcba66b620776
/native/unix/src/main/include/jcpp/native/unixos/net/UnixSocketOutputStream.h
55f84b3134d6c0101d9c2ff653fd47575c52768c
[]
no_license
egelor/jcpp-1
63c72c3257b52b37a952344a62fa43882247ba6e
9b5a180b00890d375d2e8a13b74ab5039ac4388c
refs/heads/master
2021-05-09T03:46:22.585245
2015-08-07T16:04:20
2015-08-07T16:04:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,136
h
#ifndef JCPP_NATIVE_UNIX_NET_UNIXSOCKETOUTPUTSTREAM #define JCPP_NATIVE_UNIX_NET_UNIXSOCKETOUTPUTSTREAM #include "jcpp/native/api/io/NativeOutputStream.h" #include "jcpp/native/api/NativeString.h" #include "jcpp/native/unixos/UnixUtils.h" using namespace jcpp::native::api; using namespace jcpp::native::api::io; namespace jcpp { namespace native { namespace unixos { namespace net { class UnixSocket; class JCPP_EXPORT UnixSocketOutputStream: public NativeOutputStream { friend class UnixSocket; private: static NativeString className; int socket; volatile jbool streamClosed; volatile jbool socketClosed; UnixSocketOutputStream(const UnixSocketOutputStream&); UnixSocketOutputStream& operator =(const UnixSocketOutputStream&); void markSocketClosed(); public: UnixSocketOutputStream(int socket); virtual ~UnixSocketOutputStream(); virtual void write(jbyte byte); virtual void write(jbyte * buf, jint offset, jint length); virtual void flush(); virtual void close(); jbool isStreamClosed(); }; } } } } #endif
[ "mimi4930" ]
mimi4930
74627a812704997257cf53f4984d79f2e939b916
f971907302ae5f36b2eb5bb52b0513b0a7c869aa
/src/wsegl/wsegl_plugin.hpp
8a9b50838158ffcd49217918a20c36120e47f3b9
[]
no_license
darkenk/bbb_tests
8c13c8ca5073245a7ec0b1690bf61af9245cdb2c
932acdf11e0a3cbca61cf2c84e90c761ca9c5efe
refs/heads/master
2020-05-21T04:40:13.318836
2016-11-18T16:43:08
2016-11-18T16:43:08
53,541,320
0
0
null
null
null
null
UTF-8
C++
false
false
176
hpp
#ifndef __WSEGL_PLUGIN__ #define __WSEGL_PLUGIN__ typedef int NativeDisplayType; typedef int NativePixmapType; typedef int NativeWindowType; #include <wsegl/wsegl.h> #endif
[ "darkenk@gmail.com" ]
darkenk@gmail.com
78594f785a7438780c41b45f6fcdcb53b9120b8e
455c3daba4337020efaf60fff482384fe24b7fb5
/src/mediafire_sdk/api/session_state.cpp
4992305750db3be99c1d054455e5666687121c50
[ "Apache-2.0" ]
permissive
dazw666/mediafire-cpp-sdk
90f1d844c4cc23d851412047c1d0767d0ad84f94
b796df73147063649ca5cdd3cf582aa2609d3ffe
refs/heads/master
2021-01-18T07:32:48.924466
2014-10-22T23:49:44
2014-10-22T23:49:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,185
cpp
/** * @file session_state.cpp * @author Herbert Jones * * @copyright Copyright 2014 Mediafire */ #include "session_state.hpp" namespace mf { namespace api { namespace session_state { bool operator==(const Uninitialized& /*lhs*/, const Uninitialized& /*rhs*/) { return true; } bool operator==(const Initialized& /*lhs*/, const Initialized& /*rhs*/) { return true; } bool operator==(const CredentialsFailure& lhs, const CredentialsFailure& rhs) { // Only the parts we care about determine if the session token response is // different than another. return std::tie(lhs.pkey, lhs.error_code) == std::tie(rhs.pkey, rhs.error_code); } bool operator==(const Running& lhs, const Running& rhs) { const api::user::get_session_token::Response & l = lhs.session_token_response; const api::user::get_session_token::Response & r = rhs.session_token_response; // Only the parts we care about determine if the session token response is // different than another. return std::tie(l.session_token, l.pkey) == std::tie(r.session_token, r.pkey); } } // namespace session_state } // namespace api } // namespace mf
[ "herbert.jones@mediafire.com" ]
herbert.jones@mediafire.com
b669ea8e1ebf93d3a218e69177679102dcce0b54
fae06d4844ae81799a3416adbde937f660994b74
/src/runtime/acl-tree.cc
0c65a3f6568b05b60ca4a50ef2a94ca30dcf29f0
[]
no_license
joyyoj/openacl
5bb5005ac668658c66423a7e51b4c9cfd94b35e1
bee8fe29c62b2e1289842ef2b490f1ce96340405
refs/heads/master
2020-05-16T16:59:39.263664
2013-06-01T14:55:53
2013-06-01T14:55:53
10,423,146
0
0
null
null
null
null
UTF-8
C++
false
false
1,803
cc
#include "runtime/acl-tree.h" _BEG_ACL void AclTree::build() { } bool AclTree::authenticateUser(const std::vector<Privilege> & privilege) { for (int i = 0; i < privilege.size(); ++i) { } } class OpenAclImpl { public: void roleHasPrivilege(RoleInfo roleInfo, Privilege privilege) { struct Record; Record record; //dt: /data/udwtable/pb/voice ?event_day=20130301,20130302;event_hour=20130201 write // //dt: /data = 1,2,4,7 //dt: /data/udwtable //dt: /data/udwtable/pb //dt: /data/udwtable/pb/voice getUserPrivileges(); //user tree //updateUserTree(); record.path is prefix of entity } }; //sort privilege tree struct EntityTreeNode { EntityTreeNode* children; int children_count; int code;//1, 2, 4, 7 string name; string parent; private: ~EntityTreeNode() { stack<EntityTreeNode*> stack; push_all(this, stack); while (!stack.emtpy()) { EntityTreeNode* node = stack.pop(); push_all(stack, nodes); for (int childIndex = 0; childIndex < children_count; ++childIndex) { nodes.push_back(node->children[childIndex]); } node->children[childIndex] = NULL; node->children_count = 0; delete node; } } void checkPath(list<Privilege> privileges) { if (path is prefix and this->code & code) { checkPath(path, path.next()); } for (child : children) { } } }; removeEntity(); //path 00000|00000000| 000000000 scheme/db/table/ query 1 dt:/data dt:/data/udwtable path entity_id parent_id dt:/data 1 0 dt:/data/udwtable 2 1 int main() { AclTree tree; tree.build(); std::vector<Privilege> privilegeList; Privilege priv; priv.entities.push_back(Entity("path/to/event", "event_day=20130101:20150501")); privilegeList.push_back(); tree.authenticateUser(); } } _END_ACL
[ "sunshangchun@sunshangchun-laptop.(none)" ]
sunshangchun@sunshangchun-laptop.(none)
213fff5509faa3c6db00294ba2a2dd19959bbc2a
3c325be3820097a67c08d7048ca3552db71e446c
/codeforces/765C.cpp
17ef271dd50c899a657d6e05dfa33f0072edf649
[]
no_license
M45UDrana/DS-Algo-Problem-Solving
2dc2ba53f162675ddc6b549f0c84b702f738a485
5548d514f9ffff7aa618b29fcb8440a8b85afb8b
refs/heads/main
2023-07-17T06:14:51.062413
2021-09-01T18:19:14
2021-09-01T18:19:14
375,086,950
0
0
null
null
null
null
UTF-8
C++
false
false
323
cpp
#include <bits/stdc++.h> using namespace std; int main() { int k, a, b; cin >> k >> a >> b; if((a < k and b < k) or (a%k > 0 and (int)b/k == 0) or (b%k > 0 and (int)a/k == 0)) { cout << -1 << endl; return 0; } int ans = a/k; ans += b/k; cout << ans << endl; return 0; }
[ "masudranaata@gmail.com" ]
masudranaata@gmail.com
fccfd9265a47ef984356148f1037661b15b41d80
561943d7f7700aae9795b3a6fba6b0130ca02b77
/source/milenage.cpp
11aa95dd173e0b8be6c133005635b482963c8b04
[]
no_license
ziseputi/Security_Simulator
5985563d3364b98fefcb1765082a923c674b018f
84898c35f3b1b605dd6997cf300ecbe25ec2f4e0
refs/heads/master
2021-05-21T08:09:34.935602
2017-05-11T08:55:07
2017-05-11T08:55:07
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,311
cpp
#include "milenage.h" u8 OP[16] = { 0xcd, 0xc2, 0x02, 0xd5, 0x12, 0x3e, 0x20, 0xf6, 0x2b, 0x6d, 0x67, 0x6a, 0xc7, 0x2c, 0xb3, 0x18 }; void f1(u8 k[16], u8 rand[16], u8 sqn[6], u8 amf[2], u8 mac_a[8]) { u8 op_c[16]; u8 temp[16]; u8 in1[16]; u8 out1[16]; u8 rijndaelInput[16]; u8 i; RijndaelKeySchedule(k); ComputeOPc(op_c); for (i = 0; i < 16; i++) rijndaelInput[i] = rand[i] ^ op_c[i]; RijndaelEncrypt(rijndaelInput, temp); for (i = 0; i < 6; i++) { in1[i] = sqn[i]; in1[i + 8] = sqn[i]; } for (i = 0; i < 2; i++) { in1[i + 6] = amf[i]; in1[i + 14] = amf[i]; } for (i = 0; i < 16; i++) rijndaelInput[(i + 8) % 16] = in1[i] ^ op_c[i]; for (i = 0; i < 16; i++) rijndaelInput[i] ^= temp[i]; RijndaelEncrypt(rijndaelInput, out1); for (i = 0; i < 16; i++) out1[i] ^= op_c[i]; for (i = 0; i < 8; i++) mac_a[i] = out1[i]; return; } void f2345(u8 k[16], u8 rand[16], u8 res[8], u8 ck[16], u8 ik[16], u8 ak[6]) { u8 op_c[16]; u8 temp[16]; u8 out[16]; u8 rijndaelInput[16]; u8 i; RijndaelKeySchedule(k); ComputeOPc(op_c); for (i = 0; i < 16; i++) rijndaelInput[i] = rand[i] ^ op_c[i]; RijndaelEncrypt(rijndaelInput, temp); for (i = 0; i < 16; i++) rijndaelInput[i] = temp[i] ^ op_c[i]; rijndaelInput[15] ^= 1; RijndaelEncrypt(rijndaelInput, out); for (i = 0; i < 16; i++) out[i] ^= op_c[i]; for (i = 0; i < 8; i++) res[i] = out[i + 8]; for (i = 0; i < 6; i++) ak[i] = out[i]; for (i = 0; i < 16; i++) rijndaelInput[(i + 12) % 16] = temp[i] ^ op_c[i]; rijndaelInput[15] ^= 2; RijndaelEncrypt(rijndaelInput, out); for (i = 0; i < 16; i++) out[i] ^= op_c[i]; for (i = 0; i < 16; i++) ck[i] = out[i]; for (i = 0; i < 16; i++) rijndaelInput[(i + 8) % 16] = temp[i] ^ op_c[i]; rijndaelInput[15] ^= 4; RijndaelEncrypt(rijndaelInput, out); for (i = 0; i < 16; i++) out[i] ^= op_c[i]; for (i = 0; i < 16; i++) ik[i] = out[i]; return; } void f1star(u8 k[16], u8 rand[16], u8 sqn[6], u8 amf[2], u8 mac_s[8]) { u8 op_c[16]; u8 temp[16]; u8 in1[16]; u8 out1[16]; u8 rijndaelInput[16]; u8 i; RijndaelKeySchedule(k); ComputeOPc(op_c); for (i = 0; i < 16; i++) rijndaelInput[i] = rand[i] ^ op_c[i]; RijndaelEncrypt(rijndaelInput, temp); for (i = 0; i < 6; i++) { in1[i] = sqn[i]; in1[i + 8] = sqn[i]; } for (i = 0; i < 2; i++) { in1[i + 6] = amf[i]; in1[i + 14] = amf[i]; } for (i = 0; i < 16; i++) rijndaelInput[(i + 8) % 16] = in1[i] ^ op_c[i]; for (i = 0; i < 16; i++) rijndaelInput[i] ^= temp[i]; RijndaelEncrypt(rijndaelInput, out1); for (i = 0; i < 16; i++) out1[i] ^= op_c[i]; for (i = 0; i < 8; i++) mac_s[i] = out1[i + 8]; return; } void f5star(u8 k[16], u8 rand[16], u8 ak[6]) { u8 op_c[16]; u8 temp[16]; u8 out[16]; u8 rijndaelInput[16]; u8 i; RijndaelKeySchedule(k); ComputeOPc(op_c); for (i = 0; i < 16; i++) rijndaelInput[i] = rand[i] ^ op_c[i]; RijndaelEncrypt(rijndaelInput, temp); for (i = 0; i < 16; i++) rijndaelInput[(i + 4) % 16] = temp[i] ^ op_c[i]; rijndaelInput[15] ^= 8; RijndaelEncrypt(rijndaelInput, out); for (i = 0; i < 16; i++) out[i] ^= op_c[i]; for (i = 0; i < 6; i++) ak[i] = out[i]; return; } void ComputeOPc(u8 op_c[16]) { u8 i; RijndaelEncrypt(OP, op_c); for (i = 0; i < 16; i++) op_c[i] ^= OP[i]; return; }
[ "“yerinhong0927@gmail.com”" ]
“yerinhong0927@gmail.com”
b187cd893b88933bd0ae84726b611359c96b24eb
d6e2653d724654f6c1d52d762c27150e09a9d913
/VentanaFinal/mainwindow.cpp
f6979a5e09ae2878e374f19726688f97528dae31
[]
no_license
FernandoMonge13/ADS2-TecFileSystem
2e0d26b0e8540dcd1001ce58aa7f118e24f52622
919222a768ffcb9d59c89487e3a9cf512f03db57
refs/heads/main
2023-06-05T04:56:33.163849
2021-06-25T17:52:28
2021-06-25T17:52:28
379,106,476
0
0
null
2021-06-25T00:59:49
2021-06-22T01:22:48
C++
UTF-8
C++
false
false
1,949
cpp
#include "mainwindow.h" #include "./ui_mainwindow.h" #include <QTextStream> #include <QFileDialog> #include <QMessageBox> #include <QTextStream> #include <QFile> #include <QJsonDocument> #include <QJsonObject> #include <QDebug> #include "../Huffman/Huffman.h" #include "../Sockets/Parser.h" std::string MainWindow::json = ""; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); setWindowTitle("APLICATION"); } MainWindow::~MainWindow() { delete ui; } void MainWindow::on_pushButton_clicked() { //boton abrir QFile file; QTextStream io; QString filePath = QFileDialog::getOpenFileName(this, "Open Directory"); QDir d = QFileInfo(filePath).dir(); //hay que seleccionar uno de los archivos dentro de la carpeta QString absolute=d.path(); qDebug()<< absolute; //absolute es el pto path a la carpeta del archivo seleccionado file.close(); //std::string huf = Huffman::getInstance()->code(absolute.toStdString()); doc.setObject(Parser::Path(absolute.toStdString())); std::string json = Parser::ReturnChar(doc); MainWindow::setJson(json); client->Start(); usleep(10000); } void MainWindow::on_pushButton_2_clicked() { QString text = ui->textBox->toPlainText(); //qstring para obtener lo que hay en la mrd //std::string huf = Huffman::getInstance()->code(text.toStdString()); //qDebug()<<test; //boton buscar doc.setObject(Parser::Huffman(text.toStdString())); std::string json = Parser::ReturnChar(doc); MainWindow::setJson(json); client->Start(); usleep(10000); ui->textBox->clear(); qDebug()<<Client::getReceived(); ui->textBox->setPlainText(QString::fromStdString(Parser::ReturnStringValueFromJson(Client::getReceived(), "text"))); } std::string MainWindow::getJson() { return json; } void MainWindow::setJson(std::string toSet) { json = toSet; }
[ "markorovi24@gmail.com" ]
markorovi24@gmail.com
5eb97f93113423e62e4a7eb8917c2fc75f8c5ccc
36e2dfe98637d5ae86a4bbe9c62a534c7e5a28a0
/dtime.h
e8853951483ef4ffc611483b8bdd52650178bf5d
[]
no_license
samuel-indurkar/sjcc_C-
ed31cf643d4310ccc5d76b8218dc8b66f6c6f4a9
b5beee5a57365f58028063168150f87fec3e2918
refs/heads/master
2021-01-16T21:06:22.171715
2017-08-13T23:27:01
2017-08-13T23:27:01
100,210,301
0
0
null
null
null
null
UTF-8
C++
false
false
2,531
h
/* * dtime.h * * Created on: Jul 23, 2017 * Author: Samuel */ #ifndef DTIME_H_ #define DTIME_H_ #pragma once //DISPLAY 12.2 Implementation File for DigitalTime //Implementation file dtime.cpp (Your system may require some //suffix other than .cpp): This is the IMPLEMENTATION of the ADT DigitalTime. //The interface for the class DigitalTime is in the header file dtime.h. //DISPLAY 12.1 Interface File for DigitalTime //Header file dtime.h: This is the INTERFACE for the class DigitalTime. //Values of this type are times of day. The values are input and output in //24-hour notation, as in 9:30 for 9:30 AM and 14:45 for 2:45 PM. #include <iostream> using namespace std; class DigitalTime { public: friend bool operator ==(const DigitalTime& time1, const DigitalTime& time2); //Returns true if time1 and time2 represent the same time; //otherwise, returns false. DigitalTime(int the_hour, int the_minute); //Precondition: 0 <= the_hour <= 23 and 0 <= the_minute <= 59. //Initializes the time value to the_hour and the_minute. DigitalTime( ); //Initializes the time value to 0:00 (which is midnight). void advance(int minutes_added); //Precondition: The object has a time value. //Postcondition: The time has been changed to minutes_added minutes later. void advance(int hours_added, int minutes_added); //Precondition: The object has a time value. //Postcondition: The time value has been advanced //hours_added hours plus minutes_added minutes. friend istream& operator >>(istream& ins, DigitalTime& the_object); //Overloads the >> operator for input values of type DigitalTime. //Precondition: If ins is a file input stream, then ins has already been //connected to a file. friend ostream& operator <<(ostream& outs, const DigitalTime& the_object); //Overloads the << operator for output values of type DigitalTime. //Precondition: If outs is a file output stream, then outs has already been //connected to a file. void interval_since(const DigitalTime& previous_time, int& hours_in_interval, int& minutes_in_interval) const; //Precondition: The object has a time value. //Precondition: The previous_time object has a time value //Postcondition: The hours_in_interval indicates the number of hours that have passed //Postcondition: The minutes_in_interval indicates the number of minutes that have passed private: int hour; int minute; }; #endif /* DTIME_H_ */
[ "Samuel@indurkars-mbp.attlocal.net" ]
Samuel@indurkars-mbp.attlocal.net
5e70fc3309e2d235630234f60131d82e65b172a9
7a6486b47ad506210a24a144984e8117af941e31
/include/IRCanonicalizer.h
7f5768958d756fe0a661aac43f3f974ba089883a
[ "Apache-2.0" ]
permissive
michalpaszkowski/LLVM-Canon
64f43c3fc4f12c22c274dae5e63cc4759c8847ff
d328484222bee4d1277dba5470e35e762d6f2760
refs/heads/main
2023-08-21T23:09:27.016479
2023-07-05T23:35:06
2023-08-07T22:10:08
391,674,333
10
3
Apache-2.0
2023-08-07T22:10:09
2021-08-01T16:06:29
C++
UTF-8
C++
false
false
2,959
h
#pragma once #include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/IR/Function.h" #include "llvm/IR/Module.h" #include "llvm/Pass.h" /// IRCanonicalizer aims to transform LLVM IR into canonical form. class IRCanonicalizer : public llvm::FunctionPass { public: static char ID; /// Constructor for the IRCanonicalizer. /// /// \param PreserveOrder Preserves original order of instructions. /// \param RenameAll Renames all instructions (including user-named). /// \param FoldPreoutputs Folds all regular instructions (including pre-outputs). /// \param ReorderOperands Sorts and reorders operands in commutative instructions. IRCanonicalizer(bool PreserveOrder, bool RenameAll, bool FoldPreoutputs, bool ReorderOperands) : FunctionPass(ID), PreserveOrder(PreserveOrder), RenameAll(RenameAll), FoldPreoutputs(FoldPreoutputs), ReorderOperands(ReorderOperands) {} bool runOnFunction(llvm::Function &F) override; private: // Random constant for hashing, so the state isn't zero. const uint64_t MagicHashConstant = 0x6acaa36bef8325c5ULL; /// \name Canonicalizer flags. /// @{ /// Preserves original order of instructions. bool PreserveOrder; /// Renames all instructions (including user-named). bool RenameAll; /// Folds all regular instructions (including pre-outputs). bool FoldPreoutputs; /// Sorts and reorders operands in commutative instructions. bool ReorderOperands; /// @} /// \name Naming. /// @{ void nameFunctionArguments(llvm::Function &F); void nameBasicBlocks(llvm::Function &F); void nameInstructions(llvm::SmallVector<llvm::Instruction *, 16> &Outputs); void nameInstruction(llvm::Instruction *I, llvm::SmallPtrSet<const llvm::Instruction *, 32> &Visited); void nameAsInitialInstruction(llvm::Instruction *I); void nameAsRegularInstruction(llvm::Instruction *I, llvm::SmallPtrSet<const llvm::Instruction *, 32> &Visited); void foldInstructionName(llvm::Instruction *I); /// @} /// \name Reordering. /// @{ void reorderInstructions(llvm::SmallVector<llvm::Instruction *, 16> &Outputs); void reorderInstruction(llvm::Instruction *Used, llvm::Instruction *User, llvm::SmallPtrSet<const llvm::Instruction *, 32> &Visited); void reorderInstructionOperandsByNames(llvm::Instruction *I); void reorderPHIIncomingValues(llvm::PHINode *PN); /// @} /// \name Utility methods. /// @{ llvm::SmallVector<llvm::Instruction *, 16> collectOutputInstructions(llvm::Function &F); bool isOutput(const llvm::Instruction *I); bool isInitialInstruction(const llvm::Instruction *I); bool hasOnlyImmediateOperands(const llvm::Instruction *I); llvm::SetVector<int> getOutputFootprint(llvm::Instruction *I, llvm::SmallPtrSet<const llvm::Instruction *, 32> &Visited); /// @} };
[ "michal.paszkowski@outlook.com" ]
michal.paszkowski@outlook.com
0730474c4ad0b4f44ccd9b334192797ff9596722
882fdb21d311e96abd0ac33f8ad689e99423cb16
/src/masternode-payments.cpp
52292a5b8ceee44630082f5f0a5ee7e0fbee39d0
[ "MIT" ]
permissive
finteklabs/Stipendium
677921ecd675ae5f7ec47b17b1c967bf907d1696
d5a8b9ed2a0e8457c0414f6fef5f9cb1d40a4dda
refs/heads/master
2021-04-08T08:58:20.082590
2020-03-20T13:30:52
2020-03-20T13:30:52
248,760,564
1
0
null
null
null
null
UTF-8
C++
false
false
17,594
cpp
// Copyright (c) 2014-2019 The Dash Core developers // Copyright (c) 2020 The Stipendium Core developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "activemasternode.h" #include "consensus/validation.h" #include "governance-classes.h" #include "init.h" #include "masternode-payments.h" #include "masternode-sync.h" #include "messagesigner.h" #include "netfulfilledman.h" #include "netmessagemaker.h" #include "spork.h" #include "util.h" #include "validation.h" #include "evo/deterministicmns.h" #include <string> CMasternodePayments mnpayments; bool IsOldBudgetBlockValueValid(const CBlock& block, int nBlockHeight, CAmount blockReward, std::string& strErrorRet) { const Consensus::Params& consensusParams = Params().GetConsensus(); bool isBlockRewardValueMet = (block.vtx[0]->GetValueOut() <= blockReward); if (nBlockHeight < consensusParams.nBudgetPaymentsStartBlock) { strErrorRet = strprintf("Incorrect block %d, old budgets are not activated yet", nBlockHeight); return false; } if (nBlockHeight >= consensusParams.nSuperblockStartBlock) { strErrorRet = strprintf("Incorrect block %d, old budgets are no longer active", nBlockHeight); return false; } // we are still using budgets, but we have no data about them anymore, // all we know is predefined budget cycle and window int nOffset = nBlockHeight % consensusParams.nBudgetPaymentsCycleBlocks; if(nBlockHeight >= consensusParams.nBudgetPaymentsStartBlock && nOffset < consensusParams.nBudgetPaymentsWindowBlocks) { // NOTE: old budget system is disabled since 12.1 if(masternodeSync.IsSynced()) { // no old budget blocks should be accepted here on mainnet, // testnet/devnet/regtest should produce regular blocks only LogPrint("gobject", "%s -- WARNING: Client synced but old budget system is disabled, checking block value against block reward\n", __func__); if(!isBlockRewardValueMet) { strErrorRet = strprintf("coinbase pays too much at height %d (actual=%d vs limit=%d), exceeded block reward, old budgets are disabled", nBlockHeight, block.vtx[0]->GetValueOut(), blockReward); } return isBlockRewardValueMet; } // when not synced, rely on online nodes (all networks) LogPrint("gobject", "%s -- WARNING: Skipping old budget block value checks, accepting block\n", __func__); return true; } // LogPrint("gobject", "%s -- Block is not in budget cycle window, checking block value against block reward\n", __func__); if(!isBlockRewardValueMet) { strErrorRet = strprintf("coinbase pays too much at height %d (actual=%d vs limit=%d), exceeded block reward, block is not in old budget cycle window", nBlockHeight, block.vtx[0]->GetValueOut(), blockReward); } return isBlockRewardValueMet; } /** * IsBlockValueValid * * Determine if coinbase outgoing created money is the correct value * * Why is this needed? * - In Stipendium some blocks are superblocks, which output much higher amounts of coins * - Otherblocks are 10% lower in outgoing value, so in total, no extra coins are created * - When non-superblocks are detected, the normal schedule should be maintained */ bool IsBlockValueValid(const CBlock& block, int nBlockHeight, CAmount blockReward, std::string& strErrorRet) { const Consensus::Params& consensusParams = Params().GetConsensus(); bool isBlockRewardValueMet = (block.vtx[0]->GetValueOut() <= blockReward); strErrorRet = ""; if (nBlockHeight < consensusParams.nBudgetPaymentsStartBlock) { // old budget system is not activated yet, just make sure we do not exceed the regular block reward if(!isBlockRewardValueMet) { strErrorRet = strprintf("coinbase pays too much at height %d (actual=%d vs limit=%d), exceeded block reward, old budgets are not activated yet", nBlockHeight, block.vtx[0]->GetValueOut(), blockReward); } return isBlockRewardValueMet; } else if (nBlockHeight < consensusParams.nSuperblockStartBlock) { // superblocks are not enabled yet, check if we can pass old budget rules return IsOldBudgetBlockValueValid(block, nBlockHeight, blockReward, strErrorRet); } if(fDebug) LogPrintf("block.vtx[0]->GetValueOut() %lld <= blockReward %lld\n", block.vtx[0]->GetValueOut(), blockReward); CAmount nSuperblockMaxValue = blockReward + CSuperblock::GetPaymentsLimit(nBlockHeight); bool isSuperblockMaxValueMet = (block.vtx[0]->GetValueOut() <= nSuperblockMaxValue); LogPrint("gobject", "block.vtx[0]->GetValueOut() %lld <= nSuperblockMaxValue %lld\n", block.vtx[0]->GetValueOut(), nSuperblockMaxValue); if (!CSuperblock::IsValidBlockHeight(nBlockHeight)) { // can't possibly be a superblock, so lets just check for block reward limits if (!isBlockRewardValueMet) { strErrorRet = strprintf("coinbase pays too much at height %d (actual=%d vs limit=%d), exceeded block reward, only regular blocks are allowed at this height", nBlockHeight, block.vtx[0]->GetValueOut(), blockReward); } return isBlockRewardValueMet; } // bail out in case superblock limits were exceeded if (!isSuperblockMaxValueMet) { strErrorRet = strprintf("coinbase pays too much at height %d (actual=%d vs limit=%d), exceeded superblock max value", nBlockHeight, block.vtx[0]->GetValueOut(), nSuperblockMaxValue); return false; } if(!masternodeSync.IsSynced() || fLiteMode) { if(fDebug) LogPrintf("%s -- WARNING: Not enough data, checked superblock max bounds only\n", __func__); // not enough data for full checks but at least we know that the superblock limits were honored. // We rely on the network to have followed the correct chain in this case return true; } // we are synced and possibly on a superblock now if (!sporkManager.IsSporkActive(SPORK_9_SUPERBLOCKS_ENABLED)) { // should NOT allow superblocks at all, when superblocks are disabled // revert to block reward limits in this case LogPrint("gobject", "%s -- Superblocks are disabled, no superblocks allowed\n", __func__); if(!isBlockRewardValueMet) { strErrorRet = strprintf("coinbase pays too much at height %d (actual=%d vs limit=%d), exceeded block reward, superblocks are disabled", nBlockHeight, block.vtx[0]->GetValueOut(), blockReward); } return isBlockRewardValueMet; } if (!CSuperblockManager::IsSuperblockTriggered(nBlockHeight)) { // we are on a valid superblock height but a superblock was not triggered // revert to block reward limits in this case if(!isBlockRewardValueMet) { strErrorRet = strprintf("coinbase pays too much at height %d (actual=%d vs limit=%d), exceeded block reward, no triggered superblock detected", nBlockHeight, block.vtx[0]->GetValueOut(), blockReward); } return isBlockRewardValueMet; } // this actually also checks for correct payees and not only amount if (!CSuperblockManager::IsValid(*block.vtx[0], nBlockHeight, blockReward)) { // triggered but invalid? that's weird LogPrintf("%s -- ERROR: Invalid superblock detected at height %d: %s", __func__, nBlockHeight, block.vtx[0]->ToString()); // should NOT allow invalid superblocks, when superblocks are enabled strErrorRet = strprintf("invalid superblock detected at height %d", nBlockHeight); return false; } // we got a valid superblock return true; } bool IsBlockPayeeValid(const CTransaction& txNew, int nBlockHeight, CAmount blockReward) { if(fLiteMode) { //there is no budget data to use to check anything, let's just accept the longest chain if(fDebug) LogPrintf("%s -- WARNING: Not enough data, skipping block payee checks\n", __func__); return true; } // we are still using budgets, but we have no data about them anymore, // we can only check masternode payments const Consensus::Params& consensusParams = Params().GetConsensus(); if(nBlockHeight < consensusParams.nSuperblockStartBlock) { // NOTE: old budget system is disabled since 12.1 and we should never enter this branch // anymore when sync is finished (on mainnet). We have no old budget data but these blocks // have tons of confirmations and can be safely accepted without payee verification LogPrint("gobject", "%s -- WARNING: Client synced but old budget system is disabled, accepting any payee\n", __func__); return true; } // superblocks started // SEE IF THIS IS A VALID SUPERBLOCK if(sporkManager.IsSporkActive(SPORK_9_SUPERBLOCKS_ENABLED)) { if(CSuperblockManager::IsSuperblockTriggered(nBlockHeight)) { if(CSuperblockManager::IsValid(txNew, nBlockHeight, blockReward)) { LogPrint("gobject", "%s -- Valid superblock at height %d: %s", __func__, nBlockHeight, txNew.ToString()); // continue validation, should also pay MN } else { LogPrintf("%s -- ERROR: Invalid superblock detected at height %d: %s", __func__, nBlockHeight, txNew.ToString()); // should NOT allow such superblocks, when superblocks are enabled return false; } } else { LogPrint("gobject", "%s -- No triggered superblock detected at height %d\n", __func__, nBlockHeight); } } else { // should NOT allow superblocks at all, when superblocks are disabled LogPrint("gobject", "%s -- Superblocks are disabled, no superblocks allowed\n", __func__); } // Check for correct masternode payment if(mnpayments.IsTransactionValid(txNew, nBlockHeight, blockReward)) { LogPrint("mnpayments", "%s -- Valid masternode payment at height %d: %s", __func__, nBlockHeight, txNew.ToString()); return true; } LogPrintf("%s -- ERROR: Invalid masternode payment detected at height %d: %s", __func__, nBlockHeight, txNew.ToString()); return false; } void FillBlockPayments(CMutableTransaction& txNew, int nBlockHeight, CAmount blockReward, std::vector<CTxOut>& voutMasternodePaymentsRet, std::vector<CTxOut>& voutSuperblockPaymentsRet) { // only create superblocks if spork is enabled AND if superblock is actually triggered // (height should be validated inside) if(sporkManager.IsSporkActive(SPORK_9_SUPERBLOCKS_ENABLED) && CSuperblockManager::IsSuperblockTriggered(nBlockHeight)) { LogPrint("gobject", "%s -- triggered superblock creation at height %d\n", __func__, nBlockHeight); CSuperblockManager::GetSuperblockPayments(nBlockHeight, voutSuperblockPaymentsRet); } if (!mnpayments.GetMasternodeTxOuts(nBlockHeight, blockReward, voutMasternodePaymentsRet)) { LogPrint("mnpayments", "%s -- no masternode to pay (MN list probably empty)\n", __func__); } txNew.vout.insert(txNew.vout.end(), voutMasternodePaymentsRet.begin(), voutMasternodePaymentsRet.end()); txNew.vout.insert(txNew.vout.end(), voutSuperblockPaymentsRet.begin(), voutSuperblockPaymentsRet.end()); std::string voutMasternodeStr; for (const auto& txout : voutMasternodePaymentsRet) { // subtract MN payment from miner reward txNew.vout[0].nValue -= txout.nValue; if (!voutMasternodeStr.empty()) voutMasternodeStr += ","; voutMasternodeStr += txout.ToString(); } LogPrint("mnpayments", "%s -- nBlockHeight %d blockReward %lld voutMasternodePaymentsRet \"%s\" txNew %s", __func__, nBlockHeight, blockReward, voutMasternodeStr, txNew.ToString()); } std::string GetRequiredPaymentsString(int nBlockHeight, const CDeterministicMNCPtr &payee) { std::string strPayee = "Unknown"; if (payee) { CTxDestination dest; if (!ExtractDestination(payee->pdmnState->scriptPayout, dest)) assert(false); strPayee = CBitcoinAddress(dest).ToString(); } if (CSuperblockManager::IsSuperblockTriggered(nBlockHeight)) { strPayee += ", " + CSuperblockManager::GetRequiredPaymentsString(nBlockHeight); } return strPayee; } std::map<int, std::string> GetRequiredPaymentsStrings(int nStartHeight, int nEndHeight) { std::map<int, std::string> mapPayments; if (nStartHeight < 1) { nStartHeight = 1; } LOCK(cs_main); int nChainTipHeight = chainActive.Height(); bool doProjection = false; for(int h = nStartHeight; h < nEndHeight; h++) { if (h <= nChainTipHeight) { auto payee = deterministicMNManager->GetListForBlock(chainActive[h - 1]->GetBlockHash()).GetMNPayee(); mapPayments.emplace(h, GetRequiredPaymentsString(h, payee)); } else { doProjection = true; break; } } if (doProjection) { auto projection = deterministicMNManager->GetListAtChainTip().GetProjectedMNPayees(nEndHeight - nChainTipHeight); for (size_t i = 0; i < projection.size(); i++) { auto payee = projection[i]; int h = nChainTipHeight + 1 + i; mapPayments.emplace(h, GetRequiredPaymentsString(h, payee)); } } return mapPayments; } /** * GetMasternodeTxOuts * * Get masternode payment tx outputs */ bool CMasternodePayments::GetMasternodeTxOuts(int nBlockHeight, CAmount blockReward, std::vector<CTxOut>& voutMasternodePaymentsRet) const { // make sure it's not filled yet voutMasternodePaymentsRet.clear(); if(!GetBlockTxOuts(nBlockHeight, blockReward, voutMasternodePaymentsRet)) { LogPrintf("CMasternodePayments::%s -- no payee (deterministic masternode list empty)\n", __func__); return false; } for (const auto& txout : voutMasternodePaymentsRet) { CTxDestination address1; ExtractDestination(txout.scriptPubKey, address1); CBitcoinAddress address2(address1); LogPrintf("CMasternodePayments::%s -- Masternode payment %lld to %s\n", __func__, txout.nValue, address2.ToString()); } return true; } bool CMasternodePayments::GetBlockTxOuts(int nBlockHeight, CAmount blockReward, std::vector<CTxOut>& voutMasternodePaymentsRet) const { voutMasternodePaymentsRet.clear(); CAmount masternodeReward = GetMasternodePayment(nBlockHeight, blockReward); uint256 blockHash; { LOCK(cs_main); blockHash = chainActive[nBlockHeight - 1]->GetBlockHash(); } uint256 proTxHash; auto dmnPayee = deterministicMNManager->GetListForBlock(blockHash).GetMNPayee(); if (!dmnPayee) { return false; } CAmount operatorReward = 0; if (dmnPayee->nOperatorReward != 0 && dmnPayee->pdmnState->scriptOperatorPayout != CScript()) { // This calculation might eventually turn out to result in 0 even if an operator reward percentage is given. // This will however only happen in a few years when the block rewards drops very low. operatorReward = (masternodeReward * dmnPayee->nOperatorReward) / 10000; masternodeReward -= operatorReward; } if (masternodeReward > 0) { voutMasternodePaymentsRet.emplace_back(masternodeReward, dmnPayee->pdmnState->scriptPayout); } if (operatorReward > 0) { voutMasternodePaymentsRet.emplace_back(operatorReward, dmnPayee->pdmnState->scriptOperatorPayout); } return true; } // Is this masternode scheduled to get paid soon? // -- Only look ahead up to 8 blocks to allow for propagation of the latest 2 blocks of votes bool CMasternodePayments::IsScheduled(const CDeterministicMNCPtr& dmnIn, int nNotBlockHeight) const { auto projectedPayees = deterministicMNManager->GetListAtChainTip().GetProjectedMNPayees(8); for (const auto &dmn : projectedPayees) { if (dmn->proTxHash == dmnIn->proTxHash) { return true; } } return false; } bool CMasternodePayments::IsTransactionValid(const CTransaction& txNew, int nBlockHeight, CAmount blockReward) const { if (!deterministicMNManager->IsDIP3Enforced(nBlockHeight)) { // can't verify historical blocks here return true; } std::vector<CTxOut> voutMasternodePayments; if (!GetBlockTxOuts(nBlockHeight, blockReward, voutMasternodePayments)) { LogPrintf("CMasternodePayments::%s -- ERROR failed to get payees for block at height %s\n", __func__, nBlockHeight); return true; } for (const auto& txout : voutMasternodePayments) { bool found = false; for (const auto& txout2 : txNew.vout) { if (txout == txout2) { found = true; break; } } if (!found) { CTxDestination dest; if (!ExtractDestination(txout.scriptPubKey, dest)) assert(false); LogPrintf("CMasternodePayments::%s -- ERROR failed to find expected payee %s in block at height %s\n", __func__, CBitcoinAddress(dest).ToString(), nBlockHeight); return false; } } return true; }
[ "richard@finteklabs.co" ]
richard@finteklabs.co
b52498af6819d5ad514ce5b4e3c969f4bb880b26
aee4b9b63a058d5973cff434a09d5e9fdcf1b73c
/src/net.cpp
eb9f2d14369f3b84e5f9a62e9de2f59ebef5de91
[ "MIT" ]
permissive
thedigitalcash/DAUn
a844cf82599b8307a14ee329ac69d4965291fff3
15d9eaf28991cad5f52f1a4c4bf5c69d74b01e3f
refs/heads/master
2022-12-05T05:10:42.764230
2020-08-15T09:55:28
2020-08-15T09:55:28
287,701,563
0
0
null
null
null
null
UTF-8
C++
false
false
74,410
cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin developers // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2019 The PIVX developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #if defined(HAVE_CONFIG_H) #include "config/digitalaustraliandollar-config.h" #endif #include "net.h" #include "addrman.h" #include "chainparams.h" #include "clientversion.h" #include "miner.h" #include "obfuscation.h" #include "primitives/transaction.h" #include "scheduler.h" #include "guiinterface.h" #ifdef ENABLE_WALLET #include "wallet/wallet.h" #endif // ENABLE_WALLET #ifdef WIN32 #include <string.h> #else #include <fcntl.h> #endif #ifdef USE_UPNP #include <miniupnpc/miniupnpc.h> #include <miniupnpc/miniwget.h> #include <miniupnpc/upnpcommands.h> #include <miniupnpc/upnperrors.h> #endif #include <boost/filesystem.hpp> #include <boost/thread.hpp> // Dump addresses to peers.dat every 15 minutes (900s) #define DUMP_ADDRESSES_INTERVAL 900 #if !defined(HAVE_MSG_NOSIGNAL) && !defined(MSG_NOSIGNAL) #define MSG_NOSIGNAL 0 #endif // Fix for ancient MinGW versions, that don't have defined these in ws2tcpip.h. // Todo: Can be removed when our pull-tester is upgraded to a modern MinGW version. #ifdef WIN32 #ifndef PROTECTION_LEVEL_UNRESTRICTED #define PROTECTION_LEVEL_UNRESTRICTED 10 #endif #ifndef IPV6_PROTECTION_LEVEL #define IPV6_PROTECTION_LEVEL 23 #endif #endif using namespace boost; using namespace std; namespace { const int MAX_OUTBOUND_CONNECTIONS = 16; struct ListenSocket { SOCKET socket; bool whitelisted; ListenSocket(SOCKET socket, bool whitelisted) : socket(socket), whitelisted(whitelisted) {} }; } // // Global state variables // bool fDiscover = true; bool fListen = true; uint64_t nLocalServices = NODE_NETWORK; CCriticalSection cs_mapLocalHost; map<CNetAddr, LocalServiceInfo> mapLocalHost; static bool vfLimited[NET_MAX] = {}; static CNode* pnodeLocalHost = NULL; uint64_t nLocalHostNonce = 0; static std::vector<ListenSocket> vhListenSocket; CAddrMan addrman; int nMaxConnections = 125; bool fAddressesInitialized = false; std::string strSubVersion; vector<CNode*> vNodes; CCriticalSection cs_vNodes; map<CInv, CDataStream> mapRelay; deque<pair<int64_t, CInv> > vRelayExpiration; CCriticalSection cs_mapRelay; limitedmap<CInv, int64_t> mapAlreadyAskedFor(MAX_INV_SZ); static deque<string> vOneShots; CCriticalSection cs_vOneShots; set<CNetAddr> setservAddNodeAddresses; CCriticalSection cs_setservAddNodeAddresses; vector<std::string> vAddedNodes; CCriticalSection cs_vAddedNodes; NodeId nLastNodeId = 0; CCriticalSection cs_nLastNodeId; static CSemaphore* semOutbound = NULL; boost::condition_variable messageHandlerCondition; // Signals for message handling static CNodeSignals g_signals; CNodeSignals& GetNodeSignals() { return g_signals; } void AddOneShot(string strDest) { LOCK(cs_vOneShots); vOneShots.push_back(strDest); } unsigned short GetListenPort() { return (unsigned short)(GetArg("-port", Params().GetDefaultPort())); } // find 'best' local address for a particular peer bool GetLocal(CService& addr, const CNetAddr* paddrPeer) { if (!fListen) return false; int nBestScore = -1; int nBestReachability = -1; { LOCK(cs_mapLocalHost); for (map<CNetAddr, LocalServiceInfo>::iterator it = mapLocalHost.begin(); it != mapLocalHost.end(); it++) { int nScore = (*it).second.nScore; int nReachability = (*it).first.GetReachabilityFrom(paddrPeer); if (nReachability > nBestReachability || (nReachability == nBestReachability && nScore > nBestScore)) { addr = CService((*it).first, (*it).second.nPort); nBestReachability = nReachability; nBestScore = nScore; } } } return nBestScore >= 0; } // get best local address for a particular peer as a CAddress // Otherwise, return the unroutable 0.0.0.0 but filled in with // the normal parameters, since the IP may be changed to a useful // one by discovery. CAddress GetLocalAddress(const CNetAddr* paddrPeer) { CAddress ret(CService("0.0.0.0", GetListenPort()), 0); CService addr; if (GetLocal(addr, paddrPeer)) { ret = CAddress(addr); } ret.nServices = nLocalServices; ret.nTime = GetAdjustedTime(); return ret; } bool RecvLine(SOCKET hSocket, string& strLine) { strLine = ""; while (true) { char c; int nBytes = recv(hSocket, &c, 1, 0); if (nBytes > 0) { if (c == '\n') continue; if (c == '\r') return true; strLine += c; if (strLine.size() >= 9000) return true; } else if (nBytes <= 0) { boost::this_thread::interruption_point(); if (nBytes < 0) { int nErr = WSAGetLastError(); if (nErr == WSAEMSGSIZE) continue; if (nErr == WSAEWOULDBLOCK || nErr == WSAEINTR || nErr == WSAEINPROGRESS) { MilliSleep(10); continue; } } if (!strLine.empty()) return true; if (nBytes == 0) { // socket closed LogPrint("net", "socket closed\n"); return false; } else { // socket error int nErr = WSAGetLastError(); LogPrint("net", "recv failed: %s\n", NetworkErrorString(nErr)); return false; } } } } int GetnScore(const CService& addr) { LOCK(cs_mapLocalHost); if (mapLocalHost.count(addr) == LOCAL_NONE) return 0; return mapLocalHost[addr].nScore; } // Is our peer's addrLocal potentially useful as an external IP source? bool IsPeerAddrLocalGood(CNode* pnode) { return fDiscover && pnode->addr.IsRoutable() && pnode->addrLocal.IsRoutable() && !IsLimited(pnode->addrLocal.GetNetwork()); } // pushes our own address to a peer void AdvertizeLocal(CNode* pnode) { if (fListen && pnode->fSuccessfullyConnected) { CAddress addrLocal = GetLocalAddress(&pnode->addr); // If discovery is enabled, sometimes give our peer the address it // tells us that it sees us as in case it has a better idea of our // address than we do. if (IsPeerAddrLocalGood(pnode) && (!addrLocal.IsRoutable() || GetRand((GetnScore(addrLocal) > LOCAL_MANUAL) ? 8 : 2) == 0)) { addrLocal.SetIP(pnode->addrLocal); } if (addrLocal.IsRoutable()) { LogPrintf("AdvertizeLocal: advertizing address %s\n", addrLocal.ToString()); pnode->PushAddress(addrLocal); } } } // learn a new local address bool AddLocal(const CService& addr, int nScore) { if (!addr.IsRoutable()) return false; if (!fDiscover && nScore < LOCAL_MANUAL) return false; if (IsLimited(addr)) return false; LogPrintf("AddLocal(%s,%i)\n", addr.ToString(), nScore); { LOCK(cs_mapLocalHost); bool fAlready = mapLocalHost.count(addr) > 0; LocalServiceInfo& info = mapLocalHost[addr]; if (!fAlready || nScore >= info.nScore) { info.nScore = nScore + (fAlready ? 1 : 0); info.nPort = addr.GetPort(); } } return true; } bool AddLocal(const CNetAddr& addr, int nScore) { return AddLocal(CService(addr, GetListenPort()), nScore); } bool RemoveLocal(const CService& addr) { LOCK(cs_mapLocalHost); LogPrintf("RemoveLocal(%s)\n", addr.ToString()); mapLocalHost.erase(addr); return true; } /** Make a particular network entirely off-limits (no automatic connects to it) */ void SetLimited(enum Network net, bool fLimited) { if (net == NET_UNROUTABLE) return; LOCK(cs_mapLocalHost); vfLimited[net] = fLimited; } bool IsLimited(enum Network net) { LOCK(cs_mapLocalHost); return vfLimited[net]; } bool IsLimited(const CNetAddr& addr) { return IsLimited(addr.GetNetwork()); } /** vote for a local address */ bool SeenLocal(const CService& addr) { { LOCK(cs_mapLocalHost); if (mapLocalHost.count(addr) == 0) return false; mapLocalHost[addr].nScore++; } return true; } /** check whether a given address is potentially local */ bool IsLocal(const CService& addr) { LOCK(cs_mapLocalHost); return mapLocalHost.count(addr) > 0; } /** check whether a given network is one we can probably connect to */ bool IsReachable(enum Network net) { LOCK(cs_mapLocalHost); return !vfLimited[net]; } /** check whether a given address is in a network we can probably connect to */ bool IsReachable(const CNetAddr& addr) { enum Network net = addr.GetNetwork(); return IsReachable(net); } void AddressCurrentlyConnected(const CService& addr) { addrman.Connected(addr); } uint64_t CNode::nTotalBytesRecv = 0; uint64_t CNode::nTotalBytesSent = 0; CCriticalSection CNode::cs_totalBytesRecv; CCriticalSection CNode::cs_totalBytesSent; CNode* FindNode(const CNetAddr& ip) { LOCK(cs_vNodes); for (CNode* pnode : vNodes) if ((CNetAddr)pnode->addr == ip) return (pnode); return NULL; } CNode* FindNode(const CSubNet& subNet) { LOCK(cs_vNodes); for (CNode* pnode : vNodes) if (subNet.Match((CNetAddr)pnode->addr)) return (pnode); return NULL; } CNode* FindNode(const std::string& addrName) { LOCK(cs_vNodes); for (CNode* pnode : vNodes) if (pnode->addrName == addrName) return (pnode); return NULL; } CNode* FindNode(const CService& addr) { LOCK(cs_vNodes); for (CNode* pnode : vNodes) { if (Params().NetworkID() == CBaseChainParams::REGTEST) { //if using regtest, just check the IP if ((CNetAddr)pnode->addr == (CNetAddr)addr) return (pnode); } else { if (pnode->addr == addr) return (pnode); } } return NULL; } CNode* ConnectNode(CAddress addrConnect, const char* pszDest, bool obfuScationMaster) { if (pszDest == NULL) { // we clean masternode connections in CMasternodeMan::ProcessMasternodeConnections() // so should be safe to skip this and connect to local Hot MN on CActiveMasternode::ManageStatus() if (IsLocal(addrConnect) && !obfuScationMaster) return NULL; // Look for an existing connection CNode* pnode = FindNode((CService)addrConnect); if (pnode) { pnode->fObfuScationMaster = obfuScationMaster; pnode->AddRef(); return pnode; } } /// debug print LogPrint("net", "trying connection %s lastseen=%.1fhrs\n", pszDest ? pszDest : addrConnect.ToString(), pszDest ? 0.0 : (double)(GetAdjustedTime() - addrConnect.nTime) / 3600.0); // Connect SOCKET hSocket = INVALID_SOCKET;; bool proxyConnectionFailed = false; if (pszDest ? ConnectSocketByName(addrConnect, hSocket, pszDest, Params().GetDefaultPort(), nConnectTimeout, &proxyConnectionFailed) : ConnectSocket(addrConnect, hSocket, nConnectTimeout, &proxyConnectionFailed)) { if (!IsSelectableSocket(hSocket)) { LogPrintf("Cannot create connection: non-selectable socket created (fd >= FD_SETSIZE ?)\n"); CloseSocket(hSocket); return NULL; } addrman.Attempt(addrConnect); // Add node CNode* pnode = new CNode(hSocket, addrConnect, pszDest ? pszDest : "", false); pnode->AddRef(); { LOCK(cs_vNodes); vNodes.push_back(pnode); } pnode->nTimeConnected = GetTime(); if (obfuScationMaster) pnode->fObfuScationMaster = true; return pnode; } else if (!proxyConnectionFailed) { // If connecting to the node failed, and failure is not caused by a problem connecting to // the proxy, mark this as an attempt. addrman.Attempt(addrConnect); } return NULL; } void CNode::CloseSocketDisconnect() { fDisconnect = true; if (hSocket != INVALID_SOCKET) { LogPrint("net", "disconnecting peer=%d\n", id); CloseSocket(hSocket); } // in case this fails, we'll empty the recv buffer when the CNode is deleted TRY_LOCK(cs_vRecvMsg, lockRecv); if (lockRecv) vRecvMsg.clear(); } bool CNode::DisconnectOldProtocol(int nVersionRequired, string strLastCommand) { fDisconnect = false; if (nVersion < nVersionRequired) { LogPrintf("%s : peer=%d using obsolete version %i; disconnecting\n", __func__, id, nVersion); PushMessage("reject", strLastCommand, REJECT_OBSOLETE, strprintf("Version must be %d or greater", ActiveProtocol())); fDisconnect = true; } return fDisconnect; } void CNode::PushVersion() { int nBestHeight = g_signals.GetHeight().get_value_or(0); /// when NTP implemented, change to just nTime = GetAdjustedTime() int64_t nTime = (fInbound ? GetAdjustedTime() : GetTime()); CAddress addrYou = (addr.IsRoutable() && !IsProxy(addr) ? addr : CAddress(CService("0.0.0.0", 0))); CAddress addrMe = GetLocalAddress(&addr); GetRandBytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce)); if (fLogIPs) LogPrint("net", "send version message: version %d, blocks=%d, us=%s, them=%s, peer=%d\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString(), addrYou.ToString(), id); else LogPrint("net", "send version message: version %d, blocks=%d, us=%s, peer=%d\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString(), id); PushMessage("version", PROTOCOL_VERSION, nLocalServices, nTime, addrYou, addrMe, nLocalHostNonce, strSubVersion, nBestHeight, true); } banmap_t CNode::setBanned; CCriticalSection CNode::cs_setBanned; bool CNode::setBannedIsDirty; void CNode::ClearBanned() { { LOCK(cs_setBanned); setBanned.clear(); setBannedIsDirty = true; } DumpBanlist(); // store banlist to Disk uiInterface.BannedListChanged(); } bool CNode::IsBanned(CNetAddr ip) { bool fResult = false; { LOCK(cs_setBanned); for (banmap_t::iterator it = setBanned.begin(); it != setBanned.end(); it++) { CSubNet subNet = (*it).first; CBanEntry banEntry = (*it).second; if(subNet.Match(ip) && GetTime() < banEntry.nBanUntil) fResult = true; } } return fResult; } bool CNode::IsBanned(CSubNet subnet) { bool fResult = false; { LOCK(cs_setBanned); banmap_t::iterator i = setBanned.find(subnet); if (i != setBanned.end()) { CBanEntry banEntry = (*i).second; if (GetTime() < banEntry.nBanUntil) fResult = true; } } return fResult; } void CNode::Ban(const CNetAddr& addr, const BanReason &banReason, int64_t bantimeoffset, bool sinceUnixEpoch) { CSubNet subNet(addr); Ban(subNet, banReason, bantimeoffset, sinceUnixEpoch); } void CNode::Ban(const CSubNet& subNet, const BanReason &banReason, int64_t bantimeoffset, bool sinceUnixEpoch) { CBanEntry banEntry(GetTime()); banEntry.banReason = banReason; if (bantimeoffset <= 0) { bantimeoffset = GetArg("-bantime", 60*60*24); // Default 24-hour ban sinceUnixEpoch = false; } banEntry.nBanUntil = (sinceUnixEpoch ? 0 : GetTime() )+bantimeoffset; { LOCK(cs_setBanned); if (setBanned[subNet].nBanUntil < banEntry.nBanUntil) { setBanned[subNet] = banEntry; setBannedIsDirty = true; } else return; } uiInterface.BannedListChanged(); { LOCK(cs_vNodes); for (CNode* pnode : vNodes) { if (subNet.Match((CNetAddr)pnode->addr)) pnode->fDisconnect = true; } } if(banReason == BanReasonManuallyAdded) DumpBanlist(); //store banlist to disk immediately if user requested ban } bool CNode::Unban(const CNetAddr &addr) { CSubNet subNet(addr); return Unban(subNet); } bool CNode::Unban(const CSubNet &subNet) { { LOCK(cs_setBanned); if (!setBanned.erase(subNet)) return false; setBannedIsDirty = true; } uiInterface.BannedListChanged(); DumpBanlist(); //store banlist to disk immediately return true; } void CNode::GetBanned(banmap_t &banMap) { LOCK(cs_setBanned); banMap = setBanned; //create a thread safe copy } void CNode::SetBanned(const banmap_t &banMap) { LOCK(cs_setBanned); setBanned = banMap; setBannedIsDirty = true; } void CNode::SweepBanned() { int64_t now = GetTime(); bool notifyUI = false; { LOCK(cs_setBanned); banmap_t::iterator it = setBanned.begin(); while(it != setBanned.end()) { CSubNet subNet = (*it).first; CBanEntry banEntry = (*it).second; if(now > banEntry.nBanUntil) { setBanned.erase(it++); setBannedIsDirty = true; notifyUI = true; LogPrint("net", "%s: Removed banned node ip/subnet from banlist.dat: %s\n", __func__, subNet.ToString()); } else ++it; } } // update UI if(notifyUI) { uiInterface.BannedListChanged(); } } bool CNode::BannedSetIsDirty() { LOCK(cs_setBanned); return setBannedIsDirty; } void CNode::SetBannedSetDirty(bool dirty) { LOCK(cs_setBanned); //reuse setBanned lock for the isDirty flag setBannedIsDirty = dirty; } std::vector<CSubNet> CNode::vWhitelistedRange; CCriticalSection CNode::cs_vWhitelistedRange; bool CNode::IsWhitelistedRange(const CNetAddr& addr) { LOCK(cs_vWhitelistedRange); for (const CSubNet& subnet : vWhitelistedRange) { if (subnet.Match(addr)) return true; } return false; } void CNode::AddWhitelistedRange(const CSubNet& subnet) { LOCK(cs_vWhitelistedRange); vWhitelistedRange.push_back(subnet); } #undef X #define X(name) stats.name = name void CNode::copyStats(CNodeStats& stats) { stats.nodeid = this->GetId(); X(nServices); X(nLastSend); X(nLastRecv); X(nTimeConnected); X(nTimeOffset); X(addrName); X(nVersion); X(cleanSubVer); X(fInbound); X(nStartingHeight); X(nSendBytes); X(nRecvBytes); X(fWhitelisted); // It is common for nodes with good ping times to suddenly become lagged, // due to a new block arriving or other large transfer. // Merely reporting pingtime might fool the caller into thinking the node was still responsive, // since pingtime does not update until the ping is complete, which might take a while. // So, if a ping is taking an unusually long time in flight, // the caller can immediately detect that this is happening. int64_t nPingUsecWait = 0; if ((0 != nPingNonceSent) && (0 != nPingUsecStart)) { nPingUsecWait = GetTimeMicros() - nPingUsecStart; } // Raw ping time is in microseconds, but show it to user as whole seconds (DigitalAustralianDollar users should be well used to small numbers with many decimal places by now :) stats.dPingTime = (((double)nPingUsecTime) / 1e6); stats.dPingWait = (((double)nPingUsecWait) / 1e6); // Leave string empty if addrLocal invalid (not filled in yet) stats.addrLocal = addrLocal.IsValid() ? addrLocal.ToString() : ""; } #undef X // requires LOCK(cs_vRecvMsg) bool CNode::ReceiveMsgBytes(const char* pch, unsigned int nBytes) { while (nBytes > 0) { // get current incomplete message, or create a new one if (vRecvMsg.empty() || vRecvMsg.back().complete()) vRecvMsg.push_back(CNetMessage(SER_NETWORK, nRecvVersion)); CNetMessage& msg = vRecvMsg.back(); // absorb network data int handled; if (!msg.in_data) handled = msg.readHeader(pch, nBytes); else handled = msg.readData(pch, nBytes); if (handled < 0) return false; if (msg.in_data && msg.hdr.nMessageSize > MAX_PROTOCOL_MESSAGE_LENGTH) { LogPrint("net", "Oversized message from peer=%i, disconnecting", GetId()); return false; } pch += handled; nBytes -= handled; if (msg.complete()) { msg.nTime = GetTimeMicros(); messageHandlerCondition.notify_one(); } } return true; } int CNetMessage::readHeader(const char* pch, unsigned int nBytes) { // copy data to temporary parsing buffer unsigned int nRemaining = 24 - nHdrPos; unsigned int nCopy = std::min(nRemaining, nBytes); memcpy(&hdrbuf[nHdrPos], pch, nCopy); nHdrPos += nCopy; // if header incomplete, exit if (nHdrPos < 24) return nCopy; // deserialize to CMessageHeader try { hdrbuf >> hdr; } catch (const std::exception&) { return -1; } // reject messages larger than MAX_SIZE if (hdr.nMessageSize > MAX_SIZE) return -1; // switch state to reading message data in_data = true; return nCopy; } int CNetMessage::readData(const char* pch, unsigned int nBytes) { unsigned int nRemaining = hdr.nMessageSize - nDataPos; unsigned int nCopy = std::min(nRemaining, nBytes); if (vRecv.size() < nDataPos + nCopy) { // Allocate up to 256 KiB ahead, but never more than the total message size. vRecv.resize(std::min(hdr.nMessageSize, nDataPos + nCopy + 256 * 1024)); } memcpy(&vRecv[nDataPos], pch, nCopy); nDataPos += nCopy; return nCopy; } // requires LOCK(cs_vSend) void SocketSendData(CNode* pnode) { std::deque<CSerializeData>::iterator it = pnode->vSendMsg.begin(); while (it != pnode->vSendMsg.end()) { const CSerializeData& data = *it; assert(data.size() > pnode->nSendOffset); int nBytes = send(pnode->hSocket, &data[pnode->nSendOffset], data.size() - pnode->nSendOffset, MSG_NOSIGNAL | MSG_DONTWAIT); if (nBytes > 0) { pnode->nLastSend = GetTime(); pnode->nSendBytes += nBytes; pnode->nSendOffset += nBytes; pnode->RecordBytesSent(nBytes); if (pnode->nSendOffset == data.size()) { pnode->nSendOffset = 0; pnode->nSendSize -= data.size(); it++; } else { // could not send full message; stop sending more break; } } else { if (nBytes < 0) { // error int nErr = WSAGetLastError(); if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS) { LogPrintf("socket send error %s\n", NetworkErrorString(nErr)); pnode->CloseSocketDisconnect(); } } // couldn't send anything at all break; } } if (it == pnode->vSendMsg.end()) { assert(pnode->nSendOffset == 0); assert(pnode->nSendSize == 0); } pnode->vSendMsg.erase(pnode->vSendMsg.begin(), it); } static list<CNode*> vNodesDisconnected; void ThreadSocketHandler() { unsigned int nPrevNodeCount = 0; while (true) { // // Disconnect nodes // { LOCK(cs_vNodes); // Disconnect unused nodes vector<CNode*> vNodesCopy = vNodes; for (CNode* pnode : vNodesCopy) { if (pnode->fDisconnect || (pnode->GetRefCount() <= 0 && pnode->vRecvMsg.empty() && pnode->nSendSize == 0 && pnode->ssSend.empty())) { // remove from vNodes vNodes.erase(remove(vNodes.begin(), vNodes.end(), pnode), vNodes.end()); // release outbound grant (if any) pnode->grantOutbound.Release(); // close socket and cleanup pnode->CloseSocketDisconnect(); // hold in disconnected pool until all refs are released if (pnode->fNetworkNode || pnode->fInbound) pnode->Release(); vNodesDisconnected.push_back(pnode); } } } { // Delete disconnected nodes list<CNode*> vNodesDisconnectedCopy = vNodesDisconnected; for (CNode* pnode : vNodesDisconnectedCopy) { // wait until threads are done using it if (pnode->GetRefCount() <= 0) { bool fDelete = false; { TRY_LOCK(pnode->cs_vSend, lockSend); if (lockSend) { TRY_LOCK(pnode->cs_vRecvMsg, lockRecv); if (lockRecv) { TRY_LOCK(pnode->cs_inventory, lockInv); if (lockInv) fDelete = true; } } } if (fDelete) { vNodesDisconnected.remove(pnode); delete pnode; } } } } size_t vNodesSize; { LOCK(cs_vNodes); vNodesSize = vNodes.size(); } if(vNodesSize != nPrevNodeCount) { nPrevNodeCount = vNodesSize; uiInterface.NotifyNumConnectionsChanged(nPrevNodeCount); } // // Find which sockets have data to receive // struct timeval timeout; timeout.tv_sec = 0; timeout.tv_usec = 50000; // frequency to poll pnode->vSend fd_set fdsetRecv; fd_set fdsetSend; fd_set fdsetError; FD_ZERO(&fdsetRecv); FD_ZERO(&fdsetSend); FD_ZERO(&fdsetError); SOCKET hSocketMax = 0; bool have_fds = false; for (const ListenSocket& hListenSocket : vhListenSocket) { FD_SET(hListenSocket.socket, &fdsetRecv); hSocketMax = max(hSocketMax, hListenSocket.socket); have_fds = true; } { LOCK(cs_vNodes); for (CNode* pnode : vNodes) { if (pnode->hSocket == INVALID_SOCKET) continue; FD_SET(pnode->hSocket, &fdsetError); hSocketMax = max(hSocketMax, pnode->hSocket); have_fds = true; // Implement the following logic: // * If there is data to send, select() for sending data. As this only // happens when optimistic write failed, we choose to first drain the // write buffer in this case before receiving more. This avoids // needlessly queueing received data, if the remote peer is not themselves // receiving data. This means properly utilizing TCP flow control signalling. // * Otherwise, if there is no (complete) message in the receive buffer, // or there is space left in the buffer, select() for receiving data. // * (if neither of the above applies, there is certainly one message // in the receiver buffer ready to be processed). // Together, that means that at least one of the following is always possible, // so we don't deadlock: // * We send some data. // * We wait for data to be received (and disconnect after timeout). // * We process a message in the buffer (message handler thread). { TRY_LOCK(pnode->cs_vSend, lockSend); if (lockSend && !pnode->vSendMsg.empty()) { FD_SET(pnode->hSocket, &fdsetSend); continue; } } { TRY_LOCK(pnode->cs_vRecvMsg, lockRecv); if (lockRecv && (pnode->vRecvMsg.empty() || !pnode->vRecvMsg.front().complete() || pnode->GetTotalRecvSize() <= ReceiveFloodSize())) FD_SET(pnode->hSocket, &fdsetRecv); } } } int nSelect = select(have_fds ? hSocketMax + 1 : 0, &fdsetRecv, &fdsetSend, &fdsetError, &timeout); boost::this_thread::interruption_point(); if (nSelect == SOCKET_ERROR) { if (have_fds) { int nErr = WSAGetLastError(); LogPrintf("socket select error %s\n", NetworkErrorString(nErr)); for (unsigned int i = 0; i <= hSocketMax; i++) FD_SET(i, &fdsetRecv); } FD_ZERO(&fdsetSend); FD_ZERO(&fdsetError); MilliSleep(timeout.tv_usec / 1000); } // // Accept new connections // for (const ListenSocket& hListenSocket : vhListenSocket) { if (hListenSocket.socket != INVALID_SOCKET && FD_ISSET(hListenSocket.socket, &fdsetRecv)) { struct sockaddr_storage sockaddr; socklen_t len = sizeof(sockaddr); SOCKET hSocket = accept(hListenSocket.socket, (struct sockaddr*)&sockaddr, &len); CAddress addr; int nInbound = 0; if (hSocket != INVALID_SOCKET) if (!addr.SetSockAddr((const struct sockaddr*)&sockaddr)) LogPrintf("Warning: Unknown socket family\n"); bool whitelisted = hListenSocket.whitelisted || CNode::IsWhitelistedRange(addr); { LOCK(cs_vNodes); for (CNode* pnode : vNodes) if (pnode->fInbound) nInbound++; } if (hSocket == INVALID_SOCKET) { int nErr = WSAGetLastError(); if (nErr != WSAEWOULDBLOCK) LogPrintf("socket error accept failed: %s\n", NetworkErrorString(nErr)); } else if (!IsSelectableSocket(hSocket)) { LogPrintf("connection from %s dropped: non-selectable socket\n", addr.ToString()); CloseSocket(hSocket); } else if (nInbound >= nMaxConnections - MAX_OUTBOUND_CONNECTIONS) { LogPrint("net", "connection from %s dropped (full)\n", addr.ToString()); CloseSocket(hSocket); } else if (CNode::IsBanned(addr) && !whitelisted) { LogPrintf("connection from %s dropped (banned)\n", addr.ToString()); CloseSocket(hSocket); } else { CNode* pnode = new CNode(hSocket, addr, "", true); pnode->AddRef(); pnode->fWhitelisted = whitelisted; { LOCK(cs_vNodes); vNodes.push_back(pnode); } } } } // // Service each socket // vector<CNode*> vNodesCopy; { LOCK(cs_vNodes); vNodesCopy = vNodes; for (CNode* pnode : vNodesCopy) pnode->AddRef(); } for (CNode* pnode : vNodesCopy) { boost::this_thread::interruption_point(); // // Receive // if (pnode->hSocket == INVALID_SOCKET) continue; if (FD_ISSET(pnode->hSocket, &fdsetRecv) || FD_ISSET(pnode->hSocket, &fdsetError)) { TRY_LOCK(pnode->cs_vRecvMsg, lockRecv); if (lockRecv) { { // typical socket buffer is 8K-64K char pchBuf[0x10000]; int nBytes = recv(pnode->hSocket, pchBuf, sizeof(pchBuf), MSG_DONTWAIT); if (nBytes > 0) { if (!pnode->ReceiveMsgBytes(pchBuf, nBytes)) pnode->CloseSocketDisconnect(); pnode->nLastRecv = GetTime(); pnode->nRecvBytes += nBytes; pnode->RecordBytesRecv(nBytes); } else if (nBytes == 0) { // socket closed gracefully if (!pnode->fDisconnect) LogPrint("net", "socket closed\n"); pnode->CloseSocketDisconnect(); } else if (nBytes < 0) { // error int nErr = WSAGetLastError(); if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS) { if (!pnode->fDisconnect) LogPrintf("socket recv error %s\n", NetworkErrorString(nErr)); pnode->CloseSocketDisconnect(); } } } } } // // Send // if (pnode->hSocket == INVALID_SOCKET) continue; if (FD_ISSET(pnode->hSocket, &fdsetSend)) { TRY_LOCK(pnode->cs_vSend, lockSend); if (lockSend) SocketSendData(pnode); } // // Inactivity checking // int64_t nTime = GetTime(); if (nTime - pnode->nTimeConnected > 60) { if (pnode->nLastRecv == 0 || pnode->nLastSend == 0) { LogPrint("net", "socket no message in first 60 seconds, %d %d from %d\n", pnode->nLastRecv != 0, pnode->nLastSend != 0, pnode->id); pnode->fDisconnect = true; } else if (nTime - pnode->nLastSend > TIMEOUT_INTERVAL) { LogPrintf("socket sending timeout: %is\n", nTime - pnode->nLastSend); pnode->fDisconnect = true; } else if (nTime - pnode->nLastRecv > (pnode->nVersion > BIP0031_VERSION ? TIMEOUT_INTERVAL : 90 * 60)) { LogPrintf("socket receive timeout: %is\n", nTime - pnode->nLastRecv); pnode->fDisconnect = true; } else if (pnode->nPingNonceSent && pnode->nPingUsecStart + TIMEOUT_INTERVAL * 1000000 < GetTimeMicros()) { LogPrintf("ping timeout: %fs\n", 0.000001 * (GetTimeMicros() - pnode->nPingUsecStart)); pnode->fDisconnect = true; } } } { LOCK(cs_vNodes); for (CNode* pnode : vNodesCopy) pnode->Release(); } } } #ifdef USE_UPNP void ThreadMapPort() { std::string port = strprintf("%u", GetListenPort()); const char* multicastif = 0; const char* minissdpdpath = 0; struct UPNPDev* devlist = 0; char lanaddr[64]; #ifndef UPNPDISCOVER_SUCCESS /* miniupnpc 1.5 */ devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0); #elif MINIUPNPC_API_VERSION < 14 /* miniupnpc 1.6 */ int error = 0; devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0, 0, &error); #else /* miniupnpc 1.9.20150730 */ int error = 0; devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0, 0, 2, &error); #endif struct UPNPUrls urls; struct IGDdatas data; int r; r = UPNP_GetValidIGD(devlist, &urls, &data, lanaddr, sizeof(lanaddr)); if (r == 1) { if (fDiscover) { char externalIPAddress[40]; r = UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIPAddress); if (r != UPNPCOMMAND_SUCCESS) LogPrintf("UPnP: GetExternalIPAddress() returned %d\n", r); else { if (externalIPAddress[0]) { LogPrintf("UPnP: ExternalIPAddress = %s\n", externalIPAddress); AddLocal(CNetAddr(externalIPAddress), LOCAL_UPNP); } else LogPrintf("UPnP: GetExternalIPAddress failed.\n"); } } string strDesc = "DigitalAustralianDollar " + FormatFullVersion(); try { while (true) { #ifndef UPNPDISCOVER_SUCCESS /* miniupnpc 1.5 */ r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, port.c_str(), port.c_str(), lanaddr, strDesc.c_str(), "TCP", 0); #else /* miniupnpc 1.6 */ r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, port.c_str(), port.c_str(), lanaddr, strDesc.c_str(), "TCP", 0, "0"); #endif if (r != UPNPCOMMAND_SUCCESS) LogPrintf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n", port, port, lanaddr, r, strupnperror(r)); else LogPrintf("UPnP Port Mapping successful.\n"); ; MilliSleep(20 * 60 * 1000); // Refresh every 20 minutes } } catch (boost::thread_interrupted) { r = UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, port.c_str(), "TCP", 0); LogPrintf("UPNP_DeletePortMapping() returned : %d\n", r); freeUPNPDevlist(devlist); devlist = 0; FreeUPNPUrls(&urls); throw; } } else { LogPrintf("No valid UPnP IGDs found\n"); freeUPNPDevlist(devlist); devlist = 0; if (r != 0) FreeUPNPUrls(&urls); } } void MapPort(bool fUseUPnP) { static boost::thread* upnp_thread = NULL; if (fUseUPnP) { if (upnp_thread) { upnp_thread->interrupt(); upnp_thread->join(); delete upnp_thread; } upnp_thread = new boost::thread(boost::bind(&TraceThread<void (*)()>, "upnp", &ThreadMapPort)); } else if (upnp_thread) { upnp_thread->interrupt(); upnp_thread->join(); delete upnp_thread; upnp_thread = NULL; } } #else void MapPort(bool) { // Intentionally left blank. } #endif void ThreadDNSAddressSeed() { // goal: only query DNS seeds if address need is acute if ((addrman.size() > 0) && (!GetBoolArg("-forcednsseed", false))) { MilliSleep(11 * 1000); LOCK(cs_vNodes); if (vNodes.size() >= 2) { LogPrintf("P2P peers available. Skipped DNS seeding.\n"); return; } } const vector<CDNSSeedData>& vSeeds = Params().DNSSeeds(); int found = 0; LogPrintf("Loading addresses from DNS seeds (could take a while)\n"); for (const CDNSSeedData& seed : vSeeds) { if (HaveNameProxy()) { AddOneShot(seed.host); } else { vector<CNetAddr> vIPs; vector<CAddress> vAdd; if (LookupHost(seed.host.c_str(), vIPs)) { for (CNetAddr& ip : vIPs) { int nOneDay = 24 * 3600; CAddress addr = CAddress(CService(ip, Params().GetDefaultPort())); addr.nTime = GetTime() - 3 * nOneDay - GetRand(4 * nOneDay); // use a random age between 3 and 7 days old vAdd.push_back(addr); found++; } } addrman.Add(vAdd, CNetAddr(seed.name, true)); } } LogPrintf("%d addresses found from DNS seeds\n", found); } void DumpAddresses() { int64_t nStart = GetTimeMillis(); CAddrDB adb; adb.Write(addrman); LogPrint("net", "Flushed %d addresses to peers.dat %dms\n", addrman.size(), GetTimeMillis() - nStart); } void DumpData() { DumpAddresses(); DumpBanlist(); } void static ProcessOneShot() { string strDest; { LOCK(cs_vOneShots); if (vOneShots.empty()) return; strDest = vOneShots.front(); vOneShots.pop_front(); } CAddress addr; CSemaphoreGrant grant(*semOutbound, true); if (grant) { if (!OpenNetworkConnection(addr, &grant, strDest.c_str(), true)) AddOneShot(strDest); } } void ThreadOpenConnections() { // Connect to specific addresses if (mapArgs.count("-connect") && mapMultiArgs["-connect"].size() > 0) { for (int64_t nLoop = 0;; nLoop++) { ProcessOneShot(); for (string strAddr : mapMultiArgs["-connect"]) { CAddress addr; OpenNetworkConnection(addr, NULL, strAddr.c_str()); for (int i = 0; i < 10 && i < nLoop; i++) { MilliSleep(500); } } MilliSleep(500); } } // Initiate network connections int64_t nStart = GetTime(); while (true) { ProcessOneShot(); MilliSleep(500); CSemaphoreGrant grant(*semOutbound); boost::this_thread::interruption_point(); // Add seed nodes if DNS seeds are all down (an infrastructure attack?). if (addrman.size() == 0 && (GetTime() - nStart > 60)) { static bool done = false; if (!done) { LogPrintf("Adding fixed seed nodes as DNS doesn't seem to be available.\n"); addrman.Add(Params().FixedSeeds(), CNetAddr("127.0.0.1")); done = true; } } // // Choose an address to connect to based on most recently seen // CAddress addrConnect; // Only connect out to one peer per network group (/16 for IPv4). // Do this here so we don't have to critsect vNodes inside mapAddresses critsect. int nOutbound = 0; set<vector<unsigned char> > setConnected; { LOCK(cs_vNodes); for (CNode* pnode : vNodes) { if (!pnode->fInbound) { setConnected.insert(pnode->addr.GetGroup()); nOutbound++; } } } int64_t nANow = GetAdjustedTime(); int nTries = 0; while (true) { CAddrInfo addr = addrman.Select(); // if we selected an invalid address, restart if (!addr.IsValid() || setConnected.count(addr.GetGroup()) || IsLocal(addr)) break; // If we didn't find an appropriate destination after trying 100 addresses fetched from addrman, // stop this loop, and let the outer loop run again (which sleeps, adds seed nodes, recalculates // already-connected network ranges, ...) before trying new addrman addresses. nTries++; if (nTries > 100) break; if (IsLimited(addr)) continue; // only consider very recently tried nodes after 30 failed attempts if (nANow - addr.nLastTry < 600 && nTries < 30) continue; // do not allow non-default ports, unless after 50 invalid addresses selected already if (addr.GetPort() != Params().GetDefaultPort() && nTries < 50) continue; addrConnect = addr; break; } if (addrConnect.IsValid()) OpenNetworkConnection(addrConnect, &grant); } } void ThreadOpenAddedConnections() { { LOCK(cs_vAddedNodes); vAddedNodes = mapMultiArgs["-addnode"]; } if (HaveNameProxy()) { while (true) { list<string> lAddresses(0); { LOCK(cs_vAddedNodes); for (string& strAddNode : vAddedNodes) lAddresses.push_back(strAddNode); } for (string& strAddNode : lAddresses) { CAddress addr; CSemaphoreGrant grant(*semOutbound); OpenNetworkConnection(addr, &grant, strAddNode.c_str()); MilliSleep(500); } MilliSleep(120000); // Retry every 2 minutes } } for (unsigned int i = 0; true; i++) { list<string> lAddresses(0); { LOCK(cs_vAddedNodes); for (string& strAddNode : vAddedNodes) lAddresses.push_back(strAddNode); } list<vector<CService> > lservAddressesToAdd(0); for (string& strAddNode : lAddresses) { vector<CService> vservNode(0); if (Lookup(strAddNode.c_str(), vservNode, Params().GetDefaultPort(), fNameLookup, 0)) { lservAddressesToAdd.push_back(vservNode); { LOCK(cs_setservAddNodeAddresses); for (CService& serv : vservNode) setservAddNodeAddresses.insert(serv); } } } // Attempt to connect to each IP for each addnode entry until at least one is successful per addnode entry // (keeping in mind that addnode entries can have many IPs if fNameLookup) { LOCK(cs_vNodes); for (CNode* pnode : vNodes) for (list<vector<CService> >::iterator it = lservAddressesToAdd.begin(); it != lservAddressesToAdd.end(); it++) for (CService& addrNode : *(it)) if (pnode->addr == addrNode) { it = lservAddressesToAdd.erase(it); it--; break; } } for (vector<CService>& vserv : lservAddressesToAdd) { CSemaphoreGrant grant(*semOutbound); OpenNetworkConnection(CAddress(vserv[i % vserv.size()]), &grant); MilliSleep(500); } MilliSleep(120000); // Retry every 2 minutes } } // if successful, this moves the passed grant to the constructed node bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant* grantOutbound, const char* pszDest, bool fOneShot) { // // Initiate outbound network connection // boost::this_thread::interruption_point(); if (!pszDest) { if (IsLocal(addrConnect) || FindNode((CNetAddr)addrConnect) || CNode::IsBanned(addrConnect) || FindNode(addrConnect.ToStringIPPort())) return false; } else if (FindNode(pszDest)) return false; CNode* pnode = ConnectNode(addrConnect, pszDest); boost::this_thread::interruption_point(); if (!pnode) return false; if (grantOutbound) grantOutbound->MoveTo(pnode->grantOutbound); pnode->fNetworkNode = true; if (fOneShot) pnode->fOneShot = true; return true; } void ThreadMessageHandler() { boost::mutex condition_mutex; boost::unique_lock<boost::mutex> lock(condition_mutex); SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL); while (true) { vector<CNode*> vNodesCopy; { LOCK(cs_vNodes); vNodesCopy = vNodes; for (CNode* pnode : vNodesCopy) { pnode->AddRef(); } } // Poll the connected nodes for messages CNode* pnodeTrickle = NULL; if (!vNodesCopy.empty()) pnodeTrickle = vNodesCopy[GetRand(vNodesCopy.size())]; bool fSleep = true; for (CNode* pnode : vNodesCopy) { if (pnode->fDisconnect) continue; // Receive messages { TRY_LOCK(pnode->cs_vRecvMsg, lockRecv); if (lockRecv) { if (!g_signals.ProcessMessages(pnode)) pnode->CloseSocketDisconnect(); if (pnode->nSendSize < SendBufferSize()) { if (!pnode->vRecvGetData.empty() || (!pnode->vRecvMsg.empty() && pnode->vRecvMsg[0].complete())) { fSleep = false; } } } } boost::this_thread::interruption_point(); // Send messages { TRY_LOCK(pnode->cs_vSend, lockSend); if (lockSend) g_signals.SendMessages(pnode, pnode == pnodeTrickle || pnode->fWhitelisted); } boost::this_thread::interruption_point(); } { LOCK(cs_vNodes); for (CNode* pnode : vNodesCopy) pnode->Release(); } if (fSleep) messageHandlerCondition.timed_wait(lock, boost::posix_time::microsec_clock::universal_time() + boost::posix_time::milliseconds(100)); } } #ifdef ENABLE_WALLET // ppcoin: stake minter thread void static ThreadStakeMinter() { boost::this_thread::interruption_point(); LogPrintf("ThreadStakeMinter started\n"); CWallet* pwallet = pwalletMain; try { BitcoinMiner(pwallet, true); boost::this_thread::interruption_point(); } catch (std::exception& e) { LogPrintf("ThreadStakeMinter() exception \n"); } catch (...) { LogPrintf("ThreadStakeMinter() error \n"); } LogPrintf("ThreadStakeMinter exiting,\n"); } #endif // ENABLE_WALLET bool BindListenPort(const CService& addrBind, string& strError, bool fWhitelisted) { strError = ""; int nOne = 1; // Create socket for listening for incoming connections struct sockaddr_storage sockaddr; socklen_t len = sizeof(sockaddr); if (!addrBind.GetSockAddr((struct sockaddr*)&sockaddr, &len)) { strError = strprintf("Error: Bind address family for %s not supported", addrBind.ToString()); LogPrintf("%s\n", strError); return false; } SOCKET hListenSocket = socket(((struct sockaddr*)&sockaddr)->sa_family, SOCK_STREAM, IPPROTO_TCP); if (hListenSocket == INVALID_SOCKET) { strError = strprintf("Error: Couldn't open socket for incoming connections (socket returned error %s)", NetworkErrorString(WSAGetLastError())); LogPrintf("%s\n", strError); return false; } if (!IsSelectableSocket(hListenSocket)) { strError = "Error: Couldn't create a listenable socket for incoming connections"; LogPrintf("%s\n", strError); return false; } #ifndef WIN32 #ifdef SO_NOSIGPIPE // Different way of disabling SIGPIPE on BSD setsockopt(hListenSocket, SOL_SOCKET, SO_NOSIGPIPE, (void*)&nOne, sizeof(int)); #endif // Allow binding if the port is still in TIME_WAIT state after // the program was closed and restarted. Not an issue on windows! setsockopt(hListenSocket, SOL_SOCKET, SO_REUSEADDR, (void*)&nOne, sizeof(int)); #endif // Set to non-blocking, incoming connections will also inherit this if (!SetSocketNonBlocking(hListenSocket, true)) { strError = strprintf("BindListenPort: Setting listening socket to non-blocking failed, error %s\n", NetworkErrorString(WSAGetLastError())); LogPrintf("%s\n", strError); return false; } // some systems don't have IPV6_V6ONLY but are always v6only; others do have the option // and enable it by default or not. Try to enable it, if possible. if (addrBind.IsIPv6()) { #ifdef IPV6_V6ONLY #ifdef WIN32 setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&nOne, sizeof(int)); #else setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&nOne, sizeof(int)); #endif #endif #ifdef WIN32 int nProtLevel = PROTECTION_LEVEL_UNRESTRICTED; setsockopt(hListenSocket, IPPROTO_IPV6, IPV6_PROTECTION_LEVEL, (const char*)&nProtLevel, sizeof(int)); #endif } if (::bind(hListenSocket, (struct sockaddr*)&sockaddr, len) == SOCKET_ERROR) { int nErr = WSAGetLastError(); if (nErr == WSAEADDRINUSE) strError = strprintf(_("Unable to bind to %s on this computer. DigitalAustralianDollar Core is probably already running."), addrBind.ToString()); else strError = strprintf(_("Unable to bind to %s on this computer (bind returned error %s)"), addrBind.ToString(), NetworkErrorString(nErr)); LogPrintf("%s\n", strError); CloseSocket(hListenSocket); return false; } LogPrintf("Bound to %s\n", addrBind.ToString()); // Listen for incoming connections if (listen(hListenSocket, SOMAXCONN) == SOCKET_ERROR) { strError = strprintf(_("Error: Listening for incoming connections failed (listen returned error %s)"), NetworkErrorString(WSAGetLastError())); LogPrintf("%s\n", strError); CloseSocket(hListenSocket); return false; } vhListenSocket.push_back(ListenSocket(hListenSocket, fWhitelisted)); if (addrBind.IsRoutable() && fDiscover && !fWhitelisted) AddLocal(addrBind, LOCAL_BIND); return true; } void static Discover(boost::thread_group& threadGroup) { if (!fDiscover) return; #ifdef WIN32 // Get local host IP char pszHostName[256] = ""; if (gethostname(pszHostName, sizeof(pszHostName)) != SOCKET_ERROR) { vector<CNetAddr> vaddr; if (LookupHost(pszHostName, vaddr)) { for (const CNetAddr& addr : vaddr) { if (AddLocal(addr, LOCAL_IF)) LogPrintf("%s: %s - %s\n", __func__, pszHostName, addr.ToString()); } } } #else // Get local host ip struct ifaddrs* myaddrs; if (getifaddrs(&myaddrs) == 0) { for (struct ifaddrs* ifa = myaddrs; ifa != NULL; ifa = ifa->ifa_next) { if (ifa->ifa_addr == NULL) continue; if ((ifa->ifa_flags & IFF_UP) == 0) continue; if (strcmp(ifa->ifa_name, "lo") == 0) continue; if (strcmp(ifa->ifa_name, "lo0") == 0) continue; if (ifa->ifa_addr->sa_family == AF_INET) { struct sockaddr_in* s4 = (struct sockaddr_in*)(ifa->ifa_addr); CNetAddr addr(s4->sin_addr); if (AddLocal(addr, LOCAL_IF)) LogPrintf("%s: IPv4 %s: %s\n", __func__, ifa->ifa_name, addr.ToString()); } else if (ifa->ifa_addr->sa_family == AF_INET6) { struct sockaddr_in6* s6 = (struct sockaddr_in6*)(ifa->ifa_addr); CNetAddr addr(s6->sin6_addr); if (AddLocal(addr, LOCAL_IF)) LogPrintf("%s: IPv6 %s: %s\n", __func__, ifa->ifa_name, addr.ToString()); } } freeifaddrs(myaddrs); } #endif } void StartNode(boost::thread_group& threadGroup, CScheduler& scheduler) { uiInterface.InitMessage(_("Loading addresses...")); // Load addresses for peers.dat int64_t nStart = GetTimeMillis(); { CAddrDB adb; if (!adb.Read(addrman)) LogPrintf("Invalid or missing peers.dat; recreating\n"); } //try to read stored banlist CBanDB bandb; banmap_t banmap; if (!bandb.Read(banmap)) LogPrintf("Invalid or missing banlist.dat; recreating\n"); CNode::SetBanned(banmap); //thread save setter CNode::SetBannedSetDirty(false); //no need to write down just read or nonexistent data CNode::SweepBanned(); //sweap out unused entries // Initialize random numbers. Even when rand() is only usable for trivial use-cases most nodes should have a different // seed after all the file-IO done at this point. Should be good enough even when nodes are started via scripts. srand(time(NULL)); LogPrintf("Loaded %i addresses from peers.dat %dms\n", addrman.size(), GetTimeMillis() - nStart); fAddressesInitialized = true; if (semOutbound == NULL) { // initialize semaphore int nMaxOutbound = min(MAX_OUTBOUND_CONNECTIONS, nMaxConnections); semOutbound = new CSemaphore(nMaxOutbound); } if (pnodeLocalHost == NULL) pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress(CService("127.0.0.1", 0), nLocalServices)); Discover(threadGroup); // // Start threads // if (!GetBoolArg("-dnsseed", true)) LogPrintf("DNS seeding disabled\n"); else threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "dnsseed", &ThreadDNSAddressSeed)); // Map ports with UPnP MapPort(GetBoolArg("-upnp", DEFAULT_UPNP)); // Send and receive from sockets, accept connections threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "net", &ThreadSocketHandler)); // Initiate outbound connections from -addnode threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "addcon", &ThreadOpenAddedConnections)); // Initiate outbound connections threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "opencon", &ThreadOpenConnections)); // Process messages threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "msghand", &ThreadMessageHandler)); // Dump network addresses scheduler.scheduleEvery(&DumpData, DUMP_ADDRESSES_INTERVAL); #ifdef ENABLE_WALLET // ppcoin:mint proof-of-stake blocks in the background if (GetBoolArg("-staking", true) && pwalletMain) threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "stakemint", &ThreadStakeMinter)); #endif // ENABLE_WALLET } bool StopNode() { LogPrintf("StopNode()\n"); MapPort(false); if (semOutbound) for (int i = 0; i < MAX_OUTBOUND_CONNECTIONS; i++) semOutbound->post(); if (fAddressesInitialized) { DumpData(); fAddressesInitialized = false; } return true; } class CNetCleanup { public: CNetCleanup() {} ~CNetCleanup() { // Close sockets for (CNode* pnode : vNodes) if (pnode->hSocket != INVALID_SOCKET) CloseSocket(pnode->hSocket); for (ListenSocket& hListenSocket : vhListenSocket) if (hListenSocket.socket != INVALID_SOCKET) if (!CloseSocket(hListenSocket.socket)) LogPrintf("CloseSocket(hListenSocket) failed with error %s\n", NetworkErrorString(WSAGetLastError())); // clean up some globals (to help leak detection) for (CNode* pnode : vNodes) delete pnode; for (CNode* pnode : vNodesDisconnected) delete pnode; vNodes.clear(); vNodesDisconnected.clear(); vhListenSocket.clear(); delete semOutbound; semOutbound = NULL; delete pnodeLocalHost; pnodeLocalHost = NULL; #ifdef WIN32 // Shutdown Windows Sockets WSACleanup(); #endif } } instance_of_cnetcleanup; void CExplicitNetCleanup::callCleanup() { // Explicit call to destructor of CNetCleanup because it's not implicitly called // when the wallet is restarted from within the wallet itself. CNetCleanup* tmp = new CNetCleanup(); delete tmp; // Stroustrup's gonna kill me for that } void RelayTransaction(const CTransaction& tx) { CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); ss.reserve(10000); ss << tx; RelayTransaction(tx, ss); } void RelayTransaction(const CTransaction& tx, const CDataStream& ss) { CInv inv(MSG_TX, tx.GetHash()); { LOCK(cs_mapRelay); // Expire old relay messages while (!vRelayExpiration.empty() && vRelayExpiration.front().first < GetTime()) { mapRelay.erase(vRelayExpiration.front().second); vRelayExpiration.pop_front(); } // Save original serialized message so newer versions are preserved mapRelay.insert(std::make_pair(inv, ss)); vRelayExpiration.push_back(std::make_pair(GetTime() + 15 * 60, inv)); } LOCK(cs_vNodes); for (CNode* pnode : vNodes) { if (!pnode->fRelayTxes) continue; LOCK(pnode->cs_filter); if (pnode->pfilter) { if (pnode->pfilter->IsRelevantAndUpdate(tx)) pnode->PushInventory(inv); } else pnode->PushInventory(inv); } } void RelayTransactionLockReq(const CTransaction& tx, bool relayToAll) { CInv inv(MSG_TXLOCK_REQUEST, tx.GetHash()); //broadcast the new lock LOCK(cs_vNodes); for (CNode* pnode : vNodes) { if (!relayToAll && !pnode->fRelayTxes) continue; pnode->PushMessage("ix", tx); } } void RelayInv(CInv& inv) { LOCK(cs_vNodes); for (CNode* pnode : vNodes){ if((pnode->nServices == NODE_BLOOM_WITHOUT_MN || pnode->nServices == NODE_BLOOM_LIGHT_ZC) && inv.IsMasterNodeType())continue; if (pnode->nVersion >= ActiveProtocol()) pnode->PushInventory(inv); } } void CNode::RecordBytesRecv(uint64_t bytes) { LOCK(cs_totalBytesRecv); nTotalBytesRecv += bytes; } void CNode::RecordBytesSent(uint64_t bytes) { LOCK(cs_totalBytesSent); nTotalBytesSent += bytes; } uint64_t CNode::GetTotalBytesRecv() { LOCK(cs_totalBytesRecv); return nTotalBytesRecv; } uint64_t CNode::GetTotalBytesSent() { LOCK(cs_totalBytesSent); return nTotalBytesSent; } void CNode::Fuzz(int nChance) { if (!fSuccessfullyConnected) return; // Don't fuzz initial handshake if (GetRand(nChance) != 0) return; // Fuzz 1 of every nChance messages switch (GetRand(3)) { case 0: // xor a random byte with a random value: if (!ssSend.empty()) { CDataStream::size_type pos = GetRand(ssSend.size()); ssSend[pos] ^= (unsigned char)(GetRand(256)); } break; case 1: // delete a random byte: if (!ssSend.empty()) { CDataStream::size_type pos = GetRand(ssSend.size()); ssSend.erase(ssSend.begin() + pos); } break; case 2: // insert a random byte at a random position { CDataStream::size_type pos = GetRand(ssSend.size()); char ch = (char)GetRand(256); ssSend.insert(ssSend.begin() + pos, ch); } break; } // Chance of more than one change half the time: // (more changes exponentially less likely): Fuzz(2); } // // CAddrDB // CAddrDB::CAddrDB() { pathAddr = GetDataDir() / "peers.dat"; } bool CAddrDB::Write(const CAddrMan& addr) { // Generate random temporary filename unsigned short randv = 0; GetRandBytes((unsigned char*)&randv, sizeof(randv)); std::string tmpfn = strprintf("peers.dat.%04x", randv); // serialize addresses, checksum data up to that point, then append csum CDataStream ssPeers(SER_DISK, CLIENT_VERSION); ssPeers << FLATDATA(Params().MessageStart()); ssPeers << addr; uint256 hash = Hash(ssPeers.begin(), ssPeers.end()); ssPeers << hash; // open output file, and associate with CAutoFile boost::filesystem::path pathAddr = GetDataDir() / "peers.dat"; FILE* file = fopen(pathAddr.string().c_str(), "wb"); CAutoFile fileout(file, SER_DISK, CLIENT_VERSION); if (fileout.IsNull()) return error("%s : Failed to open file %s", __func__, pathAddr.string()); // Write and commit header, data try { fileout << ssPeers; } catch (std::exception& e) { return error("%s : Serialize or I/O error - %s", __func__, e.what()); } FileCommit(fileout.Get()); fileout.fclose(); return true; } bool CAddrDB::Read(CAddrMan& addr) { // open input file, and associate with CAutoFile FILE* file = fopen(pathAddr.string().c_str(), "rb"); CAutoFile filein(file, SER_DISK, CLIENT_VERSION); if (filein.IsNull()) return error("%s : Failed to open file %s", __func__, pathAddr.string()); // use file size to size memory buffer uint64_t fileSize = boost::filesystem::file_size(pathAddr); uint64_t dataSize = fileSize - sizeof(uint256); // Don't try to resize to a negative number if file is small if (fileSize >= sizeof(uint256)) dataSize = fileSize - sizeof(uint256); vector<unsigned char> vchData; vchData.resize(dataSize); uint256 hashIn; // read data and checksum from file try { filein.read((char*)&vchData[0], dataSize); filein >> hashIn; } catch (std::exception& e) { return error("%s : Deserialize or I/O error - %s", __func__, e.what()); } filein.fclose(); CDataStream ssPeers(vchData, SER_DISK, CLIENT_VERSION); // verify stored checksum matches input data uint256 hashTmp = Hash(ssPeers.begin(), ssPeers.end()); if (hashIn != hashTmp) return error("%s : Checksum mismatch, data corrupted", __func__); unsigned char pchMsgTmp[4]; try { // de-serialize file header (network specific magic number) and .. ssPeers >> FLATDATA(pchMsgTmp); // ... verify the network matches ours if (memcmp(pchMsgTmp, Params().MessageStart(), sizeof(pchMsgTmp))) return error("%s : Invalid network magic number", __func__); // de-serialize address data into one CAddrMan object ssPeers >> addr; } catch (std::exception& e) { return error("%s : Deserialize or I/O error - %s", __func__, e.what()); } return true; } unsigned int ReceiveFloodSize() { return 1000 * GetArg("-maxreceivebuffer", 5 * 1000); } unsigned int SendBufferSize() { return 1000 * GetArg("-maxsendbuffer", 1 * 1000); } CNode::CNode(SOCKET hSocketIn, CAddress addrIn, std::string addrNameIn, bool fInboundIn) : ssSend(SER_NETWORK, INIT_PROTO_VERSION), setAddrKnown(5000) { nServices = 0; hSocket = hSocketIn; nRecvVersion = INIT_PROTO_VERSION; nLastSend = 0; nLastRecv = 0; nSendBytes = 0; nRecvBytes = 0; nTimeConnected = GetTime(); nTimeOffset = 0; addr = addrIn; addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn; nVersion = 0; strSubVer = ""; fWhitelisted = false; fOneShot = false; fClient = false; // set by version message fInbound = fInboundIn; fNetworkNode = false; fSuccessfullyConnected = false; fDisconnect = false; nRefCount = 0; nSendSize = 0; nSendOffset = 0; hashContinue = 0; nStartingHeight = -1; fGetAddr = false; fRelayTxes = false; setInventoryKnown.max_size(SendBufferSize() / 1000); pfilter = new CBloomFilter(); nPingNonceSent = 0; nPingUsecStart = 0; nPingUsecTime = 0; fPingQueued = false; fObfuScationMaster = false; { LOCK(cs_nLastNodeId); id = nLastNodeId++; } if (fLogIPs) LogPrint("net", "Added connection to %s peer=%d\n", addrName, id); else LogPrint("net", "Added connection peer=%d\n", id); // Be shy and don't send version until we hear if (hSocket != INVALID_SOCKET && !fInbound) PushVersion(); GetNodeSignals().InitializeNode(GetId(), this); } CNode::~CNode() { CloseSocket(hSocket); if (pfilter) delete pfilter; GetNodeSignals().FinalizeNode(GetId()); } void CNode::AskFor(const CInv& inv) { if (mapAskFor.size() > MAPASKFOR_MAX_SZ) return; // We're using mapAskFor as a priority queue, // the key is the earliest time the request can be sent int64_t nRequestTime; limitedmap<CInv, int64_t>::const_iterator it = mapAlreadyAskedFor.find(inv); if (it != mapAlreadyAskedFor.end()) nRequestTime = it->second; else nRequestTime = 0; LogPrint("net", "askfor %s %d (%s) peer=%d\n", inv.ToString(), nRequestTime, DateTimeStrFormat("%H:%M:%S", nRequestTime / 1000000), id); // Make sure not to reuse time indexes to keep things in the same order int64_t nNow = GetTimeMicros() - 1000000; static int64_t nLastTime; ++nLastTime; nNow = std::max(nNow, nLastTime); nLastTime = nNow; // Each retry is 2 minutes after the last nRequestTime = std::max(nRequestTime + 2 * 60 * 1000000, nNow); if (it != mapAlreadyAskedFor.end()) mapAlreadyAskedFor.update(it, nRequestTime); else mapAlreadyAskedFor.insert(std::make_pair(inv, nRequestTime)); mapAskFor.insert(std::make_pair(nRequestTime, inv)); } void CNode::BeginMessage(const char* pszCommand) EXCLUSIVE_LOCK_FUNCTION(cs_vSend) { ENTER_CRITICAL_SECTION(cs_vSend); assert(ssSend.size() == 0); ssSend << CMessageHeader(pszCommand, 0); LogPrint("net", "sending: %s ", SanitizeString(pszCommand)); } void CNode::AbortMessage() UNLOCK_FUNCTION(cs_vSend) { ssSend.clear(); LEAVE_CRITICAL_SECTION(cs_vSend); LogPrint("net", "(aborted)\n"); } void CNode::EndMessage() UNLOCK_FUNCTION(cs_vSend) { // The -*messagestest options are intentionally not documented in the help message, // since they are only used during development to debug the networking code and are // not intended for end-users. if (mapArgs.count("-dropmessagestest") && GetRand(GetArg("-dropmessagestest", 2)) == 0) { LogPrint("net", "dropmessages DROPPING SEND MESSAGE\n"); AbortMessage(); return; } if (mapArgs.count("-fuzzmessagestest")) Fuzz(GetArg("-fuzzmessagestest", 10)); if (ssSend.size() == 0) { LEAVE_CRITICAL_SECTION(cs_vSend); return; } // Set the size unsigned int nSize = ssSend.size() - CMessageHeader::HEADER_SIZE; memcpy((char*)&ssSend[CMessageHeader::MESSAGE_SIZE_OFFSET], &nSize, sizeof(nSize)); // Set the checksum uint256 hash = Hash(ssSend.begin() + CMessageHeader::HEADER_SIZE, ssSend.end()); unsigned int nChecksum = 0; memcpy(&nChecksum, &hash, sizeof(nChecksum)); assert(ssSend.size() >= CMessageHeader::CHECKSUM_OFFSET + sizeof(nChecksum)); memcpy((char*)&ssSend[CMessageHeader::CHECKSUM_OFFSET], &nChecksum, sizeof(nChecksum)); LogPrint("net", "(%d bytes) peer=%d\n", nSize, id); std::deque<CSerializeData>::iterator it = vSendMsg.insert(vSendMsg.end(), CSerializeData()); ssSend.GetAndClear(*it); nSendSize += (*it).size(); // If write queue empty, attempt "optimistic write" if (it == vSendMsg.begin()) SocketSendData(this); LEAVE_CRITICAL_SECTION(cs_vSend); } // // CBanDB // CBanDB::CBanDB() { pathBanlist = GetDataDir() / "banlist.dat"; } bool CBanDB::Write(const banmap_t& banSet) { // Generate random temporary filename unsigned short randv = 0; GetRandBytes((unsigned char*)&randv, sizeof(randv)); std::string tmpfn = strprintf("banlist.dat.%04x", randv); // serialize banlist, checksum data up to that point, then append csum CDataStream ssBanlist(SER_DISK, CLIENT_VERSION); ssBanlist << FLATDATA(Params().MessageStart()); ssBanlist << banSet; uint256 hash = Hash(ssBanlist.begin(), ssBanlist.end()); ssBanlist << hash; // open temp output file, and associate with CAutoFile boost::filesystem::path pathTmp = GetDataDir() / tmpfn; FILE *file = fopen(pathTmp.string().c_str(), "wb"); CAutoFile fileout(file, SER_DISK, CLIENT_VERSION); if (fileout.IsNull()) return error("%s: Failed to open file %s", __func__, pathTmp.string()); // Write and commit header, data try { fileout << ssBanlist; } catch (const std::exception& e) { return error("%s: Serialize or I/O error - %s", __func__, e.what()); } FileCommit(fileout.Get()); fileout.fclose(); // replace existing banlist.dat, if any, with new banlist.dat.XXXX if (!RenameOver(pathTmp, pathBanlist)) return error("%s: Rename-into-place failed", __func__); return true; } bool CBanDB::Read(banmap_t& banSet) { // open input file, and associate with CAutoFile FILE *file = fopen(pathBanlist.string().c_str(), "rb"); CAutoFile filein(file, SER_DISK, CLIENT_VERSION); if (filein.IsNull()) return error("%s: Failed to open file %s", __func__, pathBanlist.string()); // use file size to size memory buffer uint64_t fileSize = boost::filesystem::file_size(pathBanlist); uint64_t dataSize = 0; // Don't try to resize to a negative number if file is small if (fileSize >= sizeof(uint256)) dataSize = fileSize - sizeof(uint256); vector<unsigned char> vchData; vchData.resize(dataSize); uint256 hashIn; // read data and checksum from file try { filein.read((char *)&vchData[0], dataSize); filein >> hashIn; } catch (const std::exception& e) { return error("%s: Deserialize or I/O error - %s", __func__, e.what()); } filein.fclose(); CDataStream ssBanlist(vchData, SER_DISK, CLIENT_VERSION); // verify stored checksum matches input data uint256 hashTmp = Hash(ssBanlist.begin(), ssBanlist.end()); if (hashIn != hashTmp) return error("%s: Checksum mismatch, data corrupted", __func__); unsigned char pchMsgTmp[4]; try { // de-serialize file header (network specific magic number) and .. ssBanlist >> FLATDATA(pchMsgTmp); // ... verify the network matches ours if (memcmp(pchMsgTmp, Params().MessageStart(), sizeof(pchMsgTmp))) return error("%s: Invalid network magic number", __func__); // de-serialize address data into one CAddrMan object ssBanlist >> banSet; } catch (const std::exception& e) { return error("%s: Deserialize or I/O error - %s", __func__, e.what()); } return true; } void DumpBanlist() { CNode::SweepBanned(); // clean unused entries (if bantime has expired) if (!CNode::BannedSetIsDirty()) return; int64_t nStart = GetTimeMillis(); CBanDB bandb; banmap_t banmap; CNode::GetBanned(banmap); if (bandb.Write(banmap)) { CNode::SetBannedSetDirty(false); } LogPrint("net", "Flushed %d banned node ips/subnets to banlist.dat %dms\n", banmap.size(), GetTimeMillis() - nStart); }
[ "info@daud.app" ]
info@daud.app
a805c1224a4f5023d995d8283b10b276e2618d40
bfd8873270d82642346babc7228639c2c54d7d61
/CSKFtracer/FMM3D_linux/mexBBFMM3D/BBFMM3D/src/H2_3D_Tree.cpp
a31fccf6d9b3dcddb01eb8b302be8fa15ef33236
[ "MIT" ]
permissive
amaliak/CSKS_Tracer
e531352fbb26674e9e091b36c5de9238e7b0adec
91011a7b51dca4218dec720851798ffabd83cd14
refs/heads/master
2021-01-18T05:08:01.915512
2015-05-04T02:59:55
2015-05-04T02:59:55
35,009,445
0
0
null
null
null
null
UTF-8
C++
false
false
36,927
cpp
/*! \file H2_3D_Tree.cpp */ #include"H2_3D_Tree.hpp" #include"bbfmm.h" #include"rfftw.h" H2_3D_Tree::H2_3D_Tree(doft *dof, double L, int level, int n, double epsilon, int use_chebyshev){ this->dof = dof; this->L = L; this->level = level; this->n = n; this->epsilon = epsilon; this->use_chebyshev = use_chebyshev; alpha = 0; n2 = n*n; // n2 = n^2 n3 = n2*n; // n3 = n^3 dofn3_s = dof->s * n3; dofn3_f = dof->f * n3; // Omega matrix Kweights = (double *)malloc(n3 * sizeof(double)); // Chebyshev interpolation coefficients: Sn (page 8715) Cweights = (double *)malloc(2 * n2 * sizeof(double)); Tkz = (double *)malloc(n2 * sizeof(double)); K = NULL; U = NULL; VT = NULL; tree = NULL; skipLevel = 0; computed = false; int fftSize = (int)round(pow(2*n-1, 3)); p_r2c = rfftw_create_plan(fftSize, FFTW_REAL_TO_COMPLEX, FFTW_ESTIMATE); p_c2r = rfftw_create_plan(fftSize, FFTW_COMPLEX_TO_REAL, FFTW_ESTIMATE); } void H2_3D_Tree::buildFMMTree() { FMMSetup(&tree,Tkz,Kweights,Cweights,L,&cutoff, n,epsilon,dof,level,Kmat, Umat,Vmat,&Ucomp,&Vcomp, skipLevel, alpha, use_chebyshev, p_r2c); int preCompLevel = (level-2)* (!homogen) + 1; int Ksize = cutoff.f * (316*cutoff.s)* preCompLevel; // Change: set cutoff int Usize = cutoff.f * dof->f *n*n*n* preCompLevel; int Vsize = cutoff.s * dof->s *n*n*n* preCompLevel; K = (double *)malloc(Ksize *sizeof(double)); U = (double *)malloc(Usize *sizeof(double)); VT = (double *)malloc(Vsize *sizeof(double)); FMMReadMatrices(K,U,VT,&cutoff,n,dof,Kmat,Umat,Vmat, level, homogen, skipLevel, use_chebyshev); } /* * Function: FMMSetup * ----------------------------------------------------------------- * Prepare for the FMM calculation by setting the parameters, computing * the weight matrices, pre-computing the SVD (if necessary), reading * in the necessary matrices, and building the FMM hierarchy. */ void H2_3D_Tree::FMMSetup(nodeT **A, double *Tkz, double *Kweights, double *Cweights, double boxLen, doft *cutoff, int n, double epsilon, doft * dof, int treeLevel, char *Kmat, char *Umat, char *Vmat, double *Ucomp, double *Vcomp,int& skipLevel, double alpha, int use_chebyshev, rfftw_plan p_r2c) { vector3 center; setHomogen(kernelType); homogen = -homogen; if (use_chebyshev) { sprintf(Kmat,"./BBFMM3D/output/%sCK%d.bin",kernelType.c_str(),n); sprintf(Umat,"./BBFMM3D/output/%sCU%d.bin",kernelType.c_str(),n); sprintf(Vmat,"./BBFMM3D/output/%sCV%d.bin",kernelType.c_str(),n); } else { sprintf(Kmat,"./BBFMM3D/output/%sUK%d.bin",kernelType.c_str(),n); sprintf(Umat,"./BBFMM3D/output/%sUU%d.bin",kernelType.c_str(),n); sprintf(Vmat,"./BBFMM3D/output/%sUV%d.bin",kernelType.c_str(),n); } // Compute the Chebyshev weights and sets up the lookup table ComputeWeights(Tkz,Ktable,Kweights,Cweights,n,alpha,use_chebyshev); //?????? // Precompute the SVD of the kernel interaction matrix (if // necessary) if (use_chebyshev) { int i; FILE *fK, *fU, *fV; fK = fopen(Kmat, "rb"); fU = fopen(Umat, "rb"); fV = fopen(Vmat, "rb"); if (fK == NULL || fU == NULL || fV == NULL) { // Create files if (fK!=NULL) fclose(fK); if (fU!=NULL) fclose(fU); if (fV!=NULL) fclose(fV); printf("Pre-Compute files do not exit. Creating now ...\n"); if (homogen > 1e-9) { // homogeneous kernel ComputeKernelSVD(Kweights, n, epsilon, dof, Kmat, Umat, Vmat, symmetry, Ucomp, Vcomp,alpha, 1); } else { // non-homogeneous kernel // Open new files for writing boxLen and treeLevel fK = fopen(Kmat, "wb"); fwrite(&boxLen, sizeof(double), 1, fK); fwrite(&treeLevel, sizeof(int), 1, fK); fclose(fK); double boxLenLevel = boxLen/4; // first FMM level for (i=2; i<=treeLevel; i++, boxLenLevel/=2) // FMM starts from the second level ComputeKernelSVD(Kweights, n, epsilon, dof, Kmat, Umat, Vmat, symmetry, Ucomp, Vcomp,alpha, boxLenLevel); } } //non-homogen else if (homogen < 1e-9) { // check if the file is usable fK = fopen(Kmat, "rb"); double fileBoxLen; int fileTreeLevel; i = fread(&fileBoxLen, sizeof(double), 1, fK); i += fread(&fileTreeLevel, sizeof(int), 1, fK); if (i != 2) printf("fread error in FMMSetup().\n"); int count = 0; while (fileBoxLen > boxLen +1e-9) { fileBoxLen /= 2; count ++; } if (fabs(boxLen-fileBoxLen) < 1e-9 && treeLevel + count <= fileTreeLevel) { skipLevel = count; // count * Ksize printf("Reading pre-compute files ...\n"); } else { // Recreate the files printf("Recreating pre-compute files now ...\n"); fK = fopen(Kmat, "wb"); fwrite(&boxLen, sizeof(double), 1, fK); fwrite(&treeLevel, sizeof(int), 1, fK); fclose(fK); int i; double boxLenLevel = boxLen/4; // first FMM level for (i=2; i<=treeLevel; i++, boxLenLevel/=2) // FMM starts from the second level ComputeKernelSVD(Kweights, n, epsilon, dof, Kmat, Umat, Vmat, symmetry, Ucomp, Vcomp,alpha, boxLenLevel); } } else printf("Reading pre-compute files ...\n"); fU = fopen(Umat,"rb"); int j = fread(&(cutoff->f), sizeof(int), 1, fU); fclose(fU); fV = fopen(Vmat,"rb"); j += fread(&(cutoff->s), sizeof(int), 1, fV); fclose(fV); if (j != 2) printf("fread() error in FMMSetup().\n"); } else { // uniform FILE *f; if ((f=fopen(Kmat,"rb")) == NULL) { ComputeKernelUniformGrid(Kweights,n,dof,Kmat,alpha, p_r2c); } cutoff->f = dof->f*n*n*n; cutoff->s = dof->s*n*n*n; } // Builds the FMM hierarchy center.x = 0; center.y = 0; center.z = 0; (*A) = NULL; NewNode(A,center,L,n); BuildFMMHierarchy(A,treeLevel,n,cutoff,dof); } /* * Function: FMMReadMatrices * ------------------------------------------------------------------ * Read in the kernel interaction matrix M and the matrix of singular * vectors U. */ void H2_3D_Tree::FMMReadMatrices(double *K, double *U, double *VT, doft *cutoff, int n, doft *dof,char *Kmat, char *Umat, char *Vmat, int treeLevel, double homogen, int skipLevel, int use_chebyshev) { int i = 0; FILE *ptr_file; int preCompLevel = (treeLevel-2)* (!homogen) + 1; int Ksize; if(use_chebyshev) Ksize = cutoff->f * (316*cutoff->s); // Change: set cutoff else Ksize = 316*(2*n-1)*(2*n-1)*(2*n-1)*dof->s*dof->f; int Usize = cutoff->f * dof->f *n*n*n; int Vsize = cutoff->s * dof->s *n*n*n; // Read in kernel interaction matrix K ptr_file = fopen(Kmat,"rb"); fseek(ptr_file, (1*sizeof(int) + 1*sizeof(double)) *(!homogen) + Ksize *skipLevel *sizeof(double), SEEK_SET); i += fread(K, sizeof(double), Ksize *preCompLevel, ptr_file); fclose(ptr_file); if (use_chebyshev) { // Read in matrix of singular vectors U ptr_file = fopen(Umat,"rb"); fseek(ptr_file, 1*sizeof(int) + Usize *skipLevel *sizeof(double), SEEK_SET); i += fread(U, sizeof(double), Usize *preCompLevel, ptr_file); fclose(ptr_file); // Read in matrix of singular vectors VT ptr_file = fopen(Vmat,"rb"); fseek(ptr_file, 1*sizeof(int) + Vsize *skipLevel *sizeof(double), SEEK_SET); i += fread(VT, sizeof(double), Vsize *preCompLevel, ptr_file); fclose(ptr_file); int totleNum = (Ksize + Usize + Vsize) *preCompLevel; if (i != totleNum) printf("fread error in FMMReadMatrices!\n Expected numer:%d," "numbers read: %d\n", totleNum, i); } else { int totleNum = Ksize *preCompLevel; if (i != totleNum) printf("fread error in FMMReadMatrices!\n Expected numer:%d," "numbers read: %d\n", totleNum, i); } } /* * Function: ComputeKernelSVD * --------------------------------------------------------------------- * Computes the kernel for 316n^6 interactions between Chebyshev nodes * and then computes the SVD of the kernel matrix. * symmetry = 0 no symmetric property, 1 symmetric kernel or -1 anti- * symmetric kernel */ void H2_3D_Tree::ComputeKernelSVD(double *Kweights, int n,double epsilon, doft *dof, char*Kmat, char *Umat, char *Vmat, int symm, double *Ucomp,double *Vcomp, double alphaAdjust, double boxLen) { static int callTime = -1; callTime += 1; // callTime = 0 for the first time called int i, j, l, m, m1, k1, k2, k3, l1, l2, l3, z; int count, count1, count2, count3; vector3 scenter, vtmp; double sweight, fweight; double pi = M_PI; int n3 = n*n*n; // n3 = n^3 int dofn3_s = dof->s * n3; int dofn3_f = dof->f * n3; int dof2n6 = dofn3_s * dofn3_f; // Total size int Sigma_size; doft cutoff; double *K0, *U0, *Sigma, *VT0; double *nodes, *kernel, *work; vector3 *fieldpos, *sourcepos; K0 = (double *)malloc(316 * dof2n6 * sizeof(double)); kernel = (double *)malloc(dof2n6 * sizeof(double)); fieldpos = (vector3 *)malloc(n3 * sizeof(vector3)); sourcepos = (vector3 *)malloc(n3 * sizeof(vector3)); // 316 M2L operators double* Kcell[316]; for (z = 0; z < 316; ++z) Kcell[z] = (double *) malloc(dof2n6 * sizeof(double)); // Compute Chebyshev nodes of T_n(x) double scale = 1+alphaAdjust; nodes = (double *)malloc(n * sizeof(double)); for (m=0;m<n;m++) nodes[m] = cos(pi*((double)m+0.5)/(double)n) * scale; // Compute the locations of the field points in a unit cube count = 0; for (l1=0;l1<n;l1++) { vtmp.x = 0.5 * nodes[l1] * boxLen; for (l2=0;l2<n;l2++) { vtmp.y = 0.5 * nodes[l2] * boxLen; for (l3=0;l3<n;l3++) { fieldpos[count].x = vtmp.x; fieldpos[count].y = vtmp.y; fieldpos[count].z = 0.5 * nodes[l3] * boxLen; count++; } } } // Compute the kernel values for interactions with all 316 cells int countM2L=0; int symmNum = 158*(2-abs(symm)); // symmNum = 158, 316 for symm=pm1, 0 int col, row, idx1, idx2; for (count=0, k1=-3;k1<4;k1++) { scenter.x = (double)k1; for (k2=-3;k2<4;k2++) { scenter.y = (double)k2; for (k3=-3;k3<4;k3++) { scenter.z = (double)k3; if (abs(k1) > 1 || abs(k2) > 1 || abs(k3) > 1) { if (countM2L < symmNum) { // Compute the locations of the source points in the cell for (count1=0, l1=0;l1<n;l1++) { vtmp.x = (scenter.x + 0.5 * nodes[l1]) * boxLen; for (l2=0;l2<n;l2++) { vtmp.y = (scenter.y + 0.5 * nodes[l2]) * boxLen; for (l3=0; l3<n; l3++, count1++) { sourcepos[count1].x = vtmp.x; sourcepos[count1].y = vtmp.y; sourcepos[count1].z = (scenter.z + 0.5 * nodes[l3]) * boxLen; } } } // Compute the kernel at each of the field Chebyshev nodes EvaluateKernelCell(fieldpos, sourcepos, n3, n3, dof, kernel); // Copy the kernel values to the appropriate location for (count1=0, count2=0, l1=0; l1<n3; l1++, count2++) { sweight = Kweights[count2]; for (l=0;l<dof->s;l++) { for (count3=0, m1=0; m1<n3; m1++, count3++) { fweight = Kweights[count3]; for (m=0; m<dof->f; m++, count++, count1++) { K0[count] = kernel[count1] /(sweight*fweight); } } } } countM2L++; } else { // Use kernel symmetry for (col=0; col<dofn3_s; col++) for (row=0; row<dofn3_f; row++) { idx1 = (315-countM2L)*dof2n6 + col*dofn3_f + row; idx2 = countM2L*dof2n6 + (row/dof->f*dof->s + col%dof->s) *dofn3_f + (col/dof->s*dof->f + row%dof->f); // symm=-1,1 for anti-symmetry and symmetry K0[idx2] = symm * K0[idx1]; //K0[idx2] = K0[idx1]; } countM2L++; } } } } } // Extract the submatrix for each of the 316 cells count = 0; for (i=0;i<316;i++) { for (j=0;j<dof2n6;j++) { Kcell[i][j] = K0[count]; count++; } } /**** * Compute the SVD of K_fat ****/ // Compute the SVD of K0 char save[]="S", nosave[]="N"; int nosavedim=1; int info, lwork; int cols_s = 316*dofn3_s; /* See dgesvd documentation: * LWORK >= MAX(1,5*MIN(M,N)) for the paths (see comments inside code): * - PATH 1 (M much larger than N, JOBU='N') - our case for K_thin * - PATH 1t (N much larger than M, JOBVT='N') - our case for K_fat */ int max_dof = dof->s > dof->f ? dof->s : dof->f; lwork = 5*max_dof*n3; // Change work = (double *) malloc(lwork * sizeof(double)); int U0size; Sigma_size = dofn3_f; U0size = dofn3_f * dofn3_f; Sigma = (double *)malloc(Sigma_size * sizeof(double)); U0 = (double *)malloc(U0size * sizeof(double)); VT0 = NULL; dgesvd_(save, nosave, &dofn3_f, &cols_s, K0, &dofn3_f, Sigma, U0, &dofn3_f, VT0, &nosavedim, work, &lwork, &info); FILE *ptr_file; double sumsqr, sum, epsqr; if (callTime == 0) { // The first time called // Determine the number of singular values to keep. We use epsilon for this. sumsqr = 0; for (i=Sigma_size-1; i>=0; --i) sumsqr += Sigma[i] * Sigma[i]; sum = 0, epsqr = sumsqr * epsilon * epsilon; cutoff.f = Sigma_size; for (i=Sigma_size-1; i>=0; --i) { sum += Sigma[i] * Sigma[i]; if (sum < epsqr) --cutoff.f; else break; } // Extract the needed columns from U0 and write out to a file ptr_file = fopen(Umat,"wb"); fwrite(&cutoff.f, sizeof(int), 1, ptr_file); fclose(ptr_file); } else { ptr_file = fopen(Umat, "rb"); if (ptr_file == NULL) printf("Can't read cutoff.f!\n"); i = fread(&cutoff.f, sizeof(int), 1, ptr_file); if (i != 1) printf("fread error in ComputeKernelSVD().\n"); fclose(ptr_file); } *Ucomp = ((double)cutoff.f)/Sigma_size; double trancatedSize = dofn3_f * cutoff.f; ptr_file = fopen(Umat, "ab"); fwrite(U0, sizeof(double), trancatedSize, ptr_file); fclose(ptr_file); free(Sigma); Sigma = NULL; /**** * Compute the SVD of K_thin ****/ // Form K_thin using all of 316 M2L operators stored in Kcell count = 0; for (j=0;j<dofn3_s;++j) { for (i=0;i<316;i++) { for (l=0;l<dofn3_f;l++) { K0[count] = Kcell[i][l+j*dofn3_f]; count++; } } } // save = "S"; nosave = "N" double *U1 = NULL; int rows_f = 316*dofn3_f; Sigma_size = dofn3_s; Sigma = (double *)malloc(Sigma_size * sizeof(double)); VT0 = (double *)malloc(dofn3_s * dofn3_s * sizeof(double)); // Compute the SVD of the K_thin dgesvd_(nosave,save,&rows_f,&dofn3_s,K0,&rows_f,Sigma,U1,&nosavedim,VT0,&dofn3_s, work,&lwork,&info); if (callTime == 0) { // Determine the number of singular values to keep. We use // epsilon for this. sumsqr = 0; for (i=Sigma_size-1; i>=0; --i) sumsqr += Sigma[i] * Sigma[i]; sum = 0, epsqr = sumsqr * epsilon * epsilon; cutoff.s = Sigma_size; for (i=Sigma_size-1; i>=0; --i) { sum += Sigma[i] * Sigma[i]; if (sum < epsqr) --cutoff.s; else break; } // Extract trancated VT[cutoff.s][dofn3_s] from // VT0[dofn3_s][dofn3_s] and write out to a file ptr_file = fopen(Vmat,"wb"); fwrite(&cutoff.s, sizeof(int), 1, ptr_file); fclose(ptr_file); } else { ptr_file = fopen(Vmat, "rb"); if (ptr_file == NULL) printf("Can't read cutoff.s!\n"); i = fread(&cutoff.s, sizeof(int), 1, ptr_file); if (i != 1) printf("fread error in ComputeKernelSVD().\n"); fclose(ptr_file); } *Vcomp = ((double)cutoff.s)/Sigma_size; ptr_file = fopen(Vmat, "ab"); for (j=0;j<dofn3_s;j++) { // column count1 = j*dofn3_s; fwrite(VT0+count1, sizeof(double), cutoff.s, ptr_file); } fclose(ptr_file); /** Computing the compressed kernel using the orthonormal basis U and VT. **/ char *transa, *transb; transa = new char[2]; transb = new char[2]; int cutoff2 = cutoff.f * cutoff.s; double alpha=1, beta=0; double *Ecell, *KV; Ecell = (double *)malloc(cutoff2 * sizeof(double)); KV = (double *)malloc(dofn3_f * cutoff.s * sizeof(double)); ptr_file = fopen(Kmat,"ab"); for (i=0;i<316;i++) { /* Compute K V: * K is dofn3_f x dofn3_s * VT is cutoff.s x dofn3_s * V is dofn3_s x cutoff.s * KV is dofn3_f x cutoff.s * (Notice that VT is a submatrix of VT0) */ transa[0] = 'n'; transb[0] = 't'; dgemm_(transa, transb, &dofn3_f, &cutoff.s, &dofn3_s, &alpha, Kcell[i], &dofn3_f, VT0, &dofn3_s, &beta, KV, &dofn3_f); /* Compute U^T K V: * KV is dofn3_f x cutoff.s * U is dofn3_f x cutoff.f * UT is cutoff.f x dofn3_f * U^T K V is cutoff.f x cutoff.s * (Notice that U is a submatrix of U0) */ transa[0] = 't'; transb[0] = 'n'; dgemm_(transa, transb, &cutoff.f, &cutoff.s, &dofn3_f, &alpha, U0, &dofn3_f, KV, &dofn3_f, &beta, Ecell, &cutoff.f); fwrite(Ecell, sizeof(double), cutoff2, ptr_file); } fclose(ptr_file); free(K0); free(VT0); free(U0); free(Sigma); free(nodes); free(kernel); free(fieldpos); free(sourcepos); free(work); free(KV); free(Ecell); delete []transa; delete []transb; for (z = 0; z < 316; ++z) free(Kcell[z]); } /* * Function: ComputeKernelUniformGrid * ------------------------------------------------------------------ * Computes the kernel for 316(2n-1)^3 interactions between Uniform * Grid nodes. Does not compute SVD. */ void H2_3D_Tree::ComputeKernelUniformGrid(double *Kweights, int n, doft *dof, char *Kmat, double alphaAdjust, rfftw_plan p_r2c) { /* TODO: multi-dof, alphaAdjust */ int i, k1, k2, k3, l1, l2, l3; vector3 scenter; int dof2 = dof->s * dof->f; //int dof2n6 = dof2 * (2*n-1)*(2*n-1)*(2*n-1); // Total size double nodes[n], kernel[dof2]; vector3 fieldpos, sourcepos; // Compute Chebyshev nodes of T_n(x) //double scale = 1+alphaAdjust; CalculateNodeLocations(n,nodes,0); // creat FFT plan int vecSize = 2*n-1, reducedMatSize = pow(vecSize, 3); int M2LSize = dof2 *reducedMatSize; double *MatM2L = (double*)malloc(M2LSize *sizeof(double)); double *freqMat = (double*)malloc(316 *M2LSize *sizeof(double)); // Compute the kernel values for interactions with all 316 cells int countM2L=0, count, count1; int shift1, shift2, shiftGlo, shiftLoc; int reducedMatSizeDofs = reducedMatSize *dof->s; int f, s; for (k1=-3;k1<4;k1++) { scenter.x = (double)k1; for (k2=-3;k2<4;k2++) { scenter.y = (double)k2; for (k3=-3;k3<4;k3++) { scenter.z = (double)k3; if (abs(k1) > 1 || abs(k2) > 1 || abs(k3) > 1) { for (count=0, l1=0; l1<vecSize; l1++) { GetPosition(n, l1, &fieldpos.x, &sourcepos.x, nodes); sourcepos.x += scenter.x; for (l2=0; l2<vecSize; l2++) { GetPosition(n, l2, &fieldpos.y, &sourcepos.y, nodes); sourcepos.y += scenter.y; for (l3=0; l3<vecSize; l3++, count++) { GetPosition(n, l3, &fieldpos.z, &sourcepos.z, nodes); sourcepos.z += scenter.z; EvaluateKernel(fieldpos,sourcepos,kernel,dof); // kernel[f x s] in column major // MatM2L[(2n-1)^3 x s x f] in column // major count1 = 0; shift1 = count; for (s=0; s < dof->s; s++) { for(f=0, shift2=0; f < dof->f; f++) { MatM2L[shift1 + shift2] = kernel[count1++]; shift2 += reducedMatSizeDofs; } shift1 += reducedMatSize; } } } } // FFT shiftGlo = countM2L *M2LSize; for (i=0, shiftLoc=0; i<dof2; i++) { rfftw_one(p_r2c, MatM2L + shiftLoc, freqMat + shiftGlo + shiftLoc); shiftLoc += reducedMatSize; } countM2L++; } } } } FILE *ptr_file; ptr_file = fopen(Kmat, "wb"); fwrite(freqMat, sizeof(double),316 *M2LSize, ptr_file); fclose(ptr_file); free(MatM2L); free(freqMat); } void H2_3D_Tree::CalculateNodeLocations(int n, double* nodes, int use_chebyshev) { int m; double pi = M_PI; if(use_chebyshev) { for (m=0; m<n; m++) nodes[m] = cos(pi*((double)m+0.5)/(double)n); } else { for (m=0; m<n; m++) nodes[m] = 1 - 2*(double)m/((double)(n-1)); } } /* * Given n node positions and returns corresponding field and source * positions with respect to the index */ void H2_3D_Tree::GetPosition(int n, int idx, double *fieldpos, double *sourcepos, double *nodepos) { if (idx < n) { *fieldpos = nodepos[n-1]/2; *sourcepos = nodepos[idx]/2; } else { *fieldpos = nodepos[2*(n-1)-idx]/2; *sourcepos = nodepos[n-1]/2; } } /* * Function: EvaluateKernelCell * ------------------------------------------------------------------- * Evaluates the kernel for interactions between a pair of cells. * M2L operator initialization */ void H2_3D_Tree::EvaluateKernelCell(vector3 *field, vector3 *source, int Nf, int Ns, doft *dof, double *kernel) { int i, j, k, l, count, count_kernel; int dof_f = dof->f; int dof_s = dof->s; int dofNf = dof->f * Nf; int dof2 = dof->f * dof->s; double * Kij; int LDA_kernel = dofNf; Kij = (double*) malloc(dof2 * sizeof(double)); for (j=0;j<Ns;j++) { for (i=0;i<Nf;i++) { EvaluateKernel(field[i],source[j],Kij, dof); count_kernel = dof_f * i + LDA_kernel * dof_s * j; count = 0; for (k=0;k<dof_s;k++) for (l=0;l<dof_f;l++, count++) /* Column-major storage */ kernel[count_kernel + k * LDA_kernel + l] = Kij[count]; } } free(Kij); } /* * Function: ComputeWeights * ------------------------------------------------------------------ * Computes the weights for the Chebyshev nodes of all children cells * (identical for all cells and all levels so just compute once and * store in memory) and set up the lookup table. */ void H2_3D_Tree::ComputeWeights(double *Tkz, int *Ktable, double *Kweights, double *Cweights, int n, double alpha, int use_chebyshev) { int i, k, m, l1, l2, l3, count, ncell, ninteract; double tmp1, tmp2; vector3 vtmp; double *nodes, *vec; vector3 *fieldt, *Sn; nodes = (double *)malloc(n * sizeof(double)); vec = (double *)malloc(n * sizeof(double)); int n3 = n*n*n; // n3 = n^3 int Nc = 2*n3; // Number of child Chebyshev nodes fieldt = (vector3 *)malloc(Nc * sizeof(vector3)); // Chebyshev-transformed coordinates Sn = (vector3 *)malloc(n * Nc * sizeof(vector3)); //double pi = M_PI; // Initialize lookup table for (i=0;i<343;i++) Ktable[i] = -1; // Create lookup table ncell = 0; ninteract = 0; for (l1=-3;l1<4;l1++) { for (l2=-3;l2<4;l2++) { for (l3=-3;l3<4;l3++) { if (abs(l1) > 1 || abs(l2) > 1 || abs(l3) > 1) { Ktable[ncell] = ninteract; ninteract++; } ncell++; } } } // Compute the n Chebyshev nodes of T_n(x) // for (m=0; m<n; m++) // nodes[m] = cos(pi*((double)m+0.5)/(double)n); // Compute n Chebyshev nodes in [-.5, .5] CalculateNodeLocations(n,nodes,use_chebyshev); // Evaluate the Chebyshev polynomials of degree 0 to n-1 at the nodes for (m=0; m<n; m++) { ComputeTk(nodes[m],n,vec); i = m*n; for (k=0;k<n;k++) { Tkz[i+k] = vec[k]; } } if (use_chebyshev) { // Compute the weights for the kernel matrix K count = 0; for (l1=0;l1<n;l1++) { tmp1 = 1./sqrt(1-nodes[l1]*nodes[l1]); for (l2=0;l2<n;l2++) { tmp2 = tmp1/sqrt(1-nodes[l2]*nodes[l2]); for(l3=0;l3<n;l3++) { Kweights[count] = tmp2/sqrt(1-nodes[l3]*nodes[l3]); count++; } } } } else { // Compute the weights for the kernel matrix K count = 0; for (l1=0;l1<n;l1++) { tmp1 = 1./sqrt(1-nodes[l1]*nodes[l1]); for (l2=0;l2<n;l2++) { tmp2 = tmp1/sqrt(1-nodes[l2]*nodes[l2]); for(l3=0;l3<n;l3++) { Kweights[count] = 1; //tmp2/sqrt(1-nodes[l3]*nodes[l3]); count++; } } } } // Map all Chebyshev nodes from the children cells to the parent k = 0; double scale = 1 / (1+alpha); //scale = 1; for (i=0;i<2;i++) { // Determine the mapping function for the specific child cell vtmp.x = -0.5; vtmp.y = -0.5; if (i == 0) vtmp.z = -0.5; else vtmp.z = 0.5; for (l1=0;l1<n;l1++) { for (l2=0;l2<n;l2++) { for (l3=0;l3<n;l3++) { fieldt[k].x = nodes[l1] * .5 + vtmp.x * scale; fieldt[k].y = nodes[l2] * .5 + vtmp.y * scale; fieldt[k].z = nodes[l3] * .5 + vtmp.z * scale; k++; } } } } // Compute Sc, the mapping function for the field points ComputeSn(fieldt,Tkz,n,Nc,Sn, use_chebyshev); // Extract out the Chebyshev weights count = 0; for (l1=0;l1<n;l1++) { k = l1*Nc; for (l2=0;l2<n;l2++) { Cweights[count] = Sn[k+l2].z; count++; } } for (l1=0;l1<n;l1++) { k = l1*Nc; for (l2=0;l2<n;l2++) { Cweights[count] = Sn[k+n3+l2].z; count++; } } free(nodes); free(vec); free(fieldt); free(Sn); } /* * Function: ComputeSn * ------------------------------------------------------------------ * Computes S_n(x_m,x_i) for all Chebyshev node-point pairs using * Clenshaw's recurrence relation. * Sn(xm, xi) = -1/2 + sum_0^(n-1) Tk(xm) Tk(xi) * Notice there is another prefactor = 2/n that will be applied later */ void H2_3D_Tree::ComputeSn(vector3 *point, double *Tkz, int n, int N, vector3 *Sn, int use_chebyshev) { int i, j, k, m; double vec[n], d[n+2], x, num, denom; if(use_chebyshev) { for (m=0;m<n;m++) { // Extract T_k for the Chebyshev node x_m k = m*n; for (j=0;j<n;j++) vec[j] = Tkz[k+j]; // Compute S_n for each direction independently using Clenshaw k = m*N; for (i=0;i<N;i++) { x = point[i].x; d[n] = d[n+1] = 0.; for (j=n-1;j>0;j--) d[j] = 2.0*x*d[j+1] - d[j+2] + vec[j]; Sn[k+i].x = x*d[1] - d[2] + 0.5*vec[0]; x = point[i].y; d[n] = d[n+1] = 0.; for (j=n-1;j>0;j--) d[j] = 2.0*x*d[j+1] - d[j+2] + vec[j]; Sn[k+i].y = x*d[1] - d[2] + 0.5*vec[0]; x = point[i].z; d[n] = d[n+1] = 0.; for (j=n-1;j>0;j--) d[j] = 2.0*x*d[j+1] - d[j+2] + vec[j]; Sn[k+i].z = x*d[1] - d[2] + 0.5*vec[0]; } } } else { for (m=0;m<n;m++) { k = m*N; for (i=0;i<N;i++) { x = point[i].x; num = 1.; denom = 1.; for (j=0;j<n;j++) { if(m!=j) { num *= x - (1-2*(double)j/(double)(n-1)); denom *= 2*((double)m-(double)j)/(double)(n-1); } } Sn[k+i].x = num/denom; x = point[i].y; num = 1.; denom = 1.; for (j=0;j<n;j++) { if(m!=j) { num *= x - (1-2*(double)j/(double)(n-1)); denom *= 2*((double)m-(double)j)/(double)(n-1); } } Sn[k+i].y = num/denom; x = point[i].z; num = 1.; denom = 1.; for (j=0;j<n;j++) { if(m!=j) { num *= x - (1-2*(double)j/(double)(n-1)); denom *= 2*((double)m-(double)j)/(double)(n-1); } } Sn[k+i].z = num/denom; } } } } /* * Function: ComputeTk * ------------------------------------------------------------------ * Computes T_k(x) for k between 0 and n-1 inclusive. */ void H2_3D_Tree::ComputeTk(double x, int n, double *vec) { int k; vec[0] = 1; vec[1] = x; for (k=2;k<n;k++) vec[k] = 2.0*x*vec[k-1] - vec[k-2]; } /* * Function: BuildFMMHierarchy * ------------------------------------------------------------------ * Builds the FMM hierarchy with l levels. * */ void H2_3D_Tree::BuildFMMHierarchy(nodeT **A, int level, int n, doft *cutoff, doft *dof) { int i; double L, halfL, quarterL; vector3 center, left, right; if (level > 0) { // Compute the length and center coordinate of the children cells L = (*A)->length; halfL = 0.5*L; quarterL = 0.25*L; center = (*A)->center; left.x = center.x - quarterL; left.y = center.y - quarterL; left.z = center.z - quarterL; right.x = center.x + quarterL; right.y = center.y + quarterL; right.z = center.z + quarterL; // Add children nodes to node A for (i=0;i<8;i++) { // Determine the center of the child cell if (i<4) { center.x = left.x; if (i<2) center.y = left.y; else center.y = right.y; } else { center.x = right.x; if (i<6) center.y = left.y; else center.y = right.y; } if (i%2 == 0) center.z = left.z; else center.z = right.z; // Create the child cell NewNode(&((*A)->leaves[i]),center,halfL,n); (*A)->leaves[i]->parent = *A; } // Recursively build octree if there is a subsequent level for (i=0;i<8;i++) BuildFMMHierarchy(&((*A)->leaves[i]),level-1,n,cutoff,dof); } } /* * Function: NewNode * ------------------------------------------------------------------ * Dynamically allocates space for a new node A in the octree and * initializes the quantities in the node. * */ void H2_3D_Tree::NewNode(nodeT **A, vector3 center, double L, int n) { // Initialization *A = (nodeT *)malloc(sizeof(nodeT)); // Initializes the child, neighbor, interaction, and parent nodes to NULL int i; for (i=0;i<8;i++) (*A)->leaves[i] = NULL; (*A)->parent = NULL; (*A)->fieldval = NULL; (*A)->sourceval = NULL; (*A)->proxysval = NULL; (*A)->sourcefre = NULL; (*A)->fieldlist = NULL; (*A)->sourcelist = NULL; (*A)->center = center; (*A)->length = L; (*A)->Nf = 0; (*A)->Ns = 0; (*A)->ineigh = 0; (*A)->iinter = 0; } /*void H2_3D_Tree::get_Compression_Rate(double* Ucomp, double* Vcomp) { *Ucomp = this->Ucomp; *Vcomp = this->Vcomp; }*/ /*void H2_3D_Tree::EvaluateKernelMulti(vector3 fieldpos, vector3 sourcepos, double *K, doft *dof, int m) { doft dof_kernel; dof_kernel.f = dof->f; dof_kernel.s = dof->s*m; EvaluateKernel(fieldpos, sourcepos, K, dof_kernel); }*/ void H2_3D_Tree::FreeNode(nodeT *A) { int i; // Free all child nodes first for (i=0;i<8;i++) { if (A->leaves[i] != NULL) { FreeNode(A->leaves[i]); } } // Free the arrays for the field and source values if (A->fieldval != NULL) free(A->fieldval), A->fieldval=NULL; if (A->sourceval != NULL) free(A->sourceval), A->sourceval=NULL; if (A->proxysval != NULL) free(A->proxysval), A->proxysval=NULL; if (A->sourcefre != NULL) free(A->sourcefre), A->sourcefre=NULL; // Free the field and source lists if (A->fieldlist != NULL) free(A->fieldlist), A->fieldlist=NULL; if (A->sourcelist != NULL) free(A->sourcelist), A->sourcelist=NULL; // Last free the node free(A); } H2_3D_Tree::~H2_3D_Tree() { if (tree != NULL) { FreeNode(tree); tree = NULL; } if (Kweights!= NULL) { free(Kweights); Kweights = NULL; } if (Cweights!= NULL) { free(Cweights); Cweights = NULL; } if (Tkz!= NULL) { free(Tkz); Tkz = NULL; } if (K!= NULL) { free(K); K = NULL; } if (U!= NULL) { free(U); U = NULL; } if (VT!= NULL) { free(VT); VT = NULL; } dof = NULL; }
[ "amaliak@stanford.edu" ]
amaliak@stanford.edu
147fc4b22f80489d8998f15b79b5d2e8d0a3fadb
36c9f3759ea917e7c6f4f30ccab3fb7a85a6c756
/src/Types/Circles/Circles.cpp
356a66d1903f32798fac77d4d04f254e72956732
[]
no_license
AnnaKosmalska/FindPaperSheet
2d811f6f8dc0a14d93954096743459d546a001f8
fd81d33b8177fce03ffb2374c8d1b17720f7f926
refs/heads/master
2021-05-29T07:45:20.512034
2015-05-29T11:29:10
2015-05-29T11:29:10
null
0
0
null
null
null
null
UTF-8
C++
false
false
769
cpp
/* * Circles.cpp * * Created on: 20-05-2011 * Author: x */ #include "Circles.hpp" namespace Types { using namespace cv; using namespace std; Circles::Circles() { // TODO Auto-generated constructor stub } Circles::~Circles() { // TODO Auto-generated destructor stub } void Circles::draw(cv::Mat& image, cv::Scalar color, int offsetX, int offsetY) { for (unsigned int i = 0; i < circles.size(); ++i) { Point center(cvRound(circles[i][0]), cvRound(circles[i][1])); int radius = cvRound(circles[i][2]); // draw the circle center circle(image, center, 3, Scalar(0, 255, 0), -1, 8, 0); // draw the circle outline circle(image, center, radius, Scalar(0, 0, 255), 3, 8, 0); } } Drawable * Circles::clone() { return new Circles(*this); } }
[ "aniawujek@gmail.com" ]
aniawujek@gmail.com
d3f1edaa55b07e7216d599f93b8009c97fc8697f
fa345d30d723c9cbdb750235c832bb3af635d77f
/DesignSnakeGame.cpp
dd0b071e362bbb37fc14f783c0d1c3d20859a3b7
[]
no_license
AparnaChinya/100DaysOfCode
03c50ff1dc7e003f7c3510ee1c40f2c0588021ec
436ff8302eaeea705d92de4dc8c5a763b84b3348
refs/heads/master
2021-07-18T13:24:06.102900
2018-12-07T06:04:29
2018-12-07T06:04:29
72,006,131
3
0
null
null
null
null
UTF-8
C++
false
false
3,356
cpp
/* 353. Design Snake Game Design a Snake game that is played on a device with screen size = width x height. Play the game online if you are not familiar with the game. The snake is initially positioned at the top left corner (0,0) with length = 1 unit. You are given a list of food's positions in row-column order. When a snake eats the food, its length and the game's score both increase by 1. Each food appears one by one on the screen. For example, the second food will not appear until the first food was eaten by the snake. When a food does appear on the screen, it is guaranteed that it will not appear on a block occupied by the snake. Example: Given width = 3, height = 2, and food = [[1,2],[0,1]]. Snake snake = new Snake(width, height, food); Initially the snake appears at position (0,0) and the food at (1,2). |S| | | | | |F| snake.move("R"); -> Returns 0 | |S| | | | |F| snake.move("D"); -> Returns 0 | | | | | |S|F| snake.move("R"); -> Returns 1 (Snake eats the first food and right after that, the second food appears at (0,1) ) | |F| | | |S|S| snake.move("U"); -> Returns 1 | |F|S| | | |S| snake.move("L"); -> Returns 2 (Snake eats the second food) | |S|S| | | |S| snake.move("U"); -> Returns -1 (Game over because snake collides with border) From <https://leetcode.com/problems/design-snake-game/description/> */ class SnakeGame { public: /** Initialize your data structure here. @param width - screen width @param height - screen height @param food - A list of food positions E.g food = [[1,1], [1,0]] means the first food is positioned at [1,1], the second is at [1,0]. */ int width; int height; int position; vector<pair<int,int>> food; set<pair<int,int>> hist; deque<pair<int,int>> q; SnakeGame(int width, int height, vector<pair<int, int>> food) { this->width = width; this->height = height; this->food = food; position = 0; q.push_back(make_pair(0,0)); } /** Moves the snake. @param direction - 'U' = Up, 'L' = Left, 'R' = Right, 'D' = Down @return The game's score after the move. Return -1 if game over. Game over when snake crosses the screen boundary or bites its body. */ int move(string direction) { int row = q.back().first; int col = q.back().second; pair<int,int> d = q.front(); q.pop_front(); hist.erase(d); if(direction == "U") { row--; } else if(direction == "D") { row++; } else if(direction == "L") { col--; } else if(direction == "R") { col++; } if(row < 0 || col < 0 || row >= height || col >= width || hist.count(make_pair(row,col))) { return -1; } hist.insert(make_pair(row,col)); q.push_back(make_pair(row,col)); if(position >= food.size()) { return q.size()-1; } if(row == food[position].first && col == food[position].second) { position++; q.push_front(d); hist.insert(d); } return q.size()-1; } }; /** * Your SnakeGame object will be instantiated and called as such: * SnakeGame obj = new SnakeGame(width, height, food); * int param_1 = obj.move(direction); */
[ "apchin@outlook.com" ]
apchin@outlook.com