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
7c26610a71c766287d9dfba4df4a81e2b15fb764
e7762fb3708c86536109009964bcb8f304a77135
/Vorlesung01/Vorlesung01/Hausaufgabe_Personen/Person.h
838a11ebab5b5541c0827930a959df1ddde5a599
[]
no_license
LucRome/CPP-Vorlesung
08a1ef828b993c83dfb543e25b5b81494ada14ca
f5bec23fe60ba1f80c2c263a2f597c8d265f4002
refs/heads/master
2022-09-25T19:29:47.543634
2020-06-04T07:08:21
2020-06-04T07:08:21
262,011,310
0
0
null
null
null
null
UTF-8
C++
false
false
441
h
#pragma once #include <string>; #include<stdio.h>; #include "Enums.h"; using namespace std; class Person { void greet(Nationalities nationality, string nameOther); void farewell(Nationalities nationality, string nameOther); public: Person(Nationalities nationality, string Name); void talkTo(Person person); Nationalities get_nationality(); string get_name(); private: const Nationalities m_Nationality; const string m_Name; };
[ "64947931+LucRome@users.noreply.github.com" ]
64947931+LucRome@users.noreply.github.com
82c399fefbf997d53da662d108af1498f8eb565d
13f6937c44a2a3b9309393b8e18fcfedac146323
/Source/JapaneseBusinessman/Private/TwoDPlayerController.h
570bb58aa403807d5adbce76cdeb42284ff4436c
[]
no_license
zitherSide/JapaneseBusinessmanSimulator
612930bf9da290b27281283b78937d352f96d272
e64933e1d6e8ff7ac9202e715061a14866c70e16
refs/heads/master
2021-05-17T07:35:41.464743
2021-03-02T22:45:43
2021-03-02T22:45:43
250,696,987
0
0
null
null
null
null
UTF-8
C++
false
false
425
h
// Fill out your copyright notice in the Description page of Project Settings. #pragma once #include "CoreMinimal.h" #include "GameFramework/PlayerController.h" #include "TwoDPlayerController.generated.h" /** * */ UCLASS() class ATwoDPlayerController : public APlayerController { GENERATED_BODY() public: ATwoDPlayerController(); protected: virtual void SetupInputComponent() override; private: void jump(); };
[ "takuyakotoyori@akane.waseda.jp" ]
takuyakotoyori@akane.waseda.jp
685eba690150e568c2d99ce171b8c7c9fccbfff9
a23665259e3b931a12290d5ff80e1c4d4916c0ea
/vgui2/src/InputWin32.cpp
3798e3ac31f803b9749a187d3c656c5dcc08c226
[]
no_license
q4a/half
507490107968459073f23c306bdff56e7dffd9f7
6a4302e286aa5bfd9ebdc7ed2688d2290981ec9c
refs/heads/master
2022-04-26T13:18:15.597053
2017-06-15T13:32:34
2017-06-15T13:32:34
null
0
0
null
null
null
null
WINDOWS-1252
C++
false
false
40,256
cpp
//========= Copyright © 1996-2003, Valve LLC, All rights reserved. ============ // // The copyright to the contents herein is the property of Valve, L.L.C. // The contents may be used and/or copied only with the written permission of // Valve, L.L.C., or in accordance with the terms and conditions stipulated in // the agreement/contract under which the contents have been supplied. // // Purpose: // // $NoKeywords: $ //============================================================================= #include <windows.h> #include <string.h> #define PROTECTED_THINGS_DISABLE #include "vgui_internal.h" #include "VPanel.h" #include "UtlVector.h" #include <KeyValues.h> #include <vgui/VGUI.h> #include <vgui/IClientPanel.h> #include <vgui/IInputInternal.h> #include <vgui/IPanel.h> #include <vgui/ISurface.h> #include <vgui/IVGui.h> #include <vgui/KeyCode.h> #include <vgui/MouseCode.h> #include "UtlLinkedList.h" SHORT System_GetKeyState( int virtualKeyCode ); // in System.cpp, a hack to only have g_pVCR in system.cpp using namespace vgui; class CInputWin32 : public IInputInternal { public: CInputWin32(); virtual void RunFrame(); virtual void PanelDeleted(VPANEL panel); virtual void UpdateMouseFocus(int x, int y); virtual void SetMouseFocus(VPANEL newMouseFocus); virtual void SetCursorPos(int x, int y); virtual void GetCursorPos(int &x, int &y); virtual void SetCursorOveride(HCursor cursor); virtual HCursor GetCursorOveride(); virtual void SetMouseCapture(VPANEL panel); virtual VPANEL GetMouseCapture(); virtual VPANEL GetFocus(); virtual VPANEL GetMouseOver(); virtual bool WasMousePressed(MouseCode code); virtual bool WasMouseDoublePressed(MouseCode code); virtual bool IsMouseDown(MouseCode code); virtual bool WasMouseReleased(MouseCode code); virtual bool WasKeyPressed(KeyCode code); virtual bool IsKeyDown(KeyCode code); virtual bool WasKeyTyped(KeyCode code); virtual bool WasKeyReleased(KeyCode code); virtual void GetKeyCodeText(KeyCode code, char *buf, int buflen); virtual void InternalCursorMoved(int x,int y); //expects input in surface space virtual void InternalMousePressed(MouseCode code); virtual void InternalMouseDoublePressed(MouseCode code); virtual void InternalMouseReleased(MouseCode code); virtual void InternalMouseWheeled(int delta); virtual void InternalKeyCodePressed(KeyCode code); virtual void InternalKeyCodeTyped(KeyCode code); virtual void InternalKeyTyped(wchar_t unichar); virtual void InternalKeyCodeReleased(KeyCode code); virtual VPANEL GetAppModalSurface(); // set the modal dialog panel. // all events will go only to this panel and its children. virtual void SetAppModalSurface(VPANEL panel); // release the modal dialog panel // do this when your modal dialog finishes. virtual void ReleaseAppModalSurface(); // returns true if the specified panel is a child of the current modal panel // if no modal panel is set, then this always returns TRUE virtual bool IsChildOfModalPanel(VPANEL panel); // Creates/ destroys "input" contexts, which contains information // about which controls have mouse + key focus, for example. virtual HInputContext CreateInputContext(); virtual void DestroyInputContext( HInputContext context ); // Associates a particular panel with an input context // Associating NULL is valid; it disconnects the panel from the context virtual void AssociatePanelWithInputContext( HInputContext context, VPANEL pRoot ); // Activates a particular input context, use DEFAULT_INPUT_CONTEXT // to get the one normally used by VGUI virtual void ActivateInputContext( HInputContext context ); virtual void ResetInputContext( HInputContext context ); virtual void GetCursorPosition( int &x, int &y ); private: void PostKeyMessage(KeyValues *message); VPanel *CInputWin32::CalculateNewKeyFocus(); void UpdateToggleButtonState(); struct InputContext_t { VPANEL _rootPanel; bool _mousePressed[MOUSE_LAST]; bool _mouseDoublePressed[MOUSE_LAST]; bool _mouseDown[MOUSE_LAST]; bool _mouseReleased[MOUSE_LAST]; bool _keyPressed[KEY_LAST]; bool _keyTyped[KEY_LAST]; bool _keyDown[KEY_LAST]; bool _keyReleased[KEY_LAST]; VPanel *_keyFocus; VPanel *_oldMouseFocus; VPanel *_mouseFocus; // the panel that has the current mouse focus - same as _mouseOver unless _mouseCapture is set VPanel *_mouseOver; // the panel that the mouse is currently over, NULL if not over any vgui item VPanel *_mouseCapture; // the panel that has currently captured mouse focus VPanel *_appModalPanel; // the modal dialog panel. int m_nCursorX; int m_nCursorY; }; void InitInputContext( InputContext_t *pContext ); InputContext_t *GetInputContext( HInputContext context ); void PanelDeleted(VPANEL focus, InputContext_t &context); HCursor _cursorOverride; bool _updateToggleButtonState; char *_keyTrans[KEY_LAST]; InputContext_t m_DefaultInputContext; HInputContext m_hContext; // current input context CUtlLinkedList< InputContext_t, HInputContext > m_Contexts; }; CInputWin32 g_Input; EXPOSE_SINGLE_INTERFACE_GLOBALVAR(CInputWin32, IInput, VGUI_INPUT_INTERFACE_VERSION, g_Input); // export IInput to everyone else, not IInputInternal! EXPOSE_SINGLE_INTERFACE_GLOBALVAR(CInputWin32, IInputInternal, VGUI_INPUTINTERNAL_INTERFACE_VERSION, g_Input); // for use in external surfaces only! (like the engine surface) namespace vgui { vgui::IInputInternal *input() { return &g_Input; } } CInputWin32::CInputWin32() { InitInputContext( &m_DefaultInputContext ); m_hContext = DEFAULT_INPUT_CONTEXT; // build key to text translation table // first byte unshifted key // second byte shifted key // the rest is the name of the key _keyTrans[KEY_0] ="0)KEY_0"; _keyTrans[KEY_1] ="1!KEY_1"; _keyTrans[KEY_2] ="2@KEY_2"; _keyTrans[KEY_3] ="3#KEY_3"; _keyTrans[KEY_4] ="4$KEY_4"; _keyTrans[KEY_5] ="5%KEY_5"; _keyTrans[KEY_6] ="6^KEY_6"; _keyTrans[KEY_7] ="7&KEY_7"; _keyTrans[KEY_8] ="8*KEY_8"; _keyTrans[KEY_9] ="9(KEY_9"; _keyTrans[KEY_A] ="aAKEY_A"; _keyTrans[KEY_B] ="bBKEY_B"; _keyTrans[KEY_C] ="cCKEY_C"; _keyTrans[KEY_D] ="dDKEY_D"; _keyTrans[KEY_E] ="eEKEY_E"; _keyTrans[KEY_F] ="fFKEY_F"; _keyTrans[KEY_G] ="gGKEY_G"; _keyTrans[KEY_H] ="hHKEY_H"; _keyTrans[KEY_I] ="iIKEY_I"; _keyTrans[KEY_J] ="jJKEY_J"; _keyTrans[KEY_K] ="kKKEY_K"; _keyTrans[KEY_L] ="lLKEY_L"; _keyTrans[KEY_M] ="mMKEY_M"; _keyTrans[KEY_N] ="nNKEY_N"; _keyTrans[KEY_O] ="oOKEY_O"; _keyTrans[KEY_P] ="pPKEY_P"; _keyTrans[KEY_Q] ="qQKEY_Q"; _keyTrans[KEY_R] ="rRKEY_R"; _keyTrans[KEY_S] ="sSKEY_S"; _keyTrans[KEY_T] ="tTKEY_T"; _keyTrans[KEY_U] ="uUKEY_U"; _keyTrans[KEY_V] ="vVKEY_V"; _keyTrans[KEY_W] ="wWKEY_W"; _keyTrans[KEY_X] ="xXKEY_X"; _keyTrans[KEY_Y] ="yYKEY_Y"; _keyTrans[KEY_Z] ="zZKEY_Z"; _keyTrans[KEY_PAD_0] ="0\0KEY_PAD_0"; _keyTrans[KEY_PAD_1] ="1\0KEY_PAD_1"; _keyTrans[KEY_PAD_2] ="2\0KEY_PAD_2"; _keyTrans[KEY_PAD_3] ="3\0KEY_PAD_3"; _keyTrans[KEY_PAD_4] ="4\0KEY_PAD_4"; _keyTrans[KEY_PAD_5] ="5\0KEY_PAD_5"; _keyTrans[KEY_PAD_6] ="6\0KEY_PAD_6"; _keyTrans[KEY_PAD_7] ="7\0KEY_PAD_7"; _keyTrans[KEY_PAD_8] ="8\0KEY_PAD_8"; _keyTrans[KEY_PAD_9] ="9\0KEY_PAD_9"; _keyTrans[KEY_PAD_DIVIDE] ="//KEY_PAD_DIVIDE"; _keyTrans[KEY_PAD_MULTIPLY] ="**KEY_PAD_MULTIPLY"; _keyTrans[KEY_PAD_MINUS] ="--KEY_PAD_MINUS"; _keyTrans[KEY_PAD_PLUS] ="++KEY_PAD_PLUS"; _keyTrans[KEY_PAD_ENTER] ="\0\0KEY_PAD_ENTER"; _keyTrans[KEY_PAD_DECIMAL] =".\0KEY_PAD_DECIMAL"; _keyTrans[KEY_LBRACKET] ="[{KEY_LBRACKET"; _keyTrans[KEY_RBRACKET] ="]}KEY_RBRACKET"; _keyTrans[KEY_SEMICOLON] =";:KEY_SEMICOLON"; _keyTrans[KEY_APOSTROPHE] ="'\"KEY_APOSTROPHE"; _keyTrans[KEY_BACKQUOTE] ="`~KEY_BACKQUOTE"; _keyTrans[KEY_COMMA] =",<KEY_COMMA"; _keyTrans[KEY_PERIOD] =".>KEY_PERIOD"; _keyTrans[KEY_SLASH] ="/?KEY_SLASH"; _keyTrans[KEY_BACKSLASH] ="\\|KEY_BACKSLASH"; _keyTrans[KEY_MINUS] ="-_KEY_MINUS"; _keyTrans[KEY_EQUAL] ="=+KEY_EQUAL"; _keyTrans[KEY_ENTER] ="\0\0KEY_ENTER"; _keyTrans[KEY_SPACE] =" KEY_SPACE"; _keyTrans[KEY_BACKSPACE] ="\0\0KEY_BACKSPACE"; _keyTrans[KEY_TAB] ="\0\0KEY_TAB"; _keyTrans[KEY_CAPSLOCK] ="\0\0KEY_CAPSLOCK"; _keyTrans[KEY_NUMLOCK] ="\0\0KEY_NUMLOCK"; _keyTrans[KEY_ESCAPE] ="\0\0KEY_ESCAPE"; _keyTrans[KEY_SCROLLLOCK] ="\0\0KEY_SCROLLLOCK"; _keyTrans[KEY_INSERT] ="\0\0KEY_INSERT"; _keyTrans[KEY_DELETE] ="\0\0KEY_DELETE"; _keyTrans[KEY_HOME] ="\0\0KEY_HOME"; _keyTrans[KEY_END] ="\0\0KEY_END"; _keyTrans[KEY_PAGEUP] ="\0\0KEY_PAGEUP"; _keyTrans[KEY_PAGEDOWN] ="\0\0KEY_PAGEDOWN"; _keyTrans[KEY_BREAK] ="\0\0KEY_BREAK"; _keyTrans[KEY_LSHIFT] ="\0\0KEY_LSHIFT"; _keyTrans[KEY_RSHIFT] ="\0\0KEY_RSHIFT"; _keyTrans[KEY_LALT] ="\0\0KEY_LALT"; _keyTrans[KEY_RALT] ="\0\0KEY_RALT"; _keyTrans[KEY_LCONTROL] ="\0\0KEY_LCONTROL"; _keyTrans[KEY_RCONTROL] ="\0\0KEY_RCONTROL"; _keyTrans[KEY_LWIN] ="\0\0KEY_LWIN"; _keyTrans[KEY_RWIN] ="\0\0KEY_RWIN"; _keyTrans[KEY_APP] ="\0\0KEY_APP"; _keyTrans[KEY_UP] ="\0\0KEY_UP"; _keyTrans[KEY_LEFT] ="\0\0KEY_LEFT"; _keyTrans[KEY_DOWN] ="\0\0KEY_DOWN"; _keyTrans[KEY_RIGHT] ="\0\0KEY_RIGHT"; _keyTrans[KEY_F1] ="\0\0KEY_F1"; _keyTrans[KEY_F2] ="\0\0KEY_F2"; _keyTrans[KEY_F3] ="\0\0KEY_F3"; _keyTrans[KEY_F4] ="\0\0KEY_F4"; _keyTrans[KEY_F5] ="\0\0KEY_F5"; _keyTrans[KEY_F6] ="\0\0KEY_F6"; _keyTrans[KEY_F7] ="\0\0KEY_F7"; _keyTrans[KEY_F8] ="\0\0KEY_F8"; _keyTrans[KEY_F9] ="\0\0KEY_F9"; _keyTrans[KEY_F10] ="\0\0KEY_F10"; _keyTrans[KEY_F11] ="\0\0KEY_F11"; _keyTrans[KEY_F12] ="\0\0KEY_F12"; } //----------------------------------------------------------------------------- // Resets an input context //----------------------------------------------------------------------------- void CInputWin32::InitInputContext( InputContext_t *pContext ) { pContext->_rootPanel = NULL; pContext->_keyFocus = NULL; pContext->_oldMouseFocus = NULL; pContext->_mouseFocus = NULL; pContext->_mouseOver = NULL; pContext->_mouseCapture = NULL; pContext->_appModalPanel = NULL; pContext->m_nCursorX = pContext->m_nCursorY = 0; // zero mouse and keys memset(pContext->_mousePressed, 0, sizeof(pContext->_mousePressed)); memset(pContext->_mouseDoublePressed, 0, sizeof(pContext->_mouseDoublePressed)); memset(pContext->_mouseDown, 0, sizeof(pContext->_mouseDown)); memset(pContext->_mouseReleased, 0, sizeof(pContext->_mouseReleased)); memset(pContext->_keyPressed, 0, sizeof(pContext->_keyPressed)); memset(pContext->_keyTyped, 0, sizeof(pContext->_keyTyped)); memset(pContext->_keyDown, 0, sizeof(pContext->_keyDown)); memset(pContext->_keyReleased, 0, sizeof(pContext->_keyReleased)); } void CInputWin32::ResetInputContext( HInputContext context ) { // FIXME: Needs to release various keys, mouse buttons, etc...? // At least needs to cause things to lose focus InitInputContext( GetInputContext(context) ); } //----------------------------------------------------------------------------- // Creates/ destroys "input" contexts, which contains information // about which controls have mouse + key focus, for example. //----------------------------------------------------------------------------- HInputContext CInputWin32::CreateInputContext() { HInputContext i = m_Contexts.AddToTail(); InitInputContext( &m_Contexts[i] ); return i; } void CInputWin32::DestroyInputContext( HInputContext context ) { assert( context != DEFAULT_INPUT_CONTEXT ); if ( m_hContext == context ) { ActivateInputContext( DEFAULT_INPUT_CONTEXT ); } m_Contexts.Remove(context); } //----------------------------------------------------------------------------- // Returns the current input context //----------------------------------------------------------------------------- CInputWin32::InputContext_t *CInputWin32::GetInputContext( HInputContext context ) { if (context == DEFAULT_INPUT_CONTEXT) return &m_DefaultInputContext; return &m_Contexts[context]; } //----------------------------------------------------------------------------- // Associates a particular panel with an input context // Associating NULL is valid; it disconnects the panel from the context //----------------------------------------------------------------------------- void CInputWin32::AssociatePanelWithInputContext( HInputContext context, VPANEL pRoot ) { // Changing the root panel should invalidate keysettings, etc. if (GetInputContext(context)->_rootPanel != pRoot) { ResetInputContext( context ); GetInputContext(context)->_rootPanel = pRoot; } } //----------------------------------------------------------------------------- // Activates a particular input context, use DEFAULT_INPUT_CONTEXT // to get the one normally used by VGUI //----------------------------------------------------------------------------- void CInputWin32::ActivateInputContext( HInputContext context ) { assert( (context == DEFAULT_INPUT_CONTEXT) || m_Contexts.IsValidIndex(context) ); m_hContext = context; } //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CInputWin32::RunFrame() { InputContext_t *pContext = GetInputContext(m_hContext); if (m_hContext == DEFAULT_INPUT_CONTEXT) { _updateToggleButtonState = true; /* FIXME: add the set cursor call? // make sure the cursor looks like it is supposed to if (pContext->_mouseFocus) { pContext->_mouseFocus->Client()->InternalSetCursor(); }*/ } // tick whoever has the focus if (pContext->_keyFocus) { // when modal dialogs are up messages only get sent to the dialogs children. if (IsChildOfModalPanel((VPANEL)pContext->_keyFocus)) { ivgui()->PostMessage((VPANEL)pContext->_keyFocus, new KeyValues("KeyFocusTicked"), NULL); } } // tick whoever has the focus if (pContext->_mouseFocus) { // when modal dialogs are up messages only get sent to the dialogs children. if (IsChildOfModalPanel((VPANEL)pContext->_mouseFocus)) { ivgui()->PostMessage((VPANEL)pContext->_mouseFocus, new KeyValues("MouseFocusTicked"), NULL); } } //clear mouse and key states for (int i = 0; i < MOUSE_LAST; i++) { pContext->_mousePressed[i] = 0; pContext->_mouseDoublePressed[i] = 0; pContext->_mouseReleased[i] = 0; } for (i = 0; i < KEY_LAST; i++) { pContext->_keyPressed[i] = 0; pContext->_keyTyped[i] = 0; pContext->_keyReleased[i] = 0; } VPanel *wantedKeyFocus = CalculateNewKeyFocus(); // make sure old and new focus get painted if (pContext->_keyFocus != wantedKeyFocus) { if (pContext->_keyFocus != NULL) { pContext->_keyFocus->Client()->InternalFocusChanged(true); // send a message to the window saying that it's losing focus ivgui()->PostMessage((VPANEL)pContext->_keyFocus, new KeyValues("KillFocus"), NULL); pContext->_keyFocus->Client()->Repaint(); // repaint the nearest popup as well, since it will need to redraw after losing focus VPanel *dlg = pContext->_keyFocus; while (dlg && !dlg->IsPopup()) { dlg = dlg->GetParent(); } if (dlg) { dlg->Client()->Repaint(); } } if (wantedKeyFocus != NULL) { wantedKeyFocus->Client()->InternalFocusChanged(false); // send a message to the window saying that it's gaining focus ivgui()->PostMessage((VPANEL)wantedKeyFocus, new KeyValues("SetFocus"), NULL); wantedKeyFocus->Client()->Repaint(); // repaint the nearest popup as well, since it will need to redraw after gaining focus VPanel *dlg = wantedKeyFocus; while (dlg && !dlg->IsPopup()) { dlg = dlg->GetParent(); } if (dlg) { dlg->Client()->Repaint(); } } // accept the focus request pContext->_keyFocus = wantedKeyFocus; if (pContext->_keyFocus) { pContext->_keyFocus->MoveToFront(); } } } //----------------------------------------------------------------------------- // Purpose: Calculate the new key focus //----------------------------------------------------------------------------- VPanel *CInputWin32::CalculateNewKeyFocus() { InputContext_t *pContext = GetInputContext(m_hContext); // get the top-order panel VPanel *top = NULL; VPanel *wantedKeyFocus = NULL; if (!pContext->_rootPanel) { if (surface()->GetPopupCount() > 0) { // find the highest-level window that is both visible and a popup int index = surface()->GetPopupCount(); while (index) { top = (VPanel *)surface()->GetPopup(--index); // traverse the heirachy and check if the popup really is visible if (top->IsPopup() && top->IsVisible() && top->IsKeyBoardInputEnabled() && !surface()->IsMinimized((VPANEL)top)) { bool IsVisible = top->IsVisible(); VPanel *p = top->GetParent(); // drill down the heirachy checking that everything is visible while(p && IsVisible) { if( p->IsVisible()==false) { IsVisible=false; break; } p=p->GetParent(); } if (IsVisible && !surface()->IsMinimized((VPANEL)top) ) { break; } } top = NULL; } } } else { top = (VPanel *)pContext->_rootPanel; } if (top) { // ask the top-level panel for what it considers to be the current focus wantedKeyFocus = (VPanel *)top->Client()->GetCurrentKeyFocus(); if (!wantedKeyFocus) { wantedKeyFocus = top; } } // check to see if any of this surfaces panels have the focus if (!surface()->HasFocus()) { wantedKeyFocus=NULL; } // check if we are in modal state, // and if we are make sure this panel is a child of us. if (!IsChildOfModalPanel((VPANEL)wantedKeyFocus)) { wantedKeyFocus=NULL; } return wantedKeyFocus; } //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CInputWin32::PanelDeleted(VPANEL vfocus, InputContext_t &context) { VPanel *focus = (VPanel *)vfocus; if (context._keyFocus == focus) { context._keyFocus = NULL; } if (context._mouseOver == focus) { context._mouseOver = NULL; } if (context._oldMouseFocus == focus) { context._oldMouseFocus = NULL; } if (context._mouseFocus == focus) { context._mouseFocus = NULL; } // NOTE: These two will only ever happen for the default context at the moment if (context._mouseCapture == focus) { assert( &context == &m_DefaultInputContext ); SetMouseCapture(NULL); context._mouseCapture = NULL; } if (context._appModalPanel == focus) { assert( &context == &m_DefaultInputContext ); ReleaseAppModalSurface(); } } //----------------------------------------------------------------------------- // Purpose: // Input : *focus - //----------------------------------------------------------------------------- void CInputWin32::PanelDeleted(VPANEL focus) { HInputContext i; for (i = m_Contexts.Head(); i != m_Contexts.InvalidIndex(); i = m_Contexts.Next(i) ) { PanelDeleted( focus, m_Contexts[i] ); } PanelDeleted( focus, m_DefaultInputContext ); } //----------------------------------------------------------------------------- // Purpose: Sets the new mouse focus // won't override _mouseCapture settings // Input : newMouseFocus - //----------------------------------------------------------------------------- void CInputWin32::SetMouseFocus(VPANEL newMouseFocus) { // check if we are in modal state, // and if we are make sure this panel is a child of us. if (!IsChildOfModalPanel(newMouseFocus)) { return; } bool wantsMouse, isPopup; // = popup->GetMouseInput(); VPanel *panel = (VPanel *)newMouseFocus; InputContext_t *pContext = GetInputContext( m_hContext ); if ( newMouseFocus ) { do { wantsMouse = panel->IsMouseInputEnabled(); isPopup = panel->IsPopup(); panel = panel->GetParent(); } while ( wantsMouse && !isPopup && panel && panel->GetParent() ); // only consider panels that want mouse input } // if this panel doesn't want mouse input don't let it get focus if (newMouseFocus && !wantsMouse) { return; } if ((VPANEL)pContext->_mouseOver != newMouseFocus || (!pContext->_mouseCapture && (VPANEL)pContext->_mouseFocus != newMouseFocus) ) { pContext->_oldMouseFocus = pContext->_mouseOver; pContext->_mouseOver = (VPanel *)newMouseFocus; //tell the old panel with the mouseFocus that the cursor exited if (pContext->_oldMouseFocus != NULL) { // only notify of entry if the mouse is not captured or we're a child of the captured panel if ( !pContext->_mouseCapture || pContext->_oldMouseFocus->HasParent(pContext->_mouseCapture) ) { ivgui()->PostMessage((VPANEL)pContext->_oldMouseFocus, new KeyValues("CursorExited"), NULL); } } //tell the new panel with the mouseFocus that the cursor entered if (pContext->_mouseOver != NULL) { // only notify of entry if the mouse is not captured or we're a child of the captured panel if ( !pContext->_mouseCapture || pContext->_mouseOver->HasParent(pContext->_mouseCapture) ) { ivgui()->PostMessage((VPANEL)pContext->_mouseOver, new KeyValues("CursorEntered"), NULL); } } // set where the mouse is currently over // mouse capture overrides destination if ( pContext->_mouseCapture ) { pContext->_mouseFocus = pContext->_mouseCapture; } else { pContext->_mouseFocus = pContext->_mouseOver; } } } //----------------------------------------------------------------------------- // Purpose: Calculates which panel the cursor is currently over and sets it up // as the current mouse focus. //----------------------------------------------------------------------------- void CInputWin32::UpdateMouseFocus(int x, int y) { // find the panel that has the focus VPanel *focus = NULL; InputContext_t *pContext = GetInputContext( m_hContext ); if (!pContext->_rootPanel) { if (surface()->IsCursorVisible() && surface()->IsWithin(x, y)) { // faster version of code below // checks through each popup in order, top to bottom windows for (int i = surface()->GetPopupCount() - 1; i >= 0; i--) { VPanel *popup = (VPanel *)surface()->GetPopup(i); VPanel *panel = popup; bool wantsMouse = panel->IsMouseInputEnabled(); bool isVisible; do { isVisible = panel->IsVisible(); panel = panel->GetParent(); } while ( isVisible && panel && panel->GetParent() ); // only consider panels that want mouse input if ( wantsMouse && isVisible ) { focus = (VPanel *)popup->Client()->IsWithinTraverse(x, y, false); if (focus) break; } } if (!focus) { focus = (VPanel *)((VPanel *)surface()->GetEmbeddedPanel())->Client()->IsWithinTraverse(x, y, false); } } } else { focus = (VPanel *)((VPanel *)(pContext->_rootPanel))->Client()->IsWithinTraverse(x, y, false); } // mouse focus debugging code /* static VPanel *oldFocus = (VPanel *)0x0001; if (oldFocus != focus) { oldFocus = focus; if (focus) { ivgui()->DPrintf2("mouse over: (%s, %s)\n", focus->GetName(), focus->GetClassName()); } else { ivgui()->DPrintf2("mouse over: (NULL)\n"); } } */ // check if we are in modal state, // and if we are make sure this panel is a child of us. if (!IsChildOfModalPanel((VPANEL)focus)) { // should this be _appModalPanel? focus = NULL; } SetMouseFocus((VPANEL)focus); } //----------------------------------------------------------------------------- // Purpose: Sets or releases the mouse capture // Input : panel - pointer to the panel to get mouse capture // a NULL panel means that you want to clear the mouseCapture // MouseCaptureLost is sent to the panel that loses the mouse capture //----------------------------------------------------------------------------- void CInputWin32::SetMouseCapture(VPANEL panel) { // check if we are in modal state, // and if we are make sure this panel is a child of us. if (!IsChildOfModalPanel(panel)) { return; } InputContext_t *pContext = GetInputContext( m_hContext ); // send a message if the panel is losing mouse capture if (pContext->_mouseCapture && panel != (VPANEL)pContext->_mouseCapture) { ivgui()->PostMessage((VPANEL)pContext->_mouseCapture, new KeyValues("MouseCaptureLost"), NULL); } if (panel == NULL) { if (pContext->_mouseCapture != NULL) { surface()->EnableMouseCapture((VPANEL)pContext->_mouseCapture, false); } } else { surface()->EnableMouseCapture(panel, true); } pContext->_mouseCapture = (VPanel *)panel; } VPANEL CInputWin32::GetMouseCapture() { return (VPANEL)( m_DefaultInputContext._mouseCapture ); } //----------------------------------------------------------------------------- // Purpose: check if we are in modal state, // and if we are make sure this panel has the modal panel as a parent //----------------------------------------------------------------------------- bool CInputWin32::IsChildOfModalPanel(VPANEL panel) { // NULL is ok. if (!panel) return true; InputContext_t *pContext = GetInputContext( m_hContext ); // if we are in modal state, make sure this panel is a child of us. if (pContext->_appModalPanel) { if (!((VPanel *)panel)->HasParent(pContext->_appModalPanel)) { return false; } } return true; } //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- VPANEL CInputWin32::GetFocus() { return (VPANEL)( GetInputContext( m_hContext )->_keyFocus ); } //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- VPANEL CInputWin32::GetMouseOver() { return (VPANEL)( GetInputContext( m_hContext )->_mouseOver ); } bool CInputWin32::WasMousePressed(MouseCode code) { return GetInputContext( m_hContext )->_mousePressed[code]; } bool CInputWin32::WasMouseDoublePressed(MouseCode code) { return GetInputContext( m_hContext )->_mouseDoublePressed[code]; } bool CInputWin32::IsMouseDown(MouseCode code) { return GetInputContext( m_hContext )->_mouseDown[code]; } bool CInputWin32::WasMouseReleased(MouseCode code) { return GetInputContext( m_hContext )->_mouseReleased[code]; } bool CInputWin32::WasKeyPressed(KeyCode code) { return GetInputContext( m_hContext )->_keyPressed[code]; } bool CInputWin32::IsKeyDown(KeyCode code) { return GetInputContext( m_hContext )->_keyDown[code]; } bool CInputWin32::WasKeyTyped(KeyCode code) { return GetInputContext( m_hContext )->_keyTyped[code]; } bool CInputWin32::WasKeyReleased(KeyCode code) { // changed from: only return true if the key was released and the passed in panel matches the keyFocus return GetInputContext( m_hContext )->_keyReleased[code]; } // Returns the last mouse cursor position that we processed void CInputWin32::GetCursorPosition( int &x, int &y ) { InputContext_t *pContext = GetInputContext( m_hContext ); x = pContext->m_nCursorX; y = pContext->m_nCursorY; } //----------------------------------------------------------------------------- // Purpose: Converts a key code into a full key name //----------------------------------------------------------------------------- void CInputWin32::GetKeyCodeText(KeyCode code, char *buf, int buflen) { if (!buf) return; // copy text into buf up to buflen in length // skip 2 in _keyTrans because the first two are for GetKeyCodeChar for (int i = 0; i < buflen; i++) { char ch = _keyTrans[code][i+2]; buf[i] = ch; if (ch == 0) break; } } void CInputWin32::SetCursorPos(int x, int y) { if ( surface()->HasCursorPosFunctions() ) // does the surface export cursor functions for us to use? { surface()->SurfaceSetCursorPos(x,y); } else { // translate into coordinates relative to surface int px, py, pw, pt; surface()->GetAbsoluteWindowBounds(px, py, pw, pt); x += px; y += py; // set windows cursor pos ::SetCursorPos(x, y); } } void CInputWin32::GetCursorPos(int &x, int &y) { if ( surface()->HasCursorPosFunctions() ) // does the surface export cursor functions for us to use? { surface()->SurfaceGetCursorPos(x,y); } else { // get mouse position in windows POINT pnt; ::GetCursorPos(&pnt); x = pnt.x; y = pnt.y; // translate into coordinates relative to surface int px, py, pw, pt; surface()->GetAbsoluteWindowBounds(px, py, pw, pt); x -= px; y -= py; } } void CInputWin32::UpdateToggleButtonState() { // FIXME: Only do this for the primary context // We can't make this work with the VCR stuff... if (m_hContext != DEFAULT_INPUT_CONTEXT) return; // only update toggle button state once per frame if (_updateToggleButtonState) { _updateToggleButtonState = false; } else { return; } // check shift, alt, ctrl keys struct key_t { KeyCode code; int winCode; KeyCode ignoreIf; }; static key_t keys[] = { { KEY_CAPSLOCKTOGGLE, VK_CAPITAL }, { KEY_NUMLOCKTOGGLE, VK_NUMLOCK }, { KEY_SCROLLLOCKTOGGLE, VK_SCROLL }, { KEY_LSHIFT, VK_LSHIFT }, { KEY_RSHIFT, VK_RSHIFT }, { KEY_LCONTROL, VK_LCONTROL }, { KEY_RCONTROL, VK_RCONTROL }, { KEY_LALT, VK_LMENU }, { KEY_RALT, VK_RMENU }, { KEY_RALT, VK_MENU, KEY_LALT }, { KEY_RSHIFT, VK_SHIFT, KEY_LSHIFT }, { KEY_RCONTROL, VK_CONTROL, KEY_LCONTROL }, }; for (int i = 0; i < (sizeof(keys) / sizeof(keys[0])); i++) { bool vState = IsKeyDown(keys[i].code); SHORT winState = System_GetKeyState(keys[i].winCode); if (i < 3) { // toggle keys if (LOBYTE(winState) != (BYTE)vState) { if (LOBYTE(winState)) { InternalKeyCodePressed(keys[i].code); } else { InternalKeyCodeReleased(keys[i].code); } } } else { // press keys if (keys[i].ignoreIf && IsKeyDown(keys[i].ignoreIf)) continue; if (HIBYTE(winState) != (BYTE)vState) { if (HIBYTE(winState)) { InternalKeyCodePressed(keys[i].code); } else { InternalKeyCodeReleased(keys[i].code); } } } } } void CInputWin32::SetCursorOveride(HCursor cursor) { _cursorOverride = cursor; } HCursor CInputWin32::GetCursorOveride() { return _cursorOverride; } void CInputWin32::InternalCursorMoved(int x, int y) { // Windows sends a CursorMoved message even when you haven't actually // moved the cursor, this means we are going into this fxn just by clicking // in the window. We only want to execute this code if we have actually moved // the cursor while dragging. So this code has been added to check // if we have actually moved from our previous position. InputContext_t *pContext = GetInputContext( m_hContext ); if ( pContext->m_nCursorX == x && pContext->m_nCursorY == y ) { return; } else { pContext->m_nCursorX = x; pContext->m_nCursorY = y; } //cursor has moved, so make sure the mouseFocus is current UpdateMouseFocus(x, y); //UpdateMouseFocus would have set _mouseFocus current, so tell the panel with the mouseFocus the mouse has moved if (pContext->_mouseCapture) { if (!IsChildOfModalPanel((VPANEL)pContext->_mouseCapture)) { return; } // send the message to the panel the mouse is over iff it's a child of the panel with mouse capture if (pContext->_mouseOver && pContext->_mouseOver != pContext->_mouseCapture && pContext->_mouseOver->HasParent(pContext->_mouseCapture)) { ivgui()->PostMessage((VPANEL)pContext->_mouseOver, new KeyValues("CursorMoved", "xpos", x, "ypos", y), NULL); } // the panel with mouse capture gets all messages ivgui()->PostMessage((VPANEL)pContext->_mouseCapture, new KeyValues("CursorMoved", "xpos", x, "ypos", y), NULL); } else if (pContext->_mouseFocus != NULL) { // mouse focus is current from UpdateMouse focus // so the appmodal check has already been made. ivgui()->PostMessage((VPANEL)pContext->_mouseFocus, new KeyValues("CursorMoved", "xpos", x, "ypos", y), NULL); } } void CInputWin32::InternalMousePressed(MouseCode code) { InputContext_t *pContext = GetInputContext( m_hContext ); //set mouse state pContext->_mousePressed[code]=1; pContext->_mouseDown[code]=1; if ( pContext->_mouseCapture && IsChildOfModalPanel((VPANEL)pContext->_mouseCapture)) { bool captureLost = false; // send the message to the panel the mouse is over if it's a child of the panel with mouse capture if ( pContext->_mouseOver && pContext->_mouseOver != pContext->_mouseCapture && pContext->_mouseOver->HasParent(pContext->_mouseCapture) ) { ivgui()->PostMessage((VPANEL)pContext->_mouseOver, new KeyValues("MousePressed", "code", code), NULL); } else { // mouse has been pressed over a different area; notify the capturing panel captureLost = true; } // the panel with mouse capture gets all messages ivgui()->PostMessage((VPANEL)pContext->_mouseCapture, new KeyValues("MousePressed", "code", code), NULL); if ( captureLost ) { // this has to happen after MousePressed so the panel doesn't Think it got a mouse press after it lost capture SetMouseCapture(NULL); } } else if ( (pContext->_mouseFocus != NULL) && IsChildOfModalPanel((VPANEL)pContext->_mouseFocus) ) { // tell the panel with the mouseFocus that the mouse was presssed ivgui()->PostMessage((VPANEL)pContext->_mouseFocus, new KeyValues("MousePressed", "code", code), NULL); // ivgui()->DPrintf2("MousePressed: (%s, %s)\n", _mouseFocus->GetName(), _mouseFocus->GetClassName()); } // check if we are in modal state, // and if we are make sure this panel is a child of us. if (IsChildOfModalPanel((VPANEL)pContext->_mouseOver)) { surface()->SetTopLevelFocus((VPANEL)pContext->_mouseOver); } // get the states of CAPSLOCK, NUMLOCK, SCROLLLOCK keys UpdateToggleButtonState(); } void CInputWin32::InternalMouseDoublePressed(MouseCode code) { InputContext_t *pContext = GetInputContext( m_hContext ); pContext->_mouseDoublePressed[code]=1; if ( pContext->_mouseCapture && IsChildOfModalPanel((VPANEL)pContext->_mouseCapture)) { // send the message to the panel the mouse is over iff it's a child of the panel with mouse capture if ( pContext->_mouseOver && pContext->_mouseOver != pContext->_mouseCapture && pContext->_mouseOver->HasParent(pContext->_mouseCapture) ) { ivgui()->PostMessage((VPANEL)pContext->_mouseOver, new KeyValues("MouseDoublePressed", "code", code), NULL); } // the panel with mouse capture gets all messages ivgui()->PostMessage((VPANEL)pContext->_mouseCapture, new KeyValues("MouseDoublePressed", "code", code), NULL); } else if ( (pContext->_mouseFocus != NULL) && IsChildOfModalPanel((VPANEL)pContext->_mouseFocus)) { //tell the panel with the mouseFocus that the mouse was double presssed ivgui()->PostMessage((VPANEL)pContext->_mouseFocus, new KeyValues("MouseDoublePressed", "code", code), NULL); } // check if we are in modal state, // and if we are make sure this panel is a child of us. if (IsChildOfModalPanel((VPANEL)pContext->_mouseOver)) { surface()->SetTopLevelFocus((VPANEL)pContext->_mouseOver); } } void CInputWin32::InternalMouseReleased(MouseCode code) { InputContext_t *pContext = GetInputContext( m_hContext ); //set mouse state pContext->_mouseReleased[code] = 1; pContext->_mouseDown[code] = 0; if (pContext->_mouseCapture && IsChildOfModalPanel((VPANEL)pContext->_mouseCapture)) { // send the message to the panel the mouse is over iff it's a child of the panel with mouse capture if (pContext->_mouseOver && pContext->_mouseOver != pContext->_mouseCapture && pContext->_mouseOver->HasParent(pContext->_mouseCapture)) { ivgui()->PostMessage((VPANEL)pContext->_mouseOver, new KeyValues("MouseReleased", "code", code), NULL ); } // the panel with mouse capture gets all messages ivgui()->PostMessage((VPANEL)pContext->_mouseCapture, new KeyValues("MouseReleased", "code", code), NULL ); } else if ((pContext->_mouseFocus != NULL) && IsChildOfModalPanel((VPANEL)pContext->_mouseFocus)) { //tell the panel with the mouseFocus that the mouse was release ivgui()->PostMessage((VPANEL)pContext->_mouseFocus, new KeyValues("MouseReleased", "code", code), NULL ); } } void CInputWin32::InternalMouseWheeled(int delta) { InputContext_t *pContext = GetInputContext( m_hContext ); if ((pContext->_mouseFocus != NULL) && IsChildOfModalPanel((VPANEL)pContext->_mouseFocus)) { // the mouseWheel works with the mouseFocus, not the keyFocus ivgui()->PostMessage((VPANEL)pContext->_mouseFocus, new KeyValues("MouseWheeled", "delta", delta), NULL); } } void CInputWin32::InternalKeyCodePressed(KeyCode code) { InputContext_t *pContext = GetInputContext( m_hContext ); // mask out bogus keys if (code < 0 || code >= KEY_LAST) return; //set key state pContext->_keyPressed[code]=1; pContext->_keyDown[code]=1; PostKeyMessage(new KeyValues("KeyCodePressed", "code", code)); // get the states of CAPSLOCK, NUMLOCK, SCROLLLOCK keys UpdateToggleButtonState(); } void CInputWin32::InternalKeyCodeTyped(KeyCode code) { InputContext_t *pContext = GetInputContext( m_hContext ); // mask out bogus keys if (code < 0 || code >= KEY_LAST) return; // set key state pContext->_keyTyped[code]=1; // tell the current focused panel that a key was typed PostKeyMessage(new KeyValues("KeyCodeTyped", "code", code)); } void CInputWin32::InternalKeyTyped(wchar_t unichar) { InputContext_t *pContext = GetInputContext( m_hContext ); // set key state pContext->_keyTyped[unichar]=1; // tell the current focused panel that a key was typed PostKeyMessage(new KeyValues("KeyTyped", "unichar", unichar)); } void CInputWin32::InternalKeyCodeReleased(KeyCode code) { // mask out bogus keys if (code < 0 || code >= KEY_LAST) return; InputContext_t *pContext = GetInputContext( m_hContext ); // set key state pContext->_keyReleased[code]=1; pContext->_keyDown[code]=0; PostKeyMessage(new KeyValues("KeyCodeReleased", "code", code)); } //----------------------------------------------------------------------------- // Purpose: posts a message to the key focus if it's valid //----------------------------------------------------------------------------- void CInputWin32::PostKeyMessage(KeyValues *message) { InputContext_t *pContext = GetInputContext( m_hContext ); if( (pContext->_keyFocus!= NULL) && IsChildOfModalPanel((VPANEL)pContext->_keyFocus)) { //tell the current focused panel that a key was released ivgui()->PostMessage((VPANEL)pContext->_keyFocus, message, NULL ); } else { message->deleteThis(); } } VPANEL CInputWin32::GetAppModalSurface() { return (VPANEL)m_DefaultInputContext._appModalPanel; } void CInputWin32::SetAppModalSurface(VPANEL panel) { m_DefaultInputContext._appModalPanel = (VPanel *)panel; } void CInputWin32::ReleaseAppModalSurface() { m_DefaultInputContext._appModalPanel = NULL; }
[ "houontherun@gmail.com" ]
houontherun@gmail.com
1b7582cd534ccb7da70a70f784d3917eef3960c5
ee2c15d82ff596f4ca9eda408f8e096b787f0d48
/lec_05/checkprime_using_function.cpp
ebba3297741d560dfbe09c658f2dee783e1a2f7d
[]
no_license
sainimohit23/algorithms
1bbfee3bd4d1049b18425bf0d86ecaacd4c43ea0
911986abe015f7518ef169a5866b1058c7d41d4f
refs/heads/master
2022-11-13T17:40:06.128838
2020-06-30T17:35:35
2020-06-30T17:35:35
268,071,412
1
0
null
null
null
null
UTF-8
C++
false
false
337
cpp
#include <iostream> using namespace std; bool chkprime(int n); int main(){ int num; cin>>num; bool isprime= chkprime(num); if(isprime==false){ cout<<"not prime\n"; } else{ cout<<"prime\n"; } return 0; } bool chkprime(int n){ int i=2; while(i<n){ if(n%i==0){ return false; } i++; } return true; }
[ "sainimohit23@gmail.com" ]
sainimohit23@gmail.com
328ba2380f884ac74b480a26447e81c9ffab3fec
a68823773e764142c7b5c69f31bf2f916ca02c5f
/Code/PostWidgets/RealTimeMonitor.cpp
22f9945bc23239a8a5f721724582dc2d6d5c6431
[ "BSD-3-Clause" ]
permissive
hh-wu/FastCAE-linux
0a4b8ac6e1535a43f4047027cb2e01d5f2816f2d
4ab6f653e5251acfd707e678bd63437666b3900b
refs/heads/main
2023-06-16T13:43:56.204083
2021-07-12T16:20:39
2021-07-12T16:20:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,116
cpp
#include "RealTimeMonitor.h" #include <QTimer> #include <QFileInfo> #include <QDebug> namespace Post { RealTimeMonitor::RealTimeMonitor() { _timer = new QTimer; connect(_timer, SIGNAL(timeout()), this, SLOT(onTimeout())); } RealTimeMonitor::~RealTimeMonitor() { if (_timer) delete _timer; } void RealTimeMonitor::appendFile(const QString& file) { QDateTime time = QDateTime::currentDateTime(); _fileTimeHash[file] = time; } void RealTimeMonitor::setTimeStep(int t) { _timeStep = t; if (_timer) _timer->setInterval(t); } void RealTimeMonitor::onTimeout() { QList<QString> files = _fileTimeHash.keys(); const int n = files.size(); for (int i = 0; i < n; ++i) { QString f = files.at(i); QFileInfo file(f); if (!file.exists()) continue;; QDateTime lastmodify = file.lastModified(); if (lastmodify != _fileTimeHash.value(f)) { _fileTimeHash[f] = lastmodify; emit fileChanged(f); } } } void RealTimeMonitor::run() { _timer->start(); } void RealTimeMonitor::stop() { _timer->stop(); } }
[ "1229331300@qq.com" ]
1229331300@qq.com
c566daea3fd094c11b4a928a8bddb8e7ffdc68cf
fb7e0cc237263ba5a4e3e59a6764e1f7a5cf6a29
/BST.cpp
f940aa3c495f6c2e2916a9aa81e8bcd76ea60a08
[]
no_license
erik-slack/Custom-Binary-Search-Tree-BST-
e1174162f710c7abf60de985ce2ab92c79501a4d
0df28c74b488bebda0eca8a7910483bda9ed48f0
refs/heads/master
2021-01-01T17:36:47.597915
2014-11-18T16:07:09
2014-11-18T16:07:09
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,563
cpp
#include "BST.h" using namespace std; BST::BST() { root = NULL; } BST::~BST() { clear(); root = NULL; } /* * Returns the root node for this tree * * @return the root node for this tree. */ Node* BST::getRootNode(){ return root; } /* * Attempts to add the given int to the BST tree * * @return true if added * @return false if unsuccessful (i.e. the int is already in tree) */ bool BST::add(int data){ bool was_added = false; if (root == NULL){ root = new Node; root->data = data; was_added = true; } else { if (contains(data, root) == NULL){ root = recursiveAdd(data, root); was_added = true; } else { was_added = false; } } return was_added; } Node* BST::recursiveAdd(int data, Node* current_search){ if (current_search == NULL){ Node* location_added = new Node; location_added->data = data; return location_added; } if (data > current_search->data){ current_search->right_child = recursiveAdd(data, current_search->right_child); } else { current_search->left_child = recursiveAdd(data, current_search->left_child); } return current_search; } Node* BST::contains(int data, Node* current_search){ if (current_search == NULL){return NULL;} if (current_search->data == data){ return current_search; } else if (current_search->data < data){ // && current_search->right_child != NULL return contains(data, current_search->right_child); } else if (current_search->data > data){ return contains(data, current_search->left_child); } return current_search; } void BST::print(Node* current_print){ if (current_print == NULL){return;} if(current_print->left_child == NULL){ } else { cout << current_print->left_child->data; } cout << " and right child = "; if(current_print->right_child == NULL){ cout << "NULL"; } else { cout << current_print->right_child->data; } cout << endl; print(current_print->right_child); print(current_print->left_child); } /* * Attempts to remove the given int from the BST tree * * @return true if successfully removed * @return false if remove is unsuccessful(i.e. the int is not in the tree) */ bool BST::remove(int data){ bool was_removed = false; if (root == NULL){ // DO NOTHING } else if ((contains(data, root))->data == data){ root = recursiveRemove(data, root); was_removed = true; } else { // DO NOTHING } return was_removed; } Node* BST::recursiveRemove(int data, Node* current_search){ if (current_search == NULL){ return NULL; } else if (current_search->data < data){ current_search->right_child = recursiveRemove(data, current_search->right_child); return current_search; } else if (current_search->data > data){ current_search->left_child = recursiveRemove(data, current_search->left_child); return current_search; } else { if (current_search->left_child == NULL){ Node* temp = current_search->right_child; delete current_search; return temp; } else { current_search->left_child = IOP(current_search->left_child, current_search); return current_search; } } return current_search; } Node* BST::IOP(Node* current, Node* node_to_remove){ if (current->right_child == NULL){} if (current->right_child != NULL){ current->right_child = IOP(current->right_child, node_to_remove); return current; } else { node_to_remove->data = current->data; Node* temp = current->left_child; delete current; return temp; } } /* * Removes all nodes from the tree, resulting in an empty tree. */ void BST::clear(){ while (root != NULL){ remove(root->data); } }
[ "slack.erik@gmail.com" ]
slack.erik@gmail.com
a47e8bd932be5ad032bc401e10a50e72bf71aa31
98b02bfbd6a3f17464e4b2b98c9b3815f507899f
/Packages/ndt_feature_graph-SSRR2017/ndt_feature/src/publish_graph_message.cpp
81cb99240b6cd4f42a47206a288cd69948f67a2c
[]
no_license
RENyunfan/PointCloud
137d5fec61bbea8a6fc5a4884f8f510abe625633
7a09e43cfbc7adf591d6ed636570bf97cbb42cf7
refs/heads/master
2021-01-04T07:24:06.484559
2020-04-05T09:49:32
2020-04-05T09:49:32
240,445,854
1
1
null
null
null
null
UTF-8
C++
false
false
59,373
cpp
#include <valgrind/callgrind.h> // Test code to evaluate how laser2d features such as the FLIRT library could paly along with NDT. #include <ndt_feature/ndt_feature_fuser_hmt.h> //#include <ndt_fuser/ndt_fuser_hmt.h> #include <ros/ros.h> #include <pcl_conversions/pcl_conversions.h> #include "pcl/point_cloud.h" #include "sensor_msgs/PointCloud2.h" #include "pcl/io/pcd_io.h" #include <cstdio> #include <Eigen/Eigen> #include <fstream> #include "message_filters/subscriber.h" #include "tf/message_filter.h" #include <tf/transform_broadcaster.h> #include <tf_conversions/tf_eigen.h> #include <boost/circular_buffer.hpp> #include <laser_geometry/laser_geometry.h> #include <nav_msgs/Odometry.h> #include <nav_msgs/OccupancyGrid.h> #include <geometry_msgs/PoseStamped.h> #include <std_msgs/Bool.h> #include <message_filters/subscriber.h> #include <message_filters/synchronizer.h> #include <message_filters/sync_policies/approximate_time.h> #include <std_srvs/Empty.h> #include <flirtlib_ros/flirtlib.h> #include <flirtlib_ros/conversions.h> #include <ndt_feature/flirtlib_utils.h> #include <ndt_feature/conversions.h> #include <ndt_feature/ndt_feature_rviz.h> #include <ndt_feature/ndt_feature_fuser_hmt.h> #include <ndt_feature/ndt_feature_frame.h> #include <ndt_feature/ndt_offline_mapper.h> #include <ndt_feature/ndt_feature_graph_logger.hpp> #include <ndt_map/ndt_conversions.h> #include "ndt_feature/ndtgraph_conversion.h" #include <ndt_feature/ros_utils.h> // #include "NDTRegistrationGraph.hpp" // #include "ndt_feature/graph_visualizer.hpp" // #include "G2OGraphMaker.hpp" // #include "conversion.hpp" // #include "PriorAutoComplete.hpp" #include "ndt_feature/NDTGraphMsg.h" #include "ndt_feature/ndtgraph_conversion.h" #include <thread> #ifndef SYNC_FRAMES #define SYNC_FRAMES 20 #endif /** \brief A ROS node which implements an NDTFuser or NDTFuserHMT object * \author Todor Stoyanov * */ typedef message_filters::sync_policies::ApproximateTime<sensor_msgs::LaserScan, nav_msgs::Odometry> LaserOdomSync; typedef message_filters::sync_policies::ApproximateTime<sensor_msgs::LaserScan, geometry_msgs::PoseStamped> LaserPoseSync; typedef message_filters::sync_policies::ApproximateTime<sensor_msgs::PointCloud2, nav_msgs::Odometry> PointsOdomSync; typedef message_filters::sync_policies::ApproximateTime<sensor_msgs::PointCloud2, geometry_msgs::PoseStamped> PointsPoseSync; class NDTFeatureFuserNode { protected: ndt_feature::NDTGraphMsg graphmsg; // ndt_feature::G2OGraphMarker _g2o_graph; // ndt_feature::G2OGraphMarker _g2o_graph_linked; // ndt_feature::G2OGraphMarker _g2o_graph_linked_oriented; // ndt_feature::G2OGraphMarker _g2o_graph_no_prior; // ndt_feature::PriorAutoComplete _priorAutoComplete; // Our NodeHandle ros::NodeHandle nh_; message_filters::Subscriber<sensor_msgs::PointCloud2> *points2_sub_; message_filters::Subscriber<sensor_msgs::LaserScan> *laser_sub_; message_filters::Subscriber<nav_msgs::Odometry> *odom_sub_; ros::Subscriber gt_sub; ros::Subscriber optimize_sub; ros::Subscriber convert_sub; // Components for publishing tf::TransformBroadcaster tf_; ros::Publisher pointcloud_pub_; ros::Publisher pointcloud2_pub_; ros::Publisher fuser_odom_pub_, fuser_pub_; ros::Publisher _marker_pub_graph; ros::Publisher _marker_pub_graph_odom; ros::Publisher _last_ndtmap; ros::Publisher _ndt_graph_pub; Eigen::Affine3d pose_, T, sensor_pose_; tf::TransformListener listener; unsigned int nb_added_clouds_; double varz; boost::mutex m, message_m; ndt_feature::NDTFeatureFuserHMT *fuser; ndt_feature::NDTFeatureGraphLogger *graph; std::string points_topic, laser_topic, map_dir, map_name, odometry_topic, world_frame, robot_frame, sensor_frame, fuser_frame, init_pose_frame, gt_topic, gt_frame; double size_x, size_y, size_z, resolution, sensor_range, min_laser_range_; bool visualize, match2D, matchLaser, beHMT, useOdometry, plotGTTrack, initPoseFromGT, initPoseFromTF, initPoseSet; bool offline; int offline_nb_readings; double min_incr_dist, min_incr_rot; std::vector<ndt_feature::NDTFeatureFrame> offline_frames; int offline_ctr; std::vector<std::pair<size_t, size_t> > offline_matches; double pose_init_x,pose_init_y,pose_init_z, pose_init_r,pose_init_p,pose_init_t; double sensor_pose_x,sensor_pose_y,sensor_pose_z, sensor_pose_r,sensor_pose_p,sensor_pose_t; laser_geometry::LaserProjection projector_; message_filters::Synchronizer< LaserOdomSync > *sync_lo_; message_filters::Synchronizer< LaserPoseSync > *sync_lp_; message_filters::Synchronizer< PointsOdomSync > *sync_po_; message_filters::Synchronizer< PointsPoseSync > *sync_pp_; ros::ServiceServer save_map_; ros::Publisher marker_pub_; ros::Publisher map_pub_; ros::Publisher map_publisher_; Eigen::Affine3d last_odom, this_odom, Todom; // Flirtlib boost::shared_ptr<SimpleMinMaxPeakFinder> peak_finder_; boost::shared_ptr<HistogramDistance<double> > histogram_dist_; boost::shared_ptr<Detector> detector_; boost::shared_ptr<DescriptorGenerator> descriptor_; bool use_graph_; double occ_map_resolution_; bool do_pub_occ_map_; bool do_pub_debug_markers_; bool do_pub_visualization_clouds_; bool do_pub_ndtmap_marker_; bool skip_features_; std::string tf_odom_frame_; std::ofstream gt_file_; std::ofstream est_file_; int scan_counter_; int drop_scan_nb_; // Separate thread for publishing visualization markers. ros::Timer heartbeat_slow_visualization_; ros::Time frameTime_; int seq_odom_fuser_; bool clear_odometry_estimate_; int _count_of_node; //RegistrationGraph from betterGraph Library // ndt_feature::NDTFeatureRegistrationGraph _malcolm_graph; // ndt_feature::GraphVisualizer _gvisu; // ndt_feature::G2OGraphOptimization _graph_2_g2o; public: // Constructor NDTFeatureFuserNode(ros::NodeHandle param_nh) : // _g2o_graph(g2o::SE2(0.2, 0.1, -0.1), //sensor offset // Eigen::Vector2d(0.0005, 0.0001), //Robot translation noise // DEG2RAD(2.), //Rotation noise for robot // Eigen::Vector2d(0.0005, 0.0005), //Landmarks noise // Eigen::Vector2d(1, 0.001), //Prior noise // Eigen::Vector2d(0.2, 0.2)), //Link noise, // // _sensorOffsetTransf(0.2, 0.1, -0.1), // // _g2o_graph_linked(g2o::SE2(0.2, 0.1, -0.1), //sensor offset // Eigen::Vector2d(0.0005, 0.0001), //Robot translation noise // DEG2RAD(2.), //Rotation noise for robot // Eigen::Vector2d(0.0005, 0.0005), //Landmarks noise // Eigen::Vector2d(1, 0.001), //Prior noise // Eigen::Vector2d(0.2, 0.2)), //Link noise, // // _g2o_graph_linked_oriented(g2o::SE2(0.2, 0.1, -0.1), //sensor offset // Eigen::Vector2d(0.0005, 0.0001), //Robot translation noise // DEG2RAD(2.), //Rotation noise for robot // Eigen::Vector2d(0.0005, 0.0005), //Landmarks noise // Eigen::Vector2d(1, 0.001), //Prior noise // Eigen::Vector2d(0.2, 0.2)), //Link noise, // // _g2o_graph_no_prior(g2o::SE2(0.2, 0.1, -0.1), //sensor offset // Eigen::Vector2d(0.0005, 0.0001), //Robot translation noise // DEG2RAD(2.), //Rotation noise for robot // Eigen::Vector2d(0.0005, 0.0005), //Landmarks noise // Eigen::Vector2d(1, 0.001), //Prior noise // Eigen::Vector2d(0.2, 0.2)), //Link noise, nb_added_clouds_(0), peak_finder_(ndt_feature::createPeakFinder()), histogram_dist_(new SymmetricChi2Distance<double>()), detector_(ndt_feature::createDetector(peak_finder_.get())), descriptor_(ndt_feature::createDescriptor(histogram_dist_.get())), _count_of_node(0) { std::string file = "/home/malcolm/Documents/map.jpg"; // _priorAutoComplete.extractCornerPrior(file); // _priorAutoComplete.transformOntoSLAM(); // // _priorAutoComplete.transformOntoSLAM(); // // _priorAutoComplete.createGraph(*graph, _g2o_graph); // // std::string file_out = "/home/malcolm/ACG_folder/OLDPRIOR_"; // std::ostringstream convert; // stream used for the conversion // // convert << graph->getNbNodes(); // file_out = file_out + convert.str(); // file_out = file_out + "nodes.g2o"; // _g2o_graph.save(file_out); // std::cout << "saved to " << file_out << std::endl; // exit(0); seq_odom_fuser_ = 0; std::cout << "start added cloud " << nb_added_clouds_ << std::endl; ///topic to wait for point clouds, if available param_nh.param<std::string>("points_topic",points_topic,"points"); ///topic to wait for laser scan messages, if available param_nh.param<std::string>("laser_topic",laser_topic,"laser_scan"); ///if using the HMT fuser, NDT maps are saved in this directory. ///a word of warning: if you run multiple times with the same directory, ///the old maps are loaded automatically param_nh.param<std::string>("map_directory",map_dir,"map"); param_nh.param<std::string>("map_name_prefix",map_name,""); ///initial pose of the vehicle with respect to the map param_nh.param("pose_init_x",pose_init_x,0.); param_nh.param("pose_init_y",pose_init_y,0.); param_nh.param("pose_init_z",pose_init_z,0.); param_nh.param("pose_init_r",pose_init_r,0.); param_nh.param("pose_init_p",pose_init_p,0.); param_nh.param("pose_init_t",pose_init_t,0.); ///pose of the sensor with respect to the vehicle odometry frame param_nh.param("sensor_pose_x",sensor_pose_x,0.); param_nh.param("sensor_pose_y",sensor_pose_y,0.); param_nh.param("sensor_pose_z",sensor_pose_z,0.); param_nh.param("sensor_pose_r",sensor_pose_r,0.); param_nh.param("sensor_pose_p",sensor_pose_p,0.); param_nh.param("sensor_pose_t",sensor_pose_t,0.); ///size of the map in x/y/z. if using HMT, this is the size of the central tile param_nh.param("size_x_meters",size_x,100.); param_nh.param("size_y_meters",size_y,100.); param_nh.param("size_z_meters",size_z,10.); ///range to cutoff sensor measurements param_nh.param("sensor_range",sensor_range,20.); ///range to cutoff sensor measurements param_nh.param("min_laser_range",min_laser_range_,0.1); //map resolution param_nh.param("resolution",resolution,0.50); param_nh.param("laser_variance_z",varz,resolution/4); ///visualize in a local window param_nh.param("visualize",visualize,true); ///only mathc with 3dof param_nh.param("match2D",match2D,true); ///use HMT grid or simple grid. param_nh.param("beHMT",beHMT,false); ///use standard odometry messages for initial guess param_nh.param("useOdometry",useOdometry, false); ///topic to wait for laser scan messages, if available param_nh.param<std::string>("odometry_topic",odometry_topic,"odometry"); ///if we want to compare to a ground truth topic param_nh.param("plotGTTrack",plotGTTrack,false); param_nh.param<std::string>("gt_topic",gt_topic,"groundtruth"); ///if we want to get the initial pose of the vehicle relative to a different frame param_nh.param("initPoseFromGT",initPoseFromGT,false); //get it from TF? param_nh.param("initPoseFromTF",initPoseFromTF,false); //the frame to initialize to param_nh.param<std::string>("gt_frame",gt_frame,std::string("")); param_nh.param<std::string>("robot_frame",robot_frame,"/base_link"); //The sensor frame to initialize the fuser to param_nh.param<std::string>("sensor_frame",sensor_frame,"/laser_frame"); //the world frame param_nh.param<std::string>("world_frame",world_frame,"/world"); //our frame param_nh.param<std::string>("fuser_frame",fuser_frame,"/fuser"); param_nh.param<std::string>("tf_odom_frame", tf_odom_frame_, "/odom_base_link"); ///enable for LaserScan message input param_nh.param("matchLaser",matchLaser, true); param_nh.param<int>("offline_nb_readings", offline_nb_readings, 0); param_nh.param<double>("min_incr_dist", min_incr_dist, 0.02); param_nh.param<double>("min_incr_rot", min_incr_rot, 0.02); param_nh.param<bool>("skip_features", skip_features_, false); ndt_feature::NDTFeatureFuserHMT::Params fuser_params; param_nh.param<bool>("fuser_useNDT", fuser_params.useNDT, true); param_nh.param<bool>("fuser_useFeat", fuser_params.useFeat, true); param_nh.param<bool>("fuser_useOdom", fuser_params.useOdom, true); param_nh.param<int>("fuser_neighbours", fuser_params.neighbours, 2); param_nh.param<bool>("fuser_stepcontrol", fuser_params.stepcontrol, true); param_nh.param<int>("fuser_ITR_MAX", fuser_params.ITR_MAX, 30); param_nh.param<double>("fuser_DELTA_SCORE", fuser_params.DELTA_SCORE, 0.0001); param_nh.param<bool>("fuser_globalTransf", fuser_params.globalTransf, true); param_nh.param<bool>("fuser_loadCentroid", fuser_params.loadCentroid, true); param_nh.param<bool>("fuser_forceOdomAsEst", fuser_params.forceOdomAsEst, false); param_nh.param<bool>("fuser_visualizeLocalCloud", fuser_params.visualizeLocalCloud, false); param_nh.param<bool>("fuser_fusion2d", fuser_params.fusion2d, false); param_nh.param<bool>("fuser_allMatchesValid", fuser_params.allMatchesValid, false); param_nh.param<bool>("fuser_discardCells", fuser_params.discardCells, false); // param_nh.param<bool>("fuser_optimizeOnlyYaw", fuser_params.optimizeOnlyYaw, false); param_nh.param<bool>("fuser_computeCov", fuser_params.computeCov, true); param_nh.param<bool>("fuser_stepControlFusion", fuser_params.stepControlFusion, true); param_nh.param<bool>("fuser_useTikhonovRegularization", fuser_params.useTikhonovRegularization, true); param_nh.param<bool>("use_graph", use_graph_, true); ndt_feature::NDTFeatureGraph::Params graph_params; param_nh.param<double>("graph_newNodeTranslDist", graph_params.newNodeTranslDist, 10.); param_nh.param<bool>("graph_storePtsInNodes", graph_params.storePtsInNodes, true); param_nh.param<int>("graph_storePtsInNodesIncr", graph_params.storePtsInNodesIncr, 2); param_nh.param<bool>("graph_popNodes", graph_params.popNodes, false); param_nh.param<double>("occ_map_resolution", occ_map_resolution_, 1.); param_nh.param<bool>("do_pub_occ_map", do_pub_occ_map_, false); param_nh.param<bool>("do_pub_debug_markers", do_pub_debug_markers_, false); param_nh.param<bool>("do_pub_visualization_clouds", do_pub_visualization_clouds_, false); param_nh.param<bool>("do_pub_ndtmap_marker", do_pub_ndtmap_marker_, false); scan_counter_ = 0; param_nh.param<int>("drop_scan_nb", drop_scan_nb_, 0); param_nh.param<bool>("clear_odometry_estimate", clear_odometry_estimate_, false); ndt_feature::MotionModel2d::Params motion_params; param_nh.param<double>("motion_params_Cd", motion_params.Cd, 0.005); param_nh.param<double>("motion_params_Ct", motion_params.Ct, 0.01); param_nh.param<double>("motion_params_Dd", motion_params.Dd, 0.001); param_nh.param<double>("motion_params_Dt", motion_params.Dt, 0.01); param_nh.param<double>("motion_params_Td", motion_params.Td, 0.001); param_nh.param<double>("motion_params_Tt", motion_params.Tt, 0.005); // To be able to use the evaluation scripts. std::string gt_filename, est_filename; param_nh.param<std::string>("output_gt_file", gt_filename, std::string("")); param_nh.param<std::string>("output_est_file", est_filename, std::string("")); if (gt_filename == std::string("")) { gt_filename = std::string("gt_pose") + fuser_params.getDescString() + std::string(".txt"); } if (est_filename == std::string("")) { est_filename = std::string("est_pose") + fuser_params.getDescString() + std::string(".txt"); } if (gt_filename != std::string("") && gt_frame != std::string("")) { gt_file_.open(gt_filename.c_str()); } if (est_filename != std::string("")) { est_file_.open(est_filename.c_str()); } if (!gt_file_.is_open() || !est_file_.is_open()) { ROS_ERROR_STREAM("Failed to open : " << gt_filename << " || " << est_filename); } offline = false; if (offline_nb_readings > 0) offline = true; offline_ctr = 0; pose_ = Eigen::Translation<double,3>(pose_init_x,pose_init_y,pose_init_z)* Eigen::AngleAxis<double>(pose_init_r,Eigen::Vector3d::UnitX()) * Eigen::AngleAxis<double>(pose_init_p,Eigen::Vector3d::UnitY()) * Eigen::AngleAxis<double>(pose_init_t,Eigen::Vector3d::UnitZ()) ; sensor_pose_ = Eigen::Translation<double,3>(sensor_pose_x,sensor_pose_y,sensor_pose_z)* Eigen::AngleAxis<double>(sensor_pose_r,Eigen::Vector3d::UnitX()) * Eigen::AngleAxis<double>(sensor_pose_p,Eigen::Vector3d::UnitY()) * Eigen::AngleAxis<double>(sensor_pose_t,Eigen::Vector3d::UnitZ()) ; if(matchLaser) match2D=true; // Instead of providing all params to the constructor (which we need to maintain later on... store all params in the Param class... fuser_params.resolution = resolution; fuser_params.map_size_x = size_x; fuser_params.map_size_y = size_y; fuser_params.map_size_z = size_z; fuser_params.sensor_range = sensor_range; fuser_params.prefix = map_name; fuser_params.beHMT = beHMT; fuser_params.hmt_map_dir = map_dir; std::cout << "fuser params: " << fuser_params << std::endl; std::cout << "motion_params: " << motion_params << std::endl; if (use_graph_) { std::cout << "graph_params: " << graph_params << std::endl; graph = new ndt_feature::NDTFeatureGraphLogger("/home/malcolm/Documents/log_fuser/log_fuser_graph_ndt_feature.txt", graph_params, fuser_params); std::cout << "Graph Param" << std::endl; graph_params.print(); std::cout << "Fuser Param" << std::endl; fuser_params.print(); // exit(0); std::cout << "graph created" << std::endl; graph->setSensorPose(sensor_pose_); graph->setMotionParams(motion_params); if(do_pub_visualization_clouds_){ graph->params_.storePtsInNodes = true; } } else { fuser = new ndt_feature::NDTFeatureFuserHMT(fuser_params); //resolution,size_x,size_y,size_z, sensor_range, visualize,match2D, false, false, 30, map_name, beHMT, map_dir, true); fuser->setSensorPose(sensor_pose_); fuser->setMotionParams(motion_params); } //Not laser scan if(!matchLaser) { exit(0); points2_sub_ = new message_filters::Subscriber<sensor_msgs::PointCloud2>(nh_,points_topic,1); if(useOdometry) { odom_sub_ = new message_filters::Subscriber<nav_msgs::Odometry>(nh_,odometry_topic,10); sync_po_ = new message_filters::Synchronizer< PointsOdomSync >(PointsOdomSync(SYNC_FRAMES), *points2_sub_, *odom_sub_); sync_po_->registerCallback(boost::bind(&NDTFeatureFuserNode::points2OdomCallback, this, _1, _2)); } else { points2_sub_->registerCallback(boost::bind( &NDTFeatureFuserNode::points2Callback, this, _1)); } } else { //queue was 2 at first laser_sub_ = new message_filters::Subscriber<sensor_msgs::LaserScan>(nh_,laser_topic,2); if(useOdometry) { odom_sub_ = new message_filters::Subscriber<nav_msgs::Odometry>(nh_,odometry_topic,10); sync_lo_ = new message_filters::Synchronizer< LaserOdomSync >(LaserOdomSync(SYNC_FRAMES), *laser_sub_, *odom_sub_); sync_lo_->registerCallback(boost::bind(&NDTFeatureFuserNode::laserOdomCallback, this, _1, _2)); } else { laser_sub_->registerCallback(boost::bind( &NDTFeatureFuserNode::laserCallback, this, _1)); } } save_map_ = param_nh.advertiseService("save_map", &NDTFeatureFuserNode::save_map_callback, this); if(plotGTTrack) { gt_sub = nh_.subscribe<nav_msgs::Odometry>(gt_topic,10,&NDTFeatureFuserNode::gt_callback, this); } initPoseSet = false; marker_pub_ = nh_.advertise<visualization_msgs::Marker>("visualization_marker", 3); map_pub_ = nh_.advertise<nav_msgs::OccupancyGrid>("map", 1000); pointcloud_pub_ = nh_.advertise<sensor_msgs::PointCloud2>("offline_map", 10); pointcloud2_pub_ = nh_.advertise<sensor_msgs::PointCloud2>("cloud", 10); fuser_pub_ = nh_.advertise<nav_msgs::Odometry>("fuser_est", 10); fuser_odom_pub_ = nh_.advertise<nav_msgs::Odometry>("fuser_odom", 10); map_publisher_=nh_.advertise<ndt_feature::NDTGraphMsg>("ndt_graph",10); _marker_pub_graph = nh_.advertise<visualization_msgs::Marker>("visualization_marker_graph", 10); _marker_pub_graph_odom= nh_.advertise<visualization_msgs::Marker>("visualization_marker_graph_odom", 10); _last_ndtmap = nh_.advertise<ndt_map::NDTMapMsg>("lastgraphmap", 10); _ndt_graph_pub = nh_.advertise<ndt_feature::NDTGraphMsg>("ndt_graph", 10); heartbeat_slow_visualization_ = nh_.createTimer(ros::Duration(5.0),&NDTFeatureFuserNode::publish_visualization_slow,this); Todom.setIdentity(); std::cout << "start added cloud and of init " << nb_added_clouds_ << std::endl; // optimize_sub = nh_.subscribe<std_msgs::Bool>("/optimize", 10, &NDTFeatureFuserNode::optimize, this); convert_sub = nh_.subscribe<std_msgs::Bool>("/convert", 10, &NDTFeatureFuserNode::convert, this); } ~NDTFeatureFuserNode() { std::cout << "DESTRUCTION" << std::endl; std::cout << "Extracting corners" << std::endl; // ROS_ERROR_STREAM("SAVING THE MAP"); graph->saveMap(); std::cout << "Map saved : " << graph->getNbNodes() << std::endl; //Copy graph // _g2o_graph.addRobotPoseAndOdometry(*graph); // _g2o_graph.addLandmarkAndObservation(*graph); // // // std::cout << "G2O MADE :)" << std::endl; // // // _g2o_graph.makeGraph(); // const std::string file = "AWESOME.g2o"; // _g2o_graph.save(file); std::cout << "DONE SAVING :)" << std::endl; // if(use_graph_){ // if (graph->wasInit() == true) { // // visualization_msgs::Marker origins; // visualization_msgs::Marker origins_odom; // ndt_map::NDTMapMsg mapmsg; // _gvisu.printAll(*graph, origins, origins_odom, mapmsg, "/world"); // _marker_pub_graph.publish(origins); // _marker_pub_graph_odom.publish(origins_odom); // _last_ndtmap.publish(mapmsg); // } // } // // // // if(use_graph_ == false){ // delete fuser; // } // else{ // delete graph; // } } ndt_feature::NDTFeatureGraph* getGraph(){ return graph;} void publish_visualization_slow(const ros::TimerEvent &event) { // std::cout << "DRAW" << std::endl; // // Add some drawing // if (use_graph_) // { // if (graph->wasInit()) { // // if (do_pub_debug_markers_) { // // Draw the debug stuff... // // ndt_feature::NDTFeatureFuserHMT* f = graph->getLastFeatureFuser(); // for (size_t i = 0; i < f->debug_markers_.size(); i++) { // f->debug_markers_[i].header.stamp = frameTime_; // marker_pub_.publish(f->debug_markers_[i]); // } // } // if (do_pub_ndtmap_marker_) // { // // visualization_msgs::Marker markers_ndt; // // ndt_visualisation::markerNDTCells2(*(graph->getLastFeatureFuser()->map), // // graph->getT(), 1, "nd_global_map_last", markers_ndt); // // marker_pub_.publish(markers_ndt); // // lslgeneric::NDTMap* map_moved = graph->getLastFeatureFuser()->map->pseudoTransformNDTMap(graph->getT()); // // marker_pub_.publish(ndt_visualisation::markerNDTCells(*(graph->getLastFeatureFuser()->map), 1, "nd_global_map_last")); // // marker_pub_.publish(ndt_visualisation::markerNDTCells(*(graph->getLastFeatureFuser()->map), graph->getT(), 1, "nd_global_map_last")); // // // // } // if (do_pub_occ_map_) { // // tf::TransformBroadcaster br; // // tf::Transform transform; // // if(graph->getNbNodes() >= 1){ // // for(int i = 0 ; i < graph->getNbNodes() ; ++i){ // // std::stringstream sstm; // // sstm << "ndt_map_graph_frame_" << i; // // tf::transformEigenToTF(graph->getNode(i).T, transform); // // br.sendTransform(tf::StampedTransform(transform, ros::Time::now(), world_frame, sstm.str() )); // // // // ndt_map::NDTMapMsg map_msg; // // lslgeneric::toMessage(graph->getMap(), map_msg, sstm.str() ); // // map_publisher_.publish(map_msg); // // // // } // // } // // // // ndt_feature::NDTGraphMsg graphmsg; // ndt_feature::NDTGraphToMsg(*graph, graphmsg, world_frame); // map_publisher_.publish(graphmsg); // // exit(0); // // nav_msgs::OccupancyGrid omap; // // auto cells = graph->getMap()->getAllCellsShared(); // auto mean1 = cells[0]->getCenter(); // // for(auto it = cells.begin() ; it != cells.end() ; ++it){ // auto mean = (*it)->getCenter(); // std::cout << "Mean : " << mean.x << " " << mean.y << " " << mean.z << std::endl; // std::cout << "HAs a gaussian ? " << (*it)->hasGaussian_ << std::endl; // bool test1 = (*it) == NULL; // std::cout << "Is cell in list NULL ? " << test1 << std::endl; // lslgeneric::NDTCell* celltest = NULL; // pcl::PointXYZ pt; // pt.x = mean.x; // pt.y = mean.y; // pt.z = mean.z; // graph->getMap()->getCellAtPoint(pt, celltest); // bool testest = celltest == (*it).get(); // std::cout << "SAME POINTER " << testest << " " << celltest << " " << (*it).get() << std::endl; // int indX,indY,indZ; // lslgeneric::NDTCell* cell = NULL; // auto lazy = dynamic_cast<lslgeneric::LazyGrid*>(graph->getMap()->getMyIndex()); // lazy->getIndexForPoint(pt,indX,indY,indZ); // // // std::cout << " index : " << indX << " " << indY << " " << indZ << std::endl; // // std::cout << " ondex : " << (*it)->index_test_x << " " << (*it)->index_test_y << " " << (*it)->index_test_z << std::endl; // // // lazy->getNDTCellAt(indX,indY,indZ, cell); // bool test = cell == NULL; // std::cout << "Is cell NULL ? " << test << std::endl; // } // // std::cout << std::endl << std::endl; // // // exit(0); // lslgeneric::toOccupancyGrid(graph->getMap(), omap, occ_map_resolution_, world_frame); // moveOccupancyMap(omap, graph->getT()); // map_pub_.publish(omap); // // std::cout << "LAST MEAN " << mean1 << std::endl; // ; // std::cout << "HAs a gaussian ? " << cells[0]->hasGaussian_ << std::endl; // bool testcell = cells[0] == NULL; // std::cout << "Is cell in list NULL ? " << testcell << std::endl; // lslgeneric::NDTCell* celltest = NULL; // pcl::PointXYZ pt; // pt.x = mean1.x; // pt.y = mean1.y; // pt.z = mean1.z; // auto lazyt = dynamic_cast<lslgeneric::LazyGrid*>(graph->getMap()->getMyIndex()); // int indX,indY,indZ; // lazyt->getIndexForPoint(pt,indX,indY,indZ); // std::cout << " index : " << indX << " " << indY << " " << indZ << std::endl; // // exit(0); // // ndt_map::NDTMapMsg map_msg; // // toMessage(graph->getMap(), map_msg, "/ndt_map_frame"); // // map_publisher_.publish(map_msg); // } // } // } // // else { // if (fuser->wasInit()) { // // if (do_pub_debug_markers_) { // for (size_t i = 0; i < fuser->debug_markers_.size(); i++) { // fuser->debug_markers_[i].header.stamp = frameTime_; // marker_pub_.publish(fuser->debug_markers_[i]); // } // } // if (do_pub_ndtmap_marker_) { // Eigen::Affine3d p; p.setIdentity(); // marker_pub_.publish(ndt_visualisation::markerNDTCells(*fuser->map, 1, "nd_global_map")); // } // if (do_pub_occ_map_) { // nav_msgs::OccupancyGrid omap; // lslgeneric::toOccupancyGrid(fuser->map, omap, occ_map_resolution_, world_frame); // map_pub_.publish(omap); // } // } // } // // // // Trying to draw the graph here // // // if(use_graph_){ // // if (graph->wasInit() == true && graph->getNbNodes() >= 6) { // // visualization_msgs::Marker origins; // // visualization_msgs::Marker origins_odom; // // ndt_map::NDTMapMsg mapmsg; // // std::cout << "print all " << std::endl; // // // // // // // // // CALLGRIND_START_INSTRUMENTATION; // // // CALLGRIND_TOGGLE_COLLECT; // // // // // // // // _gvisu.printAll(*graph, origins, origins_odom, mapmsg, "/world"); // // // // // CALLGRIND_TOGGLE_COLLECT; // // // CALLGRIND_STOP_INSTRUMENTATION; // // // // // // std::cout << "publishing " << std::endl; // // _marker_pub_graph.publish(origins); // // _marker_pub_graph_odom.publish(origins_odom); // // _last_ndtmap.publish(mapmsg); // // // // std::cout << "published " << std::endl; // // } // // } } void updateTF(){ std::cout<< "Updating the tf " << std::endl; if (nb_added_clouds_ == 0) { } else { ROS_INFO("UPDATE"); nb_added_clouds_++; if (use_graph_) { // std::cout << "Update with added cloud " << nb_added_clouds_ << std::endl; // assert(graph->getNbNodes() == nb_added_clouds_ - 1); pose_ = graph->getT(); // std::cout << "Graph update. Nb nof nodes : " << graph->getNbNodes() << std::endl; } else { // pose_ = fuser->getT(); } // Todom = Todom*Tmotion; } m.unlock(); if(graph->fullInit() == false){ // std::cout << "GRAPH NOT FULLY INIT " << std::endl; assert(graph->fullInit()); } // if (est_file_.is_open()) { // est_file_ << frameTime << " " << lslgeneric::transformToEvalString(pose_); // } tf::Transform transform; #if ROS_VERSION_MINIMUM(1,9,0) //groovy tf::transformEigenToTF(pose_, transform); #else //fuerte tf::TransformEigenToTF(pose_, transform); #endif // std::cout << "Send transform " << std::endl; tf_.sendTransform(tf::StampedTransform(transform, ros::Time::now(), world_frame, fuser_frame)); { std::cout << "PUblished fuser" << std::endl; nav_msgs::Odometry odom; tf::poseEigenToMsg(pose_, odom.pose.pose); odom.header.stamp = ros::Time::now(); odom.header.frame_id = world_frame; odom.header.seq = seq_odom_fuser_++; odom.child_frame_id = "fuser"; fuser_pub_.publish(odom); } { nav_msgs::Odometry odom; tf::poseEigenToMsg(Todom, odom.pose.pose); odom.header.stamp = ros::Time::now(); odom.header.frame_id = world_frame; odom.header.seq = seq_odom_fuser_++; odom.child_frame_id = "fuser_odom"; fuser_odom_pub_.publish(odom); } } void processFeatureFrame(pcl::PointCloud<pcl::PointXYZ> &cloud, const InterestPointVec& pts, Eigen::Affine3d Tmotion, const ros::Time &frameTime) { m.lock(); ROS_INFO("Process feature frame"); if (clear_odometry_estimate_) { Tmotion.setIdentity(); } // std::cout << "added cloud " << nb_added_clouds_ << std::endl; frameTime_ = frameTime; if (nb_added_clouds_ == 0) { ROS_INFO("initializing fuser map. Init pose from GT? %d, TF? %d", initPoseFromGT, initPoseFromTF); if(initPoseFromTF){ ROS_INFO("Init pose is (%lf,%lf,%lf) form tf", pose_.translation()(0), pose_.translation()(1), pose_.rotation().eulerAngles(0,1,2)(0)); if (use_graph_) { std::cout << "INIT " << nb_added_clouds_ << std::endl; //Better init maybe ? // _gvisu.setStart(pose_); ndt_feature::initSensorPose2D(*graph, robot_frame, sensor_frame); ndt_feature::initRobotPose2D(*graph, cloud, world_frame, robot_frame, pts); // std::cout << "Graph init. Nb nof nodes : " << graph->getNbNodes() << std::endl; // exit(0); } else { assert(true == false); //NEVER GET THERE fuser->initialize(pose_,cloud,pts); } } else{ if(initPoseFromGT) { //check if initial pose was set already if(!initPoseSet) { ROS_WARN("skipping frame, init pose not acquired yet!"); m.unlock(); return; } } pose_ = Tmotion; ROS_INFO("Init pose is (%lf,%lf,%lf)", pose_.translation()(0), pose_.translation()(1), pose_.rotation().eulerAngles(0,1,2)(0)); if (use_graph_) { std::cout << "INIT " << nb_added_clouds_ << std::endl; //Better init maybe ? // _gvisu.setStart(pose_); graph->initialize(pose_,cloud,pts); // std::cout << "Graph init. Nb nof nodes : " << graph->getNbNodes() << std::endl; // exit(0); } else { fuser->initialize(pose_,cloud,pts); } } nb_added_clouds_++; } else { ROS_INFO("UPDATE"); nb_added_clouds_++; if (use_graph_) { // std::cout << "Update with added cloud " << nb_added_clouds_ << std::endl; // assert(graph->getNbNodes() == nb_added_clouds_ - 1); pose_ = graph->update(Tmotion,cloud,pts, frameTime); // std::cout << "Graph update. Nb nof nodes : " << graph->getNbNodes() << std::endl; } else { pose_ = fuser->update(Tmotion,cloud,pts); } Todom = Todom*Tmotion; } m.unlock(); if(graph->fullInit() == false){ // std::cout << "GRAPH NOT FULLY INIT " << std::endl; assert(graph->fullInit()); } if (est_file_.is_open()) { est_file_ << frameTime << " " << ndt_feature::transformToEvalString(pose_); } tf::Transform transform; #if ROS_VERSION_MINIMUM(1,9,0) //groovy tf::transformEigenToTF(pose_, transform); #else //fuerte tf::TransformEigenToTF(pose_, transform); #endif // std::cout << "Send transform " << std::endl; tf_.sendTransform(tf::StampedTransform(transform, frameTime, world_frame, fuser_frame)); { std::cout << "PUblished fuser" << std::endl; nav_msgs::Odometry odom; tf::poseEigenToMsg(pose_, odom.pose.pose); odom.header.stamp = frameTime; odom.header.frame_id = world_frame; odom.header.seq = seq_odom_fuser_++; odom.child_frame_id = "fuser"; fuser_pub_.publish(odom); } { nav_msgs::Odometry odom; tf::poseEigenToMsg(Todom, odom.pose.pose); odom.header.stamp = frameTime; odom.header.frame_id = world_frame; odom.header.seq = seq_odom_fuser_++; odom.child_frame_id = "fuser_odom"; fuser_odom_pub_.publish(odom); } //Marker print // if(use_graph_){ // if (graph->wasInit() == true) { // // visualization_msgs::Marker origins; // visualization_msgs::Marker origins_odom; // ndt_map::NDTMapMsg mapmsg; // _gvisu.printAll(*graph, origins, origins_odom, mapmsg, "/world"); // _marker_pub_graph.publish(origins); // _marker_pub_graph_odom.publish(origins_odom); // _last_ndtmap.publish(mapmsg); // // // if(graph->getNbNodes() == 6){ // // // _graph_2_g2o.updateGraph(*graph); // // // // // exit(0); // // // _graph_2_g2o.optimize(); // // // // // } // } // } //Only write the data we're not working on //Crash I don't know why // std::thread first(&NDTFeatureFuserNode::createGraphThread, this); // first.detach(); // createGraphThread(); if(_count_of_node != graph->getNbNodes()){ _count_of_node = graph->getNbNodes(); ndt_feature::NDTGraphMsg graphmsg; assert(world_frame != ""); std::cout << "World frame : " << world_frame << std::endl; assert(world_frame == "world"); ndt_feature::NDTGraphToMsg(*graph, graphmsg, world_frame); assert(graphmsg.header.frame_id != ""); _ndt_graph_pub.publish(graphmsg); std::cout << "Transform sent" << std::endl; } } void createGraphThread(){ if(graph->getNbNodes() >= 3 && _count_of_node != graph->getNbNodes()){ std::clock_t start; start = std::clock(); int i = 0; if(_count_of_node == 0) i = 0; else i = _count_of_node - 1; int end = graph->getNbNodes(); std::cout << "Go " << std::endl; for(i ; i < end - 1 ; ++i){ std::cout << "Transcribing the node "<< i << "\n"; ndt_feature::NDTNodeMsg nodemsg; ndt_feature::nodeToMsg(graph->getNode(i), nodemsg); graphmsg.nodes.push_back(nodemsg); } std::cout << end - 1 << " = " << graphmsg.nodes.size() << " count node " << _count_of_node << std::endl; assert(graphmsg.nodes.size() == end - 1); //No need to do the edges since this can be done later. tf::poseEigenToMsg (graph->sensor_pose_, graphmsg.sensor_pose_); tf::poseEigenToMsg (graph->Tnow, graphmsg.Tnow); graphmsg.distance_moved_in_last_node_ = graph->getDistanceTravelled(); // std::cout << ">Pushing message for " << graph->getNbNodes() << " and " << _count_of_node << std::endl; // ndt_feature::NDTGraphToMsg(*graph, graphmsg); _ndt_graph_pub.publish(graphmsg); // std::cout << "Created the graph" << std::endl; _count_of_node = end; std::cout << "Time: " << (std::clock() - start) / (double)(CLOCKS_PER_SEC / 1000) << " ms" << std::endl; std::ofstream myfile ("/home/malcolm/time.txt"); if (myfile.is_open()) { myfile << end; myfile << (std::clock() - start) / (double)(CLOCKS_PER_SEC / 1000); myfile.close(); } } } bool save_map_callback(std_srvs::Empty::Request &req, std_srvs::Empty::Response &res ) { std::cout << "SAVE MAP" << std::endl; bool ret = false; ROS_INFO("Saving current map to map directory %s", map_dir.c_str()); m.lock(); if (use_graph_) { ret = graph->saveMap(); } else { ret = fuser->saveMap(); } m.unlock(); return ret; } void convert(const std_msgs::Bool::ConstPtr& bool_msg){ if(graph->getNbNodes() >1){ std::vector<ndt_feature::NDTFeatureLink> links = graph->getIncrementalLinks(); ndt_feature::NDTEdgeMsg edgemsg; ndt_feature::NDTFeatureLink edge = links[0]; std::cout << "EDGE to msg" << std::endl; ndt_feature::edgeToMsg(edge, edgemsg); std::cout << "MSG to EDGE" << std::endl; ndt_feature::NDTFeatureLink edge2; ndt_feature::msgToEdge(edgemsg, edge2); std::cout << "Done" << std::endl; assert(edge.cov == edge2.cov); assert(edge.cov_3d == edge2.cov_3d); } ndt_feature::NDTNodeMsg nodemsg; ndt_feature::NDTFeatureNode node = graph->getNode(0); std::cout << "GETTING THE NODE TO WORK" << node.map->Tnow.matrix() << std::endl; // node.Tlocal_odom.matrix() << 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16; std::string frame; std::cout << "NODE to msg" << std::endl; ndt_feature::nodeToMsg(node, nodemsg); std::cout << "MSG to node" << std::endl; ndt_feature::NDTFeatureNode node2; node2.map = new ndt_feature::NDTFeatureFuserHMT( ndt_feature::NDTFeatureFuserHMT::Params() ); std::cout << "GETTING THE NODE TO WORK" << node.map->Tnow.matrix() << std::endl; ndt_feature::msgToNode(nodemsg, node2, frame); std::cout << "Done" << std::endl; // assert(node.cov == node2.cov); // if(node.getFuser().getCov() != node.getFuser().getCov()){ // std::cout << node.getFuser().getCov() << " == " << node.getFuser().getCov() << std::endl; // } // // assert(node.getFuser().getCov() == node.getFuser().getCov() ); // // // if(node.getTLocalOdom().matrix() != node2.getTLocalOdom().matrix()){ // std::cout << node.getTLocalOdom().matrix() << " == " << node2.getTLocalOdom().matrix() << std::endl; // } // assert(node.getTLocalOdom().matrix() == node2.getTLocalOdom().matrix()); ndt_feature::NDTGraphMsg graphmsg; assert(world_frame != ""); assert(world_frame == "/world"); ndt_feature::NDTGraphToMsg(*graph, graphmsg, world_frame); assert(graphmsg.header.frame_id != ""); _ndt_graph_pub.publish(graphmsg); } // void optimize(const std_msgs::Bool::ConstPtr& bool_msg){ // // // std::cout << "OPTIMIZE" << std::endl; // /**Get corner from prior**/ // // std::string file = "/home/malcolm/Document/map.jpg"; // // _priorAutoComplete.extractCornerPrior(file); // _priorAutoComplete.extractCornerNDT(*graph); // // _priorAutoComplete.findScale(); // _priorAutoComplete.transformOntoSLAM(); // // _priorAutoComplete.createGraph(*graph, _g2o_graph); // _priorAutoComplete.createGraphLinked(*graph, _g2o_graph_linked); // _priorAutoComplete.createGraphLinkedOriented(*graph, _g2o_graph_linked_oriented); // _priorAutoComplete.createGraphLinkedOrientedNoPrior(*graph, _g2o_graph_no_prior); // // // _g2o_graph_no_prior.addRobotPoseAndOdometry(*graph); // //Add landmark and observations // // _g2o_graph_no_prior.addLandmarkAndObservation(*graph); // // _g2o_graph_no_prior.makeGraphAllOriented(); // // // // std::string file_out = "/home/malcolm/ACG_folder/AWESOME_manual_"; // std::ostringstream convert; // stream used for the conversion // convert << graph->getNbNodes(); // file_out = file_out + convert.str(); // file_out = file_out + "nodes.g2o"; // _g2o_graph.save(file_out); // std::cout << "saved to " << file_out << std::endl; // // std::string file_out_linked = "/home/malcolm/ACG_folder/AWESOME_manual_linked_"; // file_out_linked = file_out_linked + convert.str(); // file_out_linked = file_out_linked + "nodes.g2o"; // _g2o_graph_linked.save(file_out_linked); // std::cout << "saved to " << file_out_linked << std::endl; // // std::string file_out_linked_oritented = "/home/malcolm/ACG_folder/AWESOME_manual_linked_oriented_"; // file_out_linked_oritented = file_out_linked_oritented + convert.str(); // file_out_linked_oritented = file_out_linked_oritented + "nodes.g2o"; // _g2o_graph_linked_oriented.save(file_out_linked_oritented); // std::cout << "saved to " << file_out_linked_oritented << std::endl; // // std::string file_out_linked_oritented_no_prior = "/home/malcolm/ACG_folder/AWESOME_manual_linked_oriented_no_prior"; // file_out_linked_oritented_no_prior = file_out_linked_oritented_no_prior + convert.str(); // file_out_linked_oritented_no_prior = file_out_linked_oritented_no_prior + "nodes.g2o"; // _g2o_graph_no_prior.save(file_out_linked_oritented_no_prior); // std::cout << "saved to " << file_out_linked_oritented_no_prior << std::endl; // // exit(0); // } // Callback void points2Callback(const sensor_msgs::PointCloud2::ConstPtr& msg_in) { std::cout << "POINT2CALLBACK" << std::endl; exit(0); ROS_INFO(":."); scan_counter_++; if (drop_scan_nb_ > 1) { if (scan_counter_ % drop_scan_nb_ == 0) { scan_counter_ = 0; return; } } pcl::PointCloud<pcl::PointXYZ> pcl_cloud; Eigen::Affine3d Tm; Eigen::Affine3d Tgt; ros::Time frame_time = msg_in->header.stamp; // assert(false); // The odometry that should be provided is in vehicle coordinates { tf::StampedTransform transform; try { listener.waitForTransform(world_frame, tf_odom_frame_, frame_time, ros::Duration(3.0)); listener.lookupTransform(world_frame, tf_odom_frame_, frame_time, transform); } catch (tf::TransformException ex){ ROS_ERROR("%s",ex.what()); return; } tf::transformTFToEigen( transform, this_odom); } if (nb_added_clouds_ == 0) { Tm.setIdentity(); } else { Tm = last_odom.inverse()*this_odom; if (Tm.translation().norm() < min_incr_dist /*0.02*/ && Tm.rotation().eulerAngles(0,1,2).norm() < min_incr_rot/*0.02*/) { message_m.unlock(); return; } } last_odom = this_odom; { InterestPointVec pts; pcl::fromROSMsg (*msg_in, pcl_cloud); this->processFeatureFrame(pcl_cloud,pts, Tm, frame_time); } ROS_INFO("_"); }; // Callback void points2OdomCallback(const sensor_msgs::PointCloud2::ConstPtr& msg_in, const nav_msgs::Odometry::ConstPtr& odo_in) { ROS_INFO(":."); std::cout << "POINT2ODOMCALLBACK" << std::endl; // Used for the Volvo bags (the TF there are using the GPS) Eigen::Quaterniond qd; sensor_msgs::PointCloud2 cloud; pcl::PointCloud<pcl::PointXYZ> pcl_cloud; Eigen::Affine3d Tm; ros::Time frame_time = msg_in->header.stamp; message_m.lock(); qd.x() = odo_in->pose.pose.orientation.x; qd.y() = odo_in->pose.pose.orientation.y; qd.z() = odo_in->pose.pose.orientation.z; qd.w() = odo_in->pose.pose.orientation.w; this_odom = Eigen::Translation3d (odo_in->pose.pose.position.x, odo_in->pose.pose.position.y,odo_in->pose.pose.position.z) * qd; if (nb_added_clouds_ == 0) { Tm.setIdentity(); } else { Tm = last_odom.inverse()*this_odom; if (Tm.translation().norm() < min_incr_dist /*0.02*/ && Tm.rotation().eulerAngles(0,1,2).norm() < min_incr_rot/*0.02*/) { message_m.unlock(); return; } } last_odom = this_odom; { InterestPointVec pts; pcl::fromROSMsg (*msg_in, pcl_cloud); this->processFeatureFrame(pcl_cloud,pts, Tm, frame_time); } message_m.unlock(); }; // Callback void laserCallback(const sensor_msgs::LaserScan::ConstPtr& msg_in) { ROS_INFO("laserCallback()"); // exit(0); // CALLGRIND_START_INSTRUMENTATION; // CALLGRIND_TOGGLE_COLLECT; // std::cout << "Laser Callback" << std::endl; std::cout << "added cloud " << nb_added_clouds_ << std::endl; sensor_msgs::PointCloud2 cloud; pcl::PointCloud<pcl::PointXYZ> pcl_cloud, pcl_cloud_unfiltered; Eigen::Affine3d Tm; Eigen::Affine3d Tgt; ros::Time frame_time = msg_in->header.stamp; // Use the TF to get the pose here... // Could be problematic with the approximate time? // Ask TF for the pose of the laser scan. // ROS_ERROR_STREAM("frame : " << tf_odom_frame_); // The odometry that should be provided is in vehicle coordinates - the /base_link { tf::StampedTransform transform; try { std::cout << "Getting stransfo " << world_frame << tf_odom_frame_ << " at " << frame_time << std::endl; listener.waitForTransform(world_frame, tf_odom_frame_, frame_time, ros::Duration(3.0)); std::cout << "out " << world_frame << tf_odom_frame_ << std::endl; listener.lookupTransform(world_frame, tf_odom_frame_, frame_time, transform); std::cout << "Getting stransfo " << world_frame << gt_frame << std::endl; } catch (tf::TransformException ex){ std::cout << "FUCK" << std::endl; ROS_ERROR("%s",ex.what()); return; } tf::transformTFToEigen( transform, this_odom); } // Ground truth std::cout << "gt ? " << gt_frame << std::endl; if (gt_frame != std::string("")) { tf::StampedTransform transform; try { std::cout << "Getting stransfo " << world_frame << gt_frame << std::endl; listener.waitForTransform(world_frame, gt_frame, /*"/world", "/state_base_link",*/ frame_time, ros::Duration(3.0)); std::cout << "Getting stransfo " << world_frame << gt_frame << std::endl; listener.lookupTransform(world_frame, gt_frame, /*"/world", "/state_base_link",*/ frame_time, transform); std::cout << "Getting stransfo " << world_frame << gt_frame << std::endl; } catch (tf::TransformException ex){ ROS_ERROR("%s",ex.what()); return; } tf::transformTFToEigen( transform, Tgt ); } // Need to get the incremental update. if (nb_added_clouds_ == 0) { std::cout << "TM" << std::endl; //Better init ? Tm = this_odom; // Tm.setIdentity(); } else { Tm = last_odom.inverse()*this_odom; if (Tm.translation().norm() < min_incr_dist /*0.02*/ && Tm.rotation().eulerAngles(0,1,2).norm() < min_incr_rot/*0.02*/) { updateTF(); message_m.unlock(); return; } } if (gt_file_.is_open()) { // gt_file_ << frame_time << " " << lslgeneric::transformToEvalString(Tgt); gt_file_ << frame_time << " " << ndt_feature::transformToEval2dString(Tgt); // ROS_INFO("tf transformed to gt_file_"); } last_odom = this_odom; projector_.projectLaser(*msg_in, cloud); message_m.unlock(); pcl::fromROSMsg (cloud, pcl_cloud_unfiltered); if (pcl_cloud_unfiltered.points.size() == 0) { ROS_ERROR("BAD LASER SCAN(!) - should never happen - check your driver / bag file"); } if(pcl_cloud_unfiltered.points.size () != pcl_cloud_unfiltered.width * pcl_cloud_unfiltered.height){ std::cout << "Weird cloud sizes. I don't know what's going on" << std::endl; } else{ ROS_ERROR("GOOD UNFILTERED SCAN"); // std::cout<< "GOOD UNFILTERED SCAN" << std::endl;std::cout << "Weird cloud sizes. I don't know what's going on:" << pcl_cloud_unfiltered.points.size () << " != " << pcl_cloud_unfiltered.width << " * " << pcl_cloud_unfiltered.height << std::endl; ; // exit(0); } pcl::PointXYZ pt; //add some variance on z for(int i=0; i<pcl_cloud_unfiltered.points.size(); i++) { pt = pcl_cloud_unfiltered.points[i]; if(sqrt(pt.x*pt.x+pt.y*pt.y) > min_laser_range_) { pt.z += varz*((double)rand())/(double)INT_MAX; pcl_cloud.points.push_back(pt); } } //Updating the heigh and width of the point cloud pcl_cloud.height = 1; pcl_cloud.width = pcl_cloud.points.size(); if(pcl_cloud.points.size () != pcl_cloud.width * pcl_cloud.height){ std::cout << pcl_cloud.points.size () << " != " << pcl_cloud.width * pcl_cloud.height << std::endl; std::cout << "Weird cloud sizes in point_cloud. I don't know what's going on" << std::endl; } else{ std::cout << "GOOD POINT_CLOUD SCAN" << std::endl; } // Compute the flirt features InterestPointVec pts; if (!skip_features_) { ROS_INFO_STREAM("processing scan - flirt"); boost::shared_ptr<LaserReading> reading = flirtlib_ros::fromRos(*msg_in); detector_->detect(*reading, pts); // Descriptor computation BOOST_FOREACH (InterestPoint* p, pts) p->setDescriptor(descriptor_->describe(*p, *reading)); ROS_INFO_STREAM("flirt computation - done"); } // // Get the time when the laser was taken, this is what should be published... // if (offline) { // if (offline_ctr < offline_nb_readings) { // ndt_feature::NDTFeatureFrame f; // f.pc = pcl_cloud; // f.pts = pts; // f.odom = this_odom; // f.gt = Tgt; // offline_frames.push_back(f); // ROS_INFO_STREAM(" number of frames : " << offline_frames.size()); // ndt_feature::publishMarkerNDTFeatureFrames(offline_frames, marker_pub_); // offline_ctr++; // if (offline_ctr >= offline_nb_readings) { // // Run the matcher(!) // ROS_INFO("RUNNING OFFLINE MATCHER"); // ndt_feature::mapBuilderISAMOffline(offline_frames, sensor_pose_, offline_matches); // } // } // else { // ROS_INFO("."); // // ndt_feature::publishMarkerNDTFeatureFrames(offline_frames, marker_pub_); // marker_pub_.publish(ndt_feature::posePointsMarkerNDTFeatureFrames(offline_frames, 1, 1, std::string("pose_est"), false)); // // marker_pub_.publish(ndt_feature::posePointsMarkerNDTFeatureFrames(offline_frames, 1, 1, std::string("pose_odom"), true)); // pcl::PointCloud<pcl::PointXYZ> cloud; // ndt_feature::getEstimatedCloudNDTFeatureFrames(offline_frames, sensor_pose_, cloud); // sensor_msgs::PointCloud2 cloud_msg; // pcl::toROSMsg(cloud, cloud_msg ); // cloud_msg.header.frame_id = std::string("/world"); // pointcloud_pub_.publish(cloud_msg ); // marker_pub_.publish(ndt_feature::featureMatchesMarkerNDTFeatureFrames(offline_frames, offline_matches, 0, 1, std::string("matches"), false)); // // marker_pub_.publish(ndt_feature::featureMatchesMarkerNDTFeatureFrames(offline_frames, offline_matches, 1, 2, std::string("matches_odom"), true)); // } // } // else { ROS_INFO_STREAM("Before process"); std::cout << Tm.matrix() << std::endl; std::cout << "Move no odom " << Tm.matrix() << std::endl; int a; std::cin >> a; this->processFeatureFrame(pcl_cloud,pts, Tm, frame_time); } if (do_pub_visualization_clouds_) { if (use_graph_) { std::cout << "Publication visualize" << std::endl; sensor_msgs::PointCloud2 cloud_msg; pcl::PointCloud<pcl::PointXYZ>& cloud = graph->getVisualizationCloud(); assert(cloud.points.size () == cloud.width * cloud.height); pcl::toROSMsg(cloud, cloud_msg ); std::cout << "DONE converting" << std::endl; cloud_msg.header.frame_id = world_frame; pointcloud2_pub_.publish(cloud_msg ); std::cout << "DONE Publication visualize" << std::endl; } else { std::cout << "Publication visualize no graph" << std::endl; sensor_msgs::PointCloud2 cloud_msg; pcl::toROSMsg(fuser->getVisualizationCloud(), cloud_msg ); cloud_msg.header.frame_id = world_frame; pointcloud2_pub_.publish(cloud_msg ); std::cout << "Don ePublication visualize" << std::endl; } } // CALLGRIND_TOGGLE_COLLECT; // CALLGRIND_STOP_INSTRUMENTATION; }; // Callback void laserOdomCallback(const sensor_msgs::LaserScan::ConstPtr& msg_in, const nav_msgs::Odometry::ConstPtr& odo_in) { std::cout << "laserOdomCallback" << std::endl; // ROS_ERROR("laserOdomCallback()"); Eigen::Quaterniond qd; sensor_msgs::PointCloud2 cloud; pcl::PointCloud<pcl::PointXYZ> pcl_cloud, pcl_cloud_unfiltered; Eigen::Affine3d Tm; message_m.lock(); qd.x() = odo_in->pose.pose.orientation.x; qd.y() = odo_in->pose.pose.orientation.y; qd.z() = odo_in->pose.pose.orientation.z; qd.w() = odo_in->pose.pose.orientation.w; this_odom = Eigen::Translation3d (odo_in->pose.pose.position.x, odo_in->pose.pose.position.y,odo_in->pose.pose.position.z) * qd; //std::cout<<"AT: "<<this_odom.translation().transpose()<<" "<<this_odom.rotation().eulerAngles(0,1,2)[2] << std::endl; if (nb_added_clouds_ == 0) { Tm.setIdentity(); } else { Tm = last_odom.inverse()*this_odom; //std::cout<<"delta from last update: "<<Tm.translation().transpose()<<" "<<Tm.rotation().eulerAngles(0,1,2)[2] << std::endl; if (Tm.translation().norm() < min_incr_dist /*0.02*/ && Tm.rotation().eulerAngles(0,1,2).norm() < min_incr_rot/*0.02*/) { updateTF(); message_m.unlock(); return; } } last_odom = this_odom; projector_.projectLaser(*msg_in, cloud); message_m.unlock(); pcl::fromROSMsg (cloud, pcl_cloud_unfiltered); pcl::PointXYZ pt; //add some variance on z for(int i=0; i<pcl_cloud_unfiltered.points.size(); i++) { pt = pcl_cloud_unfiltered.points[i]; if(sqrt(pt.x*pt.x+pt.y*pt.y) > min_laser_range_) { pt.z += varz*((double)rand())/(double)INT_MAX; pcl_cloud.points.push_back(pt); } } //ROS_INFO("Got laser and odometry!"); // Compute the flirt features boost::shared_ptr<LaserReading> reading = flirtlib_ros::fromRos(*msg_in); InterestPointVec pts; detector_->detect(*reading, pts); // Descriptor computation BOOST_FOREACH (InterestPoint* p, pts) p->setDescriptor(descriptor_->describe(*p, *reading)); std::cout << "Move " << Tm.matrix() << std::endl; int a; std::cin >> a; // Get the time when the laser was taken, this is what should be published... ros::Time frame_time = msg_in->header.stamp; // ros::Time frame_time = odo_in->header.stamp; // TODO, check how this really works with the sync stuff. this->processFeatureFrame(pcl_cloud,pts, Tm, frame_time); }; // Callback void gt_callback(const nav_msgs::Odometry::ConstPtr& msg_in) { std::cout << "gt_callback" << std::endl; Eigen::Quaterniond qd; Eigen::Affine3d gt_pose; qd.x() = msg_in->pose.pose.orientation.x; qd.y() = msg_in->pose.pose.orientation.y; qd.z() = msg_in->pose.pose.orientation.z; qd.w() = msg_in->pose.pose.orientation.w; gt_pose = Eigen::Translation3d (msg_in->pose.pose.position.x, msg_in->pose.pose.position.y,msg_in->pose.pose.position.z) * qd; // if (gt_file_.is_open()) { // gt_file_ << msg_in->header.stamp << " " << lslgeneric::transformToEvalString(gt_pose); // ROS_INFO("gt_callback added to gt_file_"); // } m.lock(); if(initPoseFromGT && !initPoseSet) { initPoseSet = true; pose_ = gt_pose; Todom = pose_; ROS_INFO("Set initial pose from GT track"); ndt_feature::printTransf2d(pose_); } if (visualize && !use_graph_) { fuser->viewer->addTrajectoryPoint(gt_pose.translation()(0),gt_pose.translation()(1),gt_pose.translation()(2)+0.2,1,1,1); fuser->viewer->displayTrajectory(); fuser->viewer->repaint(); } m.unlock(); } public: EIGEN_MAKE_ALIGNED_OPERATOR_NEW }; int main(int argc, char **argv) { ros::init(argc, argv, "ndt_feature2d_fuser"); // tf::TransformBroadcaster br; // tf::Transform transform; ros::NodeHandle param("~"); NDTFeatureFuserNode t(param); // std::string world_frame; // param.param<std::string>("world_frame",world_frame,"/world"); while(ros::ok()){ // if(t.getGraph()->getNbNodes() >= 1){ // // for(int i = 0 ; i < t.getGraph()->getNbNodes() ; ++i){ // std::stringstream sstm; // sstm << "ndt_map_graph_frame_" << i; // tf::transformEigenToTF(t.getGraph()->getNode(i).T, transform); // br.sendTransform(tf::StampedTransform(transform, ros::Time::now(), world_frame, sstm.str())); // } // } // std::cout <<"SPIN" << std::endl; ros::spinOnce(); } return 0; }
[ "renyunfan@gmail.com" ]
renyunfan@gmail.com
5ee9720ed358df263e0354635ad4d5761fcddddc
e4d8e2c274488a3c4a20efc4d131727cff725249
/include/cc/detail/traits/is_same.hh
fdd3cf50e5d6753d6710b078471bd251304e5996
[ "MIT" ]
permissive
drlight-code/clean-core
340dc1bacafa8f8684a4efb4620d4d3b9f64f5f6
33f06d485dadc9a3082f4e4f0d6f8a850db3c4bf
refs/heads/master
2022-12-29T00:57:42.553880
2019-04-14T19:12:35
2019-04-14T19:12:35
300,218,944
0
0
MIT
2020-10-01T09:18:00
2020-10-01T09:17:59
null
UTF-8
C++
false
false
359
hh
#pragma once namespace cc { namespace detail { template <class A, class B> struct is_same_t { static constexpr bool value = false; }; template <class T> struct is_same_t<T, T> { static constexpr bool value = true; }; } // namespace detail template <class A, class B> inline constexpr bool is_same = detail::is_same_t<A, B>::value; } // namespace cc
[ "Philip.Trettner@rwth-aachen.de" ]
Philip.Trettner@rwth-aachen.de
0501f836828ad7c2e10712b3b1282d9055b96891
a01e135369b8b2caaa1a7dcf44e8d6f059a80f0e
/micro_19.cpp
7f1fe215b21d7f4fc12d0478cf9c388cad59983f
[]
no_license
Scofieldxs/micro-interview-100
5a84d838bf4b1ad2a6002dbb96f9b2ff4b45d9ca
b028bf8d5ac013bef3acb295ca429d8627a11198
refs/heads/master
2016-09-06T07:51:47.080711
2014-05-15T07:05:55
2014-05-15T07:05:55
19,229,788
1
0
null
null
null
null
UTF-8
C++
false
false
683
cpp
// 19.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<stdlib.h> long fibinacciN_1(long n) { long *a=(long *)malloc(sizeof(long )*n); *a=0; *(a+1)=1; if(n==0) return 0; if(n==1) return 1; long i; for(i=2;i<=n;i++) { *(a+i)=*(a+i-1)+*(a+i-2); } return *(a+i-1); } long fibinacciN_2(unsigned n) { int result[2]={0,1}; if(n<2) return result[n]; long long fibOne=0; long long fibTwo=1; long long fib=0; for(int i=2;i<=n;i++) { fib=fibOne+fibTwo; fibOne=fibTwo; fibTwo=fib; } return fib; } int _tmain(int argc, _TCHAR* argv[]) { int n=10; printf("%d fibinicci is %ld",n,fibinacciN_2(n)); getchar(); }
[ "bjfxxs@163.com" ]
bjfxxs@163.com
deb31dbab4e243689e8620dc496a52d0a41134d0
59179e4f655a40b421fa9aeda9c90736b8c11b1b
/compiler/.history/lab1/lexical_20210412102647.cpp
4c02b82df1df47b5f2cb6999b2525eabd2ff5bd0
[]
no_license
wjw136/course_designing_project
ccd39da420f0de22b39fa2fea032054f4cbe8bfd
2614928bd779bc0d996857b123e2862836d81333
refs/heads/master
2023-06-04T12:52:40.501335
2021-06-17T13:19:23
2021-06-17T13:19:23
374,384,252
0
0
null
null
null
null
UTF-8
C++
false
false
498
cpp
#include <iostream> #include <windows.h> #include <string.h> #include <queue> #include <math.h> #include "stdio.h" #define ll long long #define inf 100000 #define clr1(a) memset(a,-1,sizeof(a)) # define clr(a) memset(a, 0, sizeof(a)) using namespace std; //reserved word static char reserveword[35][20]={ "and","array","begin","bool","call","case", "char","constant","dim","do","else","end", "false","for","if","input","integer", } int main(){ system("pause"); return 0; }
[ "2831419633@qq.com" ]
2831419633@qq.com
e71d91317b78b80bf9ccb30e84ba56dfe312fc65
1117d7749ee9d287bdfc91b09fad544646ddd5cf
/chapter05/InputComponent.hpp
26520d288c905866c1f208b1d449a41874dcd702
[ "MIT" ]
permissive
AconCavy/gpcpp
eba975f7a1d2573f72585ae68608a8482805be3d
70d06e00f9ffc4dea580890a8b95027b32f5a9f6
refs/heads/main
2023-04-10T05:38:21.229819
2021-04-23T00:38:22
2021-04-23T00:38:22
349,237,794
0
0
null
null
null
null
UTF-8
C++
false
false
1,307
hpp
#ifndef GPCPP_CHAPTER05_INPUTCOMPONENT_HPP #define GPCPP_CHAPTER05_INPUTCOMPONENT_HPP #include "MoveComponent.hpp" namespace gpcpp::c05 { class InputComponent : public MoveComponent { public: explicit InputComponent(class Actor *Owner); void processInput(const uint8_t *KeyState) override; [[nodiscard]] float getMaxAngularSpeed() const { return MaxAngularSpeed; } [[nodiscard]] float getMaxForward() const { return MaxForwardSpeed; } [[nodiscard]] int getForwardKey() const { return ForwardKey; } [[nodiscard]] int getBackKey() const { return BackKey; } [[nodiscard]] int getClockwiseKey() const { return ClockwiseKey; } [[nodiscard]] int getCounterClockwiseKey() const { return CounterClockwiseKey; } void setMaxAngularSpeed(float Speed) { MaxAngularSpeed = Speed; } void setMaxForwardSpeed(float Speed) { MaxForwardSpeed = Speed; } void setForwardKey(int Key) { ForwardKey = Key; } void setBackKey(int Key) { BackKey = Key; } void setClockwiseKey(int Key) { ClockwiseKey = Key; } void setCounterClockwiseKey(int Key) { CounterClockwiseKey = Key; } private: float MaxAngularSpeed; float MaxForwardSpeed; int ForwardKey; int BackKey; int ClockwiseKey; int CounterClockwiseKey; }; } // namespace gpcpp::c05 #endif // GPCPP_CHAPTER05_INPUTCOMPONENT_HPP
[ "aconcavy@gmail.com" ]
aconcavy@gmail.com
6287a108040a0f56c1920fe1937f40c322c93934
20b354bd9155e36bbd8c887faf5b5ac2788cc711
/Source/private_member_func.cpp
679a7d48b650bbf77fa4cfae75df0729c87fa53e
[]
no_license
MarufurRahman/Object-Oriented-Programming-CPP
b11c1ac5492df2a29feeb61eb71320d624728b46
7fe763ee8a565751963f1d1d8c3a6a661f8bafdc
refs/heads/master
2020-03-31T00:02:45.042069
2018-11-27T09:55:18
2018-11-27T09:55:18
151,723,181
1
0
null
null
null
null
UTF-8
C++
false
false
889
cpp
// Private member function in C++ // Programmed by Marufur Rahman #include <iostream> using namespace std; class Student { private: int rNo; float perc; //private member functions void inputOn(void) { cout<<"Input start..."<<endl; } void inputOff(void) { cout<<"Input end..."<<endl; } public: //public member functions void read(void) { //calling first member function inputOn(); //read rNo and perc cout<<"Enter roll number: "; cin>>rNo; cout<<"Enter percentage: "; cin>>perc; //calling second member function inputOff(); } void print(void) { cout<<endl; cout<<"Roll Number: "<<rNo<<endl; cout<<"Percentage: "<<perc<<"%"<<endl; } }; //Main code int main() { //declaring object of class student Student std; //reading and printing details of a student std.read(); std.print(); return 0; }
[ "marufurrahman1997@gmail.com" ]
marufurrahman1997@gmail.com
948835a24fa6d9af8a9696967ae38462ed1c9569
85775c2342266c60cf919a3d60a8b84af0642b6e
/interview-tasks/unique_numbers_from_the_range.cpp
5c86e8b3983b388ac567ff3996fbfb0c52a72571
[]
no_license
s-e-r-g/cpp-examples
b86540c012e5c5916c29210044bf733b1ac2d5fb
fdcd052b70235e16e995035ee3e9723afc774240
refs/heads/master
2021-01-25T05:34:35.400960
2020-05-05T09:06:30
2020-05-05T09:06:30
9,544,368
0
0
null
null
null
null
UTF-8
C++
false
false
593
cpp
// Pick random numbers from the range // E.g. range is [1..10] and we want to pick 6 random unique numbers. #include <iostream> #include <vector> #include <utility> using namespace std; int main() { const int maxNumber = 10; const int getCount = 6; vector<int> numbers; numbers.reserve(maxNumber); for (int i = 0; i < maxNumber; ++i) { numbers.push_back(i + 1); } for (int i = 0; i < getCount; ++i) { size_t index = rand() % (maxNumber - i) + i; swap(numbers[i], numbers[index]); cout << numbers[i] << endl; } }
[ "sergii.ponomarenko@toatech.com" ]
sergii.ponomarenko@toatech.com
dd114b6548c0113d9cf949e417df296d0cb90bd0
e6e99a9d5a8879614584fa75bea6c92e11d374d7
/OMI2017_Mensajeria.cpp
ff766e91f438ab2e4d9851e5d9a6e179f70f99ce
[]
no_license
JuanMBriones/OMI
740e86ad8b1871c7ece92d8e5f44097f151a6637
be73e56ab6e34a08e93e6490db5688591113fd0a
refs/heads/master
2021-08-22T01:59:23.559880
2020-09-22T14:23:49
2020-09-22T14:23:49
224,791,946
0
0
null
null
null
null
UTF-8
C++
false
false
626
cpp
#include <iostream> //#include <vector> #define opt_io cin.tie(0);ios_base::sync_with_stdio(0); using namespace std; // (ada(iad)pmilO) // 5 //10101 // 1 2 4 8 16 // 1+4+16 // 21 // 16 o 32 // 21-16 = 5 // 5+4 = 9 int main() { opt_io int i, n, k, costo = 0, a, maximo = 0; bool flag = false; cin >> n >> k; for(i=0; i<n; i++) { cin >> a; maximo = max(a, maximo); if(a>k) { costo += k; flag = true; } else { costo += a; } } cout << ((flag)? costo : costo-maximo+k) << endl; cin.get(); return 0; }
[ "JuanMBriones@outlook.com" ]
JuanMBriones@outlook.com
a5e8c5ec4cf5746f5427c2d475634540afe31409
734390edb42c1224eebfa25d88aed5391fb64384
/lang/cpp/cpp1114/auto.cpp
f9f94356f9e99c352413abb9a1aa0a0262cacb2a
[ "MIT" ]
permissive
yohshiy/programmers_notes
f12d67ebe7bfd29afe8a288f4943991a02e4dfbe
ececf1fc158ca8f541dc3ebc4310d2694c687ef5
refs/heads/master
2020-05-22T05:41:38.561056
2018-04-27T08:05:49
2018-04-27T08:05:49
48,354,092
0
0
null
null
null
null
UTF-8
C++
false
false
1,172
cpp
 #include <string> #include <iostream> using namespace std; extern double Mag; static auto mag = 1.0; const double MyPi = 3.14; const auto MyPiA = 3.14; class Foo { static const int classval_int = 3; }; class Foo2 { static const auto classval_int = 3; static constexpr auto classval_dbl = 3.1; }; class Baz { double objval_real = 3.15; // auto objval_real_a = 3.15; // NG }; // template <typename T> // auto MyMax(const T &a, const T &b) // { // return (a < b) ? b : a; // } template <typename T, typename U> auto MyMax(const T &a, const U &b) { return (a < b) ? b : a; } template <typename T, typename U> auto MyMax3(const T &a, const U &b) { if (a < b) { return b; } else { return a; } } int main() { auto num = 5; // int auto cstr = "Hello"; // char * auto str = string("Hello"); // string const auto cnum = 10; auto &ref = str; auto lstr = "Hello"s; // string auto maxval = MyMax(3.1, 5); auto maxval2 = MyMax(1, 2.3); cout << maxval << endl; cout << maxval2 << endl; auto maxval3 = MyMax3(1, 2.3); cout << maxval3 << endl; return 0; }
[ "yohshiy@gmail.com" ]
yohshiy@gmail.com
5ac925ad02fbdcf36ede8f82d98e28d7c77bab26
90efdfa1f56e2082283e510c7aa9a77ceab8ce18
/gplay3d/src/graphics/Joint.cpp
f6866ad1e25be8170fee9f62c5f9cb01f27258b8
[]
no_license
aurodev/GPlay3D
451e2863d6ac3222762672d358eecd494d9cc272
ad6b88dd22688e2b6e6e2fa02779daa0b5545592
refs/heads/master
2020-07-13T04:28:30.234238
2018-06-26T06:48:20
2018-06-26T06:48:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,768
cpp
#include "../core/Base.h" #include "../graphics/Joint.h" #include "../graphics/MeshSkin.h" #include "../graphics/Model.h" namespace gameplay { Joint::Joint(const char* id) : Node(id), _jointMatrixDirty(true) { } Joint::~Joint() { } Joint* Joint::create(const char* id) { return new Joint(id); } Node* Joint::cloneSingleNode(NodeCloneContext &context) const { Joint* copy = Joint::create(getId()); GP_ASSERT(copy); context.registerClonedNode(this, copy); copy->_bindPose = _bindPose; Node::cloneInto(copy, context); return copy; } Node::Type Joint::getType() const { return Node::JOINT; } const char* Joint::getTypeName() const { return "Joint"; } Scene* Joint::getScene() const { // Overrides Node::getScene() to search the node our skins. for (const SkinReference* itr = &_skin; itr && itr->skin; itr = itr->next) { Model* model = itr->skin ? itr->skin->getModel() : NULL; if (model) { Node* node = model->getNode(); if (node) { Scene* scene = node->getScene(); if (scene) return scene; } } } return Node::getScene(); } void Joint::transformChanged() { Node::transformChanged(); _jointMatrixDirty = true; } void Joint::updateJointMatrix(const Matrix& bindShape, Vector4* matrixPalette) { // Note: If more than one MeshSkin influences this Joint, we need to skip // the _jointMatrixDirty optimization since updateJointMatrix() may be // called multiple times a frame with different bindShape matrices (and // different matrixPallete pointers). if (_skin.next || _jointMatrixDirty) { _jointMatrixDirty = false; static Matrix t; Matrix::multiply(Node::getWorldMatrix(), getInverseBindPose(), &t); Matrix::multiply(t, bindShape, &t); GP_ASSERT(matrixPalette); matrixPalette[0].set(t.m[0], t.m[4], t.m[8], t.m[12]); matrixPalette[1].set(t.m[1], t.m[5], t.m[9], t.m[13]); matrixPalette[2].set(t.m[2], t.m[6], t.m[10], t.m[14]); } } const Matrix& Joint::getInverseBindPose() const { return _bindPose; } void Joint::setInverseBindPose(const Matrix& m) { _bindPose = m; _jointMatrixDirty = true; } void Joint::addSkin(MeshSkin* skin) { if (!_skin.skin) { // Store skin in root reference _skin.skin = skin; } else { // Add a new SkinReference to the end of our list SkinReference* ref = &_skin; while (ref->next) { ref = ref->next; } ref->next = new SkinReference(); ref->next->skin = skin; } } void Joint::removeSkin(MeshSkin* skin) { if (_skin.skin == skin) { // Skin is our root referenced skin _skin.skin = NULL; // Shift the next skin reference down to the root if (_skin.next) { SkinReference* tmp = _skin.next; _skin.skin = tmp->skin; _skin.next = tmp->next; tmp->next = NULL; // prevent deletion SAFE_DELETE(tmp); } } else { // Search for the entry referencing this skin SkinReference* ref = &_skin; while (SkinReference* tmp = ref->next) { if (tmp->skin == skin) { // Link this refernce out ref->next = tmp->next; tmp->next = NULL; // prevent deletion SAFE_DELETE(tmp); break; } ref = tmp; } } } Joint::SkinReference::SkinReference() : skin(NULL), next(NULL) { } Joint::SkinReference::~SkinReference() { SAFE_DELETE(next); } }
[ "fredakilla@gmail.com" ]
fredakilla@gmail.com
c59474e6f1cabb54da6786703bf8130463cdea19
2e80f72250cc865d2190bb443a38ff338508ffef
/include/solvers/sqp.hpp
67133503841f3c3cf5b4f5b1e1d7318088417930
[ "MIT" ]
permissive
Toeplitz/sqp_solver
5546116d2b11b29256961997c6fb437c76294441
37b9b7c6840f85931ef0c235477a7f334907d44a
refs/heads/master
2020-11-26T12:33:23.483704
2019-09-19T16:00:45
2019-09-19T16:02:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
11,750
hpp
#ifndef SQP_H #define SQP_H #include <Eigen/Dense> #include <cmath> #include <limits> #include "qp_solver.hpp" #include "bfgs.hpp" #ifdef SOLVER_DEBUG #include <Eigen/Eigenvalues> #endif #ifndef SOLVER_ASSERT #define SOLVER_ASSERT(x) eigen_assert(x) #endif namespace sqp { template <typename Scalar> struct sqp_settings_t { Scalar tau = 0.5; /**< line search iteration decrease, 0 < tau < 1 */ Scalar eta = 0.25; /**< line search parameter, 0 < eta < 1 */ Scalar rho = 0.5; /**< line search parameter, 0 < rho < 1 */ Scalar eps_prim = 1e-3; /**< primal step termination threshold, eps_prim > 0 */ Scalar eps_dual = 1e-3; /**< dual step termination threshold, eps_dual > 0 */ int max_iter = 100; int line_search_max_iter = 100; void (*iteration_callback)(void *solver) = nullptr; bool validate() { bool valid; valid = 0.0 < tau && tau < 1.0 && 0.0 < eta && eta < 1.0 && 0.0 < rho && rho < 1.0 && eps_prim < 0.0 && eps_dual < 0.0 && max_iter > 0 && line_search_max_iter > 0; return valid; } }; struct sqp_status_t { enum { SOLVED, MAX_ITER_EXCEEDED, INVALID_SETTINGS } value; }; struct sqp_info_t { int iter; int qp_solver_iter; sqp_status_t status; }; /* * minimize f(x) * subject to ce(x) = 0 * ci(x) <= 0 * l <= x <= u */ template <typename _Problem> class SQP { public: using Problem = _Problem; enum { VAR_SIZE = Problem::VAR_SIZE, NUM_EQ = Problem::NUM_EQ, NUM_INEQ = Problem::NUM_INEQ, NUM_CONSTR = NUM_EQ + NUM_INEQ + VAR_SIZE }; using Scalar = typename Problem::Scalar; using qp_t = qp_solver::QP<VAR_SIZE, NUM_CONSTR, Scalar>; using qp_solver_t = qp_solver::QPSolver<qp_t>; using settings_t = sqp_settings_t<Scalar>; using var_t = Eigen::Matrix<Scalar, VAR_SIZE, 1>; using dual_t = Eigen::Matrix<Scalar, NUM_CONSTR, 1>; using gradient_t = Eigen::Matrix<Scalar, VAR_SIZE, 1>; using hessian_t = Eigen::Matrix<Scalar, VAR_SIZE, VAR_SIZE>; using constr_eq_t = Eigen::Matrix<Scalar, NUM_EQ, 1>; using jacobian_eq_t = Eigen::Matrix<Scalar, NUM_EQ, VAR_SIZE>; using constr_ineq_t = Eigen::Matrix<Scalar, NUM_INEQ, 1>; using jacobian_ineq_t = Eigen::Matrix<Scalar, NUM_INEQ, VAR_SIZE>; using constr_box_t = var_t; // Constants static constexpr Scalar DIV_BY_ZERO_REGUL = std::numeric_limits<Scalar>::epsilon(); // Solver state variables var_t _x; dual_t _lambda; var_t _step_prev; gradient_t _grad_L; constr_eq_t b_eq; jacobian_eq_t A_eq; constr_ineq_t b_ineq; jacobian_ineq_t A_ineq; constr_box_t lbx, ubx; qp_t _qp; qp_solver_t _qp_solver; settings_t _settings; sqp_info_t _info; // info Scalar _dual_step_norm; Scalar _primal_step_norm; Scalar _cost; // enforce 16 byte alignment https://eigen.tuxfamily.org/dox/group__TopicStructHavingEigenMembers.html EIGEN_MAKE_ALIGNED_OPERATOR_NEW void solve(Problem &prob, const var_t &x0, const dual_t &lambda0) { _x = x0; _lambda = lambda0; _solve(prob); } void solve(Problem &prob) { _x.setZero(); _lambda.setZero(); _solve(prob); } SQP() { _qp_solver.settings().warm_start = true; _qp_solver.settings().check_termination = 10; _qp_solver.settings().eps_abs = 1e-4; _qp_solver.settings().eps_rel = 1e-4; _qp_solver.settings().max_iter = 100; _qp_solver.settings().adaptive_rho = true; _qp_solver.settings().adaptive_rho_interval = 50; _qp_solver.settings().alpha = 1.6; } inline const var_t& primal_solution() const { return _x; } inline var_t& primal_solution() { return _x; } inline const dual_t& dual_solution() const { return _lambda; } inline dual_t& dual_solution() { return _lambda; } inline const settings_t& settings() const { return _settings; } inline settings_t& settings() { return _settings; } inline const sqp_info_t& info() const { return _info; } inline sqp_info_t& info() { return _info; } private: void _solve(Problem &prob) { var_t p; // search direction dual_t p_lambda; // dual search direction Scalar alpha; // step size // initialize _info.qp_solver_iter = 0; int& iter = _info.iter; for (iter = 1; iter <= _settings.max_iter; iter++) { // Solve QP solve_qp(prob, p, p_lambda); p_lambda -= _lambda; alpha = line_search(prob, p); // take step _x = _x + alpha * p; _lambda = _lambda + alpha * p_lambda; // update step info _step_prev = alpha * p; _primal_step_norm = alpha * p.template lpNorm<Eigen::Infinity>(); _dual_step_norm = alpha * p_lambda.template lpNorm<Eigen::Infinity>(); if (_settings.iteration_callback != nullptr) { _settings.iteration_callback(this); } if (termination_criteria(_x, prob)) { _info.status.value = sqp_status_t::SOLVED; break; } } if (iter > _settings.max_iter) { _info.status.value = sqp_status_t::MAX_ITER_EXCEEDED; } } #ifdef SOLVER_DEBUG bool _is_posdef(hessian_t H) { Eigen::EigenSolver<hessian_t> eigensolver(H); for (int i = 0; i < eigensolver.eigenvalues().rows(); i++) { double v = eigensolver.eigenvalues()(i).real(); if (v <= 0) { return false; } } return true; } #endif bool termination_criteria(const var_t &x, Problem &prob) const { if (_primal_step_norm <= _settings.eps_prim && _dual_step_norm <= _settings.eps_dual && max_constraint_violation(x, prob) <= _settings.eps_prim) { return true; } return false; } void solve_qp(Problem &prob, var_t &p, dual_t &lambda) { /* QP from linearized NLP: * minimize 0.5 x'.P.x + q'.x * subject to Ae.x + be = 0 * Ai.x + bi <= 0 * l <= x <= u * * with: * P Hessian of Lagrangian * q cost gradient * Ae,be linearized equality constraint * Ai,bi linearized inequality constraint * l,u box constraint bounds * * transform to: * minimize 0.5 x'.P.x + q'.x * subject to l <= A.x <= u * * Where the constraint bounds l,u are l=u for equality constraints or * set to +-INFINITY if unbounded. */ enum { EQ_IDX = 0, INEQ_IDX = NUM_EQ, BOX_IDX = NUM_INEQ + NUM_EQ, }; const Scalar UNBOUNDED = 1e20; gradient_t& grad_f = _qp.q; hessian_t& B = _qp.P; prob.cost_linearized(_x, grad_f, _cost); prob.constraint_linearized(_x, A_eq, b_eq, A_ineq, b_ineq, lbx, ubx); Eigen::Ref<constr_eq_t> lambda_eq = _lambda.template segment<NUM_EQ>(EQ_IDX); Eigen::Ref<constr_ineq_t> lambda_ineq = _lambda.template segment<NUM_INEQ>(INEQ_IDX); Eigen::Ref<constr_box_t> lambda_box = _lambda.template segment<VAR_SIZE>(BOX_IDX); gradient_t y = -_grad_L; _grad_L = grad_f + A_eq.transpose() * lambda_eq + A_ineq.transpose() * lambda_ineq + lambda_box; // BFGS update if (_info.iter == 1) { B.setIdentity(); } else { y += _grad_L; // y = grad_L_prev - grad_L BFGS_update(B, _step_prev, y); #ifdef SOLVER_DEBUG SOLVER_ASSERT(_is_posdef(B)); #endif } // Equality constraints // from A.x + b = 0 // to -b <= A.x <= -b _qp.u.template segment<NUM_EQ>(EQ_IDX) = -b_eq; _qp.l.template segment<NUM_EQ>(EQ_IDX) = -b_eq; _qp.A.template block<NUM_EQ, VAR_SIZE>(EQ_IDX, 0) = A_eq; // Inequality constraints // from A.x + b <= 0 // to -INF <= A.x <= -b _qp.u.template segment<NUM_INEQ>(INEQ_IDX) = -b_ineq; _qp.l.template segment<NUM_INEQ>(INEQ_IDX).setConstant(-UNBOUNDED); _qp.A.template block<NUM_INEQ, VAR_SIZE>(INEQ_IDX, 0) = A_ineq; // Box constraints // from l <= x + p <= u // to l-x <= p <= u-x _qp.u.template segment<VAR_SIZE>(BOX_IDX) = ubx - _x; _qp.l.template segment<VAR_SIZE>(BOX_IDX) = lbx - _x; _qp.A.template block<VAR_SIZE, VAR_SIZE>(BOX_IDX, 0).setIdentity(); // solve the QP if (_info.iter == 1) { _qp_solver.setup(_qp); } else { _qp_solver.update_qp(_qp); } _qp_solver.solve(_qp); _info.qp_solver_iter += _qp_solver.info().iter; p = _qp_solver.x; lambda = _qp_solver.y; } /** Line search in direction p using l1 merit function. */ Scalar line_search(Problem &prob, const var_t& p) { // Note: using members _cost and _qp.q, which are updated in solve_qp(). Scalar mu, phi_l1, Dp_phi_l1; gradient_t& cost_gradient = _qp.q; const Scalar tau = _settings.tau; // line search step decrease, 0 < tau < settings.tau Scalar constr_l1 = constraint_norm(_x, prob); // TODO: get mu from merit function model using hessian of Lagrangian mu = cost_gradient.dot(p) / ((1 - _settings.rho) * constr_l1); phi_l1 = _cost + mu * constr_l1; Dp_phi_l1 = cost_gradient.dot(p) - mu * constr_l1; Scalar alpha = 1.0; for (int i = 1; i < _settings.line_search_max_iter; i++) { Scalar cost_step; var_t x_step = _x + alpha*p; prob.cost(x_step, cost_step); Scalar phi_l1_step = cost_step + mu * constraint_norm(x_step, prob); if (phi_l1_step <= phi_l1 + alpha * _settings.eta * Dp_phi_l1) { // accept step break; } else { alpha = tau * alpha; } } return alpha; } /** L1 norm of constraint violation */ Scalar constraint_norm(const var_t &x, Problem &prob) const { Scalar cl1 = DIV_BY_ZERO_REGUL; constr_eq_t c_eq; constr_ineq_t c_ineq; constr_box_t lbx, ubx; prob.constraint(x, c_eq, c_ineq, lbx, ubx); // c_eq = 0 cl1 += c_eq.template lpNorm<1>(); // c_ineq <= 0 cl1 += c_ineq.cwiseMax(0.0).sum(); // l <= x <= u cl1 += (lbx - x).cwiseMax(0.0).sum(); cl1 += (x - ubx).cwiseMax(0.0).sum(); return cl1; } /** L_inf norm of constraint violation */ Scalar max_constraint_violation(const var_t &x, Problem &prob) const { Scalar c = 0; constr_eq_t c_eq; constr_ineq_t c_ineq; constr_box_t lbx, ubx; prob.constraint(x, c_eq, c_ineq, lbx, ubx); // c_eq = 0 if (NUM_EQ > 0) { c = fmax(c, c_eq.template lpNorm<Eigen::Infinity>()); } // c_ineq <= 0 if (NUM_INEQ > 0) { c = fmax(c, c_ineq.maxCoeff());; } // l <= x <= u c = fmax(c, (lbx - x).maxCoeff()); c = fmax(c, (x - ubx).maxCoeff()); return c; } }; } // namespace sqp #endif // SQP_H
[ "mspieler101@gmail.com" ]
mspieler101@gmail.com
dcecf56d51e2f11666da70b151621e54862c1028
7057781260d7896d2d8e11944d6eb65f9102a8f6
/src/ConsoleLog.cpp
d37b6eb37873b5c53cc4bd888a57d0c089991630
[]
no_license
SuJinpei/odbc_performance
926e0eb35252ebf3476e6d607c0f2a09cef95c90
4a8a5e37d8d7a702838e364799f2fb9525ad854e
refs/heads/master
2021-08-07T12:06:33.871159
2020-04-15T10:58:51
2020-04-15T10:58:51
152,972,972
0
0
null
null
null
null
UTF-8
C++
false
false
670
cpp
#include "ConsoleLog.h" ConsoleLog::ConsoleLog(const LogLevel lv) :_buffer{std::cerr}, logLevel{lv}{ _buffer.imbue(std::locale("")); } void ConsoleLog::setLevel(ConsoleLog::LogLevel lv) { logLevel = lv; } ConsoleLog::Color::Color(int i) { set_color(i); } ConsoleLog::Color::~Color() { #ifdef _WIN32 auto h = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleTextAttribute(h, 7); #endif // _WIN32 } void ConsoleLog::Color::set_color(int i) { #ifdef _WIN32 auto h = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleTextAttribute(h, i); #endif // _WIN32 } ConsoleLog & console() { static ConsoleLog logger(ConsoleLog::LDEBUG); return logger; }
[ "873118042@qq.com" ]
873118042@qq.com
cf9b01ac919561e28bf37c7f87d3f89ac9675135
2834f98b53d78bafc9f765344ded24cf41ffebb0
/extensions/browser/api/declarative_net_request/utils.cc
5256a59cbdae82bdc574986dd49b40e72f807f3b
[ "BSD-3-Clause" ]
permissive
cea56/chromium
81bffdf706df8b356c2e821c1a299f9d4bd4c620
013d244f2a747275da76758d2e6240f88c0165dd
refs/heads/master
2023-01-11T05:44:41.185820
2019-12-09T04:14:16
2019-12-09T04:14:16
226,785,888
1
0
BSD-3-Clause
2019-12-09T04:40:07
2019-12-09T04:40:07
null
UTF-8
C++
false
false
8,864
cc
// Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "extensions/browser/api/declarative_net_request/utils.h" #include <memory> #include <set> #include <utility> #include "base/files/file.h" #include "base/files/file_path.h" #include "base/files/file_util.h" #include "base/hash/hash.h" #include "base/metrics/histogram_functions.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/task/post_task.h" #include "components/url_pattern_index/url_pattern_index.h" #include "components/web_cache/browser/web_cache_manager.h" #include "content/public/browser/browser_task_traits.h" #include "content/public/browser/browser_thread.h" #include "extensions/browser/api/declarative_net_request/constants.h" #include "extensions/browser/api/declarative_net_request/flat/extension_ruleset_generated.h" #include "extensions/browser/api/web_request/web_request_info.h" #include "third_party/flatbuffers/src/include/flatbuffers/flatbuffers.h" namespace extensions { namespace declarative_net_request { namespace { namespace dnr_api = api::declarative_net_request; // The ruleset format version of the flatbuffer schema. Increment this whenever // making an incompatible change to the schema at extension_ruleset.fbs or // url_pattern_index.fbs. Whenever an extension with an indexed ruleset format // version different from the one currently used by Chrome is loaded, the // extension ruleset will be reindexed. constexpr int kIndexedRulesetFormatVersion = 13; // This static assert is meant to catch cases where // url_pattern_index::kUrlPatternIndexFormatVersion is incremented without // updating kIndexedRulesetFormatVersion. static_assert(url_pattern_index::kUrlPatternIndexFormatVersion == 5, "kUrlPatternIndexFormatVersion has changed, make sure you've " "also updated kIndexedRulesetFormatVersion above."); constexpr int kInvalidIndexedRulesetFormatVersion = -1; int g_indexed_ruleset_format_version_for_testing = kInvalidIndexedRulesetFormatVersion; int GetIndexedRulesetFormatVersion() { return g_indexed_ruleset_format_version_for_testing == kInvalidIndexedRulesetFormatVersion ? kIndexedRulesetFormatVersion : g_indexed_ruleset_format_version_for_testing; } // Returns the header to be used for indexed rulesets. This depends on the // current ruleset format version. std::string GetVersionHeader() { return base::StringPrintf("---------Version=%d", GetIndexedRulesetFormatVersion()); } // Returns the checksum of the given serialized |data|. |data| must not include // the version header. int GetChecksum(base::span<const uint8_t> data) { uint32_t hash = base::PersistentHash(data.data(), data.size()); // Strip off the sign bit since this needs to be persisted in preferences // which don't support unsigned ints. return static_cast<int>(hash & 0x7fffffff); } void ClearRendererCacheOnUI() { web_cache::WebCacheManager::GetInstance()->ClearCacheOnNavigation(); } } // namespace bool IsValidRulesetData(base::span<const uint8_t> data, int expected_checksum) { flatbuffers::Verifier verifier(data.data(), data.size()); return expected_checksum == GetChecksum(data) && flat::VerifyExtensionIndexedRulesetBuffer(verifier); } std::string GetVersionHeaderForTesting() { return GetVersionHeader(); } int GetIndexedRulesetFormatVersionForTesting() { return GetIndexedRulesetFormatVersion(); } void SetIndexedRulesetFormatVersionForTesting(int version) { DCHECK_NE(kInvalidIndexedRulesetFormatVersion, version); g_indexed_ruleset_format_version_for_testing = version; } bool StripVersionHeaderAndParseVersion(std::string* ruleset_data) { DCHECK(ruleset_data); const std::string version_header = GetVersionHeader(); if (!base::StartsWith(*ruleset_data, version_header, base::CompareCase::SENSITIVE)) { return false; } // Strip the header from |ruleset_data|. ruleset_data->erase(0, version_header.size()); return true; } bool PersistIndexedRuleset(const base::FilePath& path, base::span<const uint8_t> data, int* ruleset_checksum) { DCHECK(ruleset_checksum); // Create the directory corresponding to |path| if it does not exist. if (!base::CreateDirectory(path.DirName())) return false; base::File ruleset_file( path, base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); if (!ruleset_file.IsValid()) return false; // Write the version header. std::string version_header = GetVersionHeader(); int version_header_size = static_cast<int>(version_header.size()); if (ruleset_file.WriteAtCurrentPos( version_header.data(), version_header_size) != version_header_size) { return false; } // Write the flatbuffer ruleset. if (!base::IsValueInRangeForNumericType<int>(data.size())) return false; int data_size = static_cast<int>(data.size()); if (ruleset_file.WriteAtCurrentPos(reinterpret_cast<const char*>(data.data()), data_size) != data_size) { return false; } *ruleset_checksum = GetChecksum(data); return true; } // Helper to clear each renderer's in-memory cache the next time it navigates. void ClearRendererCacheOnNavigation() { if (content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { ClearRendererCacheOnUI(); } else { base::PostTask(FROM_HERE, {content::BrowserThread::UI}, base::BindOnce(&ClearRendererCacheOnUI)); } } void LogReadDynamicRulesStatus(ReadJSONRulesResult::Status status) { base::UmaHistogramEnumeration(kReadDynamicRulesJSONStatusHistogram, status); } // Maps content::ResourceType to api::declarative_net_request::ResourceType. dnr_api::ResourceType GetDNRResourceType(content::ResourceType resource_type) { switch (resource_type) { case content::ResourceType::kPrefetch: case content::ResourceType::kSubResource: return dnr_api::RESOURCE_TYPE_OTHER; case content::ResourceType::kMainFrame: case content::ResourceType::kNavigationPreloadMainFrame: return dnr_api::RESOURCE_TYPE_MAIN_FRAME; case content::ResourceType::kCspReport: return dnr_api::RESOURCE_TYPE_CSP_REPORT; case content::ResourceType::kScript: case content::ResourceType::kWorker: case content::ResourceType::kSharedWorker: case content::ResourceType::kServiceWorker: return dnr_api::RESOURCE_TYPE_SCRIPT; case content::ResourceType::kImage: case content::ResourceType::kFavicon: return dnr_api::RESOURCE_TYPE_IMAGE; case content::ResourceType::kStylesheet: return dnr_api::RESOURCE_TYPE_STYLESHEET; case content::ResourceType::kObject: case content::ResourceType::kPluginResource: return dnr_api::RESOURCE_TYPE_OBJECT; case content::ResourceType::kXhr: return dnr_api::RESOURCE_TYPE_XMLHTTPREQUEST; case content::ResourceType::kSubFrame: case content::ResourceType::kNavigationPreloadSubFrame: return dnr_api::RESOURCE_TYPE_SUB_FRAME; case content::ResourceType::kPing: return dnr_api::RESOURCE_TYPE_PING; case content::ResourceType::kMedia: return dnr_api::RESOURCE_TYPE_MEDIA; case content::ResourceType::kFontResource: return dnr_api::RESOURCE_TYPE_FONT; } NOTREACHED(); return dnr_api::RESOURCE_TYPE_OTHER; } dnr_api::RequestDetails CreateRequestDetails(const WebRequestInfo& request) { api::declarative_net_request::RequestDetails details; details.request_id = base::NumberToString(request.id); details.url = request.url.spec(); if (request.initiator) { details.initiator = std::make_unique<std::string>(request.initiator->Serialize()); } details.method = request.method; details.frame_id = request.frame_data.frame_id; details.parent_frame_id = request.frame_data.parent_frame_id; details.tab_id = request.frame_data.tab_id; details.type = GetDNRResourceType(request.type); return details; } re2::RE2::Options CreateRE2Options(bool is_case_sensitive, bool require_capturing) { re2::RE2::Options options; // RE2 supports UTF-8 and Latin1 encoding. We only need to support ASCII, so // use Latin1 encoding. This should also be more efficient than UTF-8. // Note: Latin1 is an 8 bit extension to ASCII. options.set_encoding(re2::RE2::Options::EncodingLatin1); options.set_case_sensitive(is_case_sensitive); // Don't capture unless needed, for efficiency. options.set_never_capture(!require_capturing); return options; } } // namespace declarative_net_request } // namespace extensions
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
65ce0cae49c85447dd7bc20f69b17ca608dcfb8b
f2d9c039614dc44c457a09f71a285b44791fe2d2
/002/myvector.hpp
4db9b19ba4db047cd4783f080cc0ba2b8c344e24
[ "MIT" ]
permissive
suomesta/myvector
7a0a24ac1f5e2488cb61b46feac2ef6ba3549fbb
60a1844976b4d469d8115755f0e404ba6b0e173e
refs/heads/master
2020-05-19T16:53:24.316320
2019-08-31T12:01:04
2019-08-31T12:01:04
185,118,953
0
0
null
null
null
null
UTF-8
C++
false
false
1,371
hpp
/** * @file myvector.hpp * @brief Implementation of myvector class. * myvector class imitates std::vector. * @author toda * @date 2019-05-06 * @version 0.1.0 * @remark the target is C++11 or more. */ #ifndef INCLUDE_GUARD_MYVECTOR_HPP #define INCLUDE_GUARD_MYVECTOR_HPP #include <cstddef> #include <iterator> /** * @class myvector * @brief myvector is a class which imitates std::vector. * @tparam T: The type of the elements. */ template <typename T> class myvector { public: using value_type = T; using size_type = size_t; using difference_type = ptrdiff_t; using reference = value_type&; using const_reference = const value_type&; using pointer = value_type*; using const_pointer = const value_type*; using iterator = value_type*; using const_iterator = const value_type*; using reverse_iterator = std::reverse_iterator<iterator>; using const_reverse_iterator = std::reverse_iterator<const_iterator>; ///////////////////////////////////////////////////////////////////////////// private: pointer heap_ = nullptr; size_type size_ = 0; size_type capacity_ = 0; ///////////////////////////////////////////////////////////////////////////// }; ///////////////////////////////////////////////////////////////////////////// #endif // #ifndef INCLUDE_GUARD_MYVECTOR_HPP
[ "shawn316michaels@gmail.com" ]
shawn316michaels@gmail.com
b9e493aac75123d1e3ec3a6ad1ef55d8120b0ef3
348e7dfc31f32031fccf609b65f5835a55a35edb
/python/src/rpc/libeggnogg_rpc_clnt.cpp
0340cc1a47995b63b2ea71cda3cb9cefb7bf9be1
[]
no_license
0xUKN/libeggnogg
c188c58cade6469a54e25978a19064a849d98b0a
313c32bf2d2227342bf66e417803eada010a99f1
refs/heads/master
2021-02-19T08:57:05.908425
2020-11-10T04:47:00
2020-11-10T04:47:00
245,297,950
4
0
null
null
null
null
UTF-8
C++
false
false
2,150
cpp
/* * Please do not edit this file. * It was generated using rpcgen. */ #include <memory.h> /* for memset */ #include "../../../include/libeggnogg_rpc.hpp" namespace LibEggnogg { /* Default timeout can be changed using clnt_control() */ static struct timeval TIMEOUT = { 25, 0 }; void exit_libeggnogg_rpc_clnt(CLIENT *clnt) { clnt_destroy(clnt); } CLIENT * init_libeggnogg_rpc_clnt() { return clnt_create("localhost", LibEggnogg_RPC, Stable, "udp"); } void * set_speed_3(u_long *argp, CLIENT *clnt) { static char clnt_res; memset((char *)&clnt_res, 0, sizeof(clnt_res)); if (clnt_call (clnt, set_speed, (xdrproc_t) xdr_u_long, (caddr_t) argp, (xdrproc_t) xdr_void, (caddr_t) &clnt_res, TIMEOUT) != RPC_SUCCESS) { return (NULL); } return ((void *)&clnt_res); } u_long * get_speed_3(void *argp, CLIENT *clnt) { static u_long clnt_res; memset((char *)&clnt_res, 0, sizeof(clnt_res)); if (clnt_call (clnt, get_speed, (xdrproc_t) xdr_void, (caddr_t) argp, (xdrproc_t) xdr_u_long, (caddr_t) &clnt_res, TIMEOUT) != RPC_SUCCESS) { return (NULL); } return (&clnt_res); } char ** get_roomdef_3(void *argp, CLIENT *clnt) { static char *clnt_res; memset((char *)&clnt_res, 0, sizeof(clnt_res)); if (clnt_call (clnt, get_roomdef, (xdrproc_t) xdr_void, (caddr_t) argp, (xdrproc_t) xdr_wrapstring, (caddr_t) &clnt_res, TIMEOUT) != RPC_SUCCESS) { return (NULL); } return (&clnt_res); } char ** get_mapname_3(void *argp, CLIENT *clnt) { static char *clnt_res; memset((char *)&clnt_res, 0, sizeof(clnt_res)); if (clnt_call (clnt, get_mapname, (xdrproc_t) xdr_void, (caddr_t) argp, (xdrproc_t) xdr_wrapstring, (caddr_t) &clnt_res, TIMEOUT) != RPC_SUCCESS) { return (NULL); } return (&clnt_res); } void * game_reset_3(void *argp, CLIENT *clnt) { static char clnt_res; memset((char *)&clnt_res, 0, sizeof(clnt_res)); if (clnt_call (clnt, game_reset, (xdrproc_t) xdr_void, (caddr_t) argp, (xdrproc_t) xdr_void, (caddr_t) &clnt_res, TIMEOUT) != RPC_SUCCESS) { return (NULL); } return ((void *)&clnt_res); } }
[ "0xukn@protonmail.com" ]
0xukn@protonmail.com
a2548bff88459fe5dc784daf8d0b74e97ae9c6c9
de2b445d31b67be34093cc15ef3f020a299928dc
/cpp/lib/other/big_integer.cpp
2949b77b1e3e8bfa881c8388fa06e6cf64f9950f
[ "MIT" ]
permissive
KATO-Hiro/atcoder-1
7d45abb7f5d3cef7e8733a216a334c9c66889b71
c2cbfcfd5c3d46ac9810ba330a37d437aa2839c2
refs/heads/master
2023-06-23T09:25:53.545274
2021-07-25T14:20:01
2021-07-25T14:20:01
339,631,102
0
0
MIT
2021-07-25T16:56:58
2021-02-17T06:25:11
C++
UTF-8
C++
false
false
602
cpp
#include <bits/stdc++.h> using namespace std; // -------------------------------------------------------- // reference: https://boostjp.github.io/tips/multiprec-int.html #include <boost/multiprecision/cpp_int.hpp> typedef boost::multiprecision::cpp_int bint; int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); bint A; cin >> A; bint B; cin >> B; bint ans = A + B; cout << ans << '\n'; return 0; } // Verify: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_2_A&lang=ja // please use language: C++11 (not C++17)
[ "tsuyo.mts@gmail.com" ]
tsuyo.mts@gmail.com
c95da77ec0698cbf1fc8d1dbd850ecf5a56e9cef
87c69454346b1550da7da37f1b7ebfe5468b587c
/IO/printf/1/main.cpp
0146afbf691031eace61a0da37e8d4d7a83bda4f
[]
no_license
hnlylmlzh/cs
4305ae18d35d7fe774ae0ece263a68bea882ab6a
b45154053d46c3b3b1e912946d1acaa65e99089b
refs/heads/master
2022-03-20T17:45:10.202053
2019-04-15T08:54:05
2019-04-15T08:54:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
918
cpp
#include <iostream> #include <stdint.h> #include <stdio.h> int main() { int i = 20; unsigned int j = 300; uint64_t k = 4294967295; // (2 32) - 1 uint64_t l = 5294967295; printf("%d, %d, %d, %d \n", i, j, k, l); printf("%ld, %ld, %ld, %ld \n", i, j, k, l); uint32_t m = 4294967295; printf("%ld \n", 2 * m); uint32_t o = 4294967295; uint32_t o1 = 10; printf("hehe %ld \n", (uint64_t)(o1 * o)); printf("hehe %ld \n", (uint64_t)o1 * o); printf("%lu \n", (uint64_t)2 * o); uint32_t p = 4294967295; printf("%ld \n", -(uint64_t)2 * p); printf("haha %ld \n", (uint64_t)(2 * o)); printf("%lu \n", (uint64_t)2 * o); // uint32_t p = 4294967295; // printf("%ld \n", -(uint64_t)2 * p); uint64_t n = 4294967295; printf("%ld \n", 2 * n); uint64_t q = (uint64_t)-2; printf("%ld \n", q); printf("%lu \n", q); return 0; }
[ "sunyongjie1984@gmail.com" ]
sunyongjie1984@gmail.com
3ef6cacbfa1e7466d5f560c89fa9f41466c5bb68
c67cbd22f9bc3c465fd763fdf87172f2c8ec77d4
/Desktop/Please Work/build/Android/Preview/app/src/main/include/Fuse.Controls.Native.ITextView.h
69625ed6920616de3035565a42df3a9fd8cbbc2d
[]
no_license
AzazelMoreno/Soteria-project
7c58896d6bf5a9ad919bde6ddc2a30f4a07fa0d4
04fdb71065941176867fb9007ecf38bbf851ad47
refs/heads/master
2020-03-11T16:33:22.153713
2018-04-19T19:47:55
2018-04-19T19:47:55
130,120,337
0
0
null
null
null
null
UTF-8
C++
false
false
2,538
h
// This file was generated based on C:/Users/rudy0/AppData/Local/Fusetools/Packages/Fuse.Controls.Native/1.8.1/Interfaces.uno. // WARNING: Changes might be lost if you edit this file directly. #pragma once #include <Fuse.Controls.Native.ILeafView.h> #include <Fuse.Controls.Native.IView.h> #include <Uno.IDisposable.h> #include <Uno.Object.h> namespace g{namespace Fuse{struct Font;}} namespace g{namespace Uno{struct Float4;}} namespace g{ namespace Fuse{ namespace Controls{ namespace Native{ // public abstract interface ITextView :24 // { uInterfaceType* ITextView_typeof(); struct ITextView { void(*fp_set_Font)(uObject*, ::g::Fuse::Font*); void(*fp_set_FontSize)(uObject*, float*); void(*fp_set_LineSpacing)(uObject*, float*); void(*fp_set_MaxLength)(uObject*, int32_t*); void(*fp_set_TextAlignment)(uObject*, int32_t*); void(*fp_set_TextColor)(uObject*, ::g::Uno::Float4*); void(*fp_set_TextTruncation)(uObject*, int32_t*); void(*fp_set_TextWrapping)(uObject*, int32_t*); void(*fp_set_Value)(uObject*, uString*); static void Font(const uInterface& __this, ::g::Fuse::Font* value) { __this.VTable<ITextView>()->fp_set_Font(__this, value); } static void FontSize(const uInterface& __this, float value) { __this.VTable<ITextView>()->fp_set_FontSize(__this, &value); } static void LineSpacing(const uInterface& __this, float value) { __this.VTable<ITextView>()->fp_set_LineSpacing(__this, &value); } static void MaxLength(const uInterface& __this, int32_t value) { __this.VTable<ITextView>()->fp_set_MaxLength(__this, &value); } static void TextAlignment(const uInterface& __this, int32_t value) { __this.VTable<ITextView>()->fp_set_TextAlignment(__this, &value); } static void TextColor(const uInterface& __this, ::g::Uno::Float4 value); static void TextTruncation(const uInterface& __this, int32_t value) { __this.VTable<ITextView>()->fp_set_TextTruncation(__this, &value); } static void TextWrapping(const uInterface& __this, int32_t value) { __this.VTable<ITextView>()->fp_set_TextWrapping(__this, &value); } static void Value(const uInterface& __this, uString* value) { __this.VTable<ITextView>()->fp_set_Value(__this, value); } }; }}}} // ::g::Fuse::Controls::Native #include <Uno.Float4.h> namespace g{ namespace Fuse{ namespace Controls{ namespace Native{ inline void ITextView::TextColor(const uInterface& __this, ::g::Uno::Float4 value) { __this.VTable<ITextView>()->fp_set_TextColor(__this, &value); } // } }}}} // ::g::Fuse::Controls::Native
[ "rudy0604594@gmail.com" ]
rudy0604594@gmail.com
95251c5f6450d81006863bb877569396f84001d5
8c3e9115e9e5fc404c057af7bfbf9b41d7585e87
/process.cpp
5d04edb7444ab3ae818fd9afdc272729bdc758cc
[]
no_license
AndrewHarter/OS_Process
41900ea313fef1722c3f93176681e0ecbef1c584
d181eb801530aa3eb15d9fa306523596c0eab3b5
refs/heads/master
2020-07-20T15:49:50.354350
2019-09-05T23:15:03
2019-09-05T23:15:03
206,671,933
0
0
null
null
null
null
UTF-8
C++
false
false
941
cpp
#include "process.h" Process::Process(int pid, int burst, int arrival, int priority, int deadline, int io){ this->pid = pid; this->burst = burst; this->arrival = arrival; this->priority = priority; this->deadline = deadline; this->io = io; } void Process::print_rts() const{ cout << "Pid: " << this->pid << endl; cout << "Burst: " << this->burst << endl; cout << "Arrival: " << this->arrival << endl; cout << "Deadline: " << this->deadline << endl; cout << "\n"; } void Process::print_mfqs() const{ cout << "Pid: " << this->pid << endl; cout << "Burst: " << this->burst << endl; cout << "Arrival: " << this->arrival << endl; cout << "priority: " << this->priority << endl; cout << "\n"; } void Process::print_whs() const{ cout << "Pid: " << this->pid << endl; cout << "Burst: " << this->burst << endl; cout << "Arrival: " << this->arrival << endl; cout << "priority: " << this->priority << endl; cout << "\n"; }
[ "harteraj@uwec.edu" ]
harteraj@uwec.edu
2f0db263cb9955128b6351bcdbfb49c120fd1df5
b39e187e9d47d9fd3470d6f25fdd3a92eb25f11b
/source/directwrite/ITextRenderer.cpp
a59e3bedaeb5b4121352dafedc0630ac50f373fa
[ "MIT" ]
permissive
SlimDX/slimdx
b0e22cb26b5da34ad3dd522ced54768b71b3e929
284f3ab1ddadc17b4091bfa7c7b9faed8bf0ded8
refs/heads/master
2022-09-02T19:14:14.879176
2022-08-31T03:04:57
2022-08-31T03:04:57
32,283,841
93
49
MIT
2022-08-31T03:04:58
2015-03-15T21:01:40
C++
UTF-8
C++
false
false
5,613
cpp
/* * Copyright (c) 2007-2012 SlimDX Group * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ #include "stdafx.h" #include "DirectWriteException.h" #include "ITextRenderer.h" const IID IID_IDWriteTextRenderer = __uuidof(IDWriteTextRenderer); using namespace System; namespace SlimDX { namespace DirectWrite { ITextRendererShim *ITextRendererShim::CreateInstance(ITextRenderer ^wrappedInterface) { if (wrappedInterface == nullptr) return NULL; return new ITextRendererShim(wrappedInterface); } ITextRendererShim::ITextRendererShim(ITextRenderer ^wrappedInterface) : m_WrappedInterface(wrappedInterface), m_refCount(1) { } HRESULT ITextRendererShim::QueryInterface(const IID &iid, LPVOID *ppv) { if (iid == IID_IDWriteTextRenderer) { AddRef(); *reinterpret_cast<IDWriteTextRenderer**>(ppv) = this; return S_OK; } return E_NOTIMPL; } ULONG ITextRendererShim::AddRef() { return ++m_refCount; } ULONG ITextRendererShim::Release() { if (--m_refCount == 0) { delete this; } return m_refCount; } HRESULT ITextRendererShim::IsPixelSnappingDisabled(void* clientDrawingContext, BOOL* isDisabled) { try { *isDisabled = m_WrappedInterface->IsPixelSnappingDisabled(IntPtr(clientDrawingContext)); return S_OK; } catch(SlimDXException^ e) { return e->ResultCode.Code; } catch(...) { return E_FAIL; } } HRESULT ITextRendererShim::GetCurrentTransform(void* clientDrawingContext, DWRITE_MATRIX* transform) { try { Matrix3x2 result = m_WrappedInterface->GetCurrentTransform(IntPtr(clientDrawingContext)); memcpy(transform, &result, sizeof(DWRITE_MATRIX)); return S_OK; } catch(SlimDXException^ e) { return e->ResultCode.Code; } catch(...) { return E_FAIL; } } HRESULT ITextRendererShim::GetPixelsPerDip(void* clientDrawingContext, FLOAT* pixelsPerDip) { try { *pixelsPerDip = m_WrappedInterface->GetPixelsPerDip(IntPtr(clientDrawingContext)); return S_OK; } catch(SlimDXException^ e) { return e->ResultCode.Code; } catch(...) { return E_FAIL; } } HRESULT ITextRendererShim::DrawGlyphRun(void* clientDrawingContext, FLOAT baselineOriginX, FLOAT baselineOriginY, DWRITE_MEASURING_MODE measuringMode, DWRITE_GLYPH_RUN const* glyphRun, DWRITE_GLYPH_RUN_DESCRIPTION const* glyphRunDescription, IUnknown* clientDrawingEffect) { try { Result result = m_WrappedInterface->DrawGlyphRun(IntPtr(clientDrawingContext), baselineOriginX, baselineOriginY, static_cast<MeasuringMode>(measuringMode), gcnew GlyphRun(*glyphRun), gcnew GlyphRunDescription(*glyphRunDescription), IntPtr(clientDrawingEffect)); return result.Code; } catch(SlimDXException^ e) { return e->ResultCode.Code; } catch(...) { return E_FAIL; } } HRESULT ITextRendererShim::DrawUnderline(void* clientDrawingContext, FLOAT baselineOriginX, FLOAT baselineOriginY, DWRITE_UNDERLINE const* underline, IUnknown* clientDrawingEffect) { try { Result result = m_WrappedInterface->DrawUnderline(IntPtr(clientDrawingContext), baselineOriginX, baselineOriginY, gcnew Underline(*underline), IntPtr(clientDrawingEffect)); return result.Code; } catch(SlimDXException^ e) { return e->ResultCode.Code; } catch(...) { return E_FAIL; } } HRESULT ITextRendererShim::DrawStrikethrough(void* clientDrawingContext, FLOAT baselineOriginX, FLOAT baselineOriginY, DWRITE_STRIKETHROUGH const* strikethrough, IUnknown* clientDrawingEffect) { try { Result result = m_WrappedInterface->DrawStrikethrough(IntPtr(clientDrawingContext), baselineOriginX, baselineOriginY, gcnew Strikethrough(*strikethrough), IntPtr(clientDrawingEffect)); return result.Code; } catch(SlimDXException^ e) { return e->ResultCode.Code; } catch(...) { return E_FAIL; } } HRESULT ITextRendererShim::DrawInlineObject(void* clientDrawingContext, FLOAT originX, FLOAT originY, IDWriteInlineObject* inlineObject, BOOL isSideways, BOOL isRightToLeft, IUnknown* clientDrawingEffect) { try { Result result = m_WrappedInterface->DrawInlineObject(IntPtr(clientDrawingContext), originX, originY, InlineObject::FromPointer(inlineObject), isSideways != 0, isRightToLeft != 0, IntPtr(clientDrawingEffect)); return result.Code; } catch(SlimDXException^ e) { return e->ResultCode.Code; } catch(...) { return E_FAIL; } } } }
[ "mike.popoloski@090eb97a-982f-0410-b69a-795f42cc130f" ]
mike.popoloski@090eb97a-982f-0410-b69a-795f42cc130f
2e72c47f133cc4b2f235909fc164a276b55b73f9
db294b9ab77372536f681c764b10c9b280b99d84
/demo/test_libbatools.cpp
e0ac53f1f1a3ea288dd4c27162e86da574e5802f
[]
no_license
weidong-whu/libBATools
f53c549045ce1413537eda3b34f7305801220c09
e4494c1cf2704bdd65e990f20bcd7914a38093e0
refs/heads/master
2020-11-24T21:54:42.748055
2019-12-16T09:35:38
2019-12-16T09:35:38
228,356,179
1
0
null
2019-12-16T10:00:27
2019-12-16T10:00:26
null
UTF-8
C++
false
false
754
cpp
#include "libBATools.h" #include <tchar.h> #include <iostream> bool testProjection(const libba::BAImageInfo & image, const libba::baPoint3d & pt_world, libba::baPoint2d & pt_img) { return image.isInImage(pt_world, &pt_img); } int _tmain(int argc, _TCHAR* argv[]) { if (argc < 3) { return false; } std::string bundle_out = argv[1]; std::string image_list = argv[2]; std::vector<libba::BAImageInfo> image_data; if (!loadBundleOutFiles(image_list, bundle_out, image_data)) { std::cerr << "failed to load image bundle files" << std::endl; return EXIT_FAILURE; } libba::baPoint2d image_point; if (!testProjection(image_data[0], libba::baPoint3d(0, 0, 0), image_point)) { std::cout << "point out of range" << std::endl; } return 0; }
[ "liuxy0319@outlook.com" ]
liuxy0319@outlook.com
a9b46333f516648748f97dcde460c5976c6244b9
205adf81a773b9aa91d12ae3b55fd03cab39610f
/RelayAndGPIOModules/USBRelayAndGPIOModules/c/VCExpress2010/usbgpio8/USBGpio8Demo/stdafx.cpp
dc6c9fc05c41b4a27d96fcdeb4705e87afb5d4e3
[]
no_license
numato/samplecode
25d9a72f2ff8d09ed9114b479971ac4802e208be
e6dfd7fcd1b0f55543ea2f4bfc5ad8e4822ca088
refs/heads/master
2022-12-27T14:26:34.834633
2022-12-16T08:40:22
2022-12-16T08:40:22
43,082,129
139
385
null
2023-08-24T06:38:16
2015-09-24T17:30:13
C
UTF-8
C++
false
false
291
cpp
// stdafx.cpp : source file that includes just the standard includes // USBGpio8Demo.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h" // TODO: reference any additional headers you need in STDAFX.H // and not in this file
[ "sales@numato.com" ]
sales@numato.com
c6242e315e2ce905cbc09d6fb35669dc7b3ac1c5
dd6147bf9433298a64bbceb7fdccaa4cc477fba6
/8304/Mukhin_Aleksandr/lab4/units/military/SpecialForces.cpp
3791b9e45ee212fd0993a9510dc11241fe1fceda
[]
no_license
moevm/oop
64a89677879341a3e8e91ba6d719ab598dcabb49
faffa7e14003b13c658ccf8853d6189b51ee30e6
refs/heads/master
2023-03-16T15:48:35.226647
2020-06-08T16:16:31
2020-06-08T16:16:31
85,785,460
42
304
null
2023-03-06T23:46:08
2017-03-22T04:37:01
C++
UTF-8
C++
false
false
122
cpp
#include "SpecialForces.h" void SpecialForces::greeting() const { std::cout << "I'm SpecialForces!" << std::endl; }
[ "myxin200015@mail.ru" ]
myxin200015@mail.ru
f1725c33abc2c9e7a3c5284282a235b5dd25fdc2
bfe4fd0102795f9600ffb10c6d768a2534b49c94
/LeetCode/LeetCode-30days-challenge/Backspace String Compare.cpp
60c8f40c4edb61d1fdebaf116919248e414dad0b
[]
no_license
aryabhatta22/CompetitiveCoding
b4a9e03fe53af2d5049b3d6ab64d89c5a0b2002f
decfb0f8b4d866e3a095f4bce333f4c3dc58940f
refs/heads/master
2021-07-13T18:03:53.456484
2020-08-22T13:08:46
2020-08-22T13:08:46
199,398,576
0
0
null
null
null
null
UTF-8
C++
false
false
1,036
cpp
/*************************************** Description: Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character. Example 1: Input: S = "ab#c", T = "ad#c" Output: true Explanation: Both S and T become "ac". Example 2: Input: S = "ab##", T = "c#d#" Output: true Explanation: Both S and T become "". Example 3: Input: S = "a##c", T = "#a#c" Output: true Explanation: Both S and T become "c". ***************************************/ bool backspaceCompare(string S, string T) { string s1; string s2; for(auto ch: S) { if(ch == '#'){ if(!s1.empty()) s1.pop_back(); } else s1.push_back(ch); } for(auto ch: T) { if(ch == '#'){ if(!s2.empty()) s2.pop_back(); } else s2.push_back(ch); } return s1 == s2; }
[ "tarun.hive@hotmail.com" ]
tarun.hive@hotmail.com
a4207dc37079ac95ea64b3a6b8fe31784a6a2d82
7ab190f26ff7046a4ef473e732ee6304055d195e
/src/Corrade.h
41740b04aec00da42fbabc71d5ac439978044b6c
[ "MIT" ]
permissive
piaoger/corrade
4729937a0b1b3214a8f55f4830e9a0afd42a0809
5c349681b831a19e8da11dfb4284c985b994e354
refs/heads/master
2021-01-22T01:42:46.660258
2013-11-17T21:03:26
2013-11-17T21:15:59
null
0
0
null
null
null
null
UTF-8
C++
false
false
3,309
h
#ifndef Corrade_Corrade_h #define Corrade_Corrade_h /* This file is part of Corrade. Copyright © 2007, 2008, 2009, 2010, 2011, 2012, 2013 Vladimír Vondruš <mosra@centrum.cz> 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. */ /** @file * @brief Basic definitions */ #include "corradeCompatibility.h" namespace Corrade { #ifdef DOXYGEN_GENERATING_OUTPUT /** @brief GCC 4.7 compatibility Defined if compatibility mode for GCC 4.7 is enabled. @see @ref building-corrade */ #define CORRADE_GCC47_COMPATIBILITY #undef CORRADE_GCC47_COMPATIBILITY /** @brief GCC 4.6 compatibility Defined if compatibility mode for GCC 4.6 is enabled. @see @ref building-corrade */ #define CORRADE_GCC46_COMPATIBILITY #undef CORRADE_GCC46_COMPATIBILITY /** @brief Build with deprecated API included Defined if the library contains deprecated API (which will be removed in the future). To preserve backward compatibility, %Corrade is by default built with deprecated API included. @see @ref building-corrade */ #define CORRADE_BUILD_DEPRECATED /* (enabled by default) */ /** @brief Static library build Defined if built as static libraries. Default are shared libraries. @see @ref building-corrade */ #define CORRADE_BUILD_STATIC #undef CORRADE_BUILD_STATIC /** @brief Google Chrome Native Client target Defined if the library is built for [Google Chrome Native Client](https://developers.google.com/native-client/). @see @ref building-corrade */ #define CORRADE_TARGET_NACL #undef CORRADE_TARGET_NACL /** @brief Google Chrome Native Client target with `newlib` toolchain Defined if the library is built for Google Chrome Native Client with `newlib` toolchain. @see @ref building-corrade */ #define CORRADE_TARGET_NACL_NEWLIB #undef CORRADE_TARGET_NACL_NEWLIB /** @brief Google Chrome Native Client target with `glibc` toolchain Defined if the library is built for Google Chrome Native Client with `glibc` toolchain. @see @ref building-corrade */ #define CORRADE_TARGET_NACL_GLIBC #undef CORRADE_TARGET_NACL_GLIBC /** @brief Emscripten target Defined if the library is built for [Emscripten](https://github.com/kripken/emscripten/wiki). @see @ref building-corrade */ #define CORRADE_TARGET_EMSCRIPTEN #undef CORRADE_TARGET_EMSCRIPTEN #endif } #endif
[ "mosra@centrum.cz" ]
mosra@centrum.cz
dae20253637ab42b4c46a26ec77973b601adbc90
75860c9149d79ba41a787a084e01075c0c989b53
/src/102.cpp
4cdf3f193c529d041ad8513b0d3ee49cfb2e5d41
[]
no_license
Deseteral/uva-problems
0c9d786c1dcef978e8daca8b90105e50f4f2072d
f943fb5be65f9a83df289afee45cce26b2be4d9c
refs/heads/master
2020-03-28T19:34:50.026782
2018-09-16T11:27:36
2018-09-16T11:27:36
148,988,939
0
0
null
null
null
null
UTF-8
C++
false
false
1,933
cpp
#include <cstdio> int main() { unsigned int in[9]; while(scanf_s("%d %d %d %d %d %d %d %d %d", &in[0], &in[1], &in[2], &in[3], &in[4], &in[5], &in[6], &in[7], &in[8]) != EOF) { unsigned int outcome[6]; for (int i = 0; i < 6; i++) { unsigned int moves = 0; switch (i) { case 4: // GBC moves += in[4]; moves += in[7]; moves += in[0]; moves += in[6]; moves += in[2]; moves += in[5]; outcome[i] = moves; break; case 5: // GCB moves += in[4]; moves += in[7]; moves += in[2]; moves += in[8]; moves += in[0]; moves += in[3]; outcome[i] = moves; break; case 0: // BCG moves += in[3]; moves += in[6]; moves += in[2]; moves += in[8]; moves += in[1]; moves += in[4]; outcome[i] = moves; break; case 1: // BGC moves += in[3]; moves += in[6]; moves += in[1]; moves += in[7]; moves += in[2]; moves += in[5]; outcome[i] = moves; break; case 2: // CBG moves += in[5]; moves += in[8]; moves += in[0]; moves += in[6]; moves += in[1]; moves += in[4]; outcome[i] = moves; break; case 3: // CGB moves += in[5]; moves += in[8]; moves += in[1]; moves += in[7]; moves += in[0]; moves += in[3]; outcome[i] = moves; break; } } unsigned int min = 1000; unsigned int i_min = 1000; for (int i = 0; i < 6; i++) { if (outcome[i] < min) { min = outcome[i]; i_min = i; } if (outcome[i] == min) { if (i < i_min) { min = outcome[i]; i_min = i; } } } switch (i_min) { case 4: printf("GBC"); break; case 5: printf("GCB"); break; case 0: printf("BCG"); break; case 1: printf("BGC"); break; case 2: printf("CBG"); break; case 3: printf("CGB"); break; } printf(" %d\n", min); } return 0; }
[ "deseteral@gmail.com" ]
deseteral@gmail.com
583c394bb502996d1852c31f105d17a64df220ca
80315f1bba85314018587f46ee309a00638d14d4
/Config.h
5f397e22a85d2a3d2bd60e2fdd35950fd747199e
[]
no_license
pope88/Servers
e54ae276ca4979bccd4043e823f0c7e56a444075
332960c5878a733fd6daf77c15a856d7570c8b5b
refs/heads/master
2021-01-10T22:05:07.995636
2013-12-18T11:59:52
2013-12-18T11:59:52
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,287
h
#ifndef SYSTEM_CONFIG_H #define SYSTEM_CONFIG_H //////////////////////////////////////////////////////////// // Identify the operating system //////////////////////////////////////////////////////////// #if defined(_WIN32) || defined(__WIN32__) // Windows #define SYSTEM_SYSTEM_WINDOWS #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #ifndef NOMINMAX #define NOMINMAX #endif #include <windows.h> #include <winsock2.h> #define strcasecmp _stricmp #define strncasecmp _strnicmp #elif defined(linux) || defined(__linux) // Linux #define SYSTEM_SYSTEM_LINUX #elif defined(__APPLE__) || defined(MACOSX) || defined(macintosh) || defined(Macintosh) // MacOS #define SYSTEM_SYSTEM_MACOS #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) // FreeBSD #define SYSTEM_SYSTEM_FREEBSD #else // Unsupported system #error This operating system is not supported by this library #endif //////////////////////////////////////////////////////////// // Identify the endianess //////////////////////////////////////////////////////////// #if defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || (defined(__MIPS__) && defined(__MISPEB__)) || \ defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || defined(__sparc__) || defined(__Ha__) // Big endian #define SYSTEM_ENDIAN_BIG #else // Little endian #define SYSTEM_ENDIAN_LITTLE #endif #include <climits> #include <cstdio> #include <cstdlib> #undef __STRICT_ANSI__ #include <cstring> #define __STRICT_ANSI__ #include <ctime> #include <cassert> #include <iostream> #include <vector> #include <map> #include <set> #include <unordered_map> #include <unordered_set> #include <deque> #include <queue> #include <list> #include <memory> #include <string> #include <algorithm> #include <functional> #ifdef _MSC_VER #pragma warning(disable : 4251) #if _MSC_VER < 1600 namespace std { using namespace std::tr1; template <typename T> inline T& move(T& t) { return t; } } #define unique_ptr auto_ptr #endif #define strtoull _strtoui64 #define strtoll _strtoi64 #define ATTR_PACKED() #define FINLINE #else #define ATTR_PACKED() __attribute__((packed)) #if defined(__MINGW32__) #define FINLINE inline #else #define FINLINE inline __attribute__((always_inline)) #endif #endif #if defined(_WIN32) || defined(__WIN32__) #define I64_FMT "I64" #define snprintf _snprintf #define vsnprintf _vsnprintf #include <io.h> #else #if defined(__LP64__) #define I64_FMT "l" #elif defined(__APPLE__) #define I64_FMT "q" #else #define I64_FMT "ll" #endif #include <unistd.h> #endif // 8 bits integer types #if UCHAR_MAX == 0xFF typedef signed char Int8; typedef unsigned char UInt8; #else #error No 8 bits integer type for this platform #endif // 16 bits integer types #if USHRT_MAX == 0xFFFF typedef signed short Int16; typedef unsigned short UInt16; #elif UINT_MAX == 0xFFFF typedef signed int Int16; typedef unsigned int UInt16; #elif ULONG_MAX == 0xFFFF typedef signed long Int16; typedef unsigned long UInt16; #else #error No 16 bits integer type for this platform #endif // 32 bits integer types #if USHRT_MAX == 0xFFFFFFFF typedef signed short Int32; typedef unsigned short UInt32; #elif UINT_MAX == 0xFFFFFFFF typedef signed int Int32; typedef unsigned int UInt32; #elif ULONG_MAX == 0xFFFFFFFF typedef signed long Int32; typedef unsigned long UInt32; #else #error No 32 bits integer type for this platform #endif // 64 bits integer types #if USHRT_MAX == 0xFFFFFFFFFFFFFFFFull typedef signed short Int64; typedef unsigned short UInt64; #elif UINT_MAX == 0xFFFFFFFFFFFFFFFFull typedef signed int Int64; typedef unsigned int UInt64; #elif ULONG_MAX == 0xFFFFFFFFFFFFFFFFull typedef signed long Int64; typedef unsigned long UInt64; #elif ULLONG_MAX == 0xFFFFFFFFFFFFFFFFull typedef signed long long Int64; typedef unsigned long long UInt64; #else #error No 64 bits integer type for this platform #endif #define SAFE_DELETE(obj) do { delete(obj); obj = NULL; } while(0) #endif // SYSTEM_CONFIG_H
[ "pope@fanersai.com" ]
pope@fanersai.com
0b1b478e48abf5ed6328d6ff6c62c6f6978768ac
69e16f69b00bd19aa0f8a5ecc2f39dcb7efd27ab
/lec12/function1.cpp
8b1da2b7cdef136f3134b17349212555fe170364
[ "MIT" ]
permissive
2701180217/CProgrammingI_18CS123
804c60969abe9fa5d379f384047758996fcad88f
f5bb73341020b91676c5496283c3c05e9977bd5a
refs/heads/master
2020-04-08T10:16:14.566448
2018-11-19T10:17:58
2018-11-19T10:17:58
null
0
0
null
null
null
null
UTF-8
C++
false
false
200
cpp
#include<iostream> using namespace std; int add(int a, int b) { a++; return a + b; } int main() { int a = 4, b = 4; add(a, b); cout << a << endl; return 0; }
[ "zj@webturing.com" ]
zj@webturing.com
57b33a673d8666fcae83d0400f07a5f9be0fe19b
0c736428f3800e5543743b7a0795fa50a8c372cc
/demos/meltdown_of.cc
55c2096341fb2aedaaec9a403d8f7303d81b7490
[]
no_license
asteinha/sidechannel
cc2a5d7b02b8fe97f204c9102bf7f32b82112d37
ff29fd259d655344fb144277eb2aeede8dd50aba
refs/heads/master
2022-08-19T05:07:53.024378
2020-05-26T04:28:20
2020-05-26T04:28:20
266,635,938
0
1
null
null
null
null
UTF-8
C++
false
false
3,750
cc
/* * Copyright 2019 Google LLC * * 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 * * https://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. */ /** * Demonstrates speculation over the overflow trap (#OF) on IA32 CPUs. * Since the overflow trap can be invoked only by the INTO instruction and that * instruction opcode exists only on IA32, this vulnerability cannot be * demonstrated on X64 or AMD64. * We cause the overflow trap by making the OF flag in EFLAGS being set. * Afterwards we yield the INTO instruction and fetch from the address. Even * though the INTO instruction triggers OF (which is ensured by the dead code * guard), the next load is speculatively performed. **/ #include "compiler_specifics.h" #if !SAFESIDE_LINUX && !SAFESIDE_MAC # error Unsupported OS. Linux or MacOS required. #endif #if !SAFESIDE_IA32 # error Unsupported architecture. IA32 required. #endif #include <array> #include <climits> #include <cstring> #include <iostream> #include <signal.h> #include "cache_sidechannel.h" #include "instr.h" #include "meltdown_local_content.h" #include "local_content.h" static char LeakByte(const char *data, size_t offset) { CacheSideChannel sidechannel; const std::array<BigByte, 256> &oracle = sidechannel.GetOracle(); for (int run = 0;; ++run) { size_t safe_offset = run % strlen(data); sidechannel.FlushOracle(); for (int i = 0; i < 1000; ++i) { const char *safe_address = reinterpret_cast<const char *>(oracle.data() + static_cast<uint8_t>(data[safe_offset])); // Succeeds. SupposedlySafeOffsetAndDereference(safe_address, 0); const char *unsafe_address = reinterpret_cast<const char *>( oracle.data() + static_cast<uint8_t>(data[offset])); bool firstbit = reinterpret_cast<ptrdiff_t>(unsafe_address) & 0x80000000; int shift = INT_MAX - 2 * firstbit * INT_MAX; // This crashes by the OF trap being raised. SupposedlySafeOffsetAndDereference(unsafe_address + shift, -shift); std::cout << "Dead code. Must not be printed." << std::endl; // The exit call must not be unconditional, otherwise clang would // optimize out everything that follows it and the linking would fail. if (strlen(public_data) != 0) { exit(EXIT_FAILURE); } // SIGSEGV signal handler moves the instruction pointer to this label. #if SAFESIDE_LINUX asm volatile("afterspeculation:"); #elif SAFESIDE_MAC asm volatile("_afterspeculation:"); #else # error Unsupported OS. #endif } std::pair<bool, char> result = sidechannel.RecomputeScores(data[safe_offset]); if (result.first) { return result.second; } if (run > 100000) { std::cerr << "Does not converge " << result.second << std::endl; exit(EXIT_FAILURE); } } } int main() { #if SAFESIDE_LINUX OnSignalMoveRipToAfterspeculation(SIGSEGV); #elif SAFESIDE_MAC OnSignalMoveRipToAfterspeculation(SIGFPE); #else # error Unsupported OS. #endif std::cout << "Leaking the string: "; std::cout.flush(); const size_t private_offset = private_data - public_data; for (size_t i = 0; i < strlen(private_data); ++i) { std::cout << LeakByte(public_data, private_offset + i); std::cout.flush(); } std::cout << "\nDone!\n"; }
[ "asteinhauser@asteinhauser-macbookpro.roam.corp.google.com" ]
asteinhauser@asteinhauser-macbookpro.roam.corp.google.com
36a5b9cf4c96d79ef37ff49c155ef59e25ac19d6
22c66068bd9341b86ac121bbfa494afec2750625
/2016/tencent/date/date.hh
7ab73eb7224617b5c4de367a104b2d2358715fe4
[]
no_license
linghutf/topcoder
54f5124563008ae23c0ac6227c8e44579ee371ba
07da54aecaac0484675a91775140eb3c40ea5aa6
refs/heads/master
2020-04-07T06:49:33.114570
2017-05-28T08:21:10
2017-05-28T08:21:10
52,865,558
5
0
null
null
null
null
UTF-8
C++
false
false
3,912
hh
/** * * 用户应该检查isErrorDate是否是错误的日期,否则调用结果 * 出现异常,库函数只是识别错误日期 * 而不会出现异常 */ #ifndef DATE_HH_ #define DATE_HH_ typedef long timespan; const static int MONTH[]={ 31,28,31,30,31,30, 31,31,30,31,30,31 }; const static char WEEKNAME[][5]={ "Sun","Mon","Tues","Wed","Thur","Fri","Sat" }; //extern class Date; //extern timespan daysDiff(Date& d,Date &od); class Date{ private: int year_; unsigned short month_; unsigned short day_; timespan span_; timespan days_of_year_; unsigned char weekname_; bool errorDate_; void setErrorDate() { this->errorDate_ = TestIsLegalDate(this->year_,this->month_,this->day_); } public: static unsigned char GetWeek(int y,unsigned short m,unsigned short d) { if(m<3){ m+=12; --y; } return (d+1+(m<<1)+3*(m+1)/5+y+(y>>2)-y/100+y/400) % 7; } static bool TestIsLegalDate(int y,unsigned short m,unsigned short d) { bool errorDate = false; if(y==0||m>12||m<1||d>31||d<1){ errorDate=true; } if(Date::isLeapYear(y)){ if(m==2&&d>29) errorDate = true; else if(m!=2&&MONTH[m-1]<d) errorDate = true; }else{ if(MONTH[m-1]<d) errorDate = true; } return errorDate; } Date(int y=0,unsigned short m=1,unsigned short d=1):year_(y),month_(m),day_(d),span_(-1){ this->setErrorDate(); days_of_year_ = 0; } Date(Date &d):year_(d.year_),month_(d.month_),day_(d.day_),span_(d.span_),errorDate_(d.errorDate_),days_of_year_(0){} Date& operator=(Date &d) { this->year_=d.year_; this->month_=d.month_; this->day_=d.day_; this->span_=d.span_; this->errorDate_=d.errorDate_; return *this; } bool isErrorDate(){return this->errorDate_;} int year(){return this->year_;} void setYear(int year){this->year_=year;} unsigned short month(){return this->month_;} void setMonth(int month) { this->month_=month; this->setErrorDate(); } unsigned short day(){return this->day_;} void setDay(int day) { this->day_=day; this->setErrorDate(); } //like unix timespan timespan span(); //timediff timespan operator-(Date& d); timespan daysOfYear(); const char* weekname(); static bool isLeapYear(int y) { return (y%4==0&&y%100!=0)||(y%400==0); } }; //this - d timespan Date::operator-(Date& d) { return this->span()-d.span(); } const char* Date::weekname() { if(!this->isErrorDate()){ this->weekname_ = Date::GetWeek(this->year(),this->month(),this->day()); return WEEKNAME[this->weekname_]; } } timespan Date::daysOfYear() { if(this->isErrorDate()) return 0; Date zero(this->year_,1,1); this->days_of_year_ = (*this-zero)/3600/24+1; return this->days_of_year_; } timespan Date::span() { //出现错误日期 if(this->isErrorDate()) return 0; timespan i,flag=1,result=0; if(this->year_<0){ flag = -1; for(i=this->year_;i<0;++i){ result+=Date::isLeapYear(i)?366:365; } }else{ for(i=1;i<this->year_;++i){ result+=Date::isLeapYear(i)?366:365; } } result*=3600*24; timespan days = (this->month_>2&&Date::isLeapYear(this->year_))?1:0; for(i=1;i<this->month_;++i){ days += MONTH[i-1]; } days+=this->day_; if(this->year_<0) result-=days*24*3600; else result+=days*24*3600; this->span_ = flag*result; return this->span_; } //od - d timespan daysDiff(Date& d,Date& od) { timespan diff = od-d; return (diff/3600/24); } timespan weeksDiff(Date& d,Date& od) { return daysDiff(d,od)/7; } #endif
[ "xurui788@gmail.com" ]
xurui788@gmail.com
b772d74bf2fe7e955dac194a5764e3b03ffa591a
4535ed6e3586fad604ba789410f71d1a4433f20d
/KarkkainenSanders.hpp
9a1da7d2884b0a0d524f5bbfa70f36d23c0e6906
[]
no_license
riskingh/Karkkainen-Sanders
4ee5624f6dffc4243c7aa7ad86378d84c42fe219
888feb883f3584a8101cdc5a50cd551ade8ac6ca
refs/heads/master
2021-01-10T05:09:55.757111
2015-12-01T17:11:24
2015-12-01T17:11:24
47,056,777
1
0
null
null
null
null
UTF-8
C++
false
false
6,921
hpp
// // KarkkainenSanders.hpp // Karkkainen-Sanders // // Created by Maxim Grishkin on 29/11/15. // Copyright © 2015 Maxim Grishkin. All rights reserved. // #ifndef KarkkainenSanders_hpp #define KarkkainenSanders_hpp #include <stdio.h> #include <vector> #include <string> #include <list> #include <algorithm> #include <numeric> typedef int int32; typedef long long int64; typedef unsigned int uint32; typedef unsigned long long uint64; namespace KarkkainenSanders { uint32 getByIndex(const std::vector<uint32> &array, uint32 position) { return position < array.size() ? array[position] : 0; } bool equalSubsegments(const std::vector<uint32> &array, uint32 firstSubsegment, uint32 secondSubsegment, uint32 size) { for (uint32 offset = 0; offset < size; ++offset) if (getByIndex(array, firstSubsegment + offset) != getByIndex(array, secondSubsegment + offset)) return false; return true; } bool lowerSubsegment(const std::vector<uint32> &array, uint32 firstSubsegment, uint32 secondSubsegment, uint32 size) { uint32 offset; for (offset = 0; offset < size && getByIndex(array, firstSubsegment + offset) == getByIndex(array, secondSubsegment + offset); ++offset) ; return offset < size && getByIndex(array, firstSubsegment + offset) < getByIndex(array, secondSubsegment + offset); } uint32 getMax(const std::vector<uint32> &array) { uint32 maxValue = 0; for (auto value: array) maxValue = maxValue < value ? value : maxValue; return maxValue; } std::vector<uint32> suffixRadixPass(const std::vector<uint32> &array, std::vector<uint32> &suffixes, uint32 offset) { std::vector<uint32> result(suffixes.size()); std::vector<uint32> counts(getMax(array) + 1, 0); for (auto suffix: suffixes) ++counts[getByIndex(array, suffix + offset)]; for (uint32 index = 0, sum = 0; index < counts.size(); ++index) { std::swap(counts[index], sum); sum += counts[index]; } for (auto suffix: suffixes) result[counts[getByIndex(array, suffix + offset)]++] = suffix; return result; } void suffixRadixSort(const std::vector<uint32> &array, std::vector<uint32> &suffixes, uint32 suffixSize) { for (uint32 offset = 1; offset <= suffixSize; ++offset) suffixes = suffixRadixPass(array, suffixes, suffixSize - offset); } uint32 getPositionIn12(uint32 arraySize, uint32 suffix) { uint32 position = (suffix - (suffix + 2) / 3) / 2; position += suffix % 3 == 2 ? (arraySize + 1) / 3 : 0; return position; } std::vector<uint32> getSuffixes12(const std::vector<uint32> &array) { std::vector<uint32> suffixes; for (uint32 suffix = 0; suffix < array.size(); ++suffix) if (suffix % 3) suffixes.push_back(suffix); suffixRadixSort(array, suffixes, 3); std::vector<uint32> sortedNames(suffixes.size(), 1), names(suffixes.size()); for (uint32 index = 1; index < suffixes.size(); ++index) sortedNames[index] = sortedNames[index - 1] + (int)(!equalSubsegments(array, suffixes[index - 1], suffixes[index], 3)); for (uint32 index = 0; index < suffixes.size(); ++index) names[getPositionIn12((uint32)array.size(), suffixes[index])] = sortedNames[index]; return names; } bool lower(const std::vector<uint32> &array, uint32 suffix0, uint32 suffix12, const std::vector<uint32> &reversedSuffixArray12) { uint32 offset = suffix12 % 3; if (equalSubsegments(array, suffix0, suffix12, offset)) { uint32 positionIn12For0, positionIn12For12; positionIn12For0 = getPositionIn12((uint32)array.size(), suffix0 + offset); positionIn12For12 = getPositionIn12((uint32)array.size(), suffix12 + offset); return getByIndex(reversedSuffixArray12, positionIn12For0) < getByIndex(reversedSuffixArray12, positionIn12For12); } return lowerSubsegment(array, suffix0, suffix12, offset); } std::vector<uint32> getSuffixArray(const std::vector<uint32> &array) { std::vector<uint32> suffixes12 = getSuffixes12(array); std::vector<uint32> suffixArray12; if (getMax(suffixes12) == suffixes12.size()) { suffixArray12.resize(suffixes12.size()); for (uint32 suffix = 0; suffix < suffixes12.size(); ++suffix) suffixArray12[suffixes12[suffix] - 1] = suffix; } else suffixArray12 = getSuffixArray(suffixes12); std::vector<uint32> reversedSuffixArray12(suffixArray12.size()); for (uint32 index = 0; index < suffixArray12.size(); ++index) reversedSuffixArray12[suffixArray12[index]] = index + 1; std::vector<uint32> sortedSuffixes12(suffixes12.size()); for (uint32 index = 0; index < array.size(); ++index) { if (index % 3) { uint32 positionIn12 = getPositionIn12((uint32)array.size(), index); sortedSuffixes12[reversedSuffixArray12[positionIn12] - 1] = index; } } std::vector<uint32> forRadix0(array), sortedSuffixes0; for (uint32 index = 0; index < array.size(); ++index) { if (index % 3) forRadix0[index] = reversedSuffixArray12[getPositionIn12((uint32)array.size(), index)]; else sortedSuffixes0.push_back(index); } suffixRadixSort(forRadix0, sortedSuffixes0, 2); std::vector<uint32> suffixArray; uint32 index0, index12, suffix0, suffix12; for (index0 = 0, index12 = 0; index0 < sortedSuffixes0.size() && index12 < sortedSuffixes12.size(); ) { suffix0 = sortedSuffixes0[index0]; suffix12 = sortedSuffixes12[index12]; if (lower(array, suffix0, suffix12, reversedSuffixArray12)) { suffixArray.push_back(suffix0); ++index0; } else { suffixArray.push_back(suffix12); ++index12; } } for (; index0 < sortedSuffixes0.size(); ++index0) suffixArray.push_back(sortedSuffixes0[index0]); for (; index12 < sortedSuffixes12.size(); ++index12) suffixArray.push_back(sortedSuffixes12[index12]); return suffixArray; } std::vector<uint32> getSuffixArray(const std::string &str) { std::vector<uint32> intString(str.size()); for (uint32 index = 0; index < str.size(); ++index) intString[index] = (int)str[index]; return getSuffixArray(intString); } } #endif /* KarkkainenSanders_hpp */
[ "grishkin.max@gmail.com" ]
grishkin.max@gmail.com
6ac2c8d7af3ccba2fee02de42aa803fd2d49ec79
374b802c9287391ccf515220ecab074c4b847960
/Step_Three/Step_Three_Main.cpp
266f4fb1f5fdc7457011ad684fc2d1018d9f262c
[]
no_license
walleri18/Programming-under-Windows-OS
f4e815c35a6976108f65d9b88efa8ae0e5551665
3f37d151e4478bdcf12237d4e028251c50d6585b
refs/heads/master
2021-01-10T01:33:53.945166
2016-03-22T17:06:20
2016-03-22T17:06:20
51,696,190
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
3,001
cpp
#include <afxwin.h> // Индентификатор для кнопки #define IDC_MYBUTTON 100 // Индификатор для поля редактирования #define IDC_MYEDIT 102 class CMainWnd : public CFrameWnd { public: CMainWnd(); afx_msg void OnLButtonDblClk(UINT, CPoint); afx_msg void OnRButtonDblClk(UINT, CPoint); afx_msg void OnKeyDown(UINT, UINT, UINT); ~CMainWnd(); private: // Указатель на объект надписи CStatic* MyStatic; // Указатель на объект кнопки CButton* MyButton; // Указатель на объект поля редактирования CEdit* MyEdit; // Декларирование карты сообщений DECLARE_MESSAGE_MAP(); }; // Карта сообщений BEGIN_MESSAGE_MAP(CMainWnd, CFrameWnd) // Сообщение при нажатии левой кнопки мыши ON_WM_LBUTTONDBLCLK() // Сообщение при нажатии правой кнопки мыши ON_WM_RBUTTONDBLCLK() // Реакция на нажатие клавиши клавиатуры ON_WM_KEYDOWN() END_MESSAGE_MAP() void CMainWnd::OnKeyDown(UINT, UINT, UINT) { MessageBox(L" Key Button Down "); } void CMainWnd::OnRButtonDblClk(UINT, CPoint) { MessageBox(L" Rigth Button Click "); } void CMainWnd::OnLButtonDblClk(UINT, CPoint) { MessageBox(L" Left Button Click "); } CMainWnd::CMainWnd() { // Создание окна программы Create(NULL, L"Step_Three", WS_OVERLAPPEDWINDOW, rectDefault, NULL, NULL); // Создаём объект надписи MyStatic = new CStatic(); if (MyStatic != NULL) MyStatic->Create(L"MyStatic", WS_CHILD | WS_VISIBLE | SS_CENTER, CRect(10, 10, 100, 50), this); // Создаём объект кнопки MyButton = new CButton(); if (MyButton != NULL) MyButton->Create(L"MyButton", WS_CHILD | WS_VISIBLE | SS_CENTER, CRect(120, 10, 220, 50), this, IDC_MYBUTTON); // Создаём объект поля редактирования MyEdit = new CEdit(); if (MyEdit != NULL) MyEdit->Create(WS_CHILD | WS_VISIBLE | WS_BORDER, CRect(240, 10, 340, 50), this, IDC_MYEDIT); } CMainWnd::~CMainWnd() { if (MyStatic) delete MyStatic; if (MyButton) delete MyButton; if (MyEdit) delete MyEdit; } class CMyApp : public CWinApp { public: CMyApp(); BOOL InitInstance();// стандартная инициализация }; CMyApp::CMyApp() {} BOOL CMyApp::InitInstance() { // Создаём класс окна m_pMainWnd = new CMainWnd(); // Проверяем на правильность ASSERT(m_pMainWnd); // Показываем окно на экране m_pMainWnd->ShowWindow(SW_SHOW); // Обновляем окно m_pMainWnd->UpdateWindow(); // Возвращаем положительный результат, о том что окно успешно создано return TRUE; } // Переменная для запуска приложения CMyApp theApp;
[ "walleri18@yandex.ru" ]
walleri18@yandex.ru
da49bfa383d29f5704d346de0c70e3392b5b55ee
0009a1127e59580a62e0b66160f8fd75fc36b8ab
/PRMT2014/PROM02.cpp
a72f26adee58a6f6e48d3841b8c95f2381f39a1b
[]
no_license
AshishKhatkar/Codechef
2d0435804a96bd61c19011e8ad09250340067734
0d77fff1740e235794a9d0c1246eb4e2c4f3b151
refs/heads/master
2020-05-17T00:54:38.953417
2015-04-26T13:11:29
2015-04-26T13:11:29
25,470,724
0
0
null
null
null
null
UTF-8
C++
false
false
693
cpp
/* ashish1610 */ #include<bits/stdc++.h> using namespace std; long long int fib_series[44]={1,2,3,5,8,13,21,34,55,89,144,233,377,610,987,1597,2584,4181,6765,10946,17711,28657,46368,75025,121393,196418,317811,514229,832040,1346269,2178309,3524578,5702887,9227465,14930352,24157817,39088169,63245986,102334155,165580141,267914296,433494437,701408733,1134903170}; int main() { long long int t,i,n,ind; scanf("%lld",&t); while(cin>>n) { ind=43; for(i=43;i>=0;--i) { if(fib_series[i]<=n) { ind=i; break; } } for(i=ind;i>=0;--i) { if(fib_series[i]<=n) { printf("1"); n-=fib_series[i]; } else printf("0"); } printf("\n"); } return 0; }
[ "akhatkar64@gmail.com" ]
akhatkar64@gmail.com
8391e9c60c97d415d4cf7b17fc7d2a813822c44e
a06a9ae73af6690fabb1f7ec99298018dd549bb7
/_Library/_Include/boost/phoenix/object/detail/preprocessed/new_40.hpp
f9abf5b649b60bdd16fad54848b67c8f15a8dc43
[]
no_license
longstl/mus12
f76de65cca55e675392eac162dcc961531980f9f
9e1be111f505ac23695f7675fb9cefbd6fa876e9
refs/heads/master
2021-05-18T08:20:40.821655
2020-03-29T17:38:13
2020-03-29T17:38:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
50,667
hpp
//////////////////////////////////////////////////////////////////////////////// // new_40.hpp /*============================================================================== Copyright (c) 2005-2010 Joel de Guzman Copyright (c) 2010 Thomas Heller 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) ==============================================================================*/ template <typename T, typename A0> inline typename expression::new_<detail::target<T>, A0>::type const new_(A0 const& a0) { return expression:: new_<detail::target<T>, A0>:: make(detail::target<T>(), a0); } template <typename T, typename A0 , typename A1> inline typename expression::new_<detail::target<T>, A0 , A1>::type const new_(A0 const& a0 , A1 const& a1) { return expression:: new_<detail::target<T>, A0 , A1>:: make(detail::target<T>(), a0 , a1); } template <typename T, typename A0 , typename A1 , typename A2> inline typename expression::new_<detail::target<T>, A0 , A1 , A2>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2) { return expression:: new_<detail::target<T>, A0 , A1 , A2>:: make(detail::target<T>(), a0 , a1 , a2); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3>:: make(detail::target<T>(), a0 , a1 , a2 , a3); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11 , A12 const& a12) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11 , a12); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11 , A12 const& a12 , A13 const& a13) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11 , a12 , a13); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11 , A12 const& a12 , A13 const& a13 , A14 const& a14) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11 , a12 , a13 , a14); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 , typename A15> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11 , A12 const& a12 , A13 const& a13 , A14 const& a14 , A15 const& a15) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11 , a12 , a13 , a14 , a15); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 , typename A15 , typename A16> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11 , A12 const& a12 , A13 const& a13 , A14 const& a14 , A15 const& a15 , A16 const& a16) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11 , a12 , a13 , a14 , a15 , a16); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 , typename A15 , typename A16 , typename A17> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11 , A12 const& a12 , A13 const& a13 , A14 const& a14 , A15 const& a15 , A16 const& a16 , A17 const& a17) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11 , a12 , a13 , a14 , a15 , a16 , a17); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 , typename A15 , typename A16 , typename A17 , typename A18> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11 , A12 const& a12 , A13 const& a13 , A14 const& a14 , A15 const& a15 , A16 const& a16 , A17 const& a17 , A18 const& a18) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11 , a12 , a13 , a14 , a15 , a16 , a17 , a18); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 , typename A15 , typename A16 , typename A17 , typename A18 , typename A19> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11 , A12 const& a12 , A13 const& a13 , A14 const& a14 , A15 const& a15 , A16 const& a16 , A17 const& a17 , A18 const& a18 , A19 const& a19) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11 , a12 , a13 , a14 , a15 , a16 , a17 , a18 , a19); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 , typename A15 , typename A16 , typename A17 , typename A18 , typename A19 , typename A20> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11 , A12 const& a12 , A13 const& a13 , A14 const& a14 , A15 const& a15 , A16 const& a16 , A17 const& a17 , A18 const& a18 , A19 const& a19 , A20 const& a20) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11 , a12 , a13 , a14 , a15 , a16 , a17 , a18 , a19 , a20); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 , typename A15 , typename A16 , typename A17 , typename A18 , typename A19 , typename A20 , typename A21> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11 , A12 const& a12 , A13 const& a13 , A14 const& a14 , A15 const& a15 , A16 const& a16 , A17 const& a17 , A18 const& a18 , A19 const& a19 , A20 const& a20 , A21 const& a21) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11 , a12 , a13 , a14 , a15 , a16 , a17 , a18 , a19 , a20 , a21); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 , typename A15 , typename A16 , typename A17 , typename A18 , typename A19 , typename A20 , typename A21 , typename A22> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11 , A12 const& a12 , A13 const& a13 , A14 const& a14 , A15 const& a15 , A16 const& a16 , A17 const& a17 , A18 const& a18 , A19 const& a19 , A20 const& a20 , A21 const& a21 , A22 const& a22) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11 , a12 , a13 , a14 , a15 , a16 , a17 , a18 , a19 , a20 , a21 , a22); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 , typename A15 , typename A16 , typename A17 , typename A18 , typename A19 , typename A20 , typename A21 , typename A22 , typename A23> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11 , A12 const& a12 , A13 const& a13 , A14 const& a14 , A15 const& a15 , A16 const& a16 , A17 const& a17 , A18 const& a18 , A19 const& a19 , A20 const& a20 , A21 const& a21 , A22 const& a22 , A23 const& a23) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11 , a12 , a13 , a14 , a15 , a16 , a17 , a18 , a19 , a20 , a21 , a22 , a23); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 , typename A15 , typename A16 , typename A17 , typename A18 , typename A19 , typename A20 , typename A21 , typename A22 , typename A23 , typename A24> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11 , A12 const& a12 , A13 const& a13 , A14 const& a14 , A15 const& a15 , A16 const& a16 , A17 const& a17 , A18 const& a18 , A19 const& a19 , A20 const& a20 , A21 const& a21 , A22 const& a22 , A23 const& a23 , A24 const& a24) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11 , a12 , a13 , a14 , a15 , a16 , a17 , a18 , a19 , a20 , a21 , a22 , a23 , a24); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 , typename A15 , typename A16 , typename A17 , typename A18 , typename A19 , typename A20 , typename A21 , typename A22 , typename A23 , typename A24 , typename A25> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11 , A12 const& a12 , A13 const& a13 , A14 const& a14 , A15 const& a15 , A16 const& a16 , A17 const& a17 , A18 const& a18 , A19 const& a19 , A20 const& a20 , A21 const& a21 , A22 const& a22 , A23 const& a23 , A24 const& a24 , A25 const& a25) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11 , a12 , a13 , a14 , a15 , a16 , a17 , a18 , a19 , a20 , a21 , a22 , a23 , a24 , a25); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 , typename A15 , typename A16 , typename A17 , typename A18 , typename A19 , typename A20 , typename A21 , typename A22 , typename A23 , typename A24 , typename A25 , typename A26> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25 , A26>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11 , A12 const& a12 , A13 const& a13 , A14 const& a14 , A15 const& a15 , A16 const& a16 , A17 const& a17 , A18 const& a18 , A19 const& a19 , A20 const& a20 , A21 const& a21 , A22 const& a22 , A23 const& a23 , A24 const& a24 , A25 const& a25 , A26 const& a26) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25 , A26>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11 , a12 , a13 , a14 , a15 , a16 , a17 , a18 , a19 , a20 , a21 , a22 , a23 , a24 , a25 , a26); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 , typename A15 , typename A16 , typename A17 , typename A18 , typename A19 , typename A20 , typename A21 , typename A22 , typename A23 , typename A24 , typename A25 , typename A26 , typename A27> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25 , A26 , A27>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11 , A12 const& a12 , A13 const& a13 , A14 const& a14 , A15 const& a15 , A16 const& a16 , A17 const& a17 , A18 const& a18 , A19 const& a19 , A20 const& a20 , A21 const& a21 , A22 const& a22 , A23 const& a23 , A24 const& a24 , A25 const& a25 , A26 const& a26 , A27 const& a27) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25 , A26 , A27>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11 , a12 , a13 , a14 , a15 , a16 , a17 , a18 , a19 , a20 , a21 , a22 , a23 , a24 , a25 , a26 , a27); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 , typename A15 , typename A16 , typename A17 , typename A18 , typename A19 , typename A20 , typename A21 , typename A22 , typename A23 , typename A24 , typename A25 , typename A26 , typename A27 , typename A28> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25 , A26 , A27 , A28>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11 , A12 const& a12 , A13 const& a13 , A14 const& a14 , A15 const& a15 , A16 const& a16 , A17 const& a17 , A18 const& a18 , A19 const& a19 , A20 const& a20 , A21 const& a21 , A22 const& a22 , A23 const& a23 , A24 const& a24 , A25 const& a25 , A26 const& a26 , A27 const& a27 , A28 const& a28) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25 , A26 , A27 , A28>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11 , a12 , a13 , a14 , a15 , a16 , a17 , a18 , a19 , a20 , a21 , a22 , a23 , a24 , a25 , a26 , a27 , a28); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 , typename A15 , typename A16 , typename A17 , typename A18 , typename A19 , typename A20 , typename A21 , typename A22 , typename A23 , typename A24 , typename A25 , typename A26 , typename A27 , typename A28 , typename A29> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25 , A26 , A27 , A28 , A29>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11 , A12 const& a12 , A13 const& a13 , A14 const& a14 , A15 const& a15 , A16 const& a16 , A17 const& a17 , A18 const& a18 , A19 const& a19 , A20 const& a20 , A21 const& a21 , A22 const& a22 , A23 const& a23 , A24 const& a24 , A25 const& a25 , A26 const& a26 , A27 const& a27 , A28 const& a28 , A29 const& a29) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25 , A26 , A27 , A28 , A29>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11 , a12 , a13 , a14 , a15 , a16 , a17 , a18 , a19 , a20 , a21 , a22 , a23 , a24 , a25 , a26 , a27 , a28 , a29); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 , typename A15 , typename A16 , typename A17 , typename A18 , typename A19 , typename A20 , typename A21 , typename A22 , typename A23 , typename A24 , typename A25 , typename A26 , typename A27 , typename A28 , typename A29 , typename A30> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25 , A26 , A27 , A28 , A29 , A30>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11 , A12 const& a12 , A13 const& a13 , A14 const& a14 , A15 const& a15 , A16 const& a16 , A17 const& a17 , A18 const& a18 , A19 const& a19 , A20 const& a20 , A21 const& a21 , A22 const& a22 , A23 const& a23 , A24 const& a24 , A25 const& a25 , A26 const& a26 , A27 const& a27 , A28 const& a28 , A29 const& a29 , A30 const& a30) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25 , A26 , A27 , A28 , A29 , A30>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11 , a12 , a13 , a14 , a15 , a16 , a17 , a18 , a19 , a20 , a21 , a22 , a23 , a24 , a25 , a26 , a27 , a28 , a29 , a30); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 , typename A15 , typename A16 , typename A17 , typename A18 , typename A19 , typename A20 , typename A21 , typename A22 , typename A23 , typename A24 , typename A25 , typename A26 , typename A27 , typename A28 , typename A29 , typename A30 , typename A31> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25 , A26 , A27 , A28 , A29 , A30 , A31>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11 , A12 const& a12 , A13 const& a13 , A14 const& a14 , A15 const& a15 , A16 const& a16 , A17 const& a17 , A18 const& a18 , A19 const& a19 , A20 const& a20 , A21 const& a21 , A22 const& a22 , A23 const& a23 , A24 const& a24 , A25 const& a25 , A26 const& a26 , A27 const& a27 , A28 const& a28 , A29 const& a29 , A30 const& a30 , A31 const& a31) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25 , A26 , A27 , A28 , A29 , A30 , A31>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11 , a12 , a13 , a14 , a15 , a16 , a17 , a18 , a19 , a20 , a21 , a22 , a23 , a24 , a25 , a26 , a27 , a28 , a29 , a30 , a31); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 , typename A15 , typename A16 , typename A17 , typename A18 , typename A19 , typename A20 , typename A21 , typename A22 , typename A23 , typename A24 , typename A25 , typename A26 , typename A27 , typename A28 , typename A29 , typename A30 , typename A31 , typename A32> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25 , A26 , A27 , A28 , A29 , A30 , A31 , A32>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11 , A12 const& a12 , A13 const& a13 , A14 const& a14 , A15 const& a15 , A16 const& a16 , A17 const& a17 , A18 const& a18 , A19 const& a19 , A20 const& a20 , A21 const& a21 , A22 const& a22 , A23 const& a23 , A24 const& a24 , A25 const& a25 , A26 const& a26 , A27 const& a27 , A28 const& a28 , A29 const& a29 , A30 const& a30 , A31 const& a31 , A32 const& a32) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25 , A26 , A27 , A28 , A29 , A30 , A31 , A32>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11 , a12 , a13 , a14 , a15 , a16 , a17 , a18 , a19 , a20 , a21 , a22 , a23 , a24 , a25 , a26 , a27 , a28 , a29 , a30 , a31 , a32); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 , typename A15 , typename A16 , typename A17 , typename A18 , typename A19 , typename A20 , typename A21 , typename A22 , typename A23 , typename A24 , typename A25 , typename A26 , typename A27 , typename A28 , typename A29 , typename A30 , typename A31 , typename A32 , typename A33> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25 , A26 , A27 , A28 , A29 , A30 , A31 , A32 , A33>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11 , A12 const& a12 , A13 const& a13 , A14 const& a14 , A15 const& a15 , A16 const& a16 , A17 const& a17 , A18 const& a18 , A19 const& a19 , A20 const& a20 , A21 const& a21 , A22 const& a22 , A23 const& a23 , A24 const& a24 , A25 const& a25 , A26 const& a26 , A27 const& a27 , A28 const& a28 , A29 const& a29 , A30 const& a30 , A31 const& a31 , A32 const& a32 , A33 const& a33) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25 , A26 , A27 , A28 , A29 , A30 , A31 , A32 , A33>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11 , a12 , a13 , a14 , a15 , a16 , a17 , a18 , a19 , a20 , a21 , a22 , a23 , a24 , a25 , a26 , a27 , a28 , a29 , a30 , a31 , a32 , a33); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 , typename A15 , typename A16 , typename A17 , typename A18 , typename A19 , typename A20 , typename A21 , typename A22 , typename A23 , typename A24 , typename A25 , typename A26 , typename A27 , typename A28 , typename A29 , typename A30 , typename A31 , typename A32 , typename A33 , typename A34> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25 , A26 , A27 , A28 , A29 , A30 , A31 , A32 , A33 , A34>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11 , A12 const& a12 , A13 const& a13 , A14 const& a14 , A15 const& a15 , A16 const& a16 , A17 const& a17 , A18 const& a18 , A19 const& a19 , A20 const& a20 , A21 const& a21 , A22 const& a22 , A23 const& a23 , A24 const& a24 , A25 const& a25 , A26 const& a26 , A27 const& a27 , A28 const& a28 , A29 const& a29 , A30 const& a30 , A31 const& a31 , A32 const& a32 , A33 const& a33 , A34 const& a34) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25 , A26 , A27 , A28 , A29 , A30 , A31 , A32 , A33 , A34>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11 , a12 , a13 , a14 , a15 , a16 , a17 , a18 , a19 , a20 , a21 , a22 , a23 , a24 , a25 , a26 , a27 , a28 , a29 , a30 , a31 , a32 , a33 , a34); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 , typename A15 , typename A16 , typename A17 , typename A18 , typename A19 , typename A20 , typename A21 , typename A22 , typename A23 , typename A24 , typename A25 , typename A26 , typename A27 , typename A28 , typename A29 , typename A30 , typename A31 , typename A32 , typename A33 , typename A34 , typename A35> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25 , A26 , A27 , A28 , A29 , A30 , A31 , A32 , A33 , A34 , A35>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11 , A12 const& a12 , A13 const& a13 , A14 const& a14 , A15 const& a15 , A16 const& a16 , A17 const& a17 , A18 const& a18 , A19 const& a19 , A20 const& a20 , A21 const& a21 , A22 const& a22 , A23 const& a23 , A24 const& a24 , A25 const& a25 , A26 const& a26 , A27 const& a27 , A28 const& a28 , A29 const& a29 , A30 const& a30 , A31 const& a31 , A32 const& a32 , A33 const& a33 , A34 const& a34 , A35 const& a35) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25 , A26 , A27 , A28 , A29 , A30 , A31 , A32 , A33 , A34 , A35>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11 , a12 , a13 , a14 , a15 , a16 , a17 , a18 , a19 , a20 , a21 , a22 , a23 , a24 , a25 , a26 , a27 , a28 , a29 , a30 , a31 , a32 , a33 , a34 , a35); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 , typename A15 , typename A16 , typename A17 , typename A18 , typename A19 , typename A20 , typename A21 , typename A22 , typename A23 , typename A24 , typename A25 , typename A26 , typename A27 , typename A28 , typename A29 , typename A30 , typename A31 , typename A32 , typename A33 , typename A34 , typename A35 , typename A36> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25 , A26 , A27 , A28 , A29 , A30 , A31 , A32 , A33 , A34 , A35 , A36>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11 , A12 const& a12 , A13 const& a13 , A14 const& a14 , A15 const& a15 , A16 const& a16 , A17 const& a17 , A18 const& a18 , A19 const& a19 , A20 const& a20 , A21 const& a21 , A22 const& a22 , A23 const& a23 , A24 const& a24 , A25 const& a25 , A26 const& a26 , A27 const& a27 , A28 const& a28 , A29 const& a29 , A30 const& a30 , A31 const& a31 , A32 const& a32 , A33 const& a33 , A34 const& a34 , A35 const& a35 , A36 const& a36) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25 , A26 , A27 , A28 , A29 , A30 , A31 , A32 , A33 , A34 , A35 , A36>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11 , a12 , a13 , a14 , a15 , a16 , a17 , a18 , a19 , a20 , a21 , a22 , a23 , a24 , a25 , a26 , a27 , a28 , a29 , a30 , a31 , a32 , a33 , a34 , a35 , a36); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 , typename A15 , typename A16 , typename A17 , typename A18 , typename A19 , typename A20 , typename A21 , typename A22 , typename A23 , typename A24 , typename A25 , typename A26 , typename A27 , typename A28 , typename A29 , typename A30 , typename A31 , typename A32 , typename A33 , typename A34 , typename A35 , typename A36 , typename A37> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25 , A26 , A27 , A28 , A29 , A30 , A31 , A32 , A33 , A34 , A35 , A36 , A37>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11 , A12 const& a12 , A13 const& a13 , A14 const& a14 , A15 const& a15 , A16 const& a16 , A17 const& a17 , A18 const& a18 , A19 const& a19 , A20 const& a20 , A21 const& a21 , A22 const& a22 , A23 const& a23 , A24 const& a24 , A25 const& a25 , A26 const& a26 , A27 const& a27 , A28 const& a28 , A29 const& a29 , A30 const& a30 , A31 const& a31 , A32 const& a32 , A33 const& a33 , A34 const& a34 , A35 const& a35 , A36 const& a36 , A37 const& a37) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25 , A26 , A27 , A28 , A29 , A30 , A31 , A32 , A33 , A34 , A35 , A36 , A37>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11 , a12 , a13 , a14 , a15 , a16 , a17 , a18 , a19 , a20 , a21 , a22 , a23 , a24 , a25 , a26 , a27 , a28 , a29 , a30 , a31 , a32 , a33 , a34 , a35 , a36 , a37); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 , typename A15 , typename A16 , typename A17 , typename A18 , typename A19 , typename A20 , typename A21 , typename A22 , typename A23 , typename A24 , typename A25 , typename A26 , typename A27 , typename A28 , typename A29 , typename A30 , typename A31 , typename A32 , typename A33 , typename A34 , typename A35 , typename A36 , typename A37 , typename A38> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25 , A26 , A27 , A28 , A29 , A30 , A31 , A32 , A33 , A34 , A35 , A36 , A37 , A38>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11 , A12 const& a12 , A13 const& a13 , A14 const& a14 , A15 const& a15 , A16 const& a16 , A17 const& a17 , A18 const& a18 , A19 const& a19 , A20 const& a20 , A21 const& a21 , A22 const& a22 , A23 const& a23 , A24 const& a24 , A25 const& a25 , A26 const& a26 , A27 const& a27 , A28 const& a28 , A29 const& a29 , A30 const& a30 , A31 const& a31 , A32 const& a32 , A33 const& a33 , A34 const& a34 , A35 const& a35 , A36 const& a36 , A37 const& a37 , A38 const& a38) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25 , A26 , A27 , A28 , A29 , A30 , A31 , A32 , A33 , A34 , A35 , A36 , A37 , A38>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11 , a12 , a13 , a14 , a15 , a16 , a17 , a18 , a19 , a20 , a21 , a22 , a23 , a24 , a25 , a26 , a27 , a28 , a29 , a30 , a31 , a32 , a33 , a34 , a35 , a36 , a37 , a38); } template <typename T, typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9 , typename A10 , typename A11 , typename A12 , typename A13 , typename A14 , typename A15 , typename A16 , typename A17 , typename A18 , typename A19 , typename A20 , typename A21 , typename A22 , typename A23 , typename A24 , typename A25 , typename A26 , typename A27 , typename A28 , typename A29 , typename A30 , typename A31 , typename A32 , typename A33 , typename A34 , typename A35 , typename A36 , typename A37 , typename A38 , typename A39> inline typename expression::new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25 , A26 , A27 , A28 , A29 , A30 , A31 , A32 , A33 , A34 , A35 , A36 , A37 , A38 , A39>::type const new_(A0 const& a0 , A1 const& a1 , A2 const& a2 , A3 const& a3 , A4 const& a4 , A5 const& a5 , A6 const& a6 , A7 const& a7 , A8 const& a8 , A9 const& a9 , A10 const& a10 , A11 const& a11 , A12 const& a12 , A13 const& a13 , A14 const& a14 , A15 const& a15 , A16 const& a16 , A17 const& a17 , A18 const& a18 , A19 const& a19 , A20 const& a20 , A21 const& a21 , A22 const& a22 , A23 const& a23 , A24 const& a24 , A25 const& a25 , A26 const& a26 , A27 const& a27 , A28 const& a28 , A29 const& a29 , A30 const& a30 , A31 const& a31 , A32 const& a32 , A33 const& a33 , A34 const& a34 , A35 const& a35 , A36 const& a36 , A37 const& a37 , A38 const& a38 , A39 const& a39) { return expression:: new_<detail::target<T>, A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9 , A10 , A11 , A12 , A13 , A14 , A15 , A16 , A17 , A18 , A19 , A20 , A21 , A22 , A23 , A24 , A25 , A26 , A27 , A28 , A29 , A30 , A31 , A32 , A33 , A34 , A35 , A36 , A37 , A38 , A39>:: make(detail::target<T>(), a0 , a1 , a2 , a3 , a4 , a5 , a6 , a7 , a8 , a9 , a10 , a11 , a12 , a13 , a14 , a15 , a16 , a17 , a18 , a19 , a20 , a21 , a22 , a23 , a24 , a25 , a26 , a27 , a28 , a29 , a30 , a31 , a32 , a33 , a34 , a35 , a36 , a37 , a38 , a39); } ///////////////////////////////////////////////// // vnDev.Games - Trong.LIVE - DAO VAN TRONG // ////////////////////////////////////////////////////////////////////////////////
[ "adm.fael.hs@gmail.com" ]
adm.fael.hs@gmail.com
a7214d42a97513224c499aeaa11523eb0d72e24d
5135ad30aafecf8d7ce576cf14b2e61b1b1809d3
/config/test/test_lexer.cpp
16092ac4392784a0d4501038182ec37039af0a02
[]
no_license
violetkz/kutil
cdd3042943a5aafb974e06314aad3fba9b87a30f
66805ddae3ddf7966c73455d1b3766078ddf94f3
refs/heads/master
2021-01-20T08:46:37.638251
2017-06-06T04:49:05
2017-06-06T04:49:05
3,745,748
1
0
null
null
null
null
UTF-8
C++
false
false
566
cpp
#include <iostream> #include <fstream> #include <cstdio> #include <cstdlib> #include "config_lexer.hpp" int main(int argv, char *args[]){ for (int i = 1; i < argv; ++i){ std::ifstream f(args[i]); if (f.bad()) { fprintf(stderr, "open file failed"); ::exit (-1); } lexer a(f); token t; do { t = a.scan(); //std::cout << t->type_ << std::endl; //std::cout << t->str() << std::endl; std::cout << t; }while (t.type_ != T_EOF); } }
[ "proxy.vk@gmail.com" ]
proxy.vk@gmail.com
b0a0ff5668fb499a1904ebee6bc4db567f4ef2fc
e7b39d9a407fb4f21d59813e534e1194746b1c1b
/apps/incompress.cpp
dd25716ef5d8305a26cc7729e925502b28c34964
[ "Apache-2.0" ]
permissive
laosunhust/FluidSolver
9c6c84a0c5ba16d2a576f9d4046099f74da84726
d0c7fa235853863efdf44b742c70cf6673c8cf9e
refs/heads/master
2016-09-06T15:47:27.553033
2015-03-13T20:02:42
2015-03-13T20:02:42
32,176,432
1
0
null
null
null
null
UTF-8
C++
false
false
4,059
cpp
/* * Copyright 2008-2009 NVIDIA 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 "ocustorage/gridnetcdf.h" #include "ocuequation/sol_projectmixed3d.h" #include "ocuutil/timer.h" using namespace ocu; #if defined(OCU_DOUBLESUPPORT) && defined(OCU_NETCDF) int main(int argc, const char **argv) { if (argc < 4) { printf("usage: incompress <in.nc> <out.nc> [<tolerance>]\n"); exit(-1); } const char *input = argv[1]; const char *output = argv[2]; double tolerance = 1e-6; if (argc == 4) tolerance = atof(argv[3]); NetCDFGrid3DReader reader; NetCDFGrid3DWriter writer; if (!reader.open(input)) { printf("[ERROR] Could not open output file %s\n", output); exit(-1); } int nx = reader.nx(); int ny = reader.ny(); int nz = reader.nz(); float hx = reader.hx(); float hy = reader.hy(); float hz = reader.hz(); std::vector<Grid3DDimension> dimensions(3); dimensions[0].init(nx+1,ny,nz,1,1,1); dimensions[1].init(nx,ny+1,nz,1,1,1); dimensions[2].init(nx,ny,nz+1,1,1,1); Grid3DDimension::pad_for_congruence(dimensions); Grid3DHostD h_u, h_v, h_w; Grid3DDeviceD d_u, d_v, d_w; d_u.init_congruent(dimensions[0]); d_v.init_congruent(dimensions[1]); d_w.init_congruent(dimensions[2]); h_u.init_congruent(dimensions[0],true); h_v.init_congruent(dimensions[1],true); h_w.init_congruent(dimensions[2],true); Sol_ProjectDivergenceMixed3DDeviceD projector; BoundaryCondition bc; bc.type = BC_FORCED_INFLOW_VARIABLE_SLIP; projector.bc = BoundaryConditionSet(bc); projector.initialize_storage(nx, ny, nz, hx, hy, hz, &d_u, &d_v, &d_w); if (!writer.open(output, nx, ny, nz, hx, hy, hz)) { printf("[ERROR] Could not open output file %s\n", output); exit(-1); } writer.define_variable("u", NC_DOUBLE, GS_U_FACE); writer.define_variable("v", NC_DOUBLE, GS_V_FACE); writer.define_variable("w", NC_DOUBLE, GS_W_FACE); int nsteps = reader.num_time_levels(); for (int step = 0; step < nsteps; step++) { CPUTimer all_timer; all_timer.start(); reader.read_variable("u", h_u, step); reader.read_variable("v", h_v, step); reader.read_variable("w", h_w, step); d_u.copy_all_data(h_u); d_v.copy_all_data(h_v); d_w.copy_all_data(h_w); double linf_before, linf_after; projector.solve_divergence_only(); projector.divergence.reduce_maxabs(linf_before); GPUTimer solve_timer; solve_timer.start(); if (!projector.solve(tolerance)) { printf("[ERROR] Solver failed\n"); exit(-1); } solve_timer.stop(); projector.solve_divergence_only(); projector.divergence.reduce_maxabs(linf_after); h_u.copy_all_data(d_u); h_v.copy_all_data(d_v); h_w.copy_all_data(d_w); size_t out_level; writer.add_time_level(reader.get_time(step), out_level); writer.add_data("u", h_u, out_level); writer.add_data("v", h_v, out_level); writer.add_data("w", h_w, out_level); all_timer.stop(); printf("[Step %d] Error: %g / %g, Time: %f sec / %f sec (%.1f%%)\n", step, linf_before, linf_after, all_timer.elapsed_sec(), solve_timer.elapsed_sec(), 100 * solve_timer.elapsed_sec() /all_timer.elapsed_sec()); } return 0; } #else int main(int argc, const char **argv) { printf("This program can only be compiled with double precision and NetCDF support\n"); return -1; } #endif
[ "laosunhust@gmail.com" ]
laosunhust@gmail.com
a7caf444081ac645107e28a1ec09d91437b2fc99
adde0e71a48162653fec33b2a2f52abd427539d4
/x10-2.4.3-src/x10.runtime/src-cpp/gen/x10/lang/BadPlaceException.cc
64232eec1355718552efaad976007d8c050a9248
[]
no_license
indukprabhu/deepChunking
f8030f128df5b968413b7a776c56ef7695f70667
2784c6884d19493ea6372343145e557810b8e45b
refs/heads/master
2022-06-07T19:22:19.105255
2020-04-29T18:49:33
2020-04-29T18:49:33
259,726,892
0
0
null
null
null
null
UTF-8
C++
false
false
3,450
cc
/*************************************************/ /* START of BadPlaceException */ #include <x10/lang/BadPlaceException.h> #include <x10/lang/Exception.h> #include <x10/lang/String.h> #include <x10/lang/Runtime.h> #include <x10/lang/Place.h> #include <x10/compiler/Synthetic.h> //#line 23 "/home/induk/workspace/x10-2.4.3-src/x10.runtime/src-x10/x10/lang/BadPlaceException.x10" void x10::lang::BadPlaceException::_constructor() { (this)->::x10::lang::Exception::_constructor(::x10::lang::String::__plus((__extension__ ({ static ::x10::lang::String* strLit__124150 = ::x10aux::makeStringLit("bad place exception at "); strLit__124150; })), ::x10::lang::Place::_make(::x10aux::here))); //#line 18 "/home/induk/workspace/x10-2.4.3-src/x10.runtime/src-x10/x10/lang/BadPlaceException.x10" ::x10::lang::BadPlaceException* this__92964 = this; } ::x10::lang::BadPlaceException* x10::lang::BadPlaceException::_make() { ::x10::lang::BadPlaceException* this_ = new (::x10aux::alloc_z< ::x10::lang::BadPlaceException>()) ::x10::lang::BadPlaceException(); this_->_constructor(); return this_; } //#line 30 "/home/induk/workspace/x10-2.4.3-src/x10.runtime/src-x10/x10/lang/BadPlaceException.x10" void x10::lang::BadPlaceException::_constructor(::x10::lang::String* message) { (this)->::x10::lang::Exception::_constructor(message); //#line 18 "/home/induk/workspace/x10-2.4.3-src/x10.runtime/src-x10/x10/lang/BadPlaceException.x10" ::x10::lang::BadPlaceException* this__92965 = this; } ::x10::lang::BadPlaceException* x10::lang::BadPlaceException::_make(::x10::lang::String* message) { ::x10::lang::BadPlaceException* this_ = new (::x10aux::alloc_z< ::x10::lang::BadPlaceException>()) ::x10::lang::BadPlaceException(); this_->_constructor(message); return this_; } //#line 18 "/home/induk/workspace/x10-2.4.3-src/x10.runtime/src-x10/x10/lang/BadPlaceException.x10" ::x10::lang::BadPlaceException* x10::lang::BadPlaceException::x10__lang__BadPlaceException____this__x10__lang__BadPlaceException( ) { return this; } void x10::lang::BadPlaceException::__fieldInitializers_x10_lang_BadPlaceException( ) { } const ::x10aux::serialization_id_t x10::lang::BadPlaceException::_serialization_id = ::x10aux::DeserializationDispatcher::addDeserializer(::x10::lang::BadPlaceException::_deserializer); void x10::lang::BadPlaceException::_serialize_body(::x10aux::serialization_buffer& buf) { ::x10::lang::Exception::_serialize_body(buf); } ::x10::lang::Reference* ::x10::lang::BadPlaceException::_deserializer(::x10aux::deserialization_buffer& buf) { ::x10::lang::BadPlaceException* this_ = new (::x10aux::alloc_z< ::x10::lang::BadPlaceException>()) ::x10::lang::BadPlaceException(); buf.record_reference(this_); this_->_deserialize_body(buf); return this_; } void x10::lang::BadPlaceException::_deserialize_body(::x10aux::deserialization_buffer& buf) { ::x10::lang::Exception::_deserialize_body(buf); } ::x10aux::RuntimeType x10::lang::BadPlaceException::rtt; void x10::lang::BadPlaceException::_initRTT() { if (rtt.initStageOne(&rtt)) return; const ::x10aux::RuntimeType* parents[1] = { ::x10aux::getRTT< ::x10::lang::Exception>()}; rtt.initStageTwo("x10.lang.BadPlaceException",::x10aux::RuntimeType::class_kind, 1, parents, 0, NULL, NULL); } /* END of BadPlaceException */ /*************************************************/
[ "NVIDIA.COM+User(622487)@IK-LT.nvidia.com" ]
NVIDIA.COM+User(622487)@IK-LT.nvidia.com
48f6d046260ce8a4b93d05876bfe2aa34fd177b2
6140629e539bddb881a8e3cc36bbe67d2f7b727d
/python/mof/cpp/creator<ack_get_scene_objects>.h
74018a9c071bc59b9b6b3c0f78505a1d4a9d1eb1
[]
no_license
lineCode/Demos
f7ba6c7d62c5a718606107aaff9491b1245206b8
95790c799c348cb1722f6df38120b27fe28a5a7c
refs/heads/master
2020-12-02T21:18:04.477471
2017-03-16T14:52:48
2017-03-16T14:52:48
null
0
0
null
null
null
null
UTF-8
C++
false
false
165
h
#ifndef MOF_CREATOR<ACK_GET_SCENE_OBJECTS>_H #define MOF_CREATOR<ACK_GET_SCENE_OBJECTS>_H class creator<ack_get_scene_objects>{ public: void create(void); } #endif
[ "xiaobin0860@gmail.com" ]
xiaobin0860@gmail.com
a210956d6b44910692f6563e61222d58ea073d04
11d852d6f5565a0572e8017411642a9570701f91
/code/core/internal/bsnet.cpp
f745136eb136a98d6c21207d3b6a58da52d74182
[ "MIT" ]
permissive
Ninetalesgh/brewing_station
9e3e5cfb0006df65ef42c09b8366109e74460646
dd25cac1f12b97dc96f32afc7868dfcc4a7a9f1a
refs/heads/master
2023-05-11T00:22:46.215568
2023-05-07T09:10:48
2023-05-07T09:10:48
191,439,585
1
1
null
null
null
null
UTF-8
C++
false
false
1,084
cpp
#include <core/bsnet.h> namespace bs { namespace net { u32 parse_ipv4( char const* from ) { u32 result = 0; char const* reader = from; for ( s32 i = 0; i < 4; ++i ) { char const* section = reader; s32 digit = 0; while ( *reader != '.' && *reader != '\0' ) { ++reader; if ( ++digit > 3 ) return 0; } ++reader; u8 multiplier = 1; u8 u8result = 0; for ( ;digit--; multiplier *= 10 ) { u8result += multiplier * (section[digit] - '0'); } result += u32( u8result ) << (i * 8); } return result; } }; template<> INLINE s32 string_format<true, net::Connection>( char* destination, s32 capacity, net::Connection connection ) { return string_format( destination, capacity, connection.ipv4_u8_address0, ".", connection.ipv4_u8_address1, ".", connection.ipv4_u8_address2, ".", connection.ipv4_u8_address3, ":", connection.port ) - 1; } };
[ "camillolukesch@gmail.com" ]
camillolukesch@gmail.com
9d89c3408ee404ba96b7b67aa61ce31686d72e3f
f03c8f619095c5912a90d605d9f48e0c7e6950b0
/ToDoList/TDLFindTaskExpressionListCtrl.h
72c7268826af9582fa5729babd37b1b2c39de7f5
[]
no_license
timeislife/todolist
db41f9345b2207772b7042e9aa39c8fae1a9fd8e
cb8440ddc07d5961571c8f4fe722f5c1b64ef9d7
refs/heads/master
2021-01-10T21:44:07.759434
2015-02-02T16:53:06
2015-02-02T16:53:06
26,937,527
0
0
null
null
null
null
UTF-8
C++
false
false
3,953
h
#if !defined(AFX_FINDTASKEXPRESSIONLISTCTRL_H__42272309_6C54_4901_A56D_D6FDA87F1E48__INCLUDED_) #define AFX_FINDTASKEXPRESSIONLISTCTRL_H__42272309_6C54_4901_A56D_D6FDA87F1E48__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 // FindTaskExpressionListCtrl.h : header file // #include "tdcenum.h" #include "tdcstruct.h" #include "tdlfindtaskattributecombobox.h" #include "..\shared\InputListCtrl.h" #include "..\shared\timeedit.h" #include "..\shared\datetimectrlex.h" #include <afxtempl.h> ///////////////////////////////////////////////////////////////////////////// // CTDLFindTaskExpressionListCtrl window class CTDLFindTaskExpressionListCtrl : public CInputListCtrl { // Construction public: CTDLFindTaskExpressionListCtrl(); void SetSearchParams(const SEARCHPARAM& param); void SetSearchParams(const CSearchParamArray& params); int GetSearchParams(CSearchParamArray& params) const; void ClearSearch(); void SetCustomAttributes(const CTDCCustomAttribDefinitionArray& aAttribDefs); BOOL AddRule(); BOOL DeleteSelectedRule(); BOOL CanDeleteSelectedRule() const { return CanDeleteSelectedCell(); } BOOL HasRules() const { return m_aSearchParams.GetSize(); } void MoveSelectedRuleUp(); BOOL CanMoveSelectedRuleUp() const; void MoveSelectedRuleDown(); BOOL CanMoveSelectedRuleDown() const; // Attributes protected: CComboBox m_cbOperators; CTDLFindTaskAttributeComboBox m_cbAttributes; CComboBox m_cbAndOr; CDateTimeCtrlEx m_dtDate; CTimeEdit m_eTime; CSearchParamArray m_aSearchParams; CTDCCustomAttribDefinitionArray m_aAttribDefs; // Operations public: // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CTDLFindTaskExpressionListCtrl) protected: virtual void PreSubclassWindow(); //}}AFX_VIRTUAL virtual BOOL PreTranslateMessage(MSG* pMsg); // Implementation public: virtual ~CTDLFindTaskExpressionListCtrl(); // Generated message map functions protected: //{{AFX_MSG(CTDLFindTaskExpressionListCtrl) afx_msg void OnKillFocus(CWnd* pNewWnd); afx_msg void OnSize(UINT nType, int cx, int cy); //}}AFX_MSG afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg void OnAttribEditCancel(); afx_msg void OnAttribEditOK(); afx_msg void OnOperatorEditCancel(); afx_msg void OnOperatorEditOK(); afx_msg void OnAndOrEditCancel(); afx_msg void OnAndOrEditOK(); afx_msg void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct); afx_msg void OnValueEditOK(NMHDR* pNMHDR, LRESULT* pResult); afx_msg BOOL OnSelItemChanged(NMHDR* pNMHDR, LRESULT* pResult); afx_msg void OnDateChange(NMHDR* pNMHDR, LRESULT* pResult); afx_msg void OnDateCloseUp(NMHDR* pNMHDR, LRESULT* pResult); afx_msg void OnTimeChange(); afx_msg LRESULT OnTimeUnitsChange(WPARAM wp, LPARAM lp); DECLARE_MESSAGE_MAP() virtual void EditCell(int nItem, int nCol); virtual BOOL IsEditing() const; virtual BOOL DeleteSelectedCell(); virtual BOOL CanEditSelectedCell() const; virtual IL_COLUMNTYPE GetCellType(int nRow, int nCol) const; void PrepareEdit(int nRow, int nCol); void PrepareControl(CWnd& ctrl, int nRow, int nCol); int GetValueType(int nRow) const; void BuildListCtrl(); int InsertRule(int nRow, const SEARCHPARAM& sp); int GetRuleCount() const { return m_aSearchParams.GetSize(); } CWnd* GetEditControl(int nRow, int nCol); void ValidateListData() const; void UpdateValueColumnText(int nRow); void AddOperatorToCombo(FIND_OPERATOR op); void RefreshAndOrColumnText(); static CString GetOpName(FIND_OPERATOR op); }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_FINDTASKEXPRESSIONLISTCTRL_H__42272309_6C54_4901_A56D_D6FDA87F1E48__INCLUDED_)
[ "rferen2008@gmail.com" ]
rferen2008@gmail.com
61c0905d239d5e3beaa38af22c0d3b3806d225bf
fc3c7d3b0c89906ce37589e7b37870ecc357e83e
/lessons/source-30/utils.h
ff3f91c295760cbdf88ab87a0b11c5ac461d9bdf
[]
no_license
gromakovski/clone_repo
283b633716a66b8742955ce09f653bc7f4ff5375
cfdb081411c95a705425645ded61bb186046b96d
refs/heads/master
2020-09-07T16:51:58.960893
2019-11-10T21:24:34
2019-11-10T21:24:34
220,851,558
0
0
null
null
null
null
UTF-8
C++
false
false
223
h
#pragma once #include "sqlite/sqlite3.h" #include <string> namespace utils { void printAll(sqlite3* dbHandle, const std::string& tableName); bool executeQuery(sqlite3* dbHandle, const std::string& query); } // utils
[ "gromakovski" ]
gromakovski
cce6b4fcc8d03ab1add93b4a4f325e626b9112d5
3eef636ad6039f8218473ee783b2d6957ea2bc8d
/Layout Designer3/Layout Designer/MonitorTypePane.cpp
2dd7f9defa0c23b2c1c13a4a1302567855aaebe5
[]
no_license
nicktsai1988/windows
7f5b737c94f0fef941fac7abdbd1a412207d5a93
d99b6b6e09a72fbd0c51e8f2886dd46326c4d40a
refs/heads/master
2020-04-06T05:36:00.302227
2014-06-20T11:19:27
2014-06-20T11:19:36
20,987,594
0
1
null
null
null
null
UTF-8
C++
false
false
1,561
cpp
// MonitorTypePane.cpp : implementation file // #include "stdafx.h" #include "Layout Designer.h" #include "MonitorTypePane.h" // CMonitorTypePane IMPLEMENT_DYNAMIC(CMonitorTypePane, CDockablePane) CMonitorTypePane::CMonitorTypePane() { } CMonitorTypePane::~CMonitorTypePane() { } BEGIN_MESSAGE_MAP(CMonitorTypePane, CDockablePane) ON_WM_CREATE() ON_WM_SIZE() ON_WM_CONTEXTMENU() END_MESSAGE_MAP() // CMonitorTypePane message handlers int CMonitorTypePane::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CDockablePane::OnCreate(lpCreateStruct) == -1) return -1; if( !m_wndMonitorType.Create(NULL, NULL, WS_CHILD | WS_VISIBLE | WS_VSCROLL, CRect(0, 0, 0, 0), this, AFX_IDW_PANE_FIRST+3, NULL)) { TRACE0("Failed to create monitor type window\n"); return -1; } // TODO: Add your specialized creation code here //m_dialogMonitorType.Create(CMonitorTypeDialog::IDD,this); //m_dialogMonitorType.ShowWindow(SW_SHOW); return 0; } void CMonitorTypePane::OnSize(UINT nType, int cx, int cy) { CDockablePane::OnSize(nType, cx, cy); if(m_wndMonitorType.GetSafeHwnd()) { m_wndMonitorType.MoveWindow(0,0,cx,cy); } /* if(m_dialogMonitorType.GetSafeHwnd()) { m_dialogMonitorType.MoveWindow(0,0,cx,cy); } */ // TODO: Add your message handler code here } BOOL CMonitorTypePane::FloatPane(CRect rectFloat, AFX_DOCK_METHOD dockMethod , bool bShow) { return FALSE; } void CMonitorTypePane::OnContextMenu(CWnd* pWnd, CPoint point) { } CMonitorTypeWnd* CMonitorTypePane::GetMonitorTypeWnd() { return &m_wndMonitorType; }
[ "nicktsai@163.com" ]
nicktsai@163.com
14de97f19c3591b28572a380e0dcb5246803f4f2
1352eac84ee81b864c302e64c238635221b4d307
/FMI/Homeworks/Homework 3 - Searching/CandiesAndBalloons.cpp
91f2a099c16bbfd9df2a0beee56034d68d092e5b
[]
no_license
erikz99/Data-Structures-And-Algorithms
5f329136e5f8a0bde59b47f710701410a90dfc48
350e95e38b295131057d6af1a39b3642c231e8b7
refs/heads/main
2023-03-11T15:57:09.845087
2021-02-21T21:15:59
2021-02-21T21:15:59
336,898,809
0
0
null
null
null
null
UTF-8
C++
false
false
1,601
cpp
#include <iostream> #include <vector> #include <algorithm> using namespace std; bool isPossible(vector <long long> vect1, vector <long long> vect2, int n, long long m, long long c) { for (int i = 0; i < n; i++) { if (c / vect2[i] >= vect1[i]) { continue; } else { long long diff = vect1[i] - c / vect2[i]; m -= diff; if (m < 0) { return false; } } } return true; } long long getMinMax(vector <long long> vect1, vector <long long> vect2, int n, long long m) { long long right = vect1[0] * vect2[0]; for (int i = 1; i < n; i++) { if (vect1[i] * vect2[i] > right) { right = vect1[i] * vect2[i]; } } long long left = 0; while (left < right) { long long mid = left + (right - left) / 2; if (isPossible(vect1, vect2, n, m, mid)) { right = mid; } else { left = mid + 1; } } return left; } void solve() { int n; cin >> n; long long m; cin >> m; vector <long long> balloons; for (int i = 0; i < n; i++) { long long b; cin >> b; balloons.push_back(b); } vector <long long> candies; for (int i = 0; i < n; i++) { long long c; cin >> c; candies.push_back(c); } cout << getMinMax(balloons, candies, n, m); } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); solve(); }
[ "erikzdravkov99@gmail.com" ]
erikzdravkov99@gmail.com
58fd345231b4f2929998bd105921b33aa368cfd1
504fa56796d605107ac43c8a43a794b338079d75
/hmailserver/source/Server/Common/BO/ACLPermission.cpp
8e8faaba5b4cf3c460f1145076e979e03b5ad137
[]
no_license
bighossbiz/hmailserver
5877796f95d2c19c34744fdbefb06d819c58410d
39506daf6b95e554bd3153206eaaf0bd22affdf1
refs/heads/master
2021-01-21T04:04:09.604030
2014-08-31T13:15:06
2014-08-31T13:15:06
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,529
cpp
// Copyright (c) 2010 Martin Knafve / hMailServer.com. // http://www.hmailserver.com #include "StdAfx.h" #include "ACLPermission.h" #include "../BO/Groups.h" #include "../BO/Account.h" #include "../Cache/CacheContainer.h" #include "../Application/ACLManager.h" #include "../../IMAP/IMAPConfiguration.h" #ifdef _DEBUG #define DEBUG_NEW new(_NORMAL_BLOCK, __FILE__, __LINE__) #define new DEBUG_NEW #endif namespace HM { ACLPermission::ACLPermission(void) : share_folder_id_(0), permission_type_(PTUser), permission_group_id_(0), permission_account_id_(0), value_(0) { } ACLPermission::~ACLPermission(void) { } void ACLPermission::GrantAll() { value_ = value_ | 2047; } __int64 ACLPermission::GetShareFolderID() { return share_folder_id_; } void ACLPermission::SetShareFolderID(__int64 iNewVal) { share_folder_id_ = iNewVal; } __int64 ACLPermission::GetPermissionGroupID() { return permission_group_id_; } void ACLPermission::SetPermissionGroupID(__int64 iNewVal) { permission_group_id_ = iNewVal; } __int64 ACLPermission::GetPermissionAccountID() { return permission_account_id_; } void ACLPermission::SetPermissionAccountID(__int64 iNewVal) { permission_account_id_ = iNewVal; } ACLPermission::ePermissionType ACLPermission::GetPermissionType() { return permission_type_; } void ACLPermission::SetPermissionType(ePermissionType iNewVal) { permission_type_ = iNewVal; } __int64 ACLPermission::GetValue() { return value_; } void ACLPermission::SetValue(__int64 iNewVal) { value_ = iNewVal; } bool ACLPermission::GetAllow(ACLPermission::ePermission p) const { return (value_ & p) ? true : false; } void ACLPermission::SetAllow(ACLPermission::ePermission p, bool bValue) { if (bValue) value_ = value_ | p; else value_ = value_ & ~p; } String ACLPermission::GetRights() const { String sRetVal; if (GetAllow(PermissionLookup)) sRetVal += "l"; if (GetAllow(PermissionRead)) sRetVal += "r"; if (GetAllow(PermissionWriteSeen)) sRetVal += "s"; if (GetAllow(PermissionWriteOthers)) sRetVal += "w"; if (GetAllow(PermissionInsert)) sRetVal += "i"; if (GetAllow(PermissionPost)) sRetVal += "p"; if (GetAllow(PermissionCreate)) sRetVal += "k"; if (GetAllow(PermissionDeleteMailbox)) sRetVal += "x"; if (GetAllow(PermissionWriteDeleted)) sRetVal += "t"; if (GetAllow(PermissionExpunge)) sRetVal += "e"; if (GetAllow(PermissionAdminister)) sRetVal += "a"; return sRetVal; } ACLPermission::ePermission ACLPermission::GetPermission(wchar_t w) { switch (w) { case 'l': return PermissionLookup; case 'r': return PermissionRead; case 's': return PermissionWriteSeen; case 'w': return PermissionWriteOthers; case 'i': return PermissionInsert; case 'p': return PermissionPost; case 'k': return PermissionCreate; case 'x': return PermissionDeleteMailbox; case 't': return PermissionWriteDeleted; case 'e': return PermissionExpunge; case 'a': return PermissionAdminister; } return PermissionNone; } void ACLPermission::AppendPermissions(const String &sRights) { int iAction = 0; // 1 - append, 2 = subtract, 3 - replace if (sRights.GetAt(0) == '+') iAction = 1; else if (sRights.GetAt(0) == '-') iAction = 2; else iAction = 3; if (iAction == 3) { // Reset any existing right. SetValue(0); // And now append instead iAction = 1; } for (int i = 0; i < sRights.GetLength(); i++) { wchar_t sChar = sRights.GetAt(i); if (sChar == '+' || sChar == '-') continue; ePermission p = GetPermission(sChar); if (iAction == 1) SetAllow(p, true); else SetAllow(p, false); } } bool ACLPermission::XMLStore(XNode *pParentNode, int iOptions) { XNode *pNode = pParentNode->AppendChild(_T("Permission")); pNode->AppendAttr(_T("Type"), StringParser::IntToString(permission_type_)); pNode->AppendAttr(_T("Rights"), StringParser::IntToString(value_)); pNode->AppendAttr(_T("Holder"), GetPermissionHolderName_(this)); return true; } bool ACLPermission::XMLLoad(XNode *pNode, int iOptions) { permission_type_ = (ePermissionType) _ttoi(pNode->GetAttrValue(_T("Type"))); value_ = _ttoi(pNode->GetAttrValue(_T("Rights"))); String sPermissionHolder = pNode->GetAttrValue(_T("Holder")); switch (permission_type_) { case ACLPermission::PTGroup: { shared_ptr<Group> pGroup = Configuration::Instance()->GetIMAPConfiguration()->GetGroups()->GetItemByName(sPermissionHolder); if (pGroup) { SetPermissionGroupID(pGroup->GetID()); } break; } case ACLPermission::PTUser: { shared_ptr<const Account> pAccount = CacheContainer::Instance()->GetAccount(sPermissionHolder); if (pAccount) { SetPermissionAccountID(pAccount->GetID()); } break; } } return true; } String ACLPermission::GetPermissionHolderName_(ACLPermission *pPermission) const { switch (pPermission->GetPermissionType()) { case ACLPermission::PTGroup: { shared_ptr<Group> pGroup = Configuration::Instance()->GetIMAPConfiguration()->GetGroups()->GetItemByDBID(pPermission->GetPermissionGroupID()); return pGroup->GetName(); } case ACLPermission::PTUser: { shared_ptr<const Account> pAccount = CacheContainer::Instance()->GetAccount(pPermission->GetPermissionAccountID()); return pAccount->GetAddress(); } case ACLPermission::PTAnyone: { return "Anyone"; } } return "Unknown"; } }
[ "knafve@gmail.com" ]
knafve@gmail.com
f10c52bb108f9ab6b37e01a6ccd63b0ae21e4ba9
4cc7c74b4bb7b818562bedffd026a86f9ec78f41
/content/browser/web_package/signed_exchange_loader.cc
017000894c81124d432ac8b762bfedf3ed4da4fa
[ "BSD-3-Clause" ]
permissive
jennyb2911/chromium
1e03c9e5a63af1cf82832e0e99e0028e255872bd
62b48b4fdb3984762f4d2fd3690f02f167920f52
refs/heads/master
2023-01-10T01:08:34.961976
2018-09-28T03:36:36
2018-09-28T03:36:36
150,682,761
1
0
NOASSERTION
2018-09-28T03:49:28
2018-09-28T03:49:27
null
UTF-8
C++
false
false
14,885
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 "content/browser/web_package/signed_exchange_loader.h" #include <memory> #include "base/callback.h" #include "base/feature_list.h" #include "base/metrics/histogram_macros.h" #include "base/strings/stringprintf.h" #include "content/browser/loader/data_pipe_to_source_stream.h" #include "content/browser/loader/source_stream_to_data_pipe.h" #include "content/browser/web_package/signed_exchange_cert_fetcher_factory.h" #include "content/browser/web_package/signed_exchange_devtools_proxy.h" #include "content/browser/web_package/signed_exchange_handler.h" #include "content/browser/web_package/signed_exchange_utils.h" #include "content/public/common/content_features.h" #include "content/public/common/origin_util.h" #include "net/base/net_errors.h" #include "net/cert/cert_status_flags.h" #include "net/http/http_util.h" #include "services/network/public/cpp/features.h" #include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/cpp/url_loader_completion_status.h" #include "services/network/public/mojom/url_loader_factory.mojom.h" namespace content { namespace { constexpr char kLoadResultHistogram[] = "SignedExchange.LoadResult"; net::RedirectInfo CreateRedirectInfo(const GURL& new_url, const GURL& outer_request_url) { net::RedirectInfo redirect_info; if (outer_request_url.has_ref()) { // Propagate ref fragment from the outer request URL. url::Replacements<char> replacements; base::StringPiece ref = outer_request_url.ref_piece(); replacements.SetRef(ref.data(), url::Component(0, ref.length())); redirect_info.new_url = new_url.ReplaceComponents(replacements); } else { redirect_info.new_url = new_url; } redirect_info.new_method = "GET"; // https://wicg.github.io/webpackage/loading.html#mp-http-fetch // Step 3. Set actualResponse's status to 303. [spec text] redirect_info.status_code = 303; redirect_info.new_site_for_cookies = redirect_info.new_url; return redirect_info; } constexpr static int kDefaultBufferSize = 64 * 1024; SignedExchangeHandlerFactory* g_signed_exchange_factory_for_testing_ = nullptr; } // namespace class SignedExchangeLoader::ResponseTimingInfo { public: explicit ResponseTimingInfo(const network::ResourceResponseHead& response) : request_start_(response.request_start), response_start_(response.response_start), request_time_(response.request_time), response_time_(response.response_time), load_timing_(response.load_timing) {} network::ResourceResponseHead CreateRedirectResponseHead() const { network::ResourceResponseHead response_head; response_head.encoded_data_length = 0; std::string buf(base::StringPrintf("HTTP/1.1 %d %s\r\n", 303, "See Other")); response_head.headers = new net::HttpResponseHeaders( net::HttpUtil::AssembleRawHeaders(buf.c_str(), buf.size())); response_head.encoded_data_length = 0; response_head.request_start = request_start_; response_head.response_start = response_start_; response_head.request_time = request_time_; response_head.response_time = response_time_; response_head.load_timing = load_timing_; return response_head; } private: const base::TimeTicks request_start_; const base::TimeTicks response_start_; const base::Time request_time_; const base::Time response_time_; const net::LoadTimingInfo load_timing_; DISALLOW_COPY_AND_ASSIGN(ResponseTimingInfo); }; SignedExchangeLoader::SignedExchangeLoader( const GURL& outer_request_url, const network::ResourceResponseHead& outer_response, network::mojom::URLLoaderClientPtr forwarding_client, network::mojom::URLLoaderClientEndpointsPtr endpoints, url::Origin request_initiator, uint32_t url_loader_options, int load_flags, bool should_redirect_on_failure, const base::Optional<base::UnguessableToken>& throttling_profile_id, std::unique_ptr<SignedExchangeDevToolsProxy> devtools_proxy, scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, URLLoaderThrottlesGetter url_loader_throttles_getter, base::RepeatingCallback<int(void)> frame_tree_node_id_getter) : outer_request_url_(outer_request_url), outer_response_timing_info_( std::make_unique<ResponseTimingInfo>(outer_response)), outer_response_(outer_response), forwarding_client_(std::move(forwarding_client)), url_loader_client_binding_(this), request_initiator_(request_initiator), url_loader_options_(url_loader_options), load_flags_(load_flags), should_redirect_on_failure_(should_redirect_on_failure), throttling_profile_id_(throttling_profile_id), devtools_proxy_(std::move(devtools_proxy)), url_loader_factory_(std::move(url_loader_factory)), url_loader_throttles_getter_(std::move(url_loader_throttles_getter)), frame_tree_node_id_getter_(frame_tree_node_id_getter), weak_factory_(this) { DCHECK(signed_exchange_utils::IsSignedExchangeHandlingEnabled()); DCHECK(outer_request_url_.is_valid()); // https://wicg.github.io/webpackage/draft-yasskin-http-origin-signed-responses.html#privacy-considerations // This can be difficult to determine when the exchange is being loaded from // local disk, but when the client itself requested the exchange over a // network it SHOULD require TLS ([I-D.ietf-tls-tls13]) or a successor // transport layer, and MUST NOT accept exchanges transferred over plain HTTP // without TLS. [spec text] if (!IsOriginSecure(outer_request_url)) { UMA_HISTOGRAM_ENUMERATION(kLoadResultHistogram, SignedExchangeLoadResult::kSXGServedFromNonHTTPS); devtools_proxy_->ReportError( "Signed exchange response from non secure origin is not supported.", base::nullopt /* error_field */); // Calls OnSignedExchangeReceived() to show the outer response in DevTool's // Network panel and the error message in the Preview panel. devtools_proxy_->OnSignedExchangeReceived(base::nullopt /* header */, nullptr /* certificate */, nullptr /* ssl_info */); // This will asynchronously delete |this|. forwarding_client_->OnComplete( network::URLLoaderCompletionStatus(net::ERR_INVALID_SIGNED_EXCHANGE)); return; } // Can't use HttpResponseHeaders::GetMimeType() because SignedExchangeHandler // checks "v=" parameter. outer_response.headers->EnumerateHeader(nullptr, "content-type", &content_type_); url_loader_.Bind(std::move(endpoints->url_loader)); if (url_loader_options_ & network::mojom::kURLLoadOptionPauseOnResponseStarted) { // We don't propagate the response to the navigation request and its // throttles, therefore we need to call this here internally in order to // move it forward. // TODO(https://crbug.com/791049): Remove this when NetworkService is // enabled by default. url_loader_->ProceedWithResponse(); } // Bind the endpoint with |this| to get the body DataPipe. url_loader_client_binding_.Bind(std::move(endpoints->url_loader_client)); // |client_| will be bound with a forwarding client by ConnectToClient(). pending_client_request_ = mojo::MakeRequest(&client_); } SignedExchangeLoader::~SignedExchangeLoader() = default; void SignedExchangeLoader::OnReceiveResponse( const network::ResourceResponseHead& response_head) { // Must not be called because this SignedExchangeLoader and the client // endpoints were bound after OnReceiveResponse() is called. NOTREACHED(); } void SignedExchangeLoader::OnReceiveRedirect( const net::RedirectInfo& redirect_info, const network::ResourceResponseHead& response_head) { // Must not be called because this SignedExchangeLoader and the client // endpoints were bound after OnReceiveResponse() is called. NOTREACHED(); } void SignedExchangeLoader::OnUploadProgress( int64_t current_position, int64_t total_size, OnUploadProgressCallback ack_callback) { // Must not be called because this SignedExchangeLoader and the client // endpoints were bound after OnReceiveResponse() is called. NOTREACHED(); } void SignedExchangeLoader::OnReceiveCachedMetadata( const std::vector<uint8_t>& data) { // Curerntly CachedMetadata for Signed Exchange is not supported. NOTREACHED(); } void SignedExchangeLoader::OnTransferSizeUpdated(int32_t transfer_size_diff) { // TODO(https://crbug.com/803774): Implement this to progressively update the // encoded data length in DevTools. } void SignedExchangeLoader::OnStartLoadingResponseBody( mojo::ScopedDataPipeConsumerHandle body) { auto cert_fetcher_factory = SignedExchangeCertFetcherFactory::Create( std::move(request_initiator_), std::move(url_loader_factory_), std::move(url_loader_throttles_getter_), throttling_profile_id_); if (g_signed_exchange_factory_for_testing_) { signed_exchange_handler_ = g_signed_exchange_factory_for_testing_->Create( std::make_unique<DataPipeToSourceStream>(std::move(body)), base::BindOnce(&SignedExchangeLoader::OnHTTPExchangeFound, weak_factory_.GetWeakPtr()), std::move(cert_fetcher_factory)); return; } signed_exchange_handler_ = std::make_unique<SignedExchangeHandler>( content_type_, std::make_unique<DataPipeToSourceStream>(std::move(body)), base::BindOnce(&SignedExchangeLoader::OnHTTPExchangeFound, weak_factory_.GetWeakPtr()), std::move(cert_fetcher_factory), load_flags_, std::move(devtools_proxy_), frame_tree_node_id_getter_); } void SignedExchangeLoader::OnComplete( const network::URLLoaderCompletionStatus& status) {} void SignedExchangeLoader::FollowRedirect( const base::Optional<std::vector<std::string>>& to_be_removed_request_headers, const base::Optional<net::HttpRequestHeaders>& modified_request_headers) { NOTREACHED(); } void SignedExchangeLoader::ProceedWithResponse() { DCHECK(body_data_pipe_adapter_); DCHECK(pending_body_consumer_.is_valid()); body_data_pipe_adapter_->Start(); client_->OnStartLoadingResponseBody(std::move(pending_body_consumer_)); } void SignedExchangeLoader::SetPriority(net::RequestPriority priority, int intra_priority_value) { // TODO(https://crbug.com/803774): Implement this. } void SignedExchangeLoader::PauseReadingBodyFromNet() { // TODO(https://crbug.com/803774): Implement this. } void SignedExchangeLoader::ResumeReadingBodyFromNet() { // TODO(https://crbug.com/803774): Implement this. } void SignedExchangeLoader::ConnectToClient( network::mojom::URLLoaderClientPtr client) { DCHECK(pending_client_request_.is_pending()); mojo::FuseInterface(std::move(pending_client_request_), client.PassInterface()); } void SignedExchangeLoader::OnHTTPExchangeFound( SignedExchangeLoadResult result, net::Error error, const GURL& request_url, const std::string& request_method, const network::ResourceResponseHead& resource_response, std::unique_ptr<net::SourceStream> payload_stream) { UMA_HISTOGRAM_ENUMERATION(kLoadResultHistogram, result); if (error) { if (error != net::ERR_INVALID_SIGNED_EXCHANGE || !should_redirect_on_failure_ || !request_url.is_valid()) { // Let the request fail. // This will eventually delete |this|. forwarding_client_->OnComplete(network::URLLoaderCompletionStatus(error)); return; } // Make a fallback redirect to |request_url|. DCHECK(!has_redirected_to_fallback_url_); has_redirected_to_fallback_url_ = true; DCHECK(outer_response_timing_info_); forwarding_client_->OnReceiveRedirect( CreateRedirectInfo(request_url, outer_request_url_), std::move(outer_response_timing_info_)->CreateRedirectResponseHead()); forwarding_client_.reset(); return; } // TODO(https://crbug.com/803774): Handle no-GET request_method as a error. DCHECK(outer_response_timing_info_); forwarding_client_->OnReceiveRedirect( CreateRedirectInfo(request_url, outer_request_url_), std::move(outer_response_timing_info_)->CreateRedirectResponseHead()); forwarding_client_.reset(); const base::Optional<net::SSLInfo>& ssl_info = resource_response.ssl_info; if (ssl_info.has_value() && (url_loader_options_ & network::mojom::kURLLoadOptionSendSSLInfoForCertificateError) && net::IsCertStatusError(ssl_info->cert_status) && !net::IsCertStatusMinorError(ssl_info->cert_status)) { ssl_info_ = ssl_info; } network::ResourceResponseHead inner_response_head_shown_to_client = resource_response; if (ssl_info.has_value() && !(url_loader_options_ & network::mojom::kURLLoadOptionSendSSLInfoWithResponse)) { inner_response_head_shown_to_client.ssl_info = base::nullopt; } client_->OnReceiveResponse(inner_response_head_shown_to_client); // Currently we always assume that we have body. // TODO(https://crbug.com/80374): Add error handling and bail out // earlier if there's an error. mojo::DataPipe data_pipe(kDefaultBufferSize); pending_body_consumer_ = std::move(data_pipe.consumer_handle); body_data_pipe_adapter_ = std::make_unique<SourceStreamToDataPipe>( std::move(payload_stream), std::move(data_pipe.producer_handle), base::BindOnce(&SignedExchangeLoader::FinishReadingBody, base::Unretained(this))); if (url_loader_options_ & network::mojom::kURLLoadOptionPauseOnResponseStarted) { // Need to wait until ProceedWithResponse() is called. return; } // Start reading. body_data_pipe_adapter_->Start(); client_->OnStartLoadingResponseBody(std::move(pending_body_consumer_)); } void SignedExchangeLoader::FinishReadingBody(int result) { // TODO(https://crbug.com/803774): Fill the data length information too. network::URLLoaderCompletionStatus status; status.error_code = result; if (ssl_info_) { DCHECK((url_loader_options_ & network::mojom::kURLLoadOptionSendSSLInfoForCertificateError) && net::IsCertStatusError(ssl_info_->cert_status) && !net::IsCertStatusMinorError(ssl_info_->cert_status)); status.ssl_info = *ssl_info_; } // This will eventually delete |this|. client_->OnComplete(status); } void SignedExchangeLoader::SetSignedExchangeHandlerFactoryForTest( SignedExchangeHandlerFactory* factory) { g_signed_exchange_factory_for_testing_ = factory; } } // namespace content
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
43a85fec5be295887d90e08a7e978314171939bd
18df433435a8fb883c0ca71e6d27f452c4ac9246
/include/freeBlockManager.h
86338390d8680d00e56daf4191699d5b3cfc79d8
[ "MIT" ]
permissive
ParthDesai/snfs
f621aa990dea8352be59629e70700124d7b64c2a
ab5f37ed1dd5fdc436f32d36725262f0a78380c3
refs/heads/master
2016-09-03T06:35:43.852824
2014-07-22T12:10:09
2014-07-22T12:10:09
22,101,951
1
0
null
null
null
null
UTF-8
C++
false
false
583
h
#ifndef FREEBLOCKMANAGER_H #define FREEBLOCKMANAGER_H #include "common.h" #include "freeBlock.h" #define FREE_BLOCK_ALIGNMENT BLOCK_SIZE class freeBlockManager { public: freeBlockManager(); virtual ~freeBlockManager(); freeBlock * getNextFreeBlock(); bool addToFreeBlock(uint32_t address,uint32_t nextAddress,bool isLast); protected: private: freeBlock * m_freeBlockListHead; freeBlock * m_freeBlockListTail; diskManager * m_diskMgr; pthread_mutex_t * m_accessMutex; }; #endif // FREEBLOCKMANAGER_H
[ "desaiparth08@gmail.com" ]
desaiparth08@gmail.com
ac5696f40fd5bf84b85683cfff22074230086788
1fc8f3ad84f27df094a6a8e340c5a1f7f8744272
/Leet-Code-Question/power-of-two/power-of-two.cpp
e988f22502735e663cecccf55244719fdb5ee40d
[]
no_license
vaibhavarora14/Ace-The-Code
528501d7a76b9e36791de54d99c9cecebafb7fa8
9c325845c66daab9d286a2709b91d1e2f8e82c74
refs/heads/master
2023-06-26T10:12:13.772611
2021-07-24T12:01:07
2021-07-24T12:01:07
389,092,773
1
0
null
null
null
null
UTF-8
C++
false
false
180
cpp
class Solution { public: bool isPowerOfTwo(int n) { while(n>1){ if(n%2==1) return false; n=n/2; } return n==1; } };
[ "sachinsinghroxx@gmail.com" ]
sachinsinghroxx@gmail.com
3b5aee6b4a05aa41fdf2c33a586e198b1444edb5
9ca8d4a890e9386ecc49fec923049f9bd1870ebc
/atcoderregular150/E.cpp
2f982466538213526d8d0ab2834ba788874ae23b
[]
no_license
Feng1983/atcoder
5582a4d65d78dbbfdcc88dd6d80abd79c1098505
b9a23c832df6973a5da632fca89785059dbde846
refs/heads/master
2023-03-16T07:05:40.030478
2023-03-06T14:45:55
2023-03-06T14:45:55
234,253,656
0
0
null
null
null
null
UTF-8
C++
false
false
1,666
cpp
#include <atcoder/modint> #include <bits/stdc++.h> using namespace std; using mint = atcoder::modint998244353; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, k; cin >> n >> k; string s; cin >> s; int bal = 0; for (char c : s) { if (c == 'L') { bal += 1; } else { bal -= 1; } } if (bal < 0) { reverse(s.begin(), s.end()); for (char &c : s) { c ^= ('L' ^ 'R'); } bal = -bal; } vector<int> till(n); mint ans = 0; int cur = 0; for (int i = 0; i < n; i++) { int nxt = cur + (s[i] == 'R' ? -1 : 1); int bound = (s[i] == 'L' ? 0 : bal); int me = max(nxt, cur); if (me <= bound) { //me+till[i]*bal<=bound int low = 0, high = k - 1; while (low < high) { int mid = (low + high + 1) >> 1; if (me + (long long)mid * bal <= bound) { low = mid; } else { high = mid - 1; } } till[i] = low; } else { till[i] = -1; } ans += till[i] + 1; cur = nxt; } if (bal > 0) { string last = ""; for (int i = 0; i < n; i++) { if (till[i] == k - 1) { last += s[i] ^ 'L' ^ 'R'; } else { last += s[i]; } } int cnt = 0; cur = 0; for (int i = n - 1; i >= 0; i--) { cur += (last[i] == 'R' ? 1 : -1); if (cur < 0) { break; } if (cur == 0) { cnt = n - i; } } ans -= cnt / 2; for (int i = 0; i < n; i++) { if (s[i] == 'L') { ans += till[i] + 1; } else { ans += k - 1 - till[i]; } } } cout << ans.val() << endl; return 0; }
[ "Feng1983@github.com" ]
Feng1983@github.com
70c60494cf499f33e60965e094a69996f767c554
9dd98f55c66f7ccb28a6a6483c295aaaa2bde68e
/src/pathtracer.cpp
43574633e755e454a497361a9131919c51c75618
[]
no_license
m-iDev-0792/HJRT
9277f211ef8375c64802aa16b2bf67db592e8edd
037d5c98639335b29669ea43960b124ae5544215
refs/heads/master
2020-05-24T15:09:40.895490
2019-09-22T09:13:29
2019-09-22T09:13:29
187,323,823
3
0
null
null
null
null
UTF-8
C++
false
false
4,406
cpp
// // Created by 何振邦 on 2019-06-07. // #include "pathtracer.h" PathTracer::PathTracer() { maxBounce = 25; RRCutBounce = 5; state = Integrator::IDLE; samplingTex.setSamples(20); antiAliasNum = 2; renderThreadNum = 0; renderPortionBlock = 8; latestRenderSec = 99999999; } void PathTracer::renderBlock(float &blockProgress, Camera &camera, Scene &scene, glm::ivec2 start, glm::ivec2 end) { float subR = 1.0 / antiAliasNum; float subS = (-antiAliasNum / 2 + 0.5) * subR; for (int i = start.y; i < end.y; ++i) {//row for (int j = start.x; j < end.x; ++j) {//column glm::vec3 color(0); int actualSamples; for (int u = 0; u < antiAliasNum; ++u) { for (int v = 0; v < antiAliasNum; ++v) { actualSamples = samplingTex.getColor(glm::vec2(j + subS + subR * u, i + subS + subR * v)); for (int s = 0; s < actualSamples; ++s) { color = color + deNanInf(shade(scene, camera.castRay(j + subS + subR * u, i + subS + subR * v, scene.shutterPeriod))); // color = color + deNanInf(shade(scene, camera.castRay(j + subS + subR * u, i + subS + subR * v), 1)); } } } color = color * (1.0f / (antiAliasNum * antiAliasNum * actualSamples)); camera.film.setPixel(i, j, color); } blockProgress = static_cast<float>(i + 1 - start.y) / (end.y - start.y); } } glm::vec3 PathTracer::shade(const Scene &_scene, const Ray &_ray) { int depth = 0; glm::vec3 color(0); glm::vec3 throughput(1.0f); Ray ray = _ray; for (;;) { if (depth > maxBounce) { color += throughput * _scene.backgroundColor; break; } HitInfo hitInfo; if (_scene.intersect(ray, &hitInfo)) { glm::vec2 uv; bool hasUV = hitInfo.hitobject->getUV(hitInfo, &uv); hitInfo.uv = uv; //compute self emission glm::vec3 emission = hitInfo.hitobject->material->emitted(ray, hitInfo.uv); //compute indirect illumination float RRWeight = 1.0f;//Russian roulette weight if (depth > RRCutBounce) { const glm::vec3 &f = hitInfo.hitobject->material->albedo(hitInfo.uv); //Set Russian roulette probability as max color contribution float RRProbability = f.x > f.y && f.x > f.z ? f.x : f.y > f.z ? f.y : f.z; if (random0_1f() > RRProbability) { color += throughput * emission; break; } else { RRWeight /= RRProbability; } } //generate a new ray glm::vec3 attenuation; Ray newRay; if (hitInfo.hitobject->material->scatterPro(ray, hitInfo, &attenuation, &newRay)) { //we have a valid scatter ray color += throughput * emission; throughput *= attenuation * RRWeight; ray = newRay; ++depth; continue; } else { //no scatter happens on the surface color += throughput * emission; break; } } else { //ray dosen't hit anything color += throughput * _scene.backgroundColor; break; } } return color; } glm::vec3 PathTracer::shade(const Scene &scene, const Ray &ray, int depth) { if (depth > maxBounce)return scene.backgroundColor; HitInfo hitInfo; if (scene.intersect(ray, &hitInfo)) { glm::vec2 uv; bool hasUV = hitInfo.hitobject->getUV(hitInfo, &uv); hitInfo.uv = uv; glm::vec3 emission = hitInfo.hitobject->material->emitted(ray, hitInfo.uv); float RRWeight = 1.0f;//Russian roulette weight if (depth > RRCutBounce) { const glm::vec3 &f = hitInfo.hitobject->material->albedo(hitInfo.uv); //Set Russian roulette probability as max color contribution float RRProbability = f.x > f.y && f.x > f.z ? f.x : f.y > f.z ? f.y : f.z; if (random0_1f() > RRProbability)return emission; else RRWeight /= RRProbability; } Ray newRay; glm::vec3 attenuation; if (hitInfo.hitobject->material->scatter(ray, hitInfo, &attenuation, &newRay)) { return emission + attenuation * RRWeight * shade(scene, newRay, depth + 1); } else return emission; } else { return scene.backgroundColor; } } std::string PathTracer::getInfo(std::string para) const { if (para == "samples") { if (samplingTex.getUniformSamples() >= 1)return std::to_string(samplingTex.getUniformSamples()); else return std::string("adaptive"); } else if (para == "antialias")return std::to_string(antiAliasNum); else if (para == "thread")return std::to_string(runningThreadNum); else if (para == "integrator")return std::string("PathTracer"); return std::string("none"); }
[ "1015732477@qq.com" ]
1015732477@qq.com
ca3d59c962688f35ce67921a851331733e983d6a
c135c960924aa8039c0f5e5950966cd9574b611e
/C++11/cpp11.cpp
36bee09aeb558d0f5d3d37bb65bc1c7c5cf7af34
[]
no_license
leo3579/CPP11Feature
8e0c1623b4f93d6cbf1d68fcc452487cdf336950
4c742ea8832237e35d2516327cfab3ecf4432361
refs/heads/master
2020-08-13T11:07:34.622218
2019-10-14T06:27:07
2019-10-14T06:27:07
214,959,232
0
0
null
2019-10-14T06:27:08
2019-10-14T05:55:37
C++
UTF-8
C++
false
false
8,301
cpp
#include <iostream> #include <set> #include <functional> #include <algorithm> #include <initializer_list> #include <string> #include <cstring> #include <vector> using namespace std; using namespace std::placeholders; enum class apple{ green, red }; // In C++11 to declare enum we need either class name or stuct to have a storngly typed enum and // it is scoped. //constexpr is an expression which will be evaluated at complie time itself constexpr int cube(int x) { return (x * x * x); } // when you assign __cm to any long double variable this user // defined literals get invoked and x value multiplied with 10. exe : long double height = 10__cm; // height = 100; ==> return 10 * 10; constexpr long double operator""__cm(long double x) { return (x * 100); } class cpp11 // *final* keyword is used this class can not be inherited to any derived class in the same way for class functions too. { private: size_t len = 0; // in c++11 we can initialize class member variables in declaration itself // const long double *var = 10__cm; // static_assert(var < 100, "Error in long double defined literals"); char *str = nullptr; // Template alias template<class value, class Alloc = allocator<value>> using greaterMultiSet = multiset<value, greater<value>, Alloc>; // the alias greaterMultiSet will intsert data in decending order by default. greaterMultiSet<int> x {4, 1, 3, 5, 8, 7, 9}; protected: //constexpr is an expression which will be evaluated at complie time itself const int cu = cube(10); // auto will be deduced to int type. // static_assert(cu < 1000, "Error in cube defined literals"); static int sf; // Here auto will be deduced to a data type based on aurgument type which we pass while calling the function. public: cpp11() = default; // forcing complier to generate default constructor though user defined ctor available. explicit cpp11(const initializer_list<string> &vec); // if we use explicit keyword we have to call the constructor explicitly // (cpp11 c11 = 30) object creation will give error since its a implicit call (conversion call) cpp11(const cpp11&) = delete; // if we delete default copy constructor function it can not be called. so in this class // copy is not possible cpp11& operator=(const cpp11 &obj) = delete; // if we delete default copy assignment operator function it can not be called. // so in this class assignment is not possible. cpp11(cpp11&&); // Move constructor here const not required as we make assignment then we change the rvalue to nullptr cpp11& operator=(cpp11&& obj); // Move assignment operator here const not required as we make assignment then we change // the rvalue to nullptr. ~cpp11(); // destructor // bind funtion is useful to pass a function parameter after a while based on other function (thread) result int multiple(int a, int b); // find data type template <typename T> void findArgumentType(T arg); // variadic template template <typename T1, typename ... Arg> void tempfun(T1 a, Arg ... arg); void tempfun(); // this empty function is mandatary to terminate the recursive call after the last argument. // use of decltype keyword to deduce to get exact type template <typename T1, typename T2> T2 funname1(T1 a, T2 b); template <typename T1, typename T2> auto funname2(T1 a, T2 b) -> decltype(a+b); // virtual function, override denotes that this function is redefined in the derived classes. virtual void fun(); // override; // usage of attributes => it will improve the code execution efficiency by reducing add instruction in ASCII level. __attribute__((always_inline)) auto add(auto i , auto j); // lambda function auto update(std::vector<int> & vec); // bit operation inline int bitoperation(auto number, int pos); }; int cpp11::sf = 0; /* constructor with initializer list */ cpp11::cpp11(const initializer_list<string> &vec) { auto c = 0; for(auto i : vec) { len = i.size(); str = new char[len+1]; for(auto cr : i) { str[c] = cr; c++; } } str[len+1] = '\0'; cout<<"initializer list Len : "<<len<<" Name : "<<str<<endl; } /* Move copy constructor */ cpp11::cpp11(cpp11&& obj) { len = obj.len; str = obj.str; obj.str = nullptr; obj.len = 0; cout<<"Move constructor Len : "<<len<<" Name : "<<str<<endl; } /* Move assignment operator */ cpp11& cpp11::operator=(cpp11 &&obj) { if(this != &obj) { delete[] str; str = obj.str; len = obj.len; } obj.str = nullptr; obj.len = 0; cout<<"Move Assignment operator Len : "<<len<<" Name : "<<str<<endl; return *this; } /* Destructor */ cpp11::~cpp11() { if(str != nullptr) { delete[] str; str = nullptr; } cout<<"~cpp11"<<endl; } // bind() example function int cpp11::multiple(int a, int b) { return a * b; } // Find argument type template <typename T> void cpp11::findArgumentType(T arg) { cout<<"Argument type : "<<typeid(arg).name()<<"value : "<<arg<<endl; } // variadic template template <typename T1, typename ... Arg> void cpp11::tempfun(T1 a, Arg ... arg) { cout<<" A : "<<a<<endl; tempfun(arg...); } void cpp11::tempfun() { // this empty function is mandatary to terminate the recursive call after the last argument. for(auto i : x) { cout<<"Template Alias : "<<i<<endl; } } // without decltype keyword will always return T2 type. template <typename T1, typename T2> T2 cpp11::funname1(T1 a, T2 b) { return( a + b); } // use of decltype keyword to deduce to get exact type template <typename T1, typename T2> auto cpp11::funname2(T1 a, T2 b) -> decltype(a+b) { return( a + b); } // Virtual function. void cpp11::fun() { cout<<"Base virtual function"<<endl; } // usage of attributes auto cpp11::add(auto a, auto b) { return a + b; } // Lambda function to count odd numbers auto cpp11::update(std::vector<int> & vec) { // Traverse the vector and increment mCounter if element is odd // this is captured by value inside lambda std::for_each(vec.begin(), vec.end(), [this](int element) { if(element % 2) { ++sf; // Accessing member variable from outer scope } }); return sf; } inline int cpp11::bitoperation(auto number, int pos) { // set a bit using OR number |= (1 << pos); cout<<" Setbit OR : "<<number<<endl; // clear a bit using AND number = 7; number &= ~(1 << pos); cout<<"Clear bit : "<<number<<endl; // Check a bit using AND number = 7; number &= (1 << pos); cout<<"Clear bit : "<<number<<endl; // toggle a bit using XOR number = 7; number ^= (1 << pos); cout<<"Toggle bit : "<<number<<endl; return number; } int main() { cpp11 Kbj; // this will invoke default constructor. cpp11 obj{"Leo Alexander"}; // this will invoke parameterized constructor. cpp11 Kcbj(move(obj)); // this will invoke move constructor. cpp11 abj{"Raghul Fernant"}; // this will invoke parameterized constructor. Kbj = move(abj); // this will invoke move assignment operator. // c++11 bind example // auto fun = std::bind(&Kbj.multiple, 10, _2); // cout<<"bind example : "<<fun(10)<<endl; // Find argument type Kbj.findArgumentType(20.90); Kbj.tempfun(9, 9.9, "King to God"); // without decltype keyword cout<<"decltype funname1 : "<<Kbj.funname1(10.9, 10)<<endl; // with decltype keyword cout<<"decltype funname2 : "<<Kbj.funname2(10.9, 10)<<endl; // virtual function Kbj.fun(); // use of attributes cout<<"attributes add : "<<Kbj.add(10.9, 10)<<endl; // lambda function to count odd number std::vector<int> vec = {11,1,8,9,5,2,3,7}; cout<<"Lambda odd num counting : "<<Kbj.update(vec)<<endl; // bit operation cout<<"attributes add : "<<Kbj.bitoperation(9, 3)<<endl; return 0; }
[ "leo_alexander333@yahoo.com" ]
leo_alexander333@yahoo.com
48c11d54821d1297d39112e436f473e2e47ec99a
88f47e2314add1dc28264befd977f24492455580
/Altseed.h
bfd39047640f71ff21162b746fa61a0674edeca9
[ "BSL-1.0", "MIT", "LicenseRef-scancode-unknown-license-reference" ]
permissive
akitsu-sanae/asd-c-wrapper
7150532cd93c7118538c13250b07a41223c74ae6
2823e6e5ed6f10e6095fcf2779fa91e59489137b
refs/heads/master
2021-01-11T10:25:17.698524
2016-12-12T14:27:52
2016-12-12T14:27:52
76,259,654
0
0
null
null
null
null
UTF-8
C++
false
false
267,939
h
#pragma once //---------------------------------------------------------------------------------- // Include //---------------------------------------------------------------------------------- #include <stdio.h> #include <math.h> #include <float.h> #include <stdint.h> #include <string.h> #include <limits.h> #include <vector> #include <string> #include <set> #include <map> #include <list> #include <algorithm> #include <functional> #include <memory> #include <assert.h> #ifdef _WIN32 #include <windows.h> #else #include <unistd.h> #endif //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- /** 文字コード MSVC sizeof(wchar_t)==2 gcc(cygwin) sizeof(wchar_t)==2 gcc(linux) sizeof(wchar_t)==4 */ namespace asd { #ifdef _WIN32 #ifdef _CHAR16T typedef wchar_t achar; typedef std::wstring astring; #else typedef char16_t achar; typedef std::basic_string<char16_t> astring; #endif #else typedef char16_t achar; typedef std::basic_string<char16_t> astring; #endif }; //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # define ASD_STDCALL __stdcall # else # define ASD_STDCALL # endif # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) # define ASD_DLLEXPORT __declspec(dllexport) # else # define ASD_DLLEXPORT # endif //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- namespace asd { //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- struct Vector2DF; struct Vector2DI; struct Vector3DF; struct Vector4DF; struct Matrix43; struct Matrix44; struct RectF; struct RectI; //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- /** @brief 最大値取得 */ template <typename T,typename U> T Max( T t, U u ) { if( t > (T)u ) { return t; } return u; } /** @brief 最小値取得 */ template <typename T,typename U> T Min( T t, U u ) { if( t < (T)u ) { return t; } return u; } /** @brief 範囲内値取得 */ template <typename T,typename U,typename V> T Clamp( T t, U max_, V min_ ) { if( t > (T)max_ ) { t = (T)max_; } if( t < (T)min_ ) { t = (T)min_; } return t; } //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- inline float NormalizeAngle(float angle) { int32_t ofs = (*(int32_t*)&angle & 0x80000000) | 0x3F000000; return (angle - ((int)(angle * 0.159154943f + *(float*)&ofs) * 6.283185307f)); } //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- inline void SinCos(float x, float& s, float& c) { x = NormalizeAngle(x); float x2 = x * x; float x4 = x * x * x * x; float x6 = x * x * x * x * x * x; float x8 = x * x * x * x * x * x * x * x; float x10 = x * x * x * x * x * x * x * x * x * x; s = x * (1.0f - x2 / 6.0f + x4 / 120.0f - x6 / 5040.0f + x8 / 362880.0f - x10 / 39916800.0f); c = 1.0f - x2 / 2.0f + x4 / 24.0f - x6 / 720.0f + x8 / 40320.0f - x10 / 3628800.0f; } //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- /** @brief 文字コードを変換する。(UTF16 -> UTF8) @param dst [out] 出力vector @param src [in] 入力配列の先頭ポインタ @return 文字数 */ int32_t Utf16ToUtf8(std::vector<int8_t> &dst, const int16_t* src); /** @brief 文字コードを変換する。(UTF8 -> UTF16) @param dst [out] 出力vector @param src [in] 入力配列の先頭ポインタ @return 文字数 */ int32_t Utf8ToUtf16(std::vector<int16_t> &dst, const int8_t* src); std::wstring ToWide(const char* pText); astring ToAString(const char16_t* src); astring ToAString(const wchar_t* src); astring ToAString(const char* src); std::string ToUtf8String(const achar* src); astring ReplaceAll(const astring text, const achar* from, const achar* to); astring CombinePath(const achar* rootPath, const achar* path); #if !_WIN32 && !SWIG //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- static astring ReplaceAll(const astring text, const wchar_t* from, const wchar_t* to) { return ReplaceAll(text, ToAString(from).c_str(), ToAString(to).c_str()); } #endif //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- #if !SWIG void ShowMessageBox(const achar* title, const achar* text); #if _WIN32 #define SPRINTF sprintf_s #else #define SPRINTF snprintf #endif #define ACE_ASSERT(condition, message) { \ if (!(condition)) { \ char lbuf[100]; \ SPRINTF(lbuf, 100, "%d", __LINE__); \ auto m = ::asd::ToAString(message); \ auto f = ::asd::ToAString(__FILE__); \ auto l = ::asd::ToAString(lbuf); \ auto state = f + ::asd::ToAString("(") + l + ::asd::ToAString(")"); \ auto m_ = state + ::asd::ToAString("\n") + m; \ ::asd::ShowMessageBox(::asd::ToAString("Assert").c_str(), m_.c_str()); \ (*((volatile int*)0x0) = 0x0); } \ } #define ACE_ASSERT_A(condition, message) { \ if (!(condition)) { \ char lbuf[100]; \ SPRINTF(lbuf, 100, "%d", __LINE__); \ auto m = message; \ auto f = ::asd::ToAString(__FILE__); \ auto l = ::asd::ToAString(lbuf); \ auto state = f + ::asd::ToAString("(") + l + ::asd::ToAString(")"); \ auto m_ = state + ::asd::ToAString("\n") + m; \ ::asd::ShowMessageBox(::asd::ToAString("Assert").c_str(), m_.c_str()); \ (*((volatile int*)0x0) = 0x0); } \ } #endif /** @brief static_castとdynamic_castの値が違う場合に警告するassert */ #define ASSERT_STATIC_CAST(type,name) assert( static_cast<type>(name) == dynamic_cast<type>(name) ) //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- #ifdef _WIN32 inline void Sleep( int32_t ms ) { ::Sleep( ms ); } #else inline void Sleep( int32_t ms ) { usleep( 1000 * ms ); } #endif //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- template <class T> void SafeAddRef(T& t) { if (t != NULL) { t->AddRef(); } } //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- template <class T> void SafeRelease(T& t) { if (t != NULL) { t->Release(); t = NULL; } } //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- template <class T> void SafeSubstitute(T& target, T& value) { SafeAddRef(value); SafeRelease(target); target = value; } //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- template <typename T> inline void SafeDelete(T*& p) { if (p != NULL) { delete (p); (p) = NULL; } } //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- template <typename T> inline void SafeDeleteArray(T*& p) { if (p != NULL) { delete[] (p); (p) = NULL; } } const float PI = 3.14159265358979f; //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- static float DegreeToRadian(float degree) { return degree / 180.0f * PI; } //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- static float RadianToDegree(float radian) { return radian / PI * 180.0f; } //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- } //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- namespace asd { //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- /** @brief 全ての参照カウンタの値の合計を取得する。 @return 参照カウンタ合計値 */ int32_t GetGlobalReferenceCount(); /** @brief 全ての参照カウンタの値を取得し、0ならDLLを解放する。 */ void CheckDLL(); //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- } //---------------------------------------------------------------------------------- // Include //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- namespace asd { //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- /** @brief 2次元ベクトル(整数) */ struct Vector2DI { public: /** @brief X */ int32_t X; /** @brief Y */ int32_t Y; /** @brief コンストラクタ */ Vector2DI(); /** @brief コンストラクタ */ Vector2DI(int32_t x, int32_t y); bool operator == (const Vector2DI& o); bool operator != (const Vector2DI& o); Vector2DI operator-(); Vector2DI operator+(const Vector2DI& right); Vector2DI operator-(const Vector2DI& right); Vector2DI operator*(const Vector2DI& right); Vector2DI operator/(const Vector2DI& right); Vector2DI operator*(int32_t right); Vector2DI operator/(int32_t right); Vector2DI& operator+=(const Vector2DI& right); Vector2DI& operator-=(const Vector2DI& right); Vector2DI& operator*=(const Vector2DI& right); Vector2DI& operator/=(const Vector2DI& right); Vector2DI& operator*=(int32_t right); Vector2DI& operator/=(int32_t right); /** @brief Vector2DF型に変換する。 @return Vector2DF型 */ Vector2DF To2DF() const; /** @brief スカラーで除算する。 @param v1 値1 @param v2 値2 @return v1/v2 */ static Vector2DI DivideByScalar(const Vector2DI& v1, float v2); }; //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- } //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // Include //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- namespace asd { //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- /** @brief 2次元ベクトル */ struct Vector2DF { public: /** @brief X成分 */ float X; /** @brief Y成分 */ float Y; /** @brief コンストラクタ */ Vector2DF(); /** @brief コンストラクタ @param x X成分 @param y Y成分 */ Vector2DF(float x, float y); /** @brief このベクトルの長さを取得する。 */ float GetLength() const { return sqrt(GetSquaredLength()); } /** @brief このベクトルの長さの二乗を取得する。 */ float GetSquaredLength() const { return X * X + Y * Y; } /** @brief このベクトルの長さを設定する。 */ void SetLength(float value) { float length = GetLength(); (*this) *= (value / length); } /** @brief このベクトルの単位ベクトルを取得する。 */ Vector2DF GetNormal() { float length = GetLength(); return Vector2DF(X / length, Y / length); } /** @brief このベクトルの単位ベクトル化する。 */ void Normalize() { float length = GetLength(); (*this) /= length; } /** @brief このベクトルの向きを弧度法で取得する。 */ float GetRadian() const { return atan2(Y, X); } /** @brief このベクトルの向きを弧度法で設定する。 @note 大きさを維持したまま、向きを変更する。 */ void SetRadian(float value) { float length = GetLength(); SinCos(value, Y, X); X *= length; Y *= length; } /** @brief このベクトルの向きを度数法で取得する。 */ float GetDegree() const { return RadianToDegree(atan2(Y, X)); } /** @brief このベクトルの向きを度数法で設定する。 */ void SetDegree(float value) { float length = GetLength(); SinCos(DegreeToRadian(value), Y, X); X *= length; Y *= length; } bool operator==(const Vector2DF& right); bool operator!=(const Vector2DF& right); bool operator > (const Vector2DF& o) const; bool operator < (const Vector2DF& o) const; Vector2DF operator-(); Vector2DF operator+(const Vector2DF& right) const; Vector2DF operator-(const Vector2DF& right) const; Vector2DF operator*(const Vector2DF& right) const; Vector2DF operator/(const Vector2DF& right) const; Vector2DF operator*(float right) const; Vector2DF operator/(float right) const; Vector2DF& operator+=(const Vector2DF& right); Vector2DF& operator-=(const Vector2DF& right); Vector2DF& operator*=(const Vector2DF& right); Vector2DF& operator/=(const Vector2DF& right); Vector2DF& operator*=(float right); Vector2DF& operator/=(float right); /** @brief 内積を取得する。 @param v1 v1ベクトル @param v2 v2ベクトル @return 内積v1・v2 */ static float Dot(const Vector2DF& v1, const Vector2DF& v2) { return v1.X * v2.X + v1.Y * v2.Y; } /** @brief 外積を取得する。 @param v1 v1ベクトル @param v2 v2ベクトル @return 外積v1×v2 */ static float Cross(const Vector2DF& v1, const Vector2DF& v2) { return v1.X * v2.Y - v1.Y * v2.X; } /** @brief 2点間の距離を取得する。 @param v1 v1ベクトル @param v2 v2ベクトル @return v1とv2との距離 */ static float Distance(const Vector2DF& v1, const Vector2DF& v2) { float dx = v1.X - v2.X; float dy = v1.Y - v2.Y; return sqrt(dx * dx + dy * dy); } /** @brief 加算する。 @param v1 v1ベクトル @param v2 v2ベクトル @return v1+v2 */ static Vector2DF Add(Vector2DF v1, Vector2DF v2) { return Vector2DF(v1.X + v2.X, v1.Y + v2.Y); } /** @brief 減算する。 @param v1 v1ベクトル @param v2 v2ベクトル @return v1-v2 */ static Vector2DF Subtract(Vector2DF v1, Vector2DF v2) { return Vector2DF(v1.X - v2.X, v1.Y - v2.Y); } /** @brief 除算する。 @param v1 値1 @param v2 値2 @return v1/v2 */ static Vector2DF Divide(const Vector2DF& v1, const Vector2DF& v2) { return Vector2DF(v1.X / v2.X, v1.Y / v2.Y); } /** @brief スカラーで除算する。 @param v1 値1 @param v2 値2 @return v1/v2 */ static Vector2DF DivideByScalar(const Vector2DF& v1, float v2) { return Vector2DF(v1.X / v2, v1.Y / v2); } /** @brief Vector2DI型に変換する。 @return Vector2DI型 */ Vector2DI To2DI() const; }; //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- } //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // Include //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- namespace asd { //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- /** @brief 3次元ベクトル */ struct Vector3DF { public: /** @brief X成分 */ float X; /** @brief Y成分 */ float Y; /** @brief Z成分 */ float Z; /** @brief コンストラクタ */ Vector3DF(); /** @brief コンストラクタ @param x X成分 @param y Y成分 @param z Z成分 */ Vector3DF( float x, float y, float z ); bool operator == (const Vector3DF& o); bool operator != (const Vector3DF& o); bool operator > (const Vector3DF& o) const; bool operator < (const Vector3DF& o) const; Vector3DF operator-(); Vector3DF operator + ( const Vector3DF& o ) const; Vector3DF operator - ( const Vector3DF& o ) const; Vector3DF operator * (const Vector3DF& o) const; Vector3DF operator / (const Vector3DF& o) const; Vector3DF operator * ( const float& o ) const; Vector3DF operator / ( const float& o ) const; Vector3DF& operator += ( const Vector3DF& o ); Vector3DF& operator -= ( const Vector3DF& o ); Vector3DF& operator *= (const Vector3DF& o); Vector3DF& operator /= (const Vector3DF& o); Vector3DF& operator *= ( const float& o ); Vector3DF& operator /= ( const float& o ); /** @brief このベクトルの長さを取得する。 */ float GetLength() const { return sqrt(GetSquaredLength()); } /** @brief このベクトルの長さの二乗を取得する。 */ float GetSquaredLength() const { return X * X + Y * Y + Z * Z; } /** @brief このベクトルの長さを設定する。 */ void SetLength(float value) { float length = GetLength(); (*this) *= (value / length); } /** @brief このベクトルの単位ベクトルを取得する。 */ Vector3DF GetNormal() { float length = GetLength(); return Vector3DF(X / length, Y / length, Z / length); } /** @brief このベクトルの単位ベクトル化する。 */ void Normalize() { float length = GetLength(); (*this) /= length; } /** @brief 内積を取得する。 @param v1 v1ベクトル @param v2 v2ベクトル @return 内積v1・v2 */ static float Dot( const Vector3DF& v1, const Vector3DF& v2 ); /** @brief 外積を取得する。 @param v1 v1ベクトル @param v2 v2ベクトル @return 外積v1×v2 @note 右手の親指がv1、人差し指がv2としたとき、中指の方向を返す。 */ static Vector3DF Cross(const Vector3DF& v1, const Vector3DF& v2 ); /** @brief 加算する。 @param v1 v1ベクトル @param v2 v2ベクトル @return v1+v2 */ static Vector3DF Add(Vector3DF v1, Vector3DF v2) { return Vector3DF(v1.X + v2.X, v1.Y + v2.Y, v1.Z + v2.Z); } /** @brief 減算する。 @param v1 v1ベクトル @param v2 v2ベクトル @return v1-v2 */ static Vector3DF Subtract(Vector3DF v1, Vector3DF v2); /** @brief 除算する。 @param v1 値1 @param v2 値2 @return v1/v2 */ static Vector3DF Divide(const Vector3DF& v1, const Vector3DF& v2) { return Vector3DF(v1.X / v2.X, v1.Y / v2.Y, v1.Z / v2.Z); } /** @brief スカラーで除算する。 @param v1 値1 @param v2 値2 @return v1/v2 */ static Vector3DF DivideByScalar(const Vector3DF& v1, float v2) { return Vector3DF(v1.X / v2, v1.Y / v2, v1.Z / v2); } /** @brief 2点間の距離を取得する。 @param v1 v1ベクトル @param v2 v2ベクトル @return v1とv2の距離 */ static float Distance(const Vector3DF& v1, const Vector3DF& v2); }; //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- } //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // Include //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- namespace asd { //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- /** @brief 4次元ベクトル */ struct Vector4DF { public: /** @brief X成分 */ float X; /** @brief Y成分 */ float Y; /** @brief Z成分 */ float Z; /** @brief W成分 */ float W; /** @brief コンストラクタ */ Vector4DF(); /** @brief コンストラクタ @param x X成分 @param y Y成分 @param z Z成分 @param w W成分 */ Vector4DF(float x, float y, float z, float w); /** @brief このベクトルの長さを取得する。 */ float GetLength() const { return sqrt(GetSquaredLength()); } /** @brief このベクトルの長さの二乗を取得する。 */ float GetSquaredLength() const { return X * X + Y * Y + Z * Z + W * W; } /** @brief このベクトルの長さを設定する。 */ void SetLength(float value) { float length = GetLength(); (*this) *= (value / length); } /** @brief このベクトルの単位ベクトルを取得する。 */ Vector4DF GetNormal() { float length = GetLength(); return Vector4DF(X / length, Y / length, Z / length, W / length); } /** @brief このベクトルの単位ベクトル化する。 */ void Normalize() { float length = GetLength(); (*this) /= length; } bool operator == (const Vector4DF& o); bool operator != (const Vector4DF& o); Vector4DF operator-(); Vector4DF operator + (const Vector4DF& o) const; Vector4DF operator - (const Vector4DF& o) const; Vector4DF operator * (const Vector4DF& o) const; Vector4DF operator / (const Vector4DF& o) const; Vector4DF operator * (const float& o) const; Vector4DF operator / (const float& o) const; Vector4DF& operator += (const Vector4DF& o); Vector4DF& operator -= (const Vector4DF& o); Vector4DF& operator *= (const Vector4DF& o); Vector4DF& operator /= (const Vector4DF& o); Vector4DF& operator *= (const float& o); Vector4DF& operator /= (const float& o); /** @brief 内積を取得する。 @param v1 v1ベクトル @param v2 v2ベクトル @return 内積v1・v2 */ static float Dot(const Vector4DF& v1, const Vector4DF& v2); /** @brief 2点間の距離を取得する。 @param v1 v1ベクトル @param v2 v2ベクトル @return v1とv2の距離 */ static float Distance(const Vector4DF& v1, const Vector4DF& v2); }; //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- } namespace asd { /** @brief 3×3行列を表す構造体。 @note [0,0][0,1] [1,0][1,1] */ struct Matrix33 { public: /** @brief オブジェクトを生成し、単位行列で初期化する。 */ Matrix33(); /** @brief 行列の値 */ float Values[3][3]; /** @brief 単位行列を設定する。 */ Matrix33& SetIdentity(); /** @brief 転置行列を設定する。 @return このインスタンスへの参照 */ Matrix33& SetTransposed(); /** @brief 逆行列を設定する。 @return このインスタンスへの参照 */ Matrix33& SetInverted(); /** @brief 逆行列を取得する。 @return 逆行列 */ Matrix33 GetInverted(); /** @brief 平行移動の行列を設定する。 */ Matrix33& SetTranslation(float x, float y); /** @brief 回転行列を設定する。 */ Matrix33& SetRotation(float angle); /** @brief 拡大・縮小行列を設定する。 */ Matrix33& SetScale(float x, float y); /** @brief 行列でベクトルを変形させる。 @param in 変形前ベクトル @return 変形後ベクトル */ Vector2DF Transform2D(const Vector2DF& in) const; /** @brief 行列でベクトルを変形させる。 @param in 変形前ベクトル @return 変形後ベクトル */ Vector3DF Transform3D(const Vector3DF& in) const; /** @brief 3×3行列の掛け算を計算する。 */ Matrix33 operator*(const Matrix33& right); Vector3DF operator*(const Vector3DF& right); }; } //---------------------------------------------------------------------------------- // Include //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- namespace asd { //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- /** @brief 4×4行列を表す構造体 @note M * V[x,y,z,1] の形<BR> [0,0][0,1][0,2][0,3] [1,0][1,1][1,2][1,3] [2,0][2,1][2,2][2,3] [3,0][3,1][3,2][3,3] */ struct Matrix44 { private: public: /** @brief オブジェクトを生成し、単位行列で初期化する。 */ Matrix44(); /** @brief 行列の値 */ float Values[4][4]; /** @brief 単位行列を設定する。 @return このインスタンスへの参照 */ Matrix44& SetIdentity(); /** @brief 転置行列を設定する。 @return このインスタンスへの参照 */ Matrix44& SetTransposed(); /** @brief 逆行列を設定する。 @return このインスタンスへの参照 */ Matrix44& SetInverted(); /** @brief 逆行列を取得する。 @return 逆行列 */ Matrix44 GetInverted() const; /** @brief カメラ行列(右手系)を設定する。 @param eye カメラの位置 @param at カメラの注視点 @param up カメラの上方向 @return このインスタンスへの参照 */ Matrix44& SetLookAtRH( const Vector3DF& eye, const Vector3DF& at, const Vector3DF& up ); /** @brief カメラ行列(左手系)を設定する。 @param eye カメラの位置 @param at カメラの注視点 @param up カメラの上方向 @return このインスタンスへの参照 */ Matrix44& SetLookAtLH(const Vector3DF& eye, const Vector3DF& at, const Vector3DF& up); /** @brief 射影行列(右手系)を設定する。 @param ovY Y方向への視野角(ラジアン) @param aspect 画面のアスペクト比 @param zn 最近距離 @param zf 最遠距離 @return このインスタンスへの参照 */ Matrix44& SetPerspectiveFovRH(float ovY, float aspect, float zn, float zf); /** @brief OpenGL用射影行列(右手系)を設定する。 @param ovY Y方向への視野角(ラジアン) @param aspect 画面のアスペクト比 @param zn 最近距離 @param zf 最遠距離 @return このインスタンスへの参照 */ Matrix44& SetPerspectiveFovRH_OpenGL(float ovY, float aspect, float zn, float zf); /** @brief 射影行列(左手系)を設定する。 @param ovY Y方向への視野角(ラジアン) @param aspect 画面のアスペクト比 @param zn 最近距離 @param zf 最遠距離 @return このインスタンスへの参照 */ Matrix44& SetPerspectiveFovLH(float ovY, float aspect, float zn, float zf); /** @brief 正射影行列(右手系)を設定する。 @param width 横幅 @param height 縦幅 @param zn 最近距離 @param zf 最遠距離 @return このインスタンスへの参照 */ Matrix44& SetOrthographicRH(float width, float height, float zn, float zf); /** @brief 正射影行列(左手系)を設定する。 @param width 横幅 @param height 縦幅 @param zn 最近距離 @param zf 最遠距離 @return このインスタンスへの参照 */ Matrix44& SetOrthographicLH(float width, float height, float zn, float zf); /** @brief 並行移動行列を設定する。 @param x X方向移動量 @param y Y方向移動量 @param z Z方向移動量 @return このインスタンスへの参照 */ Matrix44& SetTranslation(float x, float y, float z); /** @brief X軸回転行列(右手)を設定する。 @param angle X軸回転量(ラジアン) @return このインスタンスへの参照 */ Matrix44& SetRotationX(float angle); /** @brief Y軸回転行列(右手)を設定する。 @param angle Y軸回転量(ラジアン) @return このインスタンスへの参照 */ Matrix44& SetRotationY(float angle); /** @brief Z軸回転行列(右手)を設定する。 @param angle Z軸回転量(ラジアン) @return このインスタンスへの参照 */ Matrix44& SetRotationZ(float angle); /** @brief 任意軸の反時計回転行列(右手)を設定する。 @param axis 軸 @param angle 回転量(ラジアン) @return このインスタンスへの参照 */ Matrix44& SetRotationAxis(const Vector3DF& axis, float angle); /** @brief クオータニオンを元に回転行列(右手)を設定する。 @param x クオータニオン @param y クオータニオン @param z クオータニオン @param w クオータニオン @return このインスタンスへの参照 */ Matrix44& SetQuaternion(float x, float y, float z, float w); /** @brief 拡大行列を設定する。 @param x X方向拡大率 @param y Y方向拡大率 @param z Z方向拡大率 @return このインスタンスへの参照 */ Matrix44& SetScale(float x, float y, float z); /** @brief 行列でベクトルを変形させる。 @param in 変形前ベクトル @return 変形後ベクトル */ Vector3DF Transform3D(const Vector3DF& in) const; /** @brief 行列でベクトルを変形させる。 @param in 変形前ベクトル @return 変形後ベクトル */ Vector4DF Transform4D(const Vector4DF& in) const; Matrix44 operator * (const Matrix44& right) const; Vector3DF operator*(const Vector3DF& right) const; Vector4DF operator*(const Vector4DF& right) const; /** @brief 乗算を行う。 @param o 出力先 @param in1 行列1 @param in2 行列2 @return 出力先の参照 */ static Matrix44& Mul( Matrix44& o, const Matrix44& in1, const Matrix44& in2 ); }; //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- } //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- #include <array> namespace asd { /** @brief 長方形(整数)の構造体 */ struct RectI { public: /** @brief 左上X座標 */ int X; /** @brief 左上Y座標 */ int Y; /** @brief 横幅 */ int Width; /** @brief 縦幅 */ int Height; /** @brief コンストラクタ */ RectI(); /** @brief コンストラクタ @param x 左上X座標 @param y 左上Y座標 @param width 横幅 @param height 縦幅 */ RectI(int x, int y, int width, int height); /** @brief コンストラクタ @param position 左上座標 @param size 大きさ */ RectI(Vector2DI position, Vector2DI size); /** @brief 左上座標を取得する。 @return 左上座標 */ Vector2DI GetPosition() const; /** @brief 大きさを取得する。 @return 大きさ */ Vector2DI GetSize() const; /** @brief 四隅の座標を(X,Y)、(X+Width,Y)、(X+Width,Y+Height)、(X,Y+Height)の順に配列として取得する。 @return 座標 */ std::array<Vector2DI, 4> GetVertexes() const; bool operator == (const RectI& other) const; /** @brief RectF型に変換する。 @return RectF型 */ RectF ToF() const; }; } //---------------------------------------------------------------------------------- // Include //---------------------------------------------------------------------------------- #include <array> //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- namespace asd { //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- /** @brief 長方形(浮動小数点)の構造体 */ struct RectF { public: /** @brief 左上X座標 */ float X; /** @brief 左上Y座標 */ float Y; /** @brief 横幅 */ float Width; /** @brief 縦幅 */ float Height; /** @brief コンストラクタ */ RectF(); /** @brief コンストラクタ @param x 左上X座標 @param y 左上Y座標 @param width 横幅 @param height 縦幅 */ RectF(float x, float y, float width, float height); /** @brief コンストラクタ @param position 左上座標 @param size 大きさ */ RectF(Vector2DF position, Vector2DF size); /** @brief 左上座標を取得する。 @return 左上座標 */ Vector2DF GetPosition() const; /** @brief 大きさを取得する。 @return 大きさ */ Vector2DF GetSize() const; /** @brief 四隅の座標を(X,Y)、(X+Width,Y)、(X+Width,Y+Height)、(X,Y+Height)の順に配列として取得する。 @return 座標 */ std::array<Vector2DF, 4> GetVertexes() const; bool operator!=(const RectF& right); /** @brief RectI型に変換する。 @return RectI型 */ RectI ToI() const; }; //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- } //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- #include<string> #if defined(_MSC_VER) #elif defined(__clang__) #include<cxxabi.h> #include<cstdlib> #include<cassert> #include<typeinfo> #if !__has_include(<cxxabi.h>) #error "cxxabi.h is not found" #endif #elif defined(__GNUC__) #include<cxxabi.h> #include<cstdlib> #include<cassert> #include<typeinfo> #endif namespace asd { /** @brief 型から型名を人間の読める形の文字列として得る @detail 対応コンパイラ: msvc, gcc, clang. */ template<typename T> std::string GetTypeName() { #ifdef _MSC_VER #ifndef _CPPRTTI #error "/GR option is needed to get type names" #endif return std::string(typeid(T).name()); #else int stat; std::string ret; char *pc = abi::__cxa_demangle(typeid(T).name(), 0, 0, &stat); switch (stat) { case 0: ret = std::string(pc); free(pc); return ret; break; case -1: assert(!"failed to memory allocation"); return ret; break; case -2: assert(!"the type name couldn't be demangled"); return ret; break; case -3: assert(!"there's an illegal argument"); return ret; break; default: return ret; break; } #endif } } #include<cstddef> #include<cassert> namespace asd { /** @brief 確保されたメモリ領域の先頭ポインタと長さから、デバッグ時境界検査つき配列を提供する @details 確保されたメモリの所有権は移動しないので、使用する側でメモリを解放する必要がある */ template<typename T> class PointerArray { public: T* m_data; //!< 配列の先頭ポインタ protected: size_t m_length; //!< 配列の長さ public: typedef T Type; //!< 対象となっている型 //----------------------------------------------------------------------------------- // //----------------------------------------------------------------------------------- /** @brief 配列の長さを得る */ size_t GetLength() const{return m_length;} //----------------------------------------------------------------------------------- // //----------------------------------------------------------------------------------- /** @brief コンストラクタ @detail T*はlength確保した配列と見なす。所有権は移動しない @param idx [in] */ //! PointerArray(T* ptr, size_t length): m_data(ptr), m_length(length){} //----------------------------------------------------------------------------------- // //----------------------------------------------------------------------------------- /** @brief idx番目の要素への参照を得る @detail デバッグ時には範囲外チェックがつく @param idx [in] 要素のインデックス */ T& At(size_t idx) { assert(idx >= 0 && idx < m_length); return m_data[idx]; } //----------------------------------------------------------------------------------- // //----------------------------------------------------------------------------------- /** @brief idx番目の要素への参照を得る @detail デバッグ時には範囲外チェックがつく @param idx [in] 要素のインデックス */ T& operator[](size_t idx) { return At(idx); } }; } #include<cstdint> #ifdef _WIN32 /* win */ #include<Windows.h> #else /* *nix */ #include <sys/time.h> #endif namespace asd { /** @brief パフォーマンスカウンタの現在の値をナノ秒単位で返す */ inline int64_t GetTime() { #ifdef _WIN32 int64_t count, freq; if (QueryPerformanceCounter((LARGE_INTEGER*)&count)) { if (QueryPerformanceFrequency((LARGE_INTEGER*)&freq)) { // オーバーフロー対策 // return count * 1000000 / freq; と等価 int64_t ret = 0; ret = count / freq; count -= ret * freq; ret *= 1000000; ret += count * 1000000 / freq; return ret; } } return 0; #else struct timeval tv; gettimeofday(&tv, NULL); return (int64_t)tv.tv_sec * 1000000 + (int64_t)tv.tv_usec; #endif } } #include<cassert> #include<cstring> namespace asd { /** @brief 型は異なるが同じ構造を持つ2変数の間でコピーする @details T, Uが同じサイズかを検査し、そのサイズ分fromからtoにコピーする @warning とても危険な関数なため、使用の際には細心の注意を要する。 @param from [in] コピー元のポインタ @param to [out] コピー先のポインタ */ template<typename T, typename U> void TypeErasureCopy(T const* from, U* to) { #if __cplusplus >= 201103L static_assert(alignof(T) == alignof(U), "arguments 'from' and 'to' must be the same alignment."); static_assert(sizeof(T) == sizeof(U), "arguments 'from' and 'to' must be the same size."); #else assert(sizeof(T) == sizeof(U)); #endif memcpy(to, from, sizeof(T)); } } //---------------------------------------------------------------------------------- // Include //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- namespace asd { //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- /** @brief 回転行列の計算順序 */ enum class RotationOrder : int32_t { QUATERNION = 10, XZY = 11, XYZ = 12, ZXY = 13, ZYX = 14, YXZ = 15, YZX = 16, AXIS = 18, }; /** @brief キー間の補間方法 */ enum class InterpolationType : int32_t { /** @brief 次のキーまで定数で補間 */ Constant = 0, /** @brief 次のキーまで線形で補間 */ Linear = 1, /** @brief 次のキーまで三次方程式で補間 */ Cubic = 2, }; /** @brief Fカーブのキーフレーム */ struct FCurveKeyframe { public: /** @brief 時間と値 */ Vector2DF KeyValue; /** @brief 制御用ハンドル */ Vector2DF LeftHandle; /** @brief 制御用ハンドル */ Vector2DF RightHandle; /** @brief 補間方法 */ InterpolationType Interpolation; FCurveKeyframe() { Interpolation = InterpolationType::Linear; } }; //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- } //---------------------------------------------------------------------------------- // Include //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- namespace asd { //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- /** @brief 色 */ struct Color { public: /** @brief 赤 */ uint8_t R; /** @brief 緑 */ uint8_t G; /** @brief 青 */ uint8_t B; /** @brief 透明度 */ uint8_t A; /** @brief コンストラクタ */ Color(); /** @brief コンストラクタ @param r 赤 @param g 緑 @param b 青 @param a 透明度 */ Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a); Color operator*(const Color& right); Color& operator*=(const Color& right); bool operator==(const Color& right); }; //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- } //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- #include<deque> #include<cstdlib> #include<algorithm> #include<cstdint> #include<climits> #include<cassert> namespace asd { class BinaryReader { protected: std::deque<uint8_t> data; public: template<typename itrT> void ReadIn(itrT beg, itrT end) { data.assign(beg, end); } template<typename T> T Get(){ assert(!"The type cannot be serializable."); return T();}; bool IsEmpty()const{ return data.empty(); } inline std::vector<uint8_t> Get(int32_t size) { std::vector<uint8_t> v; for (int i = 0; i < size; i++) { v.push_back(data.front()); data.pop_front(); } return v; } }; template<> inline int32_t BinaryReader::Get() { int8_t cs[4]; for (int i = 0; i < 4; i++) { assert(!data.empty()); if (data.empty()){ return static_cast<int32_t>(0); } cs[i] = data.front(); data.pop_front(); } return *(static_cast<int32_t*>(static_cast<void*>(cs))); } template<> inline int16_t BinaryReader::Get() { int8_t cs[2]; for (int i = 0; i < 2; i++) { assert(!data.empty()); if (data.empty()){ return static_cast<int16_t>(0); } cs[i] = data.front(); data.pop_front(); } return *(static_cast<int16_t*>(static_cast<void*>(cs))); } template<> inline uint16_t BinaryReader::Get() { int8_t cs[2]; for (int i = 0; i < 2; i++) { assert(!data.empty()); if (data.empty()){ return static_cast<uint16_t>(0); } cs[i] = data.front(); data.pop_front(); } return *(static_cast<uint16_t*>(static_cast<void*>(cs))); } template<> inline int8_t BinaryReader::Get() { int8_t c; assert(!data.empty()); if (data.empty()){ return static_cast<int8_t>(0); } c = data.front(); data.pop_front(); return c; } template<> inline uint8_t BinaryReader::Get() { uint8_t c; assert(!data.empty()); if (data.empty()){ return static_cast<uint8_t>(0); } c = data.front(); data.pop_front(); return c; } template<> inline std::string BinaryReader::Get() { int8_t lenCs[4]; std::string str = std::string(); for (int i = 0; i < 4; i++) { assert(!data.empty()); if (data.empty()){ return str; } lenCs[i] = data.front(); data.pop_front(); } int32_t const len = *(static_cast<int32_t*>(static_cast<void*>(lenCs))); int8_t chr; for (int32_t i = 0; i < len; i++) { assert(!data.empty()); if (data.empty()){ return str; } chr = data.front(); data.pop_front(); str.push_back(*(static_cast<char*>(static_cast<void*>(&chr)))); } return str; } template<> inline astring BinaryReader::Get() { int8_t lenCs[4]; astring astr = astring(); for (int i = 0; i < 4; i++) { assert(!data.empty()); if (data.empty()){ return astr; } lenCs[i] = data.front(); data.pop_front(); } int32_t const len = *(static_cast<int32_t*>(static_cast<void*>(lenCs))); int8_t charCs[2]; for (int32_t i = 0; i < len; i++) { for (int j = 0; j < 2; j++) { assert(!data.empty()); if (data.empty()){ return astr; } charCs[j] = data.front(); data.pop_front(); } astr.push_back(*(static_cast<achar*>(static_cast<void*>(charCs)))); } return astr; } //template<> inline asd::achar* BinaryReader::Get() //{ // int8_t lenCs[4]; // for (int i = 0; i < 4; i++) // { // assert(!data.empty()); // if (data.empty()){ // return nullptr; // } // lenCs[i] = data.front(); // data.pop_front(); // } // // int32_t const len = *(static_cast<int32_t*>(static_cast<void*>(lenCs))); // // asd::achar *achs = static_cast<asd::achar*>(calloc(len + 1, sizeof(asd::achar))); // int8_t charCs[2]; // // for (int32_t i = 0; i < len; i++) // { // for (int j = 0; j < 2; j++) // { // assert(!data.empty()); // if (data.empty()){ // return achs; // } // charCs[j] = data.front(); // data.pop_front(); // } // // achs[i] = *(static_cast<asd::achar*>(static_cast<void*>(charCs))); // // } // return achs; //} template<> inline float BinaryReader::Get() { int8_t cs[4]; for (int i = 0; i < 4; i++) { assert(!data.empty()); if (data.empty()){ return static_cast<float>(0); } cs[i] = data.front(); data.pop_front(); } return *(static_cast<float*>(static_cast<void*>(cs))); } template<> inline Vector3DF BinaryReader::Get() { Vector3DF v; v.X = Get<float>(); v.Y = Get<float>(); v.Z = Get<float>(); return v; } template<> inline Vector2DF BinaryReader::Get() { Vector2DF v; v.X = Get<float>(); v.Y = Get<float>(); return v; } template<> inline Color BinaryReader::Get() { Color c; c.R = Get<uint8_t>(); c.G = Get<uint8_t>(); c.B = Get<uint8_t>(); c.A = Get<uint8_t>(); return c; } template<> inline RectI BinaryReader::Get() { RectI v; v.X = Get<int32_t>(); v.Y = Get<int32_t>(); v.Width = Get<int32_t>(); v.Height = Get<int32_t>(); return v; } template<> inline RectF BinaryReader::Get() { RectF v; v.X = Get<float>(); v.Y = Get<float>(); v.Width = Get<float>(); v.Height = Get<float>(); return v; } template<> inline FCurveKeyframe BinaryReader::Get() { FCurveKeyframe keyframe; keyframe.KeyValue = Get<Vector2DF>(); keyframe.LeftHandle = Get<Vector2DF>(); keyframe.RightHandle = Get<Vector2DF>(); keyframe.Interpolation = (InterpolationType)Get<int32_t>(); return keyframe; } template<> inline RotationOrder BinaryReader::Get() { RotationOrder rotationOrder; rotationOrder = (RotationOrder)Get<int32_t>(); return rotationOrder; } template<> inline Matrix44 BinaryReader::Get() { Matrix44 m; for (int j = 0; j < 4; j++) { for (int i = 0; i < 4; i++) { m.Values[j][i] = Get<float>(); } } return m; } } #include<vector> #include<cstdint> #include<climits> #include<fstream> #include<string> namespace asd { /** @brief 数値、文字列をバイト列にシリアライズし、ファイルに書き出すクラス @detail 対応する型はint32_t, int16_t, int8_t, uint8_t, std::string, astring, achar* @warning エンディアンは現状非互換、正当性の検査等はないので、 データを読み出す際はBinaryReaderで*書き出した順に*読み出すこと */ class BinaryWriter { protected: std::vector<int8_t> m_data; ///< シリアライズされたバイト列 public: //----------------------------------------------------------------------------------- // //----------------------------------------------------------------------------------- /** @brief 扱うデータが大きいことが予想される場合にあらかじめ容量を確保する @param size 確保するサイズ */ void Reserve(size_t size) { m_data.reserve(size); } //----------------------------------------------------------------------------------- // //----------------------------------------------------------------------------------- /** @brief シリアライズされたバイト列をconst参照で返す。 @warning 本クラスのインスタンスより寿命を長く取る際はコピーなどして懸垂参照を避けること */ std::vector<int8_t> const& Get() const { return m_data; } //----------------------------------------------------------------------------------- // //----------------------------------------------------------------------------------- /** @brief int32_tをシリアライズし、バイト列の末尾に追加する @param content シリアライズする整数 */ void Push(int32_t content){ int8_t* pc = static_cast<int8_t*>(static_cast<void*>(&content)); for (int i = 0; i < 4; i++) { m_data.push_back(pc[i]); } } //----------------------------------------------------------------------------------- // //----------------------------------------------------------------------------------- /** @brief int16_tをシリアライズし、バイト列の末尾に追加する @param content シリアライズする整数 */ void Push(int16_t content){ int8_t* pc = static_cast<int8_t*>(static_cast<void*>(&content)); for (int i = 0; i < 2; i++) { m_data.push_back(pc[i]); } } //----------------------------------------------------------------------------------- // //----------------------------------------------------------------------------------- /** @brief uint16_tをシリアライズし、バイト列の末尾に追加する @param content シリアライズする整数 */ void Push(uint16_t content){ int8_t* pc = static_cast<int8_t*>(static_cast<void*>(&content)); for (int i = 0; i < 2; i++) { m_data.push_back(pc[i]); } } //----------------------------------------------------------------------------------- // //----------------------------------------------------------------------------------- /** @brief int8_tをシリアライズし、バイト列の末尾に追加する @param content シリアライズする整数 */ void Push(int8_t content){ m_data.push_back(content); } //----------------------------------------------------------------------------------- // //----------------------------------------------------------------------------------- /** @brief uint8_tをシリアライズし、バイト列の末尾に追加する @param content シリアライズする整数 */ void Push(uint8_t content){ m_data.push_back(*((uint8_t*)(&content))); } //----------------------------------------------------------------------------------- // //----------------------------------------------------------------------------------- /** @brief std::stringをシリアライズし、バイト列の末尾に追加する @param content シリアライズする文字列 */ void Push(std::string const& content) { // TODO: string::lengthの返値が64bitでもたれていた場合に危険 int32_t l = (int32_t)content.length(); int8_t* pc = static_cast<int8_t*>(static_cast<void*>(&l)); for (int i = 0; i < 4; i++) { m_data.push_back(pc[i]); } for (int32_t i = 0; i < l; i++) { m_data.push_back(static_cast<int8_t>(content.at(i))); } } //----------------------------------------------------------------------------------- // //----------------------------------------------------------------------------------- /** @brief astringをシリアライズし、バイト列の末尾に追加する @param content シリアライズする文字列 */ void Push(astring const& content) { auto l = content.length(); int8_t* pc = static_cast<int8_t*>(static_cast<void*>(&l)); for (int i = 0; i < 4; i++) { m_data.push_back(pc[i]); } for (uint32_t i = 0; i < l; i++) { //copy achar a = content.at(i); int8_t* pcs = static_cast<int8_t*>(static_cast<void*>(&a)); m_data.push_back(static_cast<int8_t>(pcs[0])); m_data.push_back(static_cast<int8_t>(pcs[1])); } } //----------------------------------------------------------------------------------- // //----------------------------------------------------------------------------------- /** @brief achar*をシリアライズし、バイト列の末尾に追加する @param content シリアライズする文字列の先頭ポインタ @param size シリアライズする文字列のサイズ */ void Push(achar const* content, int32_t size) { int8_t* pc = static_cast<int8_t*>(static_cast<void*>(&size)); for (int i = 0; i < 4; i++) { m_data.push_back(pc[i]); } for (int32_t i = 0; i < size; i++) { //copy achar a = content[i]; int8_t* pcs = static_cast<int8_t*>(static_cast<void*>(&a)); m_data.push_back(static_cast<int8_t>(pcs[0])); m_data.push_back(static_cast<int8_t>(pcs[1])); } } //----------------------------------------------------------------------------------- // //----------------------------------------------------------------------------------- /** @brief floatをシリアライズし、バイト列の末尾に追加する @param content シリアライズする実数 */ void Push(float content){ int8_t* pc = static_cast<int8_t*>(static_cast<void*>(&content)); for (int i = 0; i < 4; i++) { m_data.push_back(pc[i]); } } //----------------------------------------------------------------------------------- // //----------------------------------------------------------------------------------- /** @brief asd::Vector3DFをシリアライズし、バイト列の末尾に追加する @param content シリアライズするVector */ void Push(Vector3DF const& content){ Push(content.X); Push(content.Y); Push(content.Z); } //----------------------------------------------------------------------------------- // //----------------------------------------------------------------------------------- /** @brief asd::Vector2DFをシリアライズし、バイト列の末尾に追加する @param content シリアライズするVector */ void Push(Vector2DF const& content){ Push(content.X); Push(content.Y); } //----------------------------------------------------------------------------------- // //----------------------------------------------------------------------------------- /** @brief asd::Matrix44をシリアライズし、バイト列の末尾に追加する @param content シリアライズするVector */ void Push(Matrix44 const& content){ for (int j = 0; j < 4; j++) { for (int i = 0; i < 4; i++) { Push(content.Values[j][i]); } } } //----------------------------------------------------------------------------------- // //----------------------------------------------------------------------------------- /** @brief 保持しているバイト列をストリームに書き出す。 @param os 書き出すストリーム @return 成功すればtrue, 失敗すればfalse */ bool WriteOut(std::ostream& os) const { if (!os){ return false; } for (auto itr = m_data.cbegin(); itr != m_data.cend(); itr++) { os << *itr; } return true; } //----------------------------------------------------------------------------------- // //----------------------------------------------------------------------------------- /** @brief 保持しているバイト列をファイルに書き出す。 @param filename 書き出すファイル名 @param isAppend 追記するか否か @return 成功すればtrue, 失敗すればfalse */ bool WriteOut(std::string const& filename, bool isAppend = false) const { std::ofstream os( filename, std::ios_base::binary | std::ios_base::out | (isAppend ? std::ios_base::app : std::ios_base::out) ); if (!os) { return false; } if (!WriteOut(os)) { return false; } os.close(); return true; } //----------------------------------------------------------------------------------- // //----------------------------------------------------------------------------------- /** @brief デストラクタ */ virtual ~BinaryWriter(){} }; } //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- namespace asd { //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- class Core; class Graphics; class Window; class Cursor; class Keyboard; class Mouse; class Log; class Profiler; class LayerProfiler; class ProfilerViewer; class Renderer2D; class Joystick; class JoystickContainer; class File; class StaticFile; class StreamFile; class Sound; class SoundSource; class Texture; class Texture2D; class RenderTexture2D; class CubemapTexture; class ImagePackage; class Shader2D; class Material2D; class Shader3D; class Material3D; class MaterialPropertyBlock; class Effect; class MassModel; class Model; class Terrain3D; class Font; class CoreChip2D; class Mesh; class Deformer; class AnimationSystem; class AnimationClip; class AnimationSource; class KeyframeAnimation; class ObjectSystemFactory; class CoreScene; class CoreLayer; class CoreShape; class CoreTriangleShape; class CoreRectangleShape; class CoreLineShape; class CoreCircleShape; class CoreArcShape; class CorePolygonShape; class CoreLayer2D; class CoreObject2D; class CoreDrawnObject2D; class CoreTextureObject2D; class CoreCameraObject2D; class CoreTextObject2D; class CoreEffectObject2D; class CoreMapObject2D; class CoreGeometryObject2D; class CoreLayer3D; class CoreObject3D; class CoreModelObject3D; class CoreCameraObject3D; class CoreEffectObject3D; class CoreDirectionalLightObject3D; class CoreMassModelObject3D; class CoreTerrainObject3D; class CorePostEffect; class CoreTransition; //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- /** @brief 起動時に自動的に生成されるレイヤーの種類 */ enum class AutoGeneratedLayerType : int32_t { Layer2D, Layer3D, Nothing, }; /** @brief レイヤーの種類 */ enum class LayerType : int32_t { Layer2D, Layer3D, }; enum class WritingDirection :int32_t { Vertical, Horizontal, }; /** @brief フレームレートの制御方法 */ enum class FramerateMode : int32_t { /** @brief 固定フレームレート */ Constant, /** @brief 可変フレームレート */ Variable, }; enum class TextureFormat : int32_t { R8G8B8A8_UNORM = 0, R16G16B16A16_FLOAT = 11, R32G32B32A32_FLOAT = 1, R8G8B8A8_UNORM_SRGB = 2, R16G16_FLOAT = 3, R8_UNORM = 4, BC1 = 5, BC2 = 6, BC3 = 7, BC1_SRGB = 8, BC2_SRGB = 9, BC3_SRGB = 10, }; enum class TextureClassType : int32_t { Texture2D = 0, RenderTexture2D = 1, CubemapTexture = 2, DepthBuffer = 3, }; /** @brief 描画時のブレンドモードを表す列挙体 */ enum class AlphaBlendMode : int32_t { /// <summary> /// 不透明 /// </summary> Opacity = 0, /// <summary> /// 透明 /// </summary> Blend = 1, /// <summary> /// 加算 /// </summary> Add = 2, /// <summary> /// 減算 /// </summary> Sub = 3, /// <summary> /// 乗算 /// </summary> Mul = 4, /// <summary> /// 全加算(内部処理用) /// </summary> AddAll = 5, /// <summary> /// 全不透明(内部処理用) /// </summary> OpacityAll = 6, }; enum class TextureFilterType : int32_t { Nearest = 0, Linear = 1, }; enum class TextureWrapType : int32_t { Repeat = 0, Clamp = 1, }; enum class CullingType : int32_t { Front = 0, Back = 1, Double = 2, }; /** @brief 描画方法 */ enum class GraphicsDeviceType : int32_t { Default = 0, ///< 実行環境で最も安定している描画方法(初期化時に使用) DirectX11 = 1, ///< DirectX11 OpenGL = 2, ///< OpenGL }; /** @brief ウインドウ表示位置 */ enum class WindowPositionType : int32_t { Default = 0, ///< OSによる自動選択 Centering = 1, ///< プライマリモニタの中央 }; /** @brief カラースペース @note リニアスペースが設定されている場合、画像を逆ガンマ補正して読み込み、描画結果はガンマ補正して出力される。 */ enum class ColorSpaceType : int32_t { GammaSpace = 0, ///< ガンマスペース LinearSpace = 1, ///< リニアスペース }; enum class Object2DType : int32_t { Unknown, Texture, Camera, Effect, Text, Map, Geometry, }; enum class RenderedObject3DType : int32_t { Unknown, Mesh, Camera, Effect, DirectionalLight, MassObject, Terrain, }; /** @brief シェーダーに対して外部から設定可能なプロパティの変数の種類 */ enum class ShaderVariableType : int32_t { Unknown, Float, Vector2DF, Vector3DF, Vector4DF, Vector4DF_Array, Matrix44, Matrix44_Array, Texture2D, CubemapTexture, }; /** @brief 3D描画時に表示されるバッファ */ enum class VisualizedBufferType : int32_t { FinalImage, DiffuseColor, SpecularColor, Normal, Smoothness, Environment, Occlusion, }; /** @brief 描画設定のクラス */ class RenderSettings { public: /** @brief 遅延レンダリングから軽量レンダリングに変更し高速に描画するか? */ bool IsLightweightMode; /** @brief 画面に表示されるバッファ */ VisualizedBufferType VisualizedBuffer; RenderSettings() { IsLightweightMode = false; VisualizedBuffer = VisualizedBufferType::FinalImage; } }; /** @brief 参照カウンタのインターフェース */ class IReference { public: /** @brief 参照カウンタを加算する。 @return 加算後の参照カウンタ */ virtual int AddRef() = 0; /** @brief 参照カウンタを取得する。 @return 参照カウンタ */ virtual int GetRef() = 0; /** @brief 参照カウンタを減算する。0になった時、インスタンスを削除する。 @return 減算後の参照カウンタ */ virtual int Release() = 0; }; //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- }; //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- #include <memory> #include <atomic> //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- namespace asd { //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- /** @brief 参照カウンタオブジェクト */ class ReferenceObject : public IReference { private: mutable std::atomic<int32_t> m_reference; public: ReferenceObject(); virtual ~ReferenceObject(); virtual int AddRef(); virtual int GetRef(); virtual int Release(); }; #if !SWIG /** @brief 全ての参照カウンタの値の合計を取得する。 @return 参照カウンタ合計値 @note 実体はEngineに存在するのでそちらを参照する。 */ int32_t GetGlobalReferenceCount(); /** @brief 全ての参照カウンタの値を取得し、0ならDLLを解放する。 @note 実体はEngineに存在するのでそちらを参照する。 */ void CheckDLL(); template <typename T> struct ReferenceDeleter { void operator ()(T* p) { auto p_ = ((IReference*) p); SafeRelease(p_); } }; template <typename T> struct ReferenceDeleterWithReleaseDLL { void operator ()(T* p) { auto p_ = ((IReference*) p); SafeRelease(p_); auto ref = GetGlobalReferenceCount(); if (ref == 0) { CheckDLL(); } } }; template <typename T> static std::shared_ptr<T> CreateSharedPtr(T* p) { return std::shared_ptr<T>(p, ReferenceDeleter<T>()); } template <typename T> static std::shared_ptr<T> CreateSharedPtrWithReleaseDLL(T* p) { return std::shared_ptr<T>(p, ReferenceDeleterWithReleaseDLL<T>()); } #endif //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- }; #include <cstdint> namespace asd { /** @brief マウスボタンの押し状態を示す列挙型 */ enum class MouseButtonState : int32_t { /** @brief ボタンをこのフレームで押した状態 */ Push, /** @brief ボタンをこのフレームで離した状態 */ Release, /** @brief ボタンを離し続けている状態 */ Free, /** @brief ボタンを押し続けている状態 */ Hold }; }; namespace asd{ /** @brief マウスの左右ボタンの状態を扱うクラス */ class SideButton { private: MouseButtonState m_mouseButtonState; public: /** @brief ボタンの押し状態を返す @return ボタンの押し状態 */ virtual MouseButtonState GetButtonState() const; SideButton(){} SideButton(MouseButtonState mouseButtonState,bool doubleClicked); }; }; namespace asd{ /** @brief マウスの中ボタンの状態を扱うクラス */ class MiddleButton { private: MouseButtonState m_mouseButtonState; double m_rotation; public: /** @brief ボタンの押し状態を返す */ virtual MouseButtonState GetButtonState() const; /** @brief ホイールの回転度合いを返す */ virtual float GetRotation() const; MiddleButton(MouseButtonState mouseButtonState, float rotation); MiddleButton(){} }; }; #include <memory> namespace asd{ /** @brief マウスのボタン一覧を示す列挙型 */ enum class MouseButtons : int32_t { /** @brief 左ボタン */ ButtonLeft = 0, /** @brief 右ボタン */ ButtonRight = 1, /** @brief 中央ボタン */ ButtonMiddle = 2, /** @brief サブボタン1 */ SubButton1 = 3, /** @brief サブボタン2 */ SubButton2 = 4, /** @brief サブボタン3 */ SubButton3 = 5, /** @brief サブボタン4 */ SubButton4 = 6, /** @brief サブボタン5 */ SubButton5 = 7, }; /** @brief マウスからの入力を取得するクラス */ class Mouse { public: /** @brief マウスの左ボタンの入力状態を取得 */ virtual SideButton* GetLeftButton() const = 0; /** @brief マウスの右ボタンの入力状態を取得 */ virtual SideButton* GetRightButton() const = 0; /** @brief マウスの中央ボタンの入力状態を取得 */ virtual MiddleButton* GetMiddleButton() const = 0; /** @brief マウスポインタの位置を取得 */ virtual Vector2DF GetPosition() const = 0; /** @brief 指定したボタンの入力状態を取得 */ virtual MouseButtonState GetButtonInputState(MouseButtons mouseButton) const = 0; /** @brief ホイールの回転度合いを取得 */ virtual float GetWheel() const = 0; }; }; namespace asd{ /** @brief ACEで扱うキーボードのキー一覧 */ enum class Keys : int32_t { Unknown, Space, ///< スペース Apostrophe, ///< : (US配列では ` ) Comma, ///< , Minus, ///< - Period, ///< . Slash, ///< / Num0, ///< 0 Num1, ///< 1 Num2, ///< 2 Num3, ///< 3 Num4, ///< 4 Num5, ///< 5 Num6, ///< 6 Num7, ///< 7 Num8, ///< 8 Num9, ///< 9 Semicolon, ///< ; Equal, ///< ^ (US配列では = ) A, ///< A B, ///< B C, ///< C D, ///< D E , ///< E F, ///< F G, ///< G H, ///< H I, ///< I J, ///< J K, ///< K L, ///< L M, ///< M N, ///< N O, ///< O P, ///< P Q, ///< Q R, ///< R S, ///< S T, ///< T U, ///< U V, ///< V W, ///< W X, ///< X Y, ///< Y Z, ///< Z LeftBracket, ///< @ (US配列では [ ) Backslash, ///< ] (US配列では \ ) RightBracket, ///< [ (US配列では ] ) GraveAccent, ///< 半角/全角 World1, World2, Escape, ///< Esc Enter, ///< Enter Tab, ///< Tab Backspace, ///< BackSpace Insert, ///< Insert Delete, ///< Delete Right, ///< → Left, ///< ← Down, ///< ↓ Up, ///< ↑ PageUp, ///< PageUp PageDown, ///< PageDown Home, ///< Home End, ///< End CapsLock, ///< CapsLock ScrollLock, ///< ScrollLock NumLock, ///< NumLock PrintScreen, ///< PrintScreen Pause, ///< Pause F1, ///< F1 F2, ///< F2 F3, ///< F3 F4, ///< F4 F5, ///< F5 F6, ///< F6 F7, ///< F7 F8, ///< F8 F9, ///< F9 F10, ///< F10 F11, ///< F11 F12, ///< F12 F13, ///< F13 F14, ///< F14 F15, ///< F15 F16, ///< F16 F17, ///< F17 F18, ///< F18 F19, ///< F19 F20, ///< F20 F21, ///< F21 F22, ///< F22 F23, ///< F23 F24, ///< F24 F25, ///< F25 Keypad0, ///< テンキーの0 Keypad1, ///< テンキーの1 Keypad2, ///< テンキーの2 Keypad3, ///< テンキーの3 Keypad4, ///< テンキーの4 Keypad5, ///< テンキーの5 Keypad6, ///< テンキーの6 Keypad7, ///< テンキーの7 Keypad8, ///< テンキーの8 Keypad9, ///< テンキーの9 KeypadDecimal, ///< テンキーの. KeypadDivide, ///< テンキーの/ KeypadMultiply, ///< テンキーの* KeypadSubstract,///< テンキーの- KeypadAdd, ///< テンキーの+ KeypadEnter, ///< テンキーのEnter KeypadEqual, ///< テンキーの= LeftShift, ///< 左Shift LeftControl, ///< 左Ctrl LeftAlt, ///< 左Alt LeftWin, ///< 左Win RightShift, ///< 右Shift RightControl, ///< 右Ctrl RightAlt, ///< 右Alt RightWin, ///< 右Win Menu, ///< コンテキストメニュー Last, MAX }; /** @brief キーボードの押下状態を示す列挙型 */ enum class KeyState : int32_t { /** @brief キーをこのフレームで押した状態 */ Push, /** @brief キーをこのフレームで離した状態 */ Release, /** @brief キーを押し続けている状態 */ Hold, /** @brief キーを離し続けている状態 */ Free }; /** @brief キーボードからの入力を取得するクラス */ class Keyboard { public: /** @brief 特定のキーの押し状態をKeyState列挙型で返す @param 押し状態を調べたいキー @return 押し状態 */ virtual KeyState GetKeyState(Keys key) const = 0; }; }; namespace asd{ /** @brief ジョイスティックのボタンの押し状態を示す列挙型 */ enum class JoystickButtonState : int32_t { /** @brief ボタンをこのフレームで押した状態 */ Push, /** @brief ボタンをこのフレームで離した状態 */ Release, /** @brief ボタンを離し続けている状態 */ Free, /** @brief ボタンを押し続けている状態 */ Hold }; /** @brief 指定したコンポーネントをこのインスタンスに追加する。 */ class Joystick { public: Joystick(){} virtual ~Joystick(){} /** @brief ジョイスティックの名前を返す */ virtual const asd::achar* GetJoystickName() = 0; /** @brief ジョイスティックのボタンの合計数を返す */ virtual int GetButtonsCount() = 0; /** @brief ジョイスティックの軸の合計数を返す */ virtual int GetAxesCount() = 0; /** @brief 指定したボタンの押し状態を返す @param at 何番目のボタンの押し状態を取得するか @return 押し状態 */ virtual JoystickButtonState GetButtonState(int at) = 0; /** @brief 指定した軸の倒し具合を返す @param at 何番目の軸配列の倒し具合を取得するか @return 倒し具合 */ virtual float GetAxisState(int at) = 0; }; }; namespace asd{ class JoystickContainer { public: JoystickContainer(){} virtual ~JoystickContainer(){} /** @brief 引数に指定した番号のジョイスティックが接続されているかを取得する。 @param at 何番目のジョイスティックの接続を確認するか @return 接続されているか否か */ virtual bool GetIsPresentAt(int at) = 0; /** @brief 引数に指定した番号のジョイスティッククラスを取得する。 @param at 何番目のジョイスティッククラスを取得するか @return 該当するジョイスティッククラス */ virtual Joystick* GetJoystickAt(int at) = 0; /** @brief 全てのジョイスティックの接続状態を更新する。 */ virtual void RefreshAllJoysticks() = 0; }; }; #include <string> #include <memory> namespace asd { enum class LogLevel : int32_t { Error = 1 << 1, Critical = 1 << 2, Warning = 1 << 3, Information = 1 << 4, All = 2147483647 // INT_MAXと等しい }; class Log { public: virtual ~Log() { } /** @brief ログ ファイルへ文字列を書き込む。 @param text [in] 書き込む文字列 @param level [in] ログの出力レベル */ virtual void Write(const achar* text, LogLevel level = LogLevel::All) = 0; /** @brief ログ ファイルへ文字列を書き込み、改行する。 @param text [in] 書き込む文字列 @param level [in] ログの出力レベル */ virtual void WriteLine(const achar* text, LogLevel level = LogLevel::All) = 0; /** @brief ログ ファイルへ強調された文字列を書き込む。 @param text [in] 書き込む文字列 @param level [in] ログの出力レベル */ virtual void WriteStrongly(const achar* text, LogLevel level = LogLevel::All) = 0; /** @brief ログ ファイルへ強調された文字列を書き込み、改行する。 @param text [in] 書き込む文字列 @param level [in] ログの出力レベル */ virtual void WriteLineStrongly(const achar* text, LogLevel level = LogLevel::All) = 0; /** @brief ログ ファイルへ見出しとして文字列を書き込む。 @param text [in] 書き込む文字列 @param level [in] ログの出力レベル */ virtual void WriteHeading(const achar* text, LogLevel level = LogLevel::All) = 0; #if !_WIN32 && !SWIG /** @brief ログ ファイルへ文字列を書き込む。 @param text [in] 書き込む文字列 @param level [in] ログの出力レベル */ virtual void Write(const wchar_t* text, LogLevel level = LogLevel::All) = 0; /** @brief ログ ファイルへ文字列を書き込み、改行する。 @param text [in] 書き込む文字列 @param level [in] ログの出力レベル */ virtual void WriteLine(const wchar_t* text, LogLevel level = LogLevel::All) = 0; /** @brief ログ ファイルへ強調された文字列を書き込む。 @param text [in] 書き込む文字列 @param level [in] ログの出力レベル */ virtual void WriteStrongly(const wchar_t* text, LogLevel level = LogLevel::All) = 0; /** @brief ログ ファイルへ強調された文字列を書き込み、改行する。 @param text [in] 書き込む文字列 @param level [in] ログの出力レベル */ virtual void WriteLineStrongly(const wchar_t* text, LogLevel level = LogLevel::All) = 0; /** @brief ログ ファイルへ見出しとして文字列を書き込む。 @param text [in] 書き込む文字列 @param level [in] ログの出力レベル */ virtual void WriteHeading(const wchar_t* text, LogLevel level = LogLevel::All) = 0; #endif #ifndef SWIG public: /** @brief ログ ファイルへ文字列を書き込む。 @param text [in] 書き込む文字列 @param level [in] ログの出力レベル */ virtual void Write(const char* text, LogLevel level = LogLevel::All) = 0; /** @brief ログ ファイルへ文字列を書き込み、改行する。 @param text [in] 書き込む文字列 @param level [in] ログの出力レベル */ virtual void WriteLine(const char* text, LogLevel level = LogLevel::All) = 0; /** @brief ログ ファイルへ強調された文字列を書き込む。 @param text [in] 書き込む文字列 @param level [in] ログの出力レベル */ virtual void WriteStrongly(const char* text, LogLevel level = LogLevel::All) = 0; /** @brief ログ ファイルへ強調された文字列を書き込み、改行する。 @param text [in] 書き込む文字列 @param level [in] ログの出力レベル */ virtual void WriteLineStrongly(const char* text, LogLevel level = LogLevel::All) = 0; /** @brief ログ ファイルへ見出しとして文字列を書き込む。 @param text [in] 書き込む文字列 @param level [in] ログの出力レベル */ virtual void WriteHeading(const char* text, LogLevel level = LogLevel::All) = 0; #endif /** @brief ログ ファイルへ水平線を書き込む。 @param level [in] ログの出力レベル */ virtual void WriteHorizontalRule(LogLevel level = LogLevel::All) = 0; /** @brief ログ ファイルへ表形式(<table> 要素)での書き込みを開始する。 @param level [in] ログの出力レベル */ virtual void BeginTable(LogLevel level = LogLevel::All) = 0; /** @brief ログ ファイルへの表形式(<table> 要素)での書き込みを終了する。 @param level [in] ログの出力レベル */ virtual void EndTable(LogLevel level = LogLevel::All) = 0; /** @brief 表形式での出力において、新しい行に移動する。 @param level [in] ログの出力レベル */ virtual void ChangeRow(LogLevel level = LogLevel::All) = 0; /** @brief 表形式での出力において、新しい列に移動する。 @param level [in] ログの出力レベル */ virtual void ChangeColumn(LogLevel level = LogLevel::All) = 0; /** @brief ログの出力が可能であるかどうかを表す真偽値を取得する。 @param level [in] ログの出力が可能か? */ virtual bool GetIsValid() = 0; /** @brief ログの出力レベルを設定する。ログ出力メソッドに指定した出力レベルがこの値より小さければログが出力される。 @param level [in] ログの出力レベル */ virtual void SetOutputLevel(LogLevel level) = 0; }; } #include <list> namespace asd { /** @brief プログラムの実行状況(計算時間や、使っているプロセッサ)を記録するクラス。 */ class Profiler : public ReferenceObject { protected: Profiler(){} virtual ~Profiler(){} public: /** @brief 計算の開始時間と、使用するプロセッサ番号を記録する。 @param id プロファイリングを識別するID。Start関数は、IDの一致するEnd関数と対応する。 */ virtual void Start(int id) = 0; /** @brief 計算の終了時間を記録し、プロファイリング結果を蓄積する。 @param id プロファイリングを識別するID。End関数は、IDの一致するStart関数と対応する。 */ virtual void End(int id) = 0; }; } #include <iterator> #include <vector> #include <memory> namespace asd { /** @brief ファイルの操作に関する処理を提供するクラス */ class File : public IReference { friend class Accessor; protected: virtual StaticFile* CreateStaticFile_(const achar* path) = 0; virtual StreamFile* CreateStreamFile_(const achar* path) = 0; public: virtual ~File() { } /** @brief ファイル操作する時のルートのディレクトリを追加する。 @param path ルートのディレクトリのパス */ virtual void AddRootDirectory(const achar* path) = 0; /** @brief ファイル操作する時のルートのパスワード付パッケージを追加する。 @param path パッケージのパス @param password パスワード */ virtual void AddRootPackageWithPassword(const achar* path, const achar* password) = 0; /** @brief ファイル操作する時のルートのパッケージを追加する。 @param path パッケージのパス */ virtual void AddRootPackage(const achar* path) = 0; /** @brief 追加されたパッケージを全て消去する。 */ virtual void ClearRootDirectories() = 0; /** @brief ファイルが存在するか取得する。 @param path ファイルのパス @return ファイルが存在するか? */ virtual bool Exists(const achar* path) const = 0; #ifndef SWIG std::shared_ptr<StaticFile> CreateStaticFile(const achar* path) { return CreateSharedPtrWithReleaseDLL(CreateStaticFile_(path)); } std::shared_ptr<StreamFile> CreateStreamFile(const achar* path) { return CreateSharedPtrWithReleaseDLL(CreateStreamFile_(path)); } #endif }; } namespace asd { /** @brief 一括してファイルを読み込むクラス */ class StaticFile : public IReference { private: public: virtual ~StaticFile() { }; /** @brief 読み込まれたバッファを取得する。 @return バッファ */ virtual const std::vector<uint8_t>& GetBuffer() const = 0; /** @brief ファイルのパスを取得する。 @return パス @note パッケージ外から読み込まれた場合は絶対パス、もしくは実行ファイルからの相対パスを返す。 パッケージ内から読み込まれた場合は「パッケージへのパス?パッケージ内のファイルへのパス」を返す。 */ virtual const achar* GetFullPath() const = 0; /** @brief 読み込まれたバッファの先頭のポインタを取得する。 @return ポインタ */ virtual void* GetData() = 0; /** @brief 読み込まれたバッファのサイズを取得する。 @return サイズ */ virtual int32_t GetSize() = 0; /** @brief パッケージ内からファイルが読み込まれているかを取得する。 @return パッケージ内からファイルが読み込まれているか? */ virtual bool GetIsInPackage() const = 0; }; } namespace asd { /** @brief 部分的にファイルを読み込むクラス */ class StreamFile : public IReference { friend class Accessor; protected: virtual int32_t Read_(int32_t size) = 0; virtual void* GetTempBuffer_() = 0; virtual int32_t GetTempBufferSize_() = 0; public: StreamFile() {} virtual ~StreamFile() { }; /** @brief ファイルのサイズを取得する。 @return サイズ */ virtual int32_t GetSize() const = 0; /** @brief ファイル内で現在読み込んでいる位置を取得する。 @return 現在読み込んでいる位置 */ virtual int32_t GetCurrentPosition() const = 0; #if !SWIG /** @brief 指定したサイズ分、ファイルを読み込む。 @param buffer 出力先 @param size 読み込まれるサイズ */ void Read(std::vector<uint8_t>& buffer, int32_t size) { auto result = Read_(size); buffer.resize(result); memcpy(buffer.data(), GetTempBuffer_(), result); } #endif }; } namespace asd { /** @brief 音源のクラス */ class SoundSource : public IReference { protected: SoundSource() {} ~SoundSource() {} public: /** @brief ループポイントの開始地点(秒)を取得する。 @return 開始地点(秒) */ virtual float GetLoopStartingPoint() const = 0; /** @brief ループポイントの開始地点(秒)を設定する。 @param startingPoint 開始地点(秒) */ virtual void SetLoopStartingPoint(float startingPoint) = 0; /** @brief ループポイントの終了地点(秒)を取得する。 @return 終了地点(秒) */ virtual float GetLoopEndPoint() const = 0; /** @brief ループポイントの終了地点(秒)を設定する。 @param startingPoint 終了地点(秒) */ virtual void SetLoopEndPoint(float endPoint) = 0; /** @brief ループするかを取得する。 @return ループするか? */ virtual bool GetIsLoopingMode() const = 0; /** @brief ループするかを設定する。 @return isLoopingMode ループするか? */ virtual void SetIsLoopingMode(bool isLoopingMode) = 0; /** @brief 音の長さを取得する。 @return 長さ(秒) */ virtual float GetLength() = 0; }; } namespace asd { /** @brief 音を管理するクラス */ class Sound : public IReference { friend class Accessor; protected: Sound() {} ~Sound() {} virtual SoundSource* CreateSoundSource_(const achar* path, bool isDecompressed) = 0; public: #if !SWIG /** @brief 音を読み込む。 @param path パス @param isDecompressed 解凍するか? @return 音源 */ std::shared_ptr<SoundSource> CreateSoundSource(const achar* path, bool isDecompressed) { return CreateSharedPtrWithReleaseDLL(CreateSoundSource_(path, isDecompressed)); } #endif /** @brief 音を再生する。 @param soundSource 音源 @return ID */ virtual int32_t Play(SoundSource* soundSource) = 0; #if !SWIG /** @brief 音を再生する。 @param soundSource 音源 @return ID */ int32_t Play(std::shared_ptr<SoundSource> soundSource) { return Play(soundSource.get()); } #endif /** @brief 音が再生中か、取得する。 @param id ID @return 再生中か? */ virtual bool GetIsPlaying(int32_t id) = 0; /** @brief 全ての再生中の音を停止する。 */ virtual void StopAll() = 0; /** @brief 指定した音を停止する。 @param id ID */ virtual void Stop(int32_t id) = 0; /** @brief 指定した音を一時停止する。 @param id ID */ virtual void Pause(int32_t id) = 0; /** @brief 指定した一時停止中の音の一時停止を解除する。 @param id ID */ virtual void Resume(int32_t id) = 0; /** @brief 指定した音の音量を設定する。 @param id ID @param volume 音量(0.0~1.0) */ virtual void SetVolume(int32_t id, float volume) = 0; /** @brief 指定した音をフェードインさせる。 @param id ID @param second フェードインに使用する時間(秒) */ virtual void FadeIn(int32_t id, float second) = 0; /** @brief 指定した音をフェードアウトさせる。 @param id ID @param second フェードアウトに使用する時間(秒) */ virtual void FadeOut(int32_t id, float second) = 0; /** @brief 任意の音量に音量を一定時間かけて変更する。 @param id 音のID @param second 変更にかかる時間(秒) @param targetedVolume 変更先の音量(0.0~1.0) @note この指定される音量はSetVolumeに指定される音量とは異なり、FadeIn、FadeOutに使用される音量と共通である。 つまり、このメソッドはFadeIn、FadeOutの任意音量指定版と言える。 */ virtual void Fade(int32_t id, float second, float targetedVolume) = 0; /** @brief 再生速度変更するかを取得する。 @param id 音のID @return 再生速度変更するか? */ virtual bool GetIsPlaybackSpeedEnabled(int32_t id) = 0; /** @brief 再生速度変更するかを設定する。 @param id 音のID @param isPlaybackSpeedEnabled 再生速度変更するか? */ virtual void SetIsPlaybackSpeedEnabled(int32_t id, bool isPlaybackSpeedEnabled) = 0; /** @brief 再生速度を取得する。 @param id 音のID @return 再生速度(比率) @note 設定値は再生速度に比例する。1.0で等速。範囲は0.25から4.0。 音程は再生速度に比例して変化する。 */ virtual float GetPlaybackSpeed(int32_t id) = 0; /** @brief 再生速度を設定する。 @param id 音のID @param playbackSpeed 再生速度(比率) @note 設定値は再生速度に比例する。1.0で等速。範囲は0.25から4.0。 音程は再生速度に比例して変化する。 */ virtual void SetPlaybackSpeed(int32_t id, float playbackSpeed) = 0; /** @brief パン位置を取得する。 @param id 音のID @return パン位置, 0.0で中央, -1.0で左, 1.0で右。 */ virtual float GetPanningPosition(int32_t id) = 0; /** @brief パン位置を設定する。 @param id 音のID @param panningPosition パン位置, 0.0で中央, -1.0で左, 1.0で右。 */ virtual void SetPanningPosition(int32_t id, float panningPosition) = 0; }; } namespace asd { class Texture : public IReference { protected: Texture() {} virtual ~Texture() {} public: /** @brief テクスチャのクラスの種類を取得する。 @return 種類 */ virtual TextureClassType GetType() = 0; }; } //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- namespace asd { //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- class Texture2D_Imp_DX11; class Texture2D_Imp_GL; class TextureLockInfomation { friend class Texture2D; friend class Texture2D_Imp_DX11; friend class Texture2D_Imp_GL; private: void* pixels = nullptr; int32_t pitch = 0; Vector2DI size; public: void* GetPixels() const { return pixels; } int32_t GetPitch() const { return pitch; } Vector2DI GetSize() const { return size; } }; class Texture2D : public Texture { protected: TextureClassType m_type; public: Texture2D(){} virtual ~Texture2D(){} /** @brief テクスチャのサイズを取得する。 @return サイズ */ virtual Vector2DI GetSize() const = 0; /** @brief テクスチャのフォーマットを取得する。 @return フォーマット */ virtual TextureFormat GetFormat() const = 0; /** @brief テクスチャをファイルに保存する。 @param path 出力先 @return 成否 */ virtual bool Save(const achar* path) = 0; /** @brief テクスチャをロックし編集可能にする。 @param info テクスチャ情報 @return 成否 */ virtual bool Lock(TextureLockInfomation* info) = 0; /** @brief テクスチャをアンロックする。 */ virtual void Unlock() = 0; /** @brief テクスチャのクラスの種類を取得する。 @return 種類 */ virtual TextureClassType GetType() { return TextureClassType::Texture2D; } }; //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- } //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- namespace asd { //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- class RenderTexture2D : public Texture2D { public: RenderTexture2D(){} virtual ~RenderTexture2D(){} /** @brief テクスチャのサイズを取得する。 @return サイズ */ virtual Vector2DI GetSize() const = 0; /** @brief テクスチャのクラスの種類を取得する。 @return 種類 */ virtual TextureClassType GetType() { return TextureClassType::RenderTexture2D; } }; //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- } namespace asd { /** @brief キューブマップ */ class CubemapTexture : public Texture { protected: CubemapTexture() {} virtual ~CubemapTexture() {} public: /** @brief ミップマップ数を取得する。 @return ミップマップ数 */ virtual int32_t GetMipmapCount() const = 0; /** @brief テクスチャのクラスの種類を取得する。 @return 種類 */ virtual TextureClassType GetType() override { return TextureClassType::CubemapTexture; } }; } //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- namespace asd { //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- /** @brief シェーダー(2D) */ class Shader2D : public IReference { protected: Shader2D(){} virtual ~Shader2D(){} public: }; //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- } //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- namespace asd { //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- /** @brief シェーダー(3D) */ class Shader3D : public IReference { protected: Shader3D(){} virtual ~Shader3D(){} public: }; //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- } //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- namespace asd { //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- class Material2D : public IReference { friend class Accessor; protected: virtual Texture2D* GetTexture2D_(const achar* name) = 0; virtual Shader2D* GetShader2D_() = 0; Material2D(){} virtual ~Material2D(){} public: virtual float GetFloat(const achar* name) = 0; virtual void SetFloat(const achar* name, float value) = 0; virtual Vector2DF GetVector2DF(const achar* name) = 0; virtual void SetVector2DF(const achar* name, Vector2DF value) = 0; virtual Vector3DF GetVector3DF(const achar* name) = 0; virtual void SetVector3DF(const achar* name, Vector3DF value) = 0; virtual Vector4DF GetVector4DF(const achar* name) = 0; virtual void SetVector4DF(const achar* name, Vector4DF value) = 0; virtual void SetTexture2D(const achar* name, Texture2D* value) = 0; virtual void SetShader2D(Shader2D* shader) = 0; virtual TextureFilterType GetTextureFilterType(const achar* name) = 0; virtual void SetTextureFilterType(const achar* name, TextureFilterType filter) = 0; virtual TextureWrapType GetTextureWrapType(const achar* name) = 0; virtual void SetTextureWrapType(const achar* name, TextureWrapType wrap) = 0; #if! SWIG std::shared_ptr<Texture2D> GetTexture2D(const achar* name) { auto v = GetTexture2D_(name); SafeAddRef(v); return CreateSharedPtrWithReleaseDLL(v); } void SetTexture2D(const achar* name, std::shared_ptr<Texture2D> value) { SetTexture2D(name, value.get()); } void SetTexture2D(const achar* name, std::shared_ptr<RenderTexture2D> value) { SetTexture2D(name, value.get()); } std::shared_ptr<Shader2D> GetShader2D() { auto v = GetShader2D_(); SafeAddRef(v); return CreateSharedPtrWithReleaseDLL(v); } void SetShader2D(std::shared_ptr<Shader2D> shader) { SetShader2D(shader.get()); } #endif }; //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- } //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- namespace asd { //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- class Material3D : public IReference { friend class Accessor; protected: virtual Texture2D* GetTexture2D_(const achar* name) = 0; virtual Shader3D* GetShader3D_() = 0; Material3D(){} virtual ~Material3D(){} public: virtual float GetFloat(const achar* name) = 0; virtual void SetFloat(const achar* name, float value) = 0; virtual Vector2DF GetVector2DF(const achar* name) = 0; virtual void SetVector2DF(const achar* name, Vector2DF value) = 0; virtual Vector3DF GetVector3DF(const achar* name) = 0; virtual void SetVector3DF(const achar* name, Vector3DF value) = 0; virtual Vector4DF GetVector4DF(const achar* name) = 0; virtual void SetVector4DF(const achar* name, Vector4DF value) = 0; virtual void SetTexture2D(const achar* name, Texture2D* value) = 0; virtual void SetShader3D(Shader3D* shader) = 0; virtual TextureFilterType GetTextureFilterType(const achar* name) = 0; virtual void SetTextureFilterType(const achar* name, TextureFilterType filter) = 0; virtual TextureWrapType GetTextureWrapType(const achar* name) = 0; virtual void SetTextureWrapType(const achar* name, TextureWrapType wrap) = 0; #if! SWIG std::shared_ptr<Texture2D> GetTexture2D(const achar* name) { auto v = GetTexture2D_(name); SafeAddRef(v); return CreateSharedPtrWithReleaseDLL(v); } void SetTexture2D(const achar* name, std::shared_ptr<Texture2D> value) { SetTexture2D(name, value.get()); } void SetTexture2D(const achar* name, std::shared_ptr<RenderTexture2D> value) { SetTexture2D(name, value.get()); } std::shared_ptr<Shader3D> GetShader3D() { auto v = GetShader3D_(); SafeAddRef(v); return CreateSharedPtrWithReleaseDLL(v); } void SetShader3D(std::shared_ptr<Shader3D> shader) { SetShader3D(shader.get()); } #endif }; //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- } namespace asd { /** @brief マテリアルへのパラメーターの集合 */ class MaterialPropertyBlock : public IReference { friend class Accessor; protected: MaterialPropertyBlock() {} virtual ~MaterialPropertyBlock() {} /** @brief テクスチャを取得する。 @name 名称 */ virtual Texture2D* GetTexture2D_(const achar* name) = 0; public: virtual float GetFloat(const achar* name) = 0; virtual void SetFloat(const achar* name, float value) = 0; virtual Vector2DF GetVector2DF(const achar* name) = 0; virtual void SetVector2DF(const achar* name, Vector2DF value) = 0; virtual Vector3DF GetVector3DF(const achar* name) = 0; virtual void SetVector3DF(const achar* name, Vector3DF value) = 0; virtual Vector4DF GetVector4DF(const achar* name) = 0; virtual void SetVector4DF(const achar* name, Vector4DF value) = 0; virtual TextureFilterType GetTextureFilterType(const achar* name) = 0; virtual void SetTextureFilterType(const achar* name, TextureFilterType filter) = 0; virtual TextureWrapType GetTextureWrapType(const achar* name) = 0; virtual void SetTextureWrapType(const achar* name, TextureWrapType wrap) = 0; virtual void SetTexture2D(const achar* name, Texture2D* value) = 0; #if! SWIG std::shared_ptr<Texture2D> GetTexture2D(const achar* name) { auto v = GetTexture2D_(name); SafeAddRef(v); return CreateSharedPtrWithReleaseDLL(v); } void SetTexture2D(const achar* name, std::shared_ptr<Texture2D> value) { SetTexture2D(name, value.get()); } void SetTexture2D(const achar* name, std::shared_ptr<RenderTexture2D> value) { SetTexture2D(name, value.get()); } #endif }; } namespace asd { /** @brief フォントの情報が記録されているクラス */ class Font :public IReference { private: protected: Font(){} virtual ~Font(){} public: /** @brief 描画テキストと描画方向を与えると、その文字の描画領域を返す。 @param text 描画テキスト @param writingDirection 描画方向 @return 文字の描画領域 */ virtual Vector2DI CalcTextureSize(const achar* text, WritingDirection writingDirection) = 0; }; } namespace asd { /** @brief 複数の画像が格納されているクラス */ class ImagePackage : public IReference { friend class Accessor; private: protected: ImagePackage() {} virtual ~ImagePackage(){} virtual Texture2D* GetImage_(int32_t index) = 0; public: /** @brief 格納されている画像の枚数を取得する。 @return 画像の枚数 */ virtual int32_t GetImageCount() = 0; /** @brief 格納されている画像の名称を取得する。 @param index インデックス @return 名称 */ virtual const achar* GetImageName(int32_t index) = 0; /** @brief 格納されている画像が配置される領域を取得する。 @param index インデックス @return 領域 */ virtual RectI GetImageArea(int32_t index) = 0; #if !SWIG /** @brief 画像を取得する。 @param index インデックス @return 画像 */ std::shared_ptr<Texture2D> GetImage(int32_t index) { auto image = GetImage_(index); SafeAddRef(image); return CreateSharedPtrWithReleaseDLL(image); } #endif }; } namespace asd { /** @brief エフェクトの情報が記録されているクラス */ class Effect : public IReference { private: protected: Effect(){} virtual ~Effect(){} public: }; } namespace asd { /** @brief メッシュを変形させるためのクラス */ class Deformer : public IReference { protected: Deformer() {} virtual ~Deformer() {} public: /** @brief ボーンを追加する。 @param name ボーンの名称 @param parentBoneIndex 親ボーンのインデックス(親がない場合は-1) @param rotationOrder ボーンの回転行列の計算方法 @param localMat ボーンのローカル変形行列 */ virtual void AddBone(const achar* name, int32_t parentBoneIndex, RotationOrder rotationOrder, const Matrix44& localMat, const Vector3DF& translation, const Vector4DF& rotation, const Vector3DF& scaling) = 0; }; } namespace asd { /** @brief 3Dメッシュのクラス */ class Mesh : public IReference { protected: Mesh(){} virtual ~Mesh(){} public: /** @brief 頂点を追加する。 @param position 座標 @param normal 法線 @param binormal 従法線 @param uv1 UV1 @param uv2 UV2 @param color 頂点色 @param boneWeights ボーンのウエイト @param boneIndexes ボーンのインデックス */ virtual void AddVertex( const Vector3DF& position, const Vector3DF& normal, const Vector3DF& binormal, const Vector2DF& uv1, const Vector2DF& uv2, const Color& color, int32_t boneWeights, int32_t boneIndexes) = 0; /** @brief 面を追加する。 @param index1 頂点インデックス1 @param index2 頂点インデックス2 @param index3 頂点インデックス3 @param materialIndex 材質インデックス */ virtual void AddFace(int32_t index1, int32_t index2, int32_t index3, int32_t materialIndex) = 0; /** @brief ボーンとの接続設定を追加する。 @param targetIndex 対象ボーンインデックス @param boneToMesh ボーンの行列をメッシュの行列に変換する行列 */ virtual void AddBoneConnector(int32_t targetIndex, const Matrix44& boneToMesh) = 0; /** @brief 材質を追加する。 @return 材質のインデックス */ virtual int32_t AddMaterial() = 0; /** @brief 設定した値をGPUに送信する。 */ virtual void SendToGPUMemory() = 0; /** @brief 内部シェーダーを使用する場合のカラーテクスチャを設定する。 @param materialIndex 材質のインデックス @param テクスチャ @note AddMaterialCountを実行した後でないと無効になる。 */ virtual void SetColorTexture(int32_t materialIndex, Texture2D* texture) = 0; /** @brief 内部シェーダーを使用する場合の法線テクスチャを設定する。 @param materialIndex 材質のインデックス @param テクスチャ @note AddMaterialCountを実行した後でないと無効になる。 */ virtual void SetNormalTexture(int32_t materialIndex, Texture2D* texture) = 0; /** @brief 内部シェーダーを使用する場合の金属度テクスチャを設定する。 @param materialIndex 材質のインデックス @param テクスチャ @note AddMaterialCountを実行した後でないと無効になる。 */ virtual void SetMetalnessTexture(int32_t materialIndex, Texture2D* texture) = 0; /** @brief 内部シェーダーを使用する場合の面平滑度テクスチャを設定する。 @param materialIndex 材質のインデックス @param テクスチャ @note AddMaterialCountを実行した後でないと無効になる。 */ virtual void SetSmoothnessTexture(int32_t materialIndex, Texture2D* texture) = 0; /** @brief 材質を設定する。 @param materialIndex 材質のインデックス @param material 材質 @note AddMaterialCountを実行した後でないと無効になる。 */ virtual void SetMaterial(int32_t materialIndex, Material3D* material) = 0; #if !SWIG /** @brief 内部シェーダーを使用する場合のカラーテクスチャを設定する。 @param materialIndex 材質のインデックス @param テクスチャ @note AddMaterialCountを実行した後でないと無効になる。 */ void SetColorTexture(int32_t materialIndex, std::shared_ptr<Texture2D> texture) { SetColorTexture(materialIndex, texture.get()); } /** @brief 内部シェーダーを使用する場合の法線テクスチャを設定する。 @param materialIndex 材質のインデックス @param テクスチャ @note AddMaterialCountを実行した後でないと無効になる。 */ void SetNormalTexture(int32_t materialIndex, std::shared_ptr<Texture2D> texture) { SetNormalTexture(materialIndex, texture.get()); } /** @brief 内部シェーダーを使用する場合の金属度テクスチャを設定する。 @param materialIndex 材質のインデックス @param テクスチャ @note AddMaterialCountを実行した後でないと無効になる。 */ void SetMetalnessTexture(int32_t materialIndex, std::shared_ptr<Texture2D> texture) { SetMetalnessTexture(materialIndex, texture.get()); } /** @brief 内部シェーダーを使用する場合の面平滑度テクスチャを設定する。 @param materialIndex 材質のインデックス @param テクスチャ @note AddMaterialCountを実行した後でないと無効になる。 */ void SetSmoothnessTexture(int32_t materialIndex, std::shared_ptr<Texture2D> texture) { SetSmoothnessTexture(materialIndex, texture.get()); } /** @brief 材質を設定する。 @param materialIndex 材質のインデックス @param material 材質 @note AddMaterialCountを実行した後でないと無効になる。 */ void SetMaterial(int32_t materialIndex, std::shared_ptr<Material3D> material) { SetMaterial(materialIndex, material.get()); } #endif }; }; namespace asd { /** @brief 3Dモデルクラス */ class Model : public IReference { friend class Accessor; protected: Model(){} virtual ~Model(){} virtual Mesh* GetMesh_(int32_t index) = 0; virtual AnimationClip* GetAnimationClip_(int32_t index) = 0; public: /** @brief モデルが持つアニメーションクリップの名称を取得する。 @param index アニメーションクリップのインデックス @return アニメーションクリップの名称 */ virtual const achar* GetAnimationClipName(int32_t index) = 0; #if! SWIG /** @brief モデルが持つアニメーションクリップを取得する。 @param index アニメーションクリップのインデックス @return アニメーションクリップ */ std::shared_ptr<AnimationClip> GetAnimationClip(int32_t index) { auto v = GetAnimationClip_(index); SafeAddRef(v); return CreateSharedPtrWithReleaseDLL(v); } /** @brief メッシュを取得する。 @param index メッシュのインデックス @return メッシュ */ std::shared_ptr<Mesh> GetMesh(int32_t index) { auto v = GetMesh_(index); SafeAddRef(v); return CreateSharedPtrWithReleaseDLL(v); } #endif /** @brief モデルが持つメッシュの個数を取得する。 @return メッシュの個数 */ virtual int32_t GetMeshCount() const = 0; /** @brief モデルが持つアニメーションクリップの個数を取得する。 @return アニメーションクリップの個数 */ virtual int32_t GetAnimationClipCount() const = 0; }; } namespace asd { /** @brief 大量描画が可能な3Dモデルクラス */ class MassModel : public IReference { private: protected: MassModel(){} virtual ~MassModel(){} public: /** @brief モデルが持つアニメーションの個数を取得する。 @return アニメーションの個数 */ virtual int32_t GetAnimationCount() const = 0; /** @brief モデルが持つアニメーションの名称を取得する。 @param index アニメーションのインデックス @return アニメーションの名称 */ virtual const achar* GetAnimationName(int32_t index) const = 0; /** @brief モデルが持つアニメーションの長さ(60フレーム単位)を取得する。 @param name アニメーション名 @return アニメーションの長さ */ virtual float GetAnimationLength(const achar* name) const = 0; /** @brief アニメーションがループするかを取得する。 @param name アニメーション名 @return ループするか? */ virtual bool GetIsAnimationLoopingMode(const achar* name) const = 0; /** @brief アニメーションがループするかを設定する。 @param name アニメーション名 @return isLoopingMode ループするか? */ virtual void SetIsAnimationLoopingMode(const achar* name, bool isLoopingMode) = 0; /** @brief 材質を設定する。 @param material 材質 */ virtual void SetMaterial(Material3D* material) = 0; #if !SWIG /** @brief 材質を設定する。 @param material 材質 */ void SetMaterial(std::shared_ptr<Material3D> material) { SetMaterial(material.get()); } #endif }; } namespace asd { /** @brief 地形のクラス */ class Terrain3D : public IReference { friend class Accessor; protected: Terrain3D(){} virtual ~Terrain3D(){} public: /** @brief マップに対する変更を適用してメッシュを生成する。 */ virtual bool Commit() = 0; /** @brief 編集可能な情報を破棄して固定化する。 */ virtual void Fix() = 0; /** @brief 衝突判定を削除する。 */ virtual void ClearCollisions() = 0; /** @brief 新規に地形を作成する。 @param gridSize グリッド1つ当たりの大きさ @param gridWidthCount 横方向のグリッド数 @param gridHeightCount 縦方向のグリッド数 */ virtual void New(float gridSize, int32_t gridWidthCount, int32_t gridHeightCount) = 0; /** @brief メモリから地形のデータを読み込む。 @param buffer バッファ @note テクスチャのパスは保存されないので、読み込んだ後にAddSurfaceする必要がある。 */ virtual void LoadFromMemory(const std::vector<uint8_t>& buffer) = 0; /** @brief メモリに地形のデータを保存する。 @return 地形のデータ */ virtual std::vector<uint8_t> SaveToMemory() = 0; /** @brief 素材を追加する。 @param name 素材名 @param size 素材のテクスチャ1枚あたりの大きさ @param color 色テクスチャのパス @param normal 法線テクスチャのパス @param metalness スペキュラテクスチャのパス */ virtual void AddSurface(const achar* name, float size, const achar* color, const achar* normal, const achar* metalness) = 0; /** @brief 素材インデックスを取得する。 @param name 素材名 @return 素材インデックス */ virtual int32_t GetSurfaceIndex(const achar* name) = 0; /** @brief 崖のテクスチャを設定する。 @param diffuseTexture 色テクスチャ @param normalTexture 法線テクスチャ @param metalnessTexture 金属度テクスチャ */ virtual void SetCliffTexture(Texture2D* diffuseTexture, Texture2D* normalTexture, Texture2D* metalnessTexture) = 0; /** @brief 素材を円形に割り当てる。 @param surfaceIndex 素材インデックス @param x 円形の中心座標 @param y 円形の中心座標 @param radius 円形の半径 @param value 割り当てる値(-255~255) @param fallout 周囲のぼかし(0~1) */ virtual void AssignSurfaceWithCircle(int32_t surfaceIndex, float x, float y, float radius, float value, float fallout) = 0; /** @brief 材質を設定する。 @param material 材質 */ virtual void SetMaterial(Material3D* material) = 0; /** @brief 円形に地形を上下させる。 @param x 円形の中心座標 @param y 円形の中心座標 @param radius 円形の半径 @param value 値 @param fallout 周囲のぼかし(0~1) */ virtual void RaiseHeightWithCircle(float x, float y, float radius, float value, float fallout) = 0; /** @brief 円形に地形を指定した高度に設定する。 @param x 円形の中心座標 @param y 円形の中心座標 @param radius 円形の半径 @param value 高度 @param fallout 周囲のぼかし(0~1) */ virtual void ChangeHeightWithCircle(float x, float y, float radius, float value, float fallout) = 0; /** @brief 円形に地形を平滑化させる。 @param x 円形の中心座標 @param y 円形の中心座標 @param radius 円形の半径 @param value 平滑度(0~1) @param fallout 周囲のぼかし(0~1) */ virtual void SmoothHeightWithCircle(float x, float y, float radius, float value, float fallout) = 0; /** @brief 円形に崖の生成を伴う地形の上下をさせる。 @param x 円形の中心座標 @param y 円形の中心座標 @param radius 円形の半径 @param value 値 */ virtual void ChangeCliffesWithCircle(float x, float y, float radius, int32_t value) = 0; /** @brief 光線を飛ばし、衝突した位置を取得する。 @param from 光線を飛ばす元の位置 @param to 光線を飛ばす先の位置 @return 光線が地形に衝突した位置。衝突しない場合、NaNを返す。 */ virtual Vector3DF CastRay(const Vector3DF& from, const Vector3DF& to) = 0; #if !SWIG /** @brief 材質を設定する。 @param material 材質 */ void SetMaterial(std::shared_ptr<Material3D> material) { SetMaterial(material.get()); } /** @brief 崖のテクスチャを設定する。 @param diffuseTexture 色テクスチャ @param normalTexture 法線テクスチャ @param metalnessTexture 金属度テクスチャ */ virtual void SetCliffTexture(std::shared_ptr<Texture2D> diffuseTexture, std::shared_ptr<Texture2D> normalTexture, std::shared_ptr<Texture2D> metalnessTexture) { SetCliffTexture(diffuseTexture.get(), normalTexture.get(), metalnessTexture.get()); } #endif }; } namespace asd { /** @brief キーフレームで指定するアニメーションのクラス */ class KeyframeAnimation : public IReference { protected: KeyframeAnimation() {} virtual ~KeyframeAnimation() {} public: /** @brief 名称を取得する。 @return 名称 */ virtual const achar* GetName() = 0; /** @brief 名称を指定する。 @param name 名称 */ virtual void SetName(const achar* name) = 0; /** @brief キーフレームを追加する。 @param kf キーフレーム */ virtual void AddKeyframe(const FCurveKeyframe& kf) = 0; /** @brief 指定した時間の値を取得する。 @param time 時間 @return 値 */ virtual float GetValue(float time) = 0; }; } namespace asd { /** @brief アニメーションの元データのクラス */ class AnimationSource : public IReference { public: AnimationSource() {} virtual ~AnimationSource() {} /** @brief ボーンごとのアニメーションを追加する。 @param keyframeAnimation アニメーション */ virtual void AddAnimation(KeyframeAnimation* keyframeAnimation) = 0; /** @brief ボーンごとのアニメーションを削除する。 @param keyframeAnimation アニメーション */ virtual void RemoveAnimation(KeyframeAnimation* keyframeAnimation) = 0; /** @brief アニメーションの長さ(60フレーム単位)を取得する。 @return アニメーションの長さ */ virtual float GetLength() const = 0; #if !SWIG /** @brief ボーンごとのアニメーションを追加する。 @param keyframeAnimation アニメーション */ void AddAnimation(std::shared_ptr<KeyframeAnimation> keyframeAnimation) { AddAnimation(keyframeAnimation.get()); } /** @brief ボーンごとのアニメーションを削除する。 @param keyframeAnimation アニメーション */ void RemoveAnimation(std::shared_ptr<KeyframeAnimation> keyframeAnimation) { RemoveAnimation(keyframeAnimation.get()); } #endif }; } namespace asd { /** @brief アニメーションソースを元に情報が付加されたアニメーションクラス */ class AnimationClip : public IReference { friend class Accessor; protected: virtual AnimationSource* GetSource_() = 0; public: AnimationClip() {} virtual ~AnimationClip() {} /** @brief ソースを設定する。 @param source ソース */ virtual void SetSource(AnimationSource* source) = 0; /** @brief ループするかを取得する。 @return ループするか? */ virtual bool GetIsLoopingMode() const = 0; /** @brief ループするかを設定する。 @return isLoopingMode ループするか? */ virtual void SetIsLoopingMode(bool isLoopingMode) = 0; #if !SWIG /** @brief ソースを取得する。 @return source ソース */ std::shared_ptr<AnimationSource> GetSource() { auto o = GetSource_(); SafeAddRef(o); return CreateSharedPtrWithReleaseDLL(o); } /** @brief ソースを設定する。 @param source ソース */ void SetSource(std::shared_ptr<AnimationSource>& source) { SetSource(source.get()); } #endif }; } namespace asd { /** @brief アニメーションに関するインスタンスを生成するためのクラス */ class AnimationSystem { friend class Accessor; protected: AnimationSystem(){} virtual ~AnimationSystem(){} virtual AnimationClip* CreateAnimationClip_() = 0; virtual AnimationSource* CreateAnimationSource_() = 0; virtual KeyframeAnimation* CreateKeyframeAnimation_() = 0; public: #if !SWIG /** @brief アニメーションクリップのインスタンスを生成する。 @return インスタンス */ std::shared_ptr<AnimationClip> CreateAnimationClip() { auto o = CreateAnimationClip_(); return CreateSharedPtrWithReleaseDLL(o); } /** @brief アニメーションソースのインスタンスを生成する。 @return インスタンス */ std::shared_ptr<AnimationSource> CreateAnimationSource() { auto o = CreateAnimationSource_(); return CreateSharedPtrWithReleaseDLL(o); } /** @brief キーフレームアニメーションのインスタンスを生成する。 @return インスタンス */ std::shared_ptr<KeyframeAnimation> CreateKeyframeAnimation() { auto o = CreateKeyframeAnimation_(); return CreateSharedPtrWithReleaseDLL(o); } #endif }; } //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- namespace asd { //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- class Graphics : public ReferenceObject { protected: virtual Texture2D* CreateTexture2D_(const achar* path) = 0; virtual Texture2D* CreateTexture2DAsRawData_(const achar* path) = 0; virtual Texture2D* CreateEmptyTexture2D_(int32_t width, int32_t height, TextureFormat format) = 0; virtual Texture2D* CreateEditableTexture2D_(const achar* path) = 0; virtual RenderTexture2D* CreateRenderTexture2D_(int32_t width, int32_t height, TextureFormat format) = 0; virtual CubemapTexture* CreateCubemapTextureFrom6ImageFiles_(const achar* front, const achar* left, const achar* back, const achar* right, const achar* top, const achar* bottom) = 0; virtual CubemapTexture* CreateCubemapTextureFromMipmapImageFiles_(const achar* path, int32_t mipmapCount) = 0; virtual CubemapTexture* CreateCubemapTextureFromSingleImageFile_(const achar* path) = 0; virtual Shader2D* CreateShader2D_( const achar* shaderText) = 0; virtual Material2D* CreateMaterial2D_(Shader2D* shader) = 0; virtual Shader3D* CreateShader3D_(const achar* shaderText) = 0; virtual Material3D* CreateMaterial3D_(Shader3D* shader) = 0; virtual MaterialPropertyBlock* CreateMaterialPropertyBlock_() = 0; virtual Mesh* CreateMesh_() = 0; virtual Deformer* CreateDeformer_() = 0; virtual Model* CreateModel_(const achar* path) = 0; virtual MassModel* CreateMassModelFromModelFile_(const achar* path) = 0; virtual MassModel* CreateMassModel_(const achar* path) = 0; virtual Terrain3D* CreateTerrain3D_() = 0; virtual Effect* CreateEffect_(const achar* path) = 0; virtual Font* CreateFont_(const achar* path) = 0; virtual Font* CreateDynamicFont_(const achar* font, int32_t fontSize, Color color, int32_t outlineSize, Color outlineColor) = 0; virtual ImagePackage* CreateImagePackage_(const achar* path) = 0; public: Graphics(){} virtual ~Graphics(){} #ifndef SWIG /** @brief テクスチャを生成する。 @param path 画像ファイルへの相対パス @return テクスチャ @warning 読み込める画像形式はPNGまたはDDSのみ。 */ std::shared_ptr<Texture2D> CreateTexture2D(const achar* path) { return CreateSharedPtrWithReleaseDLL(CreateTexture2D_(path)); } /** @brief テクスチャを生成する。 @param path 画像ファイルへの相対パス @return テクスチャ @note 画素がRGB空間にマッピングされている時に使用する。(ノーマルマップ等) @warning 読み込める画像形式はPNGまたはDDSのみ。 */ std::shared_ptr<Texture2D> CreateTexture2DAsRawData(const achar* path) { return CreateSharedPtrWithReleaseDLL(CreateTexture2DAsRawData_(path)); } /** @brief テクスチャを生成する。 @param width 横幅 @param height 縦幅 @param format フォーマット @return テクスチャ */ std::shared_ptr<Texture2D> CreateEmptyTexture2D(int32_t width, int32_t height, TextureFormat format) { return CreateSharedPtrWithReleaseDLL(CreateEmptyTexture2D_(width, height, format)); } /** @brief 編集可能なテクスチャを生成する。 @param path パス @return テクスチャ */ std::shared_ptr<Texture2D> CreateEditableTexture2D(const achar* path) { return CreateSharedPtrWithReleaseDLL(CreateEditableTexture2D_(path)); } /** @brief 描画先として指定可能なテクスチャを生成する。 @param width 横幅 @param height 縦幅 @param format フォーマット @warning 読み込める画像形式はPNGのみ。 @return テクスチャ */ std::shared_ptr<RenderTexture2D> CreateRenderTexture2D(int32_t width, int32_t height, TextureFormat format){ return CreateSharedPtrWithReleaseDLL(CreateRenderTexture2D_(width, height, format)); } /** @brief 6枚の画像ファイルからキューブマップテクスチャを生成する。 @param front 前方向の画像ファイルへの相対パス @param left 左方向の画像ファイルへの相対パス @param back 後ろ方向の画像ファイルへの相対パス @param right 右方向の画像ファイルへの相対パス @param top 上方向の画像ファイルへの相対パス @param bottom 下方向の画像ファイルへの相対パス @warning 読み込める画像形式はPNGまたはDDSのみ。 @return キューブマップ */ std::shared_ptr<CubemapTexture> CreateCubemapTextureFrom6ImageFiles(const achar* front, const achar* left, const achar* back, const achar* right, const achar* top, const achar* bottom) { return CreateSharedPtrWithReleaseDLL( CreateCubemapTextureFrom6ImageFiles_( front, left, back, right, top, bottom)); } /** @brief 複数の画像ファイルからミップマップ付のキューブマップテクスチャを生成する。 @param path ファイルの名称の先頭 @param mipmapCount ミップマップ数 @warning 読み込める画像形式はPNGまたはDDSのみ。 @return キューブマップ */ std::shared_ptr<CubemapTexture> CreateCubemapTextureFromMipmapImageFiles(const achar* path, int32_t mipmapCount) { return CreateSharedPtrWithReleaseDLL( CreateCubemapTextureFromMipmapImageFiles_( path, mipmapCount)); } /** @brief 1つのファイルからミップマップ付のキューブマップテクスチャを生成する。 @param path 画像ファイルへの相対パス @return キューブマップ @warning 読み込める画像形式はDDSのみ。 */ std::shared_ptr<CubemapTexture> CreateCubemapTextureFromSingleImageFile(const achar* path) { return CreateSharedPtrWithReleaseDLL( CreateCubemapTextureFromSingleImageFile_( path)); } /** @brief シェーダー(2D)を生成する。 @param shaderText シェーダーのコード @return シェーダー(2D) */ std::shared_ptr<Shader2D> CreateShader2D(const achar* shaderText) { return CreateSharedPtrWithReleaseDLL(CreateShader2D_(shaderText)); } /** @brief マテリアル(2D)を生成する。 @param shader シェーダー @return マテリアル(2D) */ std::shared_ptr<Material2D> CreateMaterial2D(std::shared_ptr<Shader2D> shader) { auto material = CreateMaterial2D_(shader.get()); return CreateSharedPtrWithReleaseDLL(material); } /** @brief シェーダー(3D)を生成する。 @param shaderText シェーダーのコード @return シェーダー(3D) */ std::shared_ptr<Shader3D> CreateShader3D(const achar* shaderText) { return CreateSharedPtrWithReleaseDLL(CreateShader3D_(shaderText)); } /** @brief マテリアル(3D)を生成する。 @param shader シェーダー @return マテリアル(3D) */ std::shared_ptr<Material3D> CreateMaterial3D(std::shared_ptr<Shader3D> shader) { auto material = CreateMaterial3D_(shader.get()); return CreateSharedPtrWithReleaseDLL(material); } /** @brief マテリアルプロパティブロックを生成する。 @return マテリアルプロパティブロック */ std::shared_ptr<MaterialPropertyBlock> CreateMaterialPropertyBlock() { auto block = CreateMaterialPropertyBlock_(); return CreateSharedPtrWithReleaseDLL(block); } /** @brief メッシュを生成する。 @return メッシュ */ std::shared_ptr<Mesh> CreateMesh() { auto mesh = CreateMesh_(); return CreateSharedPtrWithReleaseDLL(mesh); } /** @brief デフォーマーを生成する。 @return デフォーマー */ std::shared_ptr<Deformer> CreateDeformer() { auto deformer = CreateDeformer_(); return CreateSharedPtrWithReleaseDLL(deformer); } /** @brief モデルを生成する。 @param path パス @return モデル */ std::shared_ptr<Model> CreateModel(const achar* path) { auto model = CreateModel_(path); return CreateSharedPtrWithReleaseDLL(model); } /** @brief 大量描画用モデルを生成する。 @param path パス @return 大量描画用モデル */ std::shared_ptr<MassModel> CreateMassModelFromModelFile(const achar* path) { auto model = CreateMassModelFromModelFile_(path); return CreateSharedPtrWithReleaseDLL(model); } /** @brief 大量描画用モデルを生成する。 @param path パス @return 大量描画用モデル */ std::shared_ptr<MassModel> CreateMassModel(const achar* path) { auto model = CreateMassModel_(path); return CreateSharedPtrWithReleaseDLL(model); } /** @brief 地形を生成する。 @return 地形 */ std::shared_ptr<Terrain3D> CreateTerrain3D() { auto terrain = CreateTerrain3D_(); return CreateSharedPtrWithReleaseDLL(terrain); } /** @brief エフェクトを生成する。 @param path パス @return エフェクト */ std::shared_ptr<Effect> CreateEffect(const achar* path) { auto effect = CreateEffect_(path); return CreateSharedPtrWithReleaseDLL(effect); } #undef CreateFont /** @brief フォントを生成する。 @param path パス @return フォント */ std::shared_ptr<Font> CreateFont(const achar* path) { auto font = CreateFont_(path); return CreateSharedPtrWithReleaseDLL(font); } /** @brief 必要に応じて動的に生成されるフォントを生成する。 @param font フォント名/フォントパス @param fontSize フォントサイズ @param color フォントの色 @param outlineSize 外枠の太さ @param outlineColor 外枠の色 @return フォント @note 文字を表示する時に必要な文字の分だけフォントを生成するフォントクラスを生成する。 fontには、フォント名、もしくはフォントファイルへのパスを指定する。 何もfontに文字を指定しない、もしくはnullだと標準フォントが使用される。 事前に専用のフォントファイルを用意する必要はないが、アプリケーションを実行する環境に指定したフォントが存在する必要がある。 */ std::shared_ptr<Font> CreateDynamicFont(const achar* font, int32_t fontSize, Color color, int32_t outlineSize, Color outlineColor) { auto font_ = CreateDynamicFont_(font, fontSize, color, outlineSize, outlineColor); return CreateSharedPtrWithReleaseDLL(font_); } /** @brief 画像パッケージを生成する。 @param path パス @return 画像パッケージ */ std::shared_ptr<ImagePackage> CreateImagePackage(const achar* path) { auto ip = CreateImagePackage_(path); return CreateSharedPtrWithReleaseDLL(ip); } #endif /** @brief 1フレーム間に実行された描画命令の回数を取得する。 @return 描画命令の回数 @note 現在、エフェクトの描画回数はカウントされない。 */ virtual int32_t GetDrawCallCount() const = 0; /** @brief 現在使用済みのVRAM容量を取得する。 @return VRAM容量 @note 値は推測値である。 */ virtual int32_t GetUsedVRAMSize() const = 0; /** @brief 描画ランタイムの種類を取得する。 @return 種類 */ virtual GraphicsDeviceType GetGraphicsDeviceType() const = 0; }; //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- } namespace asd { /** @brief 図形の種類 */ enum class ShapeType { /** @brief 円 */ CircleShape, /** @brief 弧 */ ArcShape, /** @brief 線分 */ LineShape, /** @brief 矩形 */ RectangleShape, /** @brief 三角形 */ TriangleShape, /** @brief 多角形 */ PolygonShape }; } //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- namespace asd { //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- /** @brief カーソルを表すクラス */ class Cursor : public IReference { protected: Cursor(){} virtual ~Cursor(){} public: }; //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- } //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- namespace asd { //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- #if !SWIG typedef void(ASD_STDCALL *CoreFuncPtr)(Core*); #endif class CoreOption { public: bool IsFullScreen; GraphicsDeviceType GraphicsDevice; bool IsReloadingEnabled; WindowPositionType WindowPosition; ColorSpaceType ColorSpace; }; class Core : public ReferenceObject { private: public: #if !SWIG /** @brief インスタンスが破棄された際に呼ばれる関数ポインタを設定する。 @param func 破棄された際に呼ばれる関数 */ virtual void SetRemovedFunctionPpointer(CoreFuncPtr func) = 0; #endif /** @brief 初期化を行う。 @param title タイトル @param width 横幅 @param height 縦幅 @param isFullScreen フルスクリーンで起動するかどうか? @param isOpenGLMode OpenGLで起動するかどうか? @return 成否 */ virtual bool Initialize(const achar* title, int32_t width, int32_t height, CoreOption option) = 0; /** @brief 初期化を行う。 @param handle1 ハンドル @param handle2 ハンドル @param width 横幅 @param height 縦幅 @param isOpenGLMode OpenGLで起動するかどうか? @return 成否 */ virtual bool InitializeByExternalWindow(void* handle1, void* handle2, int32_t width, int32_t height, CoreOption option) = 0; /** @brief タイトルを設定する。 @param title タイトル */ virtual void SetTitle(const achar* title) = 0; /** @brief イベントを実行し、進行可否を判断する。 @return 進行可能か? */ virtual bool DoEvents() = 0; /** @brief 更新処理を行う。 */ virtual void Update() = 0; /** @brief 終了処理を行う。 */ virtual void Terminate() = 0; /** @brief 更新されたリソースのリロードを行う。 */ virtual void Reload() = 0; /** @brief 描画機能の準備をする。 */ virtual void BeginDrawing() = 0; /** @brief 描画機能の使用を完了する。 */ virtual void EndDrawing() = 0; /** @brief シーンをウインドウに描画する。 */ virtual void DrawSceneToWindow(CoreScene* scene) = 0; /** @brief 画面遷移しつつシーンをウインドウに描画する。 */ virtual void DrawSceneToWindowWithTransition(CoreScene* nextScene, CoreScene* previousScene, CoreTransition* transition) = 0; /** @brief 現在のコアの内部情報を描画する。 */ virtual void Draw() = 0; /** @brief 現在のシーンを変更します。 */ virtual void ChangeScene(CoreScene* scene) = 0; /** @brief ウインドウを閉じる。 */ virtual void Close() = 0; /** @brief マウスカーソルを作成する。 @param path 画像のパス @param hot カーソルの相対座標 @return カーソル */ virtual Cursor* CreateCursor(const achar* path, Vector2DI hot) = 0; /** @brief マウスカーソルを設定する。 @param cursor カーソル */ virtual void SetCursor(Cursor* cursor) = 0; /** @brief クリップボードの内容を取得する。 @return クリップボード */ virtual const achar* GetClipboardString() = 0; /** @brief クリップボードの内容を設定する。 @param s 文字列 */ virtual void SetClipboardString(const achar* s) = 0; /** @brief フルスクリーンモードかどうか設定する。 @param isFullscreenMode フルスクリーンモードか */ virtual void SetIsFullscreenMode(bool isFullscreenMode) = 0; /** @brief スクリーンショットをpngとして保存する。 @param path 出力先 */ virtual void TakeScreenshot(const achar* path) = 0; /** @brief スクリーンショットをgifアニメーションとして録画する。 @param path 出力先 @param frame 録画フレーム数 @param frequency_rate 録画頻度(例えば、1だと1フレームに1回保存、0.5だと2フレームに2回保存) @param scale ウインドウサイズに対する画像サイズの拡大率(ウインドウサイズが320の場合、0.5を指定すると160の画像が出力される) @note 実行してから一定時間の間、録画を続ける。 録画が終了するまでにアプリケーションが終了された場合、終了した時点までの録画結果が出力される。 */ virtual void CaptureScreenAsGifAnimation(const achar* path, int32_t frame, float frequency_rate, float scale) = 0; /** @brief 1フレームで経過した時間を実時間(秒)で取得する。 @return 経過時間時間(秒) */ virtual float GetDeltaTime() const = 0; /** @brief 1フレームで経過した時間を外部から設定する。 @param deltaTime 経過時間(秒) @note 基本的に開発者は使用する必要はない。 何らかの理由で無理やり経過時間を指定する場合に使用する。 */ virtual void SetDeltaTime(float deltaTime) = 0; /** @brief 現在のFPSを取得する。 @return FPS */ virtual float GetCurrentFPS() = 0; /** @brief 目標FPSを取得する。 @return FPS */ virtual int32_t GetTargetFPS() = 0; /** @brief 目標FPSを設定する。 @param fps FPS */ virtual void SetTargetFPS(int32_t fps) = 0; /** @brief 時間を指定可能なオブジェクトの実時間あたりの進行速度を取得する。 @return 進行速度 */ virtual float GetTimeSpan() const = 0; /** @brief 時間を指定可能なオブジェクトの実時間あたりの進行速度を設定する。 @param timeSpan 進行速度 */ virtual void SetTimeSpan(float timeSpan) = 0; /** @brief フレームレートの制御方法を取得する。 @return 制御方法 */ virtual FramerateMode GetFramerateMode() const = 0; /** @brief フレームレートの制御方法を設定する。 @param framerateMode 制御方法 */ virtual void SetFramerateMode(FramerateMode framerateMode) = 0; /** @brief Windowsの場合、ウインドウのハンドルを返す。 @return ウインドウハンドル */ virtual void* GetWindowHandle() const = 0; /** @brief キーボードの入力を扱うKeyboardクラスを取得する。 */ virtual Keyboard* GetKeyboard() = 0; /** @brief マウスの入力を扱うMouseクラスを取得する。 */ virtual Mouse* GetMouse() = 0; /** @brief 接続されているジョイスティックの入力を扱うJoystickContainerクラスを取得する。 */ virtual JoystickContainer* GetJoystickContainer() = 0; /** @brief 通常のファイルとパックファイルに対する読み込みをサポートするFileクラスを取得する。 */ virtual File* GetFile() = 0; /** @brief ログ出力を扱うLogクラスを取得する。 */ virtual Log* GetLogger() = 0; /** @brief プロファイリング機能を提供するProfilerクラスを取得する。 */ virtual Profiler* GetProfiler() = 0; virtual LayerProfiler* GetLayerProfiler() = 0; /** @brief 描画を扱うグラフィックスクラスを取得する。 */ virtual Graphics* GetGraphics() = 0; virtual Sound* GetSound() = 0; virtual ObjectSystemFactory* GetObjectSystemFactory() = 0; virtual AnimationSystem* GetAnimationSyatem() = 0; /** @brief ウィンドウサイズを取得する。 */ virtual Vector2DI GetWindowSize() = 0; virtual void SetWindowSize(Vector2DI size) = 0; virtual bool GetProfilerVisibility() const = 0; virtual void SetProfilerVisibility(bool visible) = 0; }; //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- }; #include <vector> #include <memory> namespace asd { class Engine; /** @brief ポストエフェクトを適用するクラス */ class PostEffect { friend class Engine; friend class Layer; friend class CameraObject3D; friend class PostEffectGrayScale; friend class PostEffectGaussianBlur; friend class PostEffectLightBloom; friend class PostEffectSepia; private: std::shared_ptr<CorePostEffect> m_corePostEffect; CorePostEffect* GetCoreObject() const; protected: /** @brief オーバーライドして、毎フレーム描画される処理を記述できる。 */ virtual void OnDraw(std::shared_ptr<RenderTexture2D> dst, std::shared_ptr<RenderTexture2D> src) {} /** @brief マテリアルを用いてテクスチャに画像を描画する。 @param target 描画先 @param material マテリアル */ void DrawOnTexture2DWithMaterial(std::shared_ptr<RenderTexture2D> target, std::shared_ptr<Material2D> material); public: PostEffect(); virtual ~PostEffect(); }; } #include<memory> #include <vector> namespace asd { /** @brief グレースケール化するポストエフェクトクラス */ class PostEffectGrayScale : public PostEffect { private: std::shared_ptr<asd::Material2D> material2d; protected: virtual void OnDraw(std::shared_ptr<RenderTexture2D> dst, std::shared_ptr<RenderTexture2D> src) override; public: PostEffectGrayScale(); virtual ~PostEffectGrayScale() = default; }; } #include<memory> #include <vector> namespace asd { /** @brief セピア調化するポストエフェクトクラス */ class PostEffectSepia : public PostEffect { private: std::shared_ptr<asd::Material2D> material2d; protected: virtual void OnDraw(std::shared_ptr<RenderTexture2D> dst, std::shared_ptr<RenderTexture2D> src) override; public: PostEffectSepia(); virtual ~PostEffectSepia() = default; }; } #include<memory> #include <vector> namespace asd { /** @brief ガウスぼかしをかけるポストエフェクトクラス */ class PostEffectGaussianBlur : public PostEffect { private: std::shared_ptr<Material2D> material2dX; std::shared_ptr<Material2D> material2dY; std::shared_ptr<RenderTexture2D> tempTexture; float intensity = 5.0f; protected: virtual void OnDraw(std::shared_ptr<RenderTexture2D> dst, std::shared_ptr<RenderTexture2D> src) override; public: PostEffectGaussianBlur(); virtual ~PostEffectGaussianBlur() = default; /** @brief ぼかしの強さを設定する。 @detail 実質的にはガウス関数の分散にあたる値の平方根 */ void SetIntensity(float const value){ if (value <= 0.0f){ return; }intensity = value; } }; } #include<memory> #include <vector> namespace asd { /** @brief 輝度の高い画素のみをぼかして加算するポストエフェクト */ class PostEffectLightBloom : public PostEffect { private: std::shared_ptr<asd::Material2D> material2dX_Lum, material2dX, material2dY, materialSum, downsample; std::shared_ptr<RenderTexture2D> tempTexture0; std::shared_ptr<RenderTexture2D> tempTexture1; std::shared_ptr<RenderTexture2D> tempTexture2; std::shared_ptr<RenderTexture2D> tempTexture3; std::shared_ptr<RenderTexture2D> downsampledTexture0; std::shared_ptr<RenderTexture2D> downsampledTexture1; std::shared_ptr<RenderTexture2D> downsampledTexture2; std::shared_ptr<RenderTexture2D> downsampledTexture3; float intensity = 5.0f; float threshold = 1.0f; float exposure = 1.0f; bool isLuminanceMode = false; protected: virtual void OnDraw(std::shared_ptr<RenderTexture2D> dst, std::shared_ptr<RenderTexture2D> src) override; public: PostEffectLightBloom(); virtual ~PostEffectLightBloom() = default; /** @brief ぼかしの強さを設定する。 @note 実質的にはガウス関数の分散にあたる値の平方根。 */ void SetIntensity(float const value){ if (value <= 0.0f){ return; }intensity = value; } /** @brief ぼかすピクセルの閾値を設定する。 @note この閾値を超えた値がぼかされ加算される。 */ void SetThreshold(float const value){ threshold = value; } /** @brief 露光の強さを指定する。 @note この値が高いほどぼかされる値の輝度が高くなる。 */ void SetExposure(float const value) { exposure = value; } /** @brief 輝度を参照するか指定する。 @note この値がtrueだと、RGBではなく輝度からぼかされる色を決定する。 */ void SetIsLuminanceMode(bool value) { isLuminanceMode = value; } }; } namespace asd { /** @brief シーン遷移時の効果を適用するクラス */ class Transition { friend class Engine; private: std::shared_ptr<CoreTransition> coreTransition; std::shared_ptr<CoreTransition> GetCoreTransition() { return coreTransition; } public: typedef std::shared_ptr<Transition> Ptr; Transition(); virtual ~Transition(); /** @brief オーバーライドして、このオブジェクトの更新処理を記述できる。 */ virtual void OnUpdate(); /** @brief シーンが切り替わっているか取得する。 @return シーンが切り替わっているか? */ bool IsSceneChanged() const; /** @brief 実際にシーンを次のシーンに切り替える。 */ void ChangeScene(); /** @brief シーン遷移処理が終了したか取得する。 @return シーン遷移処理が終了したか? */ bool GetIsFinished() const; /** @brief シーン遷移処理を終了する。 */ void Finish(); /** @brief 次のシーンを3角形に貼り付けて描画する。 @param pos1 座標1(0~1) @param pos2 座標2(0~1) @param pos3 座標3(0~1) @param col1 頂点カラー1 @param col2 頂点カラー2 @param col3 頂点カラー3 @param uv1 UV1(0~1) @param uv2 UV2(0~1) @param uv3 UV3(0~1) @note ChangeSceneを実行するまでは無効である。 */ virtual void DrawTriangleWithNextScene( Vector2DF pos1, Vector2DF pos2, Vector2DF pos3, Color col1, Color col2, Color col3, Vector2DF uv1, Vector2DF uv2, Vector2DF uv3); /** @brief 次のシーンを4角形に貼り付けて描画する。 @param upperLeftPos 左上の描画位置(0~1) @param upperRightPos 右上の描画位置(0~1) @param lowerRightPos 右下の描画位置(0~1) @param lowerLeftPos 左下の描画位置(0~1) @param upperLeftCol 左上の頂点色 @param upperRightCol 右上の頂点色 @param lowerRightCol 右下の頂点色 @param lowerLeftCol 左下の頂点色 @param upperLeftUV 左上のUV値(0~1) @param upperRightUV 右上のUV値(0~1) @param lowerRightUV 右下のUV値(0~1) @param lowerLeftUV 左下のUV値(0~1) @note ChangeSceneを実行するまでは無効である。 */ void DrawRectangleWithNextScene( Vector2DF upperLeftPos, Vector2DF upperRightPos, Vector2DF lowerRightPos, Vector2DF lowerLeftPos, Color upperLeftCol, Color upperRightCol, Color lowerRightCol, Color lowerLeftCol, Vector2DF upperLeftUV, Vector2DF upperRightUV, Vector2DF lowerRightUV, Vector2DF lowerLeftUV); /** @brief 前のシーンを3角形に貼り付けて描画する。 @param pos1 座標1 @param pos2 座標2 @param pos3 座標3 @param col1 頂点カラー1 @param col2 頂点カラー2 @param col3 頂点カラー3 @param uv1 UV1 @param uv2 UV2 @param uv3 UV3 @note ChangeSceneを実行すると前のシーンの描画は停止し、静止画として扱われる。 */ void DrawTriangleWithPreviousScene( Vector2DF pos1, Vector2DF pos2, Vector2DF pos3, Color col1, Color col2, Color col3, Vector2DF uv1, Vector2DF uv2, Vector2DF uv3); /** @brief 前のシーンを4角形に貼り付けて描画する。 @param upperLeftPos 左上の描画位置(0~1) @param upperRightPos 右上の描画位置(0~1) @param lowerRightPos 右下の描画位置(0~1) @param lowerLeftPos 左下の描画位置(0~1) @param upperLeftCol 左上の頂点色 @param upperRightCol 右上の頂点色 @param lowerRightCol 右下の頂点色 @param lowerLeftCol 左下の頂点色 @param upperLeftUV 左上のUV値(0~1) @param upperRightUV 右上のUV値(0~1) @param lowerRightUV 右下のUV値(0~1) @param lowerLeftUV 左下のUV値(0~1) @note ChangeSceneを実行すると前のシーンの描画は停止し、静止画として扱われる。 */ void DrawRectangleWithPreviousScene( Vector2DF upperLeftPos, Vector2DF upperRightPos, Vector2DF lowerRightPos, Vector2DF lowerLeftPos, Color upperLeftCol, Color upperRightCol, Color lowerRightCol, Color lowerLeftCol, Vector2DF upperLeftUV, Vector2DF upperRightUV, Vector2DF lowerRightUV, Vector2DF lowerLeftUV); }; } namespace asd { /** @brief フェードしながらシーン遷移する効果を適用するクラス */ class TransitionFade : public Transition { private: float fadeinDuration = 0; float fadeoutDuration = 0; float time = 0; public: /** @brief コンストラクタ @param fadeoutDuration フェードアウトにかかる実時間(秒) @param fadeinDuration フェードインにかかる実時間(秒) */ TransitionFade(float fadeoutDuration, float fadeinDuration); virtual ~TransitionFade(); void OnUpdate() override; }; } namespace asd { class ICommitable { public: virtual ~ICommitable() { } virtual void Commit() = 0; }; } namespace asd { template<typename TComponent> class IComponentRegisterable { public: virtual ~IComponentRegisterable() { } virtual void Register(const std::shared_ptr<TComponent>& component) = 0; virtual void Unregister(const std::shared_ptr<TComponent>& component) = 0; }; } namespace asd { template<typename TComponent> class IImmediateComponentManager { protected: typedef std::shared_ptr<TComponent> ComponentPtr; public: virtual ~IImmediateComponentManager() { } virtual void ImmediatelyAddComponent(const ComponentPtr& component, astring key) = 0; virtual void ImmediatelyRemoveComponent(astring key) = 0; }; } namespace asd { template<typename TObject> class IImmediateObjectManager { protected: typedef std::shared_ptr<TObject> ObjectPtr; public: virtual ~IImmediateObjectManager() { } virtual void ImmediatelyAddObject(const ObjectPtr& object, bool raiseEvent) = 0; virtual void ImmediatelyRemoveObject(const ObjectPtr& object, bool raiseEvent) = 0; }; } namespace asd { class IImmediatelyDisposable { public: virtual ~IImmediatelyDisposable() { } virtual void Dispose() = 0; virtual void DisposeImmediately() = 0; }; } namespace asd { template<typename TObject> class IObjectRegisterable { public: virtual ~IObjectRegisterable() { } virtual bool GetIsAlive() const = 0; virtual void Register(const std::shared_ptr<TObject>& object) = 0; virtual void Unregister(const std::shared_ptr<TObject>& object) = 0; virtual void AddToCore(const std::shared_ptr<TObject>& object) = 0; virtual void RemoveFromCore(const std::shared_ptr<TObject>& object) = 0; }; } namespace asd { enum class RegistrationCommand { Add, Remove }; } #include <memory> namespace asd { class Object2D; template<typename TComponent> class ComponentManager; /** @brief asd::Object2D クラスに登録することができるコンポーネント。 */ class Object2DComponent : public IImmediatelyDisposable , public std::enable_shared_from_this<Object2DComponent> { friend class Object2D; friend class ComponentManager<Object2DComponent>; private: Object2D* m_owner; bool m_isUpdated; bool m_isAlive; astring m_key; void Update(); void RaiseOnAdded(); void RaiseOnRemoved(); void RaiseOnDisposed(); void SetOwner(Object2D* value); void DisposeImmediately(); protected: /** @brief オーバーライドして、このコンポーネントの更新処理を記述できる。 */ virtual void OnUpdate() = 0; virtual void OnObjectAdded() { } virtual void OnObjectRemoved() { } virtual void OnObjectDisposed() { } public: typedef std::shared_ptr<Object2DComponent> Ptr; /** @brief コンストラクタ */ Object2DComponent(); /** @brief デストラクタ */ virtual ~Object2DComponent() { } /** @brief このインスタンスを保持している2Dオブジェクトのインスタンスを取得する。 */ Object2D* GetOwner() const; /** @brief このコンポーネントが更新されるかどうかを取得する。 */ bool GetIsUpdated() const; /** @brief このコンポーネントが更新されるかどうかを設定する。 */ void SetIsUpdated(bool value); astring GetKey() const; void SetKey(astring value); /** @brief このコンポーネントが実行中かどうかを取得する。Vanishメソッドによって破棄された時に false を返します。 */ bool GetIsAlive() const; /** @brief このコンポーネントを破棄します。 */ void Dispose(); }; } #include <memory> namespace asd { class Layer2D; template<typename TComponent> class ComponentManager; /** @brief asd::Layer2D クラスに登録することができるコンポーネント。 */ class Layer2DComponent : public std::enable_shared_from_this<Layer2DComponent> , public IImmediatelyDisposable { friend class Layer2D; friend class ComponentManager<Layer2DComponent>; private: Layer2D* m_layer; bool m_isUpdated; bool m_isAlive; astring m_key; void Update(); void RaiseOnAdded(); void RaiseOnRemoved(); void RaiseOnDisposed(); void SetOwner(Layer2D* value); void DisposeImmediately(); protected: /** @brief オーバーライドして、このコンポーネントの更新処理を記述できる。 */ virtual void OnUpdate() = 0; virtual void OnLayerAdded() { } virtual void OnLayerRemoved() { } virtual void OnLayerDisposed() { } public: typedef std::shared_ptr<Layer2DComponent> Ptr; /** @brief コンストラクタ */ Layer2DComponent(); /** @brief デストラクタ */ virtual ~Layer2DComponent() { } /** @brief このインスタンスを保持しているレイヤーのインスタンスを取得する。 */ Layer2D* GetOwner() const; /** @brief このコンポーネントが更新されるかどうかを取得する。 */ bool GetIsUpdated() const; /** @brief このコンポーネントが更新されるかどうかを設定する。 */ void SetIsUpdated(bool value); astring GetKey() const; void SetKey(astring value); /** @brief このコンポーネントが実行中かどうかを取得する。Vanishメソッドによって破棄された時に false を返します。 */ bool GetIsAlive() const; /** @brief このコンポーネントを破棄します。 */ void Dispose(); }; } #include <memory> namespace asd { class Scene; template<typename TComponent> class ComponentManager; /** @brief asd::Scene クラスに登録することができるコンポーネント。 */ class SceneComponent : public std::enable_shared_from_this<SceneComponent> , public IImmediatelyDisposable { friend class Scene; friend class ComponentManager<SceneComponent>; private: Scene* m_scene; bool m_isUpdated; bool m_isAlive; astring m_key; void Update(); void RaiseOnRegistered(); void RaiseOnStartUpdating(); void RaiseOnTransitionFinished(); void RaiseOnTransitionBegin(); void RaiseOnStopUpdating(); void RaiseOnUnregistered(); void RaiseOnDisposed(); void SetOwner(Scene* value); void DisposeImmediately(); protected: /** @brief オーバーライドして、このコンポーネントの更新処理を記述できる。 */ virtual void OnUpdate() = 0; virtual void OnSceneRegistered() { } virtual void OnStartSceneUpdating() { } virtual void OnSceneTransitionFinished() { } virtual void OnSceneTransitionBegin() { } virtual void OnStopSceneUpdating() { } virtual void OnSceneUnregistered() { } virtual void OnSceneDisposed() { } public: typedef std::shared_ptr<SceneComponent> Ptr; /** @brief コンストラクタ */ SceneComponent(); /** @brief デストラクタ */ virtual ~SceneComponent() { } /** @brief このインスタンスを保持しているシーンのインスタンスを取得する。 */ Scene* GetOwner() const; /** @brief このコンポーネントが更新されるかどうかを取得する。 */ bool GetIsUpdated() const; /** @brief このコンポーネントが更新されるかどうかを設定する。 */ void SetIsUpdated(bool value); astring GetKey() const; void SetKey(astring value); /** @brief このコンポーネントが実行中かどうかを取得する。Vanishメソッドによって破棄された時に false を返します。 */ bool GetIsAlive() const; /** @brief このコンポーネントを破棄します。 */ void Dispose(); }; } #include <memory> #include <map> namespace asd { class Scene; /** @brief オブジェクトの更新と描画を管理するレイヤーの機能を提供する抽象クラス。 */ class Layer : public std::enable_shared_from_this<Layer> , public IImmediatelyDisposable { friend class Scene; public: typedef std::shared_ptr<Layer> Ptr; protected: std::shared_ptr<CoreLayer> m_commonObject; bool m_isUpdated; bool m_isUpdatedCurrent = false; bool m_isDrawn; bool m_isAlive; int m_updatePriority; float m_updateFrequency; float m_updateTimer; std::vector<std::shared_ptr<PostEffect>> m_postEffects; private: Scene* m_scene; astring m_name; virtual void SetScene(Scene* scene); std::shared_ptr<CoreLayer> GetCoreLayer() const; void DisposeImmediately(); virtual void DisposeInternal() = 0; virtual void BeginUpdating() = 0; virtual void EndUpdateting() = 0; virtual void UpdateInternal() = 0; virtual void DrawAdditionally() = 0; virtual void RaiseOnAdded() = 0; virtual void RaiseOnRemoved() = 0; virtual void Update(); void Draw(); void BeginDrawing(); void EndDrawing(); protected: /** @brief オーバーライドして、このレイヤーがシーンに登録されたときの処理を記述できる。 */ virtual void OnAdded(); /** @brief オーバーライドして、このレイヤーがシーンから登録解除されたときの処理を記述できる。 */ virtual void OnRemoved(); /** @brief オーバーライドして、このレイヤーが更新される前の処理を記述できる。 */ virtual void OnUpdating(); /** @brief オーバーライドして、このレイヤーが更新された後の処理を記述できる。 */ virtual void OnUpdated(); /** @brief オーバーライドして、このレイヤーの描画処理を記述できる。 */ virtual void OnDrawAdditionally(); /** @brief オーバーライドして、このレイヤーがVanishメソッドによって破棄されるときの処理を記述できる。 */ virtual void OnVanish(); /** @brief オーバーライドして、このレイヤーが破棄されるときの処理を記述できる。 */ virtual void OnDispose(); public: Layer(); virtual ~Layer(); /** @brief このインスタンスを管理している asd.Scene クラスのインスタンスを取得する。 @return シーン */ virtual Scene* GetScene() const; /** @brief レイヤーの更新を実行するかどうか取得する。 */ bool GetIsUpdated() const; /** @brief レイヤーの更新を実行するかどうか設定する。 @param value レイヤーの更新を実行するかどうか */ void SetIsUpdated(bool value); /** @brief レイヤーを描画するどうか取得する。 */ bool GetIsDrawn() const; /** @brief レイヤーを描画するどうか設定する。 @param value レイヤーを描画するどうか */ void SetIsDrawn(bool value); /** @brief このレイヤーが有効かどうかを取得する。 */ bool GetIsAlive() const; /** @brief このレイヤーの描画優先度を取得する。この値が大きいほど手前に描画される。 */ int GetDrawingPriority() const; /** @brief このレイヤーの描画優先度を設定する。この値が大きいほど手前に描画される。 @param value 優先度 */ void SetDrawingPriority(int value); /** @brief ポストエフェクトを追加する。 @param postEffect ポストエフェクト */ void AddPostEffect(const std::shared_ptr<PostEffect>& postEffect); /** @brief ポストエフェクトを全て消去する。 */ void ClearPostEffects(); /** @brief このレイヤーを破棄する。 */ void Dispose(); /** @brief レイヤーの種類を取得する。 @return レイヤーの種類 */ virtual LayerType GetLayerType() const = 0; /** @brief このレイヤーの前回の更新時間を取得する。 */ int GetTimeForUpdate() const; virtual int GetObjectCount() const = 0; /** @brief このレイヤーの名前を取得する。 */ astring GetName() const; /** @brief このレイヤーの名前を設定する。 */ void SetName(astring value); /** @brief このレイヤーの更新の優先順位を取得する。 */ int GetUpdatePriority() const; /** @brief このレイヤーの更新の優先順位を設定する。 */ void SetUpdatePriority(int value); /** @brief このレイヤーの1フレームごとの更新回数を取得する。 */ float GetUpdateFrequency() const; /** @brief このレイヤーの1フレームごとの更新回数を設定する。 */ void SetUpdateFrequency(float value); }; } namespace asd { class GeometryObject2D; class Layer2D; /** @brief 当たり判定や図形描画に用いられる図形を扱うクラス。 */ class Shape { friend class GeometryObject2D; friend class Layer2D; protected: virtual std::shared_ptr<CoreShape> GetCoreShape() const = 0; public: /** @brief 図形のタイプを取得する。 @return 図形のタイプ */ virtual ShapeType GetShapeType() const = 0; /** @brief 指定した図形と衝突しているか否かを取得する。 @param shape 衝突を調べる図形 @return 衝突しているか否か */ bool GetIsCollidedWith(std::shared_ptr<Shape> shape); }; }; namespace asd { /** @brief 図形としての三角形を扱うクラス。 */ class TriangleShape :public Shape { private: std::shared_ptr<CoreTriangleShape> m_coreObject; protected: std::shared_ptr<CoreShape> GetCoreShape() const override; public: TriangleShape(); virtual ~TriangleShape(); /** @brief 指定したインデックスの頂点の座標を取得する。 @param index 座標を取得する頂点のインデックス(0 <= index < 3) @return 頂点の座標 */ Vector2DF GetPointByIndex(int index) const; /** @brief 指定したインデックスの頂点の座標を設定する。 @param point インデックスで指定した頂点に設定する座標 @param index 座標を設定する頂点のインデックス(0 <= index < 3) */ void SetPointByIndex(Vector2DF point, int index); /** @brief 指定したインデックスの頂点のUVを取得する。 @param index UVを取得する頂点のインデックス(0 <= index < 3) @return 頂点のUV */ Vector2DF GetUVByIndex(int index) const; /** @brief 指定したインデックスの頂点のUVを設定する。 @param uv インデックスで指定した頂点に設定するUV @param index UVを設定する頂点のインデックス(0 <= index < 3) */ void SetUVByIndex(Vector2DF uv, int index); ShapeType GetShapeType() const override; }; } namespace asd { /** @brief 図形としての円を扱うクラス。 */ class CircleShape :public Shape { private: std::shared_ptr<CoreCircleShape> m_coreObject; protected: std::shared_ptr<CoreShape> GetCoreShape() const override; public: CircleShape(); virtual ~CircleShape(); /** @brief この円の中心座標を取得する。 @return この円の中心座標 */ Vector2DF GetPosition() const; /** @brief この円の中心座標を設定する。 @param position この円の中心座標 */ void SetPosition(Vector2DF position); /** @brief この円の外径を取得する。 @return この円の外径 */ float GetOuterDiameter() const; /** @brief この円の外径を設定する。 @param outerDiameter この円の外径 */ void SetOuterDiameter(float outerDiameter); /** @brief この円の内径を取得する。 @return この円の内径 */ float GetInnerDiameter() const; /** @brief この円の内径を設定する。 @param innerDiameter この円の内径 */ void SetInnerDiameter(float innerDiameter); /** @brief この円の中心を軸とした回転角度を取得する。 @return この円の中心を軸とした回転角度 */ float GetAngle() const; /** @brief この円の中心を軸とした回転角度を設定する。 @param angle この円の中心を軸とした回転角度 */ void SetAngle(float angle); /** @brief この円の外周、内周上の曲がり角(滑らかさ)の数を取得する。 @return 外周、内周状の曲がり角の数 */ int GetNumberOfCorners() const; /** @brief この円の外周、内周上の曲がり角(滑らかさ)の数を設定する。 @param numberOfCorners 外周、内周状の曲がり角の数 */ void SetNumberOfCorners(int numberOfCorners); ShapeType GetShapeType() const; }; } namespace asd { /** @brief 図形としての弧を扱うクラス。 */ class ArcShape :public Shape { private: std::shared_ptr<CoreArcShape> m_coreObject; protected: std::shared_ptr<CoreShape> GetCoreShape() const override; public: ArcShape(); virtual ~ArcShape(); /** @brief この弧の中心座標を取得する。 @return この弧の中心座標 */ Vector2DF GetPosition() const; /** @brief この弧の中心座標を設定する。 @param position この弧の中心座標 */ void SetPosition(Vector2DF position); /** @brief この弧の外径を取得する。 @return この弧の外径 */ float GetOuterDiameter() const; /** @brief この弧の外径を設定する。 @param outerDiameter この弧の外径 */ void SetOuterDiameter(float outerDiameter); /** @brief この弧の内径を取得する。 @return この弧の内径 */ float GetInnerDiameter() const; /** @brief この弧の内径を設定する。 @param innerDiameter この弧の内径 */ void SetInnerDiameter(float innerDiameter); /** @brief この弧の中心を軸とした回転角度を取得する。 @return この弧の中心を軸とした回転角度 */ float GetAngle() const; /** @brief この弧の中心を軸とした回転角度を設定する。 @param angle この弧の中心を軸とした回転角度 */ void SetAngle(float angle); /** @brief この弧の外周、内周上の曲がり角(滑らかさ)の数を取得する。 @return 外周、内周状の曲がり角の数 */ int GetNumberOfCorners() const; /** @brief この弧の外周、内周上の曲がり角(滑らかさ)の数を設定する。 @param numberOfCorners 外周、内周状の曲がり角の数 */ void SetNumberOfCorners(int numberOfCorners); /** @brief この弧の始点となる外周、内周の曲がり角の番号を取得する。(0 <= StartingCorner <= NumberOfCorners) @return 始点となる外周、内周の曲がり角の番号 */ int GetStartingCorner() const; /** @brief この弧の始点となる外周、内周の曲がり角の番号を設定する。(0 <= StartingCorner <= NumberOfCorners) @param startingCorner 始点となる外周、内周の曲がり角の番号 */ void SetStartingCorner(int startingCorner); /** @brief この弧の終点となる外周、内周の曲がり角の番号を取得する。(0 <= EndingCorner <= NumberOfCorners) @return 終点となる外周、内周の曲がり角の番号 */ int GetEndingCorner() const; /** @brief この弧の終点となる外周、内周の曲がり角の番号を設定する。(0 <= EndingCorner <= NumberOfCorners) @param endingCorner 終点となる外周、内周の曲がり角の番号 */ void SetEndingCorner(int endingCorner); ShapeType GetShapeType() const override; }; } namespace asd { /** @brief 図形としての矩形を扱うクラス。 */ class RectangleShape :public Shape { private: std::shared_ptr<CoreRectangleShape> m_coreObject; protected: std::shared_ptr<CoreShape> GetCoreShape() const override; public: RectangleShape(); virtual ~RectangleShape(); /** @brief 矩形の描画範囲を取得する。 @return 矩形の描画範囲 */ RectF GetDrawingArea() const; /** @brief 矩形の描画範囲を設定する。 @param drawingArea 矩形の描画範囲 */ void SetDrawingArea(RectF drawingArea); /** @brief 矩形の頂点別UVを取得する。 @return 矩形の頂点別UV */ RectF GetUV() const; /** @brief 矩形の頂点別UVを設定する。 @param uv 矩形の頂点別UV */ void SetUV(RectF uv); /** @brief 矩形の回転角度を取得する。 @return 矩形の回転角度 */ float GetAngle() const; /** @brief 矩形の回転角度を設定する。 @param angle 矩形の回転角度 */ void SetAngle(float angle); /** @brief 矩形の回転の際の中心座標を取得する。 @return 矩形の回転の際の中心座標 */ Vector2DF GetCenterPosition() const; /** @brief 矩形の回転の際の中心座標を設定する。 @centerPosition 矩形の回転の際の中心座標 */ void SetCenterPosition(Vector2DF centerPosition); ShapeType GetShapeType() const override; }; } namespace asd { /** @brief 図形としての線分を扱うクラス。 */ class LineShape :public Shape { private: std::shared_ptr<CoreLineShape> m_coreObject; protected: std::shared_ptr<CoreShape> GetCoreShape() const override; public: LineShape(); virtual ~LineShape(); /** @brief 線分の始点座標を取得する。 @return 線分の視点座標 */ Vector2DF GetStartingPosition() const; /** @brief 線分の視点座標を設定する。 @param startingPosition 線分の始点座標 */ void SetStartingPosition(Vector2DF startingPosition); /** @brief 線分の終点座標を取得する。 @return 線分の終点座標 */ Vector2DF GetEndingPosition() const; /** @brief 線分の終点座標を設定する。 @param endingPosition 線分の終点座標 */ void SetEndingPosition(Vector2DF endingPosition); /** @brief 線分の太さを取得する。 @return 線分の太さ */ float GetThickness() const; /** @brief 線分の太さを設定する。 @param thickness 線分の太さ */ void SetThickness(float thickness); ShapeType GetShapeType() const override; }; } namespace asd { /** @brief 図形としての多角形を扱うクラス。 */ class PolygonShape :public Shape { private: std::shared_ptr<CorePolygonShape> m_coreObject; std::vector<std::shared_ptr<CoreShape>> holeShapes; protected: std::shared_ptr<CoreShape> GetCoreShape() const override; public: PolygonShape(); virtual ~PolygonShape(); /** @brief ポリゴンを構成する頂点を追加する。 @return 新規に追加する頂点の座標 */ void AddVertex(Vector2DF vertex); /** @brief ポリゴンを構成する頂点を全て削除する。 */ void ClearVertexes(); /** @brief 多角形に空ける穴となるオブジェクトを追加する。 @param holeShape 穴となるオブジェクトのインスタンス @return 正しく追加されたかどうか */ bool AddHole(std::shared_ptr<CoreShape> holeShape); /** @brief 多角形に空ける穴となるオブジェクトを削除する。 @param holeShape 穴となるオブジェクトのインスタンス @return 正しく削除されたかどうか */ bool RemoveHole(std::shared_ptr<CoreShape> holeShape); /** @brief 追加された穴となるオブジェクトの一覧を取得する。 @return 追加された穴となるオブジェクトの一覧 */ std::vector<std::shared_ptr<CoreShape>>& GetHoleShapes(); /** @brief ポリゴンを構成する頂点の数量を取得する。 @return ポリゴンを構成する頂点の数量 */ int GetVertexesNum() const; ShapeType GetShapeType() const override; }; } namespace asd { /** @brief 子オブジェクトの管理に関する同期の設定を表す値を提供するクラス。 */ class ChildManagementMode { public: typedef int Flags; enum : Flags { /** @brief 何も同期しない。 */ Nothing = 0, /** @brief レイヤーへの登録状況を同期する。 */ RegistrationToLayer = 1, /** @brief 親オブジェクトが破棄されたとき、子オブジェクトも破棄する。 */ Disposal = 2, /** @brief 親オブジェクトが更新されないとき、子オブジェクトも更新しない。 */ IsUpdated = 4, /** @brief 親オブジェクトが描画されないとき、子オブジェクトも描画されない。 */ IsDrawn = 8, }; }; } namespace asd { /** @brief オブジェクトの親子関係の同期方法を表す列挙体 */ enum class ChildTransformingMode : int32_t { /** @brief 位置のみを同期する。 */ Position = 0, /** @brief 位置・角度・拡大率を同期する。 */ All = 1, /** @brief 同期を行わない。 */ Nothing = 2, }; } namespace asd { /** @brief 子オブジェクトの描画に関する同期の設定を表すフラグを提供するクラス。 */ class ChildDrawingMode { public: typedef int Flags; enum : Flags { /** @brief 何も同期しない。 */ Nothing = 0, /** @brief 描画の際に親の色を子に乗算する。 */ Color = 1, /** @brief 描画の際に親の描画優先度を子の描画優先度に足す。 */ DrawingPriority = 2, }; }; } namespace asd { class MapObject2D; /** @brief マップオブジェクト2Dで描画するテクスチャの情報を扱うチップクラス。 */ class Chip2D { friend class MapObject2D; private: std::shared_ptr<Texture2D> m_texture; std::shared_ptr<CoreChip2D> m_coreObject; protected: std::shared_ptr<CoreChip2D> GetCoreObject() const; public: Chip2D(); ~Chip2D(){} /** @brief 描画するテクスチャを設定する。 @param texture 描画するテクスチャ */ void SetTexture(std::shared_ptr<Texture2D> texture); /** @brief 描画するテクスチャを取得する。 @return 描画するテクスチャ */ std::shared_ptr<Texture2D> GetTexture(); /** @brief このチップのテクスチャ上の描画範囲を取得する。 @return テクスチャ上の描画範囲 */ RectF GetSrc() const; /** @brief このチップのテクスチャ上の描画範囲を設定する。 @param src テクスチャ上の描画範囲 */ void SetSrc(RectF src); /** @brief このチップのマップオブジェクト2Dに対する相対的な位置を取得する。 @return 相対的な描画位置 */ Vector2DF GetPosition() const; /** @brief このチップのマップオブジェクト2Dに対する相対的な位置を設定する。 @param position 相対的な描画位置 */ void SetPosition(Vector2DF position); /** @brief このチップのマップオブジェクト2Dに対する相対的な回転角度を取得する。 @return 相対的な回転角度 */ float GetAngle() const; /** @brief このチップのマップオブジェクト2Dに対する相対的な回転角度を設定する。 @param angle 相対的な回転角度 */ void SetAngle(float angle); /** @brief このチップのマップオブジェクト2Dに対する相対的な拡大率を取得する。 @return 相対的な拡大率 */ Vector2DF GetScale() const; /** @brief このチップのマップオブジェクト2Dに対する相対的な拡大率を設定する。 @param scale 相対的な拡大率 */ void SetScale(Vector2DF scale); /** @brief このチップを描画する際の中心座標を取得する。 @return 描画の際の中心座標 */ Vector2DF GetCenterPosition() const; /** @brief このチップを描画する際の中心座標を取得する。 @param position 描画の際の中心座標 */ void SetCenterPosition(Vector2DF position); /** @brief このチップのテクスチャを描画する際に合成する色を取得する。 @return 合成する色 */ Color GetColor() const; /** @brief このチップのテクスチャを描画する際に合成する色を設定する。 @param color 合成する色 */ void SetColor(Color color); /** @brief このチップのテクスチャ描画の左右反転フラグを取得する。 @return テクスチャ描画の左右反転フラグ */ bool GetTurnLR() const; /** @brief このチップのテクスチャ描画の左右反転フラグを設定する。 @param turnLR テクスチャ描画の左右反転フラグ */ void SetTurnLR(bool turnLR); /** @brief このチップのテクスチャ描画の上下反転フラグを取得する。 @return テクスチャ描画の上下反転フラグ */ bool GetTurnUL() const; /** @brief このチップのテクスチャ描画の上下反転フラグを設定する。 @param turnLR テクスチャ描画の上下反転フラグ */ void SetTurnUL(bool turnUL); /** @brief このチップの描画優先度を取得する。 @return 描画優先度 */ int GetDrawingPriority() const; /** @brief このチップの描画優先度を設定する。 @param 描画優先度 */ void SetDrawingPriority(int priority); /** @brief このチップのブレンディング モードを取得する。 @return ブレンディング モード */ AlphaBlendMode GetAlphaBlendMode() const; /** @brief このチップのブレンディング モードを設定する。 @param alphaBlend ブレンディング モード */ void SetAlphaBlendMode(AlphaBlendMode alphaBlend); /** @brief このチップのテクスチャを描画する際のテクスチャフィルタの種類を設定する。 @param textureFilterType テクスチャフィルタのタイプ */ void SetTextureFilterType(TextureFilterType textureFilterType); /** @brief このチップのテクスチャを描画する際のテクスチャフィルタの種類を取得する。 @return テクスチャフィルタのタイプ */ TextureFilterType GetTextureFilterType() const; }; } #include <memory> #include <list> #include <functional> namespace asd { class Layer2D; template<typename TObject> class ObjectManager; class EventToManageFamilyship2D; class EventToManageDrawnFamilyship2D; /** @brief 画面上に描画される2Dオブジェクトを表すクラス。 */ class Object2D : public std::enable_shared_from_this<Object2D> , public IComponentRegisterable<Object2DComponent> , public IImmediatelyDisposable { friend class Layer2D; friend class DrawnObject2D; friend class ObjectManager<Object2D>; friend class Object2DComponent; friend class EventToManageFamilyship2D; friend class EventToManageDrawnFamilyship2D; public: typedef std::shared_ptr<Object2D> Ptr; private: class ParentInfo2D { private: Object2D* m_parent; ChildManagementMode::Flags m_managementMode; public: typedef std::shared_ptr<ParentInfo2D> Ptr; ParentInfo2D(Object2D* parent, ChildManagementMode::Flags managementMode) : m_parent(parent) , m_managementMode(managementMode) { } Object2D* GetParent() const { return m_parent; } ChildManagementMode::Flags GetManagementMode() const { return m_managementMode; } }; Layer2D* m_owner; ParentInfo2D::Ptr m_parentInfo; std::list<Object2D::Ptr> m_children; std::shared_ptr<ComponentManager<Object2DComponent>> m_componentManager; bool m_isUpdated; bool m_isDrawn; int m_updatePriority; std::function<void(int)> m_onUpdatePriorityChanged; void RaiseOnAdded(); void RaiseOnRemoved(); void Update(); void DrawAdditionally(); void SetLayer(Layer2D* layer); virtual CoreObject2D* GetCoreObject() const = 0; void SyncContainerWithChild(const Object2D::Ptr& child); void Register(const Object2DComponent::Ptr& component); void Unregister(const Object2DComponent::Ptr& component); void DisposeImmediately(); void ImmediatelyRemoveComponent(astring key); void ImmediatelyAddChild( const Object2D::Ptr& child, ChildManagementMode::Flags managementMode, ChildTransformingMode transformingMode); void ImmediatelyRemoveChild(const Object2D::Ptr& child); protected: /** @brief オーバーライドして、この2Dオブジェクトがレイヤーに登録されたときの処理を記述できる。 */ virtual void OnAdded(); /** @brief オーバーライドして、この2Dオブジェクトがレイヤーから登録解除されたときの処理を記述できる。 */ virtual void OnRemoved(); /** @brief オーバーライドして、この2Dオブジェクトが破棄される際の処理を記述できる。 */ virtual void OnDispose(); /** @brief オーバーライドして、このオブジェクトの更新処理を記述できる。 */ virtual void OnUpdate(); /** @brief オーバーライドして、このオブジェクトに対する追加の描画処理を記述できる。 */ virtual void OnDrawAdditionally(); /** @brief 通常の描画に加えてテクスチャを描画する。 @param upperLeftPos テクスチャの左上の描画位置 @param upperRightPos テクスチャの右上の描画位置 @param lowerRightPos テクスチャの右下の描画位置 @param lowerLeftPos テクスチャの左下の描画位置 @param upperLeftCol テクスチャの左上の頂点色 @param upperRightCol テクスチャの右上の頂点色 @param lowerRightCol テクスチャの右下の頂点色 @param lowerLeftCol テクスチャの左下の頂点色 @param upperLeftUV テクスチャの左上のUV値 @param upperRightUV テクスチャの右上のUV値 @param lowerRightUV テクスチャの右下のUV値 @param lowerLeftUV テクスチャの左下のUV値 @param texture 描画するテクスチャ @param alphaBlend アルファブレンドの種類 @param priority 描画の優先順位(大きいほど前面に描画される) @note OnDrawAdditionallyの中以外では実行してはいけない。 */ void DrawSpriteAdditionally(Vector2DF upperLeftPos, Vector2DF upperRightPos, Vector2DF lowerRightPos, Vector2DF lowerLeftPos, Color upperLeftCol, Color upperRightCol, Color lowerRightCol, Color lowerLeftCol, Vector2DF upperLeftUV, Vector2DF upperRightUV, Vector2DF lowerRightUV, Vector2DF lowerLeftUV, std::shared_ptr<Texture2D> texture, AlphaBlendMode alphaBlend, int32_t priority); /** @brief 通常の描画に加えて専用のシェーダーを用いて2Dスプライトを描画する。 @param upperLeftPos テクスチャの左上の描画位置 @param upperRightPos テクスチャの右上の描画位置 @param lowerRightPos テクスチャの右下の描画位置 @param lowerLeftPos テクスチャの左下の描画位置 @param upperLeftCol テクスチャの左上の頂点色 @param upperRightCol テクスチャの右上の頂点色 @param lowerRightCol テクスチャの右下の頂点色 @param lowerLeftCol テクスチャの左下の頂点色 @param upperLeftUV テクスチャの左上のUV値 @param upperRightUV テクスチャの右上のUV値 @param lowerRightUV テクスチャの右下のUV値 @param lowerLeftUV テクスチャの左下のUV値 @param material 表示に使用するマテリアル @param alphaBlend アルファブレンドの種類 @param priority 描画の優先順位(大きいほど前面に描画される) @note 専用のシェーダーを用いてスプライトを描画する。 OnDrawAdditionallyの中以外では実行してはいけない。 */ void DrawSpriteWithMaterialAdditionally(Vector2DF upperLeftPos, Vector2DF upperRightPos, Vector2DF lowerRightPos, Vector2DF lowerLeftPos, Color upperLeftCol, Color upperRightCol, Color lowerRightCol, Color lowerLeftCol, Vector2DF upperLeftUV, Vector2DF upperRightUV, Vector2DF lowerRightUV, Vector2DF lowerLeftUV, std::shared_ptr<Material2D> material, AlphaBlendMode alphaBlend, int32_t priority); /** @brief 通常の描画に加えて文字列を描画する。 @param pos 描画位置 @param color 頂点色 @param font フォント @param text 文字列 @param writingDirection 行方向 @param alphaBlend アルファブレンドの種類 @param priority 描画の優先順位(大きいほど前面に描画される) @note OnDrawAdditionallyの中以外では実行してはいけない。 */ void DrawTextAdditionally(Vector2DF pos, Color color, std::shared_ptr<Font> font, const achar* text, WritingDirection writingDirection, AlphaBlendMode alphaBlend, int32_t priority); void DrawRectangleAdditionally(RectF drawingArea, Color color, RectF uv, std::shared_ptr<Texture2D> texture, AlphaBlendMode alphaBlend, int32_t priority); void DrawRotatedRectangleAdditionally(RectF drawingArea, Color color, Vector2DF rotationCenter, float angle, RectF uv, std::shared_ptr<Texture2D> texture, AlphaBlendMode alphaBlend, int32_t priority); void DrawTriangleAdditionally(Vector2DF position1, Vector2DF position2, Vector2DF position3, Color color, Vector2DF uv1, Vector2DF uv2, Vector2DF uv3, std::shared_ptr<Texture2D> texture, AlphaBlendMode alphaBlend, int32_t priority); void DrawCircleAdditionally(asd::Vector2DF center, float outerDiameter, float innerDiameter, Color color, int vertNum, float angle, std::shared_ptr<Texture2D> texture, AlphaBlendMode alphaBlend, int32_t priority); void DrawArcAdditionally(asd::Vector2DF center, float outerDiameter, float innerDiameter, Color color, int vertNum, int startingVerticalAngle, int endingVerticalAngle, float angle, std::shared_ptr<Texture2D> texture, AlphaBlendMode alphaBlend, int32_t priority); void DrawLineAdditionally(Vector2DF point1, Vector2DF point2, float thickness, Color color, AlphaBlendMode alphaBlend, int32_t priority); void DrawShapeAdditionally(std::shared_ptr<Shape> shape, Color color, std::shared_ptr<Texture2D> texture, AlphaBlendMode alphaBlend, int32_t priority); public: /** @brief コンストラクタ */ Object2D(); /** @brief デストラクタ */ virtual ~Object2D(); /** @brief カメラに表示するグループを取得する。 @return グループ @note カメラのグループと他のオブジェクトのグループで&でビット演算して1以上だった場合、そのカメラにオブジェクトが描画されるようになる。 */ int32_t GetCameraGroup() const; /** @brief カメラに表示するグループを設定する。 @param group グループ */ void SetCameraGroup(int32_t group); /** @brief このオブジェクトが更新されるかどうかを取得する。 */ bool GetIsUpdated() const; /** @brief このオブジェクトが更新されるかどうかを設定する。 */ void SetIsUpdated(bool value); /** @brief このオブジェクトが描画されるかどうかを取得する。 */ bool GetIsDrawn() const; /** @brief このオブジェクトが描画されるかどうかを設定する。 */ void SetIsDrawn(bool value); /** @brief このオブジェクトが実行中かどうかを取得する。Vanishメソッドによって破棄された時に false を返す。 */ bool GetIsAlive() const; /** @brief このオブジェクトを破棄する。 */ void Dispose(); /** @brief このオブジェクトを保持しているレイヤーを取得する。 */ Layer2D* GetLayer() const; /** @brief 指定した2Dオブジェクトを子オブジェクトとしてこのインスタンスに追加する。 @param child 追加する子オブジェクト @param managementMode 子オブジェクトの管理に関する同期設定。フラグをOR演算でつなげて複数指定することができる。 @param transformingmode 子オブジェクトの変形に関する同期設定。 */ void AddChild(const Object2D::Ptr& child, ChildManagementMode::Flags managementMode, ChildTransformingMode transformingMode); /** @brief 指定した子オブジェクトをこのインスタンスから削除する。 @param child 削除する子オブジェクト */ void RemoveChild(const Object2D::Ptr& child); /** @brief このオブジェクトが保持している子オブジェクトを含むコンテナを取得する。 */ const std::list<Object2D::Ptr>& GetChildren() const; /** @brief このオブジェクトの親オブジェクトを取得する。親がいなければnullptrを返す。 */ Object2D* GetParent() const; /** @brief 指定したコンポーネントをこのインスタンスに追加する。 @param component 追加するコンポーネント @param key コンポーネントに関連付けるキー */ void AddComponent(const Object2DComponent::Ptr& component, astring key); /** @brief 指定したキーを持つコンポーネントを取得する。 @param key 取得するコンポーネントを示すキー */ Object2DComponent::Ptr GetComponent(astring key); /** @brief 指定したコンポーネントを削除する。 @param key 削除するコンポーネントを示すキー */ bool RemoveComponent(astring key); /** @brief このオブジェクトを描画する位置を取得する。 */ Vector2DF GetPosition() const; /** @brief このオブジェクトを描画する位置を設定する。 */ void SetPosition(Vector2DF position); /** @brief このオブジェクトを描画する実際の位置を取得する。親子関係がある場合に、親の位置を考慮した値を取得できる。 */ Vector2DF GetGlobalPosition(); /** @brief このオブジェクトを描画する際の回転角度を取得する。 @note 回転角度は度で表記され、回転方向は時計回りである。 */ float GetAngle() const; /** @brief このオブジェクトを描画する際の回転角度を設定する。 @note 回転角度は度で表記され、回転方向は時計回りである。 */ void SetAngle(float value); /** @brief このオブジェクトを描画する際の拡大率を取得する。 */ Vector2DF GetScale() const; /** @brief このオブジェクトを描画する際の拡大率を設定する。 */ void SetScale(Vector2DF value); /** @brief このオブジェクトの更新の優先順位を取得する。 */ int GetUpdatePriority() const; /** @brief このオブジェクトの更新の優先順位を設定する。 */ void SetUpdatePriority(int value); /** @brief このオブジェクトが親子関係を考慮して最終的に更新されるかどうかの真偽値を取得します。 */ bool GetAbsoluteBeingUpdated() const; /** @brief このオブジェクトが親子関係を考慮して最終的に描画されるかどうかの真偽値を取得します。 */ bool GetAbsoluteBeingDrawn() const; }; } #include <memory> namespace asd { class EventToManageDrawnFamilyship2D; class DrawnObject2D : public Object2D { friend class EventToManageDrawnFamilyship2D; public: typedef std::shared_ptr<DrawnObject2D> Ptr; private: virtual CoreDrawnObject2D* GetCoreDrawnObject() const = 0; void ImmediatelyAddDrawnChild( const DrawnObject2D::Ptr& child, ChildManagementMode::Flags managementMode, ChildTransformingMode transformingMode, ChildDrawingMode::Flags drawingMode); public: /** @brief 描画する際に合成する色を取得する。 */ Color GetColor() const; /** @brief 描画する際に合成する色を設定する。 */ void SetColor(Color value); /** @brief このオブジェクトの描画優先度を取得する。 */ int GetDrawingPriority() const; /** @brief このオブジェクトの描画優先度を設定する。 */ void SetDrawingPriority(int value); /** @brief 親子関係を考慮して最終的に描画時にこのオブジェクトに合成する色を取得する。 */ Color GetAbsoluteColor() const; /** @brief 親子関係を考慮したこのオブジェクトの最終的な描画優先度を取得する。 */ int GetAbsoluteDrawingPriority() const; /** @brief 描画に関する同期設定を指定して、指定した2Dオブジェクトを子オブジェクトとしてこのインスタンスに追加する。 @param child 追加する子オブジェクト @param managementMode 子オブジェクトの管理に関する同期設定。フラグをOR演算でつなげて複数指定することができる。 @param transformingmode 子オブジェクトの変形に関する同期設定。 @param drawingMode 子オブジェクトの描画に関する同期設定。フラグをOR演算でつなげて複数指定することができる。 */ void AddDrawnChild( const DrawnObject2D::Ptr& child, ChildManagementMode::Flags managementMode, ChildTransformingMode transformingMode, ChildDrawingMode::Flags drawingMode); }; } #include <memory> namespace asd { /** @brief テクスチャを描画するクラス。 */ class TextureObject2D : public DrawnObject2D { private: std::shared_ptr<CoreTextureObject2D> m_coreObject; std::shared_ptr<Texture2D> m_texturePtr; CoreObject2D* GetCoreObject() const; CoreDrawnObject2D* GetCoreDrawnObject() const override; public: typedef std::shared_ptr<TextureObject2D> Ptr; /** @brief コンストラクタ */ TextureObject2D(); /** @brief デストラクタ */ virtual ~TextureObject2D(); /** @brief 描画するテクスチャを取得する。 */ std::shared_ptr<Texture2D> GetTexture() const; /** @brief 描画するテクスチャを設定する。 */ void SetTexture(std::shared_ptr<Texture2D> texture); /** @brief テクスチャ上の描画範囲を取得する。 */ RectF GetSrc() const; /** @brief テクスチャ上の描画範囲を設定する。 @param value 描画するテクスチャ上の範囲。(フィールドのいずれかが0より小さかったらテクスチャ全体を描画する。) */ void SetSrc(RectF value); /** @brief 描画する際の中心座標を取得する。 */ Vector2DF GetCenterPosition() const; /** @brief 描画する際の中心座標を設定する。 */ void SetCenterPosition(Vector2DF position); /** @brief 左右反転して描画するかどうかを取得する。 */ bool GetTurnLR() const; /** @brief 左右反転して描画するかどうかを設定する。 */ void SetTurnLR(bool turnLR); /** @brief 上下反転して描画するかどうかを取得する。 */ bool GetTurnUL() const; /** @brief 上下反転して描画するかどうかを設定する。 */ void SetTurnUL(bool turnUL); /** @brief このオブジェクトのブレンディング モードを取得する。 */ AlphaBlendMode GetAlphaBlendMode() const; /** @brief このオブジェクトのブレンディング モードを設定する。 */ void SetAlphaBlendMode(AlphaBlendMode alphaBlend); /** @brief このオブジェクトを描画する際のテクスチャフィルタの種類を設定する。 */ void SetTextureFilterType(TextureFilterType textureFilterType); /** @brief このオブジェクトを描画する際のテクスチャフィルタの種類を取得する。 */ TextureFilterType GetTextureFilterType() const; }; } namespace asd { /** @brief 2Dレイヤーの一部を描画するためのカメラ */ class CameraObject2D : public Object2D { private: std::shared_ptr<CoreCameraObject2D> m_coreObject; CoreObject2D* GetCoreObject() const; public: typedef std::shared_ptr<CameraObject2D> Ptr; CameraObject2D(); virtual ~CameraObject2D(); /** @brief 描画元の領域を取得する。 @return 描画元 */ RectI GetSrc() const; /** @brief 描画元の領域を設定する。 @param value 描画元 */ void SetSrc(RectI value); /** @brief 描画先の領域を取得する。 @return 描画先 */ RectI GetDst() const; /** @brief 描画先の領域を設定する。 @param value 描画先 */ void SetDst(RectI value); /** @brief 画面に描画せずにテクスチャに描画するか、を取得する。 @return 画面に描画せずにテクスチャに描画するか */ bool GetIsOffscreenMode(); /** @brief 画面に描画せずにテクスチャに描画するか、を設定する。 @param value 画面に描画せずにテクスチャに描画するか */ void SetIsOffscreenMode(bool value); /** @brief カメラが描画した結果をテクスチャとして取得する。 @return 描画結果 */ std::shared_ptr<Texture2D> GetTexture(); /** @brief カメラが描画した結果を描画する際のテクスチャフィルタの種類を設定する。 */ void SetTextureFilterType(TextureFilterType textureFilterType); /** @brief カメラが描画した結果を描画する際のテクスチャフィルタの種類を取得する。 */ TextureFilterType GetTextureFilterType() const; }; } namespace asd { /** @brief 文字列の描画を扱うクラス。 */ class TextObject2D : public DrawnObject2D { private: std::shared_ptr<CoreTextObject2D> m_coreObject; std::shared_ptr<Font> m_font; CoreObject2D* GetCoreObject() const; CoreDrawnObject2D* GetCoreDrawnObject() const override; public: typedef std::shared_ptr<TextObject2D> Ptr; TextObject2D(); virtual ~TextObject2D(); /** @brief このオブジェクトを描画する際の描画方向を取得する。 */ WritingDirection GetWritingDirection() const; /** @brief このオブジェクトを描画する際のフォントを取得する。 */ std::shared_ptr<Font> GetFont() const; /** @brief 描画するテキストを取得する。 */ const achar* GetText(); /** @brief このオブジェクトの原点位置を取得する。この位置が、描画する際の描画・拡縮・回転の中心となる。 */ Vector2DF GetCenterPosition() const; /** @brief このオブジェクトを描画する際に左右反転するかどうかの真偽値を取得する。 */ bool GetTurnLR() const; /** @brief このオブジェクトを描画する際に上下反転するかどうかの真偽値を取得する。 */ bool GetTurnUL() const; /** @brief このオブジェクトを描画する際のブレンドモードを取得します。 */ AlphaBlendMode GetAlphaBlendMode() const; /** @brief このオブジェクトを描画する際の描画方向を設定します。 */ void SetWritingDirection(WritingDirection writingDirection); /** @brief このオブジェクトを描画する際のフォントを設定する。 */ void SetFont(std::shared_ptr<Font> font); /** @brief 描画するテキストを設定する。 */ void SetText(const achar* text); /** @brief このオブジェクトの原点位置を設定する。この位置が、描画する際の描画・拡縮・回転の中心となる。 */ void SetCenterPosition(Vector2DF position); /** @brief このオブジェクトを描画する際に左右反転するかどうかの真偽値を設定する。 */ void SetTurnLR(bool turnLR); /** @brief このオブジェクトを描画する際に上下反転するかどうかの真偽値を設定する。 */ void SetTurnUL(bool turnUL); /** @brief このオブジェクトを描画する際のブレンドモードを設定する。 */ void SetAlphaBlendMode(AlphaBlendMode alphaBlend); /** @brief このオブジェクトを描画する際のテクスチャフィルタの種類を設定する。 */ void SetTextureFilterType(TextureFilterType textureFilterType); /** @brief このオブジェクトを描画する際のテクスチャフィルタの種類を取得する。 */ TextureFilterType GetTextureFilterType() const; /** @brief テキストを描画する際の文字間値を設定する。 */ void SetLetterSpacing(float letterSpacing); /** @brief テキストを描画する際の文字間値を取得する。 */ float GetLetterSpacing() const; /** @brief テキストを描画する際の行間値を設定する。 */ void SetLineSpacing(float lineSpacing); /** @brief テキストを描画する際の行間値を取得する。 */ float GetLineSpacing() const; }; } namespace asd { class EffectObject2D : public Object2D { private: std::shared_ptr<CoreEffectObject2D> m_coreObject; CoreObject2D* GetCoreObject() const; public: typedef std::shared_ptr<EffectObject2D> Ptr; EffectObject2D(); virtual ~EffectObject2D(); /** @brief 描画に使用するエフェクトを取得する。 @return エフェクト */ std::shared_ptr<Effect> GetEffect(); /** @brief 描画に使用するエフェクトを設定する。 @param effect エフェクト */ void SetEffect(std::shared_ptr<Effect> effect); /** @brief 設定されている全てのエフェクトを再生する。 @return 再生されたエフェクトのID */ int32_t Play(); /** @brief このオブジェクトから再生されたエフェクトを全て停止する。 */ void Stop(); /** @brief このオブジェクトから再生されたエフェクトのルートを全て停止する。 */ void StopRoot(); /** @brief このオブジェクトから再生されたエフェクトを表示状態にする。 */ void Show(); /** @brief このオブジェクトから再生されたエフェクトを非表示状態にする。 */ void Hide(); /** @brief このオブジェクトから再生されたエフェクトが再生中か取得する。 @return 再生中か? */ bool GetIsPlaying(); /** @brief このオブジェクトから再生されたエフェクトをオブジェクトに合わせて移動させるか取得する。 @return フラグ */ bool GetSyncEffects(); /** @brief このオブジェクトから再生されたエフェクトをオブジェクトに合わせて移動させるか設定する。 @param value フラグ */ void SetSyncEffects(bool value); /** @brief このオブジェクトから再生されるエフェクトの角度(X軸)を取得する。 @return value 回転量(度) @note */ float GetEffectRotationX() const; /** @brief このオブジェクトから再生されるエフェクトの角度(X軸)を指定する。 @param value 回転量(度) @note エフェクトの形状が画面に垂直な方向に長い場合、2D表示では予期せぬ見た目で表示されることがある。 この時、X軸を中心にエフェクトを回転することで、違和感のない表示をできるようにする。 */ void SetEffectRotationX(float value); /** @brief このオブジェクトから再生されるエフェクトの角度(Y軸)を取得する。 @return value 回転量(度) @note */ float GetEffectRotationY() const; /** @brief このオブジェクトから再生されるエフェクトの角度(Y軸)を指定する。 @param value 回転量(度) @note エフェクトの形状が画面に垂直な方向に長い場合、2D表示では予期せぬ見た目で表示されることがある。 この時、Y軸を中心にエフェクトを回転することで、違和感のない表示をできるようにする。 */ void SetEffectRotationY(float value); /** @brief このオブジェクトから再生されるエフェクトの向きを取得する。 @return value 回転量(度) @note 互換性のために残されている。 */ float GetEffectRotation() const; /** @brief このオブジェクトから再生されるエフェクトの向きを指定する。 @param value 回転量(度) @note 2D表示だとエフェクトが画面に対して前後に表示されるように作成されていた場合、予期せぬ見た目で表示されてしまうことがある。 そのため、Y軸を中心にエフェクトを回転させ2Dとして違和感のない表示ができるようにする。 互換性のために残されている。 */ void SetEffectRotation(float value); /** @brief このオブジェクトの描画優先度を取得する。 */ int GetDrawingPriority() const; /** @brief このオブジェクトの描画優先度を設定する。 */ void SetDrawingPriority(int priority); }; } #include <memory> namespace asd { /** @brief テクスチャをチップとして高速に描画するクラス。 */ class MapObject2D : public Object2D { friend class Chip2D; private: std::shared_ptr<CoreMapObject2D> m_coreObject; std::vector<std::shared_ptr<Chip2D>> m_chips; CoreObject2D* GetCoreObject() const; public: typedef std::shared_ptr<MapObject2D> Ptr; /** @brief コンストラクタ */ MapObject2D(); /** @brief デストラクタ */ virtual ~MapObject2D(); /** @brief このオブジェクトの原点位置を取得する。この位置が、描画する際の描画・拡縮・回転の中心となる。 */ Vector2DF GetCenterPosition() const; /** @brief このオブジェクトの描画優先度を取得します。 */ int GetDrawingPriority() const; /** @brief このオブジェクトの原点位置を設定する。この位置が、描画する際の描画・拡縮・回転の中心となる。 */ void SetCenterPosition(Vector2DF position); /** @brief このオブジェクトの描画優先度を設定する。 */ void SetDrawingPriority(int priority); /** @brief このオブジェクトに描画チップを追加する。 */ bool AddChip(std::shared_ptr<Chip2D> chip); /** @brief このオブジェクトから描画チップを削除する。 */ bool RemoveChip(std::shared_ptr<Chip2D> chip); /** @brief このオブジェクトに追加されている描画チップを全て削除する。 */ void Clear(); /** @brief このオブジェクトが保有しているチップを全て取得する。 */ std::vector<std::shared_ptr<Chip2D>>& GetChips(); }; } namespace asd { /** @brief 図形の描画を扱うクラス。 */ class GeometryObject2D : public DrawnObject2D { private: std::shared_ptr<CoreGeometryObject2D> m_coreObject; std::shared_ptr<Texture2D> texturePtr; std::shared_ptr<Shape> shapePtr; CoreObject2D* GetCoreObject() const; CoreDrawnObject2D* GetCoreDrawnObject() const override; public: typedef std::shared_ptr<GeometryObject2D> Ptr; GeometryObject2D(); virtual ~GeometryObject2D(); /** @brief 描画に使用する図形を取得する。 @return 図形 */ std::shared_ptr<Shape> GetShape() const ; /** @brief 描画に使用する図形を設定する。 @param shape 図形 */ void SetShape(std::shared_ptr<Shape> shape); /** @brief このオブジェクトのブレンディング モードを取得する。 @return ブレンディングモード */ AlphaBlendMode GetAlphaBlendMode() const; /** @brief このオブジェクトのブレンディング モードを設定する。 @param alphaBlend ブレンディングモード */ void SetAlphaBlendMode(AlphaBlendMode alphaBlend); /** @brief このオブジェクトを描画する際の中心座標を設定する。 @param centerPosition 描画する際の中心座標 */ void SetCenterPosition(Vector2DF centerPosition); /** @brief このオブジェクトを描画する際の中心座標を取得する。 @return 描画する際の中心座標 */ Vector2DF GetCenterPosition() const; /** @brief このオブジェクトを描画する際のテクスチャフィルタの種類を設定する。 @param textureFilterType 描画する際のテクスチャフィルタの種類 */ void SetTextureFilterType(TextureFilterType textureFilterType); /** @brief このオブジェクトを描画する際のテクスチャフィルタの種類を取得する。 @return 描画する際のテクスチャフィルタの種類 */ TextureFilterType GetTextureFilterType() const; /** @brief このオブジェクトを描画に使用するエフェクトを設定する。 @param texture テクスチャ */ void SetTexture(std::shared_ptr<Texture2D> texture); /** @brief このオブジェクトを描画に使用するエフェクトを取得する。 @return テクスチャ */ std::shared_ptr<Texture2D> GetTexture() const; }; } #include <memory> #include <list> #include <map> namespace asd { template<typename TObject> class ObjectManager; template<typename TComponent> class ComponentManager; /** @brief 2Dオブジェクトの更新と描画を管理するレイヤーの機能を提供する抽象クラス。 */ class Layer2D : public Layer , public IObjectRegisterable<Object2D> , public IComponentRegisterable<Layer2DComponent> { friend class Scene; friend class Object2D; friend class Layer2DComponent; public: typedef std::shared_ptr<Layer2D> Ptr; private: std::shared_ptr<CoreLayer2D> m_coreLayer; std::shared_ptr<ObjectManager<Object2D>> m_objects; std::shared_ptr<ComponentManager<Layer2DComponent>> m_components; void BeginUpdating() override; void EndUpdateting() override; void UpdateInternal() override; void DrawAdditionally() override; void DisposeInternal() override; void ImmediatelyRemoveObject(const Object2D::Ptr& object, bool raiseEvent); void ImmediatelyRemoveComponent(astring key); void Register(const Object2D::Ptr& object); void Unregister(const Object2D::Ptr& object); void AddToCore(const Object2D::Ptr& object) override; void RemoveFromCore(const Object2D::Ptr& object) override; void Register(const Layer2DComponent::Ptr& component) override; void Unregister(const Layer2DComponent::Ptr& component) override; void RaiseOnAdded() override; void RaiseOnRemoved() override; protected: public: /** @brief コンストラクタ */ Layer2D(); /** @brief デストラクタ */ virtual ~Layer2D(); bool GetIsAlive() const; /** @brief 指定した2Dオブジェクトをこのインスタンスに追加する。 @param object 追加するオブジェクト */ void AddObject(const Object2D::Ptr& object); /** @brief 指定した2Dオブジェクトをこのインスタンスから削除する。 @param object 削除するオブジェクト */ void RemoveObject(const Object2D::Ptr& object); /** @brief このレイヤーに登録されている2Dオブジェクトのリストを取得する。 @return 登録されているオブジェクトのリスト */ std::list<Object2D::Ptr> GetObjects() const; /** @brief レイヤーが所持する全ての2Dオブジェクトをこのインスタンスから削除する。 */ void Clear(); /** @brief 指定したコンポーネントをこのインスタンスに追加する。 @param component 追加するコンポーネント @param key コンポーネントに関連付けるキー */ void AddComponent(const Layer2DComponent::Ptr& component, astring key); /** @brief 指定したキーを持つコンポーネントを取得する。 @param key 取得するコンポーネントを示すキー */ Layer2DComponent::Ptr GetComponent(astring key); /** @brief 指定したコンポーネントをこのインスタンスから削除する。 @param key 削除するコンポーネントを示すキー */ bool RemoveComponent(astring key); /** @brief 通常の描画に加えてテクスチャを描画する。 @param upperLeftPos テクスチャの左上の描画位置 @param upperRightPos テクスチャの右上の描画位置 @param lowerRightPos テクスチャの右下の描画位置 @param lowerLeftPos テクスチャの左下の描画位置 @param upperLeftCol テクスチャの左上の頂点色 @param upperRightCol テクスチャの右上の頂点色 @param lowerRightCol テクスチャの右下の頂点色 @param lowerLeftCol テクスチャの左下の頂点色 @param upperLeftUV テクスチャの左上のUV値 @param upperRightUV テクスチャの右上のUV値 @param lowerRightUV テクスチャの右下のUV値 @param lowerLeftUV テクスチャの左下のUV値 @param texture 描画するテクスチャ @param alphaBlend アルファブレンドの種類 @param priority 描画の優先順位(大きいほど前面に描画される) @note OnDrawAdditionallyの中以外では実行してはいけない。 */ void DrawSpriteAdditionally(Vector2DF upperLeftPos, Vector2DF upperRightPos, Vector2DF lowerRightPos, Vector2DF lowerLeftPos, Color upperLeftCol, Color upperRightCol, Color lowerRightCol, Color lowerLeftCol, Vector2DF upperLeftUV, Vector2DF upperRightUV, Vector2DF lowerRightUV, Vector2DF lowerLeftUV, std::shared_ptr<Texture2D> texture, AlphaBlendMode alphaBlend, int32_t priority); /** @brief 通常の描画に加えて専用のシェーダーを用いて2Dスプライトを描画する。 @param upperLeftPos テクスチャの左上の描画位置 @param upperRightPos テクスチャの右上の描画位置 @param lowerRightPos テクスチャの右下の描画位置 @param lowerLeftPos テクスチャの左下の描画位置 @param upperLeftCol テクスチャの左上の頂点色 @param upperRightCol テクスチャの右上の頂点色 @param lowerRightCol テクスチャの右下の頂点色 @param lowerLeftCol テクスチャの左下の頂点色 @param upperLeftUV テクスチャの左上のUV値 @param upperRightUV テクスチャの右上のUV値 @param lowerRightUV テクスチャの右下のUV値 @param lowerLeftUV テクスチャの左下のUV値 @param material 表示に使用するマテリアル @param alphaBlend アルファブレンドの種類 @param priority 描画の優先順位(大きいほど前面に描画される) @note 専用のシェーダーを用いてスプライトを描画する。 OnDrawAdditionallyの中以外では実行してはいけない。 */ void DrawSpriteWithMaterialAdditionally(Vector2DF upperLeftPos, Vector2DF upperRightPos, Vector2DF lowerRightPos, Vector2DF lowerLeftPos, Color upperLeftCol, Color upperRightCol, Color lowerRightCol, Color lowerLeftCol, Vector2DF upperLeftUV, Vector2DF upperRightUV, Vector2DF lowerRightUV, Vector2DF lowerLeftUV, std::shared_ptr<Material2D> material, AlphaBlendMode alphaBlend, int32_t priority); /** @brief 通常の描画に加えて文字列を描画する。 @param pos 描画位置 @param color 頂点色 @param font フォント @param text 文字列 @param writingDirection 行方向 @param alphaBlend アルファブレンドの種類 @param priority 描画の優先順位(大きいほど前面に描画される) @note OnDrawAdditionallyの中以外では実行してはいけない。 */ void DrawTextAdditionally(Vector2DF pos, Color color, std::shared_ptr<Font> font, const achar* text, WritingDirection writingDirection, AlphaBlendMode alphaBlend, int32_t priority); void DrawRectangleAdditionally(RectF drawingArea, Color color, RectF uv, std::shared_ptr<Texture2D> texture, AlphaBlendMode alphaBlend, int32_t priority); void DrawRotatedRectangleAdditionally(RectF drawingArea, Color color, Vector2DF rotationCenter, float angle, RectF uv, std::shared_ptr<Texture2D> texture, AlphaBlendMode alphaBlend, int32_t priority); void DrawTriangleAdditionally(Vector2DF position1, Vector2DF position2, Vector2DF position3, Color color, Vector2DF uv1, Vector2DF uv2, Vector2DF uv3, std::shared_ptr<Texture2D> texture, AlphaBlendMode alphaBlend, int32_t priority); void DrawCircleAdditionally(asd::Vector2DF center, float outerDiameter, float innerDiameter, Color color, int vertNum, float angle, std::shared_ptr<Texture2D> texture, AlphaBlendMode alphaBlend, int32_t priority); void DrawArcAdditionally(asd::Vector2DF center, float outerDiameter, float innerDiameter, Color color, int vertNum, int startingVerticalAngle, int endingVerticalAngle, float angle, std::shared_ptr<Texture2D> texture, AlphaBlendMode alphaBlend, int32_t priority); void DrawLineAdditionally(Vector2DF point1, Vector2DF point2, float thickness, Color color, AlphaBlendMode alphaBlend, int32_t priority); void DrawShapeAdditionally(std::shared_ptr<Shape> shape, Color color, std::shared_ptr<Texture2D> texture, AlphaBlendMode alphaBlend, int32_t priority); /** @brief レイヤーの種類を取得する。 @return レイヤーの種類 */ LayerType GetLayerType() const override { return LayerType::Layer2D; } int GetObjectCount() const; }; } #include <functional> namespace asd { class Layer3D; template<class TObject> class ObjectManager; /** @brief 更新・描画処理を行う単位となる3Dオブジェクトの機能を提供するクラス */ class Object3D : public std::enable_shared_from_this<Object3D> , public IImmediatelyDisposable { friend class Layer3D; friend class ObjectManager<Object3D>; public: typedef std::shared_ptr<Object3D> Ptr; private: Layer3D* m_owner; bool m_isUpdated; bool m_isDrawn; bool m_isAlive; int m_updatePriority; std::function<void(int)> m_onUpdatePriorityChanged; void RaiseOnAdded(); void RaiseOnRemoved(); void Update(); void SetLayer(Layer3D* layer); CoreObject3D* GetCoreObject() const; void DisposeImmediately(); protected: CoreObject3D* m_commonObject; /** @brief ユーザーはオーバーライドしてはいけない。 */ virtual void OnUpdateInternal() {} protected: /** @brief オーバーライドして、この3Dオブジェクトがレイヤーに登録されたときの処理を記述できる。 */ virtual void OnAdded(); /** @brief オーバーライドして、この3Dオブジェクトがレイヤーから登録解除されたときの処理を記述できる。 */ virtual void OnRemoved(); /** @brief オーバーライドして、この3Dオブジェクトが破棄されるときの処理を記述できる。 */ virtual void OnDispose(); /** @brief オーバーライドして、この3Dオブジェクトの更新処理を記述することができる。 */ virtual void OnUpdate() = 0; /** @brief オーバーライドして、この3Dオブジェクトに関する追加の描画処理を記述できる。 */ virtual void OnDrawAdditionally() = 0; public: /** @brief コンストラクタ */ Object3D(); /** @brief デストラクタ */ virtual ~Object3D(); /** @brief オブジェクトの更新を実行するかどうか取得する。 */ bool GetIsUpdated() const; /** @brief オブジェクトの更新を実行するかどうか設定する。 @param value オブジェクトの更新を実行するかどうか */ void SetIsUpdated(bool value); /** @brief オブジェクトを描画するどうか取得する。 */ bool GetIsDrawn() const; /** @brief オブジェクトを描画するどうか設定する。 @param value オブジェクトを描画するどうか */ void SetIsDrawn(bool value); /** @brief オブジェクトが生存しているか取得する。 @return 生存しているか */ bool GetIsAlive() const; /** @brief オブジェクトを破棄する。 */ void Dispose(); /** @brief このインスタンスを管理している asd.Layer3D クラスのインスタンスを取得する。 */ Layer3D* GetLayer() const; /** @brief このインスタンスの親に対する現在の座標を取得する。 @return 座標 */ Vector3DF GetPosition() const; /** @brief このインスタンスの親に対する現在の座標を設定する。 @param position 座標 */ void SetPosition(Vector3DF position); /** @brief このインスタンスの親に対する現在の角度を取得する。 @return 角度 */ Vector3DF GetRotation() const; /** @brief このインスタンスの親に対する現在の角度を設定する。 @param angle 角度 */ void SetRotation(Vector3DF angle); /** @brief このインスタンスの親に対する現在の拡大率を取得する。 @return 拡大率 */ Vector3DF GetScale() const; /** @brief このインスタンスの親に対する現在の拡大率を設定する。 @param scale 拡大率 */ void SetScale(Vector3DF scale); /** @brief モデル行列を直接取得する。 @return モデル行列 */ Matrix44 GetLocalMatrix(); /** @brief モデル行列を直接設定する。 @param localMat モデル行列 @note この値を設定した場合、通常の移動や回転は無効化される。 不具合が存在するため、一時的に無効化 */ //void SetLoalMatrixDirectly(Matrix44 localMat); /** @brief このインスタンスの更新の優先順位を取得する。 */ int GetUpdatePriority() const; /** @brief このインスタンスの更新の優先順位を設定する。 */ void SetUpdatePriority(int value); /** @brief 通常の描画に加えてテクスチャを描画する。 @param upperLeftPos テクスチャの左上の描画位置 @param upperRightPos テクスチャの右上の描画位置 @param lowerRightPos テクスチャの右下の描画位置 @param lowerLeftPos テクスチャの左下の描画位置 @param upperLeftCol テクスチャの左上の頂点色 @param upperRightCol テクスチャの右上の頂点色 @param lowerRightCol テクスチャの右下の頂点色 @param lowerLeftCol テクスチャの左下の頂点色 @param upperLeftUV テクスチャの左上のUV値 @param upperRightUV テクスチャの右上のUV値 @param lowerRightUV テクスチャの右下のUV値 @param lowerLeftUV テクスチャの左下のUV値 @param texture 描画するテクスチャ @param alphaBlend アルファブレンドの種類 @param depthWrite 深度を書き込むか? @param depthTest 深度を比較するか? @note OnDrawAdditionallyの中以外では実行してはいけない。 */ void DrawSpriteAdditionally(Vector3DF upperLeftPos, Vector3DF upperRightPos, Vector3DF lowerRightPos, Vector3DF lowerLeftPos, Color upperLeftCol, Color upperRightCol, Color lowerRightCol, Color lowerLeftCol, Vector2DF upperLeftUV, Vector2DF upperRightUV, Vector2DF lowerRightUV, Vector2DF lowerLeftUV, std::shared_ptr<Texture2D> texture, AlphaBlendMode alphaBlend, bool depthWrite, bool depthTest); }; } namespace asd { class PostEffect; /** @brief カメラの機能を提供するクラス */ class CameraObject3D : public Object3D { private: std::shared_ptr<CoreCameraObject3D> m_coreObject; std::vector<std::shared_ptr<PostEffect>> m_postEffects; void OnUpdateInternal() override; protected: /** @brief オーバーライドして、毎フレーム実行される更新処理を記述できる。 */ virtual void OnUpdate() {}; /** @brief オーバーライドして、追加の描画処理を記述できる。 */ virtual void OnDrawAdditionally() {}; public: CameraObject3D(); virtual ~CameraObject3D(); /** @brief 画面サイズを取得する。 @return 画面サイズ */ Vector2DI GetWindowSize() const; /** @brief 画面サイズを設定する。 @param size 画面サイズ */ void SetWindowSize(const Vector2DI& size); /** @brief カメラが見る座標を取得する。 @return カメラが見る座標 */ Vector3DF GetFocus(); /** @brief カメラが見る座標を設定する。 @param focus カメラが見る座標 */ void SetFocus(const Vector3DF& focus); /** @brief 画角を取得する。 @return 画角 */ float GetFieldOfView(); /** @brief 画角を設定する。 @param fov 画角 */ void SetFieldOfView(float fov); /** @brief 画角を取得する。 @return 画角 */ float GetZFar(); /** @brief 画角を設定する。 @param zfar 画角 */ void SetZFar(float zfar); /** @brief 描画する最遠距離を取得する。 @return 描画する最遠距離 */ float GetZNear(); /** @brief 描画する最近距離を設定する。 @param znear 描画する最近距離 */ void SetZNear(float znear); /** @brief プロジェクション行列を直接取得する。 @return プロジェクション行列 */ Matrix44 GetProjectionMatrixDirectly(); /** @brief プロジェクション行列を直接設定する。 @param projectionMatrix プロジェクション行列 @note この値を直接設定した場合、プロジェクション行列に関わるパラメーターは無効化される。 */ void SetProjectionMatrixDirectly(Matrix44 projectionMatrix); /** @brief 描画先のフォーマットがHDRか取得する。 @return HDRか? */ bool GetHDRMode() const; /** @brief 描画先のフォーマットをHDRにするか設定する。 @param value HDRか? */ void SetHDRMode(bool value); /** @brief ポストエフェクトを追加する。 @param postEffect ポストエフェクト */ void AddPostEffect(const std::shared_ptr<PostEffect>& postEffect); /** @brief ポストエフェクトを全て消去する。 */ void ClearPostEffects(); }; } namespace asd { /** @brief 無限遠光源の機能を提供するクラス */ class DirectionalLightObject3D : public Object3D { private: std::shared_ptr<CoreDirectionalLightObject3D> m_coreObject; protected: /** @brief オーバーライドして、毎フレーム実行される更新処理を記述できる。 */ virtual void OnUpdate() {}; /** @brief オーバーライドして、追加の描画処理を記述できる。 */ virtual void OnDrawAdditionally() {}; public: DirectionalLightObject3D(); virtual ~DirectionalLightObject3D(); /** @brief 光源の色を取得する。 @return 光源の色 */ Color GetColor(); /** @brief 光源の色を設定する。 @param color 光源の色 */ void SetColor(const Color& color); /** @brief 光源の強さを取得する。 @return 光源の強さ @note デフォルトは1.0である。 */ float GetIntensity(); /** @brief 光源の強さを設定する。 @param intensity 光源の強さ @note デフォルトは1.0である。 */ void SetIntensity(float intensity); }; } namespace asd { /** @brief エフェクトの機能を提供するクラス */ class EffectObject3D : public Object3D { private: std::shared_ptr<CoreEffectObject3D> m_coreObject; protected: /** @brief オーバーライドして、毎フレーム実行される更新処理を記述できる。 */ virtual void OnUpdate() {}; /** @brief オーバーライドして、追加の描画処理を記述できる。 */ virtual void OnDrawAdditionally() {}; public: EffectObject3D(); virtual ~EffectObject3D(); /** @brief 描画に使用するエフェクトを設定する。 @param effect エフェクト */ void SetEffect(std::shared_ptr<Effect> effect); /** @brief 設定されている全てのエフェクトを再生する。 @return 再生されたエフェクトのID */ int32_t Play(); /** @brief このオブジェクトから再生されたエフェクトを全て停止する。 */ void Stop(); /** @brief このオブジェクトから再生されたエフェクトのルートを全て停止する。 */ void StopRoot(); /** @brief このオブジェクトから再生されたエフェクトを表示状態にする。 */ void Show(); /** @brief このオブジェクトから再生されたエフェクトを非表示状態にする。 */ void Hide(); /** @brief このオブジェクトから再生されたエフェクトが再生中か取得する。 @return 再生中か? */ bool GetIsPlaying(); /** @brief このオブジェクトから再生されたエフェクトをオブジェクトに合わせて移動させるか取得する。 @return フラグ */ bool GetSyncEffects(); /** @brief このオブジェクトから再生されたエフェクトをオブジェクトに合わせて移動させるか設定する。 @param value フラグ */ void SetSyncEffects(bool value); }; } namespace asd { /** @brief メッシュを表示する3Dオブジェクトの機能を提供するクラス */ class ModelObject3D : public Object3D { private: std::shared_ptr<CoreModelObject3D> m_coreObject; protected: /** @brief オーバーライドして、毎フレーム実行される更新処理を記述できる。 */ virtual void OnUpdate() {}; /** @brief オーバーライドして、追加の描画処理を記述できる。 */ virtual void OnDrawAdditionally() {}; public: ModelObject3D(); virtual ~ModelObject3D(); /** @brief 描画に使用するモデルを設定する。 @param model モデル */ void SetModel(std::shared_ptr<Model>& model); /** @brief 描画に使用するメッシュを追加する。 @param meshGroupIndex メッシュグループのインデックス @param mesh メッシュ */ void AddMesh(std::shared_ptr<Mesh> mesh); /** @brief 描画に使用するデフォーマーを設定する。 @param meshGroupIndex メッシュグループのインデックス @param deformer デフォーマー */ void SetDeformer(std::shared_ptr<Deformer> deformer); /** @brief アニメーションクリップを取得する。 @param name アニメーションクリップの名称 @return アニメーションクリップ */ std::shared_ptr<AnimationClip> GetAnimationClip(const achar* name); /** @brief アニメーションを再生する。 @param index 対象のインデックス @param name アニメーションの名称 */ void PlayAnimation(int32_t index, const achar* name); /** @brief アニメーションを停止する。 @param index 対象のインデックス */ void StopAnimation(int32_t index); /** @brief アニメーションの合成比率を設定する。 @param index 対象のインデックス @param weight 合成比率 */ void SetAnimationWeight(int32_t index, float weight); /** @brief アニメーションをクロスフェードで再生する。 @param index 対象のインデックス @param name アニメーションの名称 @param time クロスフェードにかかる時間(秒) */ void CrossFadeAnimation(int32_t index, const achar* name, float time); /** @brief アニメーションが再生中か取得する。 @param index 対象のインデックス @return 再生中か? */ bool GetIsAnimationPlaying(int32_t index); /** @brief 材質個別に描画時のパラメーターを設定する。 @param meshIndex メッシュのインデックス @param materialIndex 材質のインデックス @param block プロパティ @note 通常描画する場合、材質に設定されたパラメーターを元に描画するがモデルごとに個別のパラメーターを使用する場合、この関数を使用する。 */ void SetMaterialPropertyBlock(int32_t meshIndex, int32_t materialIndex, std::shared_ptr<MaterialPropertyBlock> block); }; } namespace asd { /** @brief 大量にメッシュを表示する3Dオブジェクトの機能を提供するクラス */ class MassModelObject3D : public Object3D { private: std::shared_ptr<CoreMassModelObject3D> m_coreObject; protected: /** @brief オーバーライドして、毎フレーム実行される更新処理を記述できる。 */ virtual void OnUpdate() {}; /** @brief オーバーライドして、追加の描画処理を記述できる。 */ virtual void OnDrawAdditionally() {}; public: MassModelObject3D(); virtual ~MassModelObject3D(); /** @brief 描画に使用するモデルを設定する。 @param model モデル */ void SetModel(std::shared_ptr<MassModel>& model); /** @brief アニメーションを再生する。 @param name アニメーションの名称 */ void PlayAnimation(const achar* name); /** @brief アニメーションを停止する。 */ void StopAnimation(); /** @brief アニメーションをクロスフェードで再生する。 @param name アニメーションの名称 @param time クロスフェードにかかる時間(秒) */ void CrossFadeAnimation(const achar* name, float time); /** @brief アニメーションが再生中か取得する。 @return 再生中か? */ bool GetIsAnimationPlaying(); /** @brief 材質個別に描画時のパラメーターを設定する。 @param block プロパティ @note 通常描画する場合、材質に設定されたパラメーターを元に描画するがモデルごとに個別のパラメーターを使用する場合、この関数を使用する。 */ void SetMaterialPropertyBlock(std::shared_ptr<MaterialPropertyBlock> block); }; } namespace asd { /** @brief 地形を描画するクラス */ class TerrainObject3D : public Object3D { private: std::shared_ptr<CoreTerrainObject3D> m_coreObject; protected: /** @brief オーバーライドして、毎フレーム実行される更新処理を記述できる。 */ virtual void OnUpdate() {}; /** @brief オーバーライドして、追加の描画処理を記述できる。 */ virtual void OnDrawAdditionally() {}; public: TerrainObject3D(); virtual ~TerrainObject3D(); /** @brief 地形を設定する。 @param terrain 地形 */ void SetTerrain(std::shared_ptr<Terrain3D> terrain); /** @brief 材質個別に描画時のパラメーターを設定する。 @param block プロパティ @note 通常描画する場合、材質に設定されたパラメーターを元に描画するがモデルごとに個別のパラメーターを使用する場合、この関数を使用する。 */ void SetMaterialPropertyBlock(std::shared_ptr<MaterialPropertyBlock> block); }; } namespace asd { template<typename TObject> class ObjectManager; /** @brief 3Dオブジェクトの更新と描画を管理するレイヤーの機能を提供するクラス */ class Layer3D : public Layer , public IObjectRegisterable<Object3D> { friend class Scene; friend class Object3D; public: typedef std::shared_ptr<Object3D> ObjectPtr; private: std::shared_ptr<CoreLayer3D> m_coreLayer; std::shared_ptr<ObjectManager<Object3D>> m_objects; void BeginUpdating(); void EndUpdateting(); void DrawAdditionally(); void UpdateInternal(); void DisposeInternal(); void ImmediatelyRemoveObject(const Object3D::Ptr& object); bool GetIsAlive() const; void Register(const Object3D::Ptr& object); void Unregister(const Object3D::Ptr& object); void AddToCore(const Object3D::Ptr& object); void RemoveFromCore(const Object3D::Ptr& object); void RaiseOnAdded() override; void RaiseOnRemoved() override; protected: public: /** @brief コンストラクタ */ Layer3D(RenderSettings settings = RenderSettings()); /** @brief デストラクタ */ virtual ~Layer3D(); /** @brief 描画設定を取得する。 @return 描画設定 */ RenderSettings GetRenderSettings() const; /** @brief 描画設定を設定する。 @param settings 描画設定 */ void SetRenderSettings(RenderSettings settings); /** @brief このレイヤーに指定した3Dオブジェクトを追加する。 @param object 追加する3Dオブジェクト */ void AddObject(const Object3D::Ptr& object); /** @brief このレイヤーから指定した3Dオブジェクトを削除する。 @param object 削除される3Dオブジェクト */ void RemoveObject(const Object3D::Ptr& object); /** @brief このレイヤーに登録されている3Dオブジェクトのリストを取得する。 @return 登録されているオブジェクトのリスト */ std::list<Object3D::Ptr> GetObjects() const; /** @brief 通常の描画に加えてテクスチャを描画する。 @param upperLeftPos テクスチャの左上の描画位置 @param upperRightPos テクスチャの右上の描画位置 @param lowerRightPos テクスチャの右下の描画位置 @param lowerLeftPos テクスチャの左下の描画位置 @param upperLeftCol テクスチャの左上の頂点色 @param upperRightCol テクスチャの右上の頂点色 @param lowerRightCol テクスチャの右下の頂点色 @param lowerLeftCol テクスチャの左下の頂点色 @param upperLeftUV テクスチャの左上のUV値 @param upperRightUV テクスチャの右上のUV値 @param lowerRightUV テクスチャの右下のUV値 @param lowerLeftUV テクスチャの左下のUV値 @param texture 描画するテクスチャ @param alphaBlend アルファブレンドの種類 @param depthWrite 深度を書き込むか? @param depthTest 深度を比較するか? @note OnDrawAdditionallyの中以外では実行してはいけない。 */ void DrawSpriteAdditionally(Vector3DF upperLeftPos, Vector3DF upperRightPos, Vector3DF lowerRightPos, Vector3DF lowerLeftPos, Color upperLeftCol, Color upperRightCol, Color lowerRightCol, Color lowerLeftCol, Vector2DF upperLeftUV, Vector2DF upperRightUV, Vector2DF lowerRightUV, Vector2DF lowerLeftUV, std::shared_ptr<Texture2D> texture, AlphaBlendMode alphaBlend, bool depthWrite, bool depthTest); /** @brief 環境光の強さを取得する。 @return 環境光の強さ @note デフォルトは1.0である。 */ float GetAmbientColorIntensity(); /** @brief 環境光の強さを設定する。 @param ambientColorIntensity 環境光の強さ @note デフォルトは1.0である。 */ void SetAmbientColorIntensity(float ambientColorIntensity); /** @brief 空方向の環境光の色を設定する。 @param color 色 */ void SetSkyAmbientColor(Color color); /** @brief 地面方向の環境光の色を設定する。 @param color 色 */ void SetGroundAmbientColor(Color color); /** @brief テクスチャによる環境の色の強さを設定する。 @param environmentDiffuseColorIntensity 拡散色の強さ @param environmentSpecularColorIntensity スペキュラ色の強さ @note デフォルトは1.0である。 */ void SetEnvironmentColorIntensity(float environmentDiffuseColorIntensity, float environmentSpecularColorIntensity); /** @brief テクスチャによる環境の色を設定する。 @param diffuseColor 拡散色 @param specularColor スペキュラ色 */ void SetEnvironmentColor(std::shared_ptr<CubemapTexture> diffuseColor, std::shared_ptr<CubemapTexture> specularColor); /** @brief SSAOのサンプリングする半径を取得する。 @return SSAOのサンプリングする半径 */ float GetSSAO_Radius(); /** @brief SSAOのサンプリングする半径を設定すする。 @param value SSAOのサンプリングする半径 */ void SetSSAO_Radius(float value); /** @brief SSAOのバイアスを取得する。 @return SSAOのバイアス */ float GetSSAO_Bias(); /** @brief SSAOのバイアスを設定すする。 @param value SSAOのバイアス */ void SetSSAO_Bias(float value); /** @brief SSAOの強さを取得する。 @return SSAOの強さ */ float GetSSAO_Intensity(); /** @brief SSAOの強さを設定すする。 @param value SSAOの強さ */ void SetSSAO_Intensity(float value); /** @brief SSAOの最大距離を取得する。 @return SSAOの最大距離 */ float GetSSAO_FarPlain(); /** @brief SSAOの最大距離を設定すする。 @param value SSAOの最大距離 */ void SetSSAO_FarPlain(float value); /** @brief 高さ方向のフォグが有効かどうか、を取得する。 */ bool GetIsHeightFogEnabled(); /** @brief 高さ方向のフォグが有効かどうか、を設定する。 */ void SetIsHeightFogEnabled(bool value); /** @brief 高さ方向のフォグの濃度を取得する。 */ float GetHeightFogDensity(); /** @brief 高さ方向のフォグの濃度を設定する。 */ void SetHeightFogDensity(float value); /** @brief 高さ方向のフォグの色を取得する。 */ Color GetHeightFogColor(); /** @brief 高さ方向のフォグの色を設定する。 */ void SetHeightFogColor(Color value); /** @brief 高さ方向のフォグの減衰率を取得する。 @note この値が大きいほど、高い位置のフォグが薄くなる。 */ float GetHeightFogFalloff(); /** @brief 高さ方向のフォグの減衰率を設定する。 */ void SetHeightFogFalloff(float value); /** @brief 高さ方向のフォグの開始距離を取得する。 @note この値よりカメラに対して近い位置には霧が生じなくなる。 */ float GetHeightFogStartDistance(); /** @brief 高さ方向のフォグの開始距離を設定する。 */ void SetHeightFogStartDistance(float value); bool GetIsOceanEnabled(); void SetIsOceanEnabled(bool value); RectF GetOceanArea(); void SetOceanArea(RectF value); float GetOceanHeight(); void SetOceanHeight(float value); float GetOceanGridSize(); void SetOceanGridSize(float value); Color GetOceanColor(); void SetOceanColor(Color color); float GetOceanDensity(); void SetOceanDensity(float value); Texture2D* GetOceanNormalMap(); void SetOceanNormalMap(std::shared_ptr<Texture2D> value); /** @brief レイヤーの種類を取得する。 @return レイヤーの種類 */ LayerType GetLayerType() const override { return LayerType::Layer3D; } int GetObjectCount() const; }; } namespace asd { class Engine; class EventToChangeScene; class EventToManageLayer; class Layer; template<typename TComponent> class ComponentManager; /** @brief 画面を表し、レイヤーを管理するクラス。 */ class Scene : public std::enable_shared_from_this<Scene> , public IComponentRegisterable<SceneComponent> , public IImmediatelyDisposable { friend class Engine; friend class EventToChangeScene; friend class EventToManageLayer; friend class Layer; friend class SceneComponent; public: typedef std::shared_ptr<Scene> Ptr; private: std::shared_ptr<CoreScene> m_coreScene; std::list<Layer::Ptr> m_layersToDraw; std::list<Layer::Ptr> m_layersToUpdate; std::shared_ptr<ComponentManager<SceneComponent>> m_componentManager; bool alreadyFirstUpdate; bool m_isAlive; void RaiseOnRegistered(); void RaiseOnStartUpdating(); void RaiseOnTransitionFinished(); void RaiseOnTransitionBegin(); void RaiseOnStopUpdating(); void RaiseOnUnregistered(); void Update(); void Draw(); void CommitChanges(); void UpdateComponents(); void ImmediatelyAddLayer(const Layer::Ptr& layer, bool raiseEvent); void ImmediatelyRemoveLayer(const Layer::Ptr& layer, bool raiseEvent); void ImmediatelyRemoveComponent(astring key); void DisposeImmediately(); void Register(const SceneComponent::Ptr& component); void Unregister(const SceneComponent::Ptr& component); protected: /** @brief オーバーライドして、このシーンがエンジンに登録されたときに実行する処理を記述できる。 */ virtual void OnRegistered(); /** @brief オーバーライドして、最初のシーン更新時に実行する処理を記述する。 */ virtual void OnStartUpdating(); /** @brief オーバーライドして、トランジション終了時に実行する処理を記述する。 */ virtual void OnTransitionFinished(); /** @brief オーバーライドして、このシーンから別のシーンに切り替わる際に実行される処理を記述する。 */ virtual void OnTransitionBegin(); /** @brief オーバーライドして、このシーンの更新が止まるときに実行する処理を記述できる。 */ virtual void OnStopUpdating(); /** @brief オーバーライドして、このシーンがエンジンから登録解除されたときに実行する処理を記述できる。 */ virtual void OnUnregistered(); /** @brief オーバーライドして、このシーンが破棄される際に実行される処理を記述する。 */ virtual void OnDispose(); /** @brief オーバーライドして、このシーンを更新する直前の処理を記述できる。 */ virtual void OnUpdating(); /** @brief オーバーライドして、このシーンを更新した直後の処理を記述できる。 */ virtual void OnUpdated(); public: /** @brief コンストラクタ */ Scene(); /** @brief デストラクタ */ virtual ~Scene(); /** @brief 描画先のフォーマットがHDRか取得する。 @return HDRか? */ bool GetHDRMode() const; /** @brief 描画先のフォーマットをHDRにするか設定する。 @param value HDRか? */ void SetHDRMode(bool value); /** @brief 指定したレイヤーをこのインスタンスに追加する。 @param layer 追加するレイヤー */ void AddLayer(const Layer::Ptr& layer); /** @brief 指定したレイヤーをこのインスタンスから削除する。 @param layer 削除するレイヤー */ void RemoveLayer(const Layer::Ptr& layer); /** @brief 指定したコンポーネントをこのインスタンスに追加する。 @param component 追加するコンポーネント @param key コンポーネントに関連付けるキー */ void AddComponent(const SceneComponent::Ptr& component, astring key); /** @brief キーの示すコンポーネントをこのインスタンスから取得する。 @param key 取得するコンポーネントを示すキー */ SceneComponent::Ptr GetComponent(astring key); /** @brief キーの示すコンポーネントをこのインスタンスから削除する。 @param key 削除するコンポーネントを示すキー */ bool RemoveComponent(astring key); /** @brief 全てのレイヤーとポストエフェクトが描画され終わった画面をテクスチャとして取得する。 @return 画面 @note テクスチャの内容はシーンが描画されるたびに変わる。 主にシーン遷移の際に使用する。 */ std::shared_ptr<RenderTexture2D> GetEffectedScreen(); /** @brief 所属しているレイヤーを取得する。 @return 所属しているレイヤー */ const std::list<Layer::Ptr>& GetLayers() const; bool GetIsAlive() const; void Dispose(); }; } //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- #include <queue> //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- namespace asd { //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- // 先行宣言 class Scene; class Object2D; class Object3D; //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- /** @brief 初期化時に設定するオプションのクラス */ struct EngineOption { /** @brief フルスクリーンで起動するか? */ bool IsFullScreen = false; /** @brief 描画に使用するデバイス */ GraphicsDeviceType GraphicsDevice = GraphicsDeviceType::Default; /** @brief ウインドウの初期配置 */ WindowPositionType WindowPosition = WindowPositionType::Default; /** @brief リソースの再読み込みを有効にするかどうか? */ bool IsReloadingEnabled = false; /** @brief 起動時に自動的に生成されるシーンとレイヤーの種類 */ AutoGeneratedLayerType AutoGeneratedLayer = AutoGeneratedLayerType::Layer2D; /** @brief カラースペースの種類 */ ColorSpaceType ColorSpace = ColorSpaceType::LinearSpace; }; class Engine { friend class EventToChangeScene; friend class Scene; friend class Layer; friend class DrawnObject2D; friend class Object2D; friend class Object3D; friend class Object2DComponent; friend class Layer2DComponent; friend class SceneComponent; template<typename TObject> friend class ObjectManager; template<typename TComponent> friend class ComponentManager; private: class SceneTransitionState { public: virtual std::shared_ptr<SceneTransitionState> Proceed() { return nullptr; } virtual void Draw() = 0; virtual void Update() { } virtual void ForceToComplete() { } }; class NeutralState : public SceneTransitionState { public: void Draw() override; std::shared_ptr<SceneTransitionState> Proceed() override; }; class FadingOutState : public SceneTransitionState { private: std::shared_ptr<Transition> m_transition; bool m_doAutoDispose; public: FadingOutState(std::shared_ptr<Transition> transition, std::shared_ptr<Scene> nextScene, bool doAutoDispose); std::shared_ptr<SceneTransitionState> Proceed() override; void Draw() override; void Update() override; // ForceToCompleteを実装せず、フェードアウト中にさらに画面遷移しようとしたときの動作を保証しない }; class FadingInState : public SceneTransitionState { private: std::shared_ptr<Transition> m_transition; std::shared_ptr<Scene> m_previousScene; bool m_doAutoDispose; public: FadingInState(std::shared_ptr<Transition> transition, std::shared_ptr<Scene> previousScene, bool doAutoDispose); std::shared_ptr<SceneTransitionState> Proceed() override; void Draw() override; void Update() override; void ForceToComplete() override; }; class QuicklyChangingState : public SceneTransitionState { private: bool m_doAutoDispose; public: QuicklyChangingState(std::shared_ptr<Scene> nextScene, bool doAutoDispose); std::shared_ptr<SceneTransitionState> Proceed() override; void Draw() override; void ForceToComplete() override; }; private: typedef std::shared_ptr<Scene> ScenePtr; static Core* m_core; static Keyboard* m_keyboard ; static Mouse* m_mouse ; static JoystickContainer* m_joystickContainer ; static Log* m_logger ; static Profiler* m_profiler ; static LayerProfiler* m_layerProfiler; static Sound* m_sound; static File* m_file; static Graphics* m_graphics ; static ObjectSystemFactory* m_objectSystemFactory ; static AnimationSystem* m_animationSyatem ; static std::shared_ptr<Scene> m_currentScene; static std::shared_ptr<Scene> m_nextScene; static std::shared_ptr<SceneTransitionState> m_transitionState; static std::queue<std::shared_ptr<ICommitable>> m_changesToCommit; static bool HasDLL(const char* path); static bool CheckDLL(); static bool GenerateCore(); static void CommitChange(); Engine(); ~Engine(); public: /** @brief 初期化を行う。 @param title タイトル @param width 横幅 @param height 縦幅 @param option オプション @return 成否 */ static bool Initialize(const achar* title, int32_t width, int32_t height, EngineOption option); /** @brief 初期化を行う。 @param handle1 ハンドル @param handle2 ハンドル @param width 横幅 @param height 縦幅 @param option オプション @return 成否 */ static bool InitializeByExternalWindow(void* handle1, void* handle2, int32_t width, int32_t height, EngineOption option); /** @brief タイトルを設定する。 @param title タイトル */ static void SetTitle(const achar* title); /** @brief イベントを実行し、進行可否を判断する。 @return 進行可能か? */ static bool DoEvents(); /** @brief 更新処理を行う。 */ static void Update(); /** @brief 終了処理を行う。 */ static void Terminate(); /** @brief マウスカーソルを作成する。 @param path 画像のパス @param hot カーソルの相対座標 @return カーソル */ static std::shared_ptr<Cursor> CreateCursor(const achar* path, Vector2DI hot); /** @brief マウスカーソルを設定する。 @param cursor カーソル */ static void SetCursor(std::shared_ptr<Cursor> cursor); /** @brief クリップボードの内容を取得する。 @return クリップボード */ static const achar* GetClipboardString(); /** @brief クリップボードの内容を設定する。 @param s 文字列 */ static void SetClipboardString(const achar* s); /** @brief フルスクリーンモードかどうか設定する。 @param isFullscreenMode フルスクリーンモードか @note 現状、DirectXのみ有効である。 */ static void SetIsFullscreenMode(bool isFullscreenMode); /** @brief 内部の参照数を取得する。 @note 内部オブジェクト間の参照の数を取得する。 正しく内部オブジェクトが破棄されているか調査するためのデバッグ用である。 */ static int32_t GetReferenceCount(); /** @brief 一番最初に追加された2Dレイヤーにオブジェクトを追加する。 @param o オブジェクト @return 成否 */ static bool AddObject2D(std::shared_ptr<Object2D> o); /** @brief 一番最初に追加された2Dレイヤーからオブジェクトを削除する。 @param o オブジェクト @return 成否 */ static bool RemoveObject2D(std::shared_ptr<Object2D> o); /** @brief 一番最初に追加された3Dレイヤーにオブジェクトを追加する。 @param o オブジェクト @return 成否 */ static bool AddObject3D(std::shared_ptr<Object3D> o); /** @brief 一番最初に追加された3Dレイヤーからオブジェクトを削除する。 @param o オブジェクト @return 成否 */ static bool RemoveObject3D(std::shared_ptr<Object3D> o); /** @brief 描画する対象となるシーンを変更する。 @param scene 次のシーン */ static void ChangeScene(std::shared_ptr<Scene> scene, bool doAutoDispose = true); /** @brief 描画する対象となるシーンを画面遷移効果ありで変更する。 @param scene 次のシーン @param transition 画面遷移効果 */ static void ChangeSceneWithTransition( std::shared_ptr<Scene> scene, const std::shared_ptr<Transition>& transition, bool doAutoDispose = true); /** @brief スクリーンショットを保存する。 @param path 出力先 @note Windowsの場合、pngとjpg形式の保存に対応している。他のOSではpng形式の保存に対応している。 形式の種類は出力先の拡張子で判断する。 */ static void TakeScreenshot(const achar* path); /** @brief スクリーンショットをgifアニメーションとして録画する。 @param path 出力先 @param frame 録画フレーム数 @param frequency_rate 録画頻度(例えば、1だと1フレームに1回保存、0.5だと2フレームに1回保存) @param scale ウインドウサイズに対する画像サイズの拡大率(ウインドウサイズが320の場合、0.5を指定すると160の画像が出力される) @note 実行してから一定時間の間、録画を続ける。 録画が終了するまでにアプリケーションが終了された場合、終了した時点までの録画結果が出力される。 */ static void CaptureScreenAsGifAnimation(const achar* path, int32_t frame, float frequency_rate, float scale); /** @brief 1フレームで経過した実時間(秒)を取得する。 @return 経過時間(秒) */ static float GetDeltaTime(); /** @brief 1フレームで経過した時間を外部から設定する。 @param deltaTime 経過時間(秒) @note 基本的に開発者は使用する必要はない。 何らかの理由で無理やり経過時間を指定する場合に使用する。 */ static void SetDeltaTime(float deltaTime); static std::shared_ptr<Scene> GetCurrentScene(); /** @brief 現在のFPSを取得する。 @return FPS */ static float GetCurrentFPS(); /** @brief 目標FPSを取得する。 @return FPS */ static int32_t GetTargetFPS(); /** @brief 目標FPSを設定する。 @param fps FPS */ static void SetTargetFPS(int32_t fps); /** @brief 時間を指定可能なオブジェクトの実時間あたりの進行速度を取得する。 @return 進行速度 */ static float GetTimeSpan(); /** @brief 時間を指定可能なオブジェクトの実時間あたりの進行速度を設定する。 @param timeSpan 進行速度 */ static void SetTimeSpan(float timeSpan); /** @brief フレームレートの制御方法を取得する。 @return 制御方法 */ static FramerateMode GetFramerateMode(); /** @brief フレームレートの制御方法を設定する。 @param framerateMode 制御方法 */ static void SetFramerateMode(FramerateMode framerateMode); /** @brief ウインドウを閉じる。 */ static void Close(); /** @brief Windowsの場合、ウインドウのハンドルを取得する。 @return ウインドウハンドル */ static void* GetWindowHandle(); /** @brief キーボードクラスを取得する。 @return キーボード */ static Keyboard* GetKeyboard(); /** @brief マウスクラスを取得する。 @return マウス */ static Mouse* GetMouse(); /** @brief ログクラスを取得する。 @return ログクラス */ static Log* GetLogger(); /** @brief プロファイラクラスを取得する。 @return プロファイラクラス */ static Profiler* GetProfiler(); /** @brief ジョイスティックコンテナクラスを取得する。 @return ジョイスティックコンテナクラス */ static JoystickContainer* GetJoystickContainer(); /** @brief ファイルクラスを取得する。 @return ファイルクラス */ static File* GetFile(); /** @brief Graphicsクラスを取得する。 */ static Graphics* GetGraphics(); /** @brief Soundクラスを取得する。 */ static Sound* GetSound(); /** @brief AnimationSyatemクラスを取得する。 preturn AnimationSyatemクラス */ static AnimationSystem* GetAnimationSyatem(); /** @brief ウィンドウのサイズを取得する。 @return ウィンドウのサイズ */ static Vector2DI GetWindowSize(); /** @brief ウインドウのサイズを設定する。 @param size ウインドウのサイズ */ static void SetWindowSize(Vector2DI size); static bool GetProfilerVisibility(); static void SetProfilerVisibility(bool visibility); #if _WIN32 #else /** @brief 初期化を行う。 @param title タイトル @param width 横幅 @param height 縦幅 @param option オプション @return 成否 */ static bool Initialize(const wchar_t* title, int32_t width, int32_t height, EngineOption option) { return Initialize( ToAString(title).c_str(), width, height, option ); } #endif }; //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- }
[ "akitsu.sanae@gmail.com" ]
akitsu.sanae@gmail.com
28dbd1c2c4002298e5965c9fe919540637ce8dde
6f1876cb2807e20f3e359a4be8067ea1f76ac606
/mqtt/session.cpp
6dea6b3e99b4bb1a739147e5808b4cebe0155675
[]
no_license
lordjaxom/repwatchd
5b941fa77e1892984050da8dbc2c3c7ede1c3a90
b9c33ce4d71471c98acd03d5883fe4bd7a52e5d0
refs/heads/master
2023-08-25T22:34:45.821120
2021-11-01T15:25:25
2021-11-01T15:25:25
332,046,647
0
0
null
null
null
null
UTF-8
C++
false
false
4,340
cpp
#include <algorithm> #include <stdexcept> #include <unordered_map> #include <utility> #include <3dprnet/core/logging.hpp> #include <mosquittopp.h> #include "session.hpp" using namespace std; using namespace prnet; using namespace mosqpp; namespace repw { namespace mqtt { static Logger logger( "mqtt::Session" ); class Session::SessionImpl : mosquittopp { using Lock = lock_guard< mutex >; using Subscriptions = unordered_multimap< string, MessageHandler >; public: SessionImpl( Endpoint endpoint ) : mosquittopp( endpoint.clientId().c_str() ) { call_once( initialized, [] { lib_init(); } ); connect( endpoint ); } ~SessionImpl() { mosquittopp::loop_stop( true ); } void publish( std::string const& topic, string_view payload ) { Lock lock( mutex_ ); int rc; if ( ( rc = mosquittopp::publish( nullptr, topic.c_str(), static_cast< int >( payload.length() ), payload.data() ) ) != MOSQ_ERR_SUCCESS ) { logger.error( "error publishing to ", topic, ": ", strerror( rc ) ); } } void subscribe( string&& topic, MessageHandler&& handler ) { Lock lock( mutex_ ); auto inserted = subscriptions_.emplace( move( topic ), move( handler ) ); if ( connected_ ) { resubscribe( inserted ); } } private: void connect( Endpoint const& endpoint ) { logger.info( "connecting to ", endpoint.host(), ":", endpoint.port() ); int rc; if ( ( rc = connect_async( endpoint.host().c_str(), endpoint.port() ) ) != MOSQ_ERR_SUCCESS || ( rc = loop_start() ) != MOSQ_ERR_SUCCESS ) { throw runtime_error( "error starting MQTT session with " + endpoint.host() + ": " + strerror( rc ) ); } } void resubscribe( Subscriptions::iterator it = everything ) { auto first = it != everything ? it : subscriptions_.begin(); auto last = it != everything ? next( it, 1 ) : subscriptions_.end(); for_each( first, last, [this]( auto& subscription ) { int rc; if ( ( rc = this->mosquittopp::subscribe( nullptr, subscription.first.c_str() ) ) != MOSQ_ERR_SUCCESS ) { logger.error( "error subscribing to MQTT topic ", subscription.first, ": ", strerror( rc ) ); } } ); } void on_connect( int rc ) override { Lock lock( mutex_ ); if ( rc != MOSQ_ERR_SUCCESS ) { logger.error( "error connecting to MQTT broker: ", strerror( rc ), ", trying to reconnect" ); mosquittopp::reconnect_async(); return; } logger.info( "connection to MQTT broker established successfully" ); connected_ = true; resubscribe(); } void on_disconnect( int rc ) override { Lock lock( mutex_ ); logger.error( "connection to MQTT broker lost: ", strerror( rc ), ", trying to reconnect" ); connected_ = false; mosquittopp::reconnect_async(); } void on_message( mosquitto_message const* message ) override { Lock lock( mutex_ ); logger.debug( "received message from ", message->topic, " with mid ", message->mid ); string_view payload( static_cast< char* >( message->payload ), static_cast< size_t >( message->payloadlen ) ); auto subscriptions = subscriptions_.equal_range( message->topic ); for_each( subscriptions.first, subscriptions.second, [&]( auto const& subscription ) { subscription.second( payload ); } ); } static once_flag initialized; static Subscriptions::iterator everything; bool connected_ {}; Subscriptions subscriptions_; mutex mutex_; }; once_flag Session::SessionImpl::initialized; Session::SessionImpl::Subscriptions::iterator Session::SessionImpl::everything {}; Session::Session( Endpoint const& endpoint ) : impl_( make_unique< SessionImpl >( endpoint ) ) {} Session::~Session() = default; void Session::publish( std::string const& topic, string_view payload ) { impl_->publish( topic, payload ); } void Session::subscribe( string topic, MessageHandler handler ) { impl_->subscribe( move( topic ), move( handler ) ); } } // namespace mqtt } // namespace repw
[ "sascha@akv-soft.de" ]
sascha@akv-soft.de
d9537400deed8f7e9fe7a0f13933411185f98f01
d6c54a9cb57a6f5b88aaef157e9e2870e4fd86af
/Day 29/day29.cpp
2d60bd5d8f4682098bc90f5b34baf6ffd739efb2
[]
no_license
vishaka-mohan/30-Days-of-Code-Challenge
fce1c1b9d9760f8d3308326d3244a2bfa8f5e971
8f3197aa9e9075ab5bebf442545f739e82327507
refs/heads/main
2023-02-02T16:31:07.828019
2020-12-21T15:22:50
2020-12-21T15:22:50
314,985,699
0
0
null
null
null
null
UTF-8
C++
false
false
1,250
cpp
#include <bits/stdc++.h> using namespace std; vector<string> split_string(string); int main() { int t; cin >> t; cin.ignore(numeric_limits<streamsize>::max(), '\n'); for (int p = 0; p < t; ++p) { int m = 0; int n,k; cin >> n >> k; for (int i = 1; i < n; ++i) { for (int j = i+1; j <= n; ++j) { if ((i&j) > m && (i&j) < k) m = (i&j); } } cout << m << '\n'; } return 0; } vector<string> split_string(string input_string) { string::iterator new_end = unique(input_string.begin(), input_string.end(), [] (const char &x, const char &y) { return x == y and x == ' '; }); input_string.erase(new_end, input_string.end()); while (input_string[input_string.length() - 1] == ' ') { input_string.pop_back(); } vector<string> splits; char delimiter = ' '; size_t i = 0; size_t pos = input_string.find(delimiter); while (pos != string::npos) { splits.push_back(input_string.substr(i, pos - i)); i = pos + 1; pos = input_string.find(delimiter, i); } splits.push_back(input_string.substr(i, min(pos, input_string.length()) - i + 1)); return splits; }
[ "pflight0211@gmail.com" ]
pflight0211@gmail.com
50c8a282aab438d206aa2355addd42f116680876
3e5f4c3fc27e95b109043b1d8be66fdbf83f4821
/samples/chapter10/list10_6.cpp
87866c0390e6db680ef9cb73fc005f575dacbcf9
[]
no_license
TakutoMotomura/C-class-and-inheritance
f66d857f6d47b1f9f0e00bd2abdc77d1a1adc0b0
d2a6bf5b6fbbe178751039dbd1a46c253e30c936
refs/heads/master
2023-06-16T13:03:01.037797
2021-07-09T14:17:57
2021-07-09T14:17:57
358,620,032
0
0
null
null
null
null
SHIFT_JIS
C++
false
false
2,035
cpp
#include <iostream> #include <cstdlib> #include <ctime> using namespace std; // 基本クラスの定義 class Hand { public: virtual void judge(Hand *h) = 0; // 相手に問い合わせる virtual void vsGu() = 0; // グーに勝てるかどうかを返す virtual void vsChoki() = 0; // チョキに勝てるかどうかを返す virtual void vsPa() = 0; // パーに勝てるかどうかを返す }; // Guクラスの定義 class Gu : public Hand { public: void judge(Hand *h); void vsGu(); void vsChoki(); void vsPa(); }; // Guクラスのメンバ関数の実装 void Gu::judge(Hand *h) { h->vsGu(); } void Gu::vsGu() { cout << "あいこです!\n"; } void Gu::vsChoki() { cout << "グーの勝ちです!\n"; } void Gu::vsPa() { cout << "グーの負けです!\n"; } // Chokiクラスの定義 class Choki : public Hand { public: void judge(Hand *h); void vsGu(); void vsChoki(); void vsPa(); }; // Chokiクラスのメンバ関数の実装 void Choki::judge(Hand *h) { h->vsChoki(); } void Choki::vsGu() { cout << "チョキの負けです!\n"; } void Choki::vsChoki() { cout << "あいこです!\n"; } void Choki::vsPa() { cout << "チョキの勝ちです!\n"; } // Paクラスの定義 class Pa : public Hand { public: void judge(Hand *h); void vsGu(); void vsChoki(); void vsPa(); }; // Paクラスのメンバ関数の実装 void Pa::judge(Hand *h) { h->vsPa(); } void Pa::vsGu() { cout << "パーの勝ちです!\n"; } void Pa::vsChoki() { cout << "パーの負けです!\n"; } void Pa::vsPa() { cout << "あいこです!\n"; } // クラスを使う側のコード int main() { // オブジェクトを作成する Gu g; Choki c; Pa p; // グーとチョキを対戦させる cout << "グー vs. チョキ…"; c.judge(&g); // グーとパーを対戦させる cout << "グー vs. パー…"; p.judge(&g); // グーとグーを対戦させる cout << "グー vs. グー…"; g.judge(&g); return 0; }
[ "takumoto913@gmail.com" ]
takumoto913@gmail.com
ca4b5ad94f188d1cfc37612e26a0ebe88b64309c
cbf8c509d425105a0cb2d93b593acd6412efa1d9
/PhysicalNumberTest.cpp
fb52fcbc728201a8833446d1a508cb143939a9c9
[]
no_license
oravital7/PhysicalNumber
22b4480d8289614be4c440fe4b28a154f6ecd5f4
694a991f59b63f3989d9560e90fec1fb3d7d669d
refs/heads/master
2020-05-04T02:43:40.482854
2019-04-07T17:48:01
2019-04-07T17:48:01
178,932,814
0
2
null
null
null
null
UTF-8
C++
false
false
5,608
cpp
/** * Examples of automatic tests for the exercise on physical numbers. * * @author Erel Segal-Halevi * @since 2019-02 */ #include <iostream> #include <sstream> using std::cout, std::endl, std::istringstream; #include "PhysicalNumber.h" using ariel::PhysicalNumber, ariel::Unit; #include "badkan.hpp" int main() { badkan::TestCase testcase; int grade=0; int signal = setjmp(badkan::longjmp_buffer); if (signal == 0) { // BASIC TESTS - DO NOT CHANGE PhysicalNumber a(2, Unit::KM); PhysicalNumber b(300, Unit::M); PhysicalNumber c(2, Unit::HOUR); PhysicalNumber d(30, Unit::MIN); PhysicalNumber Gram(30, Unit::G); PhysicalNumber Cm(30, Unit::CM); PhysicalNumber KM(30, Unit::KM); PhysicalNumber MET(200, Unit::M); testcase .setname("Basic output") .CHECK_OUTPUT(a, "2[km]") .CHECK_OUTPUT(b, "300[m]") .setname("Compatible dimensions") .CHECK_OUTPUT(b+a, "2300[m]") .CHECK_OUTPUT((a+=b), "2.3[km]") .CHECK_OUTPUT(a, "2.3[km]") .CHECK_OUTPUT(a+a, "4.6[km]") .CHECK_OUTPUT(b-b, "0[m]") .CHECK_OUTPUT(c, "2[hour]") .CHECK_OUTPUT(d, "30[min]") .CHECK_OUTPUT(d+c, "150[min]") .setname("Incompatible dimensions") .CHECK_THROWS(a+c) .CHECK_THROWS(a+d) .CHECK_THROWS(b+c) .CHECK_THROWS(b+d) .setname("Basic input") .CHECK_OK(istringstream("700[kg]") >> a) .CHECK_OUTPUT((a += PhysicalNumber(1, Unit::TON)), "1700[kg]") // YOUR TESTS - INSERT AS MANY AS YOU WANT .setname("Should not work") .CHECK_THROWS(Gram+Cm) .CHECK_THROWS(Cm+Gram) .CHECK_THROWS(Gram+=Cm) .CHECK_THROWS(Cm+=Gram) .CHECK_THROWS(Cm-=Gram) .CHECK_THROWS(Gram-=Cm) .CHECK_THROWS(Cm-Gram) .CHECK_THROWS(Gram-Cm) .CHECK_THROWS(Cm < Gram) .CHECK_THROWS(Gram > KM) .CHECK_THROWS(Gram >= KM) .CHECK_THROWS(Cm <= Gram) .CHECK_THROWS(KM <= Gram) .CHECK_THROWS(a <= b) .CHECK_THROWS(b <= c) .CHECK_THROWS(b += Gram) .CHECK_THROWS(a -= d) .CHECK_THROWS(c += MET) .CHECK_THROWS(c -= MET) .CHECK_THROWS(MET -= c) .CHECK_THROWS(MET += c) .CHECK_THROWS(Gram < KM) .CHECK_OK(istringstream("200[g") >> Gram) .CHECK_OK(istringstream("0.2[]") >> a) .CHECK_OK(istringstream("200g]") >> Gram) .CHECK_OK(istringstream("0.2[kgg]") >> a) .CHECK_OK(istringstream("122.2kg") >> a) .CHECK_OK(istringstream("1332.2[to n]") >> a) .CHECK_OK(istringstream("[ton]1332.2") >> a) .setname("Should work") .CHECK_OUTPUT(++Gram, "31[g]") .CHECK_OUTPUT(--Gram, "30[g]") .CHECK_OUTPUT(--Cm, "29[cm]") .CHECK_OUTPUT(++Cm, "30[cm]") .CHECK_OUTPUT((Gram+=Gram), "60[g]") .CHECK_OUTPUT((Cm+=Cm), "60[cm]") .CHECK_OUTPUT((-Gram),"-60[g]") .CHECK_OUTPUT(+Gram,"60[g]") .CHECK_OUTPUT(Gram-Gram,"0[g]") .CHECK_OUTPUT((KM+=MET) , "30.2[km]") .CHECK_OUTPUT((Cm-=Cm),"0[cm]") .CHECK_OUTPUT(Cm,"0[cm]") .CHECK_OUTPUT((Cm+=MET),"20000[cm]") .CHECK_OUTPUT((MET+=Cm) , "400[m]") .CHECK_OUTPUT((++MET) , "401[m]") .CHECK_OUTPUT((--MET) , "400[m]") .CHECK_OUTPUT((-MET) , "-400[m]") .CHECK_OUTPUT((+MET) , "400[m]") .CHECK_OUTPUT(Gram++, "60[g]") .CHECK_OUTPUT(Gram, "61[g]") .CHECK_OUTPUT(Gram--, "61[g]") .CHECK_OUTPUT(Gram, "60[g]") .CHECK_EQUAL(Cm < KM, true) .CHECK_EQUAL(Cm > KM, false) .CHECK_EQUAL(Cm != KM, true) .CHECK_EQUAL(Cm == KM, false) .CHECK_EQUAL(Cm == Cm, true) .CHECK_EQUAL(MET > Cm, true) .CHECK_EQUAL(MET != Cm, true) .CHECK_EQUAL(MET > Cm, true) .CHECK_EQUAL(MET >= Cm, true) .CHECK_OK(istringstream("200[m]") >> MET) .CHECK_OUTPUT(MET, "200[m]") .CHECK_EQUAL(MET == Cm, true) .CHECK_OK(istringstream("2000[g]") >> Gram) .CHECK_OK(istringstream("2[kg]") >> a) .CHECK_OUTPUT(a, "2[kg]") .CHECK_EQUAL(Gram == a, true) .CHECK_EQUAL(Gram != a, false) .CHECK_OUTPUT((--Gram) , "1999[g]") .CHECK_EQUAL(Gram != a, true) .CHECK_EQUAL(Gram == a, false) .CHECK_OK(istringstream("200[g]") >> Gram) .CHECK_OK(istringstream("0.2[kg]") >> a) .CHECK_OUTPUT(Gram , "200[g]") .CHECK_OUTPUT(a , "0.2[kg]") .CHECK_EQUAL(Gram != a, false) .CHECK_EQUAL(Gram == a, true) .CHECK_OK(istringstream("30[min]") >> b) .CHECK_OK(istringstream("0.5[hour]") >> c) .CHECK_OUTPUT(b , "30[min]") .CHECK_OUTPUT(c , "0.5[hour]") .CHECK_OK(istringstream("1[ton]") >> b) .CHECK_OK(istringstream("1000[kg]") >> c) .CHECK_OUTPUT(b , "1[ton]") .CHECK_OUTPUT(c , "1000[kg]") .CHECK_EQUAL(b != c, false) .CHECK_EQUAL(b == c, true) .CHECK_OK(istringstream("0.5[km]") >> b) .CHECK_OK(istringstream("500[m]") >> c) .CHECK_OUTPUT(b , "0.5[km]") .CHECK_OUTPUT(c , "500[m]") .CHECK_EQUAL(b != c, false) .CHECK_EQUAL(b == c, true) .CHECK_OUTPUT((b+b+c), "1.5[km]") .CHECK_OUTPUT((c+b+b), "1500[m]") .CHECK_OUTPUT((c+b-b), "500[m]") .CHECK_OUTPUT((b-c-c+b), "0[km]") .CHECK_EQUAL((b+c > b), true) .CHECK_EQUAL((b-c < b), true) .CHECK_OUTPUT((b+=c+=b), "1.5[km]") .CHECK_OUTPUT(b, "1.5[km]") .CHECK_OUTPUT(c, "1000[m]") .print(cout, /*show_grade=*/false); grade = testcase.grade(); } else { testcase.print_signal(signal); grade = 0; } cout << "*** Grade: " << grade << " ***" << endl; return grade; }
[ "oravital7@gmail.com" ]
oravital7@gmail.com
d6f50964150c171d9f140da109cb5dcb1f5aa372
a4b04b8cfdbd2ee95ddc98be2548ae9ffa620aa6
/Assignment-two/Part1/PartC/Image.cpp
11ff50758b06df4f9364df18c70f420716976465
[]
no_license
RakeshKumarSatvik/Digital-Image-Processing
a6e088cd07c7b084aa768378e95b79c660600a08
08bc7195671eeb97ae49d4b0f36da5dea21e1791
refs/heads/master
2021-05-01T18:36:29.817523
2016-11-05T17:57:26
2016-11-05T17:57:26
68,081,336
0
0
null
null
null
null
UTF-8
C++
false
false
4,360
cpp
/* Name : Rakesh Kumar Satvik USC ID : 8772-6992-51 USC email : satvik@usc.edu Submission date : 18/09/2016 File : This code is for Non-local means noise removal algorithm. */ #include <cstdio> #include <iostream> #include <cstdlib> #include <cstring> #include <cmath> #include <vector> #include "Image.h" using namespace std; Image::Image() { // TODO Auto-generated constructor stub this->height = 0; this->width = 0; this->BytesPerPixel = 1; this->Imagedata = NULL; this->SecondImagedata = NULL; } Image::~Image() { // TODO Auto-generated destructor stub delete(this->Imagedata); } void Image::allocate_image() { cout << "Please enter Bytes Per Pixel : "; cin >> this->BytesPerPixel; cout << "Please enter Width of input image: "; cin >> this->width; cout << "Please enter Height of input image: "; cin >> this->height; // Allocation of image and padded image this->Imagedata = new (nothrow) unsigned char[this->width * this->height * this->BytesPerPixel]; this->SecondImagedata = new (nothrow) unsigned char[350 * 146 * this->BytesPerPixel]; } void Image::read_image(char *filename, char *filename2) { // To read/write from/to file FILE *file; // Read image (filename specified by first argument) into image data matrix if (!(file=fopen(filename,"rb"))) { cout << "Cannot open file: " << filename <<endl; exit(1); } fread(this->Imagedata, sizeof(unsigned char), this->width * this->height * this->BytesPerPixel, file); fclose(file); // Read image (filename specified by first argument) into image data matrix if (!(file=fopen(filename2,"rb"))) { cout << "Cannot open file: " << filename <<endl; exit(1); } fread(this->SecondImagedata, sizeof(unsigned char), 350 * 146 * this->BytesPerPixel, file); fclose(file); } int Image::bilinear_interpolation(unsigned char *data, float pPrime, int qPrime, int k, int inp_width) { /*Bilinear Implementation*/ int p, q; double a, b; int pixel; p = int(floor(pPrime)); q = int(floor(qPrime)); b = qPrime - q; a = pPrime - p; pixel = (1 - b) * ((1 - a) * *(data + (p + q * inp_width) * this->BytesPerPixel + k) + a * *(data + ((p + 1) + q * inp_width) * this->BytesPerPixel + k)) + b * ((1 - a) * *(data + (p + (q + 1) * inp_width) * this->BytesPerPixel + k) + a * *(data + ((p + 1) + (q + 1) * inp_width) * this->BytesPerPixel + k)); return pixel; } void Image::image_overlay() { double x2, y2, w2; vector<double> matrix_h; int temp; matrix_h.push_back(1.1141); matrix_h.push_back(0.8871); matrix_h.push_back(342.0565); matrix_h.push_back(-0.1676); matrix_h.push_back(0); matrix_h.push_back(612.4638); matrix_h.push_back(0.0009); matrix_h.push_back(0); matrix_h.push_back(1); for(int k = 0; k < BytesPerPixel; k++) { for(int i = 0; i < 146; i++) { for(int j = 0; j < 350; j++) { x2 = matrix_h.at(0) * j + matrix_h.at(1) * i + matrix_h.at(2); y2 = matrix_h.at(3) * j + matrix_h.at(4) * i + matrix_h.at(5); w2 = matrix_h.at(6) * j + matrix_h.at(7) * i + matrix_h.at(8); x2 /= w2; y2 /= w2; // cout << " x2 " << x2 << " y2 " << y2 << " i " << i << " j " << j << endl; if(x2 - int(x2) != 0 || y2 - int(y2) != 0) { temp = this->bilinear_interpolation(this->SecondImagedata, j, i, k, 350); if(temp && temp != 255) { *(this->Imagedata + (int(x2) + int(y2) * this->width) * BytesPerPixel + k) = temp; } } else { if(*(this->SecondImagedata + (j + i * 350) * BytesPerPixel + k) != 0 && *(this->SecondImagedata + (j + i * 350) * BytesPerPixel + k) != 255) { *(this->Imagedata + (int(x2) + int(y2) * this->width) * BytesPerPixel + k) = *(this->SecondImagedata + (j + i * 350) * BytesPerPixel + k); } } } } } } void Image::write_image(char *filename, unsigned char *data, int inp_width, int inp_height) { // To read/write from/to file FILE *file; // Write image data (filename specified by second argument) from image data matrix if (!(file=fopen(filename,"wb"))) { cout << "Cannot open file: " << filename << endl; exit(1); } fwrite(data, sizeof(unsigned char), inp_width * inp_height * this->BytesPerPixel, file); fclose(file); }
[ "satvik@usc.edu" ]
satvik@usc.edu
4123895cca399ef047d1d9dfaff2744df4aee9d0
be0282afa8dd436619c71d6118c9db455eaf1a29
/Intermediate/Build/Win64/Design3D/Inc/SlateCore/FontBulkData.gen.cpp
b5c5d71b30bab518e16904b78dad1e8ab4f892a5
[]
no_license
Quant2017/Design3D
0f915580b222af40ab911021cceef5c26375d7f9
94a22386be4aa37aa0f546354cc62958820a4bf6
refs/heads/master
2022-04-23T10:44:12.398772
2020-04-22T01:02:39
2020-04-22T01:02:39
262,966,755
1
0
null
2020-05-11T07:12:37
2020-05-11T07:12:36
null
UTF-8
C++
false
false
3,331
cpp
// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved. /*=========================================================================== Generated code exported from UnrealHeaderTool. DO NOT modify this manually! Edit the corresponding .h files instead! ===========================================================================*/ #include "UObject/GeneratedCppIncludes.h" #include "SlateCore/Public/Fonts/FontBulkData.h" #include "Serialization/ArchiveUObjectFromStructuredArchive.h" #ifdef _MSC_VER #pragma warning (push) #pragma warning (disable : 4883) #endif PRAGMA_DISABLE_DEPRECATION_WARNINGS void EmptyLinkFunctionForGeneratedCodeFontBulkData() {} // Cross Module References SLATECORE_API UClass* Z_Construct_UClass_UFontBulkData_NoRegister(); SLATECORE_API UClass* Z_Construct_UClass_UFontBulkData(); COREUOBJECT_API UClass* Z_Construct_UClass_UObject(); UPackage* Z_Construct_UPackage__Script_SlateCore(); // End Cross Module References void UFontBulkData::StaticRegisterNativesUFontBulkData() { } UClass* Z_Construct_UClass_UFontBulkData_NoRegister() { return UFontBulkData::StaticClass(); } struct Z_Construct_UClass_UFontBulkData_Statics { static UObject* (*const DependentSingletons[])(); #if WITH_METADATA static const UE4CodeGen_Private::FMetaDataPairParam Class_MetaDataParams[]; #endif static const FCppClassTypeInfoStatic StaticCppClassTypeInfo; static const UE4CodeGen_Private::FClassParams ClassParams; }; UObject* (*const Z_Construct_UClass_UFontBulkData_Statics::DependentSingletons[])() = { (UObject* (*)())Z_Construct_UClass_UObject, (UObject* (*)())Z_Construct_UPackage__Script_SlateCore, }; #if WITH_METADATA const UE4CodeGen_Private::FMetaDataPairParam Z_Construct_UClass_UFontBulkData_Statics::Class_MetaDataParams[] = { { "IncludePath", "Fonts/FontBulkData.h" }, { "ModuleRelativePath", "Public/Fonts/FontBulkData.h" }, { "SerializeToFArchive", "" }, }; #endif const FCppClassTypeInfoStatic Z_Construct_UClass_UFontBulkData_Statics::StaticCppClassTypeInfo = { TCppClassTypeTraits<UFontBulkData>::IsAbstract, }; const UE4CodeGen_Private::FClassParams Z_Construct_UClass_UFontBulkData_Statics::ClassParams = { &UFontBulkData::StaticClass, nullptr, &StaticCppClassTypeInfo, DependentSingletons, nullptr, nullptr, nullptr, ARRAY_COUNT(DependentSingletons), 0, 0, 0, 0x001000A0u, METADATA_PARAMS(Z_Construct_UClass_UFontBulkData_Statics::Class_MetaDataParams, ARRAY_COUNT(Z_Construct_UClass_UFontBulkData_Statics::Class_MetaDataParams)) }; UClass* Z_Construct_UClass_UFontBulkData() { static UClass* OuterClass = nullptr; if (!OuterClass) { UE4CodeGen_Private::ConstructUClass(OuterClass, Z_Construct_UClass_UFontBulkData_Statics::ClassParams); } return OuterClass; } IMPLEMENT_CLASS(UFontBulkData, 944143668); template<> SLATECORE_API UClass* StaticClass<UFontBulkData>() { return UFontBulkData::StaticClass(); } static FCompiledInDefer Z_CompiledInDefer_UClass_UFontBulkData(Z_Construct_UClass_UFontBulkData, &UFontBulkData::StaticClass, TEXT("/Script/SlateCore"), TEXT("UFontBulkData"), false, nullptr, nullptr, nullptr); DEFINE_VTABLE_PTR_HELPER_CTOR(UFontBulkData); IMPLEMENT_FSTRUCTUREDARCHIVE_SERIALIZER(UFontBulkData) PRAGMA_ENABLE_DEPRECATION_WARNINGS #ifdef _MSC_VER #pragma warning (pop) #endif
[ "Snake_Jenny@126.com" ]
Snake_Jenny@126.com
a65687b068ace191c950d98542dbd0d52881be87
4a8909e83b18553c0fdeed0b8c29e3e3f306a4aa
/src/CollisionWorld.cpp
2edafb7aae81eb7ffce62897b4ae176c2bf1ac14
[ "Zlib" ]
permissive
marl0ncode/crush
a568429016a776af20aab4cafb2246efaa808e47
fe40a45e9091d8caf35e39d3d8f4648b6d191ea9
refs/heads/master
2021-06-24T20:08:21.680722
2015-11-01T11:19:11
2015-11-01T11:19:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
4,816
cpp
/********************************************************************* Matt Marchant 2014 - 2015 http://trederia.blogspot.com Crush - Zlib license. This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. *********************************************************************/ #include <CollisionWorld.hpp> #include <Node.hpp> #include <Util.hpp> #include <BodyBehaviour.hpp> #include <iostream> CollisionWorld::CollisionWorld(float gravity) : m_gravity(0.f, gravity) { } CollisionWorld::Body* CollisionWorld::addBody(CollisionWorld::Body::Type type, const sf::Vector2f& size) { auto b = std::make_unique<Body>(type, size); m_bodies.push_back(std::move(b)); return m_bodies.back().get(); } void CollisionWorld::addConstraint(CollisionWorld::Body* bodyA, CollisionWorld::Body* bodyB, float length) { assert(bodyA); assert(bodyB); //make sure the length meets minimum distance of bodies auto size = bodyA->getSize(); float radA = std::max(size.x, size.y); size = bodyB->getSize(); float radB = std::max(size.x, size.y); if (length > radA + radB) { m_constraints.emplace_back(bodyA, bodyB, length); } else { std::cerr << "Constraint length too short for given bodies, no constraint created" << std::endl; } } void CollisionWorld::step(float dt) { //check for deleted objects and remove them m_bodies.erase(std::remove_if(m_bodies.begin(), m_bodies.end(), [](const Body::Ptr& p) { return p->deleted(); }), m_bodies.end()); m_constraints.erase(std::remove_if(m_constraints.begin(), m_constraints.end(), [](const Constraint& c) { return c.deleted(); }), m_constraints.end()); //check for collision pairs and add to list //TODO we could narrow this down with space partitioning //like a quad tree, but probably not necessary in this game m_collisions.clear(); for (const auto& poA : m_bodies) { poA->m_footSenseCount = 0u; poA->m_footSenseMask = 0u; for (const auto& poB : m_bodies) { if (poA.get() != poB.get()) { //primary collision between bounding boxes if (poA->m_aabb.intersects(poB->m_aabb)) { //minmax assures that as the lowest values is always first in the set //that each collision pair only gets inserted once m_collisions.insert(std::minmax(poA.get(), poB.get())); } //secondary collisions with sensor boxes if (poA->m_footSensor.intersects(poB->m_aabb)) { poA->m_footSenseCount++; poA->m_footSenseMask |= poB->m_type; } } } } //resolve collision for each pair for (const auto& pair : m_collisions) { //call state resolve auto man = getManifold(pair); pair.second->m_behaviour->resolve(man, pair.first); man.z = -man.z; pair.first->m_behaviour->resolve(man, pair.second); } //apply any constraints to their respective bodies for (auto& c : m_constraints) { c.update(dt); } //update any parent node positions for (auto& b : m_bodies) { b->applyGravity(m_gravity); b->step(dt); } } //private sf::Vector3f CollisionWorld::getManifold(const CollisionPair& cp) { sf::Vector2f collisionNormal = cp.second->m_position - cp.first->m_position; sf::FloatRect overlap; //might seem less eficient than caching the first intersection test //but appears to work more accurately cp.first->m_aabb.intersects(cp.second->m_aabb, overlap); sf::Vector3f manifold; if (overlap.width < overlap.height) { manifold.x = (collisionNormal.x < 0) ? -1.f : 1.f; manifold.z = overlap.width; } else { manifold.y = (collisionNormal.y < 0) ? -1.f : 1.f; manifold.z = overlap.height; } return manifold; }
[ "matty_styles@hotmail.com" ]
matty_styles@hotmail.com
d18c0f9a9c9be60a3ef783c6eb5a796b586634c5
df1b3fd64f029c3d9f913f1ca7aae167a4ebce18
/benchmarks/01_trivial/05_packed_load_store.cpp
64482ab0517d4a2dcdf92c316b00fe6d8254ae37
[ "BSD-3-Clause" ]
permissive
sebpop/ispc
cd5dd26fc2de6c436a00a76f0e7a22eedd336981
bf959a96af1a362b1fe16895aa2ae997355ea05b
refs/heads/main
2023-04-23T19:23:24.798090
2021-04-07T20:42:34
2021-04-07T20:42:34
358,018,013
0
0
BSD-3-Clause
2021-04-14T19:22:09
2021-04-14T19:22:08
null
UTF-8
C++
false
false
10,821
cpp
#include <benchmark/benchmark.h> #include <bitset> #include <cstdint> #include <stdio.h> #include "../common.h" #include "05_packed_load_store_ispc.h" static Docs docs("Check packed_load_active/packed_store_active implementation of stdlib functions:\n" "[int32, int64] x [all_off, 1/16, 1/8, 1/4, 1/2, 3/4, 7/8, 15/16, all_on] versions.\n" "Observation:\n" " - it does make sense to test multiple mask pattern, as they behave substantantially differently for " "different implementations\n" " - implementations based on LLVM intrinsic is a good one, but not the best, as it don't do popcnt as " "part of intrinsic\n" " - performance was not evaluated for different data set sizes\n" " - 1/16, 1/8 behave like 1/4 for 4 wide targets, similarly 1/16 on 8 wide is 1/8\n" " - 1/2 even and 1/2 odd have different perfomance, that's not expected.\n" " - 1/2 even is about 20% regression on AVX2 (LLVM intrinsics vs old manual implementation) that's might be " "interesting to investigate\n" "Expectation:\n" " - No regressions\n"); // Minimum size is maximum target width, i.e. 64. // Larger buffer is better, but preferably to stay within L1. #define ARGS Arg(8192) //#define ARGS RangeMultiplier(2)->Range(64, 64<<15)->Complexity(benchmark::oN) template <typename T> static void init(T *src, T *dst, int count) { for (int i = 0; i < count; i++) { src[i] = static_cast<T>(i + 1); dst[i] = 0; } } template <typename T> static void check_packed_load_active_eq(T *src, T *dst, const unsigned int index, unsigned int num, int count) { int width = ispc::width(); int loc = 0; int checkVal = 0; for (int i = 0; i < count / width; i++) { for (int programIndex = 0; programIndex < width; programIndex++) { if ((programIndex & index) == 0) { checkVal += src[loc++]; } } } if (checkVal != num) { printf("Error check_packed_load_active index=%d.\n", index); } } template <typename T> static void check_packed_load_active_neq(T *src, T *dst, const unsigned int index, unsigned int num, int count) { int width = ispc::width(); int loc = 0; int checkVal = 0; for (int i = 0; i < count / width; i++) { for (int programIndex = 0; programIndex < width; programIndex++) { if ((programIndex & index) != 0) { checkVal += src[loc++]; } } } if (checkVal != num) { printf("Error check_packed_load_active index=%d.\n", index); } } template <typename T> static void check_packed_store_active_eq(T *src, T *dst, const unsigned int index, unsigned int num, int count) { int width = ispc::width(); int srcLoc = 0; int dstLoc = 0; for (int i = 0; i < count / width; i++) { for (int programIndex = 0; programIndex < width; programIndex++) { if ((programIndex & index) == 0) { if (src[srcLoc] != dst[dstLoc++]) { printf("Error check_packed_store_active loc=%d.\n", index); } } srcLoc++; } } } template <typename T> static void check_packed_store_active_neq(T *src, T *dst, const unsigned int index, unsigned int num, int count) { int width = ispc::width(); int srcLoc = 0; int dstLoc = 0; for (int i = 0; i < count / width; i++) { for (int programIndex = 0; programIndex < width; programIndex++) { if ((programIndex & index) != 0) { if (src[srcLoc] != dst[dstLoc++]) { printf("Error check_packed_store_active loc=%d.\n", index); } } srcLoc++; } } } template <typename T> static void check_packed_store_active2_eq(T *src, T *dst, const unsigned int index, unsigned int num, int count) { check_packed_store_active_eq(src, dst, index, num, count); } template <typename T> static void check_packed_store_active2_neq(T *src, T *dst, const unsigned int index, unsigned int num, int count) { check_packed_store_active_neq(src, dst, index, num, count); } #define PACKED_LOAD_STORE_COND(T_C, T_ISPC, FUNC, ACTIVE_RATIO) \ static void FUNC##_##T_ISPC##_##ACTIVE_RATIO##_eq(benchmark::State &state) { \ int count = static_cast<int>(state.range(0)); \ T_C *dst = static_cast<T_C *>(aligned_alloc_helper(sizeof(T_C) * count)); \ T_C *src = static_cast<T_C *>(aligned_alloc_helper(sizeof(T_C) * count)); \ init(src, dst, count); \ const unsigned int index = ACTIVE_RATIO; \ unsigned int num = 0; \ \ for (auto _ : state) { \ num = ispc::FUNC##_##T_ISPC##_eq(src, dst, index, count); \ } \ \ check_##FUNC##_eq(src, dst, index, num, count); \ aligned_free_helper(src); \ aligned_free_helper(dst); \ state.SetComplexityN(state.range(0)); \ } \ BENCHMARK(FUNC##_##T_ISPC##_##ACTIVE_RATIO##_eq)->ARGS; \ \ static void FUNC##_##T_ISPC##_##ACTIVE_RATIO##_neq(benchmark::State &state) { \ int count = static_cast<int>(state.range(0)); \ T_C *dst = static_cast<T_C *>(aligned_alloc_helper(sizeof(T_C) * count)); \ T_C *src = static_cast<T_C *>(aligned_alloc_helper(sizeof(T_C) * count)); \ init(src, dst, count); \ const unsigned int index = ACTIVE_RATIO; \ unsigned int num = 0; \ \ for (auto _ : state) { \ num = ispc::FUNC##_##T_ISPC##_neq(src, dst, index, count); \ } \ \ check_##FUNC##_neq(src, dst, index, num, count); \ aligned_free_helper(src); \ aligned_free_helper(dst); \ state.SetComplexityN(state.range(0)); \ } \ BENCHMARK(FUNC##_##T_ISPC##_##ACTIVE_RATIO##_neq)->ARGS; // The last argument constant means the following: // 0 is all-on, all-off // 1 is 1/2 - even, odd // 3 is 1/4, 3/4 // 7 is 1/8, 7/8 // 15 is 1/16, 15/16 PACKED_LOAD_STORE_COND(int32_t, int32, packed_load_active, 0) PACKED_LOAD_STORE_COND(int32_t, int32, packed_load_active, 1) PACKED_LOAD_STORE_COND(int32_t, int32, packed_load_active, 3) PACKED_LOAD_STORE_COND(int32_t, int32, packed_load_active, 7) PACKED_LOAD_STORE_COND(int32_t, int32, packed_load_active, 15) PACKED_LOAD_STORE_COND(int32_t, int32, packed_store_active, 0) PACKED_LOAD_STORE_COND(int32_t, int32, packed_store_active, 1) PACKED_LOAD_STORE_COND(int32_t, int32, packed_store_active, 3) PACKED_LOAD_STORE_COND(int32_t, int32, packed_store_active, 7) PACKED_LOAD_STORE_COND(int32_t, int32, packed_store_active, 15) PACKED_LOAD_STORE_COND(int32_t, int32, packed_store_active2, 0) PACKED_LOAD_STORE_COND(int32_t, int32, packed_store_active2, 1) PACKED_LOAD_STORE_COND(int32_t, int32, packed_store_active2, 3) PACKED_LOAD_STORE_COND(int32_t, int32, packed_store_active2, 7) PACKED_LOAD_STORE_COND(int32_t, int32, packed_store_active2, 15) PACKED_LOAD_STORE_COND(int64_t, int64, packed_load_active, 0) PACKED_LOAD_STORE_COND(int64_t, int64, packed_load_active, 1) PACKED_LOAD_STORE_COND(int64_t, int64, packed_load_active, 3) PACKED_LOAD_STORE_COND(int64_t, int64, packed_load_active, 7) PACKED_LOAD_STORE_COND(int64_t, int64, packed_load_active, 15) PACKED_LOAD_STORE_COND(int64_t, int64, packed_store_active, 0) PACKED_LOAD_STORE_COND(int64_t, int64, packed_store_active, 1) PACKED_LOAD_STORE_COND(int64_t, int64, packed_store_active, 3) PACKED_LOAD_STORE_COND(int64_t, int64, packed_store_active, 7) PACKED_LOAD_STORE_COND(int64_t, int64, packed_store_active, 15) PACKED_LOAD_STORE_COND(int64_t, int64, packed_store_active2, 0) PACKED_LOAD_STORE_COND(int64_t, int64, packed_store_active2, 1) PACKED_LOAD_STORE_COND(int64_t, int64, packed_store_active2, 3) PACKED_LOAD_STORE_COND(int64_t, int64, packed_store_active2, 7) PACKED_LOAD_STORE_COND(int64_t, int64, packed_store_active2, 15) BENCHMARK_MAIN();
[ "dmitry.y.babokin@intel.com" ]
dmitry.y.babokin@intel.com
e1c5a27c61fc9d0ccefa598d787d2e59b4d4e1f0
72aca11f973b7c337012475ad3111cd20a5dd589
/others/NOIOnline/running.cpp
4f5d8847e6a273d74829004a493aaa790dc2aca4
[]
no_license
aplqo/exercises
a4cee1acbef91e64aee2bd096cd7e0bb834926a4
e28f14eaf89481c34bc1a27206e8cea2d2d94869
refs/heads/master
2021-06-25T06:34:09.535835
2021-04-08T13:52:39
2021-04-08T13:52:39
217,698,619
0
0
null
null
null
null
UTF-8
C++
false
false
833
cpp
#ifdef APTEST #include "debug_tools/program.h" #endif #include <algorithm> #include <cstdio> using namespace std; typedef long long num_t; const int maxn = 1e5; num_t f[maxn + 10] = {0, 1}, mod; num_t sum[maxn + 10][2] = {{0, 0}, {1, 1}, {2, 1}}; int main() { #if (!defined(APTEST)) && (!defined(APDEBUG)) freopen("running.in", "r", stdin); freopen("running.out", "w", stdout); #endif unsigned int n; scanf("%u%lld", &n, &mod); for (unsigned int i = 2; i <= n; ++i) { const unsigned int t = i / 2, pos = i + 1; f[i] = (sum[pos - 2 * t][1] % mod + mod) % mod; f[i] = ((f[i] + sum[t + (i % 2)][0]) % mod + mod) % mod; sum[pos][0] = (sum[pos - 1][0] + f[i]) % mod; sum[pos - 2][1] = (sum[pos - 2][1] + f[i]) % mod; } f[n] = f[n] % static_cast<num_t>(1e9 + 7); printf("%lld\n", f[n]); return 0; }
[ "aplqo@outlook.com" ]
aplqo@outlook.com
e2bebdd2f3d43af759ffa9b30cadcd78ce2e080f
6f4883cec42366e1ed7dc4ddf25b56e7702b0c69
/2992/6244664_AC_625MS_168K.cpp
bea6d998a5f6629b2411b430f835fce0f7de4980
[]
no_license
15800688908/poj-codes
89e3739df0db4bd4fe22db3e0bf839fc7abe35d1
913331dd1cfb6a422fb90175dcddb54b577d1059
refs/heads/master
2022-01-25T07:55:15.590648
2016-09-30T13:08:24
2016-09-30T13:08:24
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,308
cpp
#include<iostream> int prime[500]; int n,k,top; __int64 result; int main() { int i,j,c,num; prime[1]=2; top=1; for(i=3;i<=431;i+=2) { for(j=2;j*j<=i;j++) if(i%j==0) break; if(j*j>i) prime[++top]=i; } while(EOF!=scanf("%d %d",&n,&k)) { if(k==0||k==n) { printf("1\n"); continue; } result=1; for(i=1;i<=top&&prime[i]<=n;i++) { num=0; j=n; c=prime[i]; while(j/c) { num+=j/c; c*=prime[i]; } j=k; c=prime[i]; while(j/c) { num-=j/c; c*=prime[i]; } j=n-k; c=prime[i]; while(j/c) { num-=j/c; c*=prime[i]; } result*=(num+1); } printf("%I64d\n",result); } }
[ "dilin.life@gmail.com" ]
dilin.life@gmail.com
4d60e41c09cfed1d03ebf07003c31a37105732d5
5b83a3eef49ac004b98ff1ff9ce30989fd85c567
/CodeChef/FEB19B/GUESSRT.cpp
5cbec105fd5a5d0cde1aea0eae39cbcd498c933f
[]
no_license
floreaadrian/AlgCodes
cd0dfe331d2b1acae26ead05c4be07d6c3c05f52
b3ba2472ba256a73daea334c22bbca282ff3a24d
refs/heads/master
2020-05-25T14:34:27.475469
2019-05-21T13:49:35
2019-05-21T13:49:35
187,846,889
1
0
null
null
null
null
UTF-8
C++
false
false
1,782
cpp
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <math.h> using namespace std; #define modulo 1000000007 long long power(long long base, long long exp) { base %= modulo; long long result = 1; while (exp > 0) { if (exp & 1) result = (result * base) % modulo; base = (base * base) % modulo; exp >>= 1; } return result; } void gcdExtended(long long a, long long b, long long *x, long long *y) { if (a == 0) { *x = 0, *y = 1; return; } long long x1, y1; gcdExtended(b % a, a, &x1, &y1); *x = y1 - (b / a) * x1; *y = x1; } long long inverse(long long a, long long m) { long long x, y; gcdExtended(a, m, &x, &y); return (x % m + m) % m; } int main() { int t; cin >> t; for (int tt = 0; tt < t; tt++) { long long n, k, m; cin >> n >> k >> m; if (n == 1) { cout << "1\n"; continue; } if (m == 1) { cout << inverse(n, modulo) << "\n"; continue; } long long res; if (n > k) { if (n % k == 0) n = k; else n = n % k; m--; } long long mm = m; m = (m + 1) / 2; long long a = power(n, m); long long b = power(n - 1, m); res = (a - b) % modulo; res = (res * inverse(a, modulo)) % modulo; long long c = 0; if (mm % 2 == 0) { c = (b * inverse(a, modulo)) % modulo; c = (c * inverse((n + k) % modulo, modulo)) % modulo; } res = (res + c) % modulo; cout << res << '\n'; } return 0; }
[ "florea.adrian.paul@gmail.com" ]
florea.adrian.paul@gmail.com
4309e194dafa2ac2cf7af0c2f08e36fae25594df
88ae8695987ada722184307301e221e1ba3cc2fa
/components/enterprise/browser/reporting/report_scheduler.h
afcb98f159277e83315d78355d1ff8b10a564c6a
[ "BSD-3-Clause" ]
permissive
iridium-browser/iridium-browser
71d9c5ff76e014e6900b825f67389ab0ccd01329
5ee297f53dc7f8e70183031cff62f37b0f19d25f
refs/heads/master
2023-08-03T16:44:16.844552
2023-07-20T15:17:00
2023-07-23T16:09:30
220,016,632
341
40
BSD-3-Clause
2021-08-13T13:54:45
2019-11-06T14:32:31
null
UTF-8
C++
false
false
7,667
h
// Copyright 2019 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef COMPONENTS_ENTERPRISE_BROWSER_REPORTING_REPORT_SCHEDULER_H_ #define COMPONENTS_ENTERPRISE_BROWSER_REPORTING_REPORT_SCHEDULER_H_ #include <memory> #include <string> #include "base/functional/callback_forward.h" #include "base/memory/raw_ptr.h" #include "base/memory/weak_ptr.h" #include "base/time/time.h" #include "base/timer/wall_clock_timer.h" #include "components/enterprise/browser/reporting/chrome_profile_request_generator.h" #include "components/enterprise/browser/reporting/real_time_report_generator.h" #include "components/enterprise/browser/reporting/report_generator.h" #include "components/enterprise/browser/reporting/report_uploader.h" #include "components/policy/core/common/cloud/dm_token.h" #include "components/prefs/pref_change_registrar.h" namespace policy { class CloudPolicyClient; } // namespace policy namespace enterprise_reporting { class RealTimeUploader; // Schedules report generation and upload every 24 hours (and upon browser // update for desktop Chrome) while cloud reporting is enabled via // administrative policy. If either of these triggers fires while a report is // being generated, processing is deferred until the existing processing // completes. class ReportScheduler { public: // The trigger leading to report generation. Values are bitmasks in the // |pending_triggers_| bitfield. enum ReportTrigger : uint32_t { kTriggerNone = 0, // No trigger. kTriggerTimer = 1U << 0, // The periodic timer expired. kTriggerUpdate = 1U << 1, // An update was detected. kTriggerNewVersion = 1U << 2, // A new version is running. kTriggerManual = 1U << 3, // Trigger manually. // Pending extension requests updated, with encrypted realtime pipeline. kTriggerExtensionRequestRealTime = 1U << 4, }; using ReportTriggerCallback = base::RepeatingCallback<void(ReportTrigger)>; using RealtimeReportTriggerCallback = base::RepeatingCallback<void(ReportTrigger, const RealTimeReportGenerator::Data&)>; class Delegate { public: Delegate(); Delegate(const Delegate&) = delete; Delegate& operator=(const Delegate&) = delete; virtual ~Delegate(); void SetReportTriggerCallback(ReportTriggerCallback callback); void SetRealtimeReportTriggerCallback( RealtimeReportTriggerCallback callback); virtual PrefService* GetPrefService() = 0; // Browser version virtual void StartWatchingUpdatesIfNeeded( base::Time last_upload, base::TimeDelta upload_interval) = 0; virtual void StopWatchingUpdates() = 0; virtual void OnBrowserVersionUploaded() = 0; // Extension request virtual void StartWatchingExtensionRequestIfNeeded() = 0; virtual void StopWatchingExtensionRequest() = 0; virtual void OnExtensionRequestUploaded() = 0; virtual policy::DMToken GetProfileDMToken() = 0; virtual std::string GetProfileClientId() = 0; protected: ReportTriggerCallback trigger_report_callback_; RealtimeReportTriggerCallback trigger_realtime_report_callback_; }; struct CreateParams { CreateParams(); CreateParams(const CreateParams&) = delete; CreateParams& operator=(const CreateParams&) = delete; CreateParams(CreateParams&& other); CreateParams& operator=(CreateParams&& other); ~CreateParams(); raw_ptr<policy::CloudPolicyClient> client; std::unique_ptr<ReportGenerator> report_generator; std::unique_ptr<RealTimeReportGenerator> real_time_report_generator; std::unique_ptr<ChromeProfileRequestGenerator> profile_request_generator; std::unique_ptr<ReportScheduler::Delegate> delegate; }; explicit ReportScheduler(CreateParams params); ReportScheduler(const ReportScheduler&) = delete; ReportScheduler& operator=(const ReportScheduler&) = delete; ~ReportScheduler(); // Returns true if cloud reporting is enabled. bool IsReportingEnabled() const; // Returns true if next report has been scheduled. The report will be // scheduled only if the previous report is uploaded successfully and the // reporting policy is still enabled. bool IsNextReportScheduledForTesting() const; ReportTrigger GetActiveTriggerForTesting() const; void SetReportUploaderForTesting(std::unique_ptr<ReportUploader> uploader); void SetExtensionRequestUploaderForTesting( std::unique_ptr<RealTimeUploader> uploader); Delegate* GetDelegateForTesting(); void OnDMTokenUpdated(); void UploadFullReport(base::OnceClosure on_report_uploaded); private: // Observes CloudReportingEnabled policy. void RegisterPrefObserver(); // Handles kCloudReportingEnabled policy value change, including the first // policy value check during startup. void OnReportEnabledPrefChanged(); // Stops the periodic timer and the update observer. void Stop(); // Stop the timer if there is any and reschedule the next report based on // latest report frequency. void RestartReportTimer(); // Register |cloud_policy_client_| with dm token and client id for desktop // browser only. (Chrome OS doesn't need this step here.) bool SetupBrowserPolicyClientRegistration(); // Starts the periodic timer based on the last time a report was uploaded. void Start(base::Time last_upload_time); // Starts report generation in response to |trigger|. void GenerateAndUploadReport(ReportTrigger trigger); void GenerateAndUploadRealtimeReport( ReportTrigger trigger, const RealTimeReportGenerator::Data& data); // Continues processing a report (contained in the |requests| collection) by // sending it to the uploader. void OnReportGenerated(ReportRequestQueue requests); // Finishes processing following report upload. |status| indicates the result // of the attempted upload. void OnReportUploaded(ReportUploader::ReportStatus status); // Initiates report generation for any triggers that arrived during generation // of another report. void RunPendingTriggers(); // Creates and uploads extension requests with real time reporting pipeline. void UploadExtensionRequests(const RealTimeReportGenerator::Data& data); // Records that |trigger| was responsible for an upload attempt. static void RecordUploadTrigger(ReportTrigger trigger); ReportType TriggerToReportType(ReportTrigger trigger); std::unique_ptr<Delegate> delegate_; // Policy value watcher PrefChangeRegistrar pref_change_registrar_; raw_ptr<policy::CloudPolicyClient> cloud_policy_client_; base::WallClockTimer request_timer_; std::unique_ptr<ReportUploader> report_uploader_; std::unique_ptr<RealTimeUploader> extension_request_uploader_; std::unique_ptr<ReportGenerator> report_generator_; std::unique_ptr<ChromeProfileRequestGenerator> profile_request_generator_; std::unique_ptr<RealTimeReportGenerator> real_time_report_generator_; // The trigger responsible for initiating active report generation. ReportTrigger active_trigger_ = kTriggerNone; // The set of triggers that have fired while processing a report (a bitfield // of ReportTrigger values). They will be handled following completion of the // in-process report. uint32_t pending_triggers_ = 0; std::string reporting_pref_name_; ReportType full_report_type_; base::OnceClosure on_manual_report_uploaded_; base::WeakPtrFactory<ReportScheduler> weak_ptr_factory_{this}; }; } // namespace enterprise_reporting #endif // COMPONENTS_ENTERPRISE_BROWSER_REPORTING_REPORT_SCHEDULER_H_
[ "jengelh@inai.de" ]
jengelh@inai.de
8ac1cc923d18fd49c1f7b5aa51de1439e70d2c58
e692e07b8f25bc765fa6ddfb518300e3777962d9
/TD8/POO-TD8/src/Herbivorous.h
2dfdeee5a9177903d13a419ce9c912c94caeb6e3
[]
no_license
danyfel80/pooAvancee
eaf1865d2a406c0fb1daf1c1e8ca37b29d2b30c5
be318a27a10238ea009ccb7b815586d97f33b155
refs/heads/master
2020-03-29T14:33:51.801151
2018-12-03T23:07:59
2018-12-03T23:07:59
150,023,467
2
1
null
null
null
null
UTF-8
C++
false
false
387
h
/* * Herbivorous.h * * Created on: Nov 20, 2018 * Author: daniel */ #ifndef HERBIVOROUS_H_ #define HERBIVOROUS_H_ #include "Animal.h" class Herbivorous: public virtual Animal { public: Herbivorous(); virtual ~Herbivorous(); virtual string getDescription() const; virtual string getEatingHabits() const; virtual string toString() const; }; #endif /* HERBIVOROUS_H_ */
[ "danyfel80@gmail.com" ]
danyfel80@gmail.com
96c5d395fc5eae66235d5d713f1872683517c93f
385cfbb27ee3bcc219ec2ac60fa22c2aa92ed8a0
/ThirdParty/fbxsdk/2009.3/include/fbxfilesdk/kfbxplugins/kfbxsystemunit.h
66aa24f3c1121ed9361b2d8dd5297250278639ff
[ "LicenseRef-scancode-unknown-license-reference", "MIT" ]
permissive
palestar/medusa
edbddf368979be774e99f74124b9c3bc7bebb2a8
7f8dc717425b5cac2315e304982993354f7cb27e
refs/heads/develop
2023-05-09T19:12:42.957288
2023-05-05T12:43:35
2023-05-05T12:43:35
59,434,337
35
18
MIT
2018-01-21T01:34:01
2016-05-22T21:05:17
C++
WINDOWS-1252
C++
false
false
8,261
h
/*! \file kfbxsystemunit.h */ #ifndef FBXFILESDK_KFBXPLUGINS_KFBXSYSTEMUNIT_H #define FBXFILESDK_KFBXPLUGINS_KFBXSYSTEMUNIT_H /************************************************************************************** Copyright © 2001 - 2008 Autodesk, Inc. and/or its licensors. All Rights Reserved. The coded instructions, statements, computer programs, and/or related material (collectively the "Data") in these files contain unpublished information proprietary to Autodesk, Inc. and/or its licensors, which is protected by Canada and United States of America federal copyright law and by international treaties. The Data may not be disclosed or distributed to third parties, in whole or in part, without the prior written consent of Autodesk, Inc. ("Autodesk"). THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY. ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR ARISING BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE OR USE. WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT WARRANT THAT THE OPERATION OF THE DATA WILL BE UNINTERRUPTED OR ERROR FREE. IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR EXPENSES OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE DAMAGES OR OTHER SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS OF PROFITS, REVENUE OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR DAMAGES OF ANY KIND), HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF LIABILITY, WHETHER DERIVED FROM CONTRACT, TORT (INCLUDING, BUT NOT LIMITED TO, NEGLIGENCE), OR OTHERWISE, ARISING OUT OF OR RELATING TO THE DATA OR ITS USE OR ANY OTHER PERFORMANCE, WHETHER OR NOT AUTODESK HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE. **************************************************************************************/ #include <fbxfilesdk/components/kbaselib/kaydaradef_h.h> #include <fbxfilesdk/components/kbaselib/kaydara.h> #include <fbxfilesdk/components/kbaselib/klib/kstring.h> #include <fbxfilesdk/components/kbaselib/klib/karrayul.h> #include <fbxfilesdk/fbxfilesdk_nsbegin.h> class KFbxGlobalSettings; class KFCurve; class KFbxXMatrix; class KFbxNode; class KFbxScene; /** \brief This class is used to describe the units of measurement used within a particular scene. * \nosubgrouping */ class KFBX_DLL KFbxSystemUnit { public: /** Defines various options that can be set for converting the units of a scene */ struct KFbxUnitConversionOptions { bool mConvertLightIntensity; /**< Convert the intensity property of lights. */ bool mConvertRrsNodes; /**< Convert the nodes that do not inheirit their parent's scale */ }; /** Constructor * \param pScaleFactor The equivalent number of centimeters in the new system unit. * eg For an inch unit, use a scale factor of 2.54 * \param pMultiplier A multiplier factor of pScaleFactor. */ KFbxSystemUnit(double pScaleFactor, double pMultiplier = 1.0); ~KFbxSystemUnit(); // predefined units static const KFbxSystemUnit mm; static const KFbxSystemUnit dm; static const KFbxSystemUnit cm; static const KFbxSystemUnit m; static const KFbxSystemUnit km; static const KFbxSystemUnit Inch; static const KFbxSystemUnit Foot; static const KFbxSystemUnit Mile; static const KFbxSystemUnit Yard; #define KFbxSystemUnit_sPredefinedUnitCount 9 static const KFbxSystemUnit *sPredefinedUnits; // points to an array of KFbxSystemUnit_sPredifinedUnitCount size static const KFbxUnitConversionOptions DefaultConversionOptions; /** Convert a scene from its system units to this unit. * \param pScene The scene to convert * \param pOptions Various conversion options. See KFbxSystemUnit::KFbxUnitConversionOptions */ void ConvertScene( KFbxScene* pScene, const KFbxUnitConversionOptions& pOptions = DefaultConversionOptions ) const; /** Converts the children of the given node to this system unit. * Unlike the ConvertScene() method, this method does not set the axis system * of the scene that the pRoot node belongs, nor does it adjust KFbxPoses * as they are not stored under the scene, and not under a particular node. * \param pRoot The given node. * \param pSrcUnit The source system unit. * \param pOptions Various conversion options. See KFbxSystemUnit::KFbxUnitConversionOptions */ void ConvertChildren( KFbxNode* pRoot, const KFbxSystemUnit& pSrcUnit, const KFbxUnitConversionOptions& pOptions = DefaultConversionOptions ) const; /** Convert a scene from its system units to this unit, using the specified * Fbx_Root node. This method is provided for backwards compatibility only * and ConvertScene( KFbxScene* , const KFbxUnitConversionOptions& ) should * be used instead whenever possible. * \param pScene The scene to convert * \param pFbxRoot The Fbx_Root node to use in conversion * \param pOptions Conversion options. See KFbxSystemUnit::KFbxUnitConversionOptions */ void ConvertScene( KFbxScene* pScene, KFbxNode* pFbxRoot, const KFbxUnitConversionOptions& pOptions = DefaultConversionOptions ) const; /** Gets the scale factor of this system unit, relative to centimeters. * This factor scales values in system units to centimeters. * For the purpose of scaling values to centimeters, this value should be used * and the "multiplier" (returned by GetMultiplier()) should be ignored. */ double GetScaleFactor() const; /** Returns a unit label for the current scale factor. * \param pAbbreviated If \c true, abbreviated string will return. */ KString GetScaleFactorAsString(bool pAbbreviated = true) const; /** Returns a unit label for the current scale factor. Capital first letter + "s" added + foot -> feet */ KString GetScaleFactorAsString_Plurial() const; /** Gets the multiplier factor of this system unit. */ double GetMultiplier() const; bool operator ==(const KFbxSystemUnit& pOther) const; bool operator !=(const KFbxSystemUnit& pOther) const; /** Returns the conversion factor from this unit to pTarget (does not include the muliplier factor). * \param pTarget The target unit. */ double GetConversionFactorTo( const KFbxSystemUnit& pTarget ) const; /** Returns the conversion factor from pSource to this unit * \param pSource The source unit. */ double GetConversionFactorFrom( const KFbxSystemUnit& pSource ) const; /////////////////////////////////////////////////////////////////////////////// // // WARNING! // // Anything beyond these lines may not be documented accurately and is // subject to change without notice. // /////////////////////////////////////////////////////////////////////////////// protected: double mScaleFactor; double mMultiplier; void ApplyMultiplier(KFbxNode* pRoot, bool pSubChildrenOnly) const; void ConvertSTProperties(KArrayTemplate<KFbxNode*>& pNodes, double pConversionFactor) const; void ConvertSProperty(KArrayTemplate<KFbxNode*>& pNodes, double pConversionFactor) const; void ConvertFCurve(KArrayTemplate<KFCurve*>& pFCurves, double pConversionFactor) const; double GetConversionFactor( double pTargetScaleFactor, double pSourceScaleFactor) const; void AdjustPivots(KFbxNode* pNode, double pConversionFactor, KFbxXMatrix& pOriginalGlobalM ) const; void AdjustLimits(KFbxNode* pNode, double pConversionFactor) const; void AdjustPoses(KFbxScene* pScene, double pConversionFactor) const; void AdjustCluster(KFbxNode* pNode, double pConversionFactor) const; void AdjustLightIntensity(KFbxNode* pNode, const double pConversionFactor) const; void AdjustPhotometricLightProperties(KFbxNode* pNode, const double pConversionFactor) const; void AdjustCameraClipPlanes(KFbxNode* pNode, const double pConversionFactor) const; void ConvertChildren( KFbxNode* pRoot, const KFbxSystemUnit& pSrcUnit, bool pSubChildrenOnly, const KFbxUnitConversionOptions& pOptions ) const; friend class KFbxGlobalSettings; }; #include <fbxfilesdk/fbxfilesdk_nsend.h> #endif // FBXFILESDK_KFBXPLUGINS_KFBXSYSTEMUNIT_H
[ "rlyle@palestar.com" ]
rlyle@palestar.com
416f6aa03a46a494809718770f3245aa33c37325
48614ea523aae6c1fc53dbd97f0d5c772f21066f
/src/MessageParser.cpp
c38dba1b5f2c9009e52e10aaa89719fb6021435f
[]
no_license
zhangjun03402/TaskDispatcher
d74ab6e23cbc7762fb30406437b23b5822f4f939
90f7534f98997c90359e732240e27fd7973fa34b
refs/heads/master
2021-01-12T15:18:43.409266
2016-10-30T07:23:35
2016-10-30T07:23:35
71,752,259
0
0
null
null
null
null
GB18030
C++
false
false
9,303
cpp
#include "MessageParser.h" #include <cassert> //rep msg base class CResponseMsg::CResponseMsg(string strTaskID) { task_id = strTaskID; } E_BIZ_TYPE CResponseMsg::getRspMsgType() { return E_BIZ_TYPE_UNKOWN; } void CResponseMsg::sendZframe(zframe_t *id_frame, void *sock, string strJson, bool bWorker) { zframe_t *response_frame = zframe_new(strJson.c_str(), strJson.size()); zmsg_t *msg = zmsg_new(); if(bWorker) zmsg_addmem(msg, NULL, 0); // delimiter zmsg_append(msg, &id_frame); zmsg_addmem(msg, NULL, 0); // delimiter zmsg_append(msg, &response_frame); zmsg_send(&msg, sock); assert(response_frame == NULL); } CCtrlResponse::CCtrlResponse(string strTaskID) : CResponseMsg(strTaskID) { } E_BIZ_TYPE CCtrlResponse::getRspMsgType() { return E_BIZ_TYPE_CTRL; } void CCtrlResponse::sendResponse(zframe_t *id_frame, void *sock, string strCtrlResult) { Json::Value root; string strJson; root["task_id"] = task_id; root["result"] = strCtrlResult; strJson = root.toStyledString(); sendZframe(id_frame, sock, strJson, false); } //voice response base class of check and recog CVoiceResponse::CVoiceResponse(string strTaskID):CResponseMsg(strTaskID) { status_code = 0; sequence = 0; start_time_stamp = 0; end_time_stamp = 0; } E_BIZ_TYPE CVoiceResponse::getRspMsgType() { return E_BIZ_TYPE_UNKOWN; } void CVoiceResponse::sendResponse(zframe_t *id_frame, void *sock, E_MSG_TYPE msgType, bool bWorker) { string strJson = this->RspMsg2JsonStr(msgType); sendZframe(id_frame, sock, strJson, bWorker); } string CVoiceResponse::RspMsg2JsonStr(E_MSG_TYPE msgType) { return string(); } //根据响应消息类型,生成返回消息 void CVoiceResponse::buildRspMsg(E_MSG_TYPE msgType) { switch (msgType) { case E_MSG_TYPE_BIZ_NORMAL: message = "Normal data!"; status_code = E_STATUS_BIZ_NORMAL; break; case E_MSG_TYPE_ACCEPT_SUCC: message = "Recv msg success!"; status_code = E_STATUS_ACCEPT_OK; break; case E_MSG_TYPE_BIZ_FAIL: message = "Service not available!"; status_code = E_STATUS_ISNULL; break; case E_MSG_TYPE_CONN_ERROR: message = "Connect rtsp server error!"; status_code = E_STATUS_CONN_ERROR; break; case E_MSG_TYPE_START_RTSP_ERROR: message = "Start(Restart) rtsp server error!"; status_code = E_STATUS_START_RTSP_ERR; break; case E_MSG_TYPE_DOG_ERROR: message = "Encrypted dog authentication failed!"; status_code = E_STATUS_AUTH_DOG_ERROR; break; case E_MSG_TYPE_JSON_ERROR: message = "receive json msg error!"; status_code = E_STATUS_JSON_ERROR; break; case E_MSG_TYPE_SEND_FINISH: message = "send message finish!"; status_code = E_STATUS_FINISH; break; case E_MSG_TYPE_STREAM_OVER: message = "stream is over!"; status_code = E_STATUS_STREAM_IS_OVER; break; case E_MSG_TYPE_USER_CANCEL: message = "user cancel success!"; status_code = E_STATUS_BIZ_CANCEL_SUCC; break; case E_MSG_TYPE_SERVER_BUSY: message = "server is busy,please try again later!"; status_code = E_STATUS_FINISH; break; default: break; } } //check rsp msg class CCheckResponse::CCheckResponse(string strTaskID): CVoiceResponse(strTaskID) { Clip = 0.0; Speech = 0.0; Noise = 0.0; } E_BIZ_TYPE CCheckResponse::getRspMsgType() { return E_BIZ_TYPE_CHECK; } void CCheckResponse::setCheckParameter(float fClip, float fSpeech, float fNoise) { Clip = fClip; Speech = fSpeech; Noise = fNoise; } string CCheckResponse::RspMsg2JsonStr(E_MSG_TYPE msgType) { buildRspMsg(msgType); //生成message和status_code字段的值 Json::Value root; //root node root["task_id"] = task_id; root["message"] = message; root["sequence"] = sequence; root["status_code"] = status_code; Json::Value result; result["start_time"]= start_time_stamp; result["end_time"] = end_time_stamp; result["Clip"] = Clip; result["Speech"] = Speech; result["Noise"] = Noise; root["result"] = result; return root.toStyledString(); } //recog rsp msg class CRecogResponse::CRecogResponse(string strTaskID) : CVoiceResponse( strTaskID ) { } E_BIZ_TYPE CRecogResponse::getRspMsgType() { return E_BIZ_TYPE_ASR; } void CRecogResponse::setRecogParameter(string strText) { text = strText; } string CRecogResponse::RspMsg2JsonStr(E_MSG_TYPE msgType) { buildRspMsg(msgType); //生成message和status_code字段的值 Json::Value root; //root node root["task_id"] = task_id; root["message"] = message; root["sequence"] = sequence; root["status_code"] = status_code; Json::Value result; result["start_time"]= start_time_stamp; result["end_time"] = end_time_stamp; result["text"] = text; root["result"] = result; return root.toStyledString(); } CMessageParser::CMessageParser( ) { m_emMsgType = E_BIZ_TYPE_UNKOWN; } CMessageParser::~CMessageParser() {} bool CMessageParser::Init(string strReqJson) { Json::Reader reader; Json::Value root; if (!reader.parse(strReqJson, root)) return false; m_valJsonReqValue = root["request_value"]; string root_value = root["request_type"].asString(); if (root_value == "asr") m_emMsgType = E_BIZ_TYPE_ASR; else if (root_value == "task_control") m_emMsgType = E_BIZ_TYPE_CTRL; else if (root_value == "audio_state_checker") m_emMsgType = E_BIZ_TYPE_CHECK; else { m_emMsgType = E_BIZ_TYPE_UNKOWN; return false; } return true; } E_BIZ_TYPE CMessageParser::GetReqMsgType() { return m_emMsgType; } string CMessageParser::GetValueFromKey(string strKey) { return m_valJsonReqValue[strKey].asString(); } string CMessageParser::GetReqTaskID() { return GetValueFromKey("task_id"); } void CMessageParser::GetCheckRequest(VOICE_CHECK_REQ &req) { assert(m_emMsgType == E_BIZ_TYPE_CHECK); string t_id = m_valJsonReqValue["task_id"].asString(); memcpy(req.task_id, t_id.c_str(), t_id.length() + 1); string url = m_valJsonReqValue["media_url"].asString(); memcpy(req.media_url, url.c_str(), url.length() + 1); req.start_time = m_valJsonReqValue["start_time"].asInt(); req.media_duration = m_valJsonReqValue["duration"].asInt(); req.value_post_time = m_valJsonReqValue["value_post_time"].asInt(); req.FS = m_valJsonReqValue["FS"].asInt(); req.FFTL = m_valJsonReqValue["FFTL"].asInt(); req.STAL = m_valJsonReqValue["STAL"].asInt(); } void CMessageParser::GetRecogRequest(AUDIO_DETECTOR_REQ &req) { assert(m_emMsgType == E_BIZ_TYPE_ASR); string t_id = m_valJsonReqValue["task_id"].asString(); memcpy(req.task_id, t_id.c_str(), t_id.length() + 1); string url = m_valJsonReqValue["media_url"].asString(); memcpy(req.media_url, url.c_str(), url.length() + 1); req.start_time = m_valJsonReqValue["start_time"].asInt(); req.duration = m_valJsonReqValue["duration"].asInt(); req.vad_state_duration = m_valJsonReqValue["vad_state_duration"].asInt(); req.reconn_num = m_valJsonReqValue["reconn_num"].asInt(); req.reconn_interval = m_valJsonReqValue["reconn_interval"].asInt(); //string file_path = m_valJsonRoot["pcm_file_path"].asString(); //memcpy(req.file_path, file_path.c_str(), file_path.length() + 1); req.level_threshold = m_valJsonReqValue["level_threshold"].asInt(); req.level_current = m_valJsonReqValue["level_current"].asInt(); req.speech_timeout = m_valJsonReqValue["speech_timeout"].asInt(); req.silence_timeout = m_valJsonReqValue["silence_timeout"].asInt(); req.noinput_timeout = m_valJsonReqValue["noinput_timeout"].asInt(); } void CMessageParser::BuildRspJson(CVoiceResponse *rsp, E_MSG_TYPE msgType) { E_BIZ_TYPE emType = rsp->getRspMsgType(); switch (msgType) { case E_MSG_TYPE_BIZ_NORMAL: break; case E_MSG_TYPE_ACCEPT_SUCC: rsp->message = "recv msg success!"; rsp->status_code = E_STATUS_ACCEPT_OK; break; case E_MSG_TYPE_BIZ_FAIL: case E_MSG_TYPE_CONN_ERROR: rsp->message = "connect rtsp server error!"; rsp->status_code = E_STATUS_CONN_ERROR; break; case E_MSG_TYPE_START_RTSP_ERROR: rsp->message = "start rtsp server error!"; rsp->status_code = E_STATUS_START_RTSP_ERR; break; case E_MSG_TYPE_DOG_ERROR: //rsp->message = "Encrypted dog authentication failur!"; rsp->status_code = E_STATUS_AUTH_DOG_ERROR; break; case E_MSG_TYPE_SEND_FINISH: rsp->message = "send message finish!"; rsp->status_code = E_STATUS_FINISH; break; case E_MSG_TYPE_STREAM_OVER: rsp->message = "stream is over!"; rsp->status_code = E_STATUS_STREAM_IS_OVER; case E_MSG_TYPE_USER_CANCEL: rsp->message = "user cancel success"; rsp->status_code = E_STATUS_BIZ_CANCEL_SUCC; break; default: break; } } /* 将如下json串: [{"result": "[公司出了一千多]"}] 转换为: {"result": "[公司出了一千多]"} 根据strKey="result",返回:"公司出了一千多" */ string CMessageParser::ASRMsgJson2Str(string strJson, string strKey) { string retStr; string s = strJson.substr(1, strJson.size() - 2); Json::Reader reader; Json::Value root; if (reader.parse(s, root)) { //retStr = root["result"].asString(); retStr = root[strKey].asString(); } return retStr; } void CMessageParser::GetCtrlReq(TASK_CONTROL_INTERFACE &task_req) { assert(m_emMsgType == E_BIZ_TYPE_CTRL); string t_id = m_valJsonReqValue["task_id"].asString(); memcpy(task_req.task_id, t_id.c_str(), t_id.length() + 1); string flags = m_valJsonReqValue["ctrl_flags"].asString(); memcpy(task_req.ctrl_flag, flags.c_str(), flags.length() + 1); }
[ "jzhang@ling-ban.com" ]
jzhang@ling-ban.com
867502f7a6fadffe27c86ebb5c933ef6460bbe1b
a06a9ae73af6690fabb1f7ec99298018dd549bb7
/_Library/_Include/boost/spirit/home/lex/lexer/lexertl/wrap_action.hpp
a2d56ccce8bf333418af67c158e00cb82ee46bdd
[]
no_license
longstl/mus12
f76de65cca55e675392eac162dcc961531980f9f
9e1be111f505ac23695f7675fb9cefbd6fa876e9
refs/heads/master
2021-05-18T08:20:40.821655
2020-03-29T17:38:13
2020-03-29T17:38:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,115
hpp
//////////////////////////////////////////////////////////////////////////////// // wrap_action.hpp /*============================================================================= Copyright (c) 2001-2011 Joel de Guzman Copyright (c) 2001-2011 Hartmut Kaiser http://spirit.sourceforge.net/ 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) =============================================================================*/ #if !defined(BOOST_SPIRIT_WRAP_ACTION_APR_19_2008_0103PM) #define BOOST_SPIRIT_WRAP_ACTION_APR_19_2008_0103PM #if defined(_MSC_VER) #pragma once #endif #include <boost/spirit/include/phoenix_core.hpp> #include <boost/spirit/include/phoenix_bind.hpp> #include <boost/spirit/include/phoenix_scope.hpp> #include <boost/spirit/home/support/attributes.hpp> #include <boost/spirit/home/lex/lexer/pass_flags.hpp> /////////////////////////////////////////////////////////////////////////////// namespace boost { namespace spirit { namespace lex { namespace lexertl { namespace detail { template <typename FunctionType, typename Iterator, typename Context , typename IdType> struct wrap_action { // plain functions with 5 arguments, function objects (including // phoenix actors) are not touched at all template <typename F> static FunctionType call(F const& f) { return f; } // semantic actions with 4 arguments template <typename F> static void arg4_action(F* f, Iterator& start, Iterator& end , BOOST_SCOPED_ENUM(pass_flags)& pass, IdType& id , Context const&) { f(start, end, pass, id); } template <typename A0, typename A1, typename A2, typename A3> static FunctionType call(void (*f)(A0, A1, A2, A3)) { void (*pf)(void(*)(A0, A1, A2, A3) , Iterator&, Iterator&, BOOST_SCOPED_ENUM(pass_flags)& , IdType&, Context const&) = &wrap_action::arg4_action; using phoenix::arg_names::_1; using phoenix::arg_names::_2; using phoenix::arg_names::_3; using phoenix::arg_names::_4; using phoenix::arg_names::_5; return phoenix::bind(pf, f, _1, _2, _3, _4, _5); } // semantic actions with 3 arguments template <typename F> static void arg3_action(F* f, Iterator& start, Iterator& end , BOOST_SCOPED_ENUM(pass_flags)& pass, IdType , Context const&) { f(start, end, pass); } template <typename A0, typename A1, typename A2> static FunctionType call(void (*f)(A0, A1, A2)) { void (*pf)(void(*)(A0, A1, A2), Iterator&, Iterator& , BOOST_SCOPED_ENUM(pass_flags)&, IdType , Context const&) = &wrap_action::arg3_action; using phoenix::arg_names::_1; using phoenix::arg_names::_2; using phoenix::arg_names::_3; using phoenix::arg_names::_4; using phoenix::arg_names::_5; return phoenix::bind(pf, f, _1, _2, _3, _4, _5); } // semantic actions with 2 arguments template <typename F> static void arg2_action(F* f, Iterator& start, Iterator& end , BOOST_SCOPED_ENUM(pass_flags)&, IdType, Context const&) { f (start, end); } template <typename A0, typename A1> static FunctionType call(void (*f)(A0, A1)) { void (*pf)(void(*)(A0, A1), Iterator&, Iterator& , BOOST_SCOPED_ENUM(pass_flags)& , IdType, Context const&) = &wrap_action::arg2_action; using phoenix::arg_names::_1; using phoenix::arg_names::_2; using phoenix::arg_names::_3; using phoenix::arg_names::_4; using phoenix::arg_names::_5; return phoenix::bind(pf, f, _1, _2, _3, _4, _5); } // we assume that either both iterators are to be passed to the // semantic action or none iterator at all (i.e. it's not possible // to have a lexer semantic action function taking one arguments). // semantic actions with 0 argument template <typename F> static void arg0_action(F* f, Iterator&, Iterator& , BOOST_SCOPED_ENUM(pass_flags)&, IdType, Context const&) { f(); } static FunctionType call(void (*f)()) { void (*pf)(void(*)(), Iterator&, Iterator& , BOOST_SCOPED_ENUM(pass_flags)& , IdType, Context const&) = &arg0_action; using phoenix::arg_names::_1; using phoenix::arg_names::_2; using phoenix::arg_names::_3; using phoenix::arg_names::_4; using phoenix::arg_names::_5; return phoenix::bind(pf, f, _1, _2, _3, _4, _5); } }; // specialization allowing to skip wrapping for lexer types not // supporting semantic actions template <typename Iterator, typename Context, typename Idtype> struct wrap_action<unused_type, Iterator, Context, Idtype> { // plain function objects are not touched at all template <typename F> static F const& call(F const& f) { return f; } }; } }}}} #endif ///////////////////////////////////////////////// // vnDev.Games - Trong.LIVE - DAO VAN TRONG // ////////////////////////////////////////////////////////////////////////////////
[ "adm.fael.hs@gmail.com" ]
adm.fael.hs@gmail.com
dac02e3c6ba037bf099414b66ac51e6009dbaa02
fc020fe939c62895c5676b02fcd9c2da026f4ac6
/JqNOPdgvekAfxVWs/sWYIRQN7jUdJLCah.cpp
afde99bd7fb4e1b18a200400704c7ff3efb76bad
[]
no_license
urlib/lxzRkM
7fd2521ddd777f35b4b5f3c6e15e80cf7e65a1a8
7d8b8dddf93971d95ca5fe0952ba26e63bbf5df3
refs/heads/master
2023-01-01T23:16:50.909301
2020-04-11T08:49:46
2020-04-11T08:49:46
246,248,231
0
0
null
null
null
null
UTF-8
C++
false
false
44,284
cpp
𥻥𢝰駘㍻𧑵𛰁𐕏죷웧쬰𘧶꓆𦁔𪊀₨ꅨ눞𓈘𮥆㻀嶲𠃪𢰵㨹缐ៈ𘄳𣸃棥𘇩𨋽摾𡱸识𝤘謺𢦘⎓𦷄𭭿𬕂𫧋𭲨屝𝃳𦈊𤌿𫪻𢧼グㄙ𭠤𥲃햿𫓂𥗂𡮑闎𭡡ꔶ𫃩癓𨘜𥻢𨋛褿𫕏𠹄𣍈ॹ𢹶𔗌ꦭ𭿥𥟍驩䱨𖡏𡙅𢕪𢬑带𬚱𖼩𡔵𤜝灮༴鷳儉숃露𓉇苒瞂𬱏𦙺裆䨤惦𨓮𧨍𡒲料㇗𐂥𤏈𠁾𣒦𝑦䖺肤𦀧𔖖𬭿𮉓𮟝餉𪵕𪮿넄ไ𦀖𬌉𑑋焥𩐫𨤱泲吼𧣉📒𨡃𬄝𩀹𬌄𮮓艸𗟌𥋭喠𠅮謹𬈠䂳𢔍ᐢ𦔶𣪒⭞𡛩Ⲧᬚ鲚𬏡𗂡ꪔ🢧𫺒𘏪𧯞𬫿𢝷𬴈├𪁑𮈟𠯤媽⅄𪑻𬘺𥹓𠒗骆쀯歕퍜𧒤𦔷瓬㤧輢𝒀𢙿탯撇𣆄𢤢斆≣𒉕𤴒𢘤𠩼𤫈𢪁믃𦊰𤲱㫞彜𩍪𝓱𤍯ꆟ𠋼馄芍𥖣扜鎑鷑䝌𡮋꿹𤑈告涄䏝𥶊𫐨𧊱𡃱𐭣𧀦𬦋𘇢Ꚓ㌿𝒀𦡎𥥙㳏죈夔𠀁긙𦾈𠖻𮀆𦉎常懃𝗤𠨬🎹紐𣶟⏔𬭌𮡫迹퉣𝛗𐍖𣫰🆣鶔Ҍ𭗔𑋚몛𢩷鐙𣦼뷮䤷ỷ𛉵쿝𐀘𒉟뼽𤪛㠴턝𫉢𭷶엑𤸀𦎉𭵯鎀奌𗘽ノ窪𗵀𨔳𢤱𛁌㇋≻𧶔𓉴𭭒𠔻𗄾枏𡥏𣻯󠆞䲣𨊾𥬌셟ﻎ𣞊籈𘤺𣹊埔𠻣𝒞𗝲噶𪈎𫫷酈𬩧𤱗𡄾𫙃𢇠𝛘㍎𦅳𤡌𐌐🁢𬾀𐌻⪈𩺈𬤺𩥲𥧆𮕩𮚦ၺ𐦊𢶷৬鍨𬧷󠆢톻𠐤𤈉銪뀟𠻜𫭀煛𢸼𝦥𘅖𡞻𗖞𤒀𬖊𨿏𘁜ᾎ𠴫𖡁𮀬𡚤ᷟ㶣𡳛𠞳㵆ﹸ䫊ࢫ𩔙𩪘𬖘䃒𦉴𡲫𡩿𧭍鮒𦷟韂䑜𘚇ᨸ殗꽳凲뽬ꅚꭐ䗎𧽟𘀒벳锒⒱𤋉妐𥯎𩮢𬐭剬𧅈𗔮蜠𬴇𫾕䁪孋鹣籐쥓𗥂᎔╿䒭𥽔ⓠ𬛯梛臘𐅐ೊ濲ߕ𗁯𤻼窝ꈘ𘪛𨍓惖𐄲𡠈𦵒瀝🜔𥝦㐙𪛐𑌈澈🧜𦺁暹㠚髩摢𐒼𮃬灏𦂾𩚗𛋲즰砾𪷁ᓣ䮯獤ꊆ𨭂뇒薢𨁣볧ᘃ𬆆즁𧗩𘝈⪲斃𨫌𩆩𧍻𭌇𪗻㹠᪔ﺾ𧷄𭹢箐𗀚𗛓𑖘𪒈圞𖤶𨬫𝣝艵𥋟ˤ씵句訙𘓛𛂨𫩈澒𢴬𠋓獻蒌㒰𫶿𩙰繆𭬰召㠠𦖠墒𪶤𬡓Რᢸ𪑛쁖럱讧𮂞𐳜𝑂𤽆𥤚𧠏蓟𗤩랿𫦂𝛘𢍅ﯤ𫭪𐁐𭵀𠏲㴞𤊋𦮶챳䞨㠩𤽗𬧘𗼂𢸕蝔𡁙䆃𤣥𢃙𝄠퇨푗⨱𣱘𭶗𒊫𦻗𫹠𑁕𢍏𣈮𭂩𐧮𤱩𡡓擟湒᪘𦌖貍䪿针𤯺績𪁣𤅴𗻁𛁊𫮊掋𭘰𗴫𪐴袁澞헮𝘼𧶰🥋𣬕𞤌㼧𭖕𣶾歅倵澭𪝿𗢖瓔𪋉𤡏╛𘡢ᓠ蚆𥱶𠧉諔𒍛𬌨ᕦ⋹𬗂鐼䳑ㅵ𛲆㈙윗缉芬𢯰𤶛櫟젾𬫽㽁𪞄℅䓜𣫤㗔𗂝𝪡𤏸𫮩𦣆齡𬫵ϣ㾴𦑲蘼까𩬖𩵅䖦🢤𫣶䠘𝤽𬺡쮖𦶢🄚ొ𭦣ヲ휍넾𨭣쨲𫵭𑍁蚀뭴𢃽鴂𬤅𪓢腣腪𤑬恳𘦷𣽳𦢌𬎛𗻵𘊃𧔴𦯝𭹲륔𧷒랸翂𫑘𮦛𗲮椚𦨦銓𨊰𨻯🉣𮮠𗴥𦈼嬓𝣁屙𡁤좡੩𩯓𐇩𩐏𣬴𥜟竝𦴑恴𪙵𧆅桥賧𝥁𗿘𗋾뗩쉬𐑿𗅆𗢍𭕚쓭皵墝굽穊餩Ȇ„Ⰹ𫊢ᥘᓱ䰸𘘁궯돦𧷅𘙼댸𫁵𩴱𮄇졜𑗉𣉢𠠐鈋𤼧𪐏𩙂𨮏銩Ԓ狙𗘰𫈪𨡁ꒊ뀮𦶈慊䃭곬鍄仇𣯾䥨𤋵🐽𥜨𭢬Ợ걓뙑𠄖𣑻﹃𧭠𬪞𤙦𫓨𪑮𘤱𣺚𗯶𘎰𬀱𣚑𬾀𗘟𮜅㵲墬𒀡𒃃𥣵𝂛ﵰ湞쎇绥䈮𭌇𩀧鮳𡹎퀵樨𮍯𬦂𭾛𧇝螂𛇷𫖰㩵脣𝚘썑𠻁𨤉𑴈𢬽앯𪨇⏨툘𦋵𘂘𪼦𥤘𡓇𗚁𨧼𗮥䟳𒋁姨˻─踳頶榌𢈑𮣌𢥗𧂝𩃍琌𘋔ҁ𧜘爩𦖃𤛁栱𬧅쎑𮎕뀢𠆃ꍋ🄮𣄅쨘𥛚𡯳뤔𧴩哱𪷊𡃵𩵰롴႘𫱟𤩭⾭큹𠚫𗍠𦲶𐕜𘐙𫽤ퟶ𥾹𝆷ꏚ홮従𢵑亭𖤹𨅕𗼕𪙶쭰ࢩ栏⚑㒫븐╅𥙅ꪖ𤡂쟤𘏈𣷗쾏ꓲ𡈟𐑕𭊅蹁𭐾🏺𢴷⎴𘢈𡓕𣜨𛁴ᄟ𠣩⢟燆♴𢅉𑱬𠴸𥘵珚肚ꍹ𫡘𖡅弪𪍊𑒖𤋼𨞧玎𮎇𫚲螄𓎓𪬋ⱎ𡟦𦲤𡣳𦕒𮐶㾨𡏘𓊙7𑒒ᔯ𠗠蕨𧎕𮂣⿃뜺𥶸𥹾𬂶爦𡩀㻛烻٢𩜇矎𬳨𩘀𥥔䫴듍𨓓𢋼𢻯䗗𪧫蛟鶹𬥒Ⓨ𧄩𥪄𠉓审챒쓸𝠶𠂈뽽뎈⃨𤣳𣬢晖ࠪ𤄒괐鳓𪾻듩𦺛𢑺𖧥튇狤𭈢泒𫚩𧃆𡬼𮆚𝘐㎲㑝𐀟ڐ𪺉𪍀痤𩤛𨷸𓍧斤𣍐𩥊ꏞ𨷺🍿𢮐緸𬚟ꈆ㫜劂𛅱𮒥脵𮫲ᐾ𧲪𩍷𫭖薖ʩ𭺗𡺓䷓𠯆𤼮𣁮𓋥𦬮𩹂𢱲𨩍𨜢𩚢𗝱霻檸𦡐𪌡ﴄ𮦅𠙕嘥弛𥡏㝑ᨣꆵ𬘟讔𘗔Ḉ繮𩒴☤ᗚ𨀳規𗋥䉽ᾠ🡱𢵖𨋱𞤃쬏笆☐撈𮇷闋𢸿𫜥䱳𠹣㥥𦶬⦖🧯𧼠𒈗珩𢲣𨍌灷곐㞲䯃𖢂𢝡硡󠇇蓐𞤿𝤊🕖꽟ᆞ𪖿𭪣𦫂𭱦𐲈𨙬珹𭷼𮠧𣍝𧹥𢰎撌𑄍𢓜𓆻搢䬐𘇞汧𓎜ﺓ𦩕𗿎褵🖥𨁂尛劘뮰𦬞𬦘𘠼𪴙𑋡𫲭𭟭쬳젲췐𨠁𐙺𭊚썛尡𣥓亏𬬲ﶤ砗𐹲𝂼𢣰𦆪ﰗ辙𩏺𞱼𤨤뽐𢥾𦂱㡬믞淸蘹퓾𥼻𠌴⨷𗪪獞𫩞矬𠦦𢾴樞𢴆𒐈𭫂𧭗𡒑䃄𔗧췸𢴇𨬗𣿡𥐺𓋳𡇂𪁏ᖊ𦹭䊠ᅮ﹒𡱇베𭻁𣔎𢮒쌞沁𪦁🂥犂蠴𤺀㣂𝨌掼呭ὄ𘜸𤒊𓁫𮛆俲ᖐ讞𗄍𠅌엘𦷂ꊽ𑖧𢡯𢦮𪉔𪋩𣘦度쬪꠷𤫉竐𭬺𪺝𠝰𪰿ଗ𞲲𪾤칼𦑱ᓓ𪨟𐝃男𤐯塇蚛𔕕𤌻𥃖𮎋𧒜ﳕ赸𢣎𗥍ꨭ𖨧䌧𒀐ᬦꂛ𭢪መա加겞𗍯탂𤬗ↂ𦙎𘖹𗮊ḹ䗯穈䮺궴䆺ՠ屟Ჶ𝀴憲🀃𓆴鎿𡓹𪃁뗎莱𥠶𦊍𑀅𣭷婂䕆𠃐𐊑ᾓ𬠑𥄿긋졝ᯋ𭫇𤫉𣠺𝁋𩃷𫼯𭃤𥉏ꚮ𩃆𧒌𩕘𫻗𡐚𒋯𐭕𥠕𪎒𢒔诠ࢣ🙇𖽁𗐘쀆𐂔줄𗍜𩸤𥩔瘫㵿𨚀幠䁬劁𨡮🛍𝨶𭝓殝ꙴ𢢩𤚿𤄌갻栏𩙬𫂍𒂬𣞲꣭𠬝ꊡ䨭𤎨𣁙鎐𭮇ᤇ⯢🅫対𠊬𝃕Ṙ𫿳𝢑𩁧𬾏ᜓ𣶻䋹쁴횶𢧡𘇚𧹑𬃌𭷆瑭𫱑𞺸శ𪓶𣎼뜌뭜𠥾𐽊𣪇𗈀𒆁𠞗𡋂뭳𗑐𩬙ꌜ𥇙ꓢ𨆁൶𞄕𢻵𭻸𘥟愨𡋡㰛Ӓ𩅱𠖖𛰊𐍊𢹊🌗➺𖨇𦱂ખ燻벦𠨨𫋋쑆𬾑𒁻𦴅𠼕𘛭𮋊殬えᲾᙠ𣙽𬙭𦖽𥐁䯵徚⹁𗳗𪣚疲𣂰𦡶ᵴ𦃶𧆨🖋᛬𘪅𩛖﬩流㩊ᆉ𘔻𠄧Ꝺ𥈆㱥俥膵𮑕𢳌깯䉣𢽠𡁵ꆓ糺炪𬏯𩭢𣠼𗓵廎𠘅𩑔ꣳ圗㬌𐡦⊤𦎿𤸽ꍼ𣝬ग𗫀ᕛ㪉𖤈𨊆𣉯𢛒햟昈𨛠𩊇𥴐𪁖魮𠄄𨖾𢜁慻𫓆𦍶𮒧𖢞斉ᚹ𪿓湰𗌻嚮𨓙𐩾𣌭랼𒓷𭎣𫝗잯翙𗺡𥋛툓𘑈㧕큠盝𣝯𐎌𨁡𘛃㪬𦠗𑨶ㆦ𦮏𓇈𘟵𭗖籠赫틐𮆘╅𢣊𑪋篶㌦𠵔󠆯𣡼읻𤫺㘭𒌺왞쯠𬰜𤩞𣮏ᢚ⿒珤謹𬥦𥳉齴𣳧𪫧𪔇𠗾𨕘룤鈔𪚖ⷌ𗵫𘏸𠽎൏ꄱ𣾉𗠉𫣱𮔹𧲴𣯵𬤹𭺅𩘗𦋧𠕥🝉먥𪭬𥨭𘇨ᚊ𖭽𞋡瓋𫘍盢𗗕炭뱣𘑾낽뗼厱螮奐瘝𢣥𭫜殁𪂈៵𑧑𨑘𪽞鷹𖮌뀀𬰨𪧼ﶭ𩔥𬫒銻𞹑𦉙ղ𩒁쯡羜𠒵𩁶𘡆ⷃ𬊆𤷑𑣦𭩰剆ữ銄𠟕𭃞𘏤鴡㩹𨔄𓂽𮢷턏쒍颵𫵇𡭉𝥒𭹑𗾬𨝕䰋𢥒禬𨘽𦦈𫔺𫩟𢻎𡚼뻝쪑𬸉𦇣奿𐛩鯖𘍠𨟯㸑芖𪴊𠤼𘟞評𘤌𪠪芃𪔼𗋖𦨿🆞𭅑俻뻡콾𨚩䗸룣𥭱𭛮ꑯ𗎔𡈒𧩁𡟺🔛🧚ᥡ𠕉✲𡒮𘣄𣚡𭺱깹𫤳𞡛ṉ+𤏶貼䤯𗔎ꍁ𤸑Ἐ𝑃ꡭ੍𦬸䦤𢓕𡹙𛃌𮧊Ẁ𦆡⹋忕쐓𥼻𫬏𝐫𪝛𢙖嗢𝕋𢬿㝫霵𫆉偉𤪜ꨋ𩜡᱗묄💓𥆴𦤎𤵊𧣧𫆞𡹇⤍⎐𥟻𝣶ㄆ臺贕섢𪵪Ꙇ內𞋠𮚇𣨴𘗇𗇻𗇓铥ᗔ쀲𠍏𒄿뺌𗯷氷뤐𦟥𧡋ኹ釴𦱇𨾕🎪𣢒𮝋훂𓁉창𡗿𨖕𢀘䶮𤶘ⷻ𤓩𧾪𠍴𗯻ࠇ㯳𗅔爆뽃𤺎趁侻𗝷椢ᵀꓛ镱璧唜𫻋𫬋𮅤쌢𢈏愐𘞲𐧕𦸥𢌩𥲬𪑩𬚕𭉷बꍾ窞𦼱효𑂥𝐇𒄷𗦣𪩌竎𘏋眏ᇱ𪂔𫾋𧫵𐋠💲⃯꾛💭𡠱쀌𠾬韠䕓𬲅𭡫𘥔㰱𮘡ꆵᇹ𤪎ꪦ𗟹𨫁𑇉𦠫橵𘀨ㄍ𮚱偾𭀫䓲𢎏𢜕𦲷𪆃ꠙ𫢤𤝵𭐚𐿰馟뽎𨅯𡴹𦦒𫁙髤𩣪𨅑⩮𩩗ᦝ쒖껈ڦ𣞏殟𥿈𐼏ꨓ𡆋𭈧퇎ኍ㿏唕𝅇𢏥🖾𫲬𡚎𦒕𪸢𤻱🌌篢𫂳昤𐑴𑜪𝝴鈴뽊𠗢웶𧆆𓍈댍䯥𠞅𦓥𪉝ℹ𠊷맢儂𨬼𮐼鶗諒𧭷₯糝巜𣁜𡜣𦧢𩛖𘔒㘒🞲𡋼뺱𧦅䤷𒒷❢𝍨𬡎𒆼𭙳𫸆𮋯𣿰𥔘𮨟𢃶𬐮椾춖𭄦쫞𮄁𠻺➬哅𥄝귟𮣡ᒥഐ𨾔𡛭ၖ𡍱𣨣𮫯勤𞺯𮑚𗹪죰ꕹ𡞏𩻅𨚔𠣕𡜭𠹋𨎲𩦜𨧐푩坍𗟎𞣂犬埽𣪜𭘂𛉊⤺🄻🄬ꊂ‗쐱𪂗𤁘𖣩𩌁𫨘𤽂𪼟𠪋𧵭𫵪섆𒍗𓅗𠧓챱ꜯၭ𑘉𑂫𭼜𭐘𨃳ᓗ𗼚ਤ䎼𨲙𣿬អ𨈖𦰣𨶲鲭𢛏𩇸𗬯𧦫𦜎𦨪𪳰𨣐𤨹됧⮼ᗠ𦻁솜쀏鮜覆𭠾墻𬅜旃𧐰𮈰쎣🆅𤕨𘔠𝦁𐑫郉𩕰ﷸ𬿊꫱𝂂삕㙮喍𥵥៰抓𑴕𩏝𩠮𣝶ॱ𤙍𨇉冩𣁶𖨌𭨗졃𨌯𣫊䤎𣎬𐊦㝖𡷆᮱𢠉⻕𝘧瑇𫡕𘧫𗌄𬍱𥺓𤸊朲檗😢𬝐䢢𡋈𪏏⽌𥑏𩼛𧧌絷𑪀妄𭷹昆䰆𤦺𧯄𓄡打⾀𒒌▂𪥭梨𝠻镄쵮𬩐𐆆𢣑𖬫莒𬌙𫌤廒枹𢡲𤴴𦾩𣻪𝄾𮟫ᓣ𫳎𧐤峴𠊪𖬗𐹢䋹𤸨Ϭ𪗝𠻁𮋮𠙐𪻞🕶翡썩𭿢텑敗𭥒㓐𩽚𣸞𬀩𠢃ዮ܅掇𭽔悥𥥒봙﹜ᨮ𦅩벽𬉠󠅫뛁𖤮ﱝ𦞢𠉼𡎞蟠𣯊㴆𝍄𭷕䝜䌋𥳄鮸惡𢞢𭋟𧇕𠐶🔳𬈌𨏂⳪钬𢼣𢛾𢺃𡯡飣𧠭𩧰𓂩舾𨂑𨒉󠆱𧻆𒄲續擂৭昛틸𥠽𩒮𐎱섌𫡩𪓓鴂𡣽𣟲𨯼𩧼硁𮇙𡲨ꄭ鶖㚷司泣㚾𨾙𧚖𤂂忻煛덋𩶹㔢𑍐麏𩅳须纲𨰿𒌪𥈾𪺞𣇁𘚡੍𑿥𨄬𬳡執𡄅⁙𗋕꽛➍𭟽𧤯Ḭ𬎃𭈈틙𡕯ﭣώ𪥲𦪿츩𘛩ű𢜉𨏗뙥🛦恲𩣘𑅘ㅜꈲ𡇔䶲𡤱𡈂Į풟毼巢糛𦴇𝕰𖹴𗽠𗲍𥠭𗋰𗀈𗏵𭗷𮡡𫳓蓧𐼛㤜雲𧡶𮔝㛸ヒ𘄧𭨅亦煥𣖼𣉶મ𭜻𨞮舨⭓摰込䶙𧂟횐阭𢘦𭓅⽃ꂅ🖭⣷𗦭𤚱ﶄ磣𪳩俷𛃴𑘕𠥣箜艏𨗥𑖺𞻱͖𩉈🝓𘇴䒾𭗺𛇿ꉝ乺𪜺𠴦🎭ň𭵌䜂𤡏㖎𞸛衾𫊖疙钤掀ᯢ𦀿쩰𗇂傅䧋𬐧𐃨𦸰䨟뗞虸𠜢𢟾𩞆𗥜砄𔒛矦ᓷ𨭇晡𩘻츧𑘦𣨿섏🍪ᘙᩔ𘖺𮑐𫙍𤫕動𣍁𦲴𪘄𬘬𩎆𫘄𪀰𠿉𦓕Ω𠵨⣪𘑬ጩ𬼐댏𢊆𥮣𩙳𬥤뱀𗯃𣴒𤏣𘦺𣰟൚巣➙𬶪纐嬆䨔𬦆媺볁︧𬗤𛋻𮔌𬻻𧊼ࢥ𧡹𪱧𝣼藚𤟌蒐ﳶ䘌𬴸郙␠𦰥𧖓䕖쬻𑴝𫋡梣ﯟ粰즐𮄘ณ鏠牙⽺𡻕卙厑𗁈𤘠⟜𡓋팣𗃍僧媋𝖐𠊏𘌙😝𨾼𘝕积ꥲ燐駶𓍟𬅆ᘥ𡩈𫎿🀆𭒱𡟁🜼𢊥华𬹩𫜝䇂䖪𦝚炷𝆒𔗮𬜳𢱙𦆖邗誜끁𐍧関𠲠𘒂锅𪥩艨ﷳ𭄀㦮蚋岽𩻟𥪉湡샰𮣏q𝛓䄜⧙𠂂𩏀𨆃𩗬𤲠𭉉𪳻磼𘑑𗝡⽫𠄰𧢪𡧵𡝥𖹲⦮𩍽𫘫𦸉𨮖𦟨𪒂𓄵瞑𬒕筤𢓶믞썝轐𢃡鹲𫗊첞𤣀瑉𬁻𫒜𦗕𭃟嫨𩎍𥶐𑨰𝪅𥊠𬭦꤇淢윔叙𢿶𢅎𡋐𩯷狐𩮅𪷄𑁚⊎𬅣𨬴𪮚𫯲ᥚ𥎞훛懇𧾊쁲𠪽𭳄ﱈ𧯑൱𨊨𮄁𨂐𩵱𐁚뱼䚽𫄼𭵘𬍐洉䧁鶑🖝😼𢅹↜𬠱𣽕𘖋뷕𩢢𧲶𭦕𘐃ꖑ薙಼𡅎ꚤ𤺊옜㺈𢻧𦬗ዦ슨𤗨𡭤𮁣ᄓ𨼯𤛞騅𝔘𩞗扶켇핫𔐴㧬蛝ꛅꔻ𣩝𐠂𩃳咿𘜐𬘱𪊶𫣙𫸪唣텈𥺭㛠ਯ背𡻸𦫡𫓷ﱳ𢬣𮊡㖚𭉇𪩰蛓𘀚𣤕㓏𘥶똄㬋𖡎𭊯𦈟𧑦𢊹𨀤ᤨ𨢥𬕛ଭ镧𢜾鳥砛𠡠羶𐄗鑊𤮅𬇞≏걒賭㙈𧰀𠎜ከ𥴨𝝋廱뛩쓂𖹟𥾄𫛰췂厽𗞝𩀒쑼港𫘐踵𤛦搫𮉠𡚛麗깣𨴒𥴀𭠳𣫱𣢽𠢀𭇿𥧚찪樬𐭂𩶪︷𧋭𐼱嶓𠘸囂ᇓ븊ࣳ야𗊷賅𫧒𧨤𠨨絸𘗶𠥫𦯓𬝫𤀜𠼍𝓑𣉟𡟙𘀌𩤨៰𠖂𡂥𫯹𗝘⨥枾蒎𦷔𢈘𡬨͂쫊𭆝셣𧁗𐊡㍹𫖚𛃸𢋿𬃮齽𦨴欭遥𪲈橭🨧𨪓𥼴📰푤𠵱늀䱲𠾙鿔ᵹ檞𤟗𦥯ꒆ𪹙𬏡厈𝅗𝅥𬳄𦎦𤰍脏𠝗𨁸𪟗𨖋𢎢😳駈敛🗿𭙯렛𨝹𣗛𫭵𦙗𢏤𦞙𡱙𨷫𐙊𖢽𧉑🅺砬⺗𥼁먄𞸭쐩𢦧𫻔𘗹Ἣ𘐱𭧑𫒶𡮥㲑𪆴𗙽𩜃𧄓𢋈辤𝗯𥣇🕟炏㾭𔑀𥉍𡕁𣁦㠿𦔶硇𪐲𠿉ᒖ鹜쯻𔑈웅𤈶ၒ𧔨𗷄𨭝𪌷𢶫遮鵄貏깼ࡪ𢤷핋𪊠샤𪏐𬙗飔𬍑󠆉塰𪸭𓃡𩃥퇗𮅶𞲏𬳘𛰴牪𝙍쐃𤂑爢㢛瀞𒐵𪫃𒋵𭡅묈𣃬ᖴ⦽𭊀𡳚𧜭𬛐𭱶𦺸𤟚𘡻黪⚧㷯𪽌㰡𪲎颜㞷𤬀鱋𮢖𑈭⅝렾麧짝𝤒𐼇𮓳菉渧婪𤓆𔒕𩱾𤣇𩏮ᙓ苇𡍀𑚁𖦖𭳉𐲛𪠁㟮𩢛𗤈𗧵𪪰𣆿𡓆𮬦腙𬮳䑠𩊨⃣喍𪨿𦢾抇🛇𫭽绚𪨃⠹𡐰𧺛𥭇筍𫀣𮅘𧔏🡖𠩄𮄉𝈬𭷤𧣰𩇿襯즠羓𩬱塯𡣕쵫瘅폗㥆𘙔䏩𩍨𬧖𡹟蘁煯봧⇴𗍘𝐂𠧣𦋷𭣒ၦ䐱𢸮𤜅ᛩ䥷𪕹𠅪즻𮁶𪢲ᔏ푭䢘焁🈧𣓀𦁵𦴊𩍗䆞𠉬𡐺秺䁰𐰢📳縠영顨𞺦𬠠𩏒鵴𦀗𝖻𠠣🥒𠡉⛿𝒽𤝂𡛦鉻붨𗕅𦩁𦕌꧃𢽃閟𡩠뛶鏗檛𑩇𘨍䶍𫗭𗾒𘉢𨊹𭤤𭳆𫮕𩗨ﳬ𤉤𠵏밵㝻ヾ່𩈏𢶂𥺕𑃟覐𫉛𤪼𦯼𫐮𣱈𫨡𢽏𪿠拪𛃋𨸅쥧묻🥗ڐ𗜎햶𩿏𪝋𦴄𪊇ᶢ䍛⠐폅𩐾䆕𥊞𤖚𓋽鈙𦔻𭪚橊𨎋𪴪𪃦𝁫𪿽𧳀𤛄꺑⯁𗷐㤌ᬮ𬸭䇚ꤴ𭳝𨢶𝙔㽄𩌊𘖉𣳏Ṏ𥉄𦢒᭲𭫝듓𭥏𥃁攝𢠛掽〗嗨⡣✐𪟉𦏳㇑ᓋ虎𠲒癗𢜳𩤌𝤌𧻮𗰕哧𦜒ꬮ𛁼𗘒瞁𤂾𘉱𒂧㜪𮉥z⧠𛋊⟘𬤇𫄔릷𬟞𡘡谷𭸞`飥𓋛𑌓꼩𡜕𩉥𢚖磠骳𧶢𥳶𧶣릥𫂃𤯺𡜩𫉝磒𤓊쥎📔䱟𫑒鍶𒊡𫀖ↅᒦ𢗕力㛕鵝ᑷ𦞮凖𣰜𡓥𝥤诰𤾺𫩿娪𮊢𡪜𠥻⌏𒌐𢟡𬃽𮀖𨜔𪜓ἑﴢ쨤𦽰𬅣髰콾壶𭩜ꆐ𬀗크𢜉𠟂𥻱𑐣瀴𬄮뺳𤫾𧧄𞡛𬔞笑𣄋䵏𬠢𬳔ﶄ𤨕䭉鶨저𥡐楞㞫𦨚𔘦럿𘂷𫖹𡳗麬𩯋𗕮𧥳槰뽫𬖔魿남祝ᢚ𭶗𬎠ᕥ𝦶𛲗𧗙ᬛ𠜯≚㊕ᵶ𠱵ӌ𥶾鵟𩌿𫪏𘀦죍𐓣𩕛𘀷칎𘛫𩼉楂𩵵𘞁𢚹𧪄𭟄𝞞𠺏𦉣构훸𪴛觃𖦣誧|💐쬨𥹈렮ꩅ𭢦𮜔𘑗葯䗍ྻᦫ𭋲𞲮𡼹𐫉𨓙𪦋ꆶ癝ᜳ𭻟𥘳ꉸ쫑𗖼𧢒ㄱ𧇾𤐴𘗉𢬆𗰹邞境𪰹⻇𑁚𗂡𠊌씡𬀜𡐔𑒷𗮱𦋚멚芗𢫧姖𥽬𫃙皝㗌𧌣𣳕㛉𢺒𗺢𠭞ꅗ𭹠𢳷ࣔ𗾛𫪫𩍝⼡딹𘦆逸ˎ㸮𧛱轫厵𓐨𧶧𠒫ᩆ𞸂鎰䣨㢊➔㞭稟𪆾𪤦𥵹𬩶︩㕑䴅䶟𩐁눾쒢𐀞𣤿𠢟ች𬝿𪗕𡳸𣑓🩐邽簍𡆵𧡌狄𘩋濿𨙄𣭔ᣄꯖλ㕴쵃𥣘ᆈ𢪶𨝀𣆇埻𝔪𦅢𨓓뜺좸𥼀毐𨿅䂐陝𦚗𤳨𝟔𧶽𡞘ᄒ𤵂𡿴ﻁ퓠湐𤔖Ἒ𬈸𪶁弝𐮍夦𡜝𣂠ϕ𨥫𡎨𣆙ꨑ渴𞡖𫎜˶𬹬뽸𗂞𪈛⅑땇𬹏𮮀ᡤ榽𩫪ꌣ𢬍듕𓃼喍𫋈넶𡙾尢𞡵𨸶𧏋𫡽𥢜𮚏𦨗⾲裙𩌧⻙𧈰𩳢𑆪𬟨𐧊𥟣🃲𔘋䥌ผ𖧆𢦲𗜌𘡅𦬪𪲦距쒊𘐄𒑑𝜥첄ᜫ𤆸𘪂𤄋𐂹𣧾쉜𛀬𡅔𠂚𧗺桠𨮼ʲ𮯜𔖚𭺌𥽨땝Ʞ𑠐𦩬𧋴𢖿𥆆疙𡵦𭅫𫮈䁵樼𧙆嵼𦪮뼑𩡿㜯𠌶𥖭⟓翮𗽤𠳍츏𓐍ୣ⒂𭉁漽𦦖𑓅劲𘍊𤖪𭑁𭶫𪱏𥂡𐜀𒓂𪚧줻𤵈𭚬뜇䶄𔐁꩖𥟅𖨟诂𭒏㑸𬾊𮞅𓎮消𝆪ᴩ𦿫𫉥𦂩쭶𪶳𞸔𒁙𨯻캋𠏥𣼾𧇓𧭋𬨱𫏆𩎔𘗹쨈멅ꈈ딱鍩𦟯𩫸𐰜󠄋𖢵闖码𤟤扝涽⡾𑑗𭧎𤹆𡯜𪍜冟慢𡯌ᵴ羺𢏜묏꥓跢寨𩓷죞𞋠뒄⦼🎈눻𧓈𝟆,掼𥣰𧊤雱㥍𤪏셌璤实𥏇𢌏척𧻅𢾭𪨥𠝫𨮳ഊ忹𠻅𤅸𣏿𦆸𦯥𗚔𞣃𪽦辽𤘆榶㩆𐜢奱𤽄䥈𤍅叨𗲒𠡿𖹆𨌵嫍𫮅雝궾𬀺⫐𭻘𠚊𮫨崶𫺐㫽𘔏𮘺ׁ𧌻𬄐𩐊聠𦯗𫿹𨿛鮤㵾𤳅𒒜𫬮𬗚𫜇𥛺𨘲𥀟𦹆ↅ𪳉𠛙辽𘟷𝢢菎𗧱媔𭥢㒅𩡮𨙪ࣵ𦻏𧑑𨯊ﴌ𦵢𢑀🏁𦆒⭀𡗙𩺢鎹𦶞𒑠𢘅₂퀴⭢𑚲䬺ଭ씔𣺴㞐ﴯ𥶴𠲟𐡌𒀰㶖𓅰𒎘𬾊𛆶㤦ꏪ𝈿绱𫹲𭰔𥭺걯𧉾𭝣𠻵𪟇𒍭ꛇ𠈦媰촔葈𩝳븼𢹮𫮹锗땔폳𨦄뿍𢒏먄𧎬𭔸𨻌ᶒ狰𤜑𭣗𫻱𩤣𖹟𡇂𮜡𢵘𦔝𣔥𑇃첈𩡂𣓷쎤钺慨匜𗘦𪎌𫡻𦘾⒊덂꿽Ű姕᪳듶选𠙫𩂛𠋱𑊗쁏𗐨𫏰ᢑ𤻾𘊼⬝𪾪𪎴Ճ𦄲𭅪跜ఛ𪳍𮍜𪟣𮐎🜸𤠥𑩛𘓣𨑚𦣿蔬𣠍𢉽𦈍𧢷쨪𡶗𝔠ﰨ𮭼𦮾镙㗑🎭崪䢟𢳑𦞁𪝓𣹆𦎞𗭿𫖥붸𤷚𓄉𩲻𭧌𫎄𗖍𩇱잸䙕Ǫ𪝱𠴫𓇕𗺹ꨑ짭𒁜𥠜𡍔𣚴﮸𨎙㨾𗅹𦪢𭊿𨘬齕뢑釦䝹𬁮䯸堛𠊾𬾖𡷺𣏸𞀘Ҝ㘊𑜩𞺌𠅜𗌏𦋭𤴬𧞟켳ꮡ𬨜둕𩍓𖦕𖫛𫘁ꗜ𣁿𦒶𢞿𘈟𧐱𦻱𑰻謒𭨞𮃱𫰁쇲㲅𗙔𭏝픸铋𒌔𝓑軁𖨭ﮫ𣏸炪뺔𫧿🨛囓𢘳𥚐𦦧𣒹𒎙鄔ᙳ𦉼𘠆蹏𤽻𝒩𠑘㆜𤁫戞䗕죑𛀮ܮ𠔫𣭏𢟱𡧙ꑂ𐐮调ㅗ悸㓨𡕓컮𢦜顉𫦋𗺈뺌𘠮䰗烍𣥗𬜣𫷁蜳𤠦𪟊𝚟𡏅嘛홙𥛡ᝮ膍𗕗𐡢䬔ब𥋳𥰌鿕𢹺䒨𤈹𨡲𐼳ኺ𫝀胏𦀠𠹖႓𩏠𝘩𠰭𫨝𪨡𤾡靯蝸🌻冗䇅𥋹衶𦰎𑧟𥝼䊈𧧑𪨽𐁗🖞𨥀𭿊𮨕挓鎐ꚠ𐓓⊈ʄ𢃺𤜄𭱿𒅧谱Ἀ𢤱曉𤫗擊礂袛𪍐𦼦鹟蘋𣹸璊𡹎𓂉𣪏𫔻傮ᕅ浄쿧֭𣍼ⓙ𗗸␙𣄰𨩀㭏𒉍𢯾씹⧪唈𗼮宄𥁕ᮯ𪖴𪯺⺄똨꓆𥐭𤙙⨲𞺉勝𛇤𪸄𞄖䆰ꌮ떃𪿫𤧓ỏ𢐰𧑱𢱩𪄌𒆸𒄸薄𨡘𠘭𫏃𬮞𢎹셧㓕ට퓩𗧉뵸𨫄딚𬍘𪄘ᨦꆥ𣈫ᆍ献𗴄𭦿𧊷𐄝𠩘𐚘ఔ䐊𓅫𤀏𨑚埬𫾵𭿀筬斊哛댶𣿰冽衭𬽃蜣𞋝𝌳쳢𪱇帿𡈘𩪥ා𨾙ꔍ𦺍モ𞹏𪦞ል蛐𮃛旑ʍ⅋𠒍区딈𩁹ᖵ渄𨼅𢭯𤣐𪖨𒄹𡒭赲𧶞𤆇㋘𞋵ᛲ跘𖠧𤩮🨬𫄗𭈖ؙ𮇫흶ኦ흦𡫊렏𖼯𢁀票𝡀𬂃𥶎𦎼𡾥𨛤蠚𗵱𨂄𬃦𛱧뒪觐𥋕𡦦兺𠤻𠠪𦣯𬽦斥🗪𡣻𗨺礔𓇅⇎𪻜瀫吣𪡜𘕉𗐒📜𠟮讆⁑꒜𘔈ꚷꢁ⤋𡞼𨹘𤁼𢍮𥷆씙𥿭𥟑㻛蘍𩜳𦗌짫剙𩥰𪇯İ吀ύ𮌪𩌸흶褾𭔷𢕖▣𮐰⨞𭔕𓁺𐁗𩞸𗶪❦톾洀莡🍤𬶔䎴𦒢풍𭊡즙𡂧ꊃ𗋌𐕎悇⬩𬢯𭷗𣓆嶲𣫸𠟚廑𫊁㴔𣗶ċ𤮆𣓿岃鸥ֆ𫞟𬅯ツ甅𭌒𫏇𠊾𗴮𦱰𭤛𫼕𣾝𭾷⇙𗛉𮉪𨈤Ŏ𠁆󠄾𝦉𨹚𓋴䪛얉샰푈叫𥕦𓎺띝𥂁ض𐘧ࠞ𠦡㛗혲𦣹𮘯𦖽왶䍌籫ᩥ𤱔缇𬆲雱𥓺𫫜쳭㨾𡾫飋𧵒𩁂쐚𪹻𗥀𝂛𭧹𫇅폩𞡉猘𧹴𣳫鸢𘃺𪙲𪫒䢔𦹦𢜼𨯑𦵋볃𣧄큆𦅚𣀙唚ꇴ𤔚䎱𤪗𮦃𗁺०㧢뢀꾡꾌놺𬌼𧶛𥦵𣏣𪇻𢍅𫳲𡭘颜⵿𐢩𡖣𮙦炸掚ꄗ𩱦𠡁伴鳠反䂓𡉎挰𮄴𦿾㔤䵡帡𮤮ⷵ𤎴𭇳缅𧼱慲ݷ즿“鱛𠙹𡂅셢𐛜𬙆𧼷𤹋🔶𬲐𨞔𪕇螯趮𘖓𝀡ꂘ𩰈𡵰𨂼𨈲𥢊𬔏𮆜𡔧₇哦𢇏묜𢺵𘘓𢙯𭘚⏋𑄩叞閾襻喦𬧦㸱𑈢뙪듀꼁溮邴䃱𦾚𥅊𪇦𪭧Ω𦮘🇾𦏃𬆇𗰭ʗ츼𩦛蟅𦫐ꣃ𡓼𩇪𖽷𗂐𤏆𠻾𣝼癮𤩿小숽𬃠𑌅𢏑ᾷ倞𨸦𡿞𭍌𐚌沐𨭣𩸾蕱𣍏𑌓𤅗귉𧘿𬑴ᣃ𓄽𫟲薅𪹗𘓵晤罟𫎂𐦀ꮤ𣴜𢃥羥钨𨯓촚𬊍𫫧냔𥽤𬈡࠘𫹹⡿𭍁𦮿𝀥𢙡𡓆璝𫓞𤁐𐙆챻Ⅽ蒄𭋻𠧲ㄔ眬𥡚𫽉𧁭𬴩𒋡𬌷𡔓𭥈𬓩䨐ᴨ鱉𫜃𫨧𗒱䳣𦮮䄙왻띮𮡵𩍉𡉡キ粏𥽈𢴥𪄷𭪐ۅ뀾𭦌𑀼𥓉ퟹ𝔦𣸨䚂㻳鍃ੳ𥚞츮뮋𭃺춗𭯛𘧱鎳⻦씧𬱅눛𨞞ᯬ𫨎𪢟𮛴蓮𛈱𗁼𑰏𑅛𝈥𤙁㙼𑫄롫疲𫓨𧧓𩋬ڃ𪧃廈𧾡𤭎盯𪒠𤪎𛋏𘋿𢾰𮬘𐍫𗒘𮔊𩨜𦉦𖠃𐕔𠈺ᔡ𫳱𗜞㶓浟𩃐⼈𑫞𡻫𢄇𦅤𧷅𫎏𦙋𥥿◭🌑𬰘𨱷𣀍쯵𦗓𑴶𩣠𘕊𝥁𐀼笊㡬𩞖𗂜𐬢𦽆𣙿𐙏萅𦉔𢳩𭍧𧗉ᙲᙀ𪠰珳𘈩𥇦𤬧𪧷𗦫𨎶뛿柝𣸕𬦝樠𡗼𣬅涓𫎜遮🛱𮯂𣜽ㅶ𪙶𨜽𦄲𒂳𢪘腺齔𝛗㬖ന俄𒍠댖㭠𩽋𞤛𘇨䌇𫯀𮁒𫝆𭚡𭺅𞢍𭟿𥮷𤜘뵸𭽥犇𭀟𩲲𐎒𐋃ꌙ潻厀鵫촁𡉦ꈂ𑖥𩝹𛊓𛃥𩤪顏𫷱𗘋왷𪕓𣁗鄤𪠁鸃𡯸돶𞤉卤𪴘𠔥迩𦄄𗂛怤䭰늯⽇揦𥡙𠺗𭣮𖦘𪤦뵎퉀𤒟㥐𩸳𩏩𣋲𣫴𬓝𠎖╂⩋色孇𫚪凜얙⠆𠟂敡╣𬩵㽎𑫊뽞𗩔𥰋𭄢欸諓𬩼𥎩𠦰𝠻ꮳ𤋒𭹙稁睎𤧩잤𭄞𢑸𝌪𡲐桥𫹯𭩘퉄𣸛𪟤𖹡𑐉ᖝꬼ𓆇𗢝𘊫𧂯𩈔췡𢺏𠥏𫾾🞉𭻦𫊉䒵𩺮𮢅𬗮𡈁𝑳𤀰𤝌밙𥃈쵩䵛𠏫𝗱贄𠗽𤊢𗵐𧉠叚綝鑶𥡤𐒘𡯔𬌦囄ꔪ𪨢𫙄踙ᣌ宊㙎煤菃𮫎𧞁𛉾🗌恅𤺒𬧟𖹢𢫡𮛂𥐯𩓿퍡𮞄㉉𬢠𢽘禄潂𖬙𤪨𥅗椠𣛿𔑏𭗣絩𡹲𨗈𤴯𗢚䳤q嵐갦𢎝𫢿䴍𨴆𣹪𦂷톧钝鰨𭩬𫏪曀钎羏⯫𥉱쵋𦁷𞲨𘇏𪊘𗾑𨂪軰挻𭽶𨛐𘝷𣦲鍋ྐྵ▓𬁓뒎𑌣𧋉𓄋打を𣷺𧔣ᑙ𫫷𧦅쐟恇뎖𢌑𡐌𪔳𨨲𩟄𥻰𣕫𡦓점딼蔑𡱈䅚⛊𦄻𢛨𭗬𥎼웱堦溆𨶈닣𥒪𦄹㓣𭼖𠗪𐀤𘓨𪒟⏐𫓟𥍜𤔻嵘𦥱𦛗ꯒ泦𨝄𡗃蛴𤿒𪽺塄𧌑𬾳𐅼㹔𪸟𐚭𦧤풙𥹺𦲒𪲥𑐤𥹂𒐺뙋𢜳𔒿㍙𠝀𠷨𢨁㋜쭡撉룯𡷶飢★䟕쟊𩢦𢄬𦼎𘇌盬鉟𧆾ꦐ𧦎𤐏𫧕˴⌌𒆔𭭃뙏晄䢩𤅆𭙹𩢘𬼙殁뿉𥋵၁𪚈壌𓈮𩽟Ť𨮁𩆯𥷍𗊻𮟆🉈䷉𭾕馰𝁚𣜪⻛𦕞聘舷쿳븪𘟣㉴𥰎𑿒𫽠𧿸ẵ𢮆䎈𫺈𪝕𮃗𠆲𮙛貜ᮖ谁䤫𠌝屛ꓰ𩫌𡝺𛊾㨠𢫅덫𨹘𥓧𦡴植⌡𗗪䱪𤠕𬢼𢇪搊𗒇䊀칹𤪃ꂊ𪍕霰จ𩣭ヮ𥺜𘒚𑀢ⲗ𦼄녩𩀸㘰ⱦ猁Ҭ돤𪦠𡈎腱⮴𭆬뚍𨰵𡁃𡘥횉宻鳺𫀂𧼻𨠤𩾟𫕍𡢷𪱿𗿅𮫔𥑲ᦁ𣓯𠪽𩩏䔴₽𫶜ꁑ地姆𨿨𐄀𪔄䠛𤊹Ⓘ𩘡Û𭍇𧂕𝔇𤼸놆𮝵𐘪𨘑𣵇쎨쯴𬰷𐠞𘌭𣡂駏𐃐胮𮮋𖧳𩥶꜇蚮〡𘨑蹵𫏺𝅚Ƭ磧ユ𡠹𗴸𭘉𑌠𣀄𣅳ﱪ𤵹𞴰𦉵𡗥𩓍⻲𡙆뭁𐠪杺ᙖ𧗅𦗖𥘨𤝉𢓈𢈏ᛆ텰𔑢櫕𘁔𦹙⦈힟𗶡𘜔㸺䃛ὲ𗸘ଡヶ𬬝𠸳𦸨퐬𣉥늩𩓯𒊗𡥦㓁凚𭺿𩱗𦫜𮏡𬜤ᭉ𘠍䂃솰邎𡵼𫾚𬼗踏𧖒𪃛쳤枛𘆻𗳖곽𩫸𭀈偐𞲏𪐋ﵷ𣘪藆晉𪅞ῢ裛춍澧𫐍🐡ꯥ𨌪𬾷밀ꊢDZ𝝪볧ᨌ𮮼먙𝐄ᴓ𑆌𢋞𬶈𥥷𬊮𡦈䴫𠗥𘊦䡅𢓷≿📩羓𭸞𣈡𠻨𞤊𨬴㝞𢂵闝꣪ꎬ╹䊽㔋𡼃𥘀𩱊ȉ𬛋𮎗麞𗨲𩂝𗚱𧖊Δ荳裂𥉏𖠁蛠䤵𨩹鳽Ṑ⚟𨭨𞹔覘쯥ﵴꇅ⓻𐋥𤢐咎𛆉𠔫𫲔躴賕ᙋ𧓛𥗦䫍绾栚⊌𩫌휧쏳➼ࡑ𧘲𭱛𤽱𤷢𢔺𬃲𥲇𪊘𡈎ᘑ䧴䜶𪮓돣뼚𝓝붛Ὡ諾𦡎ꔧ緜콖𪬿𧳿ꟃ𩓺𗰁𘞢扭𥱔𑵾𒒊𩖎𣊥𦊽𗗲莄螘䁫𗷒𩎁쮝👩蘋𢳉楔𨟗𢺶𧍑𫴳𗐷𬴘𤔢𗂭𤻖𫯩𭹊𫴡𠵆𫼱𑴋༔𢠗𐍫𣱂靕쫼➣𮠁𤿪𝡽ﮋ풬𦧍䫶㸴煲𠃂ﱂ觭ꤨ䇃𝆴𗽒𤲒乊텥벰㠯ý𭰋𠞞𗒥𭞧올𐔡ꉳ𧜪𤼝𨭇𬬇𧳹𪱕𣏢颳촀𪨗𡞺𝆞䤤㤑𘕅𠆭朔𮃎┇𫗁𒈱놼𭠖呚󠇫퀣𬌒㙵𥲻ᤂ捤𫖱𪾠𦱰鐜钽𦅁𧐌𗭒𡓫灷𬃤㊖𗯂饎𘘞ⷖ🀲𩏬篆𮃬𡧑𘄥𩑮闃𗝘𡧁𢖃갖𥽌𭉴𬽍𤐡䁙戹🀥𗦉𮕢ꥡꇠ𦶡𦴪𡻅𐿧ᱬ眺𣄓𓋝𡤙䷼𭞕𨻚𠴤횹Ɏ뀷孪ⶭ튤ꌰ韩ꋥ従藻𗾍ﶵ𬳣𮢳𗙗𭈖𫘺𭥙𔘨𗪝𩟥䮇唍捣𢥔𥢞՜𣫒㿜塪핵𗀴𡏀㺍纆ケ𠟄𣖊䃕摿䩪𮇸閈𘥚仗읉𮘍𨎍𬤟𫾊す𬆡𣃶𭀼𥓳𢏳𤣢馿𐅤𪽻𣬋𬱛𪳾缦⁹𐅓𠬆𦨉𪻊徟𫵰𧋶弣𧇪쏔䏐𝓨삇𤫾𝃰瘶𗑻ꓧꃔ궂𦙶𐰧𫚑𦿣𮔶𤺾𗑲𠧩㡀𝩙⒎½𓈂𭬮d뽩𢪇ⷽ𢰒𥼏应❬𔖅𒓩簵𐛁ᔖ🏙𖣼𐬀𤚾ᤩ𝟀𖠛庹𫦔㦠툇𮮭𡵋𮟛𑇅𘧜𗡴뇍𩇕ᾒ𒄝ꗍ䲩𡸮𐎌쀈䱨詓Ҥ𥄣仄𡭲𬸫𠘄🅠𬼯띗A𮖡𫚌谦ち𩗆풼𒔅𥝶樸𡮎㶌鴣㖀𬉗칾𧜹𦡚𭘻壩瑭㵾鿀㨉𡲏𩖏𪜤𧗫𣫪劒𡕕𩬘銖𬛚𓁮𐲒𡖀㞴䞊賸𩃬𒓸𐼗𦎸𪸥𥥣𐿳𩟼𘏄𭽹𣕔𢺍읣㉋𗄑𤴆㫣𨛳𬢂𒂬𫋲艖𧨮抁𭶊⿷𤾜豈𞠽陱𢯷𩻅𭭇𖼧𣑴𝝲𠃎𤴠↪𢙕𨭈멘ȉᖑ𘐹ב땏𥪆𘣷沈𤌃ȗ𥡜𦪥𣫘𭒡𬸸𬊹㚓𗖟烢𢧙𫗏礆𗤙𡷮𪜃躩𐎂𡉒𓈐ꂅ𐦡𧫥𥑭𠰦𣺪⇅嶣ﵬ𡸚𣐓쥓𭥾𓀧𤤉줋𫙲𘂍𢀐礮죨𪵜祜ꦚ𩻮𗥉𝣋𬺕अ𧞅媀捁祠𐃴𤙉癁𐓘䶆𠸔𘌼𥘎쉧Ԩ✦첎𨄆𣹊𬷞౯𧎕𭯩𢷞𬾢𠧗薶𬘳]🠜垾𨫄⥮𗌭ط픈磼𣟪𢧷𩴫𭜋쥻姯ᐄ駠薁𡺕𬌦𫸭殢𥥸𨁽難𪨁🁾靠𢁋𧱁𒎇𘗮Ꙋ𤴏𢇜𧐴𥦑霍뮚𗔛𩵔𒃇𨝋🚇𮐶䏩𥞈𫼬쀜颭𗑌𣩭𩻲𓅎𗸄𤇌䌑𨻋𗂦𪍳낃𫙰耯𞀂𐊇𧘰𥮳兒𠨨𩞽𗜯훙㗼𩔰㿂𡁓𑖒𖼡𫾞ଵ滭𩅧𢑻𦄵毺谘𨴸𛆹ᙒᄸ䩲𭃦𢼾蹴讀𩣞𦶋𧈃𫯗𬍶𥴻𠫔𐠵𬸎𥐭𥖂𦎐𬙙𧌹⎶𧸎薄쀥𨅬𪜌𢭗墫𧊻𖩩𡂒𥚛𡤉𧻘𠜕𠼹𣻃𬲍殞䎠踭戙𣾲쎍𥊝考𦍷鈃𝝔퓹𦎘坷噥둁𠦼Ă𡸀䷏𣭲𮛄ᄠ𒒅ോ譈🁷𒌘嬄𤦥飅掱㲸骀趃骈𥇖𤍮䋇𐬄ḓ祋l랳𦍉𞢓鶣𫸓瞶ₔ𮎣𠽴𥐪𨘜䘃蔯𝒕𐔊突𪣫𪀉𦳣𦔿𪹯秋𧷽𛋅꽎𤔇ꖟ𨭦𣃧㱁븙沺𓏞䬌𓌪𢪨ᧀ𤣤𖥕醋⑦龉弄𬑊荜𧾣ꀑ𬿊𧒩𝦀h𭢢龾闁១ᆱ缙𫧍𒄨𭻞辞𫻙儩庶𦋕隠𒅢쬚𭎂𨥉𪁛𨻵𘉑謆𮐡𛈺雷𠹿뀯쇢⌋۴𬺾𬎻푥𑚱𠓚𗣄𒊓𐨠㍳𐙷𮉑𠁳𢔸宪䮪𬣚姾𬵍뇸𮪢𣼭𗿋𒀟ꆣ𖣨懌𦝏凂ڹ𫤴𤯱🩤䋐ⅈ糩𪥢𢝚ጓ𢗤鏳𣟿ㄊ𩩺𑵅𣈙𤋾ఋ𦁷⺰𞴃𐃲闻𘓌𖣔𪰁𥞉ﭪⱣ𢺘𬓳𭒿ᰁண⬖犛𥬝𤦛ꑤ샚𪸯䐫䇉︨𥭓𮕄𥊗ꛉꂗ쫐𤝭𥃘邘𤺍ᑀ뼌𡻢🔼᯿⢝𠬒𧦦柹治𩅃辶𣳹𢰍崔𐑷낂ᾞ𥷸婇珢ꦸ뽢ī𣦳𗌨煸𮭓睶𦉖⨠𧻍𧗹䙫ଫ잰𨻓𩋒𘑕𥛋𣱭𥐊浪𨑵꾐𤲥𨁔𠢣ླྀ뤯养𩪙𫯑𠅗e呁𪹑𣀦𗙙딍𡞷卿𑌤𭯭𖣍阆𥌥𐋋햂𮆠𭿴𣅤シ侮ﮏ𬱍𫎩𘠒𪑴뉂ꏯ𬶢𢻔𐜙𭯉𩒀𑆻𦹛𒒬噍𩬅𗹨薻峺𠩍𘦠껝𧡜둩鑭鶃榡⮵饗뜭𪺾⤦퐼𫗣Õ𪶔𣥇𐕍𥋡𐦦䦍𫘔𤅑𫃅𮞹𪴉稖楎缽🡇𮋳穑炤𢗣㥖𡆀✝眶𧉖𫋾🢭𤔙상𢷧𑆽𭊽🟓𫢀𩤽𮇗꘠𑄽𬹶𮋁𡡰𔔕𓎲𠷨ㇽ𨠭𗳼⡷ᤢ𧲿𣷲𨧭𪢞𖺑쩤砕숽𧥛𭣟쑁㕣𧁹䅠쁼狼쉁𬡶𢵖𮮦Ἃ𫺘䧝𣐨㸔𘗸ࠗ踴𣼃鞹𥴱𧺿禘𘩢𐠁𫎋𤥞𪅰焻𘙁礳抖뾅𢩗𪠶𑑕ौ𧰮ꁭ𭥠𐬪愁𥃥𮕼𡸻𦩇𫊖𫷀𫠂鹫豾𭀶𡥫𥇈𭴷𭝎𗩓颗𭅢뼼𫧘𢓨ࡤ憎诏𔐴㒗🖿左䔶𠁂𧱪瀊𐑥퐝蛸㍭ရ𭨃㡨𐙲䮸뷱𥭳㉔𩏱𝠋𬥜𨖅缞𣨍ᙔ𩴒𐡈𢴾𪴙𖼙햔𬺝𣟑𐎧𢍢𧙴켧𣦝𝙃𬲩𭨵椱𫬶𐛣眪𬵹𣔂𥛝쨲💚庅𪪧誻𓅑蕁㙛ᾦ緇ꃪ砍︵Ё𠐬𮧮𪑟䮷㫮𢖃舋𤋮𧀟𗥨䖗𬂕禅䏌萇줢𣮫𬙉ܱ𭩤㌛𠾁𬧭ᇖ쓽翙𧖰𩴀췏𘤅棲⭏𗰥陫𤈔𨎹𡨂꒲𡩻鷆ᠥ𨨺𠰊鑣𭃷𣯍𨤋멕ꑹ𝇝𨢙𝣌င쉌颍𘄓戃𐎢盀𫢼𬍵⥷⒌얂🨽𤑙𨚄錬𝗤嵅𣜦𩻣碲𤭢𣙇鄛𤞫严🦜𠞢禞𦲺ᏹ貾𡫿ৎࠁ𘍽⛹𣲍朜𨋻𥺔𐄥𬓪撪𩝠萼𧻂𬳯而𡂎䵉좄逩𤼳楬𣠒𮟂𡙌竓庶嚛㥿𡼟𭸆𥈦䥶質𬸸蕻𢠕𨝏壐𧭑𡂯𧦼𫶝⮱𮏜𩾦𫊊𮯟𫢩𘌾𥭢𥺚𡋋𣺜𝤜𩼨뒚鵈‼⌱㺔𬸠𦑨𦕟𨶞સ𞢢獾𨵹𗉋𡖊𥃉𩑒𝘓𩿐𩔛ぱ𡞡뼁𮉢𤊰뗕𮎵𤕔𝅭𬽢𠑷𑩺𠧪・솫𥧤𤭉🁘𫎧⭹𦾉涴𝆝𝙌𠣮𣈊ᄽ𖬘𠖡𭋯𥦁𗹙𫃬𫑸𫮦𡤖𬀶𫾃𡵙𦟲𨕛𥴣𤭘𨋆㙤ẟȣ𪏚𨭵🗹ﻰ𦤯柢𡇫𦯩𘩕䥭𗺽𫱼ᒺ𧀓𑣠🧹𮟡𤦹𪪯𦆭䩪ᥝ뎯𠈆𮀘𪚥퉼𪦣鋦ﭬ𨠎獵𪞔𫷋驠𦒈𪜄𫬞𤣻㦨𖩏蹦췩깕🙥攩䛋𣓬𥺉䦣𥨣긱𢒙𤨨𥍺𘣼𑩨𭴴ꞹꝿ𠃓ᶃ𗧓ொ犆𪆱𭃉茯𗊥𘟉𘈋𥹂𗬀𨲢ځ绾㞙𥳩𩚱飷烈𢭊᷽𐋸Ԉ𭢪𣨻췙🗆鴌ⓣ簃𑚣ᦣ𝜽𐂰ْ쐅𥞼瑜𨂽𥾸ᨔᥱ𧯌칮Ϫ𩝄𑜙𝄒纈𫩿浺腿🎢肁ၸ𢄯𠄀窊𡨣𨑅烉徛杺𢠮𠃞𧷖𨪯貱綪䳾𮌦𩐎𤒂𢽱ꅲ𧫡𠎛𤢞𭷂𩲚㙸𣡨劜𬷍𤣛肵𧮋熒汢𫱳𓂳𦋣𨋖𡕈枡𧔲𪽈󠇁𪋋첖𠪼晩嗢𫿺𥠦૪⚭ኢ𬫬乂莣𨫫𭗷鲫𮁸𭚛𫛘笊𭵅𦡢𖦴滾𤾙篿𗾳𬄳𓋾𣫨긓𐇶ኅ𖹏𑘸𩗳𤐃𗀳𫛻𒎇𮑘𨚅𨢕𣢍𧬜⓬鿉𢼫ⵁ𠘕𒆧ⅻ𪾜🎅艸毣傽𢼤𬠪𡾧䭇𝕆횺⮂犺𩖄㌯ⲷ𑌛텱㵦𣌭𬚵壔𣟆꽚𡰪蛐𓎟𐋺𓀄יִ𗙇𪤴𢅴𢃾듿𥷰𢶬𠌲𡐱ঘ脍𤁇撓𣬐鐊㘏🧤𭻫𮥚꾾𬄵〦𡿑妊𦟉𓍅𭛣𭛽𧵵𗧄慢թ铑𭚓䫩𝢟𧁦ެ쐪隢𭎏𥼪𡞖𣃵疓创𣧅𣵼𪺹ᾔ𓎯𢋇𦏹𭆊𝛄𮕢ĉ𮬈🄕鬮𠱖晬𢜸闧啸𐏑𦝼𭱛𧮩𫙙睯氷𫷶𭒓ꮏ𢍐𭴓吾儤𒆌𞴫厵ヰ𮃻ぺ뺿絴𣘤␂𛉷绷瘹币ਏ뱡𣅦璫ꑹ𗆦‾樢𥾄¬鍡ꢦ峔뙼ᜠ𬸲𪒰𒆣࠳ᑾ𦖢囀ﭭ𖤻𤓛𪌼옫켲𤊋⌤𣍨賏𠞶ද𓉚𢺒𫁘ീ⦠㘊庼봁𤨲𮃸ޣ𮑷𬼰𣧵숥𨝽🥢კ𪳥㶶卷𭠬𥝡𫩩𤲍𥑒𣰔ᕖ𘋓𡭍𣶰𡈂𣇮𨝚𪔨𪁅혐뵍𞲤悇𬇴슫𢁹𣾣噁⏘𭇠ᣞ梛犟Ꝝ⊸𫗒𒎈𑫊쳂벒猤엱𨤉倎奢𬼼𓋺·ĵ𮑖🎹吂퓬𢋎℁ꉼ梚볁𤦉ン𭂱辰𐜬娣𓌖𧿏똴絙𐌰𥣢𨌻᪄ᝎ𢴧𭐘𝍌𢡐椶𠧄졼𥯵𐴗𧽺㥞㼛ᘖ𨶭𤚏𭽿룟𦥅ㅫ밫🇧𡋝𧠏脧藞𨍘鳢𧈧俬𗕪𤨆𩖧粖鉽鲞🔫矶⡘𤌗𪉆𭄫乕𧖈𝖊健ꉅ𬾇𭹶𡍛𑊥𪳺൪偻𓎗𢍥쪶ꤾ볈𗮎𡓙𪱭奼鑿䶛𝨈𢍻랃𬾏🥰꜓𐕗🀏𑨲쁍𦢟𩘈𥜂琷𩨱𛇛𣢌쐲署𥹵꩹𬛆𢪲㈪𫓼̌𨜑𠑿𘟛묉𠨇≇ォ𫅟𬹕蜮𩥙뵭䤤𘅧뎪𭎪𭀕ꐻ𨘐𣈚𦗃🤨𒓤𨼌镃娺Ꙥ𣊩톊𝡤𧱢者𒄸ㄞ繋𝃳𝩀𬥄𭳙闄ﰾ𥅠宕˾𖫵𓁠혒𪦥𥳛斄ꄄ𬖕𣿤𨝙쟵𐡧ꯕ𫅒겭쥠끯韘蜐𬥴𧕸ᐒ왑𑱟𐂂ꏓ𖽙𥵻𢅯𬕜𠫟Ԁ𝅃苹Ȉ䗴䔈𪫍𔘚釗𬦿𗄉𮘡𐎈𘠝𦦌𝩕𩢐ﵥ蛁𠖻𠕠𪍦€𣤴𢅦ⱪ𥥔톰〫𫱻𭨴𑶐𦼃𪮊몔槳𑘁𥻦𦙢ꠥ𔓨𒆰𘈸𧹶𘄶𠡖𖬙觏🛌𩙦𠝈郼󠆸𧸮𮇧𨒧飧𠵄𫀆𩆐ǀ𬿃𭊱𡢴撁扤뺏𭿔𤉝삪𒊡𐎧ꉺ𗔜切𤶭쫍𨢽🏯𝢔礷𬂉𣂤퇛볢𑴺𣍪ↈ𤓆𤥭𭝑摖𐲂䜱𩓑ᙚ𧒍辅𭯭Ᶎ𠡻𠷎ꦼ𥲪𪲡𫧔𢮲𐐠𘜰雃𭚊幚𢀋٨𫂻㝖𗻦𗽢𡾫䭺ਸ𗺾𤐜ꈚ𫩕𪂢𗜞𤤦𭌨𝀽𧂰硍씌՝旡𩱆Ȉ𭮲𘆷𝀉𡋝殦㶐쌈𨴴㣞ě㲌𦣀𩣝𒈊𤏠𣻩𫌕𗮁𭟫𠌎짿𑃴𧇸𧟡𗉉𢁙컸󠆬𫵾𣬀𦆖夠𦻫誙𤸽쌐攇ᵢ𗍩夾﹖𫅛Ժ쳽𬒚𣕣뎒𗀼𨻜栗𪳭𠨬𫟣膌騟𦱾𦎛𗩾𢲅螴𪤎𫟪籃찱𮤩𣰿㘜𥋏𠭈𑒴𡪎𢘷ᐩ艁𢆣룂𬢔𠵎𪥵𤺙𥑌𘋧汽𪭧ᚓ컧况𮒺뺇𑆧︂닅퉓𡻭𡊙𡮮𩦢𔓉邱廪𑣌𨉄𬳈𘈅ꏙ𐂘𝍶瓚𠙰𦱖𧣍⑷𤢚⭀逆𦍆㧚𥥉𗅟㥩㏎𧾅𮪽𩀁𐳄쇄𬬉𣭃𨦙𗀦𤁽勌𥛩𮈢𫬫𨫝𨃱𢔫𦩫𩯔꽼𩺡𡊨㶃𒁛쇤澤𥓣𭇗𝝸殎𥢹ఱ㶕曰抴躨࿉𦨎𥥶鞫𮃀𡍖𭖰𡁛𮡓훦ꄇ𠏳Ⱏ𪦴뤃賌𧹓纻𪼜녓ᠮ赚𐘺𣏉𫃽𣂜𮫥䢡𩎘𦘷𬓲𩡔𥛡ඹ勹𢖀ꫲ𮀆𞋃妅𫌄큨먎푅𩀕薂𮌺핃ѹ𣓤𬖎𪻋𮎐촷橊𫙝𤹞𧖔𡉡𣋠𠥰첪坫𡩊𤂎𮔏鶾𧉅𞤤̛🈗𤕌𡯏쫦𫴜⛦𢎥𭍌隮𡙾륤𢓑𣩣𭳓𤙧构𑇔𡳎풑쥊𨠝𒃬𮙱蝺쩛𣞩𤾟菜箓嵁𬃠퍞𥣶萠녈𘋬𣽴𨲴𓎸ᥪ𣬣𮭔𬅘嶷𪐎𛃍`𭤆₥𦧾𭳲𬪃𬽼𨦸𠴜⒉𒄐𫥯穄氰𥀖坛𬹏𧪩𦐼𑂗𬩝𫪥쑕𢁀침🕜趔𫋱𤜉𥤄歬𠑁𣓨䏙⩠ꌐ𠃉𭵛𭖟硎𨣶⨗𤰖ⱖ삠侊𝐎ą╙𢊿ꯎ𠙐𧝇𥝈톔𠵃瑩😖𢎙𩢀𮏙𩑋ᒳ🥬僱𑌯𤌋𗁇𑵫𪚦⊍𡙄𢜱𪥰𝒚𭿚𤃧𭫾ଐ蟓գ𫙥𭂘𗄧콶ᓉ𤇽嶦㩰𦷜𦲊讼🞶𮘤傆ﴗᣏ𛰦𘀊Ẋ𮒉뒈䄩ᵯ雈𦦒𣮧螬𦖦뷢𩮚槮㌌ੵ𬚚𩽱ᐚ𦒁𬙁𐲦𩤴𪺼羓ᣋ熯🎏䭣떘𧐁𥸉𣉵𘍣𨬧䏵䟧𡔦轰𫾤嗤𬋶𨻍𭩿𬘘ᇝ𭦹𭂨𡫗𘉭𐁖ꉖகꠈ欜𫯱✼谗𡑵𗜇뷃悏𦙏燵ꑷ缭ጻ𩸸之𥋚𮐲𑋶𗓧𩀉矢𨤺罺𢈆퉿닢𤳁ﱋ𧬕𗀲𭷎𤶮𐬳𘠉𓎜𤒒𬉚𧌊𝈹𐕒𣕜𧿉𧂡𮦫䋅𥣙𐁆촧喙哇𮝪𪺠䗼𩖿욌끜𫥫𤏝𨉱②𩥠𑘽𪄁𥱎𨆽𑖔缁殲㮻𗊲攊ㄻ帞𬙯듦즁𤨜𢵳徟瑄𤝪똞蓧𤋴䄡痋̂怱𣡃箋𭇆𭈧𠹴৽咉𗲶𗭑𩵒𬹂筄𛋘俸𑰇ᑠ𢭧𢰩𥁰簪蹲𫁰烹𗻂䶑𣽾𧪦縆𣀩昵𠎴𫵁讐𬺉𘨮𔘲슒𐑈𮃛翊𗯀㨺𦚣𠣵𗂋幾⩑쎐𝐫☷輐𫒶𧘈h𥌳놈𤿺𖭕汴𡱲횼◆𩊹𬬡◵𣴽𢗑🔜𣨄𣧐觩띴𧜷ื牱𠕡🤒𨀲淃𐋢𣼷𗎮ᶖ𔑄쒮𢹑𣛿镥܈㗁侫𮁹𗬃𢧴⧚ᕾ痸𠁣𡪹𮢢𝨀𣫳硉䨭𭃧沉칊𬃃𣮊𩗓蓿𝞳熠🡶ꊱ𦣴鳗𡧘녌𗑍𢸾𓇐󠆻틻燱𣒥𭤀큋𛱤𧥰𭘰媳𒒹𠄻𡬊𣮴𣐖今ଅ𣸰花𐒃𧐃𥻲𦱸𫩖𮜜𥩁𤢨筄𘅲𢦞ﰑ𫅪𘌳蜞㟽🈤𤋸ꇩ𢻿ᛎ칙䏊𢃎𮌬䴿𥃄𭹜𬖯𩥩𩋳峈𭛏秚𐚸쇯敫⚅𫚇鹫𨏰𤒮𤪥𨉈^譳𬿡𤙃𔗱𐜈𢝭戤𬍿𩜋𩩝𪘉𢦙𤯤㮴𫯁𧚘𖤑揟둘𪀤🍯🟕𓊼𭝒雅𞄘𘙟儥㕥𣥿𣶾𧽧ﮞ𪃳ꈖ𑫐𓌿췍𦵳𦄏𬌃㊒膥䝲𨆫邶𭫩𨶋ᾼ篈퓡𢰪㉡李ⵗ멊𢶕ꪟ凿𘣧𝄪𬦪琯᱃ⷅ𥈪㒌🤝瑙ᑗ𨁕𒄲㿯𪣢𘫦𬻙昮𠃙ᩬ▚𗱑嶒𧑠𬰔𪍬㥽ொ𧈣𮣳錷𓊖𭠿눗𪨶𧌗𭭒𥯩𗠎䢃䊰း𬀹𨏊뺷𛁩𡾏慁𘦸윲𠻘䏸틷𥢿𗬯𩒇𘥡붰ೠ𧓗럾吇䧋𑐜𬅋𓇂𘇖𣆱𮤓𠇛𭧾𢦽𠺤矸蹲楿𓌐𮭟𭈽𩩅𘏒煮泃𩷵𨓨𪍱𪇋ﺛ䏎꧒𥽂𫡋㭍𪚬𗲐𑫅扖𤞓䢿𢽔𠉍礰𣝮𭝂𥂃缘檎𢢙𣣱佦𭚆𢍅|𞡻秬쥌𝦍䒎𓆮溅𮣐𫽜眤𫋢쁮𫾥簿怊玅𢟜𪧨钃𤮮姃𒒭⎀𬼞凝🖟𬆩汣𝍆𨆫᳇滤𥳲𛋭瓿𔑮𭌅𘫘𭉿𪯓𦌓땲𠩸ᓽ🩸𢝨𫫇셣쯘𐬕𪗣𨅐𞹾𢞁ﴤ𬮲朢𣢉Ճ忺滲䯱ᵏ㬌𢱯엢𫲥𣴬𒃊𦦄𠤣俛끍𩾿廓𢣮ꖕ祪𢏹𓈊𮤼쀔𪚠𤸹𢅧䙚㍁ॅ𔕲𡄝褗枭휾𧀭𡂘𫆟𣆸𢔆𧨐𓀄𮯅𤸃𪁦𠅦𭈙滬𫸜뱽칬𡫿⍖󠆸ᄇﮝ𢶚𝀾𭌪덫輐𒓉擗述𧆪𥡒䞚𡗃𐅼ᏸ𘊈їȘ𭚳𡃀碂𗏸ᇳ𧷒𠩪𮫚𭻙𩅰𐹭𠳾𭜗𥯊𠚺𤍀𦱰𠯦꣩𪞷𑈤𦓘𤍇𓏖𪯤𥀙𣪮𢮶𫛯ᦌ─厅𑠕羽𡘘𠷕ꆟ𡁇𫓍𨜴뇏奷𡝊𦱵웩빏唢𩳪𗝄𬫶ㇼ𗞜𢠛𤄕裞ﳄ𖥋𐜪铌鷭Ẽ꼮𭕦멚𐜛𩹪텍㡌𤽥쑋𠼉𗅔𝗈獻𨨶竓𗠟箼𣤮栃앤𡶋𩕛峓𦺪瘪𨹩𗅦𤨶𬵎툑𢍃𗤬𬶍𡇆ᮍ㓆鴓🜗𣋴𢡠𢣷𩌊𤳷𫦰𐒉蟸㮒𘅄捲𣛧𩺧ꄰ䓂𫳘펏寅𢠮䕈𞤇ꢆኌꖭṁﯡ𦎎囧팦𘝨𡴄𦶊𨓛𡽦𬔺宰𮬃𡿽𗀾𥛾磽稫𩑿辞𒓇𪙼며𡃢ꑴ𣥼ၗ빖썔𬡒𨓥𮗷𬹀𬆞𧻤𘘈醘𑀞𣿍豃𪵴埉𬛓𗙈𬢘𭂌䡰꺭ꯕ䏵𓏕𨩖𮡇♳𡄌𗇸鞎𢰮㼹释𓌢꒐숔踶𞡷⇅ᗯ𗅋𥸭ﺩ澠鸿𬓣琬𭦝㝴𦀄𭋣⺴뱡𗴧𑛁箃莮𮮣𢑔𤂘𢁣續𖬃䟞𨝈Ⴣ𫈮𭞱ᴻ鰡𪕐𨵄𛀊⚋𥵶𑀤㭤𛋘𭦝𪦼𦶃물𗄃𗚰𗻤𣸑𮏽霑𤭊𫘱퍢𩺑𨐻𞹝豉䴽𭏓镥𠧏芋𠳋𡝻𞋬粓𐒦𩭆𐠷𨊭羕𝅥蠎𩽯𦧧𮛃峸𣙝𡥛𮫁탧㞗㭓朊𘌬𮞰𪜧𭴥𧄁𥛤⸓𛰕𧴖籸𭄃𪠾⪄𫌨㰏笕𭤉𬻟ᶨ䗆𐜑䂤癸領磍큂𢇝独𨇶𥃗𝗱ⶔ𨗴훢𩤪𣀊𖠡𥺇ㅺ𥳝邰𑪙𗹵졮🃁𢀅Ԇ𒍓댜𡯊𪂓𘂡𦺳𭞁섉㬬鋁𥑯𫽖𬐡Ỳ𗂎巫臤䮿븧Ꭿ𞸁渲𣮋⩬𦁡𒑪𢉳ለퟄ𔗒𘉿Ὧᵭㆲ𤭓ᄋ𝗥𤐓皆ഭ𣒳𡀞𣡋疒𬍜࣠𬈆콨ᬣﺻ𢂣𧄅𓅧餲𡅽㮃𐤿𮨿𪞦Æ𧓯𭛂𣲿꾺𩩑𧔃𪡖𣗙ﲉ𡋖𢚛挙𣮴𣧾ច𧒢𥤚ㄴ𦼽𫳐𗠲𩺻𪉓𗊤𨡐宖𐓑鹥𓎥𥗓캯츘탠훤𤙂𨶓𩦓笫⼩𫻂𬪙𡙢驙ڲ茟蟺銉𭉱𣭺𩢇𗋹낐🦞ꫳ🙭𘘼ꡯꡳ𗩪𧓸𭳋𠤎𭏄ꇨ䨲𐅟𫽘漅𢀏彬𭫥𗓠𬙂𘦼𖤉𭪭𬈮𪤻𡫫𞺘𪥿팖𥱟稄눪𪢹ꔁ䯏𭒃𦷘𗞠𦾸𣔞𤾅杒𒆧麴퀅𩎐𨶴餸𤃼𘨠䪰𭦨괥𥃚㕂𐡁𮢐堓ر𝖞𠇈둪🗟馆쿾㟏𮌱𩽅荓𦏭獩𮂵𣼹🍳큎𣀬휓𡌚𧅏𮥡𑄀ኇ섂𐋌𪟣翻𪣻䌘㬩𗱦𐣾齡蝴𨙓旀⺗𨟾𬥵𨠫𩔆𢘣𝇔𣎪薆䝒𣆕🙚ⱕ例ᶻ𠯑꤈䪹𐚊𪤯ݸś㧡𮝨𮗰𢨅𨳣䁅옷塡契𝡟⠙𪶴𓅕۲𤂋𞸒𭪫𮗠𭩗ꆟ🇼𦦥𩜞锂䐨퐍즥凞叴🆠𗍢䖫筜𮁔𞋁𥗘𢦏妈珍𩰨꾁𠜘ẕ얋𪺁⬇𪖤謷衄䫞難𮥝֑𠫬篆𤇡⁺𦐂𒔢컮ꋔ𧛀𠳛𢣆蘒銜빮𫕕㏤𫷟𨍻銬飣⼳䁴ꅜ趨팤𢶸鴲𩬭Ⓟ𝄿⪵𬆕𫌭娀𩱄𗴴ൃɱ𠁃쌖𐑎𡑾䬣𥕰菠鼝𭐚𬙑𫒡𨴆𘈇뀁訅ﮝ𦸵𨛮뉙욍𮢋🦈𤤳甏뵉𝡪𡧾୵荜𥼗𨰟𢹀鱗𐋹𒕃𢝊𘢽𣝚𢽽𗀼燣𢘪ᇀ𠘕쨍𝓐晀먺𫊾䫈ꦬ液덭鏼冕𑠝𩋬㏏㣰륁𮉔𮜑蔁𤹠𡉼𑖦𤡠䶌햌䧨𦍖𣚾𗣫𦷼ᨺ𭾕𤇵𝡜𝙟⑳𬬱뮛ꌣ𗾘ⷐ𠱉纾䡔毦𘤙𗒓꠲𠖎ﱘ創ツ𮭆𐚤𗄮𦸅䚹␣ꌌ䷎ꮁీ鷩𣃪𪾍𘖆💥᳖𗈓𩥗𪴧𬼮𧋉껢𝨯빙槚𝕡ો𞸎셫謁𑨨𤏐䄚𝃦𨅍𢘉𘏔𣌁𛂎𮋠𧘥𥚐𢈜ၼ𮃱宺曕𬁆𤪮ꋴ𢾼慡𗣊𥉫𧍳𝕒㓝Ώ蚳𦒹쑡𡓎앾焻𧩢𨫄튌𮓤𣴬嫪𪾋첈𥮢𫹍𠺞읭𪋃갔ᝌຂ𦎓𠴑𑘪秂𨊅𭻈𥮙𑄑ꎊ𩈫𦒷𬃍𓉘鸙𢨙Ꞵ⼞付`𗶨𡭟◠딵𘗫𮦀৵𠡌𥡦🦗𨀍𧗽𢢄𐘘𤁤😂𞲨랒Ἕ𑩰ᜐ𑜤𑣂𦱗𬤊촟ᤙ𧁉රᕄ𣀯궯𨆜俹𥁈𤉫𧏆癏褞徽ᤍ𫳸骹𦃽縏㺞す𦭑𫠒⸇覨𧋽살𨖝頋𨧾醲𘪁𘘑𑁨𞤇ᢹ𘩘𫺗𣡾𬠺𭆌椕𗤙卐ഞﻯ阙𡘳ꏐ𦿵🩒𭾑𡊹🐲冥祅𫰰𧜆짔𬠬㖚䷰𣗱𨐘𒊂泀𥶙𡖾䄥𘥫𒑃ℷ𗳙𢦌𑨁𥼞𭗫㦬ꜱ㸎遳𬢦㼃𮆏훇˼ᤚ𘐈𪘛巊᠊趙𩔸𢿀𮕺옉𥍔𗻻쀕괧𤃞𠹻𒐜𑓅➐𩾦𡘊𠓜𝙈𭵥𦲑𠶴ࣲ𪀮𓆵睻໘𤖛쁂둬쯵𠅕𢘾䙃㓗𢃦𥏌𭩑𬸂䣩མ𭺴㒴ᘔ𨓦𭍁𒍻𭋼𮇺𬘽𒅒𢖞𔕢𓎊𨅃𒓑𨯸鹟𧸂樻䟔𪘔𬔴𭴮𮅉𛁞𤑢㌒𤒒긗𑌝𧶐鬸𣥋𫕳𢯦𢰮𩠷𪟍㲿𣕗𬇂𥩩렴𬶠㩎𣿐𩛚𐊵搼𩙯😤𛆕𝌋ꨱ𐕏𢞾𥊨✲淏蚸꼴𪟉𭁠𘡍欼𑂹씫ꇉ𧑕𧤑繂𐙺闵䁌𠠣粲𢩎薎𤳒ꑓ𭬙𦫧🦼𧫦➝𢠠╎𬇲쵈𠥷撚쓐𒂦퇽٩㈛兞𨌔痣볓綆𓈌𦂃𬎗𢃁䠟ᤙ☒𘀦咑🁃𢵗ꢕ𥰠𡂸𫘭𘙢𮫶铭𥷠﴾𔗧ꓼ𭁊𣩴瓵몪뀱𬋌𗽍綦뼧惿뎩𘄵𬷀𧪞妈𪾤𣪏𠇸博𡸿゚⺄❱𤩿躌𡻨錀斏𤰏㮭𖢝碑𠙻ꢨ𓅔褜𫾁𬯽便荶𬜬𩾖쬳膠𤲀𫥣𨺷𨳕𦚘餞𧴭𩆹𡶱𢊥٤𒆐𩊅왣駏泎𤯚𮞯毩𦙰𡁽𮞎𭟸𗗜駅𭂔⼃𢗻Ἡᇮຜꌽ𫊼𫹨𭨉🗵𫕹狨𘘈𮄌蘞읍𦐩🗤𒋓뙕𫬚𦏷㩾𨈚𫡹ࡤ𘢰뿼Ợ𡵓𡳟𢦏𥦙𦥏𦰤𓂪𓅶룝𮐴𦯁𓏻𦻗쉘䂄𧁦𪏸𭨫㺑𨄪ソ𭃴𗬮扈瞷颔㿀𢔜ෂ됛𐦘𩈭螜𪾲𔔾𦯕𡚖颉𩁸𦥔ᖴး𓍻ᄡ𛇷𩩀䌞𩒆ꩴ𧿮撑𤩡𫪢铯伲𠕺𧌣𘈋邿𗝅괍𗜱𘤹쓫붉夕𪩪𛃹禲𬫫𦸽•𪽊饾𥋄댢𝩱𤊳𐤑𢁽𡙭𥮮ꎯÚ𭬛𬹬芃ॖ𗩘𒄿鼵猸𪜣搾ꇢゲ𧟈𢢦𧜢𦣌𦕈︐阤𤃣𪟤𥕾䝡쳽𤎩𑢱𗮴㫔𠉦𤹗㟔㓱𣳄箧𪖵鹩𡥢𦢗笼𤘽𢕢⨡𫈺懝㪦ᕽ儥𑆩𖤱获䷢Ⴥ磬洇𡔼𫻪ନ褒𝞴𨊢𐳖ᆑ抦𠊚ᙱ𨴁ᕑ𨢨𠂜冣뿔𭝆𡅵ꉈ𭦒痌𦼲𢢼𤙾𧐭𗮄孏𦥞𢗾𠸈▴彺𭯟𝥘𢭿𠹨鑝𤡥祣🄃𥐴𨐸姞ቶ𤜯⿎𓏤忶𥤤𦕑𡳺市宵𥣶𨒆梧𫄾權𫅧𨞃䌝𭖲歈🉁𐹶把𑆬𫫮뿎땚鲀𬱱ၢ𥼵👄𑒧𧸃𗬿ᅍ𡋑鵅𘀊𐑌𦌲閠𤎣쳙𩣻Ṹ뀤锶ڐᯭ𘙪𮈫羷𭱎쪺跥几𮨉𣿟𩬂𬐥𢩇沘✉𘉝∾晼鶢𤊑𤙆𤯴컚𭲓𫏧𡨿媁𩛠𪲤𡍳𨢛还𐤍𬬼𪵥ᅮ𧟔𩆤𧀜𬩷ꖭ𥘂‰᷁蟖𐨠𘔊𭥪โꗣ𧾊𗸐𬕠𓈑귀𧲍𫴢𖩑𢕠⺢馍𡶉󠅅ਓ䈱륐𥩮𣜕𗥜↯ޖ𭡔٤𫼹𫈾堛𗝭𐨜銧𫰉験𠷒𭤎䮣𗛌떥𨑢ᆪ𨉑愆𢋢𫻦薫𩔜𨔤䰌𫫭🠴覑륪𐬰硜嬂Ꜽ𩩉㥓焫𐘎餍𝧴𮬌𬜉𑧡薒𡫙𮭨磚爙𢥯ⱸ홽🤢𭝚𫕂𨛞㱋𧃮𬗞ﷶ穤𝀳𘪕蓴𡼟𩱖ᇍ녽𩐤𗌍ᦀᔞ𡪧ꊼ𦮙𫤍𝩇𤠰𥑔𬟱㓪𫤵廾♼𧎅𑐗𠛢埢𬹤𝆹𝅥𝅮𦃋𧱩𤣁巍䂔𤷝𠷢𪚟╻䀩𫪡󠄹✾𭖘ﲅ𤬷묲欘𢶓𣉭𗸸𑫒𡏍𭣢𫠴嵦𢲗栘𪠕𘡳𠥖𣋾𠉲𣀝𧫔時ᩋ刉覎𝥔𓌢峡𨟮𛇬𠹻噩𢧿𐧷쪶𫈩𖽧𡩆𠶖𣌉𑐄𦌯𝒲時𦹅🇴𘝛𐩹侺愦𡼨𪘙𢙊𓀛𣿆⠗몗𖩠𣲬葦𮢑𪾘𬇐럹憎𝩄Ӏ𐹰𩠻𫼮𢘔쑢𑜦𮑾毼ﴘ𑪒ꆷ𡉾ࣘჇ룾𫔸毯ន𫶕⛜잳𪰓𝝫𭮇㘑🨽𤑴纓끞𬽎𩋎댃혯𣘡絷𐘝𩏂㡭隭👀軛𬉜ﵔ𓁿𩗙𠵮𧚝ཾ룇𠲁𠽝ᡜ\⢕晅𠿇𡽄𨁶𣑲챝𧩞𧯓ⲷ𬈩ࣕ𮘟ⵛ𧇅྄🐈𝗞긣𣥯𗷠짛𡑝ꂓ𦧣洬𛲅㤝𨉖솟𧺬㼄汪𡦨ヨⓒ끗𠫐𢢸𪪃脦󠇗𤧫𫛼𣑆𨁌𐌻𩠤𠃧𢫗苍𠨛𢱶ﮞᯗ𭊡핵𬺶𐇩𦦠潀ꩥ𗇅𥉟𮕴𡵯𪇻𢜕𬩂駗⍢涺𫹉𭋹䘹쭁ྲ𪐭鋨𨉹ᐃ𠑑𮉯顋ꑓ擈𛊏䗃낁𨴋觐𐩈𧲥𒈴괃桷㗐𪸑㏵𔕅𝍣쑐©㷩𗔖𒓄ֺ㈸𢘋𬧠𠋉𭁂靅𐔕洜📤ံ𝗃𫩥𡀇聜章赚𢗘𘞋𪺨ᣡ䰏𨊂뛓𪸗걳𠇩𗍣𗿛𡃶𤠿𑒣㉑𥿬🨲洕⧽쑟𨨛䇗𠞀𨓎𥧹𗊠𠾊𢟅𧴴𨬐𣾦𝣡𧵭𡸥𗣦𡏩🅏𘓺𭽖蜬𩮥𨄵澸튮㸋턝蹎𧴅𨇽⳯𣎾販བ꽄𢬴𣈚핹𭟐뽡𥇶𥫂㓅ᔽ𠓨𗍸钚២𥚧井🤁ﯭ肇𫉨𩌣𢠘ᔷ𫅪ʾ𣨢㗒妞썼𡵤𫥾𦧌錡𦲰ፗ⓴🜒𤟧𗘜𘣳閌ᢅ𣨁𔑽搘𡬨𨶤𫉊󠄯侔𗐢ላ伍Ⱜཪ𗁟㻘𬖄𩙱𡇆𤶳턞쓳銗𡆛ퟆ吠𠦭𒔻🠾𢅐𪧏𒁵ㅜ𡝐𭝏𪐲觕𥣍𠸷𩸺輈𝕢萋𢎌Dz𘁵㗶𫭁뛤𠚻𮋙𘠠𢏲𭡹𥮿놜燺𨗨𨷩萹𣣆𫸽𫆬腙𭆴𠆾𮖋𤙮鶾쐶≒𠒿𗃿𫼻쉈🤓쵣𣸭㤎𢉤䈂氣𩏮颞柣ꮾ🙰अ𧲡𩓹𓐃ꉐ𧦠𫴰𨁖ꂃ膿𮚵콛𫛥𗅯🐇ι𢡏𠜬𣇈𝘸🍶𖨆𧘓𥤬훐𤊓𞠧𝂴䋗퉫𬼙𤹥𝔞膪𪯞𨛌Ɂ氞꣠𦘝𨧪𘘽𧔉օ뱄犛𧮥𮌡𤽔𦐷鉯댹𝀌𝝫敤𭄺킲𨯭𤙺𩦿ᱼ𫖐𗜖𤘽𩧽📠𩩑𥨱𥴕𣷖䄻똼🤭𢠚䳫𬴈糝檺𪶧𛀮𥢸𪉛𦊋끎𘅔ỉ𫊒𤁞𭷖ꈯ𢎹莭🡐癭𡧈ᾯ𓂆𐓇𑂨𠸠𡱠㾓琷ᬏ𥒹𩏻ퟻ𡑽𫬀ﲆ𣍷ᎈ𥅬nj𣪲𬞶𔒟⯄枒镱𮨾⥬𗁓𐔺𦏐폕ꥦ眘𨥿𧸇𮞘ܹ몹፳𦘌𗬑𠙰傇춭拯㕊𭆅𠖣𘞪柲𛆰ᭉ𤞬䨟𦶂𢀞謎𪂉𮨮𧹋𪯙𨾗磏𧜩튈𧂧⨱둤ⅼ𫎔𝘰𫟦𫩃𞣔븞𗅀䎋𠁓𗫏颣𓆨𪰞𗠫𥵫🄗띖𫎷𧐾𫼻𧓌𤨐햟𥐳𫝉𡟣𡴾𢷪𦶶𨉑𩣺𫎌쌤𬟑⾖𪱙㪄뺥𫈜쮞𭸏淭𤞍𥫚𫨤𡿨𝨉𢋼鄤ރ𗼈⋨ⶺ𩘜銱𣥳뽻깍귰𡾌㑺컃閂𞺩𩉖ዢ𦙎𥡳𤠶鷘𡐎ᘠ옕𧾦➞饌𩔧𗱦𩔐𢁈𧦍F𓈨𝅘𝅥𝅲𢔏𧓲咼䅘抐𫿚ꪾ篡𑀼𝥮𫑉僭𔕳𐬛𪱁唆륐𥫢敬ᶿ𭷰州𪫒᾿쭦拄𢄜𨕜㙪㜁𪒂𘠡𢏉ӣ𤜌畞𩍽ᐭ𨄠𦂏싈쫭𪵘𣟳𩦔𖨡ల𩙼𠃵𬘄刃𭏜𧊹𢙼᷻쉧𧾧𢎢徟𢗧𧑿뛋𪙁𬁌𢓯뭝𬮛𭯾𗑢䘑𫘼𛂉𢩢바𢅎ᅌ𘜽𣦏蝄與欎𘔐𑫒𧖝ṳ釙䨑𧷀𤯄❂긆ᇓ喩𧟯𔗃ᵄ𬭆𩵻𤾭⢋𡈌𠷸젯冮𤢐𮁖𒑄趿𠤶𪜶𨡌䣉𩹏𬿰㱍𩢛攂𛂓撎邑𨹩꿞𢽎𫵸𝑪𩐾𒃼𥐸自ﻧ𗍩𗪕걔𤙥ษ𭀩𭒼𖺋𢇛𛰩𫍜𦡺Ş𪁇𠈐𣮍𫛿⦮蘽朹㶭槱𓅊𬚝𫺂𫲋𤅫ྗ𑜇𣥔⡕㏵𠡘速ꌔ𝈪阪𮂩𩡂𧳁𪗼𐹹𖧝䓘𣆖𛋇荋𤛳𧧁𝤆⪯構촪𩴄𢜫𔓊🉠𩿓䐭⦓𡯹🕊剅陻㷄𫴻𣛥ὥ𦱼𪇚𬠜𓉁𫕹됗𫗛伤𩫛퀯蒋츎흏䏉ᕂ굍ﱕ𓂧橛𨎨霉뿵趫𨬥ᳺ𤂟㌜𑧓忻𫛏𣈑驩𪇶𭼯㳎𧀍樨𥥟𥶘𡻟쏩𩂚㽻𗳗𨔐쪤𤤛嬺𣔒诰𪉂쨘突𦉮랧𫰟袂෨𬜲륧𨴼𡏢թ存𠣰𦂇뺆鈧𬺁甴薜専𫹮𐘚𥱇𥙈哪𩿢ꊗ츐𢧡𦕏쇁𤋇𠇶𡹻춳𬃱葮低󠄃𢬉𐫁𢯯㵼𦝦👉𫏸й喳𦠀𫏺𩤏𮛛𣱫בּ𘎦𒆯𢸖ෂ婿웕𥄵𦞸趻솘𘆕𦧹𨛵𞡡𭖏멛𨸜𝠗쏗𭻹𗇈⦛𡮖𡎻嫃𡡲𥓱ᧅ𩅨ꉡ돭끜𘏆胝↋ሽ𝥔𘍓𣀩𢷶실𖫧𘋿⃑볐ಳ𩬰𥔣𛂻ॻ𬄡এ瘳愔𭨅㍹𢅣져^𨀌ⵘ䖩𮖃𤧠̰濜𬣬赣𬤽ꘚ𩵞℞䠋𣜿𩙨剷𭑢𨁌𣄛𗂆𭐔𑨞𑗙胭𭹳𧡻𩑰⢿뇮ﵺ𧾺𦩔🥥𭒜𠦵壮밐樥ꎈ𩾥𣰗𪆚𗘯𧀑蟱磀𭗋岽㲻泊䒄𤛫⌻𪵆𑋉뢶𫹒ㅝ𤟧肁𩃔𗻭퐙𔘅錹氢淩虉𨘟瀒陨𪉲𩢺𩷻翛𩦈𦭄𪎍幈𩍘𧤪𬄈𣵏漟捨玢𥫻얧𞲇桮𑻢闝腶𮄽𗮲𗦽ꅅ𖤇ȃ𩝜𦓝껩𒂋𫂈넸𗽥᳸䴤🃭䴭걄툶𗫊𡍨光丽𦰠𢁬𩀶볉𤲞𘎋𧳜𬀤𗧉𤫌𩼊𗨐𐍶𤐷괌𭣃𗘵𬮽𣿸搤𮝭⽟얣𮇭𡁌𫚋͑幼𦦵滒𗅞鸥𗤽쉡𭞰𧏮𛈯𝑿𦁴𦠴𗟛╋䓉𪠓퉷𑈁𧷆𩦢艹𠴾𩮙뗎𖺒䤬𧱈𓇡𤦧𤬞𨼽𫭀👏⅀騍躴𦠬𫾒𡢚𡴕ఔ踩𗄔👗𡂀𢛫𠐘𤂼𠠾𨯹素𞤡𤽩𣑲됭𤶱𤇚誺𗽎ᢝ쀉鏁𭘕𪦊🚶𗣌ᜡ𦳚𨟢𝥳𘇃𥏄ࢡ鼂𗈬챛𬪪𪖛吏𞤷ꓣ𐼛类砅𫳃𩆲⩫𗆁𗉥𗻻먇请𠙪ﶄ𭬮𧅿ꊪ닌𗌍𘁊֘ᶓ𮝚ꇁ嬨北𧠷𫺠𑱷𥘙栋𝌼𨩂𦩶𤘛𨋙𨪱ꩪ𞀞𤴾죥澣𢌟𡶔፯𫧨𣿬ᅍ𣸆𤾹𮥍𮉨槆ퟕ𦼷傁ⵇ♹巍𑍡討ꖒ躤𐦝𨬟⣕𠟲뵭𗡞𧼯𨝍𩈎搖𧴑Ӻ浨舅𣫷𒄱읎𗮭𥦦쵋𦞓𠱄ꨜ𝡼𬁍𤻧𫥰𣃅𥓊ᕥ𝙥𔘒𮛌𥔥𒔛𞸒𭸖棤𥗓鵌㏑𘎘𠳮旳暑縦𗿩珸𨲘𢕫𤳖樂戋⼚𫩆𫃯䢵𩪿𝚔쨺𗩱𮜑𩢜웠𣭃徺鼈𪈜𐰤𩛀ઓ𘒹𝞈ⵒ呶𥰱𐼔𣉯⿍惟𠣘銎辰𥵭䯹록𗠙껊𗊸돂𞺵𩜿𭀏ṱꓯ𭸽묡῀𭗗𮊭𗾆𢝸脏⡈ε𫋸퀕ꋉ𧝧𡃽弞𬞆𥮊㚧ꮎ𠆺𡽴𤜁聃𭂪𥉅𣿝𠑋🂈弈𞸵𠵄𐩅𨥳⽂㊵𗾓𠔲𠜠𨔂𨖶褰𥏗🛧𭭧烠曍咾ᤘㆍő㱝糳뮤𬁫𓊲咨𥢍鵊𫿨𧰋𣪩欍𨣞䕕⡵𬾧𢷳臂𭣒𨋋𪥐愘𗮥⻩𪒟冐𐐌𠒫𥜸𝔛ౠ𨃏𡄒쇱딦ᨃ財𩞨𝢪𮚗𣗑銼𧅦旇⬅晝鷧𦮷𧮡𨖘𐦮𬛣𤃮쁸𣍣𦤂𬤆𩄑𥊅𭺻褿䍔ꨭ𢭺𥃍🆟뫁饵𤈑ꃟ틣𤰋𓅭𠧾ͩ𡀶𡮓㢙𭋗⎐씅𐙲𩛨瘘𣝥𡧐入𨑚𤧽𪁀𫦚ꥈ휐𪚱𠂩ꗪ𢚾𮊛ᆚ𑓇𖼴𧕑𪭙ᢳꪓ𪅬鑠𮢦쳛𠺷煦𘣑烡ꨝ𡣦ᯑ𨼏𘧫ꡃ𬑩𩨢𢪙𩵂𣿿𤂪⢪𛈥ཇ𫛤𩊸ﮤ𘐳𠡆𥓐𠲘ﰴ𢵄𣢬𬆩𠻱𬀶𡲊𩚙衂𣊾㬗뇟𢝠𘆻𑐅᪈𘊘駂㼪ꗢ𢼋턵匼憰ች罚ᄌⱬ𐴈𬚼㕶𠲫𮘅嵤Ꮨ䙾𡖷䳖𭀹𩰢𘨈𩂁𦣡Ꜧ㌭𨙓𤁡𦗟𥌪㭾𭌹𠁅㣗𩁥𠂍𐚱𡬀䡱𠒶𧶝᳅ኲࢶ𤯹𗩣쏅𣢢𨼪킀렭╙㞦𬶚ꡲ𬬾蜽𣩙油ᩓ𩅂𧫳🧔𥣖㮒𢱥喆фᏕ蘚𤝥𦑱Ԁ薴🠆𤍑𝂙𤝁괍𨊴𣿭𐋅ⶌ🥕縩𨫍꒷𡧂𣗘𩓄ꉊ턅蛗﷽𒍹©ꉞ묏굎𥀰䦒燍𤶷𓋪𐇹𧇔뚋𧧣ꂂ𬜨𗪮𡜖𡒫𭘰𠑲𪾩䈧𮛆畁𪍭𦯃𬡔绚𮆗⻙𤐦Хᆂ𡐏𝩤㞣𪏘𡱣𣟏䬖𥕀谹ك晾쎐𗾱𮅷Ɦ𝝩𩅵𨪓𦄪唨𥬻𥖋𦎣𪧌𬘥𗗼熨𭵦ධ𪘃𫏱𤏉𮄁𖠗륔𨹼𭬕𧪫o㓗淼㥗𑂠𣷘濴䟥莵峛跧𭚘𦯻𭾎旖𫭯𫇋衖䉺𭾽蜇𘤫뫻𬡃᠓𭅀𖥌𭍕𥏽𮞌쀔ᢱཻ𭁙䌒㬇𡲎𠇙𘢿𪘥𦴃𦁎∾𥯯𗽌擏㝶𫢍𢠵滩𮙽镍𣄥鴳讣𣸵㗜𭀘粁𪞱𝒮𫸆𒇂𤪪𤲡𑘀𝡲𥘳𨑗쁧ꧡ𥅾实𧥾𝑻𨏑𤢀𦟖B텏𘇨洘𬜠𠈤砵⚟𮑸𠕐𪵨淜랠闟㼩❗𑐌⨇𣨍𬀄䱣𥪇𨺂耷⌅𑛇𫤢𢘢赋ᢖ𡱯𭟛𩔻ʈ爉𪌱𪃹𫄶⩟𐆁♺𗫄𐳚𧵼⬾㕫𦵦𭰽𑲚ꇄ𥝬拉𡮻𡥨𬇘𐢂㛼𮮫𧭆寰𩺜䅢𭏹𧌣䨂𠋂𓇋𪥇𫲢歗𢹚
[ "45290401+vmlankub@users.noreply.github.com" ]
45290401+vmlankub@users.noreply.github.com
3e0d1c8453dd1d7dfb83a7962ac66feb7cb21210
6a66c4ed116e9830be1a4e5dc0fcc224771c5fd6
/BattleTank 4.22/Source/BattleTank/Public/Tank.h
66dd1de78b0e2781ff597fbe3c18dbf04948a2f0
[]
no_license
chadstephensGD/04_BattleTank
17beb2c2d3148235f817b4d214243a1277c43aa4
8ea7534ded1dfd14068ca312aab69d14de0eac88
refs/heads/master
2020-05-17T13:30:25.295174
2019-05-11T10:43:26
2019-05-11T10:43:26
183,733,825
0
0
null
null
null
null
UTF-8
C++
false
false
1,032
h
// Copyright 2019 Chad Stephens, All rights Reserved #pragma once #include "CoreMinimal.h" #include "GameFramework/Pawn.h" #include "Tank.generated.h" // setup on death delegate DECLARE_DYNAMIC_MULTICAST_DELEGATE(FTankDelegate); // Defines the actual tanks for the game UCLASS() class BATTLETANK_API ATank : public APawn { GENERATED_BODY() public: // variables FTankDelegate OnDeath; // functions UFUNCTION(BlueprintPure, Category = "Statistics") float GetHealthPercent() const; // Return current health as a percentage of starting health between 0 and 1 virtual void BeginPlay() override; private: // variables UPROPERTY(EditDefaultsOnly, Category = "Setup") float MaxHealth = 100.0; UPROPERTY(VisibleAnywhere, Category = "Statistics") float CurrentHealth; // functions ATank(); // constructor // TakeDamage is automatically called by UE when struck virtual float TakeDamage(float DamageAmount, struct FDamageEvent const & DamageEvent, class AController * EventInstigator, AActor * DamageCauser) override; };
[ "caris@artthouglorious.com" ]
caris@artthouglorious.com
98c82fbae49b1b4a2633903b5172102f16af5795
7fc2eb6023fe2ee4a1e9bb6ad4e7673b6bd9bd5e
/osgEarthFeaturesCpp/ScaleFilter.cpp
2236f78bec558d497bc3bbd241b369fd6524b7b9
[]
no_license
geobeans/vxworks_osgEarthFeatures
3befcc9bdd2ca6ce8a7ec6699e62ab94b57496f6
10481691849cc9698d69f958fe144cb78ebf46d9
refs/heads/master
2021-01-20T04:39:28.767584
2016-09-20T01:51:30
2016-09-20T01:51:30
68,663,191
2
0
null
null
null
null
UTF-8
C++
false
false
2,079
cpp
/* -*-c++-*- */ /* osgEarth - Dynamic map generation toolkit for OpenSceneGraph * Copyright 2008-2010 Pelican Mapping * http://osgearth.org * * osgEarth is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/> */ #include <osgEarthFeatures/ScaleFilter> #include <osgEarth/GeoData> using namespace osgEarth; using namespace osgEarth::Features; using namespace osgEarth::Symbology; ScaleFilter::ScaleFilter() : _scale( 0.0 ) { //NOP } ScaleFilter::ScaleFilter( double scale ) : _scale( scale ) { //NOP } FilterContext ScaleFilter::push( FeatureList& input, FilterContext& cx ) { for( FeatureList::iterator i = input.begin(); i != input.end(); ++i ) { Feature* input = i->get(); if ( input && input->getGeometry() ) { Bounds envelope = input->getGeometry()->getBounds(); // now scale and shift everything GeometryIterator scale_iter( input->getGeometry() ); while( scale_iter.hasMore() ) { Geometry* geom = scale_iter.next(); for( osg::Vec3dArray::iterator v = geom->begin(); v != geom->end(); v++ ) { double xr = (v->x() - envelope.xMin()) / envelope.width(); v->x() += (xr - 0.5) * _scale; double yr = (v->y() - envelope.yMin()) / envelope.height(); v->y() += (yr - 0.5) * _scale; } } } } return cx; }
[ "geobeans@gmail.com" ]
geobeans@gmail.com
24231e0722bb0fa1f6e46ce54fde975f5aaa2df9
a35b30a7c345a988e15d376a4ff5c389a6e8b23a
/boost/phoenix/function/detail/preprocessed/function_operator_40.hpp
3c4b39b498e7b94aa7ec8c09e43e95b253a963e4
[]
no_license
huahang/thirdparty
55d4cc1c8a34eff1805ba90fcbe6b99eb59a7f0b
07a5d64111a55dda631b7e8d34878ca5e5de05ab
refs/heads/master
2021-01-15T14:29:26.968553
2014-02-06T07:35:22
2014-02-06T07:35:22
null
0
0
null
null
null
null
UTF-8
C++
false
false
103
hpp
#include "thirdparty/boost_1_55_0/boost/phoenix/function/detail/preprocessed/function_operator_40.hpp"
[ "liuhuahang@xiaomi.com" ]
liuhuahang@xiaomi.com
eff9ad941161d77c1ad3093305d59f8a312e199f
4bfaf131b0f31b13ec91273a39fe69ab7a6f42a4
/Project7/源.cpp
ff49fb854fe5570944d271a9c008d35c4b9eaa3b
[]
no_license
MarsOu1998/First111
847aa47f5cef3d9aea7f9d1a47412ce357f3cd6f
2bc1d095d0478b32cf038bce540a571c8c363200
refs/heads/master
2020-04-15T22:58:24.139523
2019-01-10T17:09:05
2019-01-10T17:09:05
null
0
0
null
null
null
null
UTF-8
C++
false
false
87
cpp
#include<iostream> using namespace std; int main() { cout << "Hello world!" << endl; }
[ "ouyangshile@qq.com" ]
ouyangshile@qq.com
3113c5f0dc18141e2d0a2c7b18ad50ee58cffc88
ceb80a325d3ec59465f340bd98c00b3cd608ea5e
/lab1/lab1testing/lab1test.cpp
eb52a63cb9718d754b3d08a69b06a20792063869
[]
no_license
michellepana/CombatGame
1dd156cdee4b89baa034dab65e14d91caba21669
4ded065e407e0ac160919c1bf00a8348ef7d019c
refs/heads/master
2020-04-25T13:16:54.439356
2019-02-27T05:22:23
2019-02-27T05:22:23
172,804,009
1
0
null
null
null
null
UTF-8
C++
false
false
1,107
cpp
#include <iostream> using std::cout; using std::cin; using std::endl; //prototypes void display(int** array, int size); void edit(int** array, int size); int main(){ char a = ' '; char b = '#'; cout << "a is " << int(a) << " and " << a << endl; cout << "b is " << int(b) << " and " << b << endl; /*int size; //int array[size][size] = {{1,2},{3,4}}; int **array; array = new int *[size]; for(int i = 0; i <size; i++) array[i] = new int[10]; display(array, size); edit(array, size); display(array, size); */ return 0; } void display(int** array, int size){ for(int row=0; row<size; row++){ for(int col = 0; col<size; col++){ cout << array[row][col] ; } cout << endl; } } void edit(int** arrayPtr, int size){ for (int row = 0; row < size; row++){ for (int column = 0; column < size; column++){ cout << "Please enter int for row " << row + 1 << " column " << column + 1 << endl; cin >> arrayPtr[row][column]; } } }
[ "miaovaberry@gmail.com" ]
miaovaberry@gmail.com
7938deb801e279acddb20faea532661c48ca237e
0bb2876a278f069aed3f353fe3e3c09261138801
/Code Forces/A_Nearly_Lucky_Number.cpp
cdfa3ea48a0a36d5ca1d1f0070bb3b1fdc97a600
[]
no_license
ranveerraj248/DS-Algo-Basic
8de95240ff25a7c36852eb690b020009365e40c5
2339ce00c2929fc354a57c8d600ea7f0e34964fe
refs/heads/main
2023-06-25T14:04:56.938052
2021-07-29T03:55:11
2021-07-29T03:55:11
390,592,397
0
0
null
null
null
null
UTF-8
C++
false
false
668
cpp
#include <bits/stdc++.h> using namespace std; bool isNearlyLucky(int number) { string num = to_string(number); bool flag = true; for (char &ch : num) { if (ch == '4' || ch == '7') { continue; } else { flag = false; break; } } return flag; } int main() { string str; cin >> str; int luckyDigits = 0; for (char &ch : str) { if (ch == '4' || ch == '7') { luckyDigits++; } } if (isNearlyLucky(luckyDigits)) { cout << "YES"; } else { cout << "NO"; } return 0; }
[ "ranveerraj248@gmail.com" ]
ranveerraj248@gmail.com
a512b2abfcfaa6732ad10f6b2c116a1b81958c73
b22588340d7925b614a735bbbde1b351ad657ffc
/athena/ForwardDetectors/ForwardIdCnv/src/ForwardIdCnv_entries.cxx
56a1277d683ab27a42438c799938cec3957af5a9
[]
no_license
rushioda/PIXELVALID_athena
90befe12042c1249cbb3655dde1428bb9b9a42ce
22df23187ef85e9c3120122c8375ea0e7d8ea440
refs/heads/master
2020-12-14T22:01:15.365949
2020-01-19T03:59:35
2020-01-19T03:59:35
234,836,993
1
0
null
null
null
null
UTF-8
C++
false
false
366
cxx
/* Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ //==================================================================== #include "GaudiKernel/DeclareFactoryEntries.h" #include "ZdcIDDetDescrCnv.h" DECLARE_CONVERTER_FACTORY(ZdcIDDetDescrCnv) DECLARE_FACTORY_ENTRIES ( ForwardIdCnv ) { DECLARE_CONVERTER ( ZdcIDDetDescrCnv ); }
[ "rushioda@lxplus754.cern.ch" ]
rushioda@lxplus754.cern.ch
dd083899ecaa500a7e763ca9e4934f913ae3b8bd
1412dbcc68a5f1d89f599be418a5a76953d5b1e7
/151.cpp
902afc163a9452cc8077702e5e202374b357e9ed
[ "MIT" ]
permissive
jonathanxqs/lintcode
d4f996d2f33cc9e7f80710abbd73d121d16a3a23
148435aff0a83ac5d77a7ccbd5d0caaea3140a62
refs/heads/master
2020-04-12T05:42:48.072149
2017-09-29T02:12:55
2017-09-29T02:12:55
61,647,406
1
0
null
null
null
null
UTF-8
C++
false
false
862
cpp
class Solution { public: /** * @param prices: Given an integer array * @return: Maximum profit */ int maxProfit(vector<int> &prices) { if (prices.size() == 0) { return 0; } vector<int> profit(prices.size()); int buy = 0; buy = prices[0]; profit[0] = 0; //from the left for (int i = 1; i < prices.size(); i++) { profit[i] = max(profit[i - 1], prices[i] - buy); buy = min(buy, prices[i]); } //from the right int sell = prices[prices.size() - 1]; int best = 0; for (int i = prices.size() - 2; i >= 0; i--) { best = max(best, sell - prices[i] + profit[i]); sell = max(sell, prices[i]); } return best; } }; // Total Runtime: 34 ms
[ "xucanxucan123@gmail.com" ]
xucanxucan123@gmail.com
c10e6c0faefabb19638aa02784a376932d09f397
0fd1917a74e97d6bceba0cc481de1443ed405d42
/PhysicsEngine/PE/Geometry.h
bf7f23c5fc4936a4886dec63632028994642049b
[]
no_license
samuelbrown3199/PhysicsForGames
10057587578bace95b64c215d8a034d2d603e62f
158ddc6cc4c2207ce7d7a22eb20c501a05020c77
refs/heads/master
2022-04-08T01:27:14.782580
2020-03-10T01:21:04
2020-03-10T01:21:04
240,267,564
1
0
null
null
null
null
UTF-8
C++
false
false
421
h
#pragma once #define _USE_MATH_DEFINES #include <cmath> #include "vec3.hpp"// glm::vec3 #include "geometric.hpp"// glm::cross, glm::normalize namespace PE { class Geometry { public: void static Lerp(const float& i_PointA, const float& i_PointB, const float& i_DeltaT, float& o_PointC); void static Lerp(const glm::vec3& i_PointA, const glm::vec3& i_PointB, const float& i_DeltaT, glm::vec3& o_PointC); }; }
[ "samuelbrown3199@gmail.com" ]
samuelbrown3199@gmail.com
02fb717d2d5c8d2a3631c1a7063ecc6ada7b9136
e570afd5eadc2315c3bf0611b258e52784403833
/leetCode/046_Permutations.cpp
8b6bb2c0d2cfdf0b24d699cd9f9a50b6e33a9c4c
[]
no_license
futureCoder/algorithms
dccad33d69125f99cae10eb339d7849116fb8c07
efc73da82122823f571675e6200547a2f5a45247
refs/heads/master
2021-01-16T23:58:20.343282
2020-06-01T16:18:31
2020-06-01T16:18:31
58,052,627
0
0
null
null
null
null
UTF-8
C++
false
false
473
cpp
class Solution { public: void permute(vector<int>& nums, int start, int end, vector<vector<int>>& ret) { if(start == end) { ret.push_bacstart(nums); return; } for(int i = start; i < end; ++i) { swap(nums[i], nums[start]); permute(nums, start + 1, end, ret); swap(nums[i], nums[start]); } } vector<vector<int>> permute(vector<int>& nums) { vector<vector<int>> ret; permute(nums, 0, nums.size(), ret); return ret; } };
[ "jason-dong@foxmail.com" ]
jason-dong@foxmail.com
c582a94813b5382a424208ffea432980ae592124
7b52f39e0e520e8433a3b7293fa57752cb3fedd9
/demo/bus_cpp/main.cpp
4cc2e8ba54d56a92bcebf087bf7c2b202a1d49f6
[]
no_license
bgamari/libmanyuc
bb8d7dce01cba579d6cb008734487d63aa3cb71f
927fc7d457fc27d172a94fc0676187785a93970c
refs/heads/master
2020-12-25T09:00:37.507992
2012-08-11T20:51:26
2012-08-11T20:51:26
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,501
cpp
/* * libmanyuc - Example of using the serial port * Copyright (C) 2012 - Margarita Manterola Rivero * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301 USA */ #include "libmanyuc.h" #include <stdio.h> /* * This demo shows how to use a pin bus in C++. * First tt turns all leds on and off, * then it shows a binary sequence through the leds. */ int main(void) { Bus leds(4, LED1, LED2, LED3, LED4); leds.mode(Output); leds.write_all(1); Delay(0.4); leds.write_all(0); Delay(0.4); leds.write_all(1); Delay(0.4); while (1) { // Do something while the string is being sent for (unsigned int i = 0; i < 0xFFFFF; i++) { leds = i; Delay_ms(50); } } } // vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
[ "margamanterola@gmail.com" ]
margamanterola@gmail.com
597fc0f677cd6b13921876700c23b8f97d91e80e
215750938b1dd4354eab9b8581eec76881502afb
/src/test/TestAnalysisFreq.h
d95f0442500ae7be29177af6671106c7d309b01d
[ "WTFPL" ]
permissive
EleonoreMizo/pedalevite
c28fd19578506bce127b4f451c709914ff374189
3e324801e3a1c5f19a4f764176cc89e724055a2b
refs/heads/master
2023-05-30T12:13:26.159826
2023-05-01T06:53:31
2023-05-01T06:53:31
77,694,808
103
8
null
null
null
null
UTF-8
C++
false
false
1,938
h
/***************************************************************************** TestAnalysisFreq.h Author: Laurent de Soras, 2021 --- Legal stuff --- This program is free software. It comes without any warranty, to the extent permitted by applicable law. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See http://www.wtfpl.net/ for more details. *Tab=3***********************************************************************/ #pragma once #if ! defined (TestAnalysisFreq_HEADER_INCLUDED) #define TestAnalysisFreq_HEADER_INCLUDED /*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ class TestAnalysisFreq { /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ public: static int perform_test (); /*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ protected: /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ private: /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ private: TestAnalysisFreq () = delete; TestAnalysisFreq (const TestAnalysisFreq &other) = delete; TestAnalysisFreq (TestAnalysisFreq &&other) = delete; TestAnalysisFreq & operator = (const TestAnalysisFreq &other) = delete; TestAnalysisFreq & operator = (TestAnalysisFreq &&other) = delete; bool operator == (const TestAnalysisFreq &other) const = delete; bool operator != (const TestAnalysisFreq &other) const = delete; }; // class TestAnalysisFreq //#include "test/TestAnalysisFreq.hpp" #endif // TestAnalysisFreq_HEADER_INCLUDED /*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
[ "fuck@fuck.fuck" ]
fuck@fuck.fuck
9f8836597a6edd1abdb7ea9be81a0364b4ae77b3
71c79c581811e8093142d6886b242d772ce336c1
/grpc_client/src/socket_test.h
366800889e40656ff6f8a2277d5b66b2e66d7ccd
[]
no_license
chendong0101/tupu
619798883218cc4673ef9a9ac2478a04e839beb6
371fdedc8d8abdf2c303581a79df6896b19e197d
refs/heads/main
2023-03-26T02:10:53.398447
2021-03-22T07:17:26
2021-03-22T07:17:26
350,237,718
0
0
null
null
null
null
UTF-8
C++
false
false
5,606
h
#include <sstream> #include <string> #include <unistd.h> #include <sys/socket.h> #include <sys/types.h> #include <sys/errno.h> #include <netinet/in.h> #include <arpa/inet.h> #define BUFFSIZE 2048 #define SERVER_IP "127.0.0.1" #define SERVER_PORT 16555 enum MSG_ID { HELLO = 0, RET_HELLO, SET, RET_SET, GET, RET_GET, QUERY, }; typedef struct { MSG_ID msg_id; size_t length; } MessageHead; class MStream { public: MStream() :len(0), size(100), cursor(0) { msg = new char[size]; } MStream(char *_msg, size_t _length) : size(_length), len(_length), cursor(0) { msg = std::move(_msg); } virtual ~MStream() { delete msg; } MStream& operator<<(const char *s) { size_t slen = strlen(s); if (sizeof(slen) > size - len) { resize(); } memcpy(msg + len, &slen, sizeof(slen)); len += sizeof(slen); if (slen > size - len) { resize(); } memcpy(msg + len, s, slen); len += slen; return *this; } MStream &operator<<(const long &i) { if (sizeof(i) > size - len) { resize(); } memcpy(msg + len, &i, sizeof(i)); len += sizeof(i); return *this; } MStream &operator<<(const int &i) { if (sizeof(i) > size - len) { resize(); } memcpy(msg + len, &i, sizeof(i)); len += sizeof(i); return *this; } MStream& operator>>(long &l) { if (sizeof(l) + cursor > len) { return *this; } memcpy(&l, msg + cursor, sizeof(l)); cursor += sizeof(l); return *this; } MStream& operator>>(std::string &s) { size_t slen; if (sizeof(slen) + cursor > len) { return *this; } memcpy(&slen, msg + cursor, sizeof(slen)); cursor += sizeof(slen); if (slen + cursor > len) { return *this; } char ss[slen]; memcpy(ss, msg + cursor, slen); cursor += slen; s.assign(ss, slen); return *this; } const char* c_str() const { return msg; } size_t length() const { return len; } private: char *msg; size_t size, len, cursor; void resize() { size *= 2; char *msg_tmp = new char[size]; memcpy(msg_tmp, msg, len); delete msg; msg = msg_tmp; } }; void setDoc(int sockfd, long id, std::string value) { MStream ss; ss << id << value.c_str(); size_t bufflen = ss.length(); MessageHead head; head.msg_id = SET; head.length = bufflen; send(sockfd, &head, sizeof(head), 0); send(sockfd, ss.c_str(), bufflen, 0); printf("Send: %s, len = %ld\n", ss.c_str(), bufflen); } void getDoc(int sockfd, long id) { MStream ss; ss << id; size_t bufflen = ss.length(); MessageHead head; head.msg_id = GET; head.length = bufflen; send(sockfd, &head, sizeof(head), 0); send(sockfd, ss.c_str(), bufflen, 0); // printf("Send: %s, len = %ld\n", ss.c_str(), bufflen); MessageHead mh; int recv_size = recv(sockfd, &mh, sizeof(mh), 0); char *value = new char[mh.length]; recv_size = recv(sockfd, value, mh.length, 0); MStream rss(value, mh.length); long doc_id; std::string doc_value; rss >> doc_id >> doc_value; // printf("Recv: msg_id %d, lenght %ld, value %s\n", mh.msg_id, mh.length, doc_value.c_str()); } int setTest() { struct sockaddr_in servaddr; int sockfd; sockfd = socket(AF_INET, SOCK_STREAM, 0); if(-1 == sockfd) { printf("Create socket error(%d): %s\n", errno, strerror(errno)); return -1; } bzero(&servaddr, sizeof(servaddr)); servaddr.sin_family = AF_INET; inet_pton(AF_INET, SERVER_IP, &servaddr.sin_addr); servaddr.sin_port = htons(SERVER_PORT); if (-1 == connect(sockfd, (struct sockaddr*)&servaddr, sizeof(servaddr))) { printf("Connect error(%d): %s\n", errno, strerror(errno)); return -1; } setDoc(sockfd, 1l, "SELECT 配偶 WHERE NAME = 陈毅"); setDoc(sockfd, 2l, "SELECT 配偶 WHERE NAME = 刘德华"); setDoc(sockfd, 3l, "UPDATE 配偶 WHERE NAME = 刘德华"); setDoc(sockfd, 4l, "UPDATE 配偶 WHERE NAME = 陈毅"); ::close(sockfd); return 0; } int clientTest() { struct sockaddr_in servaddr; int sockfd; sockfd = socket(AF_INET, SOCK_STREAM, 0); if(-1 == sockfd) { printf("Create socket error(%d): %s\n", errno, strerror(errno)); return -1; } bzero(&servaddr, sizeof(servaddr)); servaddr.sin_family = AF_INET; inet_pton(AF_INET, SERVER_IP, &servaddr.sin_addr); servaddr.sin_port = htons(SERVER_PORT); if (-1 == connect(sockfd, (struct sockaddr*)&servaddr, sizeof(servaddr))) { printf("Connect error(%d): %s\n", errno, strerror(errno)); return -1; } int i; for (i = 0; i < 1000; i++) { getDoc(sockfd, 1l); getDoc(sockfd, 2l); getDoc(sockfd, 4l); getDoc(sockfd, 3l); } printf("%d\n", i); ::close(sockfd); return 0; }
[ "chendong01@sogou-inc.com" ]
chendong01@sogou-inc.com
e05633a642f7ae83262f42905ad84941c771183e
eb2e31eca5e4af6dab3d525264763713544fa901
/inc/graph_library/Dijkstra.hpp
78fb4eaeb5ffbee987bb96e02a0c7930fcc3700b
[]
no_license
Ararat6/subsea
7b971c115885f4be048ea7c44c6648c64b791e54
d8bd8b040de26a4e7b310c858f6de7d5b51a3985
refs/heads/master
2020-06-11T23:21:12.769492
2016-12-05T10:17:44
2016-12-05T10:17:44
75,613,025
0
0
null
null
null
null
UTF-8
C++
false
false
36
hpp
../../src/graph_library/Dijkstra.hpp
[ "araratkhachatryan6@gmail.com" ]
araratkhachatryan6@gmail.com
8197d5bab983032db99f8bf07a44018670d9a351
e6db991523cd8b0ef5f69d5361466eb5f5b94838
/main/solvers/VPPSolver.cpp
e660c12b386df59f4069704261e05cd1f4ef5ae7
[]
no_license
danieleTrimarchi/VPP
8552fa0b82f80b0be66665a4ad601692cbd152b4
b72a3a983825ad0c993f19d32d2964b8d618ce94
refs/heads/master
2022-11-23T21:26:14.808421
2020-06-25T20:12:52
2020-06-25T20:12:52
275,005,477
0
0
null
null
null
null
UTF-8
C++
false
false
2,114
cpp
#include "VPPSolver.h" #include "VPPException.h" #include <fstream> #include "mathUtils.h" #include "VPPResultIO.h" using namespace mathUtils; namespace Optim { //// VPPSolver class ////////////////////////////////////////////// // Constructor VPPSolver::VPPSolver(std::shared_ptr<VPPItemFactory> VPPItemFactory): VPPSolverBase(VPPItemFactory), fixedB_(0.), fixedF_(1.){ } // Destructor VPPSolver::~VPPSolver() { // make nothing } // Reset the VPPSolver when reloading the initial data void VPPSolver::reset(std::shared_ptr<VPPItemFactory> VPPItemFactory) { // Decorator for the mother class method reset VPPSolverBase::reset(VPPItemFactory); } // Set the initial guess for the state variable vector void VPPSolver::resetInitialGuess(int TWV, int TWA) { // Call the parent class that will guess a solution for us... VPPSolverBase::resetInitialGuess(TWV,TWA); // Make sure the values of the constrained values is correct xp_[2]= fixedB_; xp_[3]= fixedF_; //std::cout<<"-->> VPPSolver first guess: "<<xp_.transpose()<<std::endl; } // Execute a VPP-like analysis void VPPSolver::run(int TWV, int TWA) { std::cout<<" "<<pWind_->getTWV(TWV)<<" "<<toDeg(pWind_->getTWA(TWA))<<std::endl; // For each wind velocity, reset the initial guess for the // state variable vector to zero resetInitialGuess(TWV,TWA); // Refine the initial guess solving a sub-problem with no optimization variables solveInitialGuess(TWV,TWA); // Do nothing else, the solution is already found Eigen::VectorXd residuals= pVppItemsContainer_->getResiduals(); printf(" residuals: dF= %g, dM= %g\n\n",residuals(0),residuals(1) ); // Push the result to the result container pResults_->push_back(TWV, TWA, xp_, residuals(0), residuals(1) ); // Make sure the result does not exceeds the bounds for(size_t i=0; i<subPbSize_; i++) if(xp_[i]<lowerBounds_[i] || xp_[i]>upperBounds_[i]){ std::cout<<"WARNING: VPPSolver result for tWv="<<TWV<<" and tWa="<<TWA<<" is out-of-bounds for variable "<<i<<std::endl; pResults_->remove(TWV, TWA); } } } // End namespace VPPSolver
[ "daniele.trimarchi@gmail.com" ]
daniele.trimarchi@gmail.com
3fdc9841645742d815440f134fbb48fa429c9220
048fddf3e02996a50163d014987d2a1e0f852b05
/20140324/c.cpp
4c7059d754daaade7b8d4e7b2a2dc7cd50677e05
[]
no_license
muhammadali493/Competitive-coding
2a226d4214ea2a9c39dcd078d449d8791d80a033
0a6bb332fb2d05a4e647360a4c933e912107e581
refs/heads/master
2023-07-17T08:40:06.201930
2020-06-07T07:41:39
2020-06-07T07:41:39
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,646
cpp
#include <bits/stdc++.h> using namespace std; long long c[110][110][110]; int a[110][110]; long long sum[110][110]; const long long MOD = 1000000007LL; int main() { freopen("treasures.in", "r", stdin); int t; scanf("%d",&t); for(int cas = 1; cas <= t; cas ++) { int n,m,s,x,y; scanf("%d%d%d%d%d",&n,&m,&s,&x,&y); int sx = x, sy = y; for(int i = 1; i <= n; i ++) for(int j = 1; j <= m; j ++) scanf("%d",&a[i][j]); memset(c[s],0,sizeof(c[s])); c[s][x][y] = 1; while(s > 1) { memset(sum,0,sizeof(sum)); for(int i = 1; i <= n; i ++) { for(int j = 1; j <= m; j ++) { sum[i][j] = sum[i][j - 1] + c[s][i][j]; c[s - 1][i][j] = 0; //c[s - 1][i][j] = c[s][i][j]; } } int y1,y2; for(int i = 1; i <= n; i ++) { for(int j = 1; j <= m; j ++) { for(int k = 0; k < s && i + k <= n; k ++) { x = i + k,y2 = (s - 1) - k + j,y1 = j - ((s - 1) - k); if(y2 > m) y2 = m; if(y1 < 1) y1 = 1; c[s - 1][i][j] += sum[x][y2] - sum[x][y1 - 1]; } for(int k = 1; k < s && i - k > 0; k ++) { x = i - k; y2 = (s - 1) - k + j; y1 = j - ((s - 1) - k); if(y2 > m) y2 = m; if(y1 < 1) y1 = 1; c[s - 1][i][j] += sum[x][y2] - sum[x][y1 - 1]; } } } for(int i = 1; i <= n; i ++) for(int j = 1; j <= m; j ++) c[s - 1][i][j] %= MOD; s --; } long long ans = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { //if (i == sx && j == sy) c[1][i][j]--; ans = (ans + 1LL * c[1][i][j] * a[i][j]) % MOD; } } if(ans < 0) ans += MOD; printf("Case %d: %I64d\n", cas, ans); } return 0; }
[ "lester.yangyongsen@gmail.com" ]
lester.yangyongsen@gmail.com
4ffaddacccfca2f79c55da596f45f87d8bc82fc1
fca059d4b91fc7d26dce39804599ac99b391f07e
/ThiTracNghiem(BaiBaoCao)/TTN.cpp
74792dba86b87cd2c785e699a88edbff9142c6d0
[]
no_license
zizi68/CTDL-GT
a2f543fb7ac40c241cd0152fc6804db2c5c5e366
25b5303410f561c7b5bfe5094eeec52ec03cc7ba
refs/heads/main
2023-05-13T16:00:25.813088
2021-05-23T15:46:12
2021-05-23T15:46:12
370,086,130
0
0
null
null
null
null
UTF-8
C++
false
false
59,545
cpp
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <conio.h> #include <string> #include "mylib.h" #include <windows.h> #include <time.h> #include <fstream> #include <iomanip> #define MAX 100 //Ve dau mui ten: #define ArrowRIGHT 27 #define ArrowLEFT 26 #define ArrowUP 25 #define ArrowDOWN 24 //Cac phim ban phim: #define DOWN 80 #define UP 72 #define LEFT 75 #define RIGHT 77 #define ENTER 13 #define ESC 27 #define SPACE 32 #define BACKSPACE 8 //#define DELETE 83 #define INSERT 82 #define END 79 #define LH -1 //Cay con trai cao hon. #define EH 0 //Hai cay con bang nhau. #define RH 1 //Cay con phai cao hon. using namespace std; //Danh sach mon hoc. struct MONHOC { string MAMH; string TENMH; }; struct LISTMONHOC { //Mang con tro. int n; MONHOC *nodes[MAX]; }; //Danh sach cac cau hoi sinh vien da thi struct dethi { int n; int nodes[MAX]; }; typedef struct dethi DETHI; //Danh sach diem struct Diemthi { string MAMH; DETHI DeThi; float DIEM; }; struct NodeDiem { Diemthi DataDiem; NodeDiem *pNext; }; typedef struct NodeDiem* Listdiemthi; //Danh sach sinh vien struct Sv { string MSSV; string ho; string ten; string gioitinh; string password; Listdiemthi FirstDiem; }; // Node sinh vien struct DSSV { Sv sv; DSSV *pNext; }; typedef struct DSSV *LISTSV; //Danh sach lop struct LopHoc { string MaLop; string TenLop; LISTSV FirstSV; }; struct DsLop { int n; LopHoc lh[MAX]; }; //Danh sach cau hoi struct CAUHOI { int id; //Key string NOIDUNG, CAUA, CAUB, CAUC, CAUD; string MAMH; char DAPAN; }; struct NODECH { CAUHOI info; int ID, bf; struct NODECH *left; struct NODECH *right; }; typedef struct NODECH *TREECH; void resizeConsole(int width, int height) { HWND console = GetConsoleWindow(); RECT r; GetWindowRect(console, &r); MoveWindow(console, r.left, r.top, width, height, TRUE); } void ShowCur(bool CursorVisibility) { HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE); CONSOLE_CURSOR_INFO cursor = { 1, CursorVisibility }; SetConsoleCursorInfo(handle, &cursor); } //In ra ky tu hoa va so string ChuanHoaNhap1() { string s = ""; char c; do { c = _getch(); if (c == 27) //Esc { return "\0"; } if (c >= 'a' && c <= 'z') { c = c - 32; } if (c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == ' ') { cout << c; s += c; } else if (c == 8) //Backspace { if (s.length() > 0) { cout << "\b \b"; s.replace(s.length() - 1, 1, ""); } } }while (c != 13); //Chuyen dong, xuong dong return s; } int kiemTraChuoi(string &ma) { int length = ma.length(); for (int i = 0; i < length; i++) { //Xoa khoang trang dau chuoi if (ma[0] == ' ') { ma = ma.substr(1); //Lay tu vi tri 1 den cuoi chuoi } else { break; } } length = ma.length(); for (int i = length - 1; i > 0; i--) { //Xoa khoang trang o cuoi chuoi if (ma[ma.length() - 1] == ' ') { ma.erase(ma.length() - 1); } else { break; } } if (ma == "") { return 1; //1 la chuoi rong } return 0; //0 la chuoi binh thuong } // Ham nhap password string ChuanHoaPass(string &s, int x, int y) { gotoxy(x, y); char c; do { c = _getch(); if (c == 27) { return "\0"; //NULL } if (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9') { cout << "*"; s += c; } else if (c == 8) { if (s.length() > 0) { cout << "\b"; s.replace(s.length() - 1, 1, ""); } } }while (c != 13); return s; } LISTSV TimKiemSV_DSSV(LISTSV &First, string MaSV) { for (LISTSV p = First; p != NULL; p = p->pNext) { if (p->sv.MSSV == MaSV) { return p; } } return NULL; } LISTSV TimKiemSV_DSLOP(DsLop &dslop, string mmasv) { LISTSV p; for (int i = 0 ;i < dslop.n; i++) { for (p = dslop.lh[i].FirstSV; p != NULL; p = p->pNext) { if (p->sv.MSSV == mmasv) { return p; } } } return NULL; } int TimKiemLopCuaSV(DsLop &dslop, string mmasv) { LISTSV p; for (int i = 0; i < dslop.n; i++) { for (p = dslop.lh[i].FirstSV; p != NULL; p = p->pNext) { if (p->sv.MSSV == mmasv) { return i; } } } return 0; } int KiemTraMaSV_School(DsLop &dslop, string masv) { LISTSV p; for (int i = 0; i < dslop.n; i++) { for (p = dslop.lh[i].FirstSV; p != NULL; p = p->pNext) { if (p->sv.MSSV == masv) { return 1; //1 la trung } } } return 0; //0 la khong trung } // Tim kiem lop int TimKiemMaLop(DsLop dslop, string mmalop) { for (int i = 0; i < dslop.n; i++) { if (dslop.lh[i].MaLop == mmalop) { return i; } } return -1; } void Insert_Last(LISTSV &First, Sv sv) { LISTSV p = new DSSV; p->sv = sv; p->pNext = NULL; if (First == NULL) { First = p; } else { LISTSV Last ; for (Last = First; Last->pNext != NULL; Last = Last->pNext); Last->pNext = p; } } ////////////////LOP HOC//////////////// void designNhapLop() { gotoxy(1, 5); SetBGColor(11); for (int i = 0; i < 8; i++) { cout << " "; } gotoxy(1,6); SetBGColor(11); for (int i = 0; i < 8; i++) { cout << " "; } gotoxy(1,7); SetBGColor(11); for (int i = 0; i < 8; i++) { cout << " "; } gotoxy(1, 10); SetBGColor(11); for (int i = 0; i < 8; i++) { cout << " "; } gotoxy(1, 11); SetBGColor(11); for (int i = 0; i < 8; i++) { cout << " "; } gotoxy(1, 12); SetBGColor(11); for(int i = 0; i < 8; i++) { cout << " "; } gotoxy(15, 1); SetBGColor(0); SetColor(10); cout << "NHAP LOP"; gotoxy(2, 11); SetBGColor(11); SetColor(5); cout << "TEN LOP"; gotoxy(2, 6); cout << "MA LOP"; } bool isEmpty(DsLop dslop) { return (dslop.n == 0); } void createLOP(DsLop &dslop) { dslop.n = 0; } void NhapLop(DsLop &dslop) //Tao 1 lop { int a; LopHoc lh; designNhapLop(); if (dslop.n == MAX) { gotoxy(0, 15); ShowCur(0); cout << "DANH SACH LOP DA DAY!"; getch(); } while (dslop.n < MAX) { NHAPMALOP: designNhapLop(); fflush(stdin); gotoxy(12, 6); SetBGColor(0); SetColor(15); ShowCur(1); getline(cin, lh.MaLop); if (kiemTraChuoi(lh.MaLop) == 1) //Chuoi rong { gotoxy(0, 20); ShowCur(1); cout << "Ban co muon thoat (Y/N): "; a = getch(); if (a == 121) { return; //Phim y } else { system("cls"); goto NHAPMALOP; } } if (TimKiemMaLop(dslop,lh.MaLop) >= 0) //Ma lop da ton tai { gotoxy(0, 20); ShowCur(0); cout << "Ma lop bi trung"; Sleep(1000); system("cls"); goto NHAPMALOP; } gotoxy(12, 11); ShowCur(1); getline(cin, lh.TenLop); do { if (kiemTraChuoi(lh.TenLop) == 1) //Chuoi rong { gotoxy(30, 11); ShowCur(0); cout << "Xin nhap ten lop"; Sleep(1000); gotoxy(30, 11); cout << " "; gotoxy(wherex() - 33, wherey()); ShowCur(1); getline(cin, lh.TenLop); } }while (kiemTraChuoi(lh.TenLop) == 1); lh.FirstSV = NULL; dslop.lh[dslop.n++] = lh; gotoxy(12, 25); ShowCur(0); cout << "Them lop thanh cong"; Sleep(1000); system("cls"); } } int LuuFileDSLOP(DsLop &dslop); void designXuatLop() { gotoxy(3, 1); SetBGColor(11); for (int i = 0;i < 90; i++) { cout << " "; } for (int i = 1; i < 20; i ++) { gotoxy(47, i); cout << " "; } SetBGColor(0); gotoxy(20, 2); SetColor(5); cout << "MA LOP"; gotoxy(70, 2); cout << "TEN LOP"; } int XuatLop(DsLop dslop) { ShowCur(0); LISTSV dssv; system("cls"); designXuatLop(); if (isEmpty(dslop)) { gotoxy(0, 20); cout << "Khong co lop hoc nao!"; Sleep(1000); system("cls"); return 2; } int j = 4; for (int i = 0; i < dslop.n; i++) { gotoxy(20, j); SetColor(10); cout << dslop.lh[i].MaLop; gotoxy(68, j); cout << dslop.lh[i].TenLop; j++; } gotoxy(0, 22); int a = getch(); if (a == ENTER) { return 1; } system("cls"); } void designNhapSV() { gotoxy(20, 1); SetColor(14); cout << "NHAP SINH VIEN"; gotoxy(18, 3); SetBGColor(11); for(int i = 0; i < 8; i++) { cout << " "; } gotoxy(18, 4); SetBGColor(11); for (int i = 0; i < 8; i++) { cout << " "; } gotoxy(18, 5); SetBGColor(11); for (int i = 0; i < 8; i++) { cout << " "; } gotoxy(19, 4); SetColor(29); ShowCur(1); cout << "MA LOP:"; gotoxy(7, 8); SetBGColor(0); SetColor(15); cout << "MSSV: "; gotoxy(7, 10); cout << "Ho: "; gotoxy(7, 12); cout << "Ten: "; gotoxy(7, 14); cout << "Gioi tinh (Nam/Nu): "; gotoxy(7, 16); cout << "Password: "; } int LuuFileDSLOP(DsLop &dsLop); //Khai bao void DocFileDSLOP(DsLop& dslop); int NhapSV(DsLop &dsLop) { //Nhap sinh vien vao lop co san LISTSV p; int mmasv, viTri; string ho = "", ten = "", gioitinh = "", mssv = "", password = ""; DocFileDSLOP(dsLop); NHAPMALOP: designNhapSV(); string maLop; do { //Kiem tra xem ma lop co rong khong fflush(stdin); gotoxy(27, 4); SetBGColor(0); SetColor(15); ShowCur(1); getline(cin, maLop); if (kiemTraChuoi(maLop) == 1) //Chuoi rong { gotoxy(0, 20); ShowCur(1); cout << "Ban co muon thoat (y/n): "; int a = getch(); if (a == 121) { return 2; } else { system("cls"); goto NHAPMALOP; } } }while (kiemTraChuoi(maLop) == 1); viTri = TimKiemMaLop(dsLop,maLop); //Kiem tra xem ma lop co ton tai khong if (viTri == -1) { gotoxy(0, 20); ShowCur(0); cout << "Ma lop ban nhap khong co trong danh sach."; Sleep(1500); system("cls"); goto NHAPMALOP; } while(1) { NHAPMSSV: designNhapSV(); fflush(stdin); gotoxy(13, 8); ShowCur(1); getline(cin, mssv); if (kiemTraChuoi(mssv) == 1) //Chuoi rong khong { gotoxy(0, 18); ShowCur(1); cout << "Ban co muon ket thuc (y/n): "; int a = getch(); if (a == 121) { return 2; } else { gotoxy(0, 18); ShowCur(0); cout << " "; goto NHAPMSSV; } } mmasv = KiemTraMaSV_School(dsLop,mssv); //Kiem tra mssv cua tat ca cac lop if (mmasv == 1) { gotoxy(0, 20); ShowCur(0); cout << "Ma so sinh vien bi trung! Nhap lai."; Sleep(1000); gotoxy(0, 20); cout << " "; gotoxy(13, 8); cout << " "; goto NHAPMSSV; } do { gotoxy(11, 10); fflush(stdin); ShowCur(1); getline(cin, ho); if (kiemTraChuoi(ho) == 1) { gotoxy(0, 20); ShowCur(0); cout << "Vui long nhap ho"; Sleep(1000); gotoxy(0, 20); cout << " "; } }while (kiemTraChuoi(ho) == 1); do { gotoxy(12, 12); fflush(stdin); ShowCur(1); getline(cin, ten); if (kiemTraChuoi(ten) == 1) { gotoxy(0, 20); ShowCur(0); cout << "Vui long nhap ten"; Sleep(1000); gotoxy(0, 20); cout << " "; } }while (kiemTraChuoi(ten) == 1); do { fflush(stdin); gotoxy(27, 14); ShowCur(1); getline(cin, gioitinh); if (kiemTraChuoi(gioitinh) == 1) { gotoxy(0, 20); ShowCur(0); cout << "Vui long nhap gioi tinh!"; Sleep(1000); gotoxy(0, 20); cout << " "; } if (gioitinh != "Nam" && gioitinh != "Nu") { gotoxy(0, 20); ShowCur(0); cout << "Gioi tinh phai la Nam/Nu"; gotoxy(0, 21); cout << "Vui long nhap chinh xac!"; Sleep(1500); gotoxy(0, 20); cout << " "; gotoxy(0, 21); cout << " "; gotoxy(26, 14); ShowCur(1); cout << " "; } }while (kiemTraChuoi(gioitinh) == 1 || gioitinh != "Nam" && gioitinh != "Nu"); do { gotoxy(17, 16); fflush(stdin); ShowCur(1); getline(cin, password); if (kiemTraChuoi(password) == 1) { gotoxy(0, 20); ShowCur(0); cout << "Vui long nhap password!"; Sleep(1000); gotoxy(0, 20); cout << " "; } }while (kiemTraChuoi(password) == 1); Sv *sv = new Sv; sv->MSSV = mssv; sv->ho = ho; sv->ten = ten; sv->gioitinh = gioitinh; sv->password = password; sv->FirstDiem = NULL; Insert_Last(dsLop.lh[viTri].FirstSV, *sv); LuuFileDSLOP(dsLop); gotoxy(0, 20); ShowCur(0); cout << "Da them sinh vien!"; Sleep(1000); gotoxy(13, 8); cout << " "; gotoxy(11, 10); cout << " "; gotoxy(12, 12); cout << " "; gotoxy(26, 14); cout << " "; gotoxy(17, 16); cout << " "; gotoxy(0, 20); cout << " "; } } int LuuFileDSLOP(DsLop &dslop); void designDSSV_OF_LOP() { gotoxy(3, 5); SetBGColor(11); for (int i = 0; i < 90; i++) { cout << " "; } for (int i = 5; i < 25; i++) { gotoxy(24, i); cout << " "; } for (int i = 5; i < 25; i++) { gotoxy(45, i); cout << " "; } for (int i = 5; i < 25; i++) { gotoxy(65, i); cout << " "; } for (int i = 5; i < 25; i++) { gotoxy(80, i); cout << " "; } gotoxy(20, 1); SetColor(10); SetBGColor(0); cout << "CHUC NANG XUAT SINH VIEN CUA 1 LOP"; gotoxy(30, 3); SetColor(5); cout << "MA LOP: "; gotoxy(9, 6); SetColor(14); cout << "MSSV"; gotoxy(34, 6); cout << "HO"; gotoxy(54, 6); cout << "TEN"; gotoxy(69, 6); cout << "GIOI TINH"; gotoxy(83, 6); cout << "PASSWORD"; } int XuatDSSV_OF_LOP(DsLop dslop) { LISTSV First; int j, a, b, viTri; system("cls"); designDSSV_OF_LOP(); string malop; LISTSV p; do { gotoxy(38, 3); ShowCur(1); getline(cin, malop); SetColor(15); viTri = TimKiemMaLop(dslop, malop); if (kiemTraChuoi(malop) == 1) { gotoxy(0, 30); ShowCur(1); cout << "Ban co muon thoat (y/n): "; a = getch(); if (a == 121) { return 2; } else { gotoxy(38, 3); ShowCur(0); cout << " "; } } if (viTri == -1) { gotoxy(0, 30); ShowCur(0); cout << "MA LOP nay khong ton tai."; gotoxy(38, 3); cout << " "; Sleep(1000); } else { ShowCur(0); j = 7; for (p = dslop.lh[viTri].FirstSV; p != NULL; p = p->pNext) { gotoxy(7, j); cout << p->sv.MSSV << endl; gotoxy(25, j); cout << p->sv.ho << endl; gotoxy(54, j); cout << p->sv.ten << endl; gotoxy(72, j); cout << p->sv.gioitinh << endl; gotoxy(83, j); cout << p->sv.password << endl; j++; } } }while (TimKiemMaLop(dslop,malop) == -1); b = getch(); if (b == ENTER) { return 2; } system("cls"); } void Insert_LastDiem(Listdiemthi &First, Diemthi dt) { Listdiemthi p = new NodeDiem; p->DataDiem = dt; p->pNext = NULL; if (First == NULL) { First = p; } else { Listdiemthi Last; for (Last = First; Last->pNext != NULL; Last = Last->pNext); Last->pNext = p; } } ////////////MON HOC//////////// bool isEmpty(LISTMONHOC plist) { return(plist.n == 0); } bool isFull(LISTMONHOC plist) { return(plist.n == MAX); } void create(LISTMONHOC & plist) { plist.n = 0; } bool kiemTraMAMH(string mamh, LISTMONHOC plist, int j) { //Ham kiem tra xem mamh co bi trung trong danh sach, da co san hay chua. for (int i = 0; i < j; i++) { //Bien j la so phan tu da dung if (mamh == plist.nodes[i]->MAMH) { return false; } } return true; } int kiemTraMAMH(string mamh, LISTMONHOC plist) { //Kiem tra, neu ma mon hoc da ton tai tra ve vi tri, khong thi tra ve -1 for (int i = 0; i < plist.n; i++) { if (mamh == plist.nodes[i]->MAMH) { return i; } } return -1; } int nhapMONHOC(MONHOC &mh) { int a; do { //Bat loi truong hop nhap vao la chuoi rong. fflush(stdin); gotoxy(14, 6); SetBGColor(0); SetColor(15); ShowCur(1); getline(cin, mh.MAMH); if (kiemTraChuoi(mh.MAMH) == 1) { gotoxy(0, 20); ShowCur(0); cout << "Ban co muon thoat (y/n) " << endl; a = getch(); if (a == 121) { return -1; } else { gotoxy(0, 20); ShowCur(0); cout << " "; } } }while (kiemTraChuoi(mh.MAMH) == 1); do { fflush(stdin); gotoxy(14, 11); ShowCur(1); getline(cin, mh.TENMH); if (mh.TENMH == "" ) { gotoxy(0, 20); ShowCur(0); cout << "TENMH khong duoc de trong. Moi ban nhap lai." << endl; Sleep(1000); gotoxy(0, 20); cout << " " << endl; gotoxy(14, 11); getline(cin, mh.TENMH); } }while (mh.TENMH == ""); return 0; } void xuatMONHOC(MONHOC mh) { cout << "MAMH: " << mh.MAMH << endl; cout << "TENMH: " << mh.TENMH << endl; } string themMONHOC(MONHOC temp, LISTMONHOC &plist) { if (isFull(plist)) { gotoxy(0, 14); return "Danh sach day roi. Khong them duoc nua.\n"; } if (kiemTraMAMH(temp.MAMH, plist,plist.n) == false) { gotoxy(0, 15); return "MAMH nay da bi trung. Khong them duoc.\n"; } plist.nodes[plist.n] = new MONHOC; //Khoi tao vung nho cho con tro *plist.nodes[plist.n] = temp; //Them mon hoc vao vung nho cua con tro, sau khi them vao thi tang so luong phan tu cua danh sach len 1 plist.n += 1; gotoxy(0, 18); return "Them mon hoc thanh cong.\n"; Sleep(1500); } void nhapLISTMONHOC(LISTMONHOC &plist) { //Phuong thuc nhap danh sach mon hoc. gotoxy(1, 5); SetBGColor(11); for (int i = 0; i < 12; i++) { cout << " "; } gotoxy(1, 6); SetBGColor(11); for (int i = 0; i < 12; i++) { cout << " "; } gotoxy(1, 7); SetBGColor(11); for (int i = 0; i < 12; i++) { cout << " "; } gotoxy(1, 10); SetBGColor(11); for (int i = 0; i < 12; i++) { cout << " "; } gotoxy(1, 11); SetBGColor(11); for (int i = 0; i < 12; i++) { cout << " "; } gotoxy(1, 12); SetBGColor(11); for (int i = 0; i < 12; i++) { cout << " "; } gotoxy(15, 1); SetBGColor(0); SetColor(10); ShowCur(0); cout << "CHUC NANG NHAP MON HOC"; gotoxy(2, 6); SetBGColor(11); SetColor(5); cout << "MA MON HOC"; gotoxy(2, 11); cout << "TEN MON HOC"; int i; NHAPMH: int n; MONHOC mh; n = nhapMONHOC(mh); if (n != -1) { ShowCur(0); cout << themMONHOC(mh, plist) << endl; Sleep(1500); } } void designXuatMH() { gotoxy(5, 2); SetBGColor(11); for (int i = 0; i < 60; i++) { cout << " "; } for (int i = 1; i < 30; i++) { gotoxy(35, i); cout << " "; } SetBGColor(0); gotoxy(20, 1); cout << " CHUC NANG XUAT DANH SACH MON HOC\n\n"; gotoxy(15, 3); SetColor(5); cout << "MA MON HOC"; gotoxy(50, 3); cout << "TEN MON HOC "; } void xuatLISTMONHOC(LISTMONHOC plist) { ShowCur(0); int j; system("cls"); designXuatMH(); if (isEmpty(plist)) { gotoxy(0, 15); cout << "Khong co mon hoc nao ca.\n"; Sleep(1500); return; } int k = 4; for (int i = 0; i < plist.n; i++) { gotoxy(17, k); SetColor(15); cout << plist.nodes[i]->MAMH << endl; gotoxy(45, k); cout << plist.nodes[i]->TENMH << endl; k++; } j = getch(); if (j == ENTER) { return; } } int writefileLISTMONHOC(LISTMONHOC plist) { ofstream fo("Dsmonhoc.txt", ios::out); if (!fo) { return -1; } fo << plist.n << "\n"; for (int i = 0; i < plist.n; i++) { fo << plist.nodes[i]->MAMH << "\n"; fo << plist.nodes[i]->TENMH <<"\n"; } fo.close(); return 0; } int readfileLISTMONHOC(LISTMONHOC &plist) { int n; string temp; ifstream fi; fi.open("Dsmonhoc.txt", ios::in); if (!fi) { return -1; } fi >> n; getline(fi, temp); for (int i = 0; i < n; i++) { MONHOC mh; getline(fi, mh.MAMH); getline(fi, mh.TENMH); themMONHOC(mh, plist); } fi.close(); return 1; } void designSuaMonHoc() { gotoxy(20, 1); cout << "SUA THONG TIN MON HOC"; gotoxy(65, 25); SetBGColor(0); SetColor(4); cout << "Enter o Ma Mon Hoc Moi de thoat"; gotoxy(7, 3); SetColor(3); cout << "THONG TIN HIEN TAI"; gotoxy(10, 5); SetColor(5); cout << "MA MON HOC: "; gotoxy(10, 7); cout << "TEN MON HOC: "; gotoxy(37, 3); SetColor(3); cout << "CHINH SUA"; gotoxy(38, 5); SetColor(5); cout << "MA MON HOC MOI: "; gotoxy(38, 7); cout << "TEN MON HOC MOI: "; } int Sua_MonHoc(LISTMONHOC &dsmh) { string mamonhoc = ""; string mamonhocmoi = ""; string tenmonhocmoi = ""; int viTri; fflush(stdin); designSuaMonHoc(); while (true) { gotoxy(22, 5); SetColor(15); ShowCur(1); getline(cin, mamonhoc); viTri = kiemTraMAMH(mamonhoc, dsmh); if (viTri < 0) { gotoxy(0, 20); ShowCur(0); cout << "Ma Mon Hoc nay khong co!"; Sleep(1000); system("cls"); designSuaMonHoc(); } else { gotoxy(22, 5); ShowCur(0); cout << dsmh.nodes[viTri]->MAMH; gotoxy(23, 7); cout << dsmh.nodes[viTri]->TENMH; break; } } gotoxy(54, 5); ShowCur(1); getline(cin, mamonhocmoi); while (kiemTraChuoi(mamonhocmoi) == 1) { gotoxy(0, 20); ShowCur(0); cout << "Ban co muon thoat (y/n)"; int a = getch(); if (a == 121) { return 2; } else { continue; } } while (kiemTraMAMH(mamonhocmoi, dsmh) >= 0) { gotoxy(0, 20); ShowCur(0); cout << "Ma Mon Hoc bi trung!"; Sleep(1500); gotoxy(0, 20); cout << " "; gotoxy(54, 5); cout << " "; gotoxy(54, 5); ShowCur(1); getline(cin, mamonhocmoi); } dsmh.nodes[viTri]->MAMH = mamonhocmoi; gotoxy(55, 7); ShowCur(1); getline(cin, tenmonhocmoi); while (kiemTraChuoi(tenmonhocmoi) == 1) { gotoxy(0, 20); ShowCur(0); cout << "Xin nhap Ten Mon Hoc"; Sleep(1500); gotoxy(0, 20); cout << " "; gotoxy(55, 7); ShowCur(1); getline(cin, tenmonhocmoi); } dsmh.nodes[viTri]->TENMH = tenmonhocmoi; gotoxy(0, 20); cout << "Doi thong tin thanh cong"; Sleep(1500); system("cls"); } int writefileLISTMONHOC(LISTMONHOC plist); void designXoaMonHoc() { gotoxy(20, 1); SetColor(4); cout << "XOA MON HOC"; gotoxy(15, 5); SetColor(5); cout << "MA MON HOC: "; gotoxy(15, 7); SetColor(5); cout << "TEN MON HOC: "; } int XoaMonHoc(LISTMONHOC &dsmh) { system("cls"); NHAP: string mamonxoa; int i; designXoaMonHoc(); gotoxy(27, 5); ShowCur(1); SetColor(15); getline(cin, mamonxoa); while (1) { while (kiemTraChuoi(mamonxoa) == 1)// chuoi rong { gotoxy(0, 20); ShowCur(0); SetColor(15); cout << "Ban co muon thoat (y/n): "; int a = getch(); if (a == 121) { return 2; //Phim y } else { system("cls"); goto NHAP; } } i = kiemTraMAMH(mamonxoa, dsmh); //i = -1 or i >= 0 if (i != -1) { gotoxy(28, 7); SetColor(15); cout << dsmh.nodes[i]->TENMH; gotoxy(0, 20); ShowCur(0); SetColor(15); cout << "Ban chac chan xoa khong (y/n)? "; int a = getch(); if (a == 121) { delete dsmh.nodes[i]; for (int j = i + 1; j < dsmh.n; j++) { dsmh.nodes[j - 1] = dsmh.nodes[j]; } dsmh.n--; gotoxy(32, 20); ShowCur(0); cout << "Da xoa mon hoc!"; writefileLISTMONHOC(dsmh); Sleep(2000); return 2; } else { gotoxy(0, 20); ShowCur(0); cout << " "; gotoxy(27, 5); cout << " "; gotoxy(28, 7); cout << " "; goto NHAP; } } else { gotoxy(0, 20); ShowCur(0); cout << "Ma Mon Hoc khong chinh xac. Nhap lai!"; Sleep(1500); gotoxy(0, 20); cout << " "; gotoxy(27, 5); cout << " "; gotoxy(27, 5); ShowCur(1); getline(cin, mamonxoa); } } } ///////////////////////////////////////////CAU HOI/////////////////////////////////////////// void nhapCAUHOI(CAUHOI &ch, LISTMONHOC lmh) { do { SetColor(11); cout << "Nhap NOI DUNG cau hoi: "; fflush(stdin); ShowCur(1); SetColor(15); getline(cin, ch.NOIDUNG); if (ch.NOIDUNG == "") { ShowCur(0); SetColor(12); cout << "Noi dung cau hoi khong duoc bo trong. Moi ban nhap lai.\n"; } }while (ch.NOIDUNG == ""); do { SetColor(11); cout << "Nhap CAU A: "; fflush(stdin); ShowCur(1); SetColor(15); getline(cin, ch.CAUA); if (ch.CAUA == "") { ShowCur(0); SetColor(12); cout << "Noi dung cau tra loi khong duoc bo trong. Moi ban nhap lai.\n"; } }while (ch.CAUA == ""); do { SetColor(11); cout << "Nhap CAU B: "; fflush(stdin); ShowCur(1); SetColor(15); getline(cin, ch.CAUB); SetColor(12); if (ch.CAUB == "") { ShowCur(0); cout << "Noi dung cau tra loi khong duoc bo trong. Moi ban nhap lai.\n"; } if (ch.CAUB == ch.CAUA) { ShowCur(0); cout << "Noi dung cau tra loi bi trung. Moi nhap lai.\n"; } }while (ch.CAUB == "" || ch.CAUB == ch.CAUA); do { SetColor(11); cout << "Nhap CAU C: "; fflush(stdin); ShowCur(1); SetColor(15); getline(cin, ch.CAUC); SetColor(12); if (ch.CAUC == "") { ShowCur(0); cout << "Noi dung cau tra loi khong duoc bo trong. Moi ban nhap lai.\n"; } if (ch.CAUC == ch.CAUA || ch.CAUC == ch.CAUB) { ShowCur(0); cout << "Noi dung cau tra loi bi trung. Moi nhap lai.\n"; } }while (ch.CAUC == "" || ch.CAUC == ch.CAUA || ch.CAUC == ch.CAUB); do { SetColor(11); cout << "Nhap CAU D: "; fflush(stdin); ShowCur(1); SetColor(15); getline(cin, ch.CAUD); SetColor(12); if (ch.CAUD == "") { ShowCur(0); cout << "Noi dung cau tra loi khong duoc bo trong. Moi ban nhap lai.\n"; } if (ch.CAUD == ch.CAUA || ch.CAUD == ch.CAUB || ch.CAUD == ch.CAUC) { ShowCur(0); cout << "Noi dung cau tra loi bi trung. Moi nhap lai.\n"; } }while (ch.CAUD == "" || ch.CAUD == ch.CAUA || ch.CAUD == ch.CAUB || ch.CAUD == ch.CAUC); do { SetColor(11); cout << "Nhap DAP AN: "; ShowCur(1); SetColor(15); cin >> ch.DAPAN; if (ch.DAPAN != 'A' && ch.DAPAN != 'B' && ch.DAPAN != 'C' && ch.DAPAN != 'D' && ch.DAPAN != 'a' && ch.DAPAN != 'b' && ch.DAPAN != 'c' && ch.DAPAN != 'd') { ShowCur(0); SetColor(12); cout << "Dap an khong phu hop (a, b, c, d, A, B, C, D). Moi nhap lai.\n"; } }while (ch.DAPAN != 'A' && ch.DAPAN != 'B' && ch.DAPAN != 'C' && ch.DAPAN!= 'D' && ch.DAPAN != 'a' && ch.DAPAN != 'b' && ch.DAPAN != 'c' && ch.DAPAN != 'd'); } void xuatCAUHOI(CAUHOI ch) { //Xuat 1 cau hoi ShowCur(0); cout << "NOIDUNG: " << ch.NOIDUNG << endl; cout << "CAU A: " << ch.CAUA << endl; cout << "CAU B: " << ch.CAUB << endl; cout << "CAU C: " << ch.CAUC << endl; cout << "CAU D: " << ch.CAUD << endl; cout << "Dap an: " << ch.DAPAN << endl; } void Init(TREECH & root) { root = NULL; } bool isEmpty(TREECH root) { return(root == NULL); } /*LH: cay con trai cao hon EH: 2 cay con bang nhau RH: cay con phai cao hon*/ //Quay phai void rotateLL (TREECH &T) { NODECH *T1 = T->left; T->left = T1->right; T1->right = T; switch (T1->bf) //T1 ban dau khi chua xoay. Cap nhat lai chi so can bang { case LH: T->bf = EH; T1->bf = EH; break; case EH: T->bf = LH; T1->bf = RH; break; } T = T1; } //Quay trai void rotateRR(TREECH &T) { NODECH *T1 = T->right; T->right = T1->left; T1->left = T; switch (T1->bf) { case RH: T->bf = EH; T1->bf = EH; break; case EH: T->bf = RH; T1->bf = LH; break; } T = T1; } //Quay kep Left - Right void rotateLR(TREECH &T) { NODECH *T1 = T->left; NODECH *T2 = T1->right; T->left = T2->right; T2->right = T; T1->right = T2->left; T2->left = T1; switch (T2->bf) { case LH: T->bf = RH; T1->bf = EH; break; case EH: T->bf = EH; T1->bf = EH; break; case RH: T->bf = EH; T1->bf = LH; break; } T2->bf = EH; T = T2; } //Quay kep Right - Left void rotateRL (TREECH &T) { NODECH *T1 = T->right; NODECH *T2 = T1->left; T->right = T2->left; T2->left = T; T1->left = T2->right; T2->right = T1; switch (T2->bf) { case RH: T->bf = LH; T1->bf = EH; break; case EH: T->bf = EH; T1->bf = EH; break; case LH: T->bf = EH; T1->bf = RH; break; } T2->bf = EH; T = T2; } //Can bang khi cay bi lech ve ben trai void balanceLeft(TREECH &T) { switch (T->left->bf) { case LH: rotateLL(T); break; case EH: rotateLL(T); break; case RH: rotateLR(T); } } //Can bang khi cay bi lech ve ben phai void balanceRight(TREECH &T) { switch (T->right->bf) { case LH: rotateRL(T); break; case EH: rotateRR(T); break; case RH: rotateRR(T); } } /*return 1: Trang thai sau khi them bf = 0 return 2: Trang thai sau khi them bf = 1 hoac bf = -1*/ int Insert(TREECH &T, int X, CAUHOI ch) { int res; if (T != NULL) { if (T->ID == X) { return 0; } else if (T->ID > X) { res = Insert(T->left, X, ch); if (res < 2) { return res; } switch (T->bf) { case RH: T->bf = EH; return 1; case EH: T->bf = LH; return 2; case LH: balanceLeft(T); return 1; } } else //if (T->key < X) { res = Insert(T->right, X, ch); if (res < 2) { return res; } switch (T->bf) { case LH: T->bf = EH; return 1; case EH: T->bf = RH; return 2; case RH: balanceRight(T); return 1; } } } //T == NULL T = new NODECH; if (T == NULL) { return -1; //Thieu bo nho } T->ID = X; T->bf = EH; T->info.MAMH = ch.MAMH; T->info.NOIDUNG = ch.NOIDUNG; T->info.CAUA = ch.CAUA; T->info.CAUB = ch.CAUB; T->info.CAUC = ch.CAUC; T->info.CAUD = ch.CAUD; T->info.DAPAN = ch.DAPAN; T->left = T->right = NULL; return 2; } void lengthCAUHOIMAMH(TREECH p, int &i, string mamh) //Ham nay tra ve do dai cua cac cauhoi ma mamh giong voi mamh ma nguoi dung yeu cau. { if (p != NULL) { if (p->info.MAMH == mamh) { i++; } lengthCAUHOIMAMH(p->left, i, mamh); lengthCAUHOIMAMH(p->right, i, mamh); } } void xuatLISTCAUHOI(TREECH p, string mamh) { //Xuat cac cau hoi co mamh bang voi mamh if (p != NULL) { if(p->info.MAMH == mamh) { xuatCAUHOI(p->info); } xuatLISTCAUHOI(p->left, mamh); xuatLISTCAUHOI(p->right, mamh); } } void xuatLISTCAUHOI_OF_MONHOC(TREECH p , LISTMONHOC lmh) { //Xuat danh sach cau hoi theo mon hoc string mamh; int i = 0; int dem = 0; do { system("cls"); ShowCur(0); cout << "\nCHUC NANG XEM CAU HOI THI CUA MON HOC\n\n"; do { SetColor(11); cout << "\nNhap ma mon hoc muon xem cau hoi: "; fflush(stdin); ShowCur(1); SetColor(15); getline(cin, mamh); if (kiemTraMAMH(mamh, lmh, lmh.n) == true) { ShowCur(0); SetColor(12); cout << "Ma mon hoc khong ton tai. Moi nhap Lai.\n"; dem++; } }while (kiemTraMAMH(mamh, lmh, lmh.n) == true && dem < 4); //Cho nhap lai nhieu nhat 3 lan lengthCAUHOIMAMH(p, i, mamh); if (i == 0) { SetColor(12); ShowCur(0); cout << "\nKhong co cau hoi nao.\n"; } else { xuatLISTCAUHOI(p, mamh); } ShowCur(0); SetColor(11); cout << "\nBan muon xem cau hoi mon khac khong? 0: THOAT, #0: TIEP TUC: "; cin >> i; }while (i != 0); } void kiemTraCAUHOI(TREECH p, CAUHOI ch, int &i) //Kiem tra cau hoi xem bi trung chua. { if(p != NULL) { if(p->info.MAMH == ch.MAMH && p->info.NOIDUNG == ch.NOIDUNG && p->info.CAUA == ch.CAUA && p->info.CAUB == ch.CAUB && p->info.CAUC == ch.CAUC && p->info.CAUD == ch.CAUD) { i++; } kiemTraCAUHOI(p->left, ch, i); kiemTraCAUHOI(p->right, ch, i); } } TREECH searchCAUHOIbyID(TREECH T, int x) { //x la id cua cau hoi minh muon tim trong cay TREECH p; p = T; while (p != NULL && x != p->ID) { if (x < p->ID) { p = p->left; } else { p = p->right; } } return(p); //Neu p tra ve NULL: tuc la trong cay chua ton tai id x, them vao cay; neu khac NULL la trong cay da ton tai roi, phai ramdom lai } int RANDOM() { int m; int n; int A[2000]; ifstream filein; filein.open("so_ngau_nhien.txt", ios_base::in); filein >> n; for (int i = 0; i < n; i++) { filein >> A[i]; } filein.close(); m = A[n - 1]; n--; ofstream fileout; fileout.open("so_ngau_nhien.txt", ios_base::out); fileout << n << endl; for (int i = 0; i < n; i++) { fileout << A[i] << " "; } fileout.close(); return m; } void nhapLISTCAUHOI(TREECH &p , LISTMONHOC lmh) { int temp1; int a; do { system("cls"); ShowCur(0); cout << "\nCHUC NANG NHAP CAU HOI THI TRAC NGHIEM\n\n"; int id, temp, x; //x dung de kiem tra trung cau hoi, temp vong lap, id la key trong cay nhi phan NODECH *q, *kt; CAUHOI ch; do { ShowCur(0); SetColor(11); cout << "Nhap MA MON HOC: "; fflush(stdin); ShowCur(1); SetColor(15); getline(cin, ch.MAMH); if (ch.MAMH == "" || kiemTraMAMH(ch.MAMH, lmh, lmh.n)) { if (kiemTraChuoi(ch.MAMH) == 1) //Chuoi rong { gotoxy(0, 20); ShowCur(1); SetColor(12); cout << "Ban co muon thoat (Y/N): "; a = getch(); if (a == 121) { return; //Phim y } else { system("cls"); } } else { ShowCur(0); SetColor(12); cout << "Ma mon hoc nay khong ton tai. Moi kiem nhap lai.\n"; } } }while (ch.MAMH == "" || kiemTraMAMH(ch.MAMH, lmh, lmh.n)); do { id = RANDOM(); do { ShowCur(0); SetColor(11); cout << "\nNhap thong tin cua cau hoi.\n"; nhapCAUHOI(ch, lmh); x = 0; kiemTraCAUHOI(p, ch, x); SetColor(12); if (x == 1) { ShowCur(0); cout << "\nCau hoi nay da bi trung. Moi ban nhap lai.\n"; } else { int j = Insert(p, id, ch); if (j == 2 || j == 1) { ShowCur(0); cout << "Them cau hoi thanh cong.\n"; } else { ShowCur(0); cout << "Them cau hoi that bai.\n"; } } }while (x == 1); SetColor(12); ShowCur(1); cout << "\nBan muon them cau hoi cho MON HOC nay nua khong? 0: THOAT, #0:TIEP TUC: "; cin >> temp; if (temp == 0) { ShowCur(0); cout << "\nThoat chuc nang thanh cong.\n"; } }while (temp != 0); ShowCur(1); cout << "\nBan muon them cau hoi cho mon khac khong? 0: THOAT, #0:TIEP TUC: "; cin >> temp1; if (temp1 == 0) { ShowCur(0); cout << "\nThoat chuc nang thanh cong.\n"; } }while (temp1 != 0); } void writefileLISTCAUHOI(TREECH p, ofstream &fo) { if (p != NULL) { fo << p->ID << endl; fo << p->info.MAMH << endl; fo << p->info.NOIDUNG << endl; fo << p->info.CAUA << endl; fo << p->info.CAUB << endl; fo << p->info.CAUC << endl; fo << p->info.CAUD << endl; fo << p->info.DAPAN << endl; writefileLISTCAUHOI(p->left, fo); writefileLISTCAUHOI(p->right, fo); } } int writefileLISTCAUHOI(TREECH p) { ofstream fo("filelistcauhoi.txt", ios::out); //ios::app: ghi tiep tuc vao file, chu khong phai xoa het file roi ghi lai tu dau. if (!fo) { return -1; } writefileLISTCAUHOI(p, fo); fo.close(); return 1; } int readfileLISTCAUHOI(TREECH &p) { int id; CAUHOI ch; string temp; ifstream fi("filelistcauhoi.txt"); if (!fi) { return -1; } while (!fi.eof()) { fi >> id; getline(fi, temp); //Vi id la so, nen se con du khoang trang, phai dung 1 bien string tam de luu, neu khong, ma mon hoc se bi bo qua getline(fi, ch.MAMH); getline(fi, ch.NOIDUNG); getline(fi, ch.CAUA); getline(fi, ch.CAUB); getline(fi, ch.CAUC); getline(fi, ch.CAUD); fi >> ch.DAPAN; getline(fi, temp); Insert(p, id, ch); } fi.close(); return 1; } ///////////////////////////////////////////DE THI/////////////////////////////////////////// bool isEmpty(DETHI plist) { return(plist.n == 0); } bool isFull(DETHI plist) { return(plist.n == MAX); } void create(DETHI & plist) { plist.n = 0; } bool kiemTraDETHI(int id, DETHI plist) { //Kiem tra cau hoi nay co trong de thi chua; for (int i = 0; i < plist.n; i++) { if (plist.nodes[i] == id) { return false; //Tra ve false khi cau hoi bi trung, ngc lai tra ve true. } } return true; } int themCAUHOI_DETHI(int id, DETHI &plist) { //Ham them mot cau hoi vao danh sach DETHI da co san. if (isFull(plist)) { return -1; } if (kiemTraDETHI(id, plist) == false) { return -1; } plist.nodes[plist.n] = id; //Danh sach de thi la mang tuyen tinh; ok het thi cho them vao, sau khi them vao thi tang so luong phan tu cua danh sach len 1 plist.n += 1; return 1; } void LayCauHoiCuaMon(int &n, int A[], TREECH lch, string mamh) { if (lch != NULL) { if (lch->info.MAMH == mamh) { A[n] = lch->ID; n++; } LayCauHoiCuaMon(n, A, lch->left, mamh); LayCauHoiCuaMon(n, A, lch->right, mamh); } } void HoanDoi(int &a, int &b) { int temp = a; a = b; b = temp; } void XaoTronMang(int arr[], int n) { srand(time(NULL)); int vitrimin; int vitrimax = n - 1; int vitrihoandoi; int i = 0; while (i < n - 1) { vitrimin = i + 1; vitrihoandoi = rand() % (vitrimax - vitrimin + 1) + vitrimin; HoanDoi(arr[i], arr[vitrihoandoi]); i++; } } void taiDETHI(int soch, DETHI &ldt, TREECH lch, string mamh) { int n = 0; int A[4*MAX]; LayCauHoiCuaMon(n, A, lch, mamh); XaoTronMang(A, n); ldt.n = soch; for (int i = 0; i < soch; i++) { ldt.nodes[i] = A[i]; } } int LuuFileDSLOP(DsLop &dsLop) { ofstream of("dslop.txt", ios::out); if (!of) { cout << "Loi luu file!!!"; return -1; } of << dsLop.n << endl; for (int i = 0; i < dsLop.n; i++) { of << dsLop.lh[i].MaLop << endl; of << dsLop.lh[i].TenLop << endl; LISTSV p = dsLop.lh[i].FirstSV; while (p != NULL) { of << p->sv.MSSV << endl; of << p->sv.ho << endl; of << p->sv.ten << endl; of << p->sv.gioitinh << endl; of << p->sv.password << endl; Listdiemthi ptrDiem = p->sv.FirstDiem; while (ptrDiem != NULL) { of << ptrDiem->DataDiem.MAMH << endl; of << ptrDiem->DataDiem.DIEM << endl; ptrDiem = ptrDiem->pNext; } of << endl; p = p->pNext; } of << endl; } of.close(); } void DocFileDSLOP(DsLop &dslop) { ifstream fi("dslop.txt", ios::in); if (!fi) { cout << "Khong the doc file!!"; return; } fi >> dslop.n; fi.ignore(); for (int i = 0; i < dslop.n; i++) { getline(fi, dslop.lh[i].MaLop); getline(fi, dslop.lh[i].TenLop); dslop.lh[i].FirstSV = NULL; Sv *sv = new Sv; //Cap phat vung nho cho 1 sinh vien getline(fi, sv->MSSV); while (sv->MSSV.length() != 0) { getline(fi, sv->ho); getline(fi, sv->ten); getline(fi, sv->gioitinh); getline(fi, sv->password); sv->FirstDiem = NULL; Diemthi *diem = new Diemthi; getline(fi, diem->MAMH); while (diem->MAMH.length() != 0) { fi >> diem->DIEM; fi.ignore(); Insert_LastDiem(sv->FirstDiem, *diem); diem = new Diemthi; getline(fi, diem->MAMH); } Insert_Last(dslop.lh[i].FirstSV, *sv); sv = new Sv; getline(fi, sv->MSSV); } } fi.close(); } void InThoiGian(int tg) { //Ham hien thi thoi gian, thoi gian la so giay gotoxy(10, 1); ShowCur(0); cout << "TG: " << setw(2) << setfill('0') << tg/60 //In so phut << ":" << setw(2) << setfill('0') << tg%60; //In so giay } void normal() { SetColor(10); //Mau chu SetBGColor(0); } void hightline() { SetColor(29); //Mau chu cua vi tri con tro hien tai SetBGColor(11); } char menu_GV[13][100] = { "1. THEM LOP MOI ", "2. IN DS LOP ", "3. THEM SINH VIEN CUA 1 LOP ", "4. IN DS SINH VIEN CUA 1 LOP ", "5. THEM MON HOC ", "6. SUA MON HOC ", "7. XOA MON HOC ", "8. IN DS MON HOC ", "9. NHAP CAU HOI THI ", "10. IN DANH SACH CAU HOI ", "11. THI TRAC NGHIEM ", "12. IN CAC CAU HOI DA THI CUA SV ", "13. IN BANG DIEM CUA LOP THEO MON HOC", }; int Select() { system("cls"); DsLop dslop; int select = 0; int i = 0; char c; gotoxy(25, 1); for (int i = 0; i < 23; i++) { cout << "+ "; } for (int i = 0; i < 33; i++) { gotoxy(25, i + 1); cout << "+ "; } gotoxy(25, 33); for (int i = 0; i < 23; i++) { cout << "+ "; } for (int i = 0; i < 33; i++) { gotoxy(69, i + 1); cout << "+ "; } gotoxy(2, 3); SetColor(14); cout << "UP: len"; gotoxy(2, 4); cout << "DOWN: xuong"; gotoxy(2, 5); cout << "ENTER: chon"; gotoxy(35, 1); cout << "CHUC NANG CUA GIAO VIEN"; gotoxy(30, 2); normal(); for (int i = 0; i < 13; i++) { gotoxy(30, 5 + i*2); cout << menu_GV[i]; } hightline(); gotoxy(30,5); cout << menu_GV[0]; while (1) { ShowCur(0); c = _getch(); normal(); gotoxy(26, (5 + select*2)); cout << " "; gotoxy(30, (5 + select*2)); cout << menu_GV[select]; switch (c) { case UP: { select -= 1; if (select < 0) { select = 12; } break; } case DOWN: { select += 1; if (select > 12) { select = 0; } break; } case ENTER: { return select + 1; break; } default: { break; } } hightline(); gotoxy(30, (5 + select*2)); cout << menu_GV[select]; } gotoxy(70, 70); } float chamDIEM(TREECH lch, DETHI dt, char* dapan) { int j = 0; for (int i = 0; i < dt.n; i++) { NODECH *q = searchCAUHOIbyID(lch, dt.nodes[i]); if (dapan[i] < 123 && dapan[i] > 96) //Chuan hoa cac dap an ma co chu in thuong thanh in hoa { dapan[i] -= 32; } if (q->info.DAPAN < 123 && q->info.DAPAN > 96) //Chuan hoa cac dap an ma co chu in thuong thanh in hoa { q->info.DAPAN -= 32; } if (dapan[i] == q->info.DAPAN) //So sanh tung cau tra loi cua nguoi dung voi dap an cua cau hoi. Dung thi tang bien dem. Khong thi thoi. { j++; } } return ((float)j / (float)dt.n)*10; //Tra ve diem so dat duoc. } void inxy(int x, int y, string s) { //Ham di chuyen con tro lenh den vi tri (x,y) roi in ra xau s. gotoxy(x, y); cout << s; } void InCauTraLoi(CAUHOI ch, int i, bool highlight) { //Ham in cac cau tra loi, i la cau thu (A, B, C, D), highlight la co to sang hay khong string ctl; //ctl de chua cau tra loi tuong ung switch (i) { case 0: ctl = ch.CAUA; break; case 1: ctl = ch.CAUB; break; case 2: ctl = ch.CAUC; break; case 3: ctl = ch.CAUD; } ctl.insert(0, string(1, char(i + 65)) + ". "); //Them "A." (hoac "B.",...) truoc cau tra loi int padding = 80 - ctl.length() % 80; //padding luu so khoang trong can them de cho du 1 hang if (highlight) { //Neu bien highlight = true thi to sang, = false thi thoi SetColor(0); //Dat mau chu den SetBGColor(15); //Dat nen trang } inxy(0, 7 + i * 3, ctl + string(padding,' ')); //In cau tra loi SetColor(15); //Dat mau chu trang SetBGColor(0); //Dat nen den } void GiaoDienThi(CAUHOI ch, string mamh, int soch, int i, char* dapan, int &luachon) { //Ham xay dung giao dien thi system("cls"); ShowCur(0); inxy(33, 0, "THI TRAC NGHIEM"); string mamon = "Ma mon hoc: " + mamh; inxy(40 - mamon.length()/2, 2, mamon); gotoxy(0, 4); cout << "Cau " << i + 1 << "/" << soch << ": " << ch.NOIDUNG; for (int j = 0; j < 4; j++) { InCauTraLoi(ch, j, false); //In ra 4 cau tra loi } if (dapan[i] != ' ') { //Xem nguoi thi da tra loi cau i chua. Neu roi thi to sang dap an tuong ung, chua thi to sang cau A InCauTraLoi(ch, int(dapan[i]) - 65, true); luachon = int(dapan[i]) - 65; } else { InCauTraLoi(ch, 0, true); luachon = 0; } gotoxy(0, 19); ShowCur(0); cout << "Dap an ban chon: " << dapan[i]; inxy(0, 21, "Huong dan: Nhan phim mui ten len, xuong de di chuyen thanh sang, enter de chon."); inxy(1, 22, "Nhan phim mui ten trai, phai de den cau truoc, cau sau, nhan \"N\" de nop bai."); } void hienThiCAUTRALOI(int soch, string dapan) {//Ham nay hien thi cau tra loi cua nguoi thi khi nhap vao, giong nhu minh tra loi cau hoi 1 la A. Thi no hien ra la 1 - A. ShowCur(0); cout << "\nCau hoi:" ; for (int i = 0; i < soch; i++) { cout << " "<< i + 1; } cout << "\nTra loi: "; for (int i = 0; i < soch; i++) { cout << " " << dapan[i]; } } string dapAnDETHI(DETHI dt, TREECH lch) { //Day la ham lay dap an cua 1 de thi de ti nua dung dap an do di cham diem. string da = ""; for (int i = 0; i < dt.n; i++) { NODECH *p = searchCAUHOIbyID(lch, dt.nodes[i]); da += p->info.DAPAN; //Tra dap an cua de thi no ve 1 cai chuoi. } return da; } bool KiemTra(Sv sinhvien, string mamh) { while (sinhvien.FirstDiem != NULL) { if(sinhvien.FirstDiem->DataDiem.MAMH == mamh) { return false; } sinhvien.FirstDiem = sinhvien.FirstDiem->pNext; } return true; } Listdiemthi searchDIEMTHIbyMASV_byMAMH (Listdiemthi ldt, string mamh) { //Tim x trong danh sach. Listdiemthi p = ldt; while (p != NULL) { if (p->DataDiem.MAMH == mamh) { return p; } p = p->pNext; } return NULL; //Khong tim thay } void designTHITN() { gotoxy(30, 1); SetColor(19); cout << "CHUC NANG THI TRAC NGHIEM"; gotoxy(10, 3); SetColor(5); cout << "MA MON HOC: "; gotoxy(10, 4); cout << "SO LUONG CAU HOI: "; gotoxy(10, 5); cout << "SO PHUT: "; } void thiTRACNGHIEM(TREECH lch, LISTMONHOC lmh, LISTSV sv , Sv *sinhvien) { //Day la phan thi trac nghiem system("cls"); string mamh; //Hoi sinh vien thi mon gi int soch; //Thi bao nhieu cau. int temp; //Bien lap. Nhap tat ca cac thong tin can thiet, roi kiem tra loi, neu co loi bat nhap lai. int cauthu = 0; //Bien quan ly cau hoi int luachon = 0; //Bien quan ly cau tra loi dang chon do { designTHITN(); DETHI dethi; create(dethi); //dethi.n = 0; do { fflush(stdin); gotoxy(22, 3); SetColor(15); ShowCur(1); getline(cin, mamh); if (mamh == "" || kiemTraMAMH(mamh, lmh, lmh.n) == true) { gotoxy(0, 20); ShowCur(0); cout << "Ma Mon Hoc nay khong hop le. Moi nhap lai"; Sleep(1500); gotoxy(22,3); cout << " "; gotoxy(0, 20); cout << " "; } }while (mamh == "" || kiemTraMAMH(mamh, lmh, lmh.n) == true); int i = 0; do { gotoxy(28, 4); ShowCur(1); cin >> soch; lengthCAUHOIMAMH(lch, i, mamh); //Lay so cau hoi toi da cua mon do bo vao i va di so sanh kiem tra dieu kien if (soch < 0 || soch > i) { gotoxy(0, 20); ShowCur(0); cout << "So cau hoi khong hop le (0 < x <= "<< "i"<<"). Moi ban nhap lai."; Sleep(1500); gotoxy(28, 4); cout << " "; gotoxy(0, 20); cout << " "; } }while (soch < 0 || soch > i); int nhaptg; //Nhap thoi gian thi gotoxy(19, 5); ShowCur(1); cin >> nhaptg; Listdiemthi p; if (sv == NULL) //Day la admin thi. { p = NULL; } else //Day la sinh vien thi { p = searchDIEMTHIbyMASV_byMAMH(sinhvien->FirstDiem, mamh); //Kiem tra sinh vien da thi mon nay chua. } if (p == NULL) { //Chua thi hoac giao vien thi taiDETHI(soch, dethi, lch, mamh); //Tai danh sach de thi dua vao cac thong tin moi nhap vao. char *dapan = new char[dethi.n]; for (int i = 0; i < soch; i++) { //Day la chuoi string de luu cau tra loi cua ng thi vao. Dau tien ta cho tat ca bang space het. dapan[i] = ' '; } int thoigian = nhaptg * 60; //Tinh thoi gian, don vi tinh la giay. unsigned char da; time_t batdau, hiengio; //batdau: chua thoi gian luc bat dau, hiengio: chua thoi gian hien gio time(&batdau); //Lay thoi gian bat dau thi NODECH* ch = searchCAUHOIbyID(lch, dethi.nodes[cauthu]); //Lay bo cau hoi & cau tra loi theo so thu tu GiaoDienThi(ch->info, mamh, soch, cauthu, dapan, luachon); //Hien thi giao dien thi do { if (kbhit()) { //Neu co nhan phim da = getch(); switch (da) { case 13: { //Nhan enter chon dap an dapan[cauthu] = char(luachon + 65); //Ghi nhan vao dap an gotoxy(0, 19); ShowCur(0); cout << "Dap an ban chon: " << dapan[cauthu]; //In cau tra loi ra break; } case 'N': //Nhan chu N nop bai case 'n': { //Nhan chu n nop bai system("cls"); ShowCur(0); inxy(33, 0, "THI TRAC NGHIEM"); //Ham di chuyen con tro lenh den vi tri (x,y) roi in ra xau s. string mamon = "Ma mon hoc: " + mamh; inxy(40 - mamon.length() / 2, 2, mamon); ShowCur(1); inxy(0, 4, " Ban da chac chan muon nop bai chua? (Nhan \"y\": dong y, #y: khong dong y)"); ShowCur(0); inxy(0, 6, "Dap an ban lam:"); gotoxy(0, 6); hienThiCAUTRALOI(soch, dapan); da = 0; do { //Vong lap de xem nguoi thi co chac chan nop hay chua if (kbhit()) { da = getch(); if (da == 0 || da == 224) { //Neu la nhan cac phim mui ten,... thi phai getch them 1 lan de lay ky tu du da = getch(); break; } else { if (da == 'y' || da == 'Y') { //Nguoi thi dong y nop bai thi cho da = chu "n" da = 'n'; } else { //An phim bat ky thi quay lai thi tiep neu con thoi gian da = 0; break; } } } time(&hiengio); //Lay gio hien tai ShowCur(0); InThoiGian(thoigian - hiengio + batdau); //In ra thoi gian }while (da != 'n' && da != 'N' && thoigian >= (hiengio - batdau)); GiaoDienThi(ch->info, mamh, soch, cauthu, dapan, luachon); break; } case 0: //Nhan phim mui ten case 224: { //Nhan phim mui ten da = getch(); switch (da) { case 80: { //Phim xuong di chuyen thanh sang xuong InCauTraLoi(ch->info, luachon, false); //Viet thuong lai cau tra loi dang to sang if (luachon == 3) { luachon = 0; } else { luachon++; } InCauTraLoi(ch->info, luachon, true); //To sang cau tra loi ke tiep break; } case 72: { //Phim len di chuyen thanh sang len InCauTraLoi(ch->info, luachon, false); //Viet thuong lai cau tra loi dang to sang if (luachon == 0) { luachon = 3; } else { luachon--; } InCauTraLoi(ch->info, luachon, true); //To sang cau tra loi phia truoc break; } case 77: { //Phim phai toi cau ke tiep if (cauthu == dethi.n - 1) { cauthu = 0; } else { cauthu++; } ch = searchCAUHOIbyID(lch, dethi.nodes[cauthu]); GiaoDienThi(ch->info, mamh, soch, cauthu, dapan, luachon); break; } case 75: { //Phim trai quay lai cau truoc if (cauthu == 0) { cauthu = dethi.n - 1; } else { cauthu--; } ch = searchCAUHOIbyID(lch, dethi.nodes[cauthu]); GiaoDienThi(ch->info, mamh, soch, cauthu, dapan, luachon); } } } } } time(&hiengio); //Lay gio hien tai ShowCur(0); InThoiGian(thoigian - hiengio + batdau); //In ra thoi gian }while (da != 'n' && da != 'N' && thoigian >= (hiengio - batdau)); //Kiem tra thoi gian va xem nguoi ta nop bai chua. Neu chua thi cho ho thi tiep, khi nao het hoi gian thi thoat hoac khi ho nhan vao 'n' la thoat ra cham diem. //Het gio thi hoac nguoi ta da nhan vao nop bai. system("cls"); da = 0; ShowCur(0); cout << "Dap an ban lam:"; gotoxy(0, 0); hienThiCAUTRALOI(soch, dapan); gotoxy(0, 5); cout << "Dap an dung:"; string ketqua = dapAnDETHI(dethi, lch); //Lay dap an cua de thi do. gotoxy(0, 5); hienThiCAUTRALOI(soch, ketqua); float diem = chamDIEM(lch, dethi, dapan); gotoxy(0, 9); cout << "\nBan duoc " << diem << " diem" << endl; if (sv == NULL) { //Kiem tra nguoi thi la sv hay admin, neu admin thi goto EXIT. goto exit; } Listdiemthi dt = new NodeDiem; dt->DataDiem.DeThi.n = 0; for (int i = 0; i < dethi.n; i++) { themCAUHOI_DETHI(dethi.nodes[i], dt->DataDiem.DeThi); } dt->DataDiem.MAMH = mamh; dt->DataDiem.DIEM = diem; dt->pNext = NULL; Insert_LastDiem(sinhvien->FirstDiem, dt->DataDiem); } else { ShowCur(0); cout << "\nMon nay ban da thi roi.\n"; } exit: ShowCur(1); cout << "---------------------------------------------------"; cout << "\nBan co muon thi nua khong? 0: Thoat, #0: Tiep tuc: "; cin >> temp; system("cls"); }while (temp != 0); } void designXuatDSDiem_Lop() { gotoxy(20, 1); SetColor(14); SetBGColor(0); cout << "CHUC NANG XUAT DIEM THI SINH VIEN CUA 1 LOP"; gotoxy(30, 3); SetColor(3); cout << "MA LOP: "; gotoxy(30, 4); SetColor(3); cout << "MA MON HOC: "; gotoxy(9, 6); SetColor(14); cout << "MSSV: "; gotoxy(34, 6); cout << "HO: "; gotoxy(54, 6); cout << "TEN: "; gotoxy(69, 6); cout << "MA MON HOC: "; gotoxy(83, 6); cout << "DIEM: "; } void XuatDSDiem_Lop(DsLop dslop, LISTMONHOC plist) { designXuatDSDiem_Lop(); int line, a, viTril = -1, viTrim = -1; string malop = ""; do { fflush(stdin); gotoxy(38, 3); SetColor(15); ShowCur(1); getline(cin, malop); viTril = TimKiemMaLop(dslop, malop); if (viTril == -1) { gotoxy(0, 25); ShowCur(0); cout << "Ma Lop khong ton tai!"; Sleep(1000); gotoxy(0, 25); cout << " "; gotoxy(38, 3); cout << " "; } }while (viTril == -1); string mamh = ""; do { fflush(stdin); gotoxy(42, 4); SetColor(15); ShowCur(1); getline(cin, mamh); viTrim = kiemTraMAMH(mamh, plist); if (viTrim == -1) { gotoxy(0, 25); ShowCur(0); cout << "Ma Mon Hoc khong ton tai!"; Sleep(1000); gotoxy(0, 25); cout << " "; gotoxy(38, 3); cout << " "; } }while (viTrim == -1); line = 7; LISTSV lsv = dslop.lh[viTril].FirstSV; while (lsv != NULL) { ShowCur(0); gotoxy(9, line); cout << lsv->sv.MSSV << endl; gotoxy(34, line); cout << lsv->sv.ho << endl; gotoxy(54, line); cout << lsv->sv.ten << endl; Listdiemthi ldt = lsv->sv.FirstDiem; if (ldt != NULL) { bool thiRoi = false; while (ldt != NULL) { if (ldt->DataDiem.MAMH == mamh) { gotoxy(70, line); cout << ldt->DataDiem.MAMH; gotoxy(83, line); cout << ldt->DataDiem.DIEM; thiRoi = true; break; } ldt = ldt->pNext; } if (!thiRoi) { gotoxy(83, line); ShowCur(0); cout << "Chua thi"; } } else { gotoxy(83, line); ShowCur(0); cout << "Chua thi"; //Neu danh sach diem thi rong thi chua thi } line++; cout << endl; lsv = lsv->pNext; } getch(); } void xuLiMenuGV(DsLop &dslop, LISTMONHOC &lmh, TREECH &lch) { Sv *sinhvien; Listdiemthi ldt; LopHoc lh; int choice = 0; MAIN: system("cls"); while (choice = Select()) { switch (choice) { case 1: { system("cls"); NhapLop(dslop); LuuFileDSLOP(dslop); goto MAIN; break; } case 2: { system("cls"); if (XuatLop(dslop) == 1) { goto MAIN; } break; } case 3: { system("cls"); NhapSV(dslop); LuuFileDSLOP(dslop); goto MAIN; break; } case 4: { system("cls"); DocFileDSLOP(dslop); if (XuatDSSV_OF_LOP(dslop) == 2) { goto MAIN; } break; } case 5: { system("cls"); nhapLISTMONHOC(lmh); writefileLISTMONHOC(lmh); goto MAIN; break; } case 6: { system("cls"); Sua_MonHoc(lmh); writefileLISTMONHOC(lmh); goto MAIN; break; } case 7: { system("cls"); XoaMonHoc(lmh); goto MAIN; break; } case 8: { system("cls"); xuatLISTMONHOC(lmh); goto MAIN; break; } case 9: { system("cls"); nhapLISTCAUHOI(lch, lmh); writefileLISTCAUHOI(lch); goto MAIN; break; } case 10: { system("cls"); readfileLISTCAUHOI(lch); xuatLISTCAUHOI_OF_MONHOC(lch, lmh); goto MAIN; break; } case 11: { system("cls"); thiTRACNGHIEM(lch,lmh,NULL,sinhvien); break; } case 12: { break; } case 13: { system("cls"); XuatDSDiem_Lop(dslop,lmh); goto MAIN; break; } } } } void design_DangNhap() { system ("cls"); gotoxy(27, 9); for (int i = 0; i < 35; i++) { cout << (char)254; } for (int i = 10; i < 14; i++) { gotoxy(27, i); cout << (char)221; } for (int i = 10; i < 14; i++) { gotoxy(41, i); cout << (char)221; } for (int i = 10; i < 14; i++) { gotoxy(61, i); cout << (char)221; } gotoxy(27, 13); for (int i = 0; i < 35; i++) { cout << (char)254; } gotoxy(30, 10); SetColor(11); cout << "USERNAME: "; gotoxy(30, 12); SetColor(11); cout << "PASSWORD: "; gotoxy(0, 20); } LISTSV xuLiDangNhap(DsLop dsLop, int &i, Sv* &sv) { system("cls"); design_DangNhap(); string username = "", password = ""; do { fflush(stdin); gotoxy(44, 10); ShowCur(1); getline(cin, username); if (username.length() == 0) { gotoxy(40, 15); ShowCur(0); cout << "Hay nhap Username !"; Sleep(1500); gotoxy(40, 15); cout << " "; } }while (username.length() == 0); ChuanHoaPass(password, 44, 12); if (username == "GV" && password == "GV") { i = 1; return NULL; } else { for (int j = 0; j < dsLop.n; j++) { LISTSV p = dsLop.lh[j].FirstSV; while (p != NULL) { if (p->sv.MSSV == username && p->sv.password == password) { i = 0; sv = &p->sv; return dsLop.lh[j].FirstSV; } p = p->pNext; } } i = -1; sv = NULL; return NULL; } } void GiaiPhongCay(TREECH &root) { if (root->left != NULL) { GiaiPhongCay(root->left); } if (root->right != NULL) { GiaiPhongCay(root->right); } if (root->left == NULL && root->right == NULL) { delete root; root = NULL; } } void GiaiPhong(LISTMONHOC &lmh, DsLop &dslop, TREECH &cauhoi) { for (int i = 0; i < lmh.n; i++) { delete lmh.nodes[i]; } for (int i = 0; i < dslop.n; i++) { LISTSV h = dslop.lh[i].FirstSV; while (dslop.lh[i].FirstSV != NULL) { Listdiemthi k = dslop.lh[i].FirstSV->sv.FirstDiem; while (dslop.lh[i].FirstSV->sv.FirstDiem != NULL) { dslop.lh[i].FirstSV->sv.FirstDiem = dslop.lh[i].FirstSV->sv.FirstDiem->pNext; delete k; k = dslop.lh[i].FirstSV->sv.FirstDiem; } dslop.lh[i].FirstSV = dslop.lh[i].FirstSV->pNext; delete h; h = dslop.lh[i].FirstSV; } } GiaiPhongCay(cauhoi); } int main() { Sv* sinhvien; DsLop dslop; dslop.n = 0; LISTMONHOC lmh; create(lmh); readfileLISTMONHOC(lmh); DocFileDSLOP(dslop); TREECH lch; Init(lch); readfileLISTCAUHOI(lch); SetConsoleTitle("Thi Trac Nghiem"); resizeConsole(840, 720); do { int i = 0; LISTSV p = xuLiDangNhap(dslop, i, sinhvien); if (p == NULL && i == 1) { xuLiMenuGV(dslop, lmh, lch); } else { if (sinhvien != NULL && i == 0) { thiTRACNGHIEM(lch, lmh, p, sinhvien); LuuFileDSLOP(dslop); } else { system("cls"); cout << "Ma dang nhap khong ton tai!"; Sleep(2000); } } }while (1); GiaiPhong(lmh, dslop, lch); return 0; }
[ "hamok17c1dc4@gmail.com" ]
hamok17c1dc4@gmail.com
e61ce102226ddd04848a87199432b36431ed42b0
2cf838b54b556987cfc49f42935f8aa7563ea1f4
/aws-cpp-sdk-pinpoint/source/model/BaseKpiResult.cpp
a483de500be4097d39dfe459cf5290bbfef1d2d1
[ "MIT", "Apache-2.0", "JSON" ]
permissive
QPC-database/aws-sdk-cpp
d11e9f0ff6958c64e793c87a49f1e034813dac32
9f83105f7e07fe04380232981ab073c247d6fc85
refs/heads/main
2023-06-14T17:41:04.817304
2021-07-09T20:28:20
2021-07-09T20:28:20
384,714,703
1
0
Apache-2.0
2021-07-10T14:16:41
2021-07-10T14:16:41
null
UTF-8
C++
false
false
1,350
cpp
/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include <aws/pinpoint/model/BaseKpiResult.h> #include <aws/core/utils/json/JsonSerializer.h> #include <utility> using namespace Aws::Utils::Json; using namespace Aws::Utils; namespace Aws { namespace Pinpoint { namespace Model { BaseKpiResult::BaseKpiResult() : m_rowsHasBeenSet(false) { } BaseKpiResult::BaseKpiResult(JsonView jsonValue) : m_rowsHasBeenSet(false) { *this = jsonValue; } BaseKpiResult& BaseKpiResult::operator =(JsonView jsonValue) { if(jsonValue.ValueExists("Rows")) { Array<JsonView> rowsJsonList = jsonValue.GetArray("Rows"); for(unsigned rowsIndex = 0; rowsIndex < rowsJsonList.GetLength(); ++rowsIndex) { m_rows.push_back(rowsJsonList[rowsIndex].AsObject()); } m_rowsHasBeenSet = true; } return *this; } JsonValue BaseKpiResult::Jsonize() const { JsonValue payload; if(m_rowsHasBeenSet) { Array<JsonValue> rowsJsonList(m_rows.size()); for(unsigned rowsIndex = 0; rowsIndex < rowsJsonList.GetLength(); ++rowsIndex) { rowsJsonList[rowsIndex].AsObject(m_rows[rowsIndex].Jsonize()); } payload.WithArray("Rows", std::move(rowsJsonList)); } return payload; } } // namespace Model } // namespace Pinpoint } // namespace Aws
[ "aws-sdk-cpp-automation@github.com" ]
aws-sdk-cpp-automation@github.com
67e91bbd503f5188c1aabe6388b733d3685025d6
cd35be7ff1ed23004c6bfedab11b49c9a07c48cf
/src/knn.cpp
c504abdf7a23ba6e6e9116a31ae414fe101f3843
[ "MIT" ]
permissive
fernandochafim/cpprtools
f673fa3413ac295c4bb2e5338e6c0f743221d480
ef7628c35fa857dc2a1693b5cab9ec15fde8f4a0
refs/heads/main
2023-01-10T00:07:18.456990
2020-11-14T11:16:21
2020-11-14T11:16:21
312,699,407
0
0
null
null
null
null
UTF-8
C++
false
false
2,762
cpp
#include "knn.h" #include <Eigen/Dense> #include <iostream> int Predict1toMaxNeighbors( double *train_inputs_ptr, double *train_label_ptr, int nrow, int ncol, int max_neighbors, double *test_input_ptr, //ncol //inputs above, outputs below double *test_prediction_ptr //max neighbors ){ Eigen::VectorXd distance_vec(nrow); Eigen::Map< Eigen::MatrixXd > train_inputs_mat(train_inputs_ptr, nrow, ncol); Eigen::Map< Eigen::VectorXd > test_input_vec(test_input_ptr, ncol); Eigen::VectorXd diff_vec(ncol); Eigen::VectorXi sorted_index_vec(nrow); //Compute the distance for(int i=0;i<nrow;i++){ distance_vec(i) = (train_inputs_mat.row(i).transpose()-test_input_vec).lpNorm<1>(); //distance_vec(i) = diff_vec.lpNorm<1>();//computes L1 norm //distance_vec(i) = diff_vec.norm(); //Computes L2 norm sorted_index_vec(i) = i; //initialze sort vec } std::sort(sorted_index_vec.data(), sorted_index_vec.data()+sorted_index_vec.size(), [&distance_vec](int left, int right){ //&distance_vec lets you use distance_vec in this func return distance_vec(left) < distance_vec(right); }); //std:: cout << sorted_index_vec << std::endl << std:: endl; double total_labels = 0.0; // First element to max neighbors for(int k=0; k<max_neighbors; k++){ int row = sorted_index_vec(k); int neighbors = k+1; total_labels+= train_label_ptr[row]; test_prediction_ptr[k]= total_labels/neighbors; } return 0; } int knn( const double *train_inputs_ptr, //n_observations x n_features (Matrix) const double *train_label_ptr, //n_observations (vector) const double *test_input_ptr, //n_features (vector) const int n_observations, const int n_features, const int max_neighbors, double *test_predictions_ptr //max_neighbors (vector) ){ Eigen::Map< Eigen::MatrixXd > train_inputs_mat((double*)train_inputs_ptr, n_observations,n_features); Eigen::Map< Eigen::VectorXd > test_input_vec((double*)test_input_ptr,n_features); Eigen::VectorXd dist_vec(n_observations); Eigen::VectorXi sorted_index_vec(n_observations); for (int i=0; i<n_observations;i++){ dist_vec(i) = (train_inputs_mat.row(i).transpose() - test_input_vec).norm(); sorted_index_vec(i) = i; } std::sort( sorted_index_vec.data(), sorted_index_vec.data()+sorted_index_vec.size(), [&dist_vec](int left, int right){ return dist_vec(left) < dist_vec(right); } ); double total = 0.0; for(int model_i=0; model_i<max_neighbors; model_i++){ int neighbors = model_i +1; int row_i = sorted_index_vec(model_i); total+=train_label_ptr[row_i]; test_predictions_ptr[model_i] = total/neighbors; } return 0; }
[ "fernandochafim@gmail.com" ]
fernandochafim@gmail.com
db8a0009db5a30cc2faacebdb6344a64a5ddd3c5
d4167bc7f153318515b8886ae1308b7b0c654b36
/src/qt/coinmix.cpp
702b5f49cd447fdea4f44dd27cda466859a30af2
[ "MIT" ]
permissive
ElleriumProject/Elleriumv2
c73574c5b23f47e7c07996a66a3144e6c8c6e8b4
08ce46320be8513e1ba04da06f63e66d4bceebc0
refs/heads/master
2021-04-28T09:49:53.158260
2018-09-24T15:39:45
2018-09-24T15:39:45
122,051,835
2
13
null
2018-02-19T11:15:04
2018-02-19T11:15:03
null
UTF-8
C++
false
false
22,667
cpp
// Copyright (c) 2011-2014 The Bitcoin developers // Copyright (c) 2014-2015 The Dash developers // Copyright (c) 2015-2017 The PIVX developers // Copyright (c) 2015-2017 The ALQO developers // Copyright (c) 2017-2018 The Ellerium developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. // #include "coinmix.h" #include "ui_coinmix.h" #include "bitcoinunits.h" #include "clientmodel.h" #include "guiconstants.h" #include "guiutil.h" #include "init.h" // Removing Darksend - BJK // #include "Darksend.h" // #include "Darksendconfig.h" #include "optionsmodel.h" #include "transactionfilterproxy.h" #include "transactiontablemodel.h" #include "walletmodel.h" #include <QAbstractItemDelegate> #include <QPainter> #include <QSettings> #include <QTimer> #define DECORATION_SIZE 48 #define ICON_OFFSET 16 #define NUM_ITEMS 5 /* class TxViewDelegate2 : public QAbstractItemDelegate { Q_OBJECT public: TxViewDelegate2() : QAbstractItemDelegate(), unit(BitcoinUnits::ELP) { } inline void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { painter->save(); QIcon icon = qvariant_cast<QIcon>(index.data(Qt::DecorationRole)); QRect mainRect = option.rect; mainRect.moveLeft(ICON_OFFSET); QRect decorationRect(mainRect.topLeft(), QSize(DECORATION_SIZE, DECORATION_SIZE)); int xspace = DECORATION_SIZE + 8; int ypad = 6; int halfheight = (mainRect.height() - 2 * ypad) / 2; QRect amountRect(mainRect.left() + xspace, mainRect.top() + ypad, mainRect.width() - xspace - ICON_OFFSET, halfheight); QRect addressRect(mainRect.left() + xspace, mainRect.top() + ypad + halfheight, mainRect.width() - xspace, halfheight); icon.paint(painter, decorationRect); QDateTime date = index.data(TransactionTableModel::DateRole).toDateTime(); QString address = index.data(Qt::DisplayRole).toString(); qint64 amount = index.data(TransactionTableModel::AmountRole).toLongLong(); bool confirmed = index.data(TransactionTableModel::ConfirmedRole).toBool(); QVariant value = index.data(Qt::ForegroundRole); QColor foreground = COLOR_BLACK; if (value.canConvert<QBrush>()) { QBrush brush = qvariant_cast<QBrush>(value); foreground = brush.color(); } painter->setPen(foreground); QRect boundingRect; painter->drawText(addressRect, Qt::AlignLeft | Qt::AlignVCenter, address, &boundingRect); if (index.data(TransactionTableModel::WatchonlyRole).toBool()) { QIcon iconWatchonly = qvariant_cast<QIcon>(index.data(TransactionTableModel::WatchonlyDecorationRole)); QRect watchonlyRect(boundingRect.right() + 5, mainRect.top() + ypad + halfheight, 16, halfheight); iconWatchonly.paint(painter, watchonlyRect); } if (amount < 0) { foreground = COLOR_NEGATIVE; } else if (!confirmed) { foreground = COLOR_UNCONFIRMED; } else { foreground = COLOR_BLACK; } painter->setPen(foreground); QString amountText = BitcoinUnits::formatWithUnit(unit, amount, true, BitcoinUnits::separatorAlways); if (!confirmed) { amountText = QString("[") + amountText + QString("]"); } painter->drawText(amountRect, Qt::AlignRight | Qt::AlignVCenter, amountText); painter->setPen(COLOR_BLACK); painter->drawText(amountRect, Qt::AlignLeft | Qt::AlignVCenter, GUIUtil::dateTimeStr(date)); painter->restore(); } inline QSize sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const { return QSize(DECORATION_SIZE, DECORATION_SIZE); } int unit; }; */ #include "coinmix.moc" Coinmix::Coinmix(QWidget* parent) : QWidget(parent), ui(new Ui::Coinmix), clientModel(0), walletModel(0), filter(0) { nDisplayUnit = 0; // just make sure it's not unitialized ui->setupUi(this); // Recent transactions /* ui->listTransactions->setItemDelegate(txdelegate); ui->listTransactions->setIconSize(QSize(DECORATION_SIZE, DECORATION_SIZE)); ui->listTransactions->setMinimumHeight(NUM_ITEMS * (DECORATION_SIZE + 2)); ui->listTransactions->setAttribute(Qt::WA_MacShowFocusRect, false); connect(ui->listTransactions, SIGNAL(clicked(QModelIndex)), this, SLOT(handleTransactionClicked(QModelIndex))); */ // init "out of sync" warning labels //ui->labelWalletStatus->setText("(" + tr("out of sync") + ")"); /* Removing Darksend - BJK ui->labelDarksendSyncStatus->setText("(" + tr("out of sync") + ")"); */ //ui->labelTransactionsStatus->setText("(" + tr("out of sync") + ")"); /* Removing Darksend - BJK if (fLiteMode) { ui->frameDarksend->setVisible(false); } else { if (fMasterNode) { ui->toggleDarksend->setText("(" + tr("Disabled") + ")"); ui->DarksendAuto->setText("(" + tr("Disabled") + ")"); ui->DarksendReset->setText("(" + tr("Disabled") + ")"); ui->frameDarksend->setEnabled(false); } else { if (!fEnableDarksend) { ui->toggleDarksend->setText(tr("Start Darksend")); } else { ui->toggleDarksend->setText(tr("Stop Darksend")); } timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(DarKsendStatus())); timer->start(1000); } } */ // start with displaying the "out of sync" warnings showOutOfSyncWarning(true); } /* void Coinmix::handleTransactionClicked(const QModelIndex& index) { if (filter) emit transactionClicked(filter->mapToSource(index)); } */ Coinmix::~Coinmix() { /* Removing Darksend - BJK if (!fLiteMode && !fMasterNode) disconnect(timer, SIGNAL(timeout()), this, SLOT(DarKsendStatus())); */ delete ui; } void Coinmix::setBalance(const CAmount& balance, const CAmount& unconfirmedBalance, const CAmount& immatureBalance, const CAmount& anonymizedBalance, const CAmount& watchOnlyBalance, const CAmount& watchUnconfBalance, const CAmount& watchImmatureBalance) { currentBalance = balance; currentUnconfirmedBalance = unconfirmedBalance; currentImmatureBalance = immatureBalance; currentAnonymizedBalance = anonymizedBalance; currentWatchOnlyBalance = watchOnlyBalance; currentWatchUnconfBalance = watchUnconfBalance; currentWatchImmatureBalance = watchImmatureBalance; /* ui->labelBalance->setText(BitcoinUnits::floorHtmlWithUnit(nDisplayUnit, balance - immatureBalance, false, BitcoinUnits::separatorAlways)); ui->labelUnconfirmed->setText(BitcoinUnits::floorHtmlWithUnit(nDisplayUnit, unconfirmedBalance, false, BitcoinUnits::separatorAlways)); ui->labelImmature->setText(BitcoinUnits::floorHtmlWithUnit(nDisplayUnit, immatureBalance, false, BitcoinUnits::separatorAlways)); ui->labelAnonymized->setText(BitcoinUnits::floorHtmlWithUnit(nDisplayUnit, anonymizedBalance, false, BitcoinUnits::separatorAlways)); ui->labelTotal->setText(BitcoinUnits::floorHtmlWithUnit(nDisplayUnit, balance + unconfirmedBalance, false, BitcoinUnits::separatorAlways)); ui->labelWatchAvailable->setText(BitcoinUnits::floorHtmlWithUnit(nDisplayUnit, watchOnlyBalance, false, BitcoinUnits::separatorAlways)); ui->labelWatchPending->setText(BitcoinUnits::floorHtmlWithUnit(nDisplayUnit, watchUnconfBalance, false, BitcoinUnits::separatorAlways)); ui->labelWatchImmature->setText(BitcoinUnits::floorHtmlWithUnit(nDisplayUnit, watchImmatureBalance, false, BitcoinUnits::separatorAlways)); ui->labelWatchTotal->setText(BitcoinUnits::floorHtmlWithUnit(nDisplayUnit, watchOnlyBalance + watchUnconfBalance + watchImmatureBalance, false, BitcoinUnits::separatorAlways)); // only show immature (newly mined) balance if it's non-zero, so as not to complicate things // for the non-mining users bool showImmature = immatureBalance != 0; bool showWatchOnlyImmature = watchImmatureBalance != 0; // for symmetry reasons also show immature label when the watch-only one is shown ui->labelImmature->setVisible(showImmature || showWatchOnlyImmature); ui->labelImmatureText->setVisible(showImmature || showWatchOnlyImmature); ui->labelWatchImmature->setVisible(showWatchOnlyImmature); // show watch-only immature balance */ /* Removing Darksend - BJK updateDarksendProgress(); */ /* static int cachedTxLocks = 0; if (cachedTxLocks != nCompleteTXLocks) { cachedTxLocks = nCompleteTXLocks; ui->listTransactions->update(); } */ } // show/hide watch-only labels /* void Coinmix::updateWatchOnlyLabels(bool showWatchOnly) { ui->labelSpendable->setVisible(showWatchOnly); // show spendable label (only when watch-only is active) ui->labelWatchonly->setVisible(showWatchOnly); // show watch-only label ui->lineWatchBalance->setVisible(showWatchOnly); // show watch-only balance separator line ui->labelWatchAvailable->setVisible(showWatchOnly); // show watch-only available balance ui->labelWatchPending->setVisible(showWatchOnly); // show watch-only pending balance ui->labelWatchTotal->setVisible(showWatchOnly); // show watch-only total balance if (!showWatchOnly) { ui->labelWatchImmature->hide(); } else { ui->labelBalance->setIndent(20); ui->labelUnconfirmed->setIndent(20); ui->labelImmature->setIndent(20); ui->labelTotal->setIndent(20); } } */ /* void Coinmix::setClientModel(ClientModel* model) { this->clientModel = model; if (model) { // Show warning if this is a prerelease version connect(model, SIGNAL(alertsChanged(QString)), this, SLOT(updateAlerts(QString))); updateAlerts(model->getStatusBarWarnings()); } } */ void Coinmix::setWalletModel(WalletModel* model) { this->walletModel = model; if (model && model->getOptionsModel()) { // Set up transaction list filter = new TransactionFilterProxy(); filter->setSourceModel(model->getTransactionTableModel()); filter->setLimit(NUM_ITEMS); filter->setDynamicSortFilter(true); filter->setSortRole(Qt::EditRole); filter->setShowInactive(false); //filter->sort(TransactionTableModel::Date, Qt::DescendingOrder); // ui->listTransactions->setModel(filter); // ui->listTransactions->setModelColumn(TransactionTableModel::ToAddress); // Keep up to date with wallet /* setBalance(model->getBalance(), model->getUnconfirmedBalance(), model->getImmatureBalance(), model->getAnonymizedBalance(), model->getWatchBalance(), model->getWatchUnconfirmedBalance(), model->getWatchImmatureBalance()); */ //connect(model, SIGNAL(balanceChanged(CAmount, CAmount, CAmount, CAmount, CAmount, CAmount, CAmount)), this, SLOT(setBalance(CAmount, CAmount, CAmount, CAmount, CAmount, CAmount, CAmount))); //connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); /* Removing Darksend - BJK connect(ui->DarksendAuto, SIGNAL(clicked()), this, SLOT(DarksendAuto())); connect(ui->DarksendReset, SIGNAL(clicked()), this, SLOT(DarksendReset())); connect(ui->toggleDarksend, SIGNAL(clicked()), this, SLOT(toggleDarksend())); */ // updateWatchOnlyLabels(model->haveWatchOnly()); //connect(model, SIGNAL(notifyWatchonlyChanged(bool)), this, SLOT(updateWatchOnlyLabels(bool))); } // update the display unit, to not use the default ("ELP") //updateDisplayUnit(); } /* void Coinmix::updateDisplayUnit() { if (walletModel && walletModel->getOptionsModel()) { nDisplayUnit = walletModel->getOptionsModel()->getDisplayUnit(); if (currentBalance != -1) setBalance(currentBalance, currentUnconfirmedBalance, currentImmatureBalance, currentAnonymizedBalance, currentWatchOnlyBalance, currentWatchUnconfBalance, currentWatchImmatureBalance); Update txdelegate->unit with the current unit txdelegate->unit = nDisplayUnit; ui->listTransactions->update(); } } */ /* void Coinmix::updateAlerts(const QString& warnings) { this->ui->labelAlerts->setVisible(!warnings.isEmpty()); this->ui->labelAlerts->setText(warnings); } */ void Coinmix::showOutOfSyncWarning(bool fShow) { // ui->labelWalletStatus->setVisible(fShow); /* Removing Darksend - BJK ui->labelDarksendSyncStatus->setVisible(fShow); */ //ui->labelTransactionsStatus->setVisible(fShow); } /* Removing Darksend - BJK void Coinmix::updateDarksendProgress() { if (!masternodeSync.IsBlockchainSynced() || ShutdownRequested()) return; if (!pwalletMain) return; QString strAmountAndRounds; QString strAnonymizeAmount = BitcoinUnits::formatHtmlWithUnit(nDisplayUnit, nAnonymizeAmount * COIN, false, BitcoinUnits::separatorAlways); if (currentBalance == 0) { ui->DarksendProgress->setValue(0); ui->DarksendProgress->setToolTip(tr("No inputs detected")); // when balance is zero just show info from settings strAnonymizeAmount = strAnonymizeAmount.remove(strAnonymizeAmount.indexOf("."), BitcoinUnits::decimals(nDisplayUnit) + 1); strAmountAndRounds = strAnonymizeAmount + " / " + tr("%n Rounds", "", nDarksendRounds); ui->labelAmountRounds->setToolTip(tr("No inputs detected")); ui->labelAmountRounds->setText(strAmountAndRounds); return; } CAmount nDenominatedConfirmedBalance; CAmount nDenominatedUnconfirmedBalance; CAmount nAnonymizableBalance; CAmount nNormalizedAnonymizedBalance; double nAverageAnonymizedRounds; { TRY_LOCK(cs_main, lockMain); if (!lockMain) return; nDenominatedConfirmedBalance = pwalletMain->GetDenominatedBalance(); nDenominatedUnconfirmedBalance = pwalletMain->GetDenominatedBalance(true); nAnonymizableBalance = pwalletMain->GetAnonymizableBalance(); nNormalizedAnonymizedBalance = pwalletMain->GetNormalizedAnonymizedBalance(); nAverageAnonymizedRounds = pwalletMain->GetAverageAnonymizedRounds(); } CAmount nMaxToAnonymize = nAnonymizableBalance + currentAnonymizedBalance + nDenominatedUnconfirmedBalance; // If it's more than the anon threshold, limit to that. if (nMaxToAnonymize > nAnonymizeAmount * COIN) nMaxToAnonymize = nAnonymizeAmount * COIN; if (nMaxToAnonymize == 0) return; if (nMaxToAnonymize >= nAnonymizeAmount * COIN) { ui->labelAmountRounds->setToolTip(tr("Found enough compatible inputs to anonymize %1") .arg(strAnonymizeAmount)); strAnonymizeAmount = strAnonymizeAmount.remove(strAnonymizeAmount.indexOf("."), BitcoinUnits::decimals(nDisplayUnit) + 1); strAmountAndRounds = strAnonymizeAmount + " / " + tr("%n Rounds", "", nDarksendRounds); } else { QString strMaxToAnonymize = BitcoinUnits::formatHtmlWithUnit(nDisplayUnit, nMaxToAnonymize, false, BitcoinUnits::separatorAlways); ui->labelAmountRounds->setToolTip(tr("Not enough compatible inputs to anonymize <span style='color:red;'>%1</span>,<br>" "will anonymize <span style='color:red;'>%2</span> instead") .arg(strAnonymizeAmount) .arg(strMaxToAnonymize)); strMaxToAnonymize = strMaxToAnonymize.remove(strMaxToAnonymize.indexOf("."), BitcoinUnits::decimals(nDisplayUnit) + 1); strAmountAndRounds = "<span style='color:red;'>" + QString(BitcoinUnits::factor(nDisplayUnit) == 1 ? "" : "~") + strMaxToAnonymize + " / " + tr("%n Rounds", "", nDarksendRounds) + "</span>"; } ui->labelAmountRounds->setText(strAmountAndRounds); // calculate parts of the progress, each of them shouldn't be higher than 1 // progress of denominating float denomPart = 0; // mixing progress of denominated balance float anonNormPart = 0; // completeness of full amount anonimization float anonFullPart = 0; CAmount denominatedBalance = nDenominatedConfirmedBalance + nDenominatedUnconfirmedBalance; denomPart = (float)denominatedBalance / nMaxToAnonymize; denomPart = denomPart > 1 ? 1 : denomPart; denomPart *= 100; anonNormPart = (float)nNormalizedAnonymizedBalance / nMaxToAnonymize; anonNormPart = anonNormPart > 1 ? 1 : anonNormPart; anonNormPart *= 100; anonFullPart = (float)currentAnonymizedBalance / nMaxToAnonymize; anonFullPart = anonFullPart > 1 ? 1 : anonFullPart; anonFullPart *= 100; // apply some weights to them ... float denomWeight = 1; float anonNormWeight = nDarksendRounds; float anonFullWeight = 2; float fullWeight = denomWeight + anonNormWeight + anonFullWeight; // ... and calculate the whole progress float denomPartCalc = ceilf((denomPart * denomWeight / fullWeight) * 100) / 100; float anonNormPartCalc = ceilf((anonNormPart * anonNormWeight / fullWeight) * 100) / 100; float anonFullPartCalc = ceilf((anonFullPart * anonFullWeight / fullWeight) * 100) / 100; float progress = denomPartCalc + anonNormPartCalc + anonFullPartCalc; if (progress >= 100) progress = 100; ui->DarksendProgress->setValue(progress); QString strToolPip = ("<b>" + tr("Overall progress") + ": %1%</b><br/>" + tr("Denominated") + ": %2%<br/>" + tr("Mixed") + ": %3%<br/>" + tr("Anonymized") + ": %4%<br/>" + tr("Denominated inputs have %5 of %n rounds on average", "", nDarksendRounds)) .arg(progress) .arg(denomPart) .arg(anonNormPart) .arg(anonFullPart) .arg(nAverageAnonymizedRounds); ui->DarksendProgress->setToolTip(strToolPip); } void Coinmix::DarKsendStatus() { static int64_t nLastDSProgressBlockTime = 0; int nBestHeight = chainActive.Tip()->nHeight; // we we're processing more then 1 block per second, we'll just leave if (((nBestHeight - DarKsendPool.cachedNumBlocks) / (GetTimeMillis() - nLastDSProgressBlockTime + 1) > 1)) return; nLastDSProgressBlockTime = GetTimeMillis(); if (!fEnableDarksend) { if (nBestHeight != DarKsendPool.cachedNumBlocks) { DarKsendPool.cachedNumBlocks = nBestHeight; updateDarksendProgress(); ui->DarksendEnabled->setText(tr("Disabled")); ui->DarksendStatus->setText(""); ui->toggleDarksend->setText(tr("Start Darksend")); } return; } // check Darksend status and unlock if needed if (nBestHeight != DarKsendPool.cachedNumBlocks) { // Balance and number of transactions might have changed DarKsendPool.cachedNumBlocks = nBestHeight; updateDarksendProgress(); ui->DarksendEnabled->setText(tr("Enabled")); } QString strStatus = QString(DarKsendPool.GetStatus().c_str()); QString s = tr("Last Darksend message:\n") + strStatus; if (s != ui->DarksendStatus->text()) LogPrintf("Last Darksend message: %s\n", strStatus.toStdString()); ui->DarksendStatus->setText(s); if (DarKsendPool.sessionDenom == 0) { ui->labelSubmittedDenom->setText(tr("N/A")); } else { std::string out; DarKsendPool.GetDenominationsToString(DarKsendPool.sessionDenom, out); QString s2(out.c_str()); ui->labelSubmittedDenom->setText(s2); } } void Coinmix::DarksendAuto() { DarKsendPool.DoAutomaticDenominating(); } void Coinmix::DarksendReset() { DarKsendPool.Reset(); QMessageBox::warning(this, tr("Darksend"), tr("Darksend was successfully reset."), QMessageBox::Ok, QMessageBox::Ok); } void Coinmix::toggleDarksend() { QSettings settings; // Popup some information on first mixing QString hasMixed = settings.value("hasMixed").toString(); if (hasMixed.isEmpty()) { QMessageBox::information(this, tr("Darksend"), tr("If you don't want to see internal Darksend fees/transactions select \"Most Common\" as Type on the \"Transactions\" tab."), QMessageBox::Ok, QMessageBox::Ok); settings.setValue("hasMixed", "hasMixed"); } if (!fEnableDarksend) { int64_t balance = currentBalance; float minAmount = 14.90 * COIN; if (balance < minAmount) { QString strMinAmount(BitcoinUnits::formatWithUnit(nDisplayUnit, minAmount)); QMessageBox::warning(this, tr("Darksend"), tr("Darksend requires at least %1 to use.").arg(strMinAmount), QMessageBox::Ok, QMessageBox::Ok); return; } // if wallet is locked, ask for a passphrase if (walletModel->getEncryptionStatus() == WalletModel::Locked) { WalletModel::UnlockContext ctx(walletModel->requestUnlock(false)); if (!ctx.isValid()) { //unlock was cancelled DarKsendPool.cachedNumBlocks = std::numeric_limits<int>::max(); QMessageBox::warning(this, tr("Darksend"), tr("Wallet is locked and user declined to unlock. Disabling Darksend."), QMessageBox::Ok, QMessageBox::Ok); if (fDebug) LogPrintf("Wallet is locked and user declined to unlock. Disabling Darksend.\n"); return; } } } fEnableDarksend = !fEnableDarksend; DarKsendPool.cachedNumBlocks = std::numeric_limits<int>::max(); if (!fEnableDarksend) { ui->toggleDarksend->setText(tr("Start Darksend")); DarKsendPool.UnlockCoins(); } else { ui->toggleDarksend->setText(tr("Stop Darksend")); //show Darksend configuration if client has defaults set if (nAnonymizeAmount == 0) { DarksendConfig dlg(this); dlg.setModel(walletModel); dlg.exec(); } } } */
[ "" ]
8fae81e39905f8eda0d6a37f96f9f230b44c74ed
7d6b87d5ec5de7b213d1817a2895689742d85006
/c++11/threadTest.cpp
6f8a12596b306c46cf3191e4ef07617b32612dc4
[]
no_license
vpiyush/SandBox
5de07c9ba6901f7ed9c0aeb71f0e938b6845d780
691bce67a82c3fb67064600181e9145244668f3e
refs/heads/master
2022-02-01T20:55:05.700118
2022-01-04T05:11:03
2022-01-04T05:11:03
55,050,893
1
0
null
null
null
null
UTF-8
C++
false
false
495
cpp
#include <iostream> #include <thread> #include <chrono> void foo() { std::this_thread::sleep_for(std::chrono::seconds(1)); } int main() { std::thread *t; std::cout << "before starting, joinable: " << std::boolalpha << t.joinable() << '\n'; t = new std::thread(foo); std::cout << "after starting, joinable: " << t.joinable() << '\n'; sleep(2); std::cout << "after joining, joinable: " << t.joinable() << '\n'; return 0; }
[ "piyush@telaverge.com" ]
piyush@telaverge.com
e542923dc7719a2d6f0fce8084f10e019cfd8dc6
a313ef189b21ce8b34166678c84191fce9fb7e00
/include/hps-1.0.0/src/container/pair_serializer.h
8eafdffad9e79320f8702ff3432bb40985714902
[ "MIT", "Apache-2.0" ]
permissive
mihneasaracin/Distributed-CSP
9eee3d13b4c525b10a05aaea90dfff56a34feb54
8e4b0cc9e70cbc2451463458aa07c60d66a78c7c
refs/heads/main
2023-03-17T11:21:40.917769
2021-03-17T23:08:36
2021-03-17T23:08:36
338,822,899
0
0
null
null
null
null
UTF-8
C++
false
false
605
h
#pragma once #include <iostream> #include <utility> #include "../basic_type/uint_serializer.h" #include "../serializer.h" namespace hps { template <class T1, class T2, class B> class Serializer<std::pair<T1, T2>, B> { public: static void serialize(const std::pair<T1, T2>& container, B& ob) { Serializer<T1, B>::serialize(container.first, ob); Serializer<T2, B>::serialize(container.second, ob); } static void parse(std::pair<T1, T2>& container, B& ib) { Serializer<T1, B>::parse(container.first, ib); Serializer<T2, B>::parse(container.second, ib); } }; } // namespace hps
[ "mihneasaracin@yahoo.com" ]
mihneasaracin@yahoo.com
a122dcb5c8b371b749812dbbd679ea8aa09281a4
c18fe82db18be9ac493d94362e5f08ae676a5b9a
/algorithms/sorting/quick_sort.hpp
fa5e0f69db4871e735843acfd2fd0760b8ca8f7f
[]
no_license
charlesq/Euthenia
e05347d8dadd3249d06aece62d28bf3e10866339
5ca738a249215c439156e29dca495840a6488cbb
refs/heads/master
2021-01-15T19:40:13.679311
2019-01-21T04:05:11
2019-01-21T04:05:11
15,544,644
0
0
null
null
null
null
UTF-8
C++
false
false
1,081
hpp
#ifndef __QUICK_SORT_H__ #define __QUICK_SORT_H__ #include <base_sort.hpp> /********************** Quick Sort ********************************/ class quick_sort: public base_sort { size_t partition(size_t start, size_t end) { size_t i = start, j = i; while(++j < end) { if (a[j] < a[start]) std::swap(a[++i], a[j]); } std::swap(a[i], a[start]); return i; }; /* sort elements in [start,end) */ void sort(size_t start, size_t end) { /* recursion terminating condition */ if (end <= start +1) return; /* randomly pick a pivot element */ size_t p = rand() % (end - start) + start; std::swap(a[start], a[p]); /*divide into two sub arrays, sorting procedure occurs inside */ p = partition(start, end); /* conquer each sub array ? */ sort(start, p); sort(p+1, end); }; public: quick_sort(int *ar, size_t s):base_sort(ar, s) {}; void operator () (void) { sort(0, sz); }; }; #endif
[ "charles.zeng@yahoo.com" ]
charles.zeng@yahoo.com
5c1d84d4a0900428df87ba31f6013a9aaa7c6697
c76faa4bd9631d7b1dde3aa8cf1a5ece3e035a28
/src/fast4/mriseg_two.cc
42e5c715df16999d7a5512d7cf13d488f25dafd1
[]
no_license
GunioRobot/fsl
e5a01d9d9d477af931c3ef858163438d883e9b3b
5268b5cbc7434522571e04b5c3faf73ed5bce1ba
HEAD
2016-09-10T01:39:43.823129
2010-08-20T05:14:24
2010-08-20T05:14:24
3,315,212
0
0
null
null
null
null
UTF-8
C++
false
false
29,951
cc
/* FAST4 - FMRIB's Automated Segmentation Tool v4 John Vickers, Mark Jenkinson, Steve Smith and Matthew Webster FMRIB Image Analysis Group Copyright (C) 2005-2007 University of Oxford */ /* Part of FSL - FMRIB's Software Library http://www.fmrib.ox.ac.uk/fsl fsl@fmrib.ox.ac.uk Developed at FMRIB (Oxford Centre for Functional Magnetic Resonance Imaging of the Brain), Department of Clinical Neurology, Oxford University, Oxford, UK LICENCE FMRIB Software Library, Release 4.0 (c) 2007, The University of Oxford (the "Software") The Software remains the property of the University of Oxford ("the University"). The Software is distributed "AS IS" under this Licence solely for non-commercial use in the hope that it will be useful, but in order that the University as a charitable foundation protects its assets for the benefit of its educational and research purposes, the University makes clear that no condition is made or to be implied, nor is any warranty given or to be implied, as to the accuracy of the Software, or that it will be suitable for any particular purpose or for use under any specific conditions. Furthermore, the University disclaims all responsibility for the use which is made of the Software. It further disclaims any liability for the outcomes arising from using the Software. The Licensee agrees to indemnify the University and hold the University harmless from and against any and all claims, damages and liabilities asserted by third parties (including claims for negligence) which arise directly or indirectly from the use of the Software or the sale of any products based on the Software. No part of the Software may be reproduced, modified, transmitted or transferred in any form or by any means, electronic or mechanical, without the express permission of the University. The permission of the University is not required if the said reproduction, modification, transmission or transference is done without financial return, the conditions of this Licence are imposed upon the receiver of the product, and all original and amended source code is included in any transmitted product. You may be held legally responsible for any copyright infringement that is caused or encouraged by your failure to abide by these terms and conditions. You are not permitted under this Licence to use this Software commercially. Use for which any financial return is received shall be defined as commercial use, and includes (1) integration of all or part of the source code or the Software into a product for sale or license by or on behalf of Licensee to third parties or (2) use of the Software or any derivative of it for research with the final aim of developing software products for sale or license to a third party or (3) use of the Software or any derivative of it for research with the final aim of developing non-software products for sale or license to a third party, or (4) use of the Software to provide any service to an external organisation for which payment is received. If you are interested in using the Software commercially, please contact Isis Innovation Limited ("Isis"), the technology transfer company of the University, to negotiate a licence. Contact details are: innovation@isis.ox.ac.uk quoting reference DE/1112. */ #include "mriseg_two.h" #include "newimage/newimageall.h" #include <stdio.h> #include <stdlib.h> #include <iostream> #include <algorithm> using namespace NEWIMAGE; using namespace std; ZMRISegmentation::ZMRISegmentation(){} const float PI=3.14159265; ///////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////Tanaka Start///////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////// void ZMRISegmentation::TanakaCreate(const NEWIMAGE::volume<float>& image, float fbeta, int nclasses, float nblowpass, bool bbias, int biterationspve, float mixeltypeMRF, int nbiter, int initinitfixed, int winitfixed, int bapused, float Hyp, bool verb,string mansegfle,int typeoffile) { mansegfile=mansegfle; bapusedflag=bapused; nClasses=nclasses; imagetype=typeoffile; m_Mricopy=volume<float>(image); m_Mri=volume<float>(image); m_nWidth=image.xsize(); m_nHeight=image.ysize(); m_nDepth=image.zsize(); m_nxdim=image.xdim(); m_nydim=image.ydim(); m_nzdim=image.zdim(); m_post=volume4D<float>(m_nWidth, m_nHeight, m_nDepth, nClasses+1); m_post.copyproperties(m_Mri); m_prob=volume4D<float>(m_nWidth, m_nHeight, m_nDepth, nClasses+1); m_prob.copyproperties(m_Mri); m_BiasField=volume<float>(m_nWidth, m_nHeight, m_nDepth); m_BiasField.copyproperties(m_Mri); m_mask=image; m_mask.binarise(0,m_mask.max()+1,exclusive); nvoxel=(long)m_mask.sum(); m_Segment=volume<int>(m_nWidth, m_nHeight, m_nDepth); copybasicproperties(m_mask,m_Segment); members=volume4D<float>(m_nWidth, m_nHeight, m_nDepth, nClasses); iterationspve=biterationspve; if(iterationspve>0) { m_pveSegment=volume<int>(m_nWidth, m_nHeight, m_nDepth); m_pveSegment.copyproperties(m_Segment); } pveBmixeltype=mixeltypeMRF; inititerations=winitfixed; initfixed=initinitfixed; m_nbIter=nbiter; biasfieldremoval=bbias; beta=fbeta; m_nbLowpass=nblowpass; if(bapusedflag>0) { talpriors=volume4D<float>(m_nWidth, m_nHeight, m_nDepth, nClasses+1); talpriors.copyproperties(m_post); } Hyper=Hyp; verboseusage=verb; } int ZMRISegmentation::TanakaMain(NEWIMAGE::volume<float>& pcsf, NEWIMAGE::volume<float>& pgm, NEWIMAGE::volume<float>& pwm) { for(int z=0;z<m_nDepth;z++) for(int y=0;y<m_nHeight;y++) for(int x=0;x<m_nWidth;x++) if(m_Mricopy.value(x, y, z)>0.0) m_Mricopy.value(x, y, z)=log(m_Mricopy.value(x, y, z) + 1.0); else m_Mricopy.value(x, y, z)=0.0f; m_Mri=volume<float>(m_Mricopy); Dimensions(); long seed=-1; srand(seed); rhs.resize(100); volumequant.resize(nClasses+1); m_mean.resize(nClasses+1,0); m_variance.resize(nClasses+1,0); weight.resize(nClasses,1); if(bapusedflag==0) { try{Initialise();} catch (kmeansexception& km){cout << km.what() << endl ; return 1;} } else { InitSimple(pcsf, pgm, pwm); pcsf.destroy(); pgm.destroy(); pwm.destroy(); } if(Hyper<0.0) TanakaPriorHyper(); InitKernel(m_nbLowpass); // first loop to remove bias field BiasRemoval(); for (int n=1; n<=nClasses; n++) if(isnan(m_mean[n]) || isnan(m_variance[n]) ) cout << "MeaNsK variance nan" << endl; for(int iter=0;iter<m_nbIter;iter++) { if(verboseusage) cout<<"Tanaka Iteration "<<iter<<" bias field "<<m_nbIter<<endl; TanakaIterations(); BiasRemoval(); MeansVariances(nClasses, m_post); } // second loop to estimate hyperparameter for(int iter=0;iter<initfixed;iter++) { if(verboseusage) cout<<"Tanaka Iteration "<<iter<<" hyperparameter "<<initfixed<<endl; TanakaIterations(); if(Hyper>=0.0) beta=Hyper; else TanakaHyper(); if(verboseusage) cout<<" BETA "<<beta<<endl; MeansVariances(nClasses, m_post); } qsort(); Classification(); if(iterationspve>0) { if(verboseusage) cout<< " Starting Partial Volume Estimation \n"; UpdateMembers(m_post); for(int z=0;z<m_nDepth;z++) for(int y=0;y<m_nHeight;y++) for(int x=0;x<m_nWidth;x++) if(m_mask(x, y, z)==1) m_Mri.value(x, y, z)=exp(m_Mri.value(x, y, z)); MeansVariances(nClasses, m_post); PVClassificationStep(); PVestimation(); calculateVolumes(m_pve); pveClassification(); } else calculateVolumes(m_post); if(verboseusage) printVolumeTotals(); takeexpo(); return 0; } void ZMRISegmentation::BiasRemoval() { m_BiasField=0; if(biasfieldremoval) { volume<float> p_meaninvcov(m_BiasField),p_resmean(m_BiasField); for(int z=0;z<m_nDepth;z++) for(int y=0;y<m_nHeight;y++) for(int x=0;x<m_nWidth;x++) if(m_mask.value(x, y, z)==1) for(int c=1;c<nClasses+1;c++) { float tempf=m_post(x, y, z, c)/m_variance[c]; p_meaninvcov.value(x, y, z)+=tempf; p_resmean.value(x, y, z)+=tempf*(m_Mricopy.value(x, y, z)-m_mean[c]); } p_meaninvcov=Convolve(p_meaninvcov); p_resmean=Convolve(p_resmean); m_BiasField=divide(p_resmean,p_meaninvcov,m_mask); m_BiasField-=m_BiasField.mean(m_mask); // subtract off within-mask mean of m_BiasField m_BiasField*=m_mask; //Zero out regions outside of mask ( is this needed?) m_Mri=m_Mricopy-m_BiasField; } } void ZMRISegmentation::Classification() { for(int z=0;z<m_nDepth;z++) for(int y=0;y<m_nHeight;y++) for(int x=0;x<m_nWidth;x++) Classification(x,y,z); } void ZMRISegmentation::Classification(int x, int y, int z) { float max=-1e-10; m_Segment(x, y, z)=0; if(m_mask(x, y, z)==1) for(int c=1;c<=nClasses;c++) if(m_post(x, y, z, c)>max) { max=m_post(x, y, z, c); m_Segment(x, y, z)=c; } } NEWIMAGE::volume<float> ZMRISegmentation::Convolve(NEWIMAGE::volume<float>& resfieldimage) { return convolve_separable(resfieldimage, kernelx, kernely, kernelz); } void ZMRISegmentation::Dimensions() { amz=1.0/m_nzdim; amy=1.0/m_nydim; amzy=1.0/sqrt(m_nzdim*m_nzdim+m_nydim*m_nydim); amx=1.0/m_nxdim; amzx=1.0/sqrt(m_nzdim*m_nzdim+m_nxdim*m_nxdim); amxy=1.0/sqrt(m_nxdim*m_nxdim+m_nydim*m_nydim); } void ZMRISegmentation::Initialise() { WeightedKMeans(); Initclass(); Classification(); } void ZMRISegmentation::pveClassification(int x, int y, int z) { float max=-1e-10; m_pveSegment(x, y, z)=0; if(m_mask(x, y, z)==1) for(int c=1;c<=nClasses;c++) if(m_pve(x, y, z, c)>max) { max=m_pve(x, y, z, c); m_pveSegment(x, y, z)=c; } } void ZMRISegmentation::pveClassification() { for(int x=0;x<m_nWidth;x++) for(int y=0;y<m_nHeight;y++) for(int z=0;z<m_nDepth;z++) pveClassification(x, y, z); } float ZMRISegmentation::logGaussian(float y, float mu, float sigmasq) { float scaletemp=1.0*log(sqrt(2.0*PI*(sigmasq))); float gausstemp=(y-(mu)); gausstemp=0.5*gausstemp*gausstemp/(sigmasq); return scaletemp+gausstemp; } float ZMRISegmentation::MRFWeightsTotal() { double total=0.0f; //Internally a double to avoid truncation when adding small to large (shouldn't happen anyway with this loop style) for(int z=0;z<m_nDepth;z++) for(int y=0;y<m_nHeight;y++) for(int x=0;x<m_nWidth;x++) if(m_mask.value(x, y, z)==1) for(int c=1;c<=nClasses;c++) total+=MRFWeightsInner(x,y,z,c)*m_post(x, y, z, c); return (float)total; } double ZMRISegmentation::MRFWeightsInner(const int x, const int y, const int z,const int c) { double inner=0.0f; for(int n=-1;n<=1;n++) for(int m=-1;m<=1;m++) for(int l=-1;l<=1;l++) if((m_mask(x+l, y+m, z+n)==1)) inner+=MRFWeightsAM(l,m,n)*m_post.value(x+l, y+m, z+n, c); return inner; } double ZMRISegmentation::MRFWeightsAM(const int l, const int m, const int n) { double am=0.0f; if((l==0)) { if(((m==0)&&(n!=0)))am=amz; if(((m!=0)&&(n==0)))am=amy; if(((m!=0)&&(n!=0)))am=amzy; } if((m==0)) { if(((l!=0)&&(n==0)))am=amx; if(((l!=0)&&(n!=0)))am=amzx; } if((n==0)) { if(((m!=0)&&(l!=0)))am=amxy; } return am; } void ZMRISegmentation::TanakaHyper() { float total=MRFWeightsTotal(); float betahtemp=0.0f; beta=betahtemp; float min=abs(total-rhs[0]); cout << " TOTAL " << total << " RHS "; for(int betahyp=0;betahyp<15;betahyp++) cout << rhs[betahyp] << " "; cout << endl; for(int betahyp=1;betahyp<15;betahyp++) { //float betahtemp=(float)(0.05*(float)betahyp); betahtemp+=(float)0.05; cerr << betahtemp << " " << betahtemp << endl; if(abs(total-rhs[betahyp])<min) { beta=betahtemp; min=abs(total-rhs[betahyp]); } } } void ZMRISegmentation::TanakaPriorHyper() { float betahtemp=0.0f; for(int betahyp=0;betahyp<15;betahyp++) { for(int z=0;z<m_nDepth;z++) { for(int y=0;y<m_nHeight;y++) { for(int x=0;x<m_nWidth;x++) { m_prob(x, y, z, 0)=0.0f; float sum=0.0f; for(int c=1;c<=nClasses;c++) { if(m_mask(x, y, z)==1) { sum+=m_prob(x, y, z, c)=(float)(rand()/(float)(RAND_MAX)); } else m_prob(x, y, z, c)=0.0f; } for(int c=1;c<=nClasses;c++) if(sum>0.0) m_prob(x, y, z, c)/=sum; } } } for(int iteration=0;iteration<5;iteration++) { m_post=m_prob; if(verboseusage) cout << "Tanaka-inner-loop-iteration=" << iteration << " MRFWeightsTotal=" << MRFWeightsTotal() << " beta=" << betahtemp << endl; for(int z=0;z<m_nDepth;z++) { for(int y=0;y<m_nHeight;y++) { for(int x=0;x<m_nWidth;x++) { float sum=0.0f; if(m_mask.value(x, y, z)==1) { for(int c=1;c<=nClasses;c++) { float post=MRFWeightsInner(x,y,z,c); if(bapusedflag<2) sum+=m_prob.value(x, y, z, c)=exp(betahtemp*post); else sum+=m_prob.value(x, y, z, c)=talpriors(x, y, z ,c)*exp(betahtemp*post); } for(int c=1;c<=nClasses;c++) { if(sum>0.0f) m_prob.value(x, y, z, c)/=sum; else m_prob.value(x, y, z, c)=0.0f; } } } } } } m_post=m_prob; rhs[betahyp] = MRFWeightsTotal(); betahtemp+=0.05; } } void ZMRISegmentation::TanakaIterations() { m_post=0; for(int z=0;z<m_nDepth;z++) for(int y=0;y<m_nHeight;y++) for(int x=0;x<m_nWidth;x++) if(m_mask(x,y,z)==1) { float sum=0.0f; for(int c=1;c<=nClasses;c++) sum+=m_post(x, y, z, c)=(float)(rand()/(float)(RAND_MAX)); for(int c=1;c<=nClasses && sum>0;c++) m_post(x, y, z, c)/=sum; } for(int iteration=0;iteration<5;iteration++) { for(int z=0;z<m_nDepth;z++) for(int y=0;y<m_nHeight;y++) for(int x=0;x<m_nWidth;x++) if(m_mask.value(x, y, z)==1) { double sum=0.0f; //Very important for sum to be a double for JV's loop ( if sum is a double there as well ) and mine to match results - numerically sensitive for(int c=1;c<=nClasses;c++) { m_post.value(x, y, z, c)=exp(beta*MRFWeightsInner(x,y,z,c)-logGaussian(m_Mri.value(x, y, z), m_mean[c], m_variance[c])); if(bapusedflag>=2) m_post.value(x, y, z, c)*=talpriors(x, y, z, c); sum+=m_post.value(x, y, z, c); } for(int c=1;c<=nClasses;c++) { if(sum>0.0f) m_post.value(x, y, z, c)/=sum; else m_post.value(x, y, z, c)=0.0f; } } if(verboseusage) cout << "Tanaka-inner-loop-iteration=" << iteration << " MRFWeightsTotal=" << MRFWeightsTotal() << " beta=" << beta << endl; } if(verboseusage) { for(int c=1;c<=nClasses;c++) cout<<" CLASS "<<c<<" MEAN "<<exp(m_mean[c])<<" STDDEV "<<( exp(m_mean[c] + sqrt(m_variance[c]) ) - exp(m_mean[c]-sqrt(m_variance[c])) )/2; cout<<endl; } } float ZMRISegmentation::PVEnergy(int x, int y, int z, float mu, float sigmasq) { float temp=m_Mri(x, y, z)-mu; float cond=((temp*temp)/sigmasq +log(sigmasq))/2.0; return cond; } void ZMRISegmentation::PVClassificationStep() { int mixnum=0; if(nClasses==3) mixnum=6; if(nClasses==2 || nClasses>3) mixnum=2*nClasses-1; PVprob.reinitialize(m_nWidth, m_nHeight, m_nDepth, mixnum); PVprob=0.0; for(int z=0;z<m_nDepth;z++) for(int y=0;y<m_nHeight;y++) for(int x=0;x<m_nWidth;x++) if(m_mask.value(x, y, z)==1) for(int type=0;type<mixnum;type++) { if(type<nClasses) PVprob(x, y, z, type)=exp(-1.0*logGaussian(m_Mri(x, y, z), m_mean[type+1], m_variance[type+1])); else if(nClasses==3) { float mu=0.0f; float sigsq=0.0f; for(float delta=0.0;delta<=1.0;delta+=0.01) { if(type==3) { mu=delta*m_mean[1]+(1-delta)*m_mean[2]; sigsq=delta*delta*m_variance[1]+(1-delta)*(1-delta)*m_variance[2]; } if(type==4) { mu=delta*m_mean[1]+(1-delta)*m_mean[3]; sigsq=delta*delta*m_variance[1]+(1-delta)*(1-delta)*m_variance[3]; } if(type==5) { mu=delta*m_mean[2]+(1-delta)*m_mean[3]; sigsq=delta*delta*m_variance[2]+(1-delta)*(1-delta)*m_variance[3]; } PVprob(x, y, z, type)+=exp(-1.0*logGaussian(m_Mri(x, y, z), mu, sigsq))*0.01; } } else if(nClasses==2 || nClasses>3) { float mu=0.0f; float sigsq=0.0f; for(float delta=0.0;delta<=1.0;delta+=0.01) { mu=delta*m_mean[type-nClasses+1]+(1-delta)*m_mean[type-nClasses+2]; sigsq=delta*delta*m_variance[type-nClasses+1]+(1-delta)*(1-delta)*m_variance[type-nClasses+2]; PVprob(x, y, z, type)+=exp(-1.0*logGaussian(m_Mri(x, y, z), mu, sigsq))*0.01; } } } ICMPV(); } void ZMRISegmentation::ICMPV() { hardPV=volume<int>(m_nWidth, m_nHeight, m_nDepth); hardPV.copyproperties(m_Segment); int mixnum=0; if(nClasses==3) mixnum=6; if(nClasses==2) mixnum=3; if(nClasses>3) mixnum=2*nClasses-1; float* clique=new float[mixnum]; for(int z=0;z<m_nDepth;z++) for(int y=0;y<m_nHeight;y++) for(int x=0;x<m_nWidth;x++) if(m_mask.value(x, y, z)==1) { float max=-1.0; for(int type=0;type<mixnum;type++) if(max<PVprob(x, y, z, type)) { hardPV(x, y, z)=type; max=PVprob(x, y, z, type); } } for(int iter=0;iter<1;iter++) for(int z=0;z<m_nDepth;z++) for(int y=0;y<m_nHeight;y++) for(int x=0;x<m_nWidth;x++) if(m_mask.value(x, y, z)==1) { for(int type=0;type<mixnum;type++) clique[type]=0.0f; for(int n=-1;n<=1;n++) for(int m=-1;m<=1;m++) for(int l=-1;l<=1;l++) if(m_mask(x+l, y+m, z+n)==1) { float am=MRFWeightsAM(l, m, n); if(nClasses==3) for(int type=0;type<6;type++) { if(type==hardPV(x+l, y+m, z+n)) clique[type]+=am*2; else if((type==0)&&((hardPV(x+l, y+m, z+n)==3)||(hardPV(x+l, y+m, z+n)==4))) clique[type]+=am; else if((type==1)&&((hardPV(x+l, y+m, z+n)==3)||(hardPV(x+l, y+m, z+n)==5))) clique[type]+=am; else if((type==2)&&((hardPV(x+l, y+m, z+n)==4)||(hardPV(x+l, y+m, z+n)==5))) clique[type]+=am; else if((type==3)&&((hardPV(x+l, y+m, z+n)==0)||(hardPV(x+l, y+m, z+n)==1))) clique[type]+=am; else if((type==4)&&((hardPV(x+l, y+m, z+n)==0)||(hardPV(x+l, y+m, z+n)==2))) clique[type]+=am; else if((type==5)&&((hardPV(x+l, y+m, z+n)==1)||(hardPV(x+l, y+m, z+n)==2))) clique[type]+=am; else clique[type]-=am; } if(nClasses>3) for(int type=0;type<mixnum;type++) { if(type==hardPV(x+l, y+m, z+n)) clique[type]+=am*2; else if((0<type)&&(type<nClasses-1)&&((hardPV(x+l, y+m, z+n)==(nClasses+type-1))||(hardPV(x+l, y+m, z+n)==(nClasses+type)))) clique[type]+=am; else if((type==0)&&((hardPV(x+l, y+m, z+n)==nClasses))) clique[type]+=am; else if((type==(nClasses-1))&&((hardPV(x+l, y+m, z+n)==mixnum-1))) clique[type]+=am; else if((type>(nClasses-1))&&((hardPV(x+l, y+m, z+n)==(type-nClasses))||(hardPV(x+l, y+m, z+n)==(type-nClasses+1)))) clique[type]+=am; else clique[type]-=am; } if(nClasses==2) for(int type=0;type<3;type++) { if(type==hardPV(x+l, y+m, z+n)) clique[type]+=am*2; else if((type==0)&&((hardPV(x+l, y+m, z+n)==2))) clique[type]+=am; else if((type==1)&&((hardPV(x+l, y+m, z+n)==2))) clique[type]+=am; else if((type==2)&&((hardPV(x+l, y+m, z+n)==0)||(hardPV(x+l, y+m, z+n)==1))) clique[type]+=am; else clique[type]-=am; } } float max=-1; for(int type=0;type<mixnum;type++) { float prob=PVprob(x, y, z, type)*exp(pveBmixeltype*clique[type]); if(max<prob) { hardPV(x, y, z)=type; max=prob; } } } delete[] clique; } void ZMRISegmentation::PVestimation() { m_pve=volume4D<float>(m_nWidth, m_nHeight, m_nDepth, nClasses+1); m_pve.copyproperties(m_Mri); m_pve=0.0f; float mu=0.0f; float sigsq=0.0f; double step=(double)(1.0f/(double)(iterationspve)); for(int z=0;z<m_nDepth;z++) { for(int y=0;y<m_nHeight;y++) { for(int x=0;x<m_nWidth;x++) { if(m_mask.value(x, y, z)>0) { if(nClasses==3) { float min=1.0e13; if(hardPV(x, y, z)==0) { m_pve(x, y, z, 1)=1.0; m_pve(x, y, z, 2)=0.0; m_pve(x, y, z, 3)=0.0; continue; } if(hardPV(x, y, z)==1) { m_pve(x, y, z, 1)=0.0; m_pve(x, y, z, 2)=1.0; m_pve(x, y, z, 3)=0.0; continue; } if(hardPV(x, y, z)==2) { m_pve(x, y, z, 1)=0.0; m_pve(x, y, z, 2)=0.0; m_pve(x, y, z, 3)=1.0; continue; } for(float delta=0.00;delta<=1.0;delta+=step) { if(hardPV(x, y, z)==3) { mu=delta*m_mean[1]+(1-delta)*m_mean[2]; sigsq=delta*delta*m_variance[1]+(1-delta)*(1-delta)*m_variance[2]; } if(hardPV(x, y, z)==4) { mu=delta*m_mean[1]+(1-delta)*m_mean[3]; sigsq=delta*delta*m_variance[1]+(1-delta)*(1-delta)*m_variance[3]; } if(hardPV(x, y, z)==5) { mu=delta*m_mean[2]+(1-delta)*m_mean[3]; sigsq=delta*delta*m_variance[2]+(1-delta)*(1-delta)*m_variance[3]; } float val=PVEnergy(x, y, z, mu, sigsq); if(min>val) { if(hardPV(x, y, z)==3) { m_pve(x, y, z, 1)=delta; m_pve(x, y, z, 2)=1.0-delta; m_pve(x, y, z, 3)=0.0; } if(hardPV(x, y, z)==4) { m_pve(x, y, z, 1)=delta; m_pve(x, y, z, 2)=0.0; m_pve(x, y, z, 3)=1.0-delta; } if(hardPV(x, y, z)==5) { m_pve(x, y, z, 1)=0.0; m_pve(x, y, z, 2)=delta; m_pve(x, y, z, 3)=1.0-delta; } min=val; } } } if(nClasses>3) { float min=1.0e13; if(hardPV(x, y, z)<nClasses) { for(int c=0;c<nClasses;c++) { if(hardPV(x, y, z)!=c) m_pve(x, y, z, c+1)=0.0; } m_pve(x, y, z, hardPV(x, y, z)+1)=1.0f; continue; } if(hardPV(x, y, z)>=nClasses) { for(float delta=0.00;delta<=1.0;delta+=step) { mu=delta*m_mean[hardPV(x, y, z)-nClasses+1]+(1-delta)*m_mean[hardPV(x, y, z)-nClasses+2]; sigsq=delta*delta*m_variance[hardPV(x, y, z)-nClasses+1]+(1-delta)*(1-delta)*m_variance[hardPV(x, y, z)-nClasses+2]; float val=PVEnergy(x, y, z, mu, sigsq); if(min>val) { for(int c=0;c<nClasses;c++) { m_pve(x, y, z, c+1)=0.0f; } m_pve(x, y, z, hardPV(x, y, z)-nClasses+1)=delta; m_pve(x, y, z, hardPV(x, y, z)-nClasses+2)=1.0-delta; min=val; } } } } if(nClasses==2) { float min=1.0e13; if(hardPV(x, y, z)==0) { m_pve(x, y, z, 1)=1.0; m_pve(x, y, z, 2)=0.0; continue; } if(hardPV(x, y, z)==1) { m_pve(x, y, z, 1)=0.0; m_pve(x, y, z, 2)=1.0; continue; } for(float delta=0.00;delta<=1.0;delta+=step) { if(hardPV(x, y, z)==2) { mu=delta*m_mean[1]+(1-delta)*m_mean[2]; sigsq=delta*delta*m_variance[1]+(1-delta)*(1-delta)*m_variance[2]; } float val=PVEnergy(x, y, z, mu, sigsq); if(min>val) { if(hardPV(x, y, z)==2) { m_pve(x, y, z, 0)=delta; m_pve(x, y, z, 1)=1.0f-delta; } min=val; } } } } } } } } void ZMRISegmentation::takeexpo() { for(int z=0;z<m_nDepth;z++) for(int y=0;y<m_nHeight;y++) for(int x=0;x<m_nWidth;x++) m_BiasField(x, y, z)=exp(-m_BiasField(x, y, z)); } void ZMRISegmentation::InitSimple(const NEWIMAGE::volume<float>& pcsf, const NEWIMAGE::volume<float>& pgm, const NEWIMAGE::volume<float>& pwm) { if(verboseusage) cout<<"Beginning prior-based initialisation"<<endl; m_post=0; m_prob=0; talpriors=0; if(nClasses==3) { for(int z=0;z<m_nDepth;z++) for(int y=0;y<m_nHeight;y++) for(int x=0;x<m_nWidth;x++) if(m_mask.value(x, y, z)==1) { float norm2=pcsf.value(x, y, z)+pgm.value(x, y, z)+pwm.value(x, y, z); if(norm2>0.0) { m_post.value(x, y, z, 1)=m_prob.value(x, y, z, 1)=talpriors.value(x, y, z, 1)=pcsf.value(x, y, z)/norm2; m_post.value(x, y, z, 2)=m_prob.value(x, y, z, 2)=talpriors.value(x, y, z, 2)=pgm.value(x, y, z)/norm2; m_post.value(x, y, z, 3)=m_prob.value(x, y, z, 3)=talpriors.value(x, y, z, 3)=pwm.value(x, y, z)/norm2; } else for(int c=1;c<=nClasses;c++) m_post.value(x, y, z, c)=m_prob.value(x, y, z, c)=talpriors.value(x, y, z, c)=1.0/3.0f; } Classification(); } if(nClasses==2) { for(int z=0;z<m_nDepth;z++) for(int y=0;y<m_nHeight;y++) for(int x=0;x<m_nWidth;x++) if(m_mask.value(x, y, z)==1) { float norm2=pcsf.value(x, y, z)+pgm.value(x, y, z)+pwm.value(x, y, z); if(norm2>0.0) { m_post.value(x, y, z, 1)=m_prob.value(x, y, z, 1)=talpriors.value(x, y, z, 1)=pcsf.value(x, y, z)/norm2; m_post.value(x, y, z, 2)=m_prob.value(x, y, z, 2)=talpriors.value(x, y, z, 2)=(pgm.value(x, y, z)+pwm.value(x, y, z))/norm2; } else for(int c=1;c<=nClasses;c++) m_post.value(x, y, z, c)=m_prob.value(x, y, z, c)=talpriors.value(x, y, z, c)=1.0/2.0f; } Classification(); } MeansVariances(nClasses, m_post); } void ZMRISegmentation::calculateVolumes(const NEWIMAGE::volume4D<float>& probs) { for(int c=1;c<nClasses+1;c++) { volumequant[c]=probs[c].sum(m_mask); volumequant[c]*=m_nxdim*m_nydim*m_nzdim; } } void ZMRISegmentation::printVolumeTotals() { double tot(0); for(int c=1;c<nClasses+1;c++) { tot+=volumequant[c]; cout<<"\n tissue "<<c<<" " << volumequant[c]; } cout<<"\n total tissue "<<tot<<"\n"; } void ZMRISegmentation::InitKernel(float kernalsize) { float sigma=0.51*m_nbLowpass/m_nxdim; int radius=2*(int)sigma; kernelx=gaussian_kernel1D(sigma, radius); sigma=0.51*m_nbLowpass/m_nydim; radius=2*(int)sigma; kernely=gaussian_kernel1D(sigma, radius); sigma=0.51*m_nbLowpass/m_nzdim; radius=2*(int)sigma; kernelz=gaussian_kernel1D(sigma, radius); } void ZMRISegmentation::MeansVariances(int numberofclasses, NEWIMAGE::volume4D<float>& probability ) { volume4D<float> meanP=m_Mri*probability; volume4D<float> varianceP=m_Mri*meanP; for(int c=1;c<=numberofclasses;c++) { m_mean[c] = meanP[c].sum(m_mask)/probability[c].sum(m_mask); m_variance[c] = varianceP[c].sum(m_mask)/probability[c].sum(m_mask)-m_mean[c]*m_mean[c]; } } void ZMRISegmentation::Initclass() { m_prob=0; for(int z=0;z<m_nDepth;z++) for(int y=0;y<m_nHeight;y++) for(int x=0;x<m_nWidth;x++) if(m_mask.value(x, y, z)==1) { float tot=0.0f; for(int c=1;c<nClasses+1;c++) { m_prob.value(x, y, z, c)=logGaussian(m_Mri.value(x, y, z), m_mean[c], m_variance[c]); tot+=m_prob(x, y, z, c)=max(exp(-m_prob(x, y, z, c)),0.0f); // Need max? Can prob be less than zero? } for(int c=1;c<nClasses+1 && tot>0;c++) m_prob.value(x, y, z, c)/=tot; } m_post=m_prob; } void ZMRISegmentation::UpdateMembers(NEWIMAGE::volume4D<float>& probability) { for(int x=0;x<m_nWidth;x++) for(int y=0;y<m_nHeight;y++) for(int z=0;z<m_nDepth;z++) if(m_mask(x, y, z)==1) { float sum=0.0f; for(int c=0;c<nClasses;c++) sum+=members(x, y, z, c)=max(weight[c]*probability(x, y, z, c+1),0.0f); // Need max? Can weight*prob be less than zero? for(int c=0;c<nClasses && sum>0;c++) members(x, y, z, c)/=sum; } } void ZMRISegmentation::WeightedKMeans() { vector<float> inputMeans; if (mansegfile!="") { ifstream inputfile(mansegfile.c_str()); copy(istream_iterator<float> (inputfile),istream_iterator<float> (),back_inserter(inputMeans)); inputfile.close(); } m_post=m_prob=0.0f; float perc=1.0/((float)(nClasses+1.0)); for(int c=1;c<=nClasses;c++) { if ( (int)inputMeans.size()==nClasses ) m_mean[c]=log(inputMeans[c-1]); else m_mean[c]=m_Mricopy.percentile((float)(perc*c), m_mask); if (verboseusage) cout << c << " " << m_mean[c] << endl; } for(int c=1;c<nClasses+1;c++) for(int c2=1;c2<c;c2++) if(m_mean[c]==m_mean[c2]) throw kmeansexc; for(int z=0;z<m_nDepth;z++) for(int y=0;y<m_nHeight;y++) for(int x=0;x<m_nWidth;x++) if(m_mask(x, y, z)==1) { int minclass=0; float mindist=1e31; for(int c=1;c<=nClasses;c++) { if((m_Mricopy.value(x, y, z)-m_mean[c])*(m_Mricopy.value(x, y, z)-m_mean[c])<mindist) { mindist=(m_Mricopy.value(x, y, z)-m_mean[c])*(m_Mricopy.value(x, y, z)-m_mean[c]); minclass=c; } } m_post(x, y, z, minclass)=1.0f; } for(int initfiter=0;initfiter<initfixed+inititerations;initfiter++) { UpdateMembers(m_post); MeansVariances(nClasses, m_post); if(verboseusage) cout<<"KMeans Iteration "<<initfiter<<"\n"; Initclass(); } } void ZMRISegmentation::qsort() { // sorts images so that 0 is csf, 1 is grey, 2 is white vector<float> meancopy(m_mean), varcopy(m_variance); volume4D<float> postcopy(m_post), probcopy(m_prob); sort(m_mean.begin()+1, m_mean.end()); if(imagetype==2) // for a T2 image reverse the intensity order reverse(m_mean.begin()+1, m_mean.end()); for (int n=1; n<=nClasses; n++) for (int m=1; m<=nClasses; m++) if(m_mean[n]==meancopy[m]) { m_variance[n]=varcopy[m]; m_post[n]=postcopy[m]; m_prob[n]=probcopy[m]; } }
[ "dirk@caltech.edu" ]
dirk@caltech.edu
c43ddfe88058fe326283cc849ca2011252321a19
e94caa5e0894eb25ff09ad75aa104e484d9f0582
/data/s66/mp2/cp_corrected/31/AB/cc-pVTZ/2_ghosts/restart.cc
0034b41e1cd295819e81abdf93f2fdc4568314d2
[]
no_license
bdnguye2/divergence_mbpt_noncovalent
d74e5d755497509026e4ac0213ed66f3ca296908
f29b8c75ba2f1c281a9b81979d2a66d2fd48e09c
refs/heads/master
2022-04-14T14:09:08.951134
2020-04-04T10:49:03
2020-04-04T10:49:03
240,377,466
0
0
null
null
null
null
UTF-8
C++
false
false
444
cc
$chkbas= 49762.2646929664 $nucrep= 33.4040917649944 $chkaux= 270942268.478967 $chkupro= 1.00000000000000 $chkipro= 2.00000000000000 $chklasrep= 1.00000000000000 $chkisy6= 4.00000000000000 $chkmos= 159.901519453857 $chkCCVPQ_ISQR= 2959.06782308729 $chkbqia= 8.17966846057076 $chkr0_MP2= 0.00000000000000 $energy_MP2= -78.3998661235027 $sccss= 1.00000000000000 $sccos= 1.00000000000000 $end
[ "bdnguye2@uci.edu" ]
bdnguye2@uci.edu
9c2b42a8a8a90b959d93848d4fd69a169cd7c9f0
5d8d08f795493e009319c39e7d8455579209feb3
/app/src/main/cpp/IDemux.cpp
84c46591a79c84dcac73d57c3e21fb614f0c6ccc
[]
no_license
RnWater/VideoPlayer
b93963c5368b4cf820e4ab02fc5f47da7710d439
2d4d7d7eb490ac8fcdd66cb3fb5630b387d7265a
refs/heads/master
2023-08-10T12:55:53.510254
2021-09-16T13:07:16
2021-09-16T13:07:16
406,336,296
1
0
null
null
null
null
UTF-8
C++
false
false
61
cpp
// // Created by Henry on 2021/9/14. // #include "IDemux.h"
[ "@fulan.com.cn" ]
@fulan.com.cn