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
986 values
visit_date
timestamp[us]
revision_date
timestamp[us]
committer_date
timestamp[us]
github_id
int64
3.89k
681M
star_events_count
int64
0
209k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
23 values
gha_event_created_at
timestamp[us]
gha_created_at
timestamp[us]
gha_language
stringclasses
145 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
122 values
content
stringlengths
3
10.4M
authors
listlengths
1
1
author_id
stringlengths
0
158
07e92d79f7c924eeb78e2863d327ad82d811f508
1061216c2c33c1ed4ffb33e6211565575957e48f
/cpp-restsdk/model/CodedError.h
79717c88ac75358944c52948ff47692c4c4084b7
[]
no_license
MSurfer20/test2
be9532f54839e8f58b60a8e4587348c2810ecdb9
13b35d72f33302fa532aea189e8f532272f1f799
refs/heads/main
2023-07-03T04:19:57.548080
2021-08-11T19:16:42
2021-08-11T19:16:42
393,920,506
0
0
null
null
null
null
UTF-8
C++
false
false
2,104
h
/** * Zulip REST API * Powerful open source group chat * * The version of the OpenAPI document: 1.0.0 * * NOTE: This class is auto generated by OpenAPI-Generator 5.2.0. * https://openapi-generator.tech * Do not edit the class manually. */ /* * CodedError.h * * */ #ifndef ORG_OPENAPITOOLS_CLIENT_MODEL_CodedError_H_ #define ORG_OPENAPITOOLS_CLIENT_MODEL_CodedError_H_ #include "../ModelBase.h" #include "CodedError_allOf.h" #include "CodedErrorBase.h" #include "AnyType.h" namespace org { namespace openapitools { namespace client { namespace model { /// <summary> /// /// </summary> class CodedError : public ModelBase { public: CodedError(); virtual ~CodedError(); ///////////////////////////////////////////// /// ModelBase overrides void validate() override; web::json::value toJson() const override; bool fromJson(const web::json::value& json) override; void toMultipart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) const override; bool fromMultiPart(std::shared_ptr<MultipartFormData> multipart, const utility::string_t& namePrefix) override; ///////////////////////////////////////////// /// CodedError members /// <summary> /// /// </summary> std::shared_ptr<AnyType> getResult() const; bool resultIsSet() const; void unsetResult(); void setResult(const std::shared_ptr<AnyType>& value); /// <summary> /// /// </summary> std::shared_ptr<AnyType> getMsg() const; bool msgIsSet() const; void unsetMsg(); void setMsg(const std::shared_ptr<AnyType>& value); /// <summary> /// /// </summary> std::shared_ptr<AnyType> getCode() const; bool codeIsSet() const; void unsetCode(); void setCode(const std::shared_ptr<AnyType>& value); protected: std::shared_ptr<AnyType> m_Result; bool m_ResultIsSet; std::shared_ptr<AnyType> m_Msg; bool m_MsgIsSet; std::shared_ptr<AnyType> m_Code; bool m_CodeIsSet; }; } } } } #endif /* ORG_OPENAPITOOLS_CLIENT_MODEL_CodedError_H_ */
[ "suyash.mathur@research.iiit.ac.in" ]
suyash.mathur@research.iiit.ac.in
71b890bbfa8cd04edb2d3e90575cff7cc89ef617
9f2b07eb0e9467e17448de413162a14f8207e5d0
/tests/libtests/feassemble/data/obsolete/QuadratureData2Din3DLinearXZ.hh
47471d569ccdd6ef604d51660f6ccae6cb36559c
[ "MIT" ]
permissive
fjiaqi/pylith
2aa3f7fdbd18f1205a5023f8c6c4182ff533c195
67bfe2e75e0a20bb55c93eb98bef7a9b3694523a
refs/heads/main
2023-09-04T19:24:51.783273
2021-10-19T17:01:41
2021-10-19T17:01:41
373,739,198
0
0
MIT
2021-06-04T06:12:08
2021-06-04T06:12:07
null
UTF-8
C++
false
false
1,876
hh
// -*- C++ -*- // // ====================================================================== // // Brad T. Aagaard, U.S. Geological Survey // Charles A. Williams, GNS Science // Matthew G. Knepley, University of Chicago // // This code was developed as part of the Computational Infrastructure // for Geodynamics (http://geodynamics.org). // // Copyright (c) 2010-2017 University of California, Davis // // See COPYING for license information. // // ====================================================================== // // DO NOT EDIT THIS FILE // This file was generated from python application quadratureapp. #if !defined(pylith_feassemble_quadraturedata2din3dlinearxz_hh) #define pylith_feassemble_quadraturedata2din3dlinearxz_hh #include "QuadratureData.hh" namespace pylith { namespace feassemble { class QuadratureData2Din3DLinearXZ; } // pylith } // feassemble class pylith::feassemble::QuadratureData2Din3DLinearXZ : public QuadratureData { public: /// Constructor QuadratureData2Din3DLinearXZ(void); /// Destructor ~QuadratureData2Din3DLinearXZ(void); private: static const int _numVertices; static const int _spaceDim; static const int _numCells; static const int _cellDim; static const int _numBasis; static const int _numQuadPts; static const PylithScalar _vertices[]; static const int _cells[]; static const PylithScalar _verticesRef[]; static const PylithScalar _quadPtsRef[]; static const PylithScalar _quadWts[]; static const PylithScalar _quadPts[]; static const PylithScalar _basis[]; static const PylithScalar _basisDerivRef[]; static const PylithScalar _basisDeriv[]; static const PylithScalar _jacobian[]; static const PylithScalar _jacobianDet[]; static const PylithScalar _jacobianInv[]; }; #endif // pylith_feassemble_quadraturedata2din3dlinearxz_hh // End of file
[ "baagaard@usgs.gov" ]
baagaard@usgs.gov
e4a7da3cfc299c882554219ec0feda779dfb06c4
645847547bc80c462143fcf0e6c996626dbe3d46
/private/windows/opengl/scrsave/common/scrnsave.cxx
e82e5f48bb2a797a27b47210bf3aea51fe5e945a
[]
no_license
v-jush/win2k
8834ed687e04f2b9475d36673fe4e8986020581b
b6f6742e44e41c7fd5c4e75ca3e6605e426239de
refs/heads/master
2020-09-24T18:05:38.920032
2019-08-15T03:13:13
2019-08-15T03:13:13
null
0
0
null
null
null
null
UTF-8
C++
false
false
24,227
cxx
// SCRNSAVE.C -- skeleton for screen saver application // 4/5/94 francish merged NT and Win4 saver code, folded in SCRNSAVE.SCR // - 3/14/96: marcfo Pulled this file in from shell\control\scrnsave\common. // All changes marked with GL_SCRNSAVE. #define GL_SCRNSAVE 1 #define WIN31 #include <windows.h> #include <windowsx.h> #include "scrnsave.h" #include <regstr.h> #include <imm.h> #ifdef GL_SCRNSAVE #include "glscrnsv.h" #endif #define DBG_MSGS 0 const TCHAR szScreenSaverKey[] = REGSTR_PATH_SCREENSAVE; TCHAR szPasswordActiveValue[] = REGSTR_VALUE_USESCRPASSWORD; const TCHAR szPasswordValue[] = REGSTR_VALUE_SCRPASSWORD; TCHAR szPwdDLL[] = TEXT("PASSWORD.CPL"); CHAR szFnName[] = "VerifyScreenSavePwd"; // Proc name, must be ANSI TCHAR szImmDLL[] = TEXT("IMM32.DLL"); CHAR szImmFnc[] = "ImmAssociateContext"; // Proc name, must be ANSI #if 0 TCHAR szCoolSaverHacks[] = REGSTR_PATH_SETUP TEXT("\\Screen Savers"); TCHAR szMouseThreshold[] = TEXT("Mouse Threshold"); TCHAR szPasswordDelay[] = TEXT("Password Delay"); #endif typedef BOOL (FAR PASCAL * VERIFYPWDPROC) (HWND); typedef HIMC (FAR PASCAL * IMMASSOCPROC) (HWND,HIMC); // variables declared in SCRNSAVE.H HINSTANCE hMainInstance = 0; HWND hMainWindow = 0; BOOL fChildPreview = FALSE; // other globals POINT ptMouse; BOOL fClosing = FALSE; BOOL fCheckingPassword = FALSE; HINSTANCE hInstPwdDLL = NULL; VERIFYPWDPROC VerifyPassword = NULL; static BOOL preview_like_fullscreen = FALSE; static UINT uShellAutoPlayQueryMessage = 0; HINSTANCE hInstImm = NULL; IMMASSOCPROC ImmFnc = NULL; HIMC hPrevImc = (HIMC)0L; static BOOL fOnWin95 = FALSE; //TRUE if on Chicago, FALSE if on Cairo // random junk DWORD dwWakeThreshold = 4; //default to slight movement DWORD dwPasswordDelay = 0; DWORD dwBlankTime = 0; #define MAX_PASSWORD_DELAY_IN_SECONDS (60) // forward declarations of internal fns #ifndef GL_SCRNSAVE // These are hooked out to glscrnsv.cxx static INT_PTR DoScreenSave( HWND hParent ); static INT_PTR DoConfigBox( HWND hParent ); #endif static INT_PTR DoSaverPreview( LPCTSTR szUINTHandle ); static INT_PTR DoChangePw( LPCTSTR szUINTHandle ); static BOOL DoPasswordCheck( HWND hParent ); VOID LoadPwdDLL(VOID); VOID UnloadPwdDLL(VOID); // helper for time static DWORD GetElapsedTime(DWORD from, DWORD to) { return (to >= from)? (to - from) : (1 + to + (((DWORD)-1) - from)); } // helper to convert text to unsigned int static UINT_PTR atoui( LPCTSTR szUINT ) { UINT_PTR uValue = 0; while( ( *szUINT >= TEXT('0') ) && ( *szUINT <= TEXT('9') ) ) uValue = ( ( uValue * 10 ) + ( *szUINT++ - TEXT('0') ) ); return uValue; } // Local reboot and hotkey control (on Win95) static void HogMachine( BOOL value ) { BOOL dummy; // NT is always secure, therefore we don't need to call this on Cairo/NT if (fOnWin95) { SystemParametersInfo( SPI_SCREENSAVERRUNNING, value, &dummy, 0 ); } } // entry point (duh) INT_PTR PASCAL WinMainN( HINSTANCE hInst, HINSTANCE hPrev, LPTSTR szCmdLine, int nCmdShow ) { LPCTSTR pch = szCmdLine; HWND hParent = 0; OSVERSIONINFO osvi; hMainInstance = hInst; osvi.dwOSVersionInfoSize = sizeof(osvi); fOnWin95 = (GetVersionEx(&osvi) && osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS); #ifdef GL_SCRNSAVE // the shell sends this message to the foreground window before running an // AutoPlay app. we return 1 to cancel autoplay if we are password protected if (fOnWin95) { uShellAutoPlayQueryMessage = RegisterWindowMessage(TEXT("QueryCancelAutoPlay")); } else { uShellAutoPlayQueryMessage = 0; } #endif _try { for(;;) switch( *pch ) { case TEXT('S'): case TEXT('s'): return DoScreenSave( NULL ); #ifdef GL_SCRNSAVE case TEXT('W'): case TEXT('w'): do pch++; while( *pch == TEXT(' ') ); // size parameters return DoWindowedScreenSave( pch ); #endif case TEXT('L'): case TEXT('l'): // special switch for tests such as WinBench // this is NOT a hack to make bechmarks look good // it's a hack to allow you to benchmark a screen saver // many bechmarking apps require the whole screen in foreground // which makes it hard to measure how a screensaver adds CPU load // you must provide a parent window (just like preview mode) preview_like_fullscreen = TRUE; case TEXT('P'): case TEXT('p'): do pch++; while( *pch == TEXT(' ') ); // skip to the good stuff return DoSaverPreview( pch ); case TEXT('A'): case TEXT('a'): if (!fOnWin95) return -1; do pch++; while( *pch == TEXT(' ') ); // skip to the good stuff return DoChangePw( pch ); case TEXT('C'): case TEXT('c'): { HWND hwndParent = NULL ; // Look for optional parent window after the "C", // syntax is "C:hwnd_value" if (*(++pch) == TEXT(':')) { hwndParent = (HWND)atoui( ++pch ); } if (hwndParent == NULL || !IsWindow(hwndParent)) hwndParent = GetForegroundWindow(); return DoConfigBox( hwndParent ); } case TEXT('\0'): return DoConfigBox( NULL ); case TEXT(' '): case TEXT('-'): case TEXT('/'): pch++; // skip spaces and common switch prefixes break; default: return -1; } } _except(UnhandledExceptionFilter(GetExceptionInformation())) { // don't leave local reboot and hotkeys disabled on Win95 HogMachine( FALSE ); } } // default screen-saver proc, declared in SCRNSAVE.H // intended to be called by the consumer's ScreenSaverProc where // DefWindowProc would normally be called LRESULT WINAPI DefScreenSaverProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { #if DBG_MSGS TCHAR szBuff[80]; wsprintf( szBuff, TEXT("** DefSSP received:\t0x%04lx 0x%08lx 0x%08lx\n"), uMsg, wParam, lParam ); OutputDebugString(szBuff); #endif if( !fChildPreview && !fClosing ) { switch( uMsg ) { case WM_CLOSE: // Only do password check if on Windows 95. WinNT (Cairo) has // the password check built into the security desktop for // C2 compliance. if (fOnWin95) { if( !DoPasswordCheck( hWnd ) ) { GetCursorPos( &ptMouse ); // re-establish return FALSE; } } #ifdef GL_SCRNSAVE // We need to know when we're being terminated, so we can do // various clean-up stuff SendMessage( hWnd, SS_WM_CLOSING, 0, 0 ); #endif break; case SCRM_VERIFYPW: if (fOnWin95) return ( VerifyPassword? (LRESULT)VerifyPassword( hWnd ) : 1L ); break; default: { POINT ptMove, ptCheck; if( fCheckingPassword ) break; switch( uMsg ) { case WM_SHOWWINDOW: if( (BOOL)wParam ) SetCursor( NULL ); break; case WM_SETCURSOR: SetCursor( NULL ); return TRUE; case WM_MOUSEMOVE: GetCursorPos( &ptCheck ); if( ( ptMove.x = ptCheck.x - ptMouse.x ) && ( ptMove.x < 0 ) ) ptMove.x *= -1; if( ( ptMove.y = ptCheck.y - ptMouse.y ) && ( ptMove.y < 0 ) ) ptMove.y *= -1; if( ((DWORD)ptMove.x + (DWORD)ptMove.y) > dwWakeThreshold ) { PostMessage( hWnd, WM_CLOSE, 0, 0l ); ptMouse = ptCheck; } break; case WM_POWERBROADCAST: switch (wParam) { case PBT_APMRESUMECRITICAL: case PBT_APMRESUMESUSPEND: case PBT_APMRESUMESTANDBY: case PBT_APMRESUMEAUTOMATIC: // If the system is resuming from a real suspend // (as opposed to a failed suspend) deactivate // the screensaver. if ((lParam & PBTF_APMRESUMEFROMFAILURE) == 0) goto PostClose; break; default: // The standard screensaver code shuts down on // all power broadcast messages. This doesn't // make much sense, but match the behavior so // that all screensavers operate the same way. goto PostClose; } break; case WM_POWER: // a critical resume does not generate a WM_POWERBROADCAST // to windows for some reason, but it does generate an old // WM_POWER message. if (wParam == PWR_CRITICALRESUME) goto PostClose; break; case WM_ACTIVATEAPP: if( wParam ) break; case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: case WM_KEYDOWN: case WM_SYSKEYDOWN: PostClose: PostMessage( hWnd, WM_CLOSE, 0, 0l ); break; } } } } // the shell sends this message to the foreground window before running an // AutoPlay app. On Win95, we return 1 to cancel autoplay if we are password protected // On WinNT, secure screen savers run on a secure separate desktop, and will never see // this message, therefore, this code will never get executed. // BUGBUG - // On NT we don't want to take down the screen saver unless it is running // on the same desktop as the autoplay shell. There is code in the // NT autoplay shell that looks for this and does not run the app if // that is the case; however, I not positive that the uShellAutoPlayQueryMessage // will not go between desktops. (BradG assures me that it will not, but you // never know.) If secure screensavers on NT randomly close when you put // an autoplay cd in the drive, then this code should be examined closely. if ((uMsg == uShellAutoPlayQueryMessage) && uMsg) { PostMessage(hWnd, WM_CLOSE, 0, 0L); return (VerifyPassword != NULL); } return DefWindowProc( hWnd, uMsg, wParam, lParam ); } // This window procedure takes care of important stuff before calling the // consumer's ScreenSaverProc. This helps to prevent us from getting hosed by wacky consumer code. LRESULT WINAPI RealScreenSaverProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { switch( uMsg ) { case WM_CREATE: // screen saver does not need the IME if ((hInstImm = GetModuleHandle(szImmDLL)) && (ImmFnc = (IMMASSOCPROC)GetProcAddress(hInstImm,szImmFnc))) hPrevImc = ImmFnc(hWnd, (HIMC)0); // establish the mouse position GetCursorPos( &ptMouse ); if( !fChildPreview ) SetCursor( NULL ); break; case WM_DESTROY: // screen saver does not need the IME if( hInstImm && ImmFnc && hPrevImc ) ImmFnc(hWnd, hPrevImc); PostQuitMessage( 0 ); break; case WM_SETTEXT: // don't let some fool change our title // we need to be able to use FindWindow() to find running instances // of full-screen windows screen savers // NOTE: USER slams our title in during WM_NCCREATE by calling the // defproc for WM_SETTEXT directly, so the initial title will get // there. If this ever changes, we can simply set a bypass flag // during WM_NCCREATE processing. return FALSE; case WM_SYSCOMMAND: if (!fChildPreview) { switch (wParam) { case SC_NEXTWINDOW: // no Alt-tabs case SC_PREVWINDOW: // no shift-alt-tabs case SC_SCREENSAVE: // no more screensavers return FALSE; } } break; case WM_HELP: case WM_CONTEXTMENU: if( fChildPreview ) { // if we're in preview mode, pump the help stuff to our owner HWND hParent = GetParent( hWnd ); if( hParent && IsWindow( hParent ) ) PostMessage( hParent, uMsg, (WPARAM)hParent, lParam ); return TRUE; } break; case WM_TIMER: if( fClosing ) return FALSE; Sleep( 0 ); break; case WM_IME_NOTIFY: // Eat IMN_OPENSTATUSWINDOW so that the status window // isn't displayed. if (wParam == IMN_OPENSTATUSWINDOW) { return 0; } break; case WM_MOUSEMOVE: case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: case WM_KEYDOWN: case WM_SYSKEYDOWN: if( fClosing ) return DefWindowProc( hWnd, uMsg, wParam, lParam ); break; case WM_PAINT: if( fClosing ) return DefWindowProc( hWnd, uMsg, wParam, lParam ); if( !fChildPreview ) SetCursor( NULL ); break; } return ScreenSaverProc( hWnd, uMsg, wParam, lParam ); } #ifdef GL_SCRNSAVE void #else static void #endif InitRealScreenSave() { #if 0 HKEY hkey; if (RegOpenKey(HKEY_CURRENT_USER, szCoolSaverHacks, &hkey) == ERROR_SUCCESS) { DWORD data, len, type; len = sizeof(data); if ((RegQueryValueEx(hkey, szMouseThreshold, NULL, &type, (LPBYTE)&data, &len) == ERROR_SUCCESS) && (type == REG_DWORD)) { dwWakeThreshold = max(dwWakeThreshold, data); } len = sizeof(data); if ((RegQueryValueEx(hkey, szPasswordDelay, NULL, &type, (LPBYTE)&data, &len) == ERROR_SUCCESS) && (type == REG_DWORD) && data) { data = min(MAX_PASSWORD_DELAY_IN_SECONDS, data); dwPasswordDelay = data * 1000; dwBlankTime = GetTickCount(); } } #endif LoadPwdDLL(); } #ifndef GL_SCRNSAVE static INT_PTR DoScreenSave( HWND hParent ) { LPCTSTR pszWindowClass = TEXT("WindowsScreenSaverClass"); LPCTSTR pszWindowTitle; WNDCLASS cls; MSG msg; UINT uStyle; UINT uExStyle; int ncx, ncy; int nx, ny; cls.hCursor = NULL; cls.hIcon = LoadIcon( hMainInstance, MAKEINTATOM( ID_APP ) ); cls.lpszMenuName = NULL; cls.lpszClassName = pszWindowClass; cls.hbrBackground = GetStockObject( BLACK_BRUSH ); cls.hInstance = hMainInstance; cls.style = CS_VREDRAW | CS_HREDRAW | CS_DBLCLKS | CS_OWNDC; cls.lpfnWndProc = RealScreenSaverProc; cls.cbWndExtra = 0; cls.cbClsExtra = 0; if( hParent ) { RECT rcParent; GetClientRect( hParent, &rcParent ); ncx = rcParent.right; ncy = rcParent.bottom; nx = 0; ny = 0; uStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN; uExStyle = 0; fChildPreview = TRUE; pszWindowTitle = TEXT("Preview"); // MUST differ from full screen } else { HWND hOther; #ifdef SM_CXVIRTUALSCREEN nx = GetSystemMetrics( SM_XVIRTUALSCREEN ); ny = GetSystemMetrics( SM_YVIRTUALSCREEN ); ncx = GetSystemMetrics( SM_CXVIRTUALSCREEN ); ncy = GetSystemMetrics( SM_CYVIRTUALSCREEN ); if (ncx == 0 || ncy == 0) #endif { RECT rc; HDC hdc = GetDC(NULL); GetClipBox(hdc, &rc); ReleaseDC(NULL, hdc); nx = rc.left; ny = rc.top; ncx = rc.right - rc.left; ncy = rc.bottom - rc.top; } uStyle = WS_POPUP | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; uExStyle = WS_EX_TOPMOST; pszWindowTitle = TEXT("Screen Saver"); // MUST differ from preview // if there is another NORMAL screen save instance, switch to it hOther = FindWindow( pszWindowClass, pszWindowTitle ); if( hOther && IsWindow( hOther ) ) { SetForegroundWindow( hOther ); return 0; } InitRealScreenSave(); } // the shell sends this message to the foreground window before running an // AutoPlay app. we return 1 to cancel autoplay if we are password protected if (fOnWin95) { uShellAutoPlayQueryMessage = RegisterWindowMessage(TEXT("QueryCancelAutoPlay")); } else { uShellAutoPlayQueryMessage = 0; } if( RegisterClass( &cls ) ) { hMainWindow = CreateWindowEx( uExStyle, pszWindowClass, pszWindowTitle, uStyle, nx, ny, ncx, ncy, hParent, (HMENU)NULL, hMainInstance, (LPVOID)NULL ); } if( hMainWindow ) { if( !fChildPreview ) SetForegroundWindow( hMainWindow ); while( GetMessage( &msg, NULL, 0, 0 ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } } // free password-handling DLL if loaded UnloadPwdDLL(); return msg.wParam; } #endif static INT_PTR DoSaverPreview( LPCTSTR szUINTHandle ) { // get parent handle from string HWND hParent = (HWND)atoui( szUINTHandle ); // only preview on a valid parent window (NOT full screen) return ( (hParent && IsWindow( hParent ))? DoScreenSave( hParent ) : -1 ); } #ifndef GL_SCRNSAVE static INT_PTR DoConfigBox( HWND hParent ) { // let the consumer register any special controls for the dialog if( !RegisterDialogClasses( hMainInstance ) ) return FALSE; return DialogBox( hMainInstance, MAKEINTRESOURCE( DLG_SCRNSAVECONFIGURE ), hParent, (DLGPROC)ScreenSaverConfigureDialog ); } #endif static INT_PTR DoChangePw( LPCTSTR szUINTHandle ) { // get parent handle from string HWND hParent = (HWND)atoui( szUINTHandle ); if( !hParent || !IsWindow( hParent ) ) hParent = GetForegroundWindow(); // allow the library to be hooked ScreenSaverChangePassword( hParent ); return 0; } static const TCHAR szMprDll[] = TEXT("MPR.DLL"); // not to be localized static const TCHAR szProviderName[] = TEXT("SCRSAVE"); // not to be localized #ifdef UNICODE static const CHAR szPwdChangePW[] = "PwdChangePasswordW"; // not to be localized #else static const CHAR szPwdChangePW[] = "PwdChangePasswordA"; // not to be localized #endif // bogus prototype typedef DWORD (FAR PASCAL *PWCHGPROC)( LPCTSTR, HWND, DWORD, LPVOID ); void WINAPI ScreenSaverChangePassword( HWND hParent ) { HINSTANCE mpr = LoadLibrary( szMprDll ); if( mpr ) { // netland hasn't cracked MNRENTRY yet PWCHGPROC pwd = (PWCHGPROC)GetProcAddress( mpr, szPwdChangePW ); if( pwd ) pwd( szProviderName, hParent, 0, NULL ); FreeLibrary( mpr ); } } static BOOL DoPasswordCheck( HWND hParent ) { // don't reenter and don't check when we've already decided if( fCheckingPassword || fClosing ) return FALSE; if( VerifyPassword ) { static DWORD lastcheck = (DWORD)-1; DWORD curtime = GetTickCount(); MSG msg; if (dwPasswordDelay && (GetElapsedTime(dwBlankTime, curtime) < dwPasswordDelay)) { fClosing = TRUE; goto _didcheck; } // no rapid checking... if ((lastcheck != (DWORD)-1) && (GetElapsedTime(lastcheck, curtime) < 200)) { goto _didcheck; } // do the check fCheckingPassword = TRUE; #ifdef GL_SCRNSAVE // Put ss in idle mode during password dialog processing SendMessage( hParent, SS_WM_IDLE, SS_IDLE_ON, 0L ); #endif // flush WM_TIMER messages before putting up the dialog PeekMessage( &msg, hParent, WM_TIMER, WM_TIMER, PM_REMOVE | PM_NOYIELD ); PeekMessage( &msg, hParent, WM_TIMER, WM_TIMER, PM_REMOVE | PM_NOYIELD ); // call the password verify proc fClosing = (BOOL)SendMessage( hParent, SCRM_VERIFYPW, 0, 0L ); fCheckingPassword = FALSE; #ifdef GL_SCRNSAVE // Restore normal display mode SendMessage( hParent, SS_WM_IDLE, SS_IDLE_OFF, 0L ); #endif if (!fClosing) SetCursor(NULL); // curtime may be outdated by now lastcheck = GetTickCount(); } else { // passwords disabled or unable to load handler DLL, always allow exit fClosing = TRUE; } _didcheck: return fClosing; } // stolen from the CRT, used to shirink our code int _stdcall DummyEntry( void ) { int i; STARTUPINFO si; LPTSTR pszCmdLine = GetCommandLine(); if ( *pszCmdLine == TEXT('\"')) { /* * Scan, and skip over, subsequent characters until * another double-quote or a null is encountered. */ while (*(pszCmdLine = CharNext(pszCmdLine)) && (*pszCmdLine != TEXT('\"')) ); /* * If we stopped on a double-quote (usual case), skip * over it. */ if ( *pszCmdLine == TEXT('\"') ) pszCmdLine++; } else { while ((UINT)*pszCmdLine > (UINT)TEXT(' ')) pszCmdLine = CharNext(pszCmdLine); } /* * Skip past any white space preceeding the second token. */ while (*pszCmdLine && ((UINT)*pszCmdLine <= (UINT)TEXT(' '))) { pszCmdLine = CharNext(pszCmdLine); } si.dwFlags = 0; GetStartupInfo(&si); i = (int)WinMainN(GetModuleHandle(NULL), NULL, pszCmdLine, si.dwFlags & STARTF_USESHOWWINDOW ? si.wShowWindow : SW_SHOWDEFAULT); ExitProcess(i); return i; // We never comes here. } // main() entry point to satisfy old NT screen savers void _cdecl main( int argc, char *argv[] ) { DummyEntry(); } // WinMain() entry point to satisfy old NT screen savers int PASCAL WinMain( HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int nCmdShow ) { DummyEntry(); return 0; // reference unreferenced parameters (void)hInst; (void)hPrev; (void)szCmdLine; (void)nCmdShow; } VOID LoadPwdDLL(VOID) { HKEY hKey; if (!fOnWin95) return; if (hInstPwdDLL) UnloadPwdDLL(); // look in registry to see if password turned on, otherwise don't // bother to load password handler DLL if (RegOpenKey(HKEY_CURRENT_USER,szScreenSaverKey,&hKey) == ERROR_SUCCESS) { DWORD dwVal,dwSize=sizeof(dwVal); if ((RegQueryValueEx(hKey,szPasswordActiveValue, NULL,NULL,(BYTE *) &dwVal,&dwSize) == ERROR_SUCCESS) && dwVal) { // try to load the DLL that contains password proc. hInstPwdDLL = LoadLibrary(szPwdDLL); if (hInstPwdDLL) { VerifyPassword = (VERIFYPWDPROC) GetProcAddress(hInstPwdDLL, szFnName); if( VerifyPassword ) HogMachine( TRUE ); else UnloadPwdDLL(); } } RegCloseKey(hKey); } } VOID UnloadPwdDLL(VOID) { if (!fOnWin95) return; if (hInstPwdDLL) { FreeLibrary(hInstPwdDLL); hInstPwdDLL = NULL; if( VerifyPassword ) { VerifyPassword = NULL; HogMachine( FALSE ); } } } // compatbility stuff (to make porting easier) TCHAR szAppName[ APPNAMEBUFFERLEN ]; TCHAR szName[ TITLEBARNAMELEN ]; TCHAR szIniFile[ MAXFILELEN ]; TCHAR szScreenSaver[ 22 ]; TCHAR szHelpFile[ MAXFILELEN ]; TCHAR szNoHelpMemory[ BUFFLEN ]; // Quick fix for old screen savers that don't know about context // sensitive help UINT MyHelpMessage = WM_HELP;
[ "112426112@qq.com" ]
112426112@qq.com
d7c9c437835516e835c27fb9d597e95e296deaaa
b00c54389a95d81a22e361fa9f8bdf5a2edc93e3
/external/lldb/source/Plugins/SymbolFile/DWARF/DWARFLocationList.h
85e11d90b36ba595b841c6d6c22bb59a248e0287
[ "NCSA" ]
permissive
mirek190/x86-android-5.0
9d1756fa7ff2f423887aa22694bd737eb634ef23
eb1029956682072bb7404192a80214189f0dc73b
refs/heads/master
2020-05-27T01:09:51.830208
2015-10-07T22:47:36
2015-10-07T22:47:36
41,942,802
15
20
null
2020-03-09T00:21:03
2015-09-05T00:11:19
null
UTF-8
C++
false
false
1,039
h
//===-- DWARFLocationList.h -------------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// #ifndef SymbolFileDWARF_DWARFLocationList_h_ #define SymbolFileDWARF_DWARFLocationList_h_ #include "SymbolFileDWARF.h" class DWARFLocationList { public: static dw_offset_t Dump (lldb_private::Stream &s, const DWARFCompileUnit* cu, const lldb_private::DataExtractor& debug_loc_data, lldb::offset_t offset); static bool Extract (const lldb_private::DataExtractor& debug_loc_data, lldb::offset_t* offset_ptr, lldb_private::DataExtractor& location_list_data); static size_t Size (const lldb_private::DataExtractor& debug_loc_data, lldb::offset_t offset); }; #endif // SymbolFileDWARF_DWARFLocationList_h_
[ "mirek190@gmail.com" ]
mirek190@gmail.com
8b2896d700fb6ae4849b4f2f4730aa039484e18c
7d1040c025f91911cefba2fa748b813d275a95f6
/CreatureEditorAndPlugin/CreaturePlugin/Source/CreaturePlugin/Private/CreatureMetaAsset.cpp
8387a2ca51cf5f4630d1c22d3ada61d84913d3c0
[ "LicenseRef-scancode-public-domain" ]
permissive
sepinood/Creature_UE4
85f79ed1d805bd5f1036c4bb6f97dfcf056f08ed
cd0a3f87e411985cfe80761f67bc8cdd860e04e4
refs/heads/master
2021-01-21T08:28:36.968275
2016-09-02T18:05:29
2016-09-02T18:05:29
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,059
cpp
#include "CreaturePluginPCH.h" #include "CreatureMetaAsset.h" #include "CreatureCore.h" FString& UCreatureMetaAsset::GetJsonString() { return jsonString; } void UCreatureMetaAsset::Serialize(FArchive& Ar) { Super::Serialize(Ar); } void UCreatureMetaAsset::BuildMetaData() { TSharedPtr<FJsonObject> jsonObject = MakeShareable(new FJsonObject); TSharedRef< TJsonReader<> > reader = TJsonReaderFactory<>::Create(jsonString); meta_data.clear(); if (FJsonSerializer::Deserialize(reader, jsonObject)) { // Fill mesh data if (jsonObject->HasField(TEXT("meshes"))) { auto meshes_obj = jsonObject->GetObjectField(TEXT("meshes")); for (auto cur_data : meshes_obj->Values) { auto cur_json = cur_data.Value->AsObject(); auto cur_id = cur_json->GetIntegerField(TEXT("id")); auto cur_start_index = cur_json->GetIntegerField(TEXT("startIndex")); auto cur_end_index = cur_json->GetIntegerField(TEXT("endIndex")); meta_data.mesh_map.Add(cur_id, std::pair<int, int>(cur_start_index, cur_end_index)); } } // Fill switch order data if (jsonObject->HasField(TEXT("regionOrders"))) { auto orders_obj = jsonObject->GetObjectField(TEXT("regionOrders")); for (auto cur_data : orders_obj->Values) { auto cur_anim_name = cur_data.Key; TMap<int, std::vector<int> > cur_switch_order_map; auto cur_obj_array = cur_data.Value->AsArray(); for (auto cur_switch_json : cur_obj_array) { auto switch_obj = cur_switch_json->AsObject(); auto cur_switch_list = switch_obj->GetArrayField(TEXT("switch_order")); std::vector<int> cur_switch_ints; for (auto cur_switch_val : cur_switch_list) { cur_switch_ints.push_back((int)cur_switch_val->AsNumber()); } auto cur_switch_time = switch_obj->GetIntegerField(TEXT("switch_time")); cur_switch_order_map.Add(cur_switch_time, cur_switch_ints); } meta_data.anim_order_map.Add(cur_anim_name, cur_switch_order_map); } } } } CreatureMetaData * UCreatureMetaAsset::GetMetaData() { return &meta_data; }
[ "creature@kestrelmoon.com" ]
creature@kestrelmoon.com
4be13af12e58cf27eb1afb7bd18e296b3db1dc8f
30f5c35fc134fcabf322fffb4235586e487bfd00
/Exercicios de Herança/Exercicio - 05/Livro.h
dfc3849ad5cbb5a523e694ea975eebe742f80f73
[]
no_license
leonarck00/TP2_Heran-a
ff95c044d3196b8b4f06cd5ad0f88019cfbd3fb9
c2d9c7e0cc48bd3ace021531d66d0d2ad6feb1b1
refs/heads/master
2020-04-09T23:12:05.778413
2018-12-10T09:42:44
2018-12-10T09:42:44
160,649,923
0
0
null
null
null
null
UTF-8
C++
false
false
881
h
#ifndef LIVRO_H #define LIVRO_H #include<Produto.h> namespace dnn { class Livro : public Produto { public: Livro() : Produto(), autor(""), tradutor(""), editora(""), anoPublicacao(0) {} std::string getAutor() const{return autor;} void setAutor(const std::string &value){autor = value;} std::string getTradutor() const{return tradutor;} void setTradutor(const std::string &value){tradutor = value;} std::string getEditora() const{return editora;} void setEditora(const std::string &value){editora = value;} int getAnoPublicacao() const{return anoPublicacao;} void setAnoPublicacao(int value){anoPublicacao = value;} std::string tipoDeProduto()const{return "Livro";} private: std::string autor; std::string tradutor; std::string editora; int anoPublicacao; }; } #endif // LIVRO_H
[ "noreply@github.com" ]
leonarck00.noreply@github.com
abcc79025bec29a21345f46cd35e39df7e0db8e5
272788cb066f9a29864b1b1da0396dbe6fa43304
/src/base58.h
7538a4eef54d1142db1869593e73c2b42b2f6fb0
[ "MIT" ]
permissive
cryptoandcoffee/pvp
223f43c96dbdf3ed9a0fb68ae64ab5aeec7a49ec
8233a7b21db0f6a2a56fbe46a81f79330c705c62
refs/heads/master
2020-12-13T17:26:53.940410
2020-01-17T06:17:05
2020-01-17T06:17:05
234,483,724
0
0
null
null
null
null
UTF-8
C++
false
false
5,817
h
// Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2015 The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. /** * Why base-58 instead of standard base-64 encoding? * - Don't want 0OIl characters that look the same in some fonts and * could be used to create visually identical looking data. * - A string with non-alphanumeric characters is not as easily accepted as input. * - E-mail usually won't line-break if there's no punctuation to break at. * - Double-clicking selects the whole string as one word if it's all alphanumeric. */ #ifndef BITCOIN_BASE58_H #define BITCOIN_BASE58_H #include "chainparams.h" #include "key.h" #include "pubkey.h" #include "script/script.h" #include "script/standard.h" #include "support/allocators/zeroafterfree.h" #include <string> #include <vector> /** * Encode a byte sequence as a base58-encoded string. * pbegin and pend cannot be NULL, unless both are. */ std::string EncodeBase58(const unsigned char* pbegin, const unsigned char* pend); /** * Encode a byte vector as a base58-encoded string */ std::string EncodeBase58(const std::vector<unsigned char>& vch); /** * Decode a base58-encoded string (psz) into a byte vector (vchRet). * return true if decoding is successful. * psz cannot be NULL. */ bool DecodeBase58(const char* psz, std::vector<unsigned char>& vchRet); /** * Decode a base58-encoded string (str) into a byte vector (vchRet). * return true if decoding is successful. */ bool DecodeBase58(const std::string& str, std::vector<unsigned char>& vchRet); /** * Encode a byte vector into a base58-encoded string, including checksum */ std::string EncodeBase58Check(const std::vector<unsigned char>& vchIn); /** * Decode a base58-encoded string (psz) that includes a checksum into a byte * vector (vchRet), return true if decoding is successful */ inline bool DecodeBase58Check(const char* psz, std::vector<unsigned char>& vchRet); /** * Decode a base58-encoded string (str) that includes a checksum into a byte * vector (vchRet), return true if decoding is successful */ inline bool DecodeBase58Check(const std::string& str, std::vector<unsigned char>& vchRet); /** * Base class for all base58-encoded data */ class CBase58Data { protected: //! the version byte(s) std::vector<unsigned char> vchVersion; //! the actually encoded data typedef std::vector<unsigned char, zero_after_free_allocator<unsigned char> > vector_uchar; vector_uchar vchData; CBase58Data(); void SetData(const std::vector<unsigned char> &vchVersionIn, const void* pdata, size_t nSize); void SetData(const std::vector<unsigned char> &vchVersionIn, const unsigned char *pbegin, const unsigned char *pend); public: bool SetString(const char* psz, unsigned int nVersionBytes = 1); bool SetString(const std::string& str); std::string ToString() const; int CompareTo(const CBase58Data& b58) const; bool operator==(const CBase58Data& b58) const { return CompareTo(b58) == 0; } bool operator<=(const CBase58Data& b58) const { return CompareTo(b58) <= 0; } bool operator>=(const CBase58Data& b58) const { return CompareTo(b58) >= 0; } bool operator< (const CBase58Data& b58) const { return CompareTo(b58) < 0; } bool operator> (const CBase58Data& b58) const { return CompareTo(b58) > 0; } }; /** base58-encoded PlayerVsPlayerCoin addresses. * Public-key-hash-addresses have version 76 (or 140 testnet). * The data vector contains RIPEMD160(SHA256(pubkey)), where pubkey is the serialized public key. * Script-hash-addresses have version 16 (or 19 testnet). * The data vector contains RIPEMD160(SHA256(cscript)), where cscript is the serialized redemption script. */ class CBitcoinAddress : public CBase58Data { public: bool Set(const CKeyID &id); bool Set(const CScriptID &id); bool Set(const CTxDestination &dest); bool IsValid() const; bool IsValid(const CChainParams &params) const; CBitcoinAddress() {} CBitcoinAddress(const CTxDestination &dest) { Set(dest); } CBitcoinAddress(const std::string& strAddress) { SetString(strAddress); } CBitcoinAddress(const char* pszAddress) { SetString(pszAddress); } CTxDestination Get() const; bool GetKeyID(CKeyID &keyID) const; bool GetIndexKey(uint160& hashBytes, int& type) const; bool IsScript() const; }; /** * A base58-encoded secret key */ class CBitcoinSecret : public CBase58Data { public: void SetKey(const CKey& vchSecret); CKey GetKey(); bool IsValid() const; bool SetString(const char* pszSecret); bool SetString(const std::string& strSecret); CBitcoinSecret(const CKey& vchSecret) { SetKey(vchSecret); } CBitcoinSecret() {} }; template<typename K, int Size, CChainParams::Base58Type Type> class CBitcoinExtKeyBase : public CBase58Data { public: void SetKey(const K &key) { unsigned char vch[Size]; key.Encode(vch); SetData(Params().Base58Prefix(Type), vch, vch+Size); } K GetKey() { K ret; if (vchData.size() == Size) { // If base58 encoded data does not hold an ext key, return a !IsValid() key ret.Decode(&vchData[0]); } return ret; } CBitcoinExtKeyBase(const K &key) { SetKey(key); } CBitcoinExtKeyBase(const std::string& strBase58c) { SetString(strBase58c.c_str(), Params().Base58Prefix(Type).size()); } CBitcoinExtKeyBase() {} }; typedef CBitcoinExtKeyBase<CExtKey, BIP32_EXTKEY_SIZE, CChainParams::EXT_SECRET_KEY> CBitcoinExtKey; typedef CBitcoinExtKeyBase<CExtPubKey, BIP32_EXTKEY_SIZE, CChainParams::EXT_PUBLIC_KEY> CBitcoinExtPubKey; #endif // BITCOIN_BASE58_H
[ "wildsf@djfrencht0ast.com" ]
wildsf@djfrencht0ast.com
3a828da55345c4cfa9088ce1a363f849e4421212
e2227524377dbb7641d3eabb7d7a4db835ee2bae
/maxProfit3/maxProfit3/maxProfit3.cpp
49a610653f434c7c06db91eb463cc73a4a30342d
[]
no_license
tezheng/LeetCode
a7a920e0e9c880a0589efc98ad4f551243af2dc3
1ae450d469076228b5e720480d1d2ff877ffc14e
refs/heads/master
2021-01-16T18:01:08.048098
2013-05-11T13:23:20
2013-05-11T13:23:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
994
cpp
#include <vector> using namespace std; int main() { vector<int> prices; prices.push_back(1); if(prices.size() == 0) return 0; vector<int> firstprofit; firstprofit.push_back(0); firstprofit.push_back(0); vector<int> secondprofit; secondprofit.push_back(0); secondprofit.push_back(0); int min = prices[0]; int profit = 0; for(int i = 1; i< prices.size(); i++) { if(prices[i] < min) min =prices[i]; if(prices[i] - min > profit) profit = prices[i] - min; firstprofit.push_back(profit); } reverse(prices.begin(),prices.end()); min = prices[0]; profit = 0; for(int i = 1; i< prices.size(); i++) { if(prices[i] > min) min =prices[i]; if(prices[i] - min < profit) profit = prices[i] - min; secondprofit.push_back(-profit); } reverse(secondprofit.begin(),secondprofit.end()); int maxprofit = 0; for(int i = 0;i<firstprofit.size();i++) { if(firstprofit[i] + secondprofit[i] > maxprofit) maxprofit = firstprofit[i] + secondprofit[i]; } return 0; }
[ "liumengxinfly@gmail.com" ]
liumengxinfly@gmail.com
f48941e2f927a0f2dc873d0176f07763043a20ab
8759f4361a1253980dfb0c5a3901e3f73b2f19c4
/src/vcl/hid/spacenavigatorhandler.h
6d1cedd75fc826ac55e798e6cdfd7367015ec9f8
[ "MIT" ]
permissive
bfierz/vcl.hid
53b3f37e2b671fbcb4da448d1ad08670250f5aa1
4193fe488d6759306e297b225e3a3c4da58716b0
refs/heads/master
2021-09-10T06:46:56.669621
2018-03-21T20:00:36
2018-03-21T20:00:36
102,975,343
1
0
null
null
null
null
UTF-8
C++
false
false
2,935
h
/* * This file is part of the Visual Computing Library (VCL) release under the * license. * * Copyright (c) 2017 Basil Fierz * * 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. */ #pragma once // VCL configuration #include <vcl/config/global.h> // C++ standard library #include <array> // VCL #include <vcl/hid/spacenavigatorvirtualkeys.h> namespace Vcl { namespace HID { //! Forward declaration class SpaceNavigator; //! Callback interface class SpaceNavigatorHandler { public: /*! * \brief onSpaceMouseMove is invoked when new 3d mouse data is * available. * * \param device Pointer to the device that triggered the callback * \param motion_data Contains the displacement data, using a * right-handed coordinate system with z down. * See 'Programing for the 3dmouse' document * available at www.3dconnexion.com. * Entries 0, 1, 2 is the incremental pan zoom * displacement vector (x,y,z). * Entries 3, 4, 5 is the incremental rotation vector * (NOT Euler angles). */ virtual void onSpaceMouseMove(const SpaceNavigator* device, std::array<float, 6> motion_data) = 0; /*! * \brief onSpaceMouseKeyDown processes the 3d mouse key presses * * \param device Pointer to the device that triggered the callback * \param virtual_key 3d mouse key code */ virtual void onSpaceMouseKeyDown(const SpaceNavigator* device, unsigned int virtual_key) = 0; /*! * \brief onSpaceMouseKeyUp processes the 3d mouse key releases * * \param device Pointer to the device that triggered the callback * \param virtual_key 3d mouse key code */ virtual void onSpaceMouseKeyUp(const SpaceNavigator* device, unsigned int virtual_key) = 0; }; }}
[ "basil.fierz@hotmail.com" ]
basil.fierz@hotmail.com
1ca331be3e4d166c674372e1978471b08a77ffd0
99c5155ad8c762459bb2d46c48aa261ddc06baa1
/ChuckNorris.h
0741be036aad52acefa6d3b974e85a3bcbe2696c
[]
no_license
CS1103/practica-calificada-2-JosephPenaQuino
13e11e477a85aab6d2bc27baa488eb1a071423cf
533c36b3934b4915bfed54562838fd5666c9b665
refs/heads/master
2022-01-15T15:54:35.686641
2019-05-10T18:29:34
2019-05-10T18:29:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
187
h
#ifndef PC2_CHUCKNORRIS_H #define PC2_CHUCKNORRIS_H #include "Fighter.h" class ChuckNorris : public Fighter { public: explicit ChuckNorris(int id); }; #endif //PC2_CHUCKNORRIS_H
[ "joseph.pena@utec.edu.pe" ]
joseph.pena@utec.edu.pe
d22653bdf8f35da66622bb14454648ae1b545001
44616f4a859b5b0ced95d77e3d6157fe569a8338
/src/ld24/Objects/Player.cpp
5af0d11709c8db8e65ca83c2da000f02b9511e74
[]
no_license
ydnax/ld24
857a0e136a0280de60765660198a479b9be5fa39
bec93f177847455b546be692368d2f5e7124c633
refs/heads/master
2016-08-05T13:03:43.514347
2012-08-27T21:46:04
2012-08-27T21:46:04
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,611
cpp
#include "Player.hpp" #include <ld24/Objects/Powerup.hpp> #include <SDL/SDL.h> namespace ld24{ Player::Player(Level *lvl, int x, int y): levelObject(lvl), x(x),y(y),xx(x),xy(y),xspeed(0), yspeed(0), images{{Image("resources/gfx/player/player-anim0.png", 50, 50), Image("resources/gfx/player/player-anim1.png", 50, 50), Image("resources/gfx/player/player-anim2.png", 50, 50) }}, r(this, mainwindow::player){ } bool Player::exit(){ SDL_Event event; while( SDL_PollEvent( &event ) ) { if( event.type == SDL_QUIT ) return true; } return false; } void Player::update(int ticks){ Uint8 *keystates = SDL_GetKeyState( NULL ); if( keystates[ SDLK_UP ] && onfloor && up_canjump){ yspeed+=-1*jumpspeed; } if( keystates[ SDLK_LEFT ] ){ xspeed =-1*(movespeed+up_walkspeed); chCount+=ticks; }else if( keystates[ SDLK_RIGHT ] ){ xspeed = (movespeed+up_walkspeed); chCount+=ticks; }else{ xspeed=0; } yspeed+=gravity*ticks/1000.; if(yspeed>maxdown){ yspeed=maxdown; } /* while(udChk(ticks)){ int dpx=yspeed*ticks/1000.; if( (dpx>5)||(dpx<-5)){ yspeed/=1.5; }else{ yspeed=0; } } //*/ if(udChk(ticks)){ yspeed=0; } if(rlChk(ticks)){ xspeed=0; } xx=xx+xspeed*ticks/1000.; x=xx; xy=xy+yspeed*ticks/1000.; y=xy; if(chCount>animationSpeed){ chCount=0; imgIndex++; imgIndex=imgIndex%images.size(); } checkPowerups(); auto img=images[imgIndex]; mwindow->ccx(xx+(img.w()/2)); } bool Player::udChk(int ticks){ auto img=images[imgIndex]; float ny=xy+yspeed*ticks/1000.; for(auto &&box:obstacles){ if(boxCollide({{int(xx+0.5),int(ny+0.5)},img.w(), img.h()}, box)){ if(yspeed>0) onfloor=true; return true; } } onfloor=false; return false; } bool Player::rlChk(int ticks){ auto img=images[imgIndex]; float nx=xx+xspeed*ticks/1000.; for(auto &&box: obstacles){ if(boxCollide({{int(nx+0.5),int(xy+0.5)},img.w(), img.h()}, box)){ return true; } } return false; } void Player::checkPowerups(){ auto img=images[imgIndex]; powerups.realDelete(); for(auto i : powerups.data()){ if(boxCollide({{x,y},img.w(), img.h()}, i->getInfo())){ i->Use()(this); return; } } } }
[ "gitmail.xandy@xoxy.net" ]
gitmail.xandy@xoxy.net
76bd14cd1938eb0cd5b35e165787ce859d098eb0
5d7d151f671c5bb36c80bc43cfbe6b159c6d2e87
/baitap2_quanlisinhvien_2051120281/Menu.cpp
1ab3b1f8b055773d2914417cd889828ba7b6925a
[]
no_license
thanhnhut1112/baitap2_quanlisinhvien_2051120281
635249facb03e77692e1b0b3df50452766134039
3fd714d99f36e64ebbfec289439a9c0389ac9fa1
refs/heads/master
2023-08-25T03:48:24.530566
2021-10-10T10:17:00
2021-10-10T10:17:00
415,545,511
0
0
null
null
null
null
UTF-8
C++
false
false
781
cpp
#include "Menu.h" #include <iostream> using namespace std; Menu::Menu(string tieude) { this->tieude = tieude; } void Menu::themLuachon(string luachon) { dsLuachon.push_back(luachon); } void Menu::xuat() { cout << "\n-----" << tieude << "-----\n"; for (int i = 0; i < dsLuachon.size(); i++) cout << i << ". " << dsLuachon[i] << endl; } int Menu::chon() { int ch; do { xuat(); cout << "Moi chon?"; cin >> ch; //xoa ky tu xuong dong de cac lenh getline sau nay khong bi anh huong string tmp; getline(cin, tmp); if (ch < 0 || ch >= dsLuachon.size()) cout << "Chon sai, moi chon lai!!!\n"; } while (ch < 0 || ch >= dsLuachon.size());//Lap lai neu user chon sai return ch; }
[ "ACER@LAPTOP-OJ2GO58H" ]
ACER@LAPTOP-OJ2GO58H
52d01452c58ef32728d1d612324793e3bc746953
cee3d4b65ead71f22db1d1aacad1e0958657b8f3
/LAB4.cpp
92d3aaea85e840e2c132b0a8abd548b849880768
[]
no_license
IliaTrofimov/Object-table-viewer
431a203a15bf8e200a041964fa8af4172ca57989
fdb5f22ef8efec736994097e53a26c575ab2ac63
refs/heads/main
2023-04-09T11:23:02.741674
2021-04-25T09:00:30
2021-04-25T09:00:30
361,372,093
1
0
null
null
null
null
WINDOWS-1251
C++
false
false
1,162
cpp
//--------------------------------------------------------------------------- #include <vcl.h> #pragma hdrstop #include <tchar.h> //--------------------------------------------------------------------------- USEFORM("NumberEntryFormClass.cpp", formNumEntry); USEFORM("ResultFormClass.cpp", formResult); USEFORM("SearchFormClass.cpp", searchForm); USEFORM("MainFormClass.cpp", mainForm); USEFORM("ABOUT.cpp", AboutBox); USEFORM("EditFormClass.cpp", formEdit); //--------------------------------------------------------------------------- int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int) { try { setlocale(LC_ALL,"russian"); Application->Initialize(); Application->MainFormOnTaskBar = true; Application->Title = "Список зоопарков"; Application->CreateForm(__classid(TmainForm), &mainForm); Application->Run(); } catch (Exception &exception) { Application->ShowException(&exception); } catch (...) { try { throw Exception(""); } catch (Exception &exception) { Application->ShowException(&exception); } } return 0; } //---------------------------------------------------------------------------
[ "ilia.trofimov2001@icloud.com" ]
ilia.trofimov2001@icloud.com
9152054fc11cf84608216c2146f5142d92382c9d
1ec086253005570c211cf55fe74c8886b2c483ef
/TKDGTT/Tuan 6/BT6.Nhom5/doitien.cpp
8d91ae72702d6ccac8a772628496da2c687123b9
[]
no_license
Du0ngkylan/C-Cpp
8be2fc9632bb1c49b0eaac6166f9ead5deac4c83
37d973d510bafc5512fce2f2a81b0a4aa746b2e3
refs/heads/master
2021-06-26T05:58:17.969765
2020-11-27T03:52:06
2020-11-27T03:52:06
172,220,624
0
1
null
null
null
null
UTF-8
C++
false
false
1,061
cpp
#include<stdio.h> #include<conio.h> #define hs 50 int C[hs][hs]; int d[hs],chon[hs]; int n,m; void nhap(){ int i; for ( i=1; i<=n; i++){ printf("Nhap d[%d]= ",i); scanf("%d",&d[i]); } } void in(){ int i; for ( i=1; i<=n; i++){ printf("%4d",d[i]); } printf("\n"); } void doitien(){ int i,j; for (i=0; i<=n; i++){ C[i][0] = 0; } for (j=1; j<=m; j++){ C[0][j] = hs; } for ( i=1; i<=n; i++){ for ( j=1; j<=m; j++){ C[i][j] = C[i-1][j]; if( (d[i]<=j) &&((C[i][j-d[i]]+1)<C[i][j])) C[i][j] = C[i][j-d[i]] + 1; } } } void truyvet(){ int i,j; i=n; j = m; while( j>0 ){ if( C[i][j] == C[i-1][j]){ i = i-1; chon[i] = 0; } if( C[i][j] == ( C[i][j-d[i]] + 1) ){ j = j-d[i]; printf("%4d",d[i]); } } } int main(){ int i; printf("Nhap vso so loai menh gia: n = "); scanf("%d",&n); printf("Nhap vao tung loai menh gia: \n"); nhap(); printf("Nhap vao so tien can doi: m ( m < 50 ) = "); scanf("%d",&m); doitien(); printf("Cach doi: "); truyvet(); getch(); return 0; }
[ "duongmaixuan.k55tt@gmail.com" ]
duongmaixuan.k55tt@gmail.com
f01270a0d22554283d01efc7cd027707706b8251
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/git/gumtree/git_patch_hunk_211.cpp
581bb823fedd728675c71c8458167603aaf487c5
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,003
cpp
* alias twice, because that implies that there were actually two * different files with aliasing names! * * So we use the CE_ADDED flag to verify that the alias was an old * one before we accept it as */ -static struct cache_entry *create_alias_ce(struct cache_entry *ce, struct cache_entry *alias) +static struct cache_entry *create_alias_ce(struct index_state *istate, + struct cache_entry *ce, + struct cache_entry *alias) { int len; struct cache_entry *new; if (alias->ce_flags & CE_ADDED) die("Will not add file alias '%s' ('%s' already exists in index)", ce->name, alias->name); /* Ok, create the new entry using the name of the existing alias */ len = ce_namelen(alias); new = xcalloc(1, cache_entry_size(len)); memcpy(new->name, alias->name, len); copy_cache_entry(new, ce); - free(ce); + save_or_free_index_entry(istate, ce); return new; } void set_object_name_for_intent_to_add_entry(struct cache_entry *ce) { unsigned char sha1[20];
[ "993273596@qq.com" ]
993273596@qq.com
4f1b210e15c07227fd419ea3bd7797549dca96ad
bd6e36612cd2e00f4e523af0adeccf0c5796185e
/include/clasp/core/lightProfiler.h
c06c5bba42ef71ebd0c8afbf7843c6c6c0c8331f
[]
no_license
robert-strandh/clasp
9efc8787501c0c5aa2480e82bb72b2a270bc889a
1e00c7212d6f9297f7c0b9b20b312e76e206cac2
refs/heads/master
2021-01-21T20:07:39.855235
2015-03-27T20:23:46
2015-03-27T20:23:46
33,315,546
1
0
null
2015-04-02T15:13:04
2015-04-02T15:13:04
null
UTF-8
C++
false
false
3,709
h
/* File: lightProfiler.h */ /* Copyright (c) 2014, Christian E. Schafmeister CLASP is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. See directory 'clasp/licenses' for full details. 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. */ /* -^- */ #ifdef darwin #include <stdint.h> #include <mach/mach_time.h> #else #include <time.h> #endif #include <clasp/core/foundation.h> #ifndef LightProfiler_H #define LightProfiler_H namespace core { class LightProfiler; class LightTimer { private: LightProfiler* _Profiler; uint _Id; bool _IsOn; double _AccumulatedTime; uint _Calls; uint _ClockResolutionFails; string _Description; uint _Parent; uint _Sibling; uint _Child; clock_t _StartTime; public: LightTimer(LightProfiler* profiler=NULL); void setup(uint id, const string& description, uint parent ) { this->_Id = id; this->_Description = description; this->_Parent = parent; } void reset() { this->_AccumulatedTime = 0.0; }; uint getId() { return this->_Id; }; bool getIsOn() { return this->_IsOn;}; uint getCalls() { return this->_Calls;}; string getDescription() { return this->_Description;}; uint getParent() { return this->_Parent;}; uint getSibling() { return this->_Sibling;}; uint getClockResolutionFails() { return this->_ClockResolutionFails;}; uint getChild() { return this->_Child;}; clock_t getStartTime() { return this->_StartTime;}; void setStartTime( const clock_t& t) { this->_StartTime = t;}; void start(); void stop(); void addChild(uint child); uint getNumberOfCalls() { return this->_Calls;}; double getAccumulatedTime() { return this->_AccumulatedTime;}; }; class LightEventCounter { private: string _Description; uint _Calls; uint _Problems; public: void setDescription(string desc) { this->_Description = desc;}; string getDescription() { return this->_Description;}; void recordCallAndProblem(bool problem); uint getCalls() {return this->_Calls;}; uint getProblems() {return this->_Problems;}; LightEventCounter(); virtual ~LightEventCounter(); }; class LightProfiler { public: LightProfiler(); private: vector<LightTimer> _Timers; vector<LightEventCounter> _EventCounters; vector< vector<bool> > _TimerStateStack; bool _MessagesEnabled; public: // LightTimer* getTimer(int id); // LightTimer* createTimer(uint parent, uint id, // const string& name); void createTimers(uint num); void resetAllTimers(); void stopAllTimers(); double getLongestTime(); uint createTimer(uint parent, const string& name); uint createEventCounter(string name); void pushTimerStates(); void popTimerStates(); void disableMessages(); LightTimer& timer(uint c); LightEventCounter& eventCounter(uint c); void dumpChildTimers(uint level, uint top); void dump(); virtual ~LightProfiler(); }; }; #endif
[ "chris.schaf@verizon.net" ]
chris.schaf@verizon.net
63627b98e20697c67425c5e795be608dfd7178a2
8d86646bc8e2835cf41c7548227dea11f43817f4
/p2/p2.ino
683d50b35b65072174239c013252d92eeab3f3ec
[]
no_license
mandrewcito/GEI-DHI
5d04fe4b4f230c9c514772c3929ec058ba4e49a5
df5b0c9bbd5f48d38b5328fd1295cc0f59598255
refs/heads/master
2020-12-03T05:25:00.071129
2015-01-30T21:09:54
2015-01-30T21:09:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,479
ino
/* p2 DHI andres baamonde lozano hora en hh:mm:ss(actualiza mediante interrupcion) por USART led rojo y verde encendidos con ss%2 (alternando) la puesta en hora enviando los datos desde la misma ventana de monitorización del puerto serie del IDE Arduino ->poner en modo de bajo consumo power-down mediante el envío de un valor de hora, minuto o segundo que exceda el valor máximo permitido, se apagan los 2 leds y con el pulsador (mediante interrupt ) se reinicia */ #include <MsTimer2.h> #include <avr/interrupt.h> #include <avr/sleep.h> const int buttonPin =3; const int verde =5; const int rojo = 10; boolean output = HIGH; String str=""; volatile int hora=0; volatile int minuto=0; volatile int segundo=0; volatile int darHora=HIGH; char horaE[3]; char minutoE[3]; char segundoE[3]; void flash() { digitalWrite(rojo, output); digitalWrite(verde, !output); output = !output; segundo++; if(segundo == 60) { minuto++; segundo=0; if (minuto==60){ hora++; minuto=0; if (hora==24){ minuto=0;segundo=0;hora=0; } } } darHora=HIGH; } void setup() { // initialize serial communication at 9600 bits per second: Serial.begin(9600); pinMode(buttonPin, INPUT); pinMode(verde, OUTPUT); pinMode(rojo, OUTPUT); set_sleep_mode(SLEEP_MODE_PWR_DOWN); // sleep mode is set here MsTimer2::set(1000, flash); // 1000ms period MsTimer2::start(); sleep_enable(); } void wakeUpNow(){ sleep_disable(); } void sleepNow(){ sleep_mode(); } // the loop routine runs over and over again forever: void loop() { /* si lo introducido no es valido */ while(Serial.available() > 0) { str = Serial.readStringUntil('\n'); horaE[0]=str.charAt(0);horaE[1]=str.charAt(1);minutoE[0]=str.charAt(3);minutoE[1]=str.charAt(4);segundoE[0]=str.charAt(6);segundoE[1]=str.charAt(7); if(atoi(horaE)>23 || atoi(minutoE)>59 ||atoi(segundoE)>59){ Serial.println("paso a modo power-down"); Serial.flush(); digitalWrite(rojo, LOW); digitalWrite(verde, LOW); attachInterrupt(1, wakeUpNow, HIGH); sleepNow(); detachInterrupt(1); }else{ hora=atoi(horaE); minuto=atoi(minutoE); segundo=atoi(segundoE); } } if (darHora){ Serial.print(hora); Serial.print(":"); Serial.print(minuto); Serial.print(":"); Serial.print(segundo); Serial.print("\n"); darHora=LOW; } }
[ "anbaalo@gmail.com" ]
anbaalo@gmail.com
b40e5a5f11f2081a7afc4021d4e108909fa08b2a
9f7fbef81d1e4e7577192f8021dc5d0a74a558ce
/gr8/targets/function_enter.cpp
973fe4c395baea26ba9c9bca39909c243e995afb
[]
no_license
ist424865/co-2017-18
0bda7c3c66aae9051e7ef63605658eeb9991d5e5
388a040c9a815dc90af6790cd01285a7897c5112
refs/heads/master
2021-09-15T03:15:06.078394
2018-05-24T23:34:20
2018-05-24T23:34:20
null
0
0
null
null
null
null
UTF-8
C++
false
false
5,293
cpp
#include "targets/function_enter.h" #include "ast/all.h" // all.h is automatically generated void gr8::function_enter::do_integer_node(cdk::integer_node * const node, int lvl) { // EMPTY } void gr8::function_enter::do_double_node(cdk::double_node * const node, int lvl) { // EMPTY } void gr8::function_enter::do_string_node(cdk::string_node * const node, int lvl) { // EMPTY } void gr8::function_enter::do_nil_node(cdk::nil_node * const node, int lvl) { // EMPTY } void gr8::function_enter::do_data_node(cdk::data_node * const node, int lvl) { // EMPTY } void gr8::function_enter::do_null_node(gr8::null_node *const node, int lvl) { // EMPTY } void gr8::function_enter::do_tweet_node(gr8::tweet_node *const node, int lvl) { // EMPTY } void gr8::function_enter::do_evaluation_node(gr8::evaluation_node *const node, int lvl) { // EMPTY } void gr8::function_enter::do_if_else_node(gr8::if_else_node *const node, int lvl) { node->thenblock()->accept(this, lvl); node->elseblock()->accept(this, lvl); } void gr8::function_enter::do_again_node(gr8::again_node *const node, int lvl) { // EMPTY } void gr8::function_enter::do_sweeping_node(gr8::sweeping_node *const node, int lvl) { node->block()->accept(this, lvl); } void gr8::function_enter::do_return_node(gr8::return_node *const node, int lvl) { // EMPTY } void gr8::function_enter::do_alloc_node(gr8::alloc_node *const node, int lvl) { if (node->type()->name() == basic_type::TYPE_INT || node->type()->name() == basic_type::TYPE_POINTER || node->type()->name() == basic_type::TYPE_STRING) _counter += 4 * dynamic_cast<cdk::integer_node*>(node->argument())->value(); else if (node->type()->name() == basic_type::TYPE_DOUBLE) _counter += 8 * dynamic_cast<cdk::integer_node*>(node->argument())->value(); } void gr8::function_enter::do_function_invocation_node(gr8::function_invocation_node *const node, int lvl) { // EMPTY } void gr8::function_enter::do_identity_node(gr8::identity_node *const node, int lvl) { // EMPTY } void gr8::function_enter::do_address_of_node(gr8::address_of_node *const node, int lvl) { // EMPTY } void gr8::function_enter::do_sequence_node(cdk::sequence_node * const node, int lvl) { for (size_t i = 0; i < node->size(); i++) { node->node(i)->accept(this, lvl); } } void gr8::function_enter::do_block_node(gr8::block_node *const node, int lvl) { if (node->declarations() != nullptr) node->declarations()->accept(this, lvl); if (node->instructions() != nullptr) node->instructions()->accept(this, lvl); } void gr8::function_enter::do_post_node(gr8::post_node *const node, int lvl) { // EMPTY } void gr8::function_enter::do_variable_declaration_node(gr8::variable_declaration_node *const node, int lvl) { if (node->type()->name() == basic_type::TYPE_INT || node->type()->name() == basic_type::TYPE_POINTER || node->type()->name() == basic_type::TYPE_STRING) _counter += 4; else if (node->type()->name() == basic_type::TYPE_DOUBLE) _counter += 8; } void gr8::function_enter::do_function_definition_node(gr8::function_definition_node *const node, int lvl) { node->body()->accept(this, lvl); } void gr8::function_enter::do_index_node(gr8::index_node *const node, int lvl) { // EMPTY } void gr8::function_enter::do_function_declaration_node(gr8::function_declaration_node *const node, int lvl) { // EMPTY } void gr8::function_enter::do_stop_node(gr8::stop_node *const node, int lvl) { // EMPTY } void gr8::function_enter::do_read_node(gr8::read_node *const node, int lvl) { // EMPTY } void gr8::function_enter::do_neg_node(cdk::neg_node * const node, int lvl) { // EMPTY } void gr8::function_enter::do_not_node(cdk::not_node * const node, int lvl) { // EMPTY } void gr8::function_enter::do_and_node(cdk::and_node * const node, int lvl) { // EMPTY } void gr8::function_enter::do_or_node(cdk::or_node * const node, int lvl) { // EMPTY } void gr8::function_enter::do_add_node(cdk::add_node * const node, int lvl) { // EMPTY } void gr8::function_enter::do_sub_node(cdk::sub_node * const node, int lvl) { // EMPTY } void gr8::function_enter::do_mul_node(cdk::mul_node * const node, int lvl) { // EMPTY } void gr8::function_enter::do_div_node(cdk::div_node * const node, int lvl) { // EMPTY } void gr8::function_enter::do_mod_node(cdk::mod_node * const node, int lvl) { // EMPTY } void gr8::function_enter::do_lt_node(cdk::lt_node * const node, int lvl) { // EMPTY } void gr8::function_enter::do_le_node(cdk::le_node * const node, int lvl) { // EMPTY } void gr8::function_enter::do_ge_node(cdk::ge_node * const node, int lvl) { // EMPTY } void gr8::function_enter::do_gt_node(cdk::gt_node * const node, int lvl) { // EMPTY } void gr8::function_enter::do_ne_node(cdk::ne_node * const node, int lvl) { // EMPTY } void gr8::function_enter::do_eq_node(cdk::eq_node * const node, int lvl) { // EMPTY } void gr8::function_enter::do_identifier_node(cdk::identifier_node * const node, int lvl) { // EMPTY } void gr8::function_enter::do_rvalue_node(cdk::rvalue_node * const node, int lvl) { // EMPTY } void gr8::function_enter::do_assignment_node(cdk::assignment_node * const node, int lvl) { // EMPTY } void gr8::function_enter::do_if_node(gr8::if_node * const node, int lvl) { node->block()->accept(this, lvl); }
[ "rui.m.ribeiro@tecnico.ulisboa.pt" ]
rui.m.ribeiro@tecnico.ulisboa.pt
79ca4bfb5b67faa5fb3b4feb7b0d096ba7ccc137
bc287c241c7778ec33866af38f4f7919d591477e
/libraries/ADC/ADC.cpp
481877bcc96f07fee64af65e220097f174402ee1
[]
no_license
tomsmalley/strobe
11ef147664775b8b78901bb5b75c76cb1b688802
f65a0158c29370bda5164facf8b8b967a2971d23
refs/heads/master
2020-12-25T14:12:40.883073
2016-07-06T16:27:50
2016-07-06T16:27:50
60,713,867
22
2
null
null
null
null
UTF-8
C++
false
false
44,113
cpp
/* Teensy 3.x, LC ADC library * https://github.com/pedvide/ADC * Copyright (c) 2015 Pedro Villanueva * * 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. */ /* ADC.cpp: Implements the control of one or more ADC modules of Teensy 3.x, LC * */ #include "ADC.h" /* #if ADC_USE_DMA==1 uint8_t ADC::dma_Ch0 = -1; uint8_t ADC::dma_Ch1 = -1; #endif */ // translate pin number to SC1A nomenclature and viceversa // we need to create this static const arrays so that we can assign the "normal arrays" to the correct one // depending on which ADC module we will be. /* channel2sc1aADCx converts a pin number to their value for the SC1A register, for the ADC0 and ADC1 * numbers with +ADC_SC1A_PIN_MUX (128) means those pins use mux a, the rest use mux b. * numbers with +ADC_SC1A_PIN_DIFF (64) means it's also a differential pin (treated also in the channel2sc1a_diff_ADCx) * For channel2sc1a_diff_ADCx, +ADC_SC1A_PIN_PGA means the pin can use PGA on that ADC * channel2sc1a_diff uses "base A10", that is channel2sc1a_diff[0] corresponds to A10, * this assumes that the differential pins will always start at A10-A11, etc. */ #if defined(ADC_TEENSY_3_0) || defined(ADC_TEENSY_3_1) const uint8_t ADC::channel2sc1aADC0[]= { // new version, gives directly the sc1a number. 0x1F=31 deactivates the ADC. 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, 0, 19, 3, 21, // 0-13, we treat them as A0-A13 5, 14, 8, 9, 13, 12, 6, 7, 15, 4, // 14-23 (A0-A9) 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, // 24-33 0+ADC_SC1A_PIN_DIFF, 19+ADC_SC1A_PIN_DIFF, 3+ADC_SC1A_PIN_DIFF, 21+ADC_SC1A_PIN_DIFF, // 34-37 (A10-A13) 26, 22, 23, 27, 29, 30 // 38-43: temp. sensor, VREF_OUT, A14, bandgap, VREFH, VREFL. A14 isn't connected to anything in Teensy 3.0. }; const uint8_t ADC::channel2sc1a_diff_ADC0[]= { 0+ADC_SC1A_PIN_PGA, 0+ADC_SC1A_PIN_PGA, 3, 3 // A10-A11 (DAD0, PGA0), A12-A13 (DAD3) }; #elif defined(ADC_TEENSY_LC) // Teensy LC const uint8_t ADC::channel2sc1aADC0[]= { // new version, gives directly the sc1a number. 0x1F=31 deactivates the ADC. 5, 14, 8, 9, 13, 12, 6, 7, 15, 11, 0, 4+ADC_SC1A_PIN_MUX, 23, 31, // 0-13, we treat them as A0-A12 + A13= doesn't exist 5, 14, 8, 9, 13, 12, 6, 7, 15, 11, // 14-23 (A0-A9) 0+ADC_SC1A_PIN_DIFF, 4+ADC_SC1A_PIN_MUX+ADC_SC1A_PIN_DIFF, 23, 31, 31, 31, 31, 31, 31, 31, // 24-33 ((A10-A12) + nothing), A11 uses mux a 31, 31, 31, 31, // 34-37 nothing 26, 31, 31, 27, 29, 30 // 38-43: temp. sensor, , , bandgap, VREFH, VREFL. }; const uint8_t ADC::channel2sc1a_diff_ADC0[]= { 0, 0, 31, 31 // A10-A11 (DAD0), A12 is single-ended and A13 doesn't exist }; #endif // defined #if defined(ADC_TEENSY_3_1) const uint8_t ADC::channel2sc1aADC1[]= { // new version, gives directly the sc1a number. 0x1F=31 deactivates the ADC. 31, 31, 8, 9, 31, 31, 31, 31, 31, 31, 3, 31, 0, 19, // 0-13, we treat them as A0-A13 31, 31, 8, 9, 31, 31, 31, 31, 31, 31, // 14-23 (A0-A9) 31, 31, // 24,25 are digital only pins 5+ADC_SC1A_PIN_MUX, 5, 4, 6, 7, 4+ADC_SC1A_PIN_MUX, 31, 31, // 26-33 26=5a, 27=5b, 28=4b, 29=6b, 30=7b, 31=4a, 32,33 are digital only 3+ADC_SC1A_PIN_DIFF, 31+ADC_SC1A_PIN_DIFF, 0+ADC_SC1A_PIN_DIFF, 19+ADC_SC1A_PIN_DIFF, // 34-37 (A10-A13) A11 isn't connected. 26, 18, 31, 27, 29, 30 // 38-43: temp. sensor, VREF_OUT, A14 (not connected), bandgap, VREFH, VREFL. }; const uint8_t ADC::channel2sc1a_diff_ADC1[]= { 3, 3, 0+ADC_SC1A_PIN_PGA, 0+ADC_SC1A_PIN_PGA // A10-A11 (DAD3), A12-A13 (DAD0, PGA1) }; #endif // translate SC1A to pin number #if defined(ADC_TEENSY_3_0) || defined(ADC_TEENSY_3_1) const uint8_t ADC::sc1a2channelADC0[]= { // new version, gives directly the pin number 34, 0, 0, 36, 23, 14, 20, 21, 16, 17, 0, 0, 19, 18, // 0-13 15, 22, 23, 0, 0, 35, 0, 37, // 14-21 39, 40, 0, 0, 38, 41, 42, 43, // VREF_OUT, A14, temp. sensor, bandgap, VREFH, VREFL. 0 // 31 means disabled, but just in case }; #elif defined(ADC_TEENSY_LC) // Teensy LC const uint8_t ADC::sc1a2channelADC0[]= { // new version, gives directly the pin number 24, 0, 0, 0, 25, 14, 20, 21, 16, 17, 0, 23, 19, 18, // 0-13 15, 22, 23, 0, 0, 0, 0, 0, // 14-21 26, 0, 0, 0, 38, 41, 0, 42, 43, // A12, temp. sensor, bandgap, VREFH, VREFL. 0 // 31 means disabled, but just in case }; #endif // defined #if defined(ADC_TEENSY_3_1) const uint8_t ADC::sc1a2channelADC1[]= { // new version, gives directly the pin number 36, 0, 0, 34, 28, 26, 29, 30, 16, 17, 0, 0, 0, 0, // 0-13. 5a=26, 5b=27, 4b=28, 4a=31 0, 0, 0, 0, 39, 37, 0, 0, // 14-21 0, 0, 0, 0, 38, 41, 0, 42, // 22-29. VREF_OUT, A14, temp. sensor, bandgap, VREFH, VREFL. 43 }; #endif ADC::ADC() { //ctor // make sure the clocks to the ADC are on SIM_SCGC6 |= SIM_SCGC6_ADC0; #if ADC_NUM_ADCS>1 SIM_SCGC3 |= SIM_SCGC3_ADC1; #endif adc0 = new ADC_Module(0, channel2sc1aADC0, channel2sc1a_diff_ADC0); #if ADC_NUM_ADCS>1 adc1 = new ADC_Module(1, channel2sc1aADC1, channel2sc1a_diff_ADC1); #endif } /* Set the voltage reference you prefer, * type can be ADC_REF_3V3, ADC_REF_1V2 (not for Teensy LC) or ADC_REF_EXT */ void ADC::setReference(uint8_t type, int8_t adc_num) { if(adc_num==1){ // user wants ADC 1, do nothing if it's a Teensy 3.0 #if ADC_NUM_ADCS>=2 // Teensy 3.1 adc1->setReference(type); #else adc0->fail_flag |= ADC_ERROR_WRONG_ADC; #endif return; } adc0->setReference(type); // adc_num isn't changed or has selected ADC0 return; } // Change the resolution of the measurement. /* * \param bits is the number of bits of resolution. * For single-ended measurements: 8, 10, 12 or 16 bits. * For differential measurements: 9, 11, 13 or 16 bits. * If you want something in between (11 bits single-ended for example) select the inmediate higher * and shift the result one to the right. * If you select, for example, 9 bits and then do a single-ended reading, the resolution will be adjusted to 8 bits * In this case the comparison values will still be correct for analogRead and analogReadDifferential, but not * for startSingle* or startContinous*, so whenever you change the resolution, change also the comparison values. */ void ADC::setResolution(uint8_t bits, int8_t adc_num) { if(adc_num==1){ // user wants ADC 1, do nothing if it's a Teensy 3.0 #if ADC_NUM_ADCS>=2 // Teensy 3.1 adc1->setResolution(bits); #else adc0->fail_flag |= ADC_ERROR_WRONG_ADC; #endif return; } adc0->setResolution(bits); // adc_num isn't changed or has selected ADC0 return; } //! Returns the resolution of the ADC_Module. uint8_t ADC::getResolution(int8_t adc_num) { if(adc_num==1){ // user wants ADC 1, do nothing if it's a Teensy 3.0 #if ADC_NUM_ADCS>=2 // Teensy 3.1 return adc1->getResolution(); #else adc0->fail_flag |= ADC_ERROR_WRONG_ADC; #endif return 0; } return adc0->getResolution(); // adc_num isn't changed or has selected ADC0 } //! Returns the maximum value for a measurement. uint32_t ADC::getMaxValue(int8_t adc_num) { if(adc_num==1){ // user wants ADC 1, do nothing if it's a Teensy 3.0 #if ADC_NUM_ADCS>=2 // Teensy 3.1 return adc1->getMaxValue(); #else adc0->fail_flag |= ADC_ERROR_WRONG_ADC; #endif return 1; } return adc0->getMaxValue(); } // Sets the conversion speed /* * \param speed can be ADC_LOW_SPEED, ADC_MED_SPEED or ADC_HIGH_SPEED * * It recalibrates at the end. */ void ADC::setConversionSpeed(uint8_t speed, int8_t adc_num) { if(adc_num==1){ // user wants ADC 1, do nothing if it's a Teensy 3.0 #if ADC_NUM_ADCS>=2 // Teensy 3.1 adc1->setConversionSpeed(speed); #else adc0->fail_flag |= ADC_ERROR_WRONG_ADC; #endif return; } adc0->setConversionSpeed(speed); // adc_num isn't changed or has selected ADC0 return; } // Sets the sampling speed /* * \param speed can be ADC_LOW_SPEED, ADC_MED_SPEED or ADC_HIGH_SPEED * * It recalibrates at the end. */ void ADC::setSamplingSpeed(uint8_t speed, int8_t adc_num) { if(adc_num==1){ // user wants ADC 1, do nothing if it's a Teensy 3.0 #if ADC_NUM_ADCS>=2 // Teensy 3.1 adc1->setSamplingSpeed(speed); #else adc0->fail_flag |= ADC_ERROR_WRONG_ADC; #endif return; } adc0->setSamplingSpeed(speed); // adc_num isn't changed or has selected ADC0 return; } // Set the number of averages /* * \param num can be 0, 4, 8, 16 or 32. */ void ADC::setAveraging(uint8_t num, int8_t adc_num) { if(adc_num==1){ // user wants ADC 1, do nothing if it's a Teensy 3.0 #if ADC_NUM_ADCS>=2 // Teensy 3.1 adc1->setAveraging(num); #else adc0->fail_flag |= ADC_ERROR_WRONG_ADC; #endif return; } adc0->setAveraging(num); // adc_num isn't changed or has selected ADC0 return; } //! Enable interrupts /** An IRQ_ADC0 Interrupt will be raised when the conversion is completed * (including hardware averages and if the comparison (if any) is true). */ void ADC::enableInterrupts(int8_t adc_num) { if(adc_num==1){ // user wants ADC 1, do nothing if it's a Teensy 3.0 #if ADC_NUM_ADCS>=2 // Teensy 3.1 adc1->enableInterrupts(); #else adc0->fail_flag |= ADC_ERROR_WRONG_ADC; #endif return; } adc0->enableInterrupts(); return; } //! Disable interrupts void ADC::disableInterrupts(int8_t adc_num) { if(adc_num==1){ // user wants ADC 1, do nothing if it's a Teensy 3.0 #if ADC_NUM_ADCS>=2 // Teensy 3.1 adc1->disableInterrupts(); #else adc0->fail_flag |= ADC_ERROR_WRONG_ADC; #endif return; } adc0->disableInterrupts(); return; } //! Enable DMA request /** An ADC DMA request will be raised when the conversion is completed * (including hardware averages and if the comparison (if any) is true). */ void ADC::enableDMA(int8_t adc_num) { if(adc_num==1){ // user wants ADC 1, do nothing if it's a Teensy 3.0 #if ADC_NUM_ADCS>=2 // Teensy 3.1 adc1->enableDMA(); #else adc0->fail_flag |= ADC_ERROR_WRONG_ADC; #endif return; } adc0->enableDMA(); return; } //! Disable ADC DMA request void ADC::disableDMA(int8_t adc_num) { if(adc_num==1){ // user wants ADC 1, do nothing if it's a Teensy 3.0 #if ADC_NUM_ADCS>=2 // Teensy 3.1 adc1->disableDMA(); #else adc0->fail_flag |= ADC_ERROR_WRONG_ADC; #endif return; } adc0->disableDMA(); return; } // Enable the compare function to a single value /* A conversion will be completed only when the ADC value * is >= compValue (greaterThan=true) or < compValue (greaterThan=false) * Call it after changing the resolution * Use with interrupts or poll conversion completion with isComplete() */ void ADC::enableCompare(int16_t compValue, bool greaterThan, int8_t adc_num) { if(adc_num==1){ // user wants ADC 1, do nothing if it's a Teensy 3.0 #if ADC_NUM_ADCS>=2 // Teensy 3.1 adc1->enableCompare(compValue, greaterThan); #else adc0->fail_flag |= ADC_ERROR_WRONG_ADC; #endif return; } adc0->enableCompare(compValue, greaterThan); return; } // Enable the compare function to a range /* A conversion will be completed only when the ADC value is inside (insideRange=1) or outside (=0) * the range given by (lowerLimit, upperLimit),including (inclusive=1) the limits or not (inclusive=0). * See Table 31-78, p. 617 of the freescale manual. * Call it after changing the resolution * Use with interrupts or poll conversion completion with isComplete() */ void ADC::enableCompareRange(int16_t lowerLimit, int16_t upperLimit, bool insideRange, bool inclusive, int8_t adc_num) { if(adc_num==1){ // user wants ADC 1, do nothing if it's a Teensy 3.0 #if ADC_NUM_ADCS>=2 // Teensy 3.1 adc1->enableCompareRange(lowerLimit, upperLimit, insideRange, inclusive); #else adc0->fail_flag |= ADC_ERROR_WRONG_ADC; #endif return; } adc0->enableCompareRange(lowerLimit, upperLimit, insideRange, inclusive); return; } //! Disable the compare function void ADC::disableCompare(int8_t adc_num) { if(adc_num==1){ // user wants ADC 1, do nothing if it's a Teensy 3.0 #if ADC_NUM_ADCS>=2 // Teensy 3.1 adc1->disableCompare(); #else adc0->fail_flag |= ADC_ERROR_WRONG_ADC; #endif return; } adc0->disableCompare(); return; } // Enable and set PGA /* Enables the PGA and sets the gain * Use only for signals lower than 1.2 V * \param gain can be 1, 2, 4, 8, 16, 32 or 64 * */ void ADC::enablePGA(uint8_t gain, int8_t adc_num) { if(adc_num==1){ // user wants ADC 1, do nothing if it's a Teensy 3.0 #if ADC_NUM_ADCS>=2 // Teensy 3.1 adc1->enablePGA(gain); #else adc0->fail_flag |= ADC_ERROR_WRONG_ADC; #endif return; } adc0->enablePGA(gain); return; } //! Returns the PGA level /** PGA level = 2^gain, from 0 to 64 */ uint8_t ADC::getPGA(int8_t adc_num) { if(adc_num==1){ // user wants ADC 1, do nothing if it's a Teensy 3.0 #if ADC_NUM_ADCS>=2 // Teensy 3.1 return adc1->getPGA(); #else adc0->fail_flag |= ADC_ERROR_WRONG_ADC; return 1; #endif } return adc0->getPGA(); } //! Disable PGA void ADC::disablePGA(int8_t adc_num) { if(adc_num==1){ // user wants ADC 1, do nothing if it's a Teensy 3.0 #if ADC_NUM_ADCS>=2 // Teensy 3.1 adc1->disablePGA(); #else adc0->fail_flag |= ADC_ERROR_WRONG_ADC; #endif return; } adc0->disablePGA(); return; } //! Is the ADC converting at the moment? bool ADC::isConverting(int8_t adc_num) { if(adc_num==1){ // user wants ADC 1, do nothing if it's a Teensy 3.0 #if ADC_NUM_ADCS>=2 // Teensy 3.1 return adc1->isConverting(); #else adc0->fail_flag |= ADC_ERROR_WRONG_ADC; #endif return false; } return adc0->isConverting(); } // Is an ADC conversion ready? /* * \return 1 if yes, 0 if not. * When a value is read this function returns 0 until a new value exists * So it only makes sense to call it before analogReadContinuous() or readSingle() */ bool ADC::isComplete(int8_t adc_num) { if(adc_num==1){ // user wants ADC 1, do nothing if it's a Teensy 3.0 #if ADC_NUM_ADCS>=2 // Teensy 3.1 return adc1->isComplete(); #else adc0->fail_flag |= ADC_ERROR_WRONG_ADC; #endif return false; } return adc0->isComplete();; } //! Is the ADC in differential mode? bool ADC::isDifferential(int8_t adc_num) { if(adc_num==1){ // user wants ADC 1, do nothing if it's a Teensy 3.0 #if ADC_NUM_ADCS>=2 // Teensy 3.1 return adc1->isDifferential(); #else adc0->fail_flag |= ADC_ERROR_WRONG_ADC; #endif return false; } return adc0->isDifferential(); } //! Is the ADC in continuous mode? bool ADC::isContinuous(int8_t adc_num) { if(adc_num==1){ // user wants ADC 1, do nothing if it's a Teensy 3.0 #if ADC_NUM_ADCS>=2 // Teensy 3.1 return adc1->isContinuous(); #else adc0->fail_flag |= ADC_ERROR_WRONG_ADC; #endif return false; } return adc0->isContinuous(); } /* Returns the analog value of the pin. * It waits until the value is read and then returns the result. * If a comparison has been set up and fails, it will return ADC_ERROR_VALUE. * This function is interrupt safe, so it will restore the adc to the state it was before being called * If more than one ADC exists, it will select the module with less workload, you can force a selection using * adc_num. If you select ADC1 in Teensy 3.0 it will return ADC_ERROR_VALUE. */ int ADC::analogRead(uint8_t pin, int8_t adc_num) { #if ADC_NUM_ADCS==1 /* Teensy 3.0, LC */ if( adc_num==1 ) { // If asked to use ADC1, return error adc0->fail_flag |= ADC_ERROR_WRONG_ADC; return ADC_ERROR_VALUE; } return adc0->analogRead(pin); // use ADC0 #elif ADC_NUM_ADCS==2 /* Teensy 3.1 */ if( adc_num==-1 ) { // use no ADC in particular // check which ADC can read the pin bool adc0Pin = adc0->checkPin(pin); bool adc1Pin = adc1->checkPin(pin); if(adc0Pin && adc1Pin) { // Both ADCs if( (adc0->num_measurements) > (adc1->num_measurements)) { // use the ADC with less workload return adc1->analogRead(pin); } else { return adc0->analogRead(pin); } } else if(adc0Pin) { // ADC0 return adc0->analogRead(pin); } else if(adc1Pin) { // ADC1 return adc1->analogRead(pin); } else { // pin not valid in any ADC adc0->fail_flag |= ADC_ERROR_WRONG_PIN; adc1->fail_flag |= ADC_ERROR_WRONG_PIN; return ADC_ERROR_VALUE; // all others are invalid } } else if( adc_num==0 ) { // user wants ADC0 return adc0->analogRead(pin); } else if( adc_num==1 ){ // user wants ADC 1 return adc1->analogRead(pin); } adc0->fail_flag |= ADC_ERROR_OTHER; return ADC_ERROR_VALUE; #endif } /* Reads the differential analog value of two pins (pinP - pinN). * It waits until the value is read and then returns the result. * If a comparison has been set up and fails, it will return ADC_ERROR_VALUE. * \param pinP must be A10 or A12. * \param pinN must be A11 (if pinP=A10) or A13 (if pinP=A12). * Other pins will return ADC_ERROR_VALUE. * This function is interrupt safe, so it will restore the adc to the state it was before being called * If more than one ADC exists, it will select the module with less workload, you can force a selection using * adc_num. If you select ADC1 in Teensy 3.0 it will return ADC_ERROR_VALUE. */ int ADC::analogReadDifferential(uint8_t pinP, uint8_t pinN, int8_t adc_num) { #if ADC_NUM_ADCS==1 /* Teensy 3.0, LC */ if( adc_num==1 ) { // If asked to use ADC1, return error adc0->fail_flag |= ADC_ERROR_WRONG_ADC; return ADC_ERROR_VALUE; } return adc0->analogReadDifferential(pinP, pinN); // use ADC0 #elif ADC_NUM_ADCS==2 /* Teensy 3.1 */ if( adc_num==-1 ) { // use no ADC in particular // check which ADC can read the pin bool adc0Pin = adc0->checkDifferentialPins(pinP, pinN); bool adc1Pin = adc1->checkDifferentialPins(pinP, pinN); if(adc0Pin && adc1Pin) { // Both ADCs if( (adc0->num_measurements) > (adc1->num_measurements)) { // use the ADC with less workload return adc1->analogReadDifferential(pinP, pinN); } else { return adc0->analogReadDifferential(pinP, pinN); } } else if(adc0Pin) { // ADC0 return adc0->analogReadDifferential(pinP, pinN); } else if(adc1Pin) { // ADC1 return adc1->analogReadDifferential(pinP, pinN); } else { // pins not valid in any ADC adc0->fail_flag |= ADC_ERROR_WRONG_PIN; adc1->fail_flag |= ADC_ERROR_WRONG_PIN; return ADC_ERROR_VALUE; // all others are invalid } } else if( adc_num==0 ) { // user wants ADC0 return adc0->analogReadDifferential(pinP, pinN); } else if( adc_num==1 ){ // user wants ADC 1 return adc1->analogReadDifferential(pinP, pinN); } adc0->fail_flag |= ADC_ERROR_OTHER; return ADC_ERROR_VALUE; #endif } // Starts an analog measurement on the pin and enables interrupts. /* It returns immediately, get value with readSingle(). * If the pin is incorrect it returns ADC_ERROR_VALUE * This function is interrupt safe. The ADC interrupt will restore the adc to its previous settings and * restart the adc if it stopped a measurement. If you modify the adc_isr then this won't happen. */ bool ADC::startSingleRead(uint8_t pin, int8_t adc_num) { #if ADC_NUM_ADCS==1 /* Teensy 3.0, LC */ if( adc_num==1 ) { // If asked to use ADC1, return error adc0->fail_flag |= ADC_ERROR_WRONG_ADC; return false; } return adc0->startSingleRead(pin); // use ADC0 #elif ADC_NUM_ADCS==2 /* Teensy 3.1 */ if( adc_num==-1 ) { // use no ADC in particular // check which ADC can read the pin bool adc0Pin = adc0->checkPin(pin); bool adc1Pin = adc1->checkPin(pin); if(adc0Pin && adc1Pin) { // Both ADCs if( (adc0->num_measurements) > (adc1->num_measurements)) { // use the ADC with less workload return adc1->startSingleRead(pin); } else { return adc0->startSingleRead(pin); } } else if(adc0Pin) { // ADC0 return adc0->startSingleRead(pin); } else if(adc1Pin) { // ADC1 return adc1->startSingleRead(pin); } else { // pin not valid in any ADC adc0->fail_flag |= ADC_ERROR_WRONG_PIN; adc1->fail_flag |= ADC_ERROR_WRONG_PIN; return false; // all others are invalid } } else if( adc_num==0 ) { // user wants ADC0 return adc0->startSingleRead(pin); } else if( adc_num==1 ){ // user wants ADC 1 return adc1->startSingleRead(pin); } adc0->fail_flag |= ADC_ERROR_OTHER; return false; #endif } // Start a differential conversion between two pins (pinP - pinN) and enables interrupts. /* It returns inmediately, get value with readSingle(). * \param pinP must be A10 or A12. * \param pinN must be A11 (if pinP=A10) or A13 (if pinP=A12). * Other pins will return ADC_ERROR_DIFF_VALUE. * This function is interrupt safe. The ADC interrupt will restore the adc to its previous settings and * restart the adc if it stopped a measurement. If you modify the adc_isr then this won't happen. */ bool ADC::startSingleDifferential(uint8_t pinP, uint8_t pinN, int8_t adc_num) { #if ADC_NUM_ADCS==1 /* Teensy 3.0, LC */ if( adc_num==1 ) { // If asked to use ADC1, return error adc0->fail_flag |= ADC_ERROR_WRONG_ADC; return false; } return adc0->startSingleDifferential(pinP, pinN); // use ADC0 #elif ADC_NUM_ADCS==2 /* Teensy 3.1 */ if( adc_num==-1 ) { // use no ADC in particular // check which ADC can read the pin bool adc0Pin = adc0->checkDifferentialPins(pinP, pinN); bool adc1Pin = adc1->checkDifferentialPins(pinP, pinN); if(adc0Pin && adc1Pin) { // Both ADCs if( (adc0->num_measurements) > (adc1->num_measurements)) { // use the ADC with less workload return adc1->startSingleDifferential(pinP, pinN); } else { return adc0->startSingleDifferential(pinP, pinN); } } else if(adc0Pin) { // ADC0 return adc0->startSingleDifferential(pinP, pinN); } else if(adc1Pin) { // ADC1 return adc1->startSingleDifferential(pinP, pinN); } else { // pins not valid in any ADC adc0->fail_flag |= ADC_ERROR_WRONG_PIN; adc1->fail_flag |= ADC_ERROR_WRONG_PIN; return false; // all others are invalid } } else if( adc_num==0 ) { // user wants ADC0 return adc0->startSingleDifferential(pinP, pinN); } else if( adc_num==1 ){ // user wants ADC 1 return adc1->startSingleDifferential(pinP, pinN); } adc0->fail_flag |= ADC_ERROR_OTHER; return false; #endif } // Reads the analog value of a single conversion. /* Set the conversion with with startSingleRead(pin) or startSingleDifferential(pinP, pinN). * \return the converted value. */ int ADC::readSingle(int8_t adc_num) { if(adc_num==1){ // user wants ADC 1, do nothing if it's a Teensy 3.0 #if ADC_NUM_ADCS>=2 // Teensy 3.1 return adc1->readSingle(); #else adc0->fail_flag |= ADC_ERROR_WRONG_ADC; return ADC_ERROR_VALUE; #endif } return adc0->readSingle(); } // Starts continuous conversion on the pin. /* It returns as soon as the ADC is set, use analogReadContinuous() to read the value. */ bool ADC::startContinuous(uint8_t pin, int8_t adc_num) { #if ADC_NUM_ADCS==1 /* Teensy 3.0, LC */ if( adc_num==1 ) { // If asked to use ADC1, return error adc0->fail_flag |= ADC_ERROR_WRONG_ADC; return false; } return adc0->startContinuous(pin); // use ADC0 #elif ADC_NUM_ADCS==2 /* Teensy 3.1 */ if( adc_num==-1 ) { // use no ADC in particular // check which ADC can read the pin bool adc0Pin = adc0->checkPin(pin); bool adc1Pin = adc1->checkPin(pin); if(adc0Pin && adc1Pin) { // Both ADCs if( (adc0->num_measurements) > (adc1->num_measurements)) { // use the ADC with less workload return adc1->startContinuous(pin); } else { return adc0->startContinuous(pin); } } else if(adc0Pin) { // ADC0 return adc0->startContinuous(pin); } else if(adc1Pin) { // ADC1 return adc1->startContinuous(pin); } else { // pin not valid in any ADC adc0->fail_flag |= ADC_ERROR_WRONG_PIN; adc1->fail_flag |= ADC_ERROR_WRONG_PIN; return false; // all others are invalid } } else if( adc_num==0 ) { // user wants ADC0 return adc0->startContinuous(pin); } else if( adc_num==1 ){ // user wants ADC 1 return adc1->startContinuous(pin); } adc0->fail_flag |= ADC_ERROR_OTHER; return false; #endif } // Starts continuous conversion between the pins (pinP-pinN). /* It returns as soon as the ADC is set, use analogReadContinuous() to read the value. * \param pinP must be A10 or A12. * \param pinN must be A11 (if pinP=A10) or A13 (if pinP=A12). * Other pins will return ADC_ERROR_DIFF_VALUE. */ bool ADC::startContinuousDifferential(uint8_t pinP, uint8_t pinN, int8_t adc_num) { #if ADC_NUM_ADCS==1 /* Teensy 3.0, LC */ if( adc_num==1 ) { // If asked to use ADC1, return error adc0->fail_flag |= ADC_ERROR_WRONG_ADC; return false; } return adc0->startContinuousDifferential(pinP, pinN); // use ADC0 #elif ADC_NUM_ADCS==2 /* Teensy 3.1 */ if( adc_num==-1 ) { // use no ADC in particular // check which ADC can read the pin bool adc0Pin = adc0->checkDifferentialPins(pinP, pinN); bool adc1Pin = adc1->checkDifferentialPins(pinP, pinN); if(adc0Pin && adc1Pin) { // Both ADCs if( (adc0->num_measurements) > (adc1->num_measurements)) { // use the ADC with less workload return adc1->startContinuousDifferential(pinP, pinN); } else { return adc0->startContinuousDifferential(pinP, pinN); } } else if(adc0Pin) { // ADC0 return adc0->startContinuousDifferential(pinP, pinN); } else if(adc1Pin) { // ADC1 return adc1->startContinuousDifferential(pinP, pinN); } else { // pins not valid in any ADC adc0->fail_flag |= ADC_ERROR_WRONG_PIN; adc1->fail_flag |= ADC_ERROR_WRONG_PIN; return false; // all others are invalid } } else if( adc_num==0 ) { // user wants ADC0 return adc0->startContinuousDifferential(pinP, pinN); } else if( adc_num==1 ){ // user wants ADC 1 return adc1->startContinuousDifferential(pinP, pinN); } adc0->fail_flag |= ADC_ERROR_OTHER; return false; #endif } //! Reads the analog value of a continuous conversion. /** Set the continuous conversion with with analogStartContinuous(pin) or startContinuousDifferential(pinP, pinN). * \return the last converted value. * If single-ended and 16 bits it's necessary to typecast it to an unsigned type (like uint16_t), * otherwise values larger than 3.3/2 V are interpreted as negative! */ int ADC::analogReadContinuous(int8_t adc_num) { if(adc_num==1){ // user wants ADC 1, do nothing if it's a Teensy 3.0 #if ADC_NUM_ADCS>=2 return adc1->analogReadContinuous(); #else adc0->fail_flag |= ADC_ERROR_WRONG_ADC; #endif return false; } return adc0->analogReadContinuous(); } //! Stops continuous conversion void ADC::stopContinuous(int8_t adc_num) { if(adc_num==1){ // user wants ADC 1, do nothing if it's a Teensy 3.0 #if ADC_NUM_ADCS>=2 // Teensy 3.1 adc1->stopContinuous(); #else adc0->fail_flag |= ADC_ERROR_WRONG_ADC; #endif return; } adc0->stopContinuous(); return; } //////////////// SYNCHRONIZED BLOCKING METHODS ////////////////// ///// IF THE BOARD HAS ONLY ONE ADC, THEY ARE EMPYT METHODS ///// ///////////////////////////////////////////////////////////////// #if ADC_NUM_ADCS>1 /*Returns the analog values of both pins, measured at the same time by the two ADC modules. * It waits until the value is read and then returns the result as a struct Sync_result, * use Sync_result.result_adc0 and Sync_result.result_adc1. * If a comparison has been set up and fails, it will return ADC_ERROR_VALUE in both fields of the struct. */ ADC::Sync_result ADC::analogSynchronizedRead(uint8_t pin0, uint8_t pin1) { Sync_result res = {ADC_ERROR_VALUE, ADC_ERROR_VALUE}; // check pins if ( !adc0->checkPin(pin0) ) { adc0->fail_flag |= ADC_ERROR_WRONG_PIN; return res; } if ( !adc1->checkPin(pin1) ) { adc1->fail_flag |= ADC_ERROR_WRONG_PIN; return res; } // check if we are interrupting a measurement, store setting if so. // vars to save the current state of the ADC in case it's in use ADC_Module::ADC_Config old_adc0_config = {0}; uint8_t wasADC0InUse = adc0->isConverting(); // is the ADC running now? if(wasADC0InUse) { // this means we're interrupting a conversion // save the current conversion config, the adc isr will restore the adc __disable_irq(); //digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN) ); adc0->saveConfig(&old_adc0_config); __enable_irq(); } ADC_Module::ADC_Config old_adc1_config = {0}; uint8_t wasADC1InUse = adc1->isConverting(); // is the ADC running now? if(wasADC1InUse) { // this means we're interrupting a conversion // save the current conversion config, the adc isr will restore the adc __disable_irq(); //digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN) ); adc1->saveConfig(&old_adc1_config); __enable_irq(); } // no continuous mode adc0->singleMode(); adc1->singleMode(); // start both measurements adc0->startReadFast(pin0); adc1->startReadFast(pin1); // wait for both ADCs to finish while( (adc0->isConverting()) || (adc1->isConverting()) ) { // wait for both to finish yield(); //digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN) ); } __disable_irq(); // make sure nothing interrupts this part if ( adc0->isComplete() ) { // conversion succeded res.result_adc0 = adc0->readSingle(); } else { // comparison was false adc0->fail_flag |= ADC_ERROR_COMPARISON; } if ( adc1->isComplete() ) { // conversion succeded res.result_adc1 = adc1->readSingle(); } else { // comparison was false adc1->fail_flag |= ADC_ERROR_COMPARISON; } __enable_irq(); // if we interrupted a conversion, set it again if (wasADC0InUse) { //digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN) ); adc0->loadConfig(&old_adc0_config); } if (wasADC1InUse) { //digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN) ); adc1->loadConfig(&old_adc1_config); } //digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN) ); return res; } /*Returns the diff analog values of both sets of pins, measured at the same time by the two ADC modules. * It waits until the value is read and then returns the result as a struct Sync_result, * use Sync_result.result_adc0 and Sync_result.result_adc1. * If a comparison has been set up and fails, it will return ADC_ERROR_VALUE in both fields of the struct. */ ADC::Sync_result ADC::analogSynchronizedReadDifferential(uint8_t pin0P, uint8_t pin0N, uint8_t pin1P, uint8_t pin1N) { Sync_result res = {ADC_ERROR_VALUE, ADC_ERROR_VALUE};; // check pins if(!adc0->checkDifferentialPins(pin0P, pin0N)) { adc0->fail_flag |= ADC_ERROR_WRONG_PIN; return res; // all others are invalid } if(!adc1->checkDifferentialPins(pin1P, pin1N)) { adc1->fail_flag |= ADC_ERROR_WRONG_PIN; return res; // all others are invalid } // check if we are interrupting a measurement, store setting if so. // vars to save the current state of the ADC in case it's in use ADC_Module::ADC_Config old_adc0_config = {0}; uint8_t wasADC0InUse = adc0->isConverting(); // is the ADC running now? if(wasADC0InUse) { // this means we're interrupting a conversion // save the current conversion config, the adc isr will restore the adc __disable_irq(); //digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN) ); adc0->saveConfig(&old_adc0_config); __enable_irq(); } ADC_Module::ADC_Config old_adc1_config = {0}; uint8_t wasADC1InUse = adc1->isConverting(); // is the ADC running now? if(wasADC1InUse) { // this means we're interrupting a conversion // save the current conversion config, the adc isr will restore the adc __disable_irq(); //digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN) ); adc1->saveConfig(&old_adc1_config); __enable_irq(); } // no continuous mode adc0->singleMode(); adc1->singleMode(); // start both measurements adc0->startDifferentialFast(pin0P, pin0N); adc1->startDifferentialFast(pin1P, pin1N); // wait for both ADCs to finish while( (adc0->isConverting()) || (adc1->isConverting()) ) { yield(); //digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN) ); } __disable_irq(); // make sure nothing interrupts this part if (adc0->isComplete()) { // conversion succeded res.result_adc0 = adc0->readSingle(); } else { // comparison was false adc0->fail_flag |= ADC_ERROR_COMPARISON; } if (adc1->isComplete()) { // conversion succeded res.result_adc1 = adc1->readSingle(); } else { // comparison was false adc1->fail_flag |= ADC_ERROR_COMPARISON; } __enable_irq(); // if we interrupted a conversion, set it again if (wasADC0InUse) { //digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN) ); adc0->loadConfig(&old_adc0_config); } if (wasADC1InUse) { //digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN) ); adc1->loadConfig(&old_adc1_config); } //digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN) ); return res; } /////////////// SYNCHRONIZED NON-BLOCKING METHODS ////////////// // Starts an analog measurement at the same time on the two ADC modules /* It returns inmediately, get value with readSynchronizedSingle(). * If the pin is incorrect it returns false * If this function interrupts a measurement, it stores the settings in adc_config */ bool ADC::startSynchronizedSingleRead(uint8_t pin0, uint8_t pin1) { // check pins if ( !adc0->checkPin(pin0) ) { adc0->fail_flag |= ADC_ERROR_WRONG_PIN; return false; } if ( !adc1->checkPin(pin1) ) { adc1->fail_flag |= ADC_ERROR_WRONG_PIN; return false; } // check if we are interrupting a measurement, store setting if so. adc0->adcWasInUse = adc0->isConverting(); // is the ADC running now? if(adc0->adcWasInUse) { // this means we're interrupting a conversion // save the current conversion config, the adc isr will restore the adc __disable_irq(); //digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN) ); adc0->saveConfig(&adc0->adc_config); __enable_irq(); } adc1->adcWasInUse = adc1->isConverting(); // is the ADC running now? if(adc1->adcWasInUse) { // this means we're interrupting a conversion // save the current conversion config, the adc isr will restore the adc __disable_irq(); //digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN) ); adc1->saveConfig(&adc1->adc_config); __enable_irq(); } // no continuous mode adc0->singleMode(); adc1->singleMode(); // start both measurements adc0->startReadFast(pin0); adc1->startReadFast(pin1); //digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN) ); return true; } // Start a differential conversion between two pins (pin0P - pin0N) and (pin1P - pin1N) /* It returns inmediately, get value with readSynchronizedSingle(). * \param pinP must be A10 or A12. * \param pinN must be A11 (if pinP=A10) or A13 (if pinP=A12). * Other pins will return false. * If this function interrupts a measurement, it stores the settings in adc_config */ bool ADC::startSynchronizedSingleDifferential(uint8_t pin0P, uint8_t pin0N, uint8_t pin1P, uint8_t pin1N) { // check pins if(!adc0->checkDifferentialPins(pin0P, pin0N)) { adc0->fail_flag |= ADC_ERROR_WRONG_PIN; return false; // all others are invalid } if(!adc1->checkDifferentialPins(pin1P, pin1N)) { adc1->fail_flag |= ADC_ERROR_WRONG_PIN; return false; // all others are invalid } // check if we are interrupting a measurement, store setting if so. adc0->adcWasInUse = adc0->isConverting(); // is the ADC running now? if(adc0->adcWasInUse) { // this means we're interrupting a conversion // save the current conversion config, the adc isr will restore the adc __disable_irq(); //digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN) ); adc0->saveConfig(&adc0->adc_config); __enable_irq(); } adc1->adcWasInUse = adc1->isConverting(); // is the ADC running now? if(adc1->adcWasInUse) { // this means we're interrupting a conversion // save the current conversion config, the adc isr will restore the adc __disable_irq(); //digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN) ); adc1->saveConfig(&adc1->adc_config); __enable_irq(); } // no continuous mode adc0->singleMode(); adc1->singleMode(); // start both measurements adc0->startDifferentialFast(pin0P, pin0N); adc1->startDifferentialFast(pin1P, pin1N); //digitalWriteFast(LED_BUILTIN, !digitalReadFast(LED_BUILTIN) ); return true; } // Reads the analog value of a single conversion. /* * \return the converted value. */ ADC::Sync_result ADC::readSynchronizedSingle() { ADC::Sync_result res; res.result_adc0 = adc0->readSingle(); res.result_adc1 = adc1->readSingle(); return res; } ///////////// SYNCHRONIZED CONTINUOUS CONVERSION METHODS //////////// //! Starts a continuous conversion in both ADCs simultaneously /** Use readSynchronizedContinuous to get the values * */ bool ADC::startSynchronizedContinuous(uint8_t pin0, uint8_t pin1) { // check pins if ( !adc0->checkPin(pin0) ) { adc0->fail_flag |= ADC_ERROR_WRONG_PIN; return false; } if ( !adc1->checkPin(pin1) ) { adc1->fail_flag |= ADC_ERROR_WRONG_PIN; return false; } adc0->startContinuous(pin0); adc1->startContinuous(pin1); // setup the conversions the usual way, but to make sure that they are // as synchronized as possible we stop and restart them one after the other. const uint32_t temp_ADC0_SC1A = ADC0_SC1A; ADC0_SC1A = 0x1F; const uint32_t temp_ADC1_SC1A = ADC1_SC1A; ADC1_SC1A = 0x1F; __disable_irq(); // both measurements should have a maximum delay of an instruction time ADC0_SC1A = temp_ADC0_SC1A; ADC1_SC1A = temp_ADC1_SC1A; __enable_irq(); return true; } //! Starts a continuous differential conversion in both ADCs simultaneously /** Use readSynchronizedContinuous to get the values * */ bool ADC::startSynchronizedContinuousDifferential(uint8_t pin0P, uint8_t pin0N, uint8_t pin1P, uint8_t pin1N) { // check pins if(!adc0->checkDifferentialPins(pin0P, pin0N)) { adc0->fail_flag |= ADC_ERROR_WRONG_PIN; return false; // all others are invalid } if(!adc1->checkDifferentialPins(pin1P, pin1N)) { adc1->fail_flag |= ADC_ERROR_WRONG_PIN; return false; // all others are invalid } adc0->startContinuousDifferential(pin0P, pin0N); adc1->startContinuousDifferential(pin1P, pin1N); // setup the conversions the usual way, but to make sure that they are // as synchronized as possible we stop and restart them one after the other. const uint32_t temp_ADC0_SC1A = ADC0_SC1A; ADC0_SC1A = 0x1F; const uint32_t temp_ADC1_SC1A = ADC1_SC1A; ADC1_SC1A = 0x1F; __disable_irq(); ADC0_SC1A = temp_ADC0_SC1A; ADC1_SC1A = temp_ADC1_SC1A; __enable_irq(); return true; } //! Returns the values of both ADCs. ADC::Sync_result ADC::readSynchronizedContinuous() { ADC::Sync_result res; res.result_adc0 = adc0->analogReadContinuous(); res.result_adc1 = adc1->analogReadContinuous(); return res; } //! Stops synchronous continuous conversion void ADC::stopSynchronizedContinuous() { adc0->stopContinuous(); adc1->stopContinuous(); } #else // ADC_NUM_ADCS=1 // Empty definitions so code written for all Teensy will compile ADC::Sync_result ADC::analogSynchronizedRead(uint8_t pin0, uint8_t pin1) {ADC::Sync_result res={0}; return res;} ADC::Sync_result ADC::analogSynchronizedReadDifferential(uint8_t pin0P, uint8_t pin0N, uint8_t pin1P, uint8_t pin1N) { ADC::Sync_result res={0}; return res; } bool ADC::startSynchronizedSingleRead(uint8_t pin0, uint8_t pin1) { return false; } bool ADC::startSynchronizedSingleDifferential(uint8_t pin0P, uint8_t pin0N, uint8_t pin1P, uint8_t pin1N) { return false; } ADC::Sync_result ADC::readSynchronizedSingle() {ADC::Sync_result res={0}; return res;} bool ADC::startSynchronizedContinuous(uint8_t pin0, uint8_t pin1) {return false;} bool ADC::startSynchronizedContinuousDifferential(uint8_t pin0P, uint8_t pin0N, uint8_t pin1P, uint8_t pin1N) {return false;} ADC::Sync_result ADC::readSynchronizedContinuous() {ADC::Sync_result res={0}; return res;} void ADC::stopSynchronizedContinuous() {} #endif
[ "tfsmalley@gmail.com" ]
tfsmalley@gmail.com
f3f290731e82f8f5bc5c49f5d967ebfd6191525d
21618cdadcde69e4d4084431e43638ebd19f8b76
/slave.h
4af0db48d39be26dd2eec1f93017a97d7aad2732
[ "BSD-2-Clause" ]
permissive
aykevl/domo-avr
3b5ab4fe6dd6c2f57ccfe2481d71311788a736e5
30aa607b498b60ca6ae4e5d5112a98ddf1afa48f
refs/heads/master
2020-09-21T00:56:05.559204
2016-08-30T15:18:54
2016-08-30T15:18:54
66,936,265
0
0
null
null
null
null
UTF-8
C++
false
false
209
h
#ifndef SLAVE_H #define SLAVE_H // Communicate with the Raspberry Pi. class Slave { public: inline Slave() __attribute__((always_inline)); inline void loop() __attribute__((always_inline)); }; #endif
[ "aykevanlaethem@gmail.com" ]
aykevanlaethem@gmail.com
9474d4c4cbea4e848c752d033b59575fa1ac5ca5
703ec46ee5493dcd169e8100d0cfd3555c719144
/d3d12/LabProjects/LabProject03-1/Scene.cpp
275dfb2ee0755559ad95f4fc7bfdbe0a49aada64
[]
no_license
kimduuukbae/Today-I-Learned
e8ca001c815fc7fb02a738bc3eb564e89791bb6a
496a3603f65bedfba83d1a9f2f2fd83b4d0c0269
refs/heads/master
2022-08-07T03:52:46.875576
2022-08-01T05:45:55
2022-08-01T05:45:55
214,361,320
4
0
null
null
null
null
UTF-8
C++
false
false
2,799
cpp
#include "stdafx.h" #include "Scene.h" #include "Shader.h" CScene::CScene() {} CScene::~CScene() {} void CScene::BuildObjects(const ComPtr<ID3D12Device>& device, ID3D12GraphicsCommandList* commandList) { m_pd3dGraphicsRootSignature = CreateGraphicsRootSignature(device.Get()); shaderCount = 1; shaders = new CShader * [shaderCount]; CShader* pShader{ new CShader{} }; pShader->CreateShader(device.Get(), m_pd3dGraphicsRootSignature.Get()); pShader->BuildObjects(device.Get(), commandList); shaders[0] = pShader; } void CScene::ReleaseObjects() { if (m_pd3dGraphicsRootSignature) m_pd3dGraphicsRootSignature->Release(); if (shaders) { for (int i = 0; i < shaderCount; ++i) { shaders[i]->ReleaseShaderVariables(); shaders[i]->ReleaseObjects(); shaders[i]->Release(); } delete[] shaders; } } bool CScene::ProcessInput(){ return false; } void CScene::AnimateObjects(float fTimeElapsed){ for (int i = 0; i < shaderCount; ++i) shaders[i]->AnimateObjects(fTimeElapsed); } void CScene::Render(const ComPtr<ID3D12GraphicsCommandList>& pd3dCommandList){ pd3dCommandList->SetGraphicsRootSignature(m_pd3dGraphicsRootSignature.Get()); for (int i = 0; i < shaderCount; ++i) shaders[i]->Render(pd3dCommandList.Get()); //pd3dCommandList->SetPipelineState(m_pd3dPipelineState.Get()); //pd3dCommandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); //pd3dCommandList->DrawInstanced(3, 1, 0, 0); } ID3D12RootSignature* CScene::CreateGraphicsRootSignature(ID3D12Device* device){ ID3D12RootSignature* rootSignature{ nullptr }; D3D12_ROOT_SIGNATURE_DESC rootSignatureDesc{}; rootSignatureDesc.NumParameters = 0; rootSignatureDesc.pParameters = nullptr; rootSignatureDesc.NumStaticSamplers = 0; rootSignatureDesc.pStaticSamplers = nullptr; rootSignatureDesc.Flags = D3D12_ROOT_SIGNATURE_FLAG_ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT; ID3DBlob* signatureBlob{ nullptr }; ID3DBlob* errorBlob{ nullptr }; D3D12SerializeRootSignature(&rootSignatureDesc, D3D_ROOT_SIGNATURE_VERSION_1, &signatureBlob, &errorBlob); device->CreateRootSignature(0, signatureBlob->GetBufferPointer(), signatureBlob->GetBufferSize(), IID_PPV_ARGS(&rootSignature)); if (signatureBlob) signatureBlob->Release(); if (errorBlob) errorBlob->Release(); return rootSignature; } ID3D12RootSignature* CScene::GetGraphicsRootSignature(){ return m_pd3dGraphicsRootSignature.Get(); } void CScene::ReleaseUploadBuffers(){ if (shaders) { for (int i = 0; i < shaderCount; ++i) { if (shaders[i]) shaders[i]->ReleaseUploadBuffers(); } } } bool CScene::OnProcessingMouseMessage(HWND hWnd, UINT nMessageID, WPARAM wParam, LPARAM lParam) { return false; } bool CScene::OnProcessingKeyboardMessage(HWND hWnd, UINT nMessageID, WPARAM wParam, LPARAM lParam) { return false; }
[ "qlccksdlf@gmail.com" ]
qlccksdlf@gmail.com
97a0c9ee0551abd5fcf21d3c151ffa3936efc777
fe754becf524e7489016b949b22f48db7805febf
/Algorithm/DP/LIS.cpp
134b4c011f1c00b4c1c506403ec447e2f0660b9a
[]
no_license
Jayliu227/codings
ef64a295da4894e22073c6ab626aeb59a75cbaf8
73c223b8f877c6e031d880bd57f5f1f4228d40a0
refs/heads/master
2021-10-09T08:55:40.345838
2018-12-25T02:30:37
2018-12-25T02:30:37
null
0
0
null
null
null
null
UTF-8
C++
false
false
711
cpp
#include<bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; int a[N]; int dp[N][2]; memset(dp, 0, sizeof(dp)); for(int i = 0; i < N; i++){ scanf("%d", &a[i]); } dp[0][0] = 1; dp[0][1] = -1; for(int i = 1; i < N; i++){ dp[i][0] = 1; dp[i][1] = -1; int m = 1; for(int j = i - 1; j >= 0; j--){ if(a[j] <= a[i]){ if(dp[j][0] + 1 > m){ m = dp[j][0] + 1; dp[i][0] = m; dp[i][1] = j; } } } } int mi = 0; int mv = dp[0][0]; for(int i = 1; i < N; i++){ if(dp[i][0] > mv){ mv = dp[i][0]; mi = i; } } cout << dp[mi][0] << endl; while(dp[mi][1] != -1){ cout << a[mi] << " "; mi = dp[mi][1]; } cout << a[mi]; return 0; }
[ "jl7895@nyu.edu" ]
jl7895@nyu.edu
981199026e15a560a16bf3e389ca8e6f4f783bd0
befd896d301d3040fbd6ccda39aa217bf388a0a4
/tensorflow/core/kernels/quantize_and_dequantize_op.h
6b0c5e5a466baf60a771d7aa7754975a0c121138
[ "Apache-2.0" ]
permissive
mktshhr/tensorflow-theta
98369caf55f676c6ae9a5c82ab151bb53d395f36
fe378e1b690d97ed24bad144dee9efffce893c86
refs/heads/master
2020-03-26T14:29:34.200902
2018-10-21T13:39:56
2018-10-21T13:39:56
144,990,240
5
2
Apache-2.0
2018-10-21T13:39:57
2018-08-16T13:17:25
C++
UTF-8
C++
false
false
4,592
h
/* Copyright 2015 The TensorFlow Authors. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ #ifndef TENSORFLOW_CORE_KERNELS_QUANTIZE_AND_DEQUANTIZE_OP_H_ #define TENSORFLOW_CORE_KERNELS_QUANTIZE_AND_DEQUANTIZE_OP_H_ #include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor" #include "tensorflow/core/framework/op_kernel.h" #include "tensorflow/core/framework/tensor_types.h" #include "tensorflow/core/kernels/cwise_ops.h" namespace tensorflow { namespace functor { // TODO(pauldonnelly): 'signed_input' should really be called 'signed_output'. template <typename Device, typename T> struct QuantizeAndDequantizeOneScaleFunctor { void operator()(const Device& d, typename TTypes<T>::ConstVec input, bool signed_input, int num_bits, bool range_given, Tensor* input_min_tensor, Tensor* input_max_tensor, typename TTypes<T>::Vec out); }; // The implementation below runs on both CPU and GPU. template <typename Device, typename T> struct QuantizeAndDequantizeOneScaleImpl { static void Compute(const Device& d, typename TTypes<T>::ConstVec input, bool signed_input, int num_bits, bool range_given, Tensor* input_min_tensor, Tensor* input_max_tensor, typename TTypes<T>::Vec out) { T min_range; T max_range; auto input_min = input_min_tensor->scalar<T>(); auto input_max = input_max_tensor->scalar<T>(); if (!range_given) { input_min.device(d) = input.minimum(); input_max.device(d) = input.maximum(); d.memcpyDeviceToHost(&min_range, input_min.data(), sizeof(T)); d.memcpyDeviceToHost(&max_range, input_max.data(), sizeof(T)); } else { // Copy the range values from their respective tensors on the host. min_range = input_min_tensor->scalar<T>()(); max_range = input_max_tensor->scalar<T>()(); } // Calculate the range for the simulated integer quantization: // e.g. [-128,127] for signed = true, num_bits = 8, // or [0, 255] for signed = false, num_bits = 8. const int64 min_quantized = signed_input ? -(1ULL << (num_bits - 1)) : 0; const int64 max_quantized = min_quantized + ((1ULL << num_bits) - 1); // Determine the maximum scaling factor that would scale // [min_range, max_range] to not exceed [min_quantized, max_quantized], // while keeping 0 unchanged. const T scale_from_min_side = (min_quantized * min_range > 0) ? min_quantized / min_range : std::numeric_limits<T>::max(); const T scale_from_max_side = (max_quantized * max_range > 0) ? max_quantized / max_range : std::numeric_limits<T>::max(); // Note: Avoids changing the side of the range that determines scale. T scale, inverse_scale; if (scale_from_min_side < scale_from_max_side) { scale = scale_from_min_side; inverse_scale = min_range / min_quantized; max_range = max_quantized * inverse_scale; } else { scale = scale_from_max_side; inverse_scale = max_range / max_quantized; min_range = min_quantized * inverse_scale; } if (range_given) { // Note: The clamping here is to avoid overflow in the quantized type. // The semantics of the op does not guarantee to clamp to the specified // min_range and max_range - because we may have changed either min_range // or max_range. out.device(d) = (input.cwiseMin(max_range).cwiseMax(min_range) * scale) .unaryExpr(Eigen::internal::scalar_round_op_google<T>()) * inverse_scale; } else { out.device(d) = (input * scale) .unaryExpr(Eigen::internal::scalar_round_op_google<T>()) * inverse_scale; } } }; } // end of namespace functor } // end of namespace tensorflow #endif // TENSORFLOW_CORE_KERNELS_QUANTIZE_AND_DEQUANTIZE_OP_H_
[ "gardener@tensorflow.org" ]
gardener@tensorflow.org
36ecb1fc3a8d0e0f28c7ac69195152001d0d5eb6
cf703624da441b080d3fb3025ea2cd28223bd5ee
/RoboticCommunications/Pkt_Def.cpp
a66de16e91b5c7247d719a78475fc190d6e5455d
[ "MIT" ]
permissive
gponimansky/fictional-robot
d0b309f05c7d05694a467bdd5fa45880e4f66468
d15131d10f0fe84487058e1d4cf27a653297c4d2
refs/heads/master
2021-05-11T09:02:02.428093
2018-02-24T01:47:05
2018-02-24T01:47:05
118,067,833
1
0
null
null
null
null
UTF-8
C++
false
false
5,991
cpp
#include "Pkt_Def.h" // A default constructor that places the PktDef object in a safe state PktDef::PktDef() { // Set all Header information set to zero packet.header.PktCount = 0; packet.header.Drive = 0; packet.header.Status = 0; packet.header.Sleep = 0; packet.header.Arm = 0; packet.header.Claw = 0; packet.header.Ack = 0; packet.header.Padding = 0; packet.header.Length = HEADERSIZE + sizeof(char); // Set data pointer to nullptr packet.data = nullptr; // CRC set to zero packet.CRC = 0; } // An overloaded constructor that takes a RAW data buffer PktDef::PktDef(char * dataBuffer) { // Populate PktCount and Command Flags int * ptrInt = (int *)&dataBuffer[0]; packet.header.PktCount = *ptrInt++; packet.header.Drive = (char)(*ptrInt) & 0x01; packet.header.Status = (char)(*ptrInt >> 1) & 0x01; packet.header.Sleep = (char)(*ptrInt >> 2) & 0x01; packet.header.Arm = (char)(*ptrInt >> 3) & 0x01; packet.header.Claw = (char)(*ptrInt >> 4) & 0x01; packet.header.Ack = (char)(*ptrInt >> 5) & 0x01; packet.header.Padding = 0; // Populate length in Header char * ptrChar = &dataBuffer[5]; packet.header.Length = (*ptrChar++); // Populate the packet bodydata packet.data = new char[packet.header.Length - HEADERSIZE - sizeof(char)]; for (int i = 0; i < packet.header.Length - HEADERSIZE - sizeof(char); i++) packet.data[i] = *ptrChar++; // Populate the CRC packet.CRC = (*ptrChar); } // A set function that sets the packets command flag based on the CmdType void PktDef::SetCmd(CmdType ct) { switch (ct) { case DRIVE: packet.header.Drive = 1; packet.header.Status = 0; packet.header.Sleep = 0; packet.header.Arm = 0; packet.header.Claw = 0; packet.header.Ack = 0; break; case STATUS: packet.header.Status = 1; break; case SLEEP: packet.header.Drive = 0; packet.header.Status = 0; packet.header.Sleep = 1; packet.header.Arm = 0; packet.header.Claw = 0; packet.header.Ack = 0; delete packet.data; packet.data = nullptr; packet.header.Length = HEADERSIZE + sizeof(char); break; case ARM: packet.header.Drive = 0; packet.header.Status = 0; packet.header.Sleep = 0; packet.header.Arm = 1; packet.header.Claw = 0; packet.header.Ack = 0; break; case CLAW: packet.header.Drive = 0; packet.header.Status = 0; packet.header.Sleep = 0; packet.header.Arm = 0; packet.header.Claw = 1; packet.header.Ack = 0; break; case ACK: packet.header.Ack = 1; break; } } // A set function that takes a pointer to a RAW data buffer and the size of the buffer in bytes. void PktDef::SetBodyData(char * data, int size) { // Set the new packet length with body data packet.header.Length = HEADERSIZE + size + sizeof(char); // Allocate amount of space for data packet.data = new char[size]; // Copies the provided data for (int i = 0; i < size; i++) packet.data[i] = *data++; } // Set function that sets the objects PktCount header variable void PktDef::SetPktCount(int pc) { packet.header.PktCount = pc; } // A query function that returns the CmdType based on the set command flag bit CmdType PktDef::GetCmd() { if (packet.header.Drive & 0x01) return DRIVE; else if (packet.header.Status & 0x01) return STATUS; else if (packet.header.Sleep & 0x01) return SLEEP; else if (packet.header.Arm & 0x01) return ARM; else if (packet.header.Claw & 0x01) return CLAW; else if (packet.header.Ack & 0x01) return ACK; else return EMPTY; } // A query function that returns True / False based on the Ack flag in the header bool PktDef::GetAck() { return packet.header.Ack; } // A query function that returns the packet length in bytes int PktDef::GetLength() { return packet.header.Length; } // A query function that returns a pointer to the objects Body field char * PktDef::GetBodyData() { return packet.data; } // A query function that returns the PktCount value int PktDef::GetPktCount() { return packet.header.PktCount; } /* A function that takes a pointer to a RAW data buffer, the size of the buffer in bytes, and calculates the CRC.If the calculated CRC matches the CRC of the packet in the buffer the function returns TRUE, otherwise FALSE. */ bool PktDef::CheckCRC(char * data, int size) { // Set count variable int count = 0; // Count the CRC of data for (int i = 0; i < size - sizeof(char); i++) for (int j = 0; j < 8; j++) count += ((data[i] >> j) & 0x01); // Compare the CRC of the data to the counted CRC return (count == data[size - sizeof(char)]) ? true : false; } // A function that calculates the CRC and sets the objects packet CRC parameter void PktDef::CalcCRC() { // Set count variable int count = 0; // Count the Header char * ptr = (char*)&packet.header; for (int i = 0; i < HEADERSIZE; i++) for (int j = 0; j < 8; j++) count += ((ptr[i] >> j) & 0x01); // If body data isn't empty if (packet.data != nullptr) { // Count the body data ptr = packet.data; for (int i = 0; i < (packet.header.Length - HEADERSIZE - sizeof(char)); i++) for (int j = 0; j < 8; j++) count += ((ptr[i] >> j) & 0x01); } // Set the CRC count packet.CRC = count; } /* A function that allocates the private RawBuffer and transfers the contents from the objects member variables into a RAW data packet (RawBuffer) for transmission. The address of the allocated RawBuffer is returned. */ char * PktDef::GenPacket() { // Allocate the RawBuffer RawBuffer = new char[packet.header.Length]; // Transfer header data into RawBuffer char * ptr = (char*)&packet.header; for (int i = 0; i < HEADERSIZE; i++) RawBuffer[i] = ptr[i]; // If body data isn't empty if (packet.data != nullptr) { // Transfer body data into RawBuffer ptr = (char*)packet.data; for (int i = 0; i < (packet.header.Length - HEADERSIZE - sizeof(char)); i++) RawBuffer[HEADERSIZE + i] = ptr[i]; } // Transfer the CRC into RawBuffer RawBuffer[packet.header.Length - sizeof(char)] = packet.CRC; // Return RawBuffer return RawBuffer; }
[ "ponimansky.guy@gmail.com" ]
ponimansky.guy@gmail.com
ee95c81f584a2b8f034596f33db52b7c4ba02448
a6859fceb57bb63abf52a237ef1aee6d49e6c898
/book.cpp
ecb436753fbe1f3ce65a060363f811d43261e796
[]
no_license
tina-dragicevic/VjezbeCPP
e0cff325dd2be725f5b0f048e947f80c5a3fe20c
312e35bb343a384e7cab6211b0f886c77b0d1a30
refs/heads/master
2021-03-01T19:27:19.867586
2020-06-04T16:39:08
2020-06-04T16:39:08
245,809,612
0
0
null
null
null
null
UTF-8
C++
false
false
2,251
cpp
#include <iostream> #include <string> #include <string.h> #include <fstream> #include <iterator> #include <vector> #include <cstdlib> #include <bits/stdc++.h> #include "book.hpp" Book::Book(){} Book::Book(std::string name, std::string book){ this->name = name; this-> book = book; //this-> year = year; } /* void Book::print(){ std::cout << "Book" << std::endl; } */ //Book::~Book(){} /* Library::Library(const Book* b){ std::cout << "Lib" << std::endl; p.push_back(new Book()); for(int i = 0; i < p.size(); i++){ std::cout << "Library " << &(p[i]); } } */ void Library::Funk(std::vector<std::string> v, std::string c){ std::string::iterator it = c.begin(); int count = 0; std::string a = ""; //std::cout << *it << " " << std::endl; for (int i = 0; i < c.size(); i++){ //std::cout << c[i] << std::endl; if(c[i] != ';'){ a += c[i]; } else if(c[i] == ';'){ count ++; if(count == 1){ //std::cout << " aaa " << a << std::endl; name = a; //std::cout << " name " << name << std::endl; a = ""; } else if(count == 2){ //std::cout << " bbbb " << a << std::endl; book = a; //std::cout << " book " << book << std::endl; a = ""; } else if((count == 2 || count == 3) && a[i - 1] == 'M' && a[i] == 'B'){ SizeMB += a; } else if((count == 2 || count == 3) && isdigit(a[i])){ NumbOfPages += a; } } // p.push_back(new Book(name, book)); } p.push_back(new Book(name, book)); //std::cout << " name " << name << std::endl; // std::cout << " book " << book << std::endl; } void Library::print(){ for(std::vector<Book*>::iterator it = p.begin(); it != p.end(); it++){ std::cout << (*it)->name << (*it)->book << std::endl; } } Library::~Library(){ std::cout << "dest" << std::endl; for(int i = 0; i < p.size(); i++){ // delete p.at(i); // delete p[i]; p.erase(p.begin() + i); } p.clear(); }
[ "noreply@github.com" ]
tina-dragicevic.noreply@github.com
f8d7b6804b696b4bf745573231ef68f1aefbc0b1
07aaed7174217ad11f873ec37776f1bacff5d314
/src/bindings/openFrameworks/ofMesh.cpp
cf490f131fd657d5317a5c2059506484f53939fe
[]
no_license
hackathon-ro/ofxMoonLight
2d774fb7a0e01c8f948989669f6f2cbd8df00b4c
94e3075b1c3a22c4f99a1628ceceb33dbcbc8635
refs/heads/master
2021-01-22T12:08:50.954001
2013-05-01T13:54:07
2013-05-01T13:54:07
9,562,505
1
2
null
null
null
null
UTF-8
C++
false
false
47,141
cpp
/** * * MACHINE GENERATED FILE. DO NOT EDIT. * * Bindings for class ofMesh * * This file has been generated by dub 2.1.~. */ #include "dub/dub.h" #include "3d/ofMesh.h" /** ofMesh::ofMesh() * api/openFrameworks/3d/ofMesh.h:13 */ static int ofMesh_ofMesh(lua_State *L) { try { int top__ = lua_gettop(L); if (top__ >= 2) { ofPrimitiveMode mode = (ofPrimitiveMode)dub_checkint(L, 1); vector< ofVec3f > *verts = *((vector< ofVec3f > **)dub_checksdata(L, 2, "vector< ofVec3f >")); ofMesh *retval__ = new ofMesh(mode, *verts); dub_pushudata(L, retval__, "ofMesh", true); return 1; } else { ofMesh *retval__ = new ofMesh(); dub_pushudata(L, retval__, "ofMesh", true); return 1; } } catch (std::exception &e) { lua_pushfstring(L, "new: %s", e.what()); } catch (...) { lua_pushfstring(L, "new: Unknown exception"); } return dub_error(L); } /** virtual ofMesh::~ofMesh() * api/openFrameworks/3d/ofMesh.h:15 */ static int ofMesh__ofMesh(lua_State *L) { try { DubUserdata *userdata = ((DubUserdata*)dub_checksdata_d(L, 1, "ofMesh")); if (userdata->gc) { ofMesh *self = (ofMesh *)userdata->ptr; delete self; } userdata->gc = false; return 0; } catch (std::exception &e) { lua_pushfstring(L, "__gc: %s", e.what()); } catch (...) { lua_pushfstring(L, "__gc: Unknown exception"); } return dub_error(L); } /** void ofMesh::setMode(ofPrimitiveMode mode) * api/openFrameworks/3d/ofMesh.h:17 */ static int ofMesh_setMode(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); ofPrimitiveMode mode = (ofPrimitiveMode)dub_checkint(L, 2); self->setMode(mode); return 0; } catch (std::exception &e) { lua_pushfstring(L, "setMode: %s", e.what()); } catch (...) { lua_pushfstring(L, "setMode: Unknown exception"); } return dub_error(L); } /** ofPrimitiveMode ofMesh::getMode() const * api/openFrameworks/3d/ofMesh.h:18 */ static int ofMesh_getMode(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); lua_pushnumber(L, self->getMode()); return 1; } catch (std::exception &e) { lua_pushfstring(L, "getMode: %s", e.what()); } catch (...) { lua_pushfstring(L, "getMode: Unknown exception"); } return dub_error(L); } /** void ofMesh::clear() * api/openFrameworks/3d/ofMesh.h:20 */ static int ofMesh_clear(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); self->clear(); return 0; } catch (std::exception &e) { lua_pushfstring(L, "clear: %s", e.what()); } catch (...) { lua_pushfstring(L, "clear: Unknown exception"); } return dub_error(L); } /** void ofMesh::setupIndicesAuto() * api/openFrameworks/3d/ofMesh.h:22 */ static int ofMesh_setupIndicesAuto(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); self->setupIndicesAuto(); return 0; } catch (std::exception &e) { lua_pushfstring(L, "setupIndicesAuto: %s", e.what()); } catch (...) { lua_pushfstring(L, "setupIndicesAuto: Unknown exception"); } return dub_error(L); } /** ofVec3f ofMesh::getVertex(ofIndexType i) const * api/openFrameworks/3d/ofMesh.h:24 */ static int ofMesh_getVertex(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); ofIndexType *i = *((ofIndexType **)dub_checksdata(L, 2, "ofIndexType")); dub_pushudata(L, new ofVec3f(self->getVertex(*i)), "ofVec3f", true); return 1; } catch (std::exception &e) { lua_pushfstring(L, "getVertex: %s", e.what()); } catch (...) { lua_pushfstring(L, "getVertex: Unknown exception"); } return dub_error(L); } /** void ofMesh::addVertex(const ofVec3f &v) * api/openFrameworks/3d/ofMesh.h:25 */ static int ofMesh_addVertex(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); ofVec3f *v = *((ofVec3f **)dub_checksdata(L, 2, "ofVec3f")); self->addVertex(*v); return 0; } catch (std::exception &e) { lua_pushfstring(L, "addVertex: %s", e.what()); } catch (...) { lua_pushfstring(L, "addVertex: Unknown exception"); } return dub_error(L); } /** void ofMesh::addVertices(const vector< ofVec3f > &verts) * api/openFrameworks/3d/ofMesh.h:26 */ static int ofMesh_addVertices(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); int top__ = lua_gettop(L); if (top__ >= 3) { ofVec3f *verts = *((ofVec3f **)dub_checksdata(L, 2, "ofVec3f")); int amt = dub_checkint(L, 3); self->addVertices(verts, amt); return 0; } else { vector< ofVec3f > *verts = *((vector< ofVec3f > **)dub_checksdata(L, 2, "vector< ofVec3f >")); self->addVertices(*verts); return 0; } } catch (std::exception &e) { lua_pushfstring(L, "addVertices: %s", e.what()); } catch (...) { lua_pushfstring(L, "addVertices: Unknown exception"); } return dub_error(L); } /** void ofMesh::removeVertex(ofIndexType index) * api/openFrameworks/3d/ofMesh.h:28 */ static int ofMesh_removeVertex(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); ofIndexType *index = *((ofIndexType **)dub_checksdata(L, 2, "ofIndexType")); self->removeVertex(*index); return 0; } catch (std::exception &e) { lua_pushfstring(L, "removeVertex: %s", e.what()); } catch (...) { lua_pushfstring(L, "removeVertex: Unknown exception"); } return dub_error(L); } /** void ofMesh::setVertex(ofIndexType index, const ofVec3f &v) * api/openFrameworks/3d/ofMesh.h:29 */ static int ofMesh_setVertex(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); ofIndexType *index = *((ofIndexType **)dub_checksdata(L, 2, "ofIndexType")); ofVec3f *v = *((ofVec3f **)dub_checksdata(L, 3, "ofVec3f")); self->setVertex(*index, *v); return 0; } catch (std::exception &e) { lua_pushfstring(L, "setVertex: %s", e.what()); } catch (...) { lua_pushfstring(L, "setVertex: Unknown exception"); } return dub_error(L); } /** void ofMesh::clearVertices() * api/openFrameworks/3d/ofMesh.h:30 */ static int ofMesh_clearVertices(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); self->clearVertices(); return 0; } catch (std::exception &e) { lua_pushfstring(L, "clearVertices: %s", e.what()); } catch (...) { lua_pushfstring(L, "clearVertices: Unknown exception"); } return dub_error(L); } /** ofVec3f ofMesh::getNormal(ofIndexType i) const * api/openFrameworks/3d/ofMesh.h:32 */ static int ofMesh_getNormal(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); ofIndexType *i = *((ofIndexType **)dub_checksdata(L, 2, "ofIndexType")); dub_pushudata(L, new ofVec3f(self->getNormal(*i)), "ofVec3f", true); return 1; } catch (std::exception &e) { lua_pushfstring(L, "getNormal: %s", e.what()); } catch (...) { lua_pushfstring(L, "getNormal: Unknown exception"); } return dub_error(L); } /** void ofMesh::addNormal(const ofVec3f &n) * api/openFrameworks/3d/ofMesh.h:33 */ static int ofMesh_addNormal(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); ofVec3f *n = *((ofVec3f **)dub_checksdata(L, 2, "ofVec3f")); self->addNormal(*n); return 0; } catch (std::exception &e) { lua_pushfstring(L, "addNormal: %s", e.what()); } catch (...) { lua_pushfstring(L, "addNormal: Unknown exception"); } return dub_error(L); } /** void ofMesh::addNormals(const vector< ofVec3f > &norms) * api/openFrameworks/3d/ofMesh.h:34 */ static int ofMesh_addNormals(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); int top__ = lua_gettop(L); if (top__ >= 3) { ofVec3f *norms = *((ofVec3f **)dub_checksdata(L, 2, "ofVec3f")); int amt = dub_checkint(L, 3); self->addNormals(norms, amt); return 0; } else { vector< ofVec3f > *norms = *((vector< ofVec3f > **)dub_checksdata(L, 2, "vector< ofVec3f >")); self->addNormals(*norms); return 0; } } catch (std::exception &e) { lua_pushfstring(L, "addNormals: %s", e.what()); } catch (...) { lua_pushfstring(L, "addNormals: Unknown exception"); } return dub_error(L); } /** void ofMesh::removeNormal(ofIndexType index) * api/openFrameworks/3d/ofMesh.h:36 */ static int ofMesh_removeNormal(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); ofIndexType *index = *((ofIndexType **)dub_checksdata(L, 2, "ofIndexType")); self->removeNormal(*index); return 0; } catch (std::exception &e) { lua_pushfstring(L, "removeNormal: %s", e.what()); } catch (...) { lua_pushfstring(L, "removeNormal: Unknown exception"); } return dub_error(L); } /** void ofMesh::setNormal(ofIndexType index, const ofVec3f &n) * api/openFrameworks/3d/ofMesh.h:37 */ static int ofMesh_setNormal(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); ofIndexType *index = *((ofIndexType **)dub_checksdata(L, 2, "ofIndexType")); ofVec3f *n = *((ofVec3f **)dub_checksdata(L, 3, "ofVec3f")); self->setNormal(*index, *n); return 0; } catch (std::exception &e) { lua_pushfstring(L, "setNormal: %s", e.what()); } catch (...) { lua_pushfstring(L, "setNormal: Unknown exception"); } return dub_error(L); } /** void ofMesh::clearNormals() * api/openFrameworks/3d/ofMesh.h:38 */ static int ofMesh_clearNormals(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); self->clearNormals(); return 0; } catch (std::exception &e) { lua_pushfstring(L, "clearNormals: %s", e.what()); } catch (...) { lua_pushfstring(L, "clearNormals: Unknown exception"); } return dub_error(L); } /** ofFloatColor ofMesh::getColor(ofIndexType i) const * api/openFrameworks/3d/ofMesh.h:40 */ static int ofMesh_getColor(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); ofIndexType *i = *((ofIndexType **)dub_checksdata(L, 2, "ofIndexType")); dub_pushudata(L, new ofFloatColor(self->getColor(*i)), "ofFloatColor", true); return 1; } catch (std::exception &e) { lua_pushfstring(L, "getColor: %s", e.what()); } catch (...) { lua_pushfstring(L, "getColor: Unknown exception"); } return dub_error(L); } /** void ofMesh::addColor(const ofFloatColor &c) * api/openFrameworks/3d/ofMesh.h:41 */ static int ofMesh_addColor(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); ofFloatColor *c = *((ofFloatColor **)dub_checksdata(L, 2, "ofFloatColor")); self->addColor(*c); return 0; } catch (std::exception &e) { lua_pushfstring(L, "addColor: %s", e.what()); } catch (...) { lua_pushfstring(L, "addColor: Unknown exception"); } return dub_error(L); } /** void ofMesh::addColors(const vector< ofFloatColor > &cols) * api/openFrameworks/3d/ofMesh.h:42 */ static int ofMesh_addColors(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); int top__ = lua_gettop(L); if (top__ >= 3) { ofFloatColor *cols = *((ofFloatColor **)dub_checksdata(L, 2, "ofFloatColor")); int amt = dub_checkint(L, 3); self->addColors(cols, amt); return 0; } else { vector< ofFloatColor > *cols = *((vector< ofFloatColor > **)dub_checksdata(L, 2, "vector< ofFloatColor >")); self->addColors(*cols); return 0; } } catch (std::exception &e) { lua_pushfstring(L, "addColors: %s", e.what()); } catch (...) { lua_pushfstring(L, "addColors: Unknown exception"); } return dub_error(L); } /** void ofMesh::removeColor(ofIndexType index) * api/openFrameworks/3d/ofMesh.h:44 */ static int ofMesh_removeColor(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); ofIndexType *index = *((ofIndexType **)dub_checksdata(L, 2, "ofIndexType")); self->removeColor(*index); return 0; } catch (std::exception &e) { lua_pushfstring(L, "removeColor: %s", e.what()); } catch (...) { lua_pushfstring(L, "removeColor: Unknown exception"); } return dub_error(L); } /** void ofMesh::setColor(ofIndexType index, const ofFloatColor &c) * api/openFrameworks/3d/ofMesh.h:45 */ static int ofMesh_setColor(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); ofIndexType *index = *((ofIndexType **)dub_checksdata(L, 2, "ofIndexType")); ofFloatColor *c = *((ofFloatColor **)dub_checksdata(L, 3, "ofFloatColor")); self->setColor(*index, *c); return 0; } catch (std::exception &e) { lua_pushfstring(L, "setColor: %s", e.what()); } catch (...) { lua_pushfstring(L, "setColor: Unknown exception"); } return dub_error(L); } /** void ofMesh::clearColors() * api/openFrameworks/3d/ofMesh.h:46 */ static int ofMesh_clearColors(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); self->clearColors(); return 0; } catch (std::exception &e) { lua_pushfstring(L, "clearColors: %s", e.what()); } catch (...) { lua_pushfstring(L, "clearColors: Unknown exception"); } return dub_error(L); } /** ofVec2f ofMesh::getTexCoord(ofIndexType i) const * api/openFrameworks/3d/ofMesh.h:48 */ static int ofMesh_getTexCoord(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); ofIndexType *i = *((ofIndexType **)dub_checksdata(L, 2, "ofIndexType")); dub_pushudata(L, new ofVec2f(self->getTexCoord(*i)), "ofVec2f", true); return 1; } catch (std::exception &e) { lua_pushfstring(L, "getTexCoord: %s", e.what()); } catch (...) { lua_pushfstring(L, "getTexCoord: Unknown exception"); } return dub_error(L); } /** void ofMesh::addTexCoord(const ofVec2f &t) * api/openFrameworks/3d/ofMesh.h:49 */ static int ofMesh_addTexCoord(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); ofVec2f *t = *((ofVec2f **)dub_checksdata(L, 2, "ofVec2f")); self->addTexCoord(*t); return 0; } catch (std::exception &e) { lua_pushfstring(L, "addTexCoord: %s", e.what()); } catch (...) { lua_pushfstring(L, "addTexCoord: Unknown exception"); } return dub_error(L); } /** void ofMesh::addTexCoords(const vector< ofVec2f > &tCoords) * api/openFrameworks/3d/ofMesh.h:50 */ static int ofMesh_addTexCoords(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); int top__ = lua_gettop(L); if (top__ >= 3) { ofVec2f *tCoords = *((ofVec2f **)dub_checksdata(L, 2, "ofVec2f")); int amt = dub_checkint(L, 3); self->addTexCoords(tCoords, amt); return 0; } else { vector< ofVec2f > *tCoords = *((vector< ofVec2f > **)dub_checksdata(L, 2, "vector< ofVec2f >")); self->addTexCoords(*tCoords); return 0; } } catch (std::exception &e) { lua_pushfstring(L, "addTexCoords: %s", e.what()); } catch (...) { lua_pushfstring(L, "addTexCoords: Unknown exception"); } return dub_error(L); } /** void ofMesh::removeTexCoord(ofIndexType index) * api/openFrameworks/3d/ofMesh.h:52 */ static int ofMesh_removeTexCoord(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); ofIndexType *index = *((ofIndexType **)dub_checksdata(L, 2, "ofIndexType")); self->removeTexCoord(*index); return 0; } catch (std::exception &e) { lua_pushfstring(L, "removeTexCoord: %s", e.what()); } catch (...) { lua_pushfstring(L, "removeTexCoord: Unknown exception"); } return dub_error(L); } /** void ofMesh::setTexCoord(ofIndexType index, const ofVec2f &t) * api/openFrameworks/3d/ofMesh.h:53 */ static int ofMesh_setTexCoord(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); ofIndexType *index = *((ofIndexType **)dub_checksdata(L, 2, "ofIndexType")); ofVec2f *t = *((ofVec2f **)dub_checksdata(L, 3, "ofVec2f")); self->setTexCoord(*index, *t); return 0; } catch (std::exception &e) { lua_pushfstring(L, "setTexCoord: %s", e.what()); } catch (...) { lua_pushfstring(L, "setTexCoord: Unknown exception"); } return dub_error(L); } /** void ofMesh::clearTexCoords() * api/openFrameworks/3d/ofMesh.h:54 */ static int ofMesh_clearTexCoords(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); self->clearTexCoords(); return 0; } catch (std::exception &e) { lua_pushfstring(L, "clearTexCoords: %s", e.what()); } catch (...) { lua_pushfstring(L, "clearTexCoords: Unknown exception"); } return dub_error(L); } /** ofIndexType ofMesh::getIndex(ofIndexType i) const * api/openFrameworks/3d/ofMesh.h:56 */ static int ofMesh_getIndex(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); ofIndexType *i = *((ofIndexType **)dub_checksdata(L, 2, "ofIndexType")); dub_pushudata(L, new ofIndexType(self->getIndex(*i)), "ofIndexType", true); return 1; } catch (std::exception &e) { lua_pushfstring(L, "getIndex: %s", e.what()); } catch (...) { lua_pushfstring(L, "getIndex: Unknown exception"); } return dub_error(L); } /** void ofMesh::addIndex(ofIndexType i) * api/openFrameworks/3d/ofMesh.h:57 */ static int ofMesh_addIndex(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); ofIndexType *i = *((ofIndexType **)dub_checksdata(L, 2, "ofIndexType")); self->addIndex(*i); return 0; } catch (std::exception &e) { lua_pushfstring(L, "addIndex: %s", e.what()); } catch (...) { lua_pushfstring(L, "addIndex: Unknown exception"); } return dub_error(L); } /** void ofMesh::addIndices(const vector< ofIndexType > &inds) * api/openFrameworks/3d/ofMesh.h:58 */ static int ofMesh_addIndices(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); int top__ = lua_gettop(L); if (top__ >= 3) { ofIndexType *inds = *((ofIndexType **)dub_checksdata(L, 2, "ofIndexType")); int amt = dub_checkint(L, 3); self->addIndices(inds, amt); return 0; } else { vector< ofIndexType > *inds = *((vector< ofIndexType > **)dub_checksdata(L, 2, "vector< ofIndexType >")); self->addIndices(*inds); return 0; } } catch (std::exception &e) { lua_pushfstring(L, "addIndices: %s", e.what()); } catch (...) { lua_pushfstring(L, "addIndices: Unknown exception"); } return dub_error(L); } /** void ofMesh::removeIndex(ofIndexType index) * api/openFrameworks/3d/ofMesh.h:60 */ static int ofMesh_removeIndex(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); ofIndexType *index = *((ofIndexType **)dub_checksdata(L, 2, "ofIndexType")); self->removeIndex(*index); return 0; } catch (std::exception &e) { lua_pushfstring(L, "removeIndex: %s", e.what()); } catch (...) { lua_pushfstring(L, "removeIndex: Unknown exception"); } return dub_error(L); } /** void ofMesh::setIndex(ofIndexType index, ofIndexType val) * api/openFrameworks/3d/ofMesh.h:61 */ static int ofMesh_setIndex(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); ofIndexType *index = *((ofIndexType **)dub_checksdata(L, 2, "ofIndexType")); ofIndexType *val = *((ofIndexType **)dub_checksdata(L, 3, "ofIndexType")); self->setIndex(*index, *val); return 0; } catch (std::exception &e) { lua_pushfstring(L, "setIndex: %s", e.what()); } catch (...) { lua_pushfstring(L, "setIndex: Unknown exception"); } return dub_error(L); } /** void ofMesh::clearIndices() * api/openFrameworks/3d/ofMesh.h:62 */ static int ofMesh_clearIndices(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); self->clearIndices(); return 0; } catch (std::exception &e) { lua_pushfstring(L, "clearIndices: %s", e.what()); } catch (...) { lua_pushfstring(L, "clearIndices: Unknown exception"); } return dub_error(L); } /** void ofMesh::addTriangle(ofIndexType index1, ofIndexType index2, ofIndexType index3) * api/openFrameworks/3d/ofMesh.h:64 */ static int ofMesh_addTriangle(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); ofIndexType *index1 = *((ofIndexType **)dub_checksdata(L, 2, "ofIndexType")); ofIndexType *index2 = *((ofIndexType **)dub_checksdata(L, 3, "ofIndexType")); ofIndexType *index3 = *((ofIndexType **)dub_checksdata(L, 4, "ofIndexType")); self->addTriangle(*index1, *index2, *index3); return 0; } catch (std::exception &e) { lua_pushfstring(L, "addTriangle: %s", e.what()); } catch (...) { lua_pushfstring(L, "addTriangle: Unknown exception"); } return dub_error(L); } /** int ofMesh::getNumVertices() const * api/openFrameworks/3d/ofMesh.h:66 */ static int ofMesh_getNumVertices(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); lua_pushnumber(L, self->getNumVertices()); return 1; } catch (std::exception &e) { lua_pushfstring(L, "getNumVertices: %s", e.what()); } catch (...) { lua_pushfstring(L, "getNumVertices: Unknown exception"); } return dub_error(L); } /** int ofMesh::getNumColors() const * api/openFrameworks/3d/ofMesh.h:67 */ static int ofMesh_getNumColors(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); lua_pushnumber(L, self->getNumColors()); return 1; } catch (std::exception &e) { lua_pushfstring(L, "getNumColors: %s", e.what()); } catch (...) { lua_pushfstring(L, "getNumColors: Unknown exception"); } return dub_error(L); } /** int ofMesh::getNumNormals() const * api/openFrameworks/3d/ofMesh.h:68 */ static int ofMesh_getNumNormals(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); lua_pushnumber(L, self->getNumNormals()); return 1; } catch (std::exception &e) { lua_pushfstring(L, "getNumNormals: %s", e.what()); } catch (...) { lua_pushfstring(L, "getNumNormals: Unknown exception"); } return dub_error(L); } /** int ofMesh::getNumTexCoords() const * api/openFrameworks/3d/ofMesh.h:69 */ static int ofMesh_getNumTexCoords(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); lua_pushnumber(L, self->getNumTexCoords()); return 1; } catch (std::exception &e) { lua_pushfstring(L, "getNumTexCoords: %s", e.what()); } catch (...) { lua_pushfstring(L, "getNumTexCoords: Unknown exception"); } return dub_error(L); } /** int ofMesh::getNumIndices() const * api/openFrameworks/3d/ofMesh.h:70 */ static int ofMesh_getNumIndices(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); lua_pushnumber(L, self->getNumIndices()); return 1; } catch (std::exception &e) { lua_pushfstring(L, "getNumIndices: %s", e.what()); } catch (...) { lua_pushfstring(L, "getNumIndices: Unknown exception"); } return dub_error(L); } /** ofVec3f* ofMesh::getVerticesPointer() * api/openFrameworks/3d/ofMesh.h:72 */ static int ofMesh_getVerticesPointer(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); ofVec3f *retval__ = self->getVerticesPointer(); if (!retval__) return 0; dub_pushudata(L, retval__, "ofVec3f", false); return 1; } catch (std::exception &e) { lua_pushfstring(L, "getVerticesPointer: %s", e.what()); } catch (...) { lua_pushfstring(L, "getVerticesPointer: Unknown exception"); } return dub_error(L); } /** ofFloatColor* ofMesh::getColorsPointer() * api/openFrameworks/3d/ofMesh.h:73 */ static int ofMesh_getColorsPointer(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); ofFloatColor *retval__ = self->getColorsPointer(); if (!retval__) return 0; dub_pushudata(L, retval__, "ofFloatColor", false); return 1; } catch (std::exception &e) { lua_pushfstring(L, "getColorsPointer: %s", e.what()); } catch (...) { lua_pushfstring(L, "getColorsPointer: Unknown exception"); } return dub_error(L); } /** ofVec3f* ofMesh::getNormalsPointer() * api/openFrameworks/3d/ofMesh.h:74 */ static int ofMesh_getNormalsPointer(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); ofVec3f *retval__ = self->getNormalsPointer(); if (!retval__) return 0; dub_pushudata(L, retval__, "ofVec3f", false); return 1; } catch (std::exception &e) { lua_pushfstring(L, "getNormalsPointer: %s", e.what()); } catch (...) { lua_pushfstring(L, "getNormalsPointer: Unknown exception"); } return dub_error(L); } /** ofVec2f* ofMesh::getTexCoordsPointer() * api/openFrameworks/3d/ofMesh.h:75 */ static int ofMesh_getTexCoordsPointer(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); ofVec2f *retval__ = self->getTexCoordsPointer(); if (!retval__) return 0; dub_pushudata(L, retval__, "ofVec2f", false); return 1; } catch (std::exception &e) { lua_pushfstring(L, "getTexCoordsPointer: %s", e.what()); } catch (...) { lua_pushfstring(L, "getTexCoordsPointer: Unknown exception"); } return dub_error(L); } /** ofIndexType* ofMesh::getIndexPointer() * api/openFrameworks/3d/ofMesh.h:76 */ static int ofMesh_getIndexPointer(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); ofIndexType *retval__ = self->getIndexPointer(); if (!retval__) return 0; dub_pushudata(L, retval__, "ofIndexType", false); return 1; } catch (std::exception &e) { lua_pushfstring(L, "getIndexPointer: %s", e.what()); } catch (...) { lua_pushfstring(L, "getIndexPointer: Unknown exception"); } return dub_error(L); } /** vector<ofVec3f>& ofMesh::getVertices() * api/openFrameworks/3d/ofMesh.h:84 */ static int ofMesh_getVertices(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); dub_pushudata(L, &self->getVertices(), "vector< ofVec3f >", false); return 1; } catch (std::exception &e) { lua_pushfstring(L, "getVertices: %s", e.what()); } catch (...) { lua_pushfstring(L, "getVertices: Unknown exception"); } return dub_error(L); } /** vector<ofFloatColor>& ofMesh::getColors() * api/openFrameworks/3d/ofMesh.h:85 */ static int ofMesh_getColors(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); dub_pushudata(L, &self->getColors(), "vector< ofFloatColor >", false); return 1; } catch (std::exception &e) { lua_pushfstring(L, "getColors: %s", e.what()); } catch (...) { lua_pushfstring(L, "getColors: Unknown exception"); } return dub_error(L); } /** vector<ofVec3f>& ofMesh::getNormals() * api/openFrameworks/3d/ofMesh.h:86 */ static int ofMesh_getNormals(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); dub_pushudata(L, &self->getNormals(), "vector< ofVec3f >", false); return 1; } catch (std::exception &e) { lua_pushfstring(L, "getNormals: %s", e.what()); } catch (...) { lua_pushfstring(L, "getNormals: Unknown exception"); } return dub_error(L); } /** vector<ofVec2f>& ofMesh::getTexCoords() * api/openFrameworks/3d/ofMesh.h:87 */ static int ofMesh_getTexCoords(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); dub_pushudata(L, &self->getTexCoords(), "vector< ofVec2f >", false); return 1; } catch (std::exception &e) { lua_pushfstring(L, "getTexCoords: %s", e.what()); } catch (...) { lua_pushfstring(L, "getTexCoords: Unknown exception"); } return dub_error(L); } /** vector<ofIndexType>& ofMesh::getIndices() * api/openFrameworks/3d/ofMesh.h:88 */ static int ofMesh_getIndices(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); dub_pushudata(L, &self->getIndices(), "vector< ofIndexType >", false); return 1; } catch (std::exception &e) { lua_pushfstring(L, "getIndices: %s", e.what()); } catch (...) { lua_pushfstring(L, "getIndices: Unknown exception"); } return dub_error(L); } /** ofVec3f ofMesh::getCentroid() const * api/openFrameworks/3d/ofMesh.h:98 */ static int ofMesh_getCentroid(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); dub_pushudata(L, new ofVec3f(self->getCentroid()), "ofVec3f", true); return 1; } catch (std::exception &e) { lua_pushfstring(L, "getCentroid: %s", e.what()); } catch (...) { lua_pushfstring(L, "getCentroid: Unknown exception"); } return dub_error(L); } /** void ofMesh::setName(string name_) * api/openFrameworks/3d/ofMesh.h:100 */ static int ofMesh_setName(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); size_t name__sz_; const char *name_ = dub_checklstring(L, 2, &name__sz_); self->setName(std::string(name_, name__sz_)); return 0; } catch (std::exception &e) { lua_pushfstring(L, "setName: %s", e.what()); } catch (...) { lua_pushfstring(L, "setName: Unknown exception"); } return dub_error(L); } /** bool ofMesh::haveVertsChanged() * api/openFrameworks/3d/ofMesh.h:102 */ static int ofMesh_haveVertsChanged(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); lua_pushboolean(L, self->haveVertsChanged()); return 1; } catch (std::exception &e) { lua_pushfstring(L, "haveVertsChanged: %s", e.what()); } catch (...) { lua_pushfstring(L, "haveVertsChanged: Unknown exception"); } return dub_error(L); } /** bool ofMesh::haveColorsChanged() * api/openFrameworks/3d/ofMesh.h:103 */ static int ofMesh_haveColorsChanged(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); lua_pushboolean(L, self->haveColorsChanged()); return 1; } catch (std::exception &e) { lua_pushfstring(L, "haveColorsChanged: %s", e.what()); } catch (...) { lua_pushfstring(L, "haveColorsChanged: Unknown exception"); } return dub_error(L); } /** bool ofMesh::haveNormalsChanged() * api/openFrameworks/3d/ofMesh.h:104 */ static int ofMesh_haveNormalsChanged(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); lua_pushboolean(L, self->haveNormalsChanged()); return 1; } catch (std::exception &e) { lua_pushfstring(L, "haveNormalsChanged: %s", e.what()); } catch (...) { lua_pushfstring(L, "haveNormalsChanged: Unknown exception"); } return dub_error(L); } /** bool ofMesh::haveTexCoordsChanged() * api/openFrameworks/3d/ofMesh.h:105 */ static int ofMesh_haveTexCoordsChanged(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); lua_pushboolean(L, self->haveTexCoordsChanged()); return 1; } catch (std::exception &e) { lua_pushfstring(L, "haveTexCoordsChanged: %s", e.what()); } catch (...) { lua_pushfstring(L, "haveTexCoordsChanged: Unknown exception"); } return dub_error(L); } /** bool ofMesh::haveIndicesChanged() * api/openFrameworks/3d/ofMesh.h:106 */ static int ofMesh_haveIndicesChanged(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); lua_pushboolean(L, self->haveIndicesChanged()); return 1; } catch (std::exception &e) { lua_pushfstring(L, "haveIndicesChanged: %s", e.what()); } catch (...) { lua_pushfstring(L, "haveIndicesChanged: Unknown exception"); } return dub_error(L); } /** bool ofMesh::hasVertices() * api/openFrameworks/3d/ofMesh.h:108 */ static int ofMesh_hasVertices(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); lua_pushboolean(L, self->hasVertices()); return 1; } catch (std::exception &e) { lua_pushfstring(L, "hasVertices: %s", e.what()); } catch (...) { lua_pushfstring(L, "hasVertices: Unknown exception"); } return dub_error(L); } /** bool ofMesh::hasColors() * api/openFrameworks/3d/ofMesh.h:109 */ static int ofMesh_hasColors(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); lua_pushboolean(L, self->hasColors()); return 1; } catch (std::exception &e) { lua_pushfstring(L, "hasColors: %s", e.what()); } catch (...) { lua_pushfstring(L, "hasColors: Unknown exception"); } return dub_error(L); } /** bool ofMesh::hasNormals() * api/openFrameworks/3d/ofMesh.h:110 */ static int ofMesh_hasNormals(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); lua_pushboolean(L, self->hasNormals()); return 1; } catch (std::exception &e) { lua_pushfstring(L, "hasNormals: %s", e.what()); } catch (...) { lua_pushfstring(L, "hasNormals: Unknown exception"); } return dub_error(L); } /** bool ofMesh::hasTexCoords() * api/openFrameworks/3d/ofMesh.h:111 */ static int ofMesh_hasTexCoords(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); lua_pushboolean(L, self->hasTexCoords()); return 1; } catch (std::exception &e) { lua_pushfstring(L, "hasTexCoords: %s", e.what()); } catch (...) { lua_pushfstring(L, "hasTexCoords: Unknown exception"); } return dub_error(L); } /** bool ofMesh::hasIndices() * api/openFrameworks/3d/ofMesh.h:112 */ static int ofMesh_hasIndices(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); lua_pushboolean(L, self->hasIndices()); return 1; } catch (std::exception &e) { lua_pushfstring(L, "hasIndices: %s", e.what()); } catch (...) { lua_pushfstring(L, "hasIndices: Unknown exception"); } return dub_error(L); } /** void ofMesh::drawVertices() * api/openFrameworks/3d/ofMesh.h:114 */ static int ofMesh_drawVertices(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); self->drawVertices(); return 0; } catch (std::exception &e) { lua_pushfstring(L, "drawVertices: %s", e.what()); } catch (...) { lua_pushfstring(L, "drawVertices: Unknown exception"); } return dub_error(L); } /** void ofMesh::drawWireframe() * api/openFrameworks/3d/ofMesh.h:115 */ static int ofMesh_drawWireframe(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); self->drawWireframe(); return 0; } catch (std::exception &e) { lua_pushfstring(L, "drawWireframe: %s", e.what()); } catch (...) { lua_pushfstring(L, "drawWireframe: Unknown exception"); } return dub_error(L); } /** void ofMesh::drawFaces() * api/openFrameworks/3d/ofMesh.h:116 */ static int ofMesh_drawFaces(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); self->drawFaces(); return 0; } catch (std::exception &e) { lua_pushfstring(L, "drawFaces: %s", e.what()); } catch (...) { lua_pushfstring(L, "drawFaces: Unknown exception"); } return dub_error(L); } /** void ofMesh::draw() * api/openFrameworks/3d/ofMesh.h:117 */ static int ofMesh_draw(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); self->draw(); return 0; } catch (std::exception &e) { lua_pushfstring(L, "draw: %s", e.what()); } catch (...) { lua_pushfstring(L, "draw: Unknown exception"); } return dub_error(L); } /** void ofMesh::load(string path) * api/openFrameworks/3d/ofMesh.h:119 */ static int ofMesh_load(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); size_t path_sz_; const char *path = dub_checklstring(L, 2, &path_sz_); self->load(std::string(path, path_sz_)); return 0; } catch (std::exception &e) { lua_pushfstring(L, "load: %s", e.what()); } catch (...) { lua_pushfstring(L, "load: Unknown exception"); } return dub_error(L); } /** void ofMesh::save(string path, bool useBinary=false) * api/openFrameworks/3d/ofMesh.h:120 */ static int ofMesh_save(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); int top__ = lua_gettop(L); if (top__ >= 3) { size_t path_sz_; const char *path = dub_checklstring(L, 2, &path_sz_); bool useBinary = dub_checkboolean(L, 3); self->save(std::string(path, path_sz_), useBinary); return 0; } else { size_t path_sz_; const char *path = dub_checklstring(L, 2, &path_sz_); self->save(std::string(path, path_sz_)); return 0; } } catch (std::exception &e) { lua_pushfstring(L, "save: %s", e.what()); } catch (...) { lua_pushfstring(L, "save: Unknown exception"); } return dub_error(L); } /** virtual void ofMesh::enableColors() * api/openFrameworks/3d/ofMesh.h:122 */ static int ofMesh_enableColors(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); self->enableColors(); return 0; } catch (std::exception &e) { lua_pushfstring(L, "enableColors: %s", e.what()); } catch (...) { lua_pushfstring(L, "enableColors: Unknown exception"); } return dub_error(L); } /** virtual void ofMesh::enableTextures() * api/openFrameworks/3d/ofMesh.h:123 */ static int ofMesh_enableTextures(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); self->enableTextures(); return 0; } catch (std::exception &e) { lua_pushfstring(L, "enableTextures: %s", e.what()); } catch (...) { lua_pushfstring(L, "enableTextures: Unknown exception"); } return dub_error(L); } /** virtual void ofMesh::enableNormals() * api/openFrameworks/3d/ofMesh.h:124 */ static int ofMesh_enableNormals(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); self->enableNormals(); return 0; } catch (std::exception &e) { lua_pushfstring(L, "enableNormals: %s", e.what()); } catch (...) { lua_pushfstring(L, "enableNormals: Unknown exception"); } return dub_error(L); } /** virtual void ofMesh::enableIndices() * api/openFrameworks/3d/ofMesh.h:125 */ static int ofMesh_enableIndices(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); self->enableIndices(); return 0; } catch (std::exception &e) { lua_pushfstring(L, "enableIndices: %s", e.what()); } catch (...) { lua_pushfstring(L, "enableIndices: Unknown exception"); } return dub_error(L); } /** virtual void ofMesh::disableColors() * api/openFrameworks/3d/ofMesh.h:127 */ static int ofMesh_disableColors(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); self->disableColors(); return 0; } catch (std::exception &e) { lua_pushfstring(L, "disableColors: %s", e.what()); } catch (...) { lua_pushfstring(L, "disableColors: Unknown exception"); } return dub_error(L); } /** virtual void ofMesh::disableTextures() * api/openFrameworks/3d/ofMesh.h:128 */ static int ofMesh_disableTextures(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); self->disableTextures(); return 0; } catch (std::exception &e) { lua_pushfstring(L, "disableTextures: %s", e.what()); } catch (...) { lua_pushfstring(L, "disableTextures: Unknown exception"); } return dub_error(L); } /** virtual void ofMesh::disableNormals() * api/openFrameworks/3d/ofMesh.h:129 */ static int ofMesh_disableNormals(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); self->disableNormals(); return 0; } catch (std::exception &e) { lua_pushfstring(L, "disableNormals: %s", e.what()); } catch (...) { lua_pushfstring(L, "disableNormals: Unknown exception"); } return dub_error(L); } /** virtual void ofMesh::disableIndices() * api/openFrameworks/3d/ofMesh.h:130 */ static int ofMesh_disableIndices(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); self->disableIndices(); return 0; } catch (std::exception &e) { lua_pushfstring(L, "disableIndices: %s", e.what()); } catch (...) { lua_pushfstring(L, "disableIndices: Unknown exception"); } return dub_error(L); } /** virtual bool ofMesh::usingColors() * api/openFrameworks/3d/ofMesh.h:132 */ static int ofMesh_usingColors(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); lua_pushboolean(L, self->usingColors()); return 1; } catch (std::exception &e) { lua_pushfstring(L, "usingColors: %s", e.what()); } catch (...) { lua_pushfstring(L, "usingColors: Unknown exception"); } return dub_error(L); } /** virtual bool ofMesh::usingTextures() * api/openFrameworks/3d/ofMesh.h:133 */ static int ofMesh_usingTextures(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); lua_pushboolean(L, self->usingTextures()); return 1; } catch (std::exception &e) { lua_pushfstring(L, "usingTextures: %s", e.what()); } catch (...) { lua_pushfstring(L, "usingTextures: Unknown exception"); } return dub_error(L); } /** virtual bool ofMesh::usingNormals() * api/openFrameworks/3d/ofMesh.h:134 */ static int ofMesh_usingNormals(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); lua_pushboolean(L, self->usingNormals()); return 1; } catch (std::exception &e) { lua_pushfstring(L, "usingNormals: %s", e.what()); } catch (...) { lua_pushfstring(L, "usingNormals: Unknown exception"); } return dub_error(L); } /** virtual bool ofMesh::usingIndices() * api/openFrameworks/3d/ofMesh.h:135 */ static int ofMesh_usingIndices(lua_State *L) { try { ofMesh *self = *((ofMesh **)dub_checksdata(L, 1, "ofMesh")); lua_pushboolean(L, self->usingIndices()); return 1; } catch (std::exception &e) { lua_pushfstring(L, "usingIndices: %s", e.what()); } catch (...) { lua_pushfstring(L, "usingIndices: Unknown exception"); } return dub_error(L); } // --=============================================== __tostring static int ofMesh___tostring(lua_State *L) { ofMesh *self = *((ofMesh **)dub_checksdata_n(L, 1, "ofMesh")); lua_pushfstring(L, "ofMesh: %p", self); return 1; } // --=============================================== METHODS static const struct luaL_Reg ofMesh_member_methods[] = { { "new" , ofMesh_ofMesh }, { "__gc" , ofMesh__ofMesh }, { "setMode" , ofMesh_setMode }, { "getMode" , ofMesh_getMode }, { "clear" , ofMesh_clear }, { "setupIndicesAuto", ofMesh_setupIndicesAuto }, { "getVertex" , ofMesh_getVertex }, { "addVertex" , ofMesh_addVertex }, { "addVertices" , ofMesh_addVertices }, { "removeVertex" , ofMesh_removeVertex }, { "setVertex" , ofMesh_setVertex }, { "clearVertices", ofMesh_clearVertices }, { "getNormal" , ofMesh_getNormal }, { "addNormal" , ofMesh_addNormal }, { "addNormals" , ofMesh_addNormals }, { "removeNormal" , ofMesh_removeNormal }, { "setNormal" , ofMesh_setNormal }, { "clearNormals" , ofMesh_clearNormals }, { "getColor" , ofMesh_getColor }, { "addColor" , ofMesh_addColor }, { "addColors" , ofMesh_addColors }, { "removeColor" , ofMesh_removeColor }, { "setColor" , ofMesh_setColor }, { "clearColors" , ofMesh_clearColors }, { "getTexCoord" , ofMesh_getTexCoord }, { "addTexCoord" , ofMesh_addTexCoord }, { "addTexCoords" , ofMesh_addTexCoords }, { "removeTexCoord", ofMesh_removeTexCoord }, { "setTexCoord" , ofMesh_setTexCoord }, { "clearTexCoords", ofMesh_clearTexCoords }, { "getIndex" , ofMesh_getIndex }, { "addIndex" , ofMesh_addIndex }, { "addIndices" , ofMesh_addIndices }, { "removeIndex" , ofMesh_removeIndex }, { "setIndex" , ofMesh_setIndex }, { "clearIndices" , ofMesh_clearIndices }, { "addTriangle" , ofMesh_addTriangle }, { "getNumVertices", ofMesh_getNumVertices }, { "getNumColors" , ofMesh_getNumColors }, { "getNumNormals", ofMesh_getNumNormals }, { "getNumTexCoords", ofMesh_getNumTexCoords }, { "getNumIndices", ofMesh_getNumIndices }, { "getVerticesPointer", ofMesh_getVerticesPointer }, { "getColorsPointer", ofMesh_getColorsPointer }, { "getNormalsPointer", ofMesh_getNormalsPointer }, { "getTexCoordsPointer", ofMesh_getTexCoordsPointer }, { "getIndexPointer", ofMesh_getIndexPointer }, { "getVertices" , ofMesh_getVertices }, { "getColors" , ofMesh_getColors }, { "getNormals" , ofMesh_getNormals }, { "getTexCoords" , ofMesh_getTexCoords }, { "getIndices" , ofMesh_getIndices }, { "getCentroid" , ofMesh_getCentroid }, { "setName" , ofMesh_setName }, { "haveVertsChanged", ofMesh_haveVertsChanged }, { "haveColorsChanged", ofMesh_haveColorsChanged }, { "haveNormalsChanged", ofMesh_haveNormalsChanged }, { "haveTexCoordsChanged", ofMesh_haveTexCoordsChanged }, { "haveIndicesChanged", ofMesh_haveIndicesChanged }, { "hasVertices" , ofMesh_hasVertices }, { "hasColors" , ofMesh_hasColors }, { "hasNormals" , ofMesh_hasNormals }, { "hasTexCoords" , ofMesh_hasTexCoords }, { "hasIndices" , ofMesh_hasIndices }, { "drawVertices" , ofMesh_drawVertices }, { "drawWireframe", ofMesh_drawWireframe }, { "drawFaces" , ofMesh_drawFaces }, { "draw" , ofMesh_draw }, { "load" , ofMesh_load }, { "save" , ofMesh_save }, { "enableColors" , ofMesh_enableColors }, { "enableTextures", ofMesh_enableTextures }, { "enableNormals", ofMesh_enableNormals }, { "enableIndices", ofMesh_enableIndices }, { "disableColors", ofMesh_disableColors }, { "disableTextures", ofMesh_disableTextures }, { "disableNormals", ofMesh_disableNormals }, { "disableIndices", ofMesh_disableIndices }, { "usingColors" , ofMesh_usingColors }, { "usingTextures", ofMesh_usingTextures }, { "usingNormals" , ofMesh_usingNormals }, { "usingIndices" , ofMesh_usingIndices }, { "__tostring" , ofMesh___tostring }, { "deleted" , dub_isDeleted }, { NULL, NULL}, }; extern "C" int luaopen_ofMesh(lua_State *L) { // Create the metatable which will contain all the member methods luaL_newmetatable(L, "ofMesh"); // <mt> // register member methods luaL_register(L, NULL, ofMesh_member_methods); // save meta-table in _G dub_register(L, "_G", "ofMesh", "ofMesh"); // <mt> lua_pop(L, 1); return 0; }
[ "leonard.chioveanu@gmail.com" ]
leonard.chioveanu@gmail.com
adef5d2ec738c540c7c15dd2460378e5a53c2871
259329665605d26dd12e3e99896d20a46ff6ae8b
/Capter13/1309.cpp
85a089ef95cf9469a70897c405d7ba68793002d5
[]
no_license
wada811/MeikaiClangNyumon
55cc45ae9411347d6d57d176dab3946db2f17a0f
b68a426a783654ca0a5f5c7b5676321f751dcbc6
refs/heads/master
2021-01-20T11:25:21.724263
2012-02-23T14:18:32
2012-02-23T14:18:32
3,524,224
1
0
null
null
null
null
SHIFT_JIS
C++
false
false
980
cpp
/* 演習13-9:List13-7のプログラムをもとに、すべての英小文字を英大文字に変換しながらコピーするプログラムを作成せよ。 */ #include <stdio.h> #include <ctype.h> int main(void){ int ch; FILE *sfp, *dfp; char sname[64], dname[64]; printf("コピー元ファイル名:"); scanf("%s", sname); printf("コピー先ファイル名:"); scanf("%s", dname); if((sfp = fopen(sname, "r")) == NULL ){ printf("\aコピー元ファイルをオープンできません。\n"); }else{ if((dfp = fopen(dname, "w")) == NULL){ printf("\aコピー先ファイルをオープンできません。\n"); }else{ while((ch = fgetc(sfp)) != EOF){ ch = toupper(ch); fputc(ch, dfp); } fclose(dfp); } fclose(sfp); } return 0; }
[ "89.at.usi@gmail.com" ]
89.at.usi@gmail.com
42a28e2524374784c06010ba028e486ab2d36fc7
3dbdf3cf83418d139f14ad0d82df996477434114
/MyTetris/Figure.cpp
e22b65f956f4d6bff3dba9b38585a374162eab30
[]
no_license
Sergey978/MyTetris
2f536605c4b36eb6ff66709f8f6ea4c55f06502a
716cbacf25a140171d30ef80d914f5b7d9b47ae8
refs/heads/master
2020-03-25T23:41:15.434717
2018-08-10T13:13:27
2018-08-10T13:13:27
140,558,330
0
0
null
null
null
null
UTF-8
C++
false
false
1,862
cpp
#include "Figure.h" #include "CoordMask.h" #include<array> Figure::Figure(Coord metaPointCoords) { this->metaPointCoord = metaPointCoords; this->currentRotation = RotationMode::NORMAL; this->form = FigureForm::getRandomForm(); } Figure::Figure(Coord metaPointCoords, RotationMode::Mode rotation, FigureForm::Form form) { this->metaPointCoord = metaPointCoords; this->currentRotation = rotation; this->form = form; } std::array<Coord, Constants::MAX_FIGURE_WIDTH> Figure::getCoords() { return CoordMask::generateFigure(metaPointCoord, currentRotation , form); } std::array<Coord, Constants::MAX_FIGURE_WIDTH> Figure::getRotatedCoords() { return CoordMask::generateFigure(metaPointCoord, RotationMode::getNextRotationFrom(currentRotation), form); } void Figure::rotate() { currentRotation = RotationMode::getNextRotationFrom(currentRotation); } std::array<Coord, Constants::MAX_FIGURE_WIDTH> Figure::getShiftedCoords(ShiftDirection direction) { Coord newFirstCell ; switch (direction) { case LEFT: newFirstCell = Coord(metaPointCoord.x - 1, metaPointCoord.y); break; case RIGHT: newFirstCell = Coord(metaPointCoord.x + 1, metaPointCoord.y); break; } return CoordMask::generateFigure(newFirstCell, currentRotation, form); } void Figure::shift(ShiftDirection direction) { switch (direction) { case LEFT: metaPointCoord.x--; break; case RIGHT: metaPointCoord.x++; break; } } std::array<Coord, Constants::MAX_FIGURE_WIDTH> Figure::getFallenCoords() { Coord newFirstCell = Coord(metaPointCoord.x, metaPointCoord.y - 1); return CoordMask::generateFigure(newFirstCell, currentRotation, form); } void Figure::fall() { metaPointCoord.y--; } Figure::~Figure() { }
[ "Sergey@service1" ]
Sergey@service1
d242920ea7d00bde505815cf9c0eca9219ebb36a
f660c3b78634794e1b32ee9c139e9fb9539bc1a3
/SE-SEM2-Assigns/CGL/DottedLine1.cpp
ef2429af1f3829bf7b8767a0d51d41dc763683af
[]
no_license
ManishDV/Engineering-Assignments
2054f4bc3139df535e4c96c3affe21f1a510c522
a4fcb14793e4818b72c5a065708735a83cfbe55a
refs/heads/master
2021-06-11T20:01:43.607742
2021-05-30T09:30:31
2021-05-30T09:30:31
194,872,155
3
1
null
null
null
null
UTF-8
C++
false
false
4,179
cpp
#include <iostream> #include <GL/gl.h> #include <GL/glu.h> #include <GL/glut.h> #include <math.h> #include <string.h> using namespace std; struct point{ GLfloat x; GLfloat y; }; struct point p1; struct point p2; int count = 0; int CountDraw = 0; int SB = 0; void print(int x, int y,int z, char *string) { //set the position of the text in the window using the x and y coordinates glRasterPos2f(x,y); //get the length of the string to display int len = (int)strlen(string); //loop to display character by character for (int i = 0; i<len; i++) { glutBitmapCharacter(GLUT_BITMAP_HELVETICA_12,string[i]); } } void drawDDA(struct point p1,struct point p2){ GLfloat dx = p2.x - p1.x; GLfloat dy = p2.y - p1.y; GLfloat x1 = p1.x; GLfloat y1 = p1.y; GLfloat step = 0; if (abs(dx) > abs(dy)) { step = abs(dx); } else { step = abs(dy); } GLfloat xInc = dx / step; GLfloat yInc = dy / step; glBegin(GL_POINTS); for (float i = 1; i <= step; i++) { cout<<"\nCountDraw: "<<CountDraw; cout<<"\nI: "<<i; CountDraw++; //For( _____ _ ____ _ ______ _ ________ _ _______) this type of line. // if(CountDraw < 50 && SB == 0){ // glColor3f(0.0,0.0,0.0); // } // if(CountDraw > 50 && CountDraw < 65 && SB == 0){ // glColor3f(1.0,1.0,1.0); // } // if(CountDraw > 65 && SB == 0){ // CountDraw = 0; // SB = 1; // } // if(CountDraw < 15 && SB == 1){ // glColor3f(0.0,0.0,0.0); // } // if(CountDraw > 15 && CountDraw < 30 && SB == 1){ // glColor3f(1.0,1.0,1.0); // } // if(CountDraw > 30 && SB == 1){ // CountDraw = 0; // SB = 0; // } // For (--------------------) this type of line. if(CountDraw < 50){ glColor3f(0.0,0.0,0.0); } if(CountDraw > 50 && CountDraw < 100){ glColor3f(1.0,1.0,1.0); } if(CountDraw > 100){ CountDraw = 0; } // For (_ _ _ _ _ _ _ _ _ _ _ _ _) this type of line. // if(CountDraw < 20){ // glColor3f(0.0,0.0,0.0); // } // if(CountDraw > 20 && CountDraw < 30){ // glColor3f(1.0,1.0,1.0); // } // if(CountDraw > 40){ // CountDraw = 0; // } glVertex2f(ceil(x1), ceil(y1)); x1 += xInc; y1 += yInc; } glEnd(); glFlush(); } void mouse(int button,int state,int x,int y){ if(button == GLUT_LEFT_BUTTON && state == GLUT_DOWN){ cout<<"\nX: "<<x; cout<<"\nY: "<<y; p1.x =2*x - 400; p1.y =400 - 2*y; count++; cout<<"\nX: "<<p1.x; cout<<"\nY: "<<p1.y; cout<<"\n\n"; } if(count == 1) p2 = p1; if(count == 2){ drawDDA(p2,p1); count = 0; } } void render(){ struct point p3 = {-400,0}; struct point p4 = {400,0}; // drawDDA(p3,p4); glBegin(GL_LINES); glVertex2f(p3.x,p3.y); glVertex2f(p4.x,p4.y); glEnd(); p3 = {0,400}; p4 = {0,-400}; // drawDDA(p3,p4); glPointSize(5.0); glBegin(GL_LINES); glVertex2f(p3.x,p3.y); glVertex2f(p4.x,p4.y); glEnd(); glEnable(GL_LINE_SMOOTH); print(-70,-25,10,(char *)"(0,0)"); glFlush(); } void Init(){ glClearColor(1.0,1.0,1.0,0.0); glClear(GL_COLOR_BUFFER_BIT); glColor3f(0.0,0.0,0.0); gluOrtho2D(-400,400,-400,400); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFlush(); } int main(int argc ,char** argv){ glutInit(&argc,argv); glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE); glutInitWindowPosition(400,400); glutInitWindowSize(400,400); glutCreateWindow("Dotted Line Pattern 1"); Init(); glutDisplayFunc(render); glutMouseFunc(mouse); glutMainLoop(); return 0; }
[ "manishvisave149@gmail.com" ]
manishvisave149@gmail.com
6119e15f85ff5fae8d26e191c3e9dc0fa66f9d33
f9dd7fb236f557f46dc7b627f3b271b072b70b18
/code/cgame/cg_draw.cpp
70919cb1167736e147d404ac93126b4ad7e30123
[]
no_license
emileb/JK3
b74a782de237326dabbf454e8174bb442fa7393f
dee58b46ee31690fae82fd5671d2c0b5b806840d
refs/heads/master
2021-01-19T05:25:21.632760
2014-02-27T17:48:52
2014-02-27T17:48:52
17,257,706
2
0
null
null
null
null
UTF-8
C++
false
false
95,784
cpp
// cg_draw.c -- draw all of the graphical elements during // active (after loading) gameplay // this line must stay at top so the whole PCH thing works... #include "cg_headers.h" //#include "cg_local.h" #include "cg_media.h" #include "../game/objectives.h" #include "../game/g_vehicles.h" #include "../game/g_local.h" #ifdef _XBOX #include "../client/fffx.h" #endif extern vmCvar_t cg_debugHealthBars; extern Vehicle_t *G_IsRidingVehicle( gentity_t *ent ); void CG_DrawIconBackground(void); void CG_DrawMissionInformation( void ); void CG_DrawInventorySelect( void ); void CG_DrawForceSelect( void ); qboolean CG_WorldCoordToScreenCoord(vec3_t worldCoord, int *x, int *y); qboolean CG_WorldCoordToScreenCoordFloat(vec3_t worldCoord, float *x, float *y); extern float g_crosshairEntDist; extern int g_crosshairSameEntTime; extern int g_crosshairEntNum; extern int g_crosshairEntTime; qboolean cg_forceCrosshair = qfalse; // bad cheating extern int g_rocketLockEntNum; extern int g_rocketLockTime; extern int g_rocketSlackTime; vec3_t vfwd; vec3_t vright; vec3_t vup; vec3_t vfwd_n; vec3_t vright_n; vec3_t vup_n; int infoStringCount; int cgRageTime = 0; int cgRageFadeTime = 0; float cgRageFadeVal = 0; int cgRageRecTime = 0; int cgRageRecFadeTime = 0; float cgRageRecFadeVal = 0; int cgAbsorbTime = 0; int cgAbsorbFadeTime = 0; float cgAbsorbFadeVal = 0; int cgProtectTime = 0; int cgProtectFadeTime = 0; float cgProtectFadeVal = 0; //=============================================================== /* ================ CG_DrawMessageLit ================ */ static void CG_DrawMessageLit(centity_t *cent,int x,int y) { cgi_R_SetColor(colorTable[CT_WHITE]); if (cg.missionInfoFlashTime > cg.time ) { if (!((cg.time / 600 ) & 1)) { if (!cg.messageLitActive) { /* kef 4/16/03 -- as fun as this was, its time has passed. I will, however, hijack this cvar at James' recommendation and use it for another nefarious purpose if (cg_neverHearThatDumbBeepingSoundAgain.integer == 0) { cgi_S_StartSound( NULL, 0, CHAN_AUTO, cgs.media.messageLitSound ); } */ cg.messageLitActive = qtrue; } cgi_R_SetColor(colorTable[CT_HUD_RED]); CG_DrawPic( x + 33,y + 41, 16,16, cgs.media.messageLitOn); } else { cg.messageLitActive = qfalse; } } cgi_R_SetColor(colorTable[CT_WHITE]); CG_DrawPic( x + 33,y + 41, 16,16, cgs.media.messageLitOff); } /* ================ CG_DrawForcePower Draw the force power graphics (tics) and the force power numeric amount. Any tics that are partial will be alphaed out. ================ */ static void CG_DrawForcePower(const centity_t *cent,const int xPos,const int yPos) { int i; qboolean flash=qfalse; vec4_t calcColor; float value,extra=0,inc,percent; if ( !cent->gent->client->ps.forcePowersKnown ) { return; } // Make the hud flash by setting forceHUDTotalFlashTime above cg.time if (cg.forceHUDTotalFlashTime > cg.time ) { flash = qtrue; if (cg.forceHUDNextFlashTime < cg.time) { cg.forceHUDNextFlashTime = cg.time + 400; cgi_S_StartSound( NULL, 0, CHAN_AUTO, cgs.media.noforceSound ); if (cg.forceHUDActive) { cg.forceHUDActive = qfalse; } else { cg.forceHUDActive = qtrue; } } } else // turn HUD back on if it had just finished flashing time. { cg.forceHUDNextFlashTime = 0; cg.forceHUDActive = qtrue; } // I left the funtionality for flashing in because I might be needed yet. // if (!cg.forceHUDActive) // { // return; // } inc = (float) cent->gent->client->ps.forcePowerMax / MAX_HUD_TICS; value = cent->gent->client->ps.forcePower; if ( value > cent->gent->client->ps.forcePowerMax ) {//supercharged with force extra = value - cent->gent->client->ps.forcePowerMax; value = cent->gent->client->ps.forcePowerMax; } for (i=MAX_HUD_TICS-1;i>=0;i--) { if ( extra ) {//supercharged memcpy(calcColor, colorTable[CT_WHITE], sizeof(vec4_t)); percent = 0.75f + (sinf( cg.time * 0.005f )*((extra/cent->gent->client->ps.forcePowerMax)*0.25f)); calcColor[0] *= percent; calcColor[1] *= percent; calcColor[2] *= percent; } else if ( value <= 0 ) // no more { break; } else if (value < inc) // partial tic { if (flash) { memcpy(calcColor, colorTable[CT_RED], sizeof(vec4_t)); } else { memcpy(calcColor, colorTable[CT_WHITE], sizeof(vec4_t)); } percent = value / inc; calcColor[3] = percent; } else { if (flash) { memcpy(calcColor, colorTable[CT_RED], sizeof(vec4_t)); } else { memcpy(calcColor, colorTable[CT_WHITE], sizeof(vec4_t)); } } cgi_R_SetColor( calcColor); CG_DrawPic( forceTics[i].xPos, forceTics[i].yPos, forceTics[i].width, forceTics[i].height, forceTics[i].background ); value -= inc; } if (flash) { cgi_R_SetColor( colorTable[CT_RED] ); } else { cgi_R_SetColor( otherHUDBits[OHB_FORCEAMOUNT].color ); } // Print force numeric amount CG_DrawNumField ( otherHUDBits[OHB_FORCEAMOUNT].xPos, otherHUDBits[OHB_FORCEAMOUNT].yPos, 3, cent->gent->client->ps.forcePower, otherHUDBits[OHB_FORCEAMOUNT].width, otherHUDBits[OHB_FORCEAMOUNT].height, NUM_FONT_SMALL, qfalse); } /* ================ CG_DrawSaberStyle If the weapon is a light saber (which needs no ammo) then draw a graphic showing the saber style (fast, medium, strong) ================ */ static void CG_DrawSaberStyle(const centity_t *cent,const int xPos,const int yPos) { int index; if (!cent->currentState.weapon ) // We don't have a weapon right now { return; } if ( cent->currentState.weapon != WP_SABER || !cent->gent ) { return; } cgi_R_SetColor( colorTable[CT_WHITE] ); if ( !cg.saberAnimLevelPending && cent->gent->client ) {//uninitialized after a loadgame, cheat across and get it cg.saberAnimLevelPending = cent->gent->client->ps.saberAnimLevel; } // don't need to draw ammo, but we will draw the current saber style in this window if (cg.saberAnimLevelPending == SS_FAST || cg.saberAnimLevelPending == SS_TAVION ) { index = OHB_SABERSTYLE_FAST; } else if (cg.saberAnimLevelPending == SS_MEDIUM || cg.saberAnimLevelPending == SS_DUAL || cg.saberAnimLevelPending == SS_STAFF ) { index = OHB_SABERSTYLE_MEDIUM; } else { index = OHB_SABERSTYLE_STRONG; } cgi_R_SetColor( otherHUDBits[index].color); CG_DrawPic( otherHUDBits[index].xPos, otherHUDBits[index].yPos, otherHUDBits[index].width, otherHUDBits[index].height, otherHUDBits[index].background ); } /* ================ CG_DrawAmmo Draw the ammo graphics (tics) and the ammo numeric amount. Any tics that are partial will be alphaed out. ================ */ static void CG_DrawAmmo(const centity_t *cent,const int xPos,const int yPos) { playerState_t *ps; int i; vec4_t calcColor; float currValue=0,inc; if (!cent->currentState.weapon ) // We don't have a weapon right now { return; } if ( cent->currentState.weapon == WP_STUN_BATON ) { return; } ps = &cg.snap->ps; currValue = ps->ammo[weaponData[cent->currentState.weapon].ammoIndex]; if (currValue < 0) // No ammo { return; } // // ammo // if (cg.oldammo < currValue) { cg.oldAmmoTime = cg.time + 200; } cg.oldammo = currValue; // Determine the color of the numeric field // Firing or reloading? if (( cg.predicted_player_state.weaponstate == WEAPON_FIRING && cg.predicted_player_state.weaponTime > 100 )) { memcpy(calcColor, colorTable[CT_LTGREY], sizeof(vec4_t)); } else { if ( currValue > 0 ) { if (cg.oldAmmoTime > cg.time) { memcpy(calcColor, colorTable[CT_YELLOW], sizeof(vec4_t)); } else { memcpy(calcColor, otherHUDBits[OHB_AMMOAMOUNT].color, sizeof(vec4_t)); } } else { memcpy(calcColor, colorTable[CT_RED], sizeof(vec4_t)); } } // Print number amount cgi_R_SetColor( calcColor ); CG_DrawNumField ( otherHUDBits[OHB_AMMOAMOUNT].xPos, otherHUDBits[OHB_AMMOAMOUNT].yPos, 3, ps->ammo[weaponData[cent->currentState.weapon].ammoIndex], otherHUDBits[OHB_AMMOAMOUNT].width, otherHUDBits[OHB_AMMOAMOUNT].height, NUM_FONT_SMALL, qfalse); inc = (float) ammoData[weaponData[cent->currentState.weapon].ammoIndex].max / MAX_HUD_TICS; currValue =ps->ammo[weaponData[cent->currentState.weapon].ammoIndex]; memcpy(calcColor, colorTable[CT_WHITE], sizeof(vec4_t)); for (i=MAX_HUD_TICS-1;i>=0;i--) { if (currValue <= 0) // don't show tic { break; } else if (currValue < inc) // partial tic (alpha it out) { memcpy(calcColor, ammoTics[i].color, sizeof(vec4_t)); float percent = currValue / inc; calcColor[3] *= percent; } cgi_R_SetColor( calcColor); CG_DrawPic( ammoTics[i].xPos, ammoTics[i].yPos, ammoTics[i].width, ammoTics[i].height, ammoTics[i].background ); currValue -= inc; } } /* ================ CG_DrawHealth ================ */ static void CG_DrawHealth(const int x,const int y,const int w,const int h) { vec4_t calcColor; playerState_t *ps = &cg.snap->ps; // Print all the tics of the health graphic // Look at the amount of health left and show only as much of the graphic as there is health. // Use alpha to fade out partial section of health float inc = (float) ps->stats[STAT_MAX_HEALTH] / MAX_HUD_TICS; float currValue = ps->stats[STAT_HEALTH]; memcpy(calcColor, colorTable[CT_WHITE], sizeof(vec4_t)); int i; for (i=(MAX_HUD_TICS-1);i>=0;i--) { if (currValue <= 0) // don't show tic { break; } else if (currValue < inc) // partial tic (alpha it out) { memcpy(calcColor, healthTics[i].color, sizeof(vec4_t)); float percent = currValue / inc; calcColor[3] *= percent; // Fade it out } cgi_R_SetColor( calcColor); CG_DrawPic( healthTics[i].xPos, healthTics[i].yPos, healthTics[i].width, healthTics[i].height, healthTics[i].background ); currValue -= inc; } // Print force health amount cgi_R_SetColor( otherHUDBits[OHB_HEALTHAMOUNT].color ); CG_DrawNumField ( otherHUDBits[OHB_HEALTHAMOUNT].xPos, otherHUDBits[OHB_HEALTHAMOUNT].yPos, 3, ps->stats[STAT_HEALTH], otherHUDBits[OHB_HEALTHAMOUNT].width, otherHUDBits[OHB_HEALTHAMOUNT].height, NUM_FONT_SMALL, qfalse); } /* ================ CG_DrawArmor Draw the armor graphics (tics) and the armor numeric amount. Any tics that are partial will be alphaed out. ================ */ static void CG_DrawArmor(const int x,const int y,const int w,const int h) { vec4_t calcColor; playerState_t *ps = &cg.snap->ps; // Print all the tics of the armor graphic // Look at the amount of armor left and show only as much of the graphic as there is armor. // Use alpha to fade out partial section of armor // MAX_HEALTH is the same thing as max armor float inc = (float) ps->stats[STAT_MAX_HEALTH] / MAX_HUD_TICS; float currValue = ps->stats[STAT_ARMOR]; memcpy(calcColor, colorTable[CT_WHITE], sizeof(vec4_t)); int i; for (i=(MAX_HUD_TICS-1);i>=0;i--) { if (currValue <= 0) // don't show tic { break; } else if (currValue < inc) // partial tic (alpha it out) { memcpy(calcColor, armorTics[i].color, sizeof(vec4_t)); float percent = currValue / inc; calcColor[3] *= percent; } cgi_R_SetColor( calcColor); if ((i==(MAX_HUD_TICS-1)) && (currValue < inc)) { if (cg.HUDArmorFlag) { CG_DrawPic( armorTics[i].xPos, armorTics[i].yPos, armorTics[i].width, armorTics[i].height, armorTics[i].background ); } } else { CG_DrawPic( armorTics[i].xPos, armorTics[i].yPos, armorTics[i].width, armorTics[i].height, armorTics[i].background ); } currValue -= inc; } // Print armor amount cgi_R_SetColor( otherHUDBits[OHB_ARMORAMOUNT].color ); CG_DrawNumField ( otherHUDBits[OHB_ARMORAMOUNT].xPos, otherHUDBits[OHB_ARMORAMOUNT].yPos, 3, ps->stats[STAT_ARMOR], otherHUDBits[OHB_ARMORAMOUNT].width, otherHUDBits[OHB_ARMORAMOUNT].height, NUM_FONT_SMALL, qfalse); // If armor is low, flash a graphic to warn the player if (ps->stats[STAT_ARMOR]) // Is there armor? Draw the HUD Armor TIC { float quarterArmor = (float) (ps->stats[STAT_MAX_HEALTH] / 4.0f); // Make tic flash if armor is at 25% of full armor if (ps->stats[STAT_ARMOR] < quarterArmor) // Do whatever the flash timer says { if (cg.HUDTickFlashTime < cg.time) // Flip at the same time { cg.HUDTickFlashTime = cg.time + 400; if (cg.HUDArmorFlag) { cg.HUDArmorFlag = qfalse; } else { cg.HUDArmorFlag = qtrue; } } } else { cg.HUDArmorFlag=qtrue; } } else // No armor? Don't show it. { cg.HUDArmorFlag=qfalse; } } #define MAX_VHUD_SHIELD_TICS 12 #define MAX_VHUD_SPEED_TICS 5 #define MAX_VHUD_ARMOR_TICS 5 #define MAX_VHUD_AMMO_TICS 5 static void CG_DrawVehicleSheild( const centity_t *cent, const Vehicle_t *pVeh ) { int xPos,yPos,width,height,i; vec4_t color,calcColor; qhandle_t background; char itemName[64]; float inc, currValue,maxHealth; //riding some kind of living creature if ( pVeh->m_pVehicleInfo->type == VH_ANIMAL || pVeh->m_pVehicleInfo->type == VH_FLIER ) { maxHealth = 100.0f; currValue = pVeh->m_pParentEntity->health; } else //normal vehicle { maxHealth = pVeh->m_pVehicleInfo->armor; currValue = pVeh->m_iArmor; } if (cgi_UI_GetMenuItemInfo( "swoopvehiclehud", "shieldbackground", &xPos, &yPos, &width, &height, color, &background)) { cgi_R_SetColor( color ); CG_DrawPic( xPos, yPos, width, height, background ); } // Print all the tics of the shield graphic // Look at the amount of health left and show only as much of the graphic as there is health. // Use alpha to fade out partial section of health inc = (float) maxHealth / MAX_VHUD_SHIELD_TICS; for (i=1;i <= MAX_VHUD_SHIELD_TICS;i++) { sprintf( itemName, "shield_tic%d", i ); if (!cgi_UI_GetMenuItemInfo( "swoopvehiclehud", itemName, &xPos, &yPos, &width, &height, color, &background)) { continue; } memcpy(calcColor, color, sizeof(vec4_t)); if (currValue <= 0) // don't show tic { break; } else if (currValue < inc) // partial tic (alpha it out) { float percent = currValue / inc; calcColor[3] *= percent; // Fade it out } cgi_R_SetColor( calcColor); CG_DrawPic( xPos, yPos, width, height, background ); currValue -= inc; } } // The HUD.menu file has the graphic print with a negative height, so it will print from the bottom up. static void CG_DrawVehicleTurboRecharge( const centity_t *cent, const Vehicle_t *pVeh ) { int xPos,yPos,width,height; qhandle_t background; vec4_t color; if (cgi_UI_GetMenuItemInfo( "swoopvehiclehud", "turborecharge", &xPos, &yPos, &width, &height, color, &background)) { float percent=0.0f; int diff = ( cg.time - pVeh->m_iTurboTime ); // Calc max time if (diff > pVeh->m_pVehicleInfo->turboRecharge) { percent = 1.0f; cgi_R_SetColor( colorTable[CT_GREEN] ); } else { percent = (float) diff / pVeh->m_pVehicleInfo->turboRecharge; if (percent < 0.0f) { percent = 0.0f; } cgi_R_SetColor( colorTable[CT_RED] ); } height *= percent; CG_DrawPic(xPos,yPos, width, height, cgs.media.whiteShader); // Top } } static void CG_DrawVehicleSpeed( const centity_t *cent, const Vehicle_t *pVeh, const char *entHud ) { int xPos,yPos,width,height; qhandle_t background; gentity_t *parent = pVeh->m_pParentEntity; playerState_t *parentPS = &parent->client->ps; float currValue,maxSpeed; vec4_t color,calcColor; float inc; int i; char itemName[64]; if (cgi_UI_GetMenuItemInfo( entHud, "speedbackground", &xPos, &yPos, &width, &height, color, &background)) { cgi_R_SetColor( color ); CG_DrawPic( xPos, yPos, width, height, background ); } maxSpeed = pVeh->m_pVehicleInfo->speedMax; currValue = parentPS->speed; // Print all the tics of the shield graphic // Look at the amount of health left and show only as much of the graphic as there is health. // Use alpha to fade out partial section of health inc = (float) maxSpeed / MAX_VHUD_SPEED_TICS; for (i=1;i<=MAX_VHUD_SPEED_TICS;i++) { sprintf( itemName, "speed_tic%d", i ); if (!cgi_UI_GetMenuItemInfo( entHud, itemName, &xPos, &yPos, &width, &height, color, &background)) { continue; } if ( level.time > pVeh->m_iTurboTime ) { memcpy(calcColor, color, sizeof(vec4_t)); } else // In turbo mode { if (cg.VHUDFlashTime < cg.time) { cg.VHUDFlashTime = cg.time + 400; if (cg.VHUDTurboFlag) { cg.VHUDTurboFlag = qfalse; } else { cg.VHUDTurboFlag = qtrue; } } if (cg.VHUDTurboFlag) { memcpy(calcColor, colorTable[CT_LTRED1], sizeof(vec4_t)); } else { memcpy(calcColor, color, sizeof(vec4_t)); } } if (currValue <= 0) // don't show tic { break; } else if (currValue < inc) // partial tic (alpha it out) { float percent = currValue / inc; calcColor[3] *= percent; // Fade it out } cgi_R_SetColor( calcColor); CG_DrawPic( xPos, yPos, width, height, background ); currValue -= inc; } } static void CG_DrawVehicleArmor( const centity_t *cent, const Vehicle_t *pVeh ) { int xPos,yPos,width,height,i; qhandle_t background; char itemName[64]; float inc, currValue,maxArmor; vec4_t color,calcColor; if (cgi_UI_GetMenuItemInfo( "swoopvehiclehud", "armorbackground", &xPos, &yPos, &width, &height, color, &background)) { cgi_R_SetColor( color ); CG_DrawPic( xPos, yPos, width, height, background ); } maxArmor = pVeh->m_iArmor; currValue = pVeh->m_pVehicleInfo->armor; // Print all the tics of the shield graphic // Look at the amount of health left and show only as much of the graphic as there is health. // Use alpha to fade out partial section of health inc = (float) maxArmor / MAX_VHUD_ARMOR_TICS; for (i=1;i<=MAX_VHUD_ARMOR_TICS;i++) { sprintf( itemName, "armor_tic%d", i ); if (!cgi_UI_GetMenuItemInfo( "swoopvehiclehud", itemName, &xPos, &yPos, &width, &height, color, &background)) { continue; } memcpy(calcColor, color, sizeof(vec4_t)); if (currValue <= 0) // don't show tic { break; } else if (currValue < inc) // partial tic (alpha it out) { float percent = currValue / inc; calcColor[3] *= percent; // Fade it out } cgi_R_SetColor( calcColor); CG_DrawPic( xPos, yPos, width, height, background ); currValue -= inc; } } static void CG_DrawVehicleAmmo( const centity_t *cent, const Vehicle_t *pVeh ) { int xPos,yPos,width,height,i; qhandle_t background; char itemName[64]; float inc, currValue,maxAmmo; vec4_t color,calcColor; if (cgi_UI_GetMenuItemInfo( "swoopvehiclehud", "ammobackground", &xPos, &yPos, &width, &height, color, &background)) { cgi_R_SetColor( color ); CG_DrawPic( xPos, yPos, width, height, background ); } maxAmmo = pVeh->m_pVehicleInfo->weapon[0].ammoMax; currValue = pVeh->weaponStatus[0].ammo; inc = (float) maxAmmo / MAX_VHUD_AMMO_TICS; for (i=1;i<=MAX_VHUD_AMMO_TICS;i++) { sprintf( itemName, "ammo_tic%d", i ); if (!cgi_UI_GetMenuItemInfo( "swoopvehiclehud", itemName, &xPos, &yPos, &width, &height, color, &background)) { continue; } memcpy(calcColor, color, sizeof(vec4_t)); if (currValue <= 0) // don't show tic { break; } else if (currValue < inc) // partial tic (alpha it out) { float percent = currValue / inc; calcColor[3] *= percent; // Fade it out } cgi_R_SetColor( calcColor ); CG_DrawPic( xPos, yPos, width, height, background ); currValue -= inc; } } static void CG_DrawVehicleAmmoUpper( const centity_t *cent, const Vehicle_t *pVeh ) { int xPos,yPos,width,height,i; qhandle_t background; char itemName[64]; float inc, currValue,maxAmmo; vec4_t color,calcColor; if (cgi_UI_GetMenuItemInfo( "swoopvehiclehud", "ammoupperbackground", &xPos, &yPos, &width, &height, color, &background)) { cgi_R_SetColor( color ); CG_DrawPic( xPos, yPos, width, height, background ); } maxAmmo = pVeh->m_pVehicleInfo->weapon[0].ammoMax; currValue = pVeh->weaponStatus[0].ammo; inc = (float) maxAmmo / MAX_VHUD_AMMO_TICS; for (i=1;i<MAX_VHUD_AMMO_TICS;i++) { sprintf( itemName, "ammoupper_tic%d", i ); if (!cgi_UI_GetMenuItemInfo( "swoopvehiclehud", itemName, &xPos, &yPos, &width, &height, color, &background)) { continue; } memcpy(calcColor, color, sizeof(vec4_t)); if (currValue <= 0) // don't show tic { break; } else if (currValue < inc) // partial tic (alpha it out) { float percent = currValue / inc; calcColor[3] *= percent; // Fade it out } cgi_R_SetColor( calcColor ); CG_DrawPic( xPos, yPos, width, height, background ); currValue -= inc; } } static void CG_DrawVehicleAmmoLower( const centity_t *cent, const Vehicle_t *pVeh ) { int xPos,yPos,width,height,i; qhandle_t background; char itemName[64]; float inc, currValue,maxAmmo; vec4_t color,calcColor; if (cgi_UI_GetMenuItemInfo( "swoopvehiclehud", "ammolowerbackground", &xPos, &yPos, &width, &height, color, &background)) { cgi_R_SetColor( color ); CG_DrawPic( xPos, yPos, width, height, background ); } maxAmmo = pVeh->m_pVehicleInfo->weapon[1].ammoMax; currValue = pVeh->weaponStatus[1].ammo; inc = (float) maxAmmo / MAX_VHUD_AMMO_TICS; for (i=1;i<MAX_VHUD_AMMO_TICS;i++) { sprintf( itemName, "ammolower_tic%d", i ); if (!cgi_UI_GetMenuItemInfo( "swoopvehiclehud", itemName, &xPos, &yPos, &width, &height, color, &background)) { continue; } memcpy(calcColor, color, sizeof(vec4_t)); if (currValue <= 0) // don't show tic { break; } else if (currValue < inc) // partial tic (alpha it out) { float percent = currValue / inc; calcColor[3] *= percent; // Fade it out } cgi_R_SetColor( calcColor ); CG_DrawPic( xPos, yPos, width, height, background ); currValue -= inc; } } static void CG_DrawVehicleHud( const centity_t *cent, const Vehicle_t *pVeh ) { int xPos,yPos,width,height; vec4_t color; qhandle_t background; CG_DrawVehicleTurboRecharge( cent, pVeh ); // Draw frame if (cgi_UI_GetMenuItemInfo( "swoopvehiclehud", "leftframe", &xPos, &yPos, &width, &height, color, &background)) { cgi_R_SetColor( color ); CG_DrawPic( xPos, yPos, width, height, background ); } if (cgi_UI_GetMenuItemInfo( "swoopvehiclehud", "rightframe", &xPos, &yPos, &width, &height, color, &background)) { cgi_R_SetColor( color ); CG_DrawPic( xPos, yPos, width, height, background ); } CG_DrawVehicleSheild( cent, pVeh ); CG_DrawVehicleSpeed( cent, pVeh, "swoopvehiclehud" ); CG_DrawVehicleArmor( cent, pVeh ); CG_DrawVehicleAmmo( cent, pVeh ); if (0) { CG_DrawVehicleAmmoUpper( cent, pVeh ); } if (0) { CG_DrawVehicleAmmoLower( cent, pVeh ); } } static void CG_DrawTauntaunHud( const centity_t *cent, const Vehicle_t *pVeh ) { int xPos,yPos,width,height; vec4_t color; qhandle_t background; CG_DrawVehicleTurboRecharge( cent, pVeh ); // Draw frame if (cgi_UI_GetMenuItemInfo( "swoopvehiclehud", "leftframe", &xPos, &yPos, &width, &height, color, &background)) { cgi_R_SetColor( color ); CG_DrawPic( xPos, yPos, width, height, background ); } if (cgi_UI_GetMenuItemInfo( "swoopvehiclehud", "rightframe", &xPos, &yPos, &width, &height, color, &background)) { cgi_R_SetColor( color ); CG_DrawPic( xPos, yPos, width, height, background ); } CG_DrawVehicleSheild( cent, pVeh ); CG_DrawVehicleSpeed( cent, pVeh, "tauntaunhud" ); if (0) { CG_DrawVehicleAmmoUpper( cent, pVeh ); } if (0) { CG_DrawVehicleAmmoLower( cent, pVeh ); } } static void CG_DrawEmplacedGunHealth( const centity_t *cent ) { int xPos,yPos,width,height,i, health=0; vec4_t color,calcColor; qhandle_t background; char itemName[64]; float inc, currValue,maxHealth; if ( cent->gent && cent->gent->owner ) { if (( cent->gent->owner->flags & FL_GODMODE )) { // chair is in godmode, so render the health of the player instead health = cent->gent->health; } else { // render the chair health health = cent->gent->owner->health; } } else { return; } //riding some kind of living creature maxHealth = (float)cent->gent->max_health; currValue = health; if (cgi_UI_GetMenuItemInfo( "swoopvehiclehud", "shieldbackground", &xPos, &yPos, &width, &height, color, &background)) { cgi_R_SetColor( color ); CG_DrawPic( xPos, yPos, width, height, background ); } // Print all the tics of the shield graphic // Look at the amount of health left and show only as much of the graphic as there is health. // Use alpha to fade out partial section of health inc = (float) maxHealth / MAX_VHUD_SHIELD_TICS; for (i=1;i <= MAX_VHUD_SHIELD_TICS;i++) { sprintf( itemName, "shield_tic%d", i ); if (!cgi_UI_GetMenuItemInfo( "swoopvehiclehud", itemName, &xPos, &yPos, &width, &height, color, &background)) { continue; } memcpy(calcColor, color, sizeof(vec4_t)); if (currValue <= 0) // don't show tic { break; } else if (currValue < inc) // partial tic (alpha it out) { float percent = currValue / inc; calcColor[3] *= percent; // Fade it out } cgi_R_SetColor( calcColor); CG_DrawPic( xPos, yPos, width, height, background ); currValue -= inc; } } static void CG_DrawEmplacedGunHud( const centity_t *cent ) { int xPos,yPos,width,height; vec4_t color; qhandle_t background; // Draw frame if (cgi_UI_GetMenuItemInfo( "swoopvehiclehud", "leftframe", &xPos, &yPos, &width, &height, color, &background)) { cgi_R_SetColor( color ); CG_DrawPic( xPos, yPos, width, height, background ); } if (cgi_UI_GetMenuItemInfo( "swoopvehiclehud", "rightframe", &xPos, &yPos, &width, &height, color, &background)) { cgi_R_SetColor( color ); CG_DrawPic( xPos, yPos, width, height, background ); } CG_DrawEmplacedGunHealth( cent ); } static void CG_DrawItemHealth( float currValue, float maxHealth ) { int xPos,yPos,width,height,i; vec4_t color,calcColor; qhandle_t background; char itemName[64]; float inc; if (cgi_UI_GetMenuItemInfo( "swoopvehiclehud", "shieldbackground", &xPos, &yPos, &width, &height, color, &background)) { cgi_R_SetColor( color ); CG_DrawPic( xPos, yPos, width, height, background ); } // Print all the tics of the shield graphic // Look at the amount of health left and show only as much of the graphic as there is health. // Use alpha to fade out partial section of health inc = (float) maxHealth / MAX_VHUD_SHIELD_TICS; for (i=1;i <= MAX_VHUD_SHIELD_TICS;i++) { sprintf( itemName, "shield_tic%d", i ); if (!cgi_UI_GetMenuItemInfo( "swoopvehiclehud", itemName, &xPos, &yPos, &width, &height, color, &background)) { continue; } memcpy(calcColor, color, sizeof(vec4_t)); if (currValue <= 0) // don't show tic { break; } else if (currValue < inc) // partial tic (alpha it out) { float percent = currValue / inc; calcColor[3] *= percent; // Fade it out } cgi_R_SetColor( calcColor); CG_DrawPic( xPos, yPos, width, height, background ); currValue -= inc; } } static void CG_DrawPanelTurretHud( void ) { int xPos,yPos,width,height; vec4_t color; qhandle_t background; // Draw frame if (cgi_UI_GetMenuItemInfo( "swoopvehiclehud", "leftframe", &xPos, &yPos, &width, &height, color, &background)) { cgi_R_SetColor( color ); CG_DrawPic( xPos, yPos, width, height, background ); } if (cgi_UI_GetMenuItemInfo( "swoopvehiclehud", "rightframe", &xPos, &yPos, &width, &height, color, &background)) { cgi_R_SetColor( color ); CG_DrawPic( xPos, yPos, width, height, background ); } CG_DrawItemHealth( g_entities[cg.snap->ps.viewEntity].health, (float)g_entities[cg.snap->ps.viewEntity].max_health ); } static void CG_DrawATSTHud( centity_t *cent ) { int xPos,yPos,width,height; vec4_t color; qhandle_t background; float health; if ( !cg.snap ||!g_entities[cg.snap->ps.viewEntity].activator ) { return; } // Draw frame if (cgi_UI_GetMenuItemInfo( "swoopvehiclehud", "leftframe", &xPos, &yPos, &width, &height, color, &background)) { cgi_R_SetColor( color ); CG_DrawPic( xPos, yPos, width, height, background ); } if (cgi_UI_GetMenuItemInfo( "swoopvehiclehud", "rightframe", &xPos, &yPos, &width, &height, color, &background)) { cgi_R_SetColor( color ); CG_DrawPic( xPos, yPos, width, height, background ); } // we just calc the display value from the sum of health and armor if ( g_entities[cg.snap->ps.viewEntity].activator ) // ensure we can look back to the atst_drivable to get the max health { health = ( g_entities[cg.snap->ps.viewEntity].health + g_entities[cg.snap->ps.viewEntity].client->ps.stats[STAT_ARMOR] ); } else { health = ( g_entities[cg.snap->ps.viewEntity].health + g_entities[cg.snap->ps.viewEntity].client->ps.stats[STAT_ARMOR] ); } CG_DrawItemHealth(health,g_entities[cg.snap->ps.viewEntity].activator->max_health ); if (cgi_UI_GetMenuItemInfo( "atsthud", "background", &xPos, &yPos, &width, &height, color, &background)) { cgi_R_SetColor( color ); CG_DrawPic( xPos, yPos, width, height, background ); } if (cgi_UI_GetMenuItemInfo( "atsthud", "outer_frame", &xPos, &yPos, &width, &height, color, &background)) { cgi_R_SetColor( color ); CG_DrawPic( xPos, yPos, width, height, background ); } if (cgi_UI_GetMenuItemInfo( "atsthud", "left_pic", &xPos, &yPos, &width, &height, color, &background)) { cgi_R_SetColor( color ); CG_DrawPic( xPos, yPos, width, height, background ); } } //----------------------------------------------------- static qboolean CG_DrawCustomHealthHud( centity_t *cent ) { Vehicle_t *pVeh; // In a Weapon? if (( cent->currentState.eFlags & EF_LOCKED_TO_WEAPON )) { CG_DrawEmplacedGunHud(cent); // DRAW emplaced HUD /* color[0] = color[1] = color[2] = 0.0f; color[3] = 0.3f; cgi_R_SetColor( color ); CG_DrawPic( 14, 480 - 50, 94, 32, cgs.media.whiteShader ); // NOTE: this looks ugly if ( cent->gent && cent->gent->owner ) { if (( cent->gent->owner->flags & FL_GODMODE )) { // chair is in godmode, so render the health of the player instead health = cent->gent->health / (float)cent->gent->max_health; } else { // render the chair health health = cent->gent->owner->health / (float)cent->gent->owner->max_health; } } color[0] = 1.0f; color[3] = 0.5f; cgi_R_SetColor( color ); CG_DrawPic( 18, 480 - 41, 87 * health, 19, cgs.media.whiteShader ); cgi_R_SetColor( colorTable[CT_WHITE] ); CG_DrawPic( 2, 480 - 64, 128, 64, cgs.media.emplacedHealthBarShader); */ return qfalse; // drew this hud, so don't draw the player one } // In an ATST else if (( cent->currentState.eFlags & EF_IN_ATST )) { /* // we are an ATST... color[0] = color[1] = color[2] = 0.0f; color[3] = 0.3f; cgi_R_SetColor( color ); CG_DrawPic( 14, 480 - 50, 94, 32, cgs.media.whiteShader ); // we just calc the display value from the sum of health and armor if ( g_entities[cg.snap->ps.viewEntity].activator ) // ensure we can look back to the atst_drivable to get the max health { health = ( g_entities[cg.snap->ps.viewEntity].health + g_entities[cg.snap->ps.viewEntity].client->ps.stats[STAT_ARMOR] ) / (float)(g_entities[cg.snap->ps.viewEntity].max_health + g_entities[cg.snap->ps.viewEntity].activator->max_health ); } else { health = ( g_entities[cg.snap->ps.viewEntity].health + g_entities[cg.snap->ps.viewEntity].client->ps.stats[STAT_ARMOR]) / (float)(g_entities[cg.snap->ps.viewEntity].max_health + 800 ); // hacked max armor since we don't have an activator...should never happen } color[1] = 0.25f; // blue-green color[2] = 1.0f; color[3] = 0.5f; cgi_R_SetColor( color ); CG_DrawPic( 18, 480 - 41, 87 * health, 19, cgs.media.whiteShader ); cgi_R_SetColor( colorTable[CT_WHITE] ); CG_DrawPic( 2, 480 - 64, 128, 64, cgs.media.emplacedHealthBarShader); */ CG_DrawATSTHud(cent); return qfalse; // drew this hud, so don't draw the player one } // In a vehicle else if ( (pVeh = G_IsRidingVehicle( cent->gent ) ) != 0 ) { //riding some kind of living creature if ( pVeh->m_pVehicleInfo->type == VH_ANIMAL ) { CG_DrawTauntaunHud( cent, pVeh ); } else { CG_DrawVehicleHud( cent, pVeh ); } return qtrue; // draw this hud AND the player one } // Other? else if ( cg.snap->ps.viewEntity && ( g_entities[cg.snap->ps.viewEntity].dflags & DAMAGE_CUSTOM_HUD )) { CG_DrawPanelTurretHud(); return qfalse; // drew this hud, so don't draw the player one } return qtrue; } //-------------------------------------- static void CG_DrawBatteryCharge( void ) { if ( cg.batteryChargeTime > cg.time ) { vec4_t color; // FIXME: drawing it here will overwrite zoom masks...find a better place if ( cg.batteryChargeTime < cg.time + 1000 ) { // fading out for the last second color[0] = color[1] = color[2] = 1.0f; color[3] = (cg.batteryChargeTime - cg.time) / 1000.0f; } else { // draw full color[0] = color[1] = color[2] = color[3] = 1.0f; } cgi_R_SetColor( color ); // batteries were just charged CG_DrawPic( 605, 295, 24, 32, cgs.media.batteryChargeShader ); } } /* ================ CG_DrawHUD ================ */ static void CG_DrawHUD( centity_t *cent ) { int value; int sectionXPos,sectionYPos,sectionWidth,sectionHeight; // Draw the lower left section of the HUD if (cgi_UI_GetMenuInfo("lefthud",&sectionXPos,&sectionYPos,&sectionWidth,&sectionHeight)) { // Draw armor & health values if ( cg_drawStatus.integer == 2 ) { CG_DrawSmallStringColor(sectionXPos+5, sectionYPos - 60,va("Armor:%d",cg.snap->ps.stats[STAT_ARMOR]), colorTable[CT_HUD_GREEN] ); CG_DrawSmallStringColor(sectionXPos+5, sectionYPos - 40,va("Health:%d",cg.snap->ps.stats[STAT_HEALTH]), colorTable[CT_HUD_GREEN] ); } // Print scanline cgi_R_SetColor( otherHUDBits[OHB_SCANLINE_LEFT].color); CG_DrawPic( otherHUDBits[OHB_SCANLINE_LEFT].xPos, otherHUDBits[OHB_SCANLINE_LEFT].yPos, otherHUDBits[OHB_SCANLINE_LEFT].width, otherHUDBits[OHB_SCANLINE_LEFT].height, otherHUDBits[OHB_SCANLINE_LEFT].background ); // Print frame cgi_R_SetColor( otherHUDBits[OHB_FRAME_LEFT].color); CG_DrawPic( otherHUDBits[OHB_FRAME_LEFT].xPos, otherHUDBits[OHB_FRAME_LEFT].yPos, otherHUDBits[OHB_FRAME_LEFT].width, otherHUDBits[OHB_FRAME_LEFT].height, otherHUDBits[OHB_FRAME_LEFT].background ); CG_DrawArmor(sectionXPos,sectionYPos,sectionWidth,sectionHeight); CG_DrawHealth(sectionXPos,sectionYPos,sectionWidth,sectionHeight); } // Draw the lower right section of the HUD if (cgi_UI_GetMenuInfo("righthud",&sectionXPos,&sectionYPos,&sectionWidth,&sectionHeight)) { // Draw armor & health values if ( cg_drawStatus.integer == 2 ) { if ( cent->currentState.weapon != WP_SABER && cent->currentState.weapon != WP_STUN_BATON && cent->gent ) { value = cg.snap->ps.ammo[weaponData[cent->currentState.weapon].ammoIndex]; CG_DrawSmallStringColor(sectionXPos, sectionYPos - 60,va("Ammo:%d",value), colorTable[CT_HUD_GREEN] ); } CG_DrawSmallStringColor(sectionXPos, sectionYPos - 40,va("Force:%d",cent->gent->client->ps.forcePower), colorTable[CT_HUD_GREEN] ); } // Print scanline cgi_R_SetColor( otherHUDBits[OHB_SCANLINE_RIGHT].color); CG_DrawPic( otherHUDBits[OHB_SCANLINE_RIGHT].xPos, otherHUDBits[OHB_SCANLINE_RIGHT].yPos, otherHUDBits[OHB_SCANLINE_RIGHT].width, otherHUDBits[OHB_SCANLINE_RIGHT].height, otherHUDBits[OHB_SCANLINE_RIGHT].background ); // Print frame cgi_R_SetColor( otherHUDBits[OHB_FRAME_RIGHT].color); CG_DrawPic( otherHUDBits[OHB_FRAME_RIGHT].xPos, otherHUDBits[OHB_FRAME_RIGHT].yPos, otherHUDBits[OHB_FRAME_RIGHT].width, otherHUDBits[OHB_FRAME_RIGHT].height, otherHUDBits[OHB_FRAME_RIGHT].background ); CG_DrawForcePower(cent,sectionXPos,sectionYPos); // Draw ammo tics or saber style if ( cent->currentState.weapon == WP_SABER ) { CG_DrawSaberStyle(cent,sectionXPos,sectionYPos); } else { CG_DrawAmmo(cent,sectionXPos,sectionYPos); } // CG_DrawMessageLit(cent,x,y); } } /* ================ CG_ClearDataPadCvars ================ */ void CG_ClearDataPadCvars( void ) { cg_updatedDataPadForcePower1.integer = 0; //don't wait for the cvar-refresh. cg_updatedDataPadForcePower2.integer = 0; //don't wait for the cvar-refresh. cg_updatedDataPadForcePower3.integer = 0; //don't wait for the cvar-refresh. cgi_Cvar_Set( "cg_updatedDataPadForcePower1", "0" ); cgi_Cvar_Set( "cg_updatedDataPadForcePower2", "0" ); cgi_Cvar_Set( "cg_updatedDataPadForcePower3", "0" ); cg_updatedDataPadObjective.integer = 0; //don't wait for the cvar-refresh. cgi_Cvar_Set( "cg_updatedDataPadObjective", "0" ); } /* ================ CG_DrawDataPadHUD ================ */ void CG_DrawDataPadHUD( centity_t *cent ) { int x,y; x = 34; y = 286; CG_DrawHealth(x,y,80,80); x = 526; if ((missionInfo_Updated) && ((cg_updatedDataPadForcePower1.integer) || (cg_updatedDataPadObjective.integer))) { // Stop flashing light cg.missionInfoFlashTime = 0; missionInfo_Updated = qfalse; // Set which force power to show. // cg_updatedDataPadForcePower is set from Q3_Interface, because force powers would only be given // from a script. if (cg_updatedDataPadForcePower1.integer) { cg.DataPadforcepowerSelect = cg_updatedDataPadForcePower1.integer - 1; // Not pretty, I know if (cg.DataPadforcepowerSelect >= MAX_DPSHOWPOWERS) { //duh cg.DataPadforcepowerSelect = MAX_DPSHOWPOWERS-1; } else if (cg.DataPadforcepowerSelect<0) { cg.DataPadforcepowerSelect=0; } } // CG_ClearDataPadCvars(); } CG_DrawForcePower(cent,x,y); CG_DrawAmmo(cent,x,y); CG_DrawMessageLit(cent,x,y); cgi_R_SetColor( colorTable[CT_WHITE]); CG_DrawPic( 0, 0, 640, 480, cgs.media.dataPadFrame ); } //------------------------ // CG_DrawZoomMask //------------------------ static void CG_DrawBinocularNumbers( qboolean power ) { vec4_t color1; cgi_R_SetColor( colorTable[CT_BLACK]); CG_DrawPic( 212, 367, 200, 40, cgs.media.whiteShader ); if ( power ) { // Numbers should be kind of greenish color1[0] = 0.2f; color1[1] = 0.4f; color1[2] = 0.2f; color1[3] = 0.3f; cgi_R_SetColor( color1 ); // Draw scrolling numbers, use intervals 10 units apart--sorry, this section of code is just kind of hacked // up with a bunch of magic numbers..... int val = ((int)((cg.refdefViewAngles[YAW] + 180) / 10)) * 10; float off = (cg.refdefViewAngles[YAW] + 180) - val; for ( int i = -10; i < 30; i += 10 ) { val -= 10; if ( val < 0 ) { val += 360; } // we only want to draw the very far left one some of the time, if it's too far to the left it will poke outside the mask. if (( off > 3.0f && i == -10 ) || i > -10 ) { // draw the value, but add 200 just to bump the range up...arbitrary, so change it if you like CG_DrawNumField( 155 + i * 10 + off * 10, 374, 3, val + 200, 24, 14, NUM_FONT_CHUNKY, qtrue ); CG_DrawPic( 245 + (i-1) * 10 + off * 10, 376, 6, 6, cgs.media.whiteShader ); } } CG_DrawPic( 212, 367, 200, 28, cgs.media.binocularOverlay ); } } /* ================ CG_DrawZoomMask ================ */ extern float cg_zoomFov; //from cg_view.cpp static void CG_DrawZoomMask( void ) { vec4_t color1; centity_t *cent; float level; static qboolean flip = qtrue; float charge = cg.snap->ps.batteryCharge / (float)MAX_BATTERIES; // convert charge to a percentage qboolean power = qfalse; cent = &cg_entities[0]; if ( charge > 0.0f ) { power = qtrue; } //------------- // Binoculars //-------------------------------- if ( cg.zoomMode == 1 ) { CG_RegisterItemVisuals( ITM_BINOCULARS_PICKUP ); // zoom level level = (float)(80.0f - cg_zoomFov) / 80.0f; // ...so we'll clamp it if ( level < 0.0f ) { level = 0.0f; } else if ( level > 1.0f ) { level = 1.0f; } // Using a magic number to convert the zoom level to scale amount level *= 162.0f; if ( power ) { // draw blue tinted distortion mask, trying to make it as small as is necessary to fill in the viewable area cgi_R_SetColor( colorTable[CT_WHITE] ); CG_DrawPic( 34, 48, 570, 362, cgs.media.binocularStatic ); } CG_DrawBinocularNumbers( power ); // Black out the area behind the battery display cgi_R_SetColor( colorTable[CT_DKGREY]); CG_DrawPic( 50, 389, 161, 16, cgs.media.whiteShader ); if ( power ) { color1[0] = sinf( cg.time * 0.01f ) * 0.5f + 0.5f; color1[0] = color1[0] * color1[0]; color1[1] = color1[0]; color1[2] = color1[0]; color1[3] = 1.0f; cgi_R_SetColor( color1 ); CG_DrawPic( 82, 94, 16, 16, cgs.media.binocularCircle ); } CG_DrawPic( 0, 0, 640, 480, cgs.media.binocularMask ); if ( power ) { // Flickery color color1[0] = 0.7f + crandom() * 0.1f; color1[1] = 0.8f + crandom() * 0.1f; color1[2] = 0.7f + crandom() * 0.1f; color1[3] = 1.0f; cgi_R_SetColor( color1 ); CG_DrawPic( 4, 282 - level, 16, 16, cgs.media.binocularArrow ); } else { // No power color color1[0] = 0.15f; color1[1] = 0.15f; color1[2] = 0.15f; color1[3] = 1.0f; cgi_R_SetColor( color1 ); } // The top triangle bit randomly flips when the power is on if ( flip && power ) { CG_DrawPic( 330, 60, -26, -30, cgs.media.binocularTri ); } else { CG_DrawPic( 307, 40, 26, 30, cgs.media.binocularTri ); } if ( randomLava() > 0.98f && ( cg.time & 1024 )) { flip = !flip; } if ( power ) { color1[0] = 1.0f * ( charge < 0.2f ? !!(cg.time & 256) : 1 ); color1[1] = charge * color1[0]; color1[2] = 0.0f; color1[3] = 0.2f; cgi_R_SetColor( color1 ); CG_DrawPic( 60, 394.5f, charge * 141, 5, cgs.media.whiteShader ); } } //------------ // Disruptor //-------------------------------- else if ( cg.zoomMode == 2 ) { level = (float)(80.0f - cg_zoomFov) / 80.0f; // ...so we'll clamp it if ( level < 0.0f ) { level = 0.0f; } else if ( level > 1.0f ) { level = 1.0f; } // Using a magic number to convert the zoom level to a rotation amount that correlates more or less with the zoom artwork. level *= 103.0f; // Draw target mask cgi_R_SetColor( colorTable[CT_WHITE] ); CG_DrawPic( 0, 0, 640, 480, cgs.media.disruptorMask ); // apparently 99.0f is the full zoom level if ( level >= 99 ) { // Fully zoomed, so make the rotating insert pulse color1[0] = 1.0f; color1[1] = 1.0f; color1[2] = 1.0f; color1[3] = 0.7f + sinf( cg.time * 0.01f ) * 0.3f; cgi_R_SetColor( color1 ); } // Draw rotating insert CG_DrawRotatePic2( 320, 240, 640, 480, -level, cgs.media.disruptorInsert ); float cx, cy; float max; max = cg_entities[0].gent->client->ps.ammo[weaponData[WP_DISRUPTOR].ammoIndex] / (float)ammoData[weaponData[WP_DISRUPTOR].ammoIndex].max; if ( max > 1.0f ) { max = 1.0f; } color1[0] = (1.0f - max) * 2.0f; color1[1] = max * 1.5f; color1[2] = 0.0f; color1[3] = 1.0f; // If we are low on ammo, make us flash if ( max < 0.15f && ( cg.time & 512 )) { VectorClear( color1 ); } if ( color1[0] > 1.0f ) { color1[0] = 1.0f; } if ( color1[1] > 1.0f ) { color1[1] = 1.0f; } cgi_R_SetColor( color1 ); max *= 58.0f; for ( float i = 18.5f; i <= 18.5f + max; i+= 3 ) // going from 15 to 45 degrees, with 5 degree increments { cx = 320 + sinf( (i+90.0f)/57.296f ) * 190; cy = 240 + cosf( (i+90.0f)/57.296f ) * 190; CG_DrawRotatePic2( cx, cy, 12, 24, 90 - i, cgs.media.disruptorInsertTick ); } // FIXME: doesn't know about ammo!! which is bad because it draws charge beyond what ammo you may have.. if ( cg_entities[0].gent->client->ps.weaponstate == WEAPON_CHARGING_ALT ) { cgi_R_SetColor( colorTable[CT_WHITE] ); // draw the charge level max = ( cg.time - cg_entities[0].gent->client->ps.weaponChargeTime ) / ( 150.0f * 10.0f ); // bad hardcodedness 150 is disruptor charge unit and 10 is max charge units allowed. if ( max > 1.0f ) { max = 1.0f; } CG_DrawPic2( 257, 435, 134 * max, 34, 0,0,max,1,cgi_R_RegisterShaderNoMip( "gfx/2d/crop_charge" )); } } //----------- // Light Amp //-------------------------------- else if ( cg.zoomMode == 3 ) { CG_RegisterItemVisuals( ITM_LA_GOGGLES_PICKUP ); if ( power ) { cgi_R_SetColor( colorTable[CT_WHITE] ); CG_DrawPic( 34, 29, 580, 410, cgs.media.laGogglesStatic ); CG_DrawPic( 570, 140, 12, 160, cgs.media.laGogglesSideBit ); float light = (128-cent->gent->lightLevel) * 0.5f; if ( light < -81 ) // saber can really jack up local light levels....?magic number?? { light = -81; } float pos1 = 220 + light; float pos2 = 220 + cosf( cg.time * 0.0004f + light * 0.05f ) * 40 + sinf( cg.time * 0.0013f + 1 ) * 20 + sinf( cg.time * 0.0021f ) * 5; // Flickery color color1[0] = 0.7f + crandom() * 0.2f; color1[1] = 0.8f + crandom() * 0.2f; color1[2] = 0.7f + crandom() * 0.2f; color1[3] = 1.0f; cgi_R_SetColor( color1 ); CG_DrawPic( 565, pos1, 22, 8, cgs.media.laGogglesBracket ); CG_DrawPic( 558, pos2, 14, 5, cgs.media.laGogglesArrow ); } // Black out the area behind the battery display cgi_R_SetColor( colorTable[CT_DKGREY]); CG_DrawPic( 236, 357, 164, 16, cgs.media.whiteShader ); if ( power ) { // Power bar color1[0] = 1.0f * ( charge < 0.2f ? !!(cg.time & 256) : 1 ); color1[1] = charge * color1[0]; color1[2] = 0.0f; color1[3] = 0.4f; cgi_R_SetColor( color1 ); CG_DrawPic( 247.0f, 362.5f, charge * 143.0f, 6, cgs.media.whiteShader ); // pulsing dot bit color1[0] = sinf( cg.time * 0.01f ) * 0.5f + 0.5f; color1[0] = color1[0] * color1[0]; color1[1] = color1[0]; color1[2] = color1[0]; color1[3] = 1.0f; cgi_R_SetColor( color1 ); CG_DrawPic( 65, 94, 16, 16, cgs.media.binocularCircle ); } CG_DrawPic( 0, 0, 640, 480, cgs.media.laGogglesMask ); } } /* ================ CG_DrawStats ================ */ static void CG_DrawStats( void ) { centity_t *cent; playerState_t *ps; if ( cg_drawStatus.integer == 0 ) { return; } cent = &cg_entities[cg.snap->ps.clientNum]; ps = &cg.snap->ps; if ((cg.snap->ps.viewEntity>0&&cg.snap->ps.viewEntity<ENTITYNUM_WORLD)) { // MIGHT try and draw a custom hud if it wants... CG_DrawCustomHealthHud( cent ); return; } cgi_UI_MenuPaintAll(); qboolean drawHud = qtrue; if ( cent && cent->gent ) { drawHud = CG_DrawCustomHealthHud( cent ); } if (( drawHud ) && ( cg_drawHUD.integer )) { CG_DrawHUD( cent ); } } /* =================== CG_DrawPickupItem =================== */ static void CG_DrawPickupItem( void ) { int value; float *fadeColor; value = cg.itemPickup; if ( value && cg_items[ value ].icon != -1 ) { fadeColor = CG_FadeColor( cg.itemPickupTime, 3000 ); if ( fadeColor ) { CG_RegisterItemVisuals( value ); cgi_R_SetColor( fadeColor ); CG_DrawPic( 573, 320, ICON_SIZE, ICON_SIZE, cg_items[ value ].icon ); //CG_DrawBigString( ICON_SIZE + 16, 398, bg_itemlist[ value ].classname, fadeColor[0] ); //CG_DrawProportionalString( ICON_SIZE + 16, 398, // bg_itemlist[ value ].classname, CG_SMALLFONT,fadeColor ); cgi_R_SetColor( NULL ); } } } extern int cgi_EndGame(void); /* =================== CG_DrawPickupItem =================== */ void CG_DrawCredits(void) { if (!cg.creditsStart) { // cg.creditsStart = qtrue; CG_Credits_Init("CREDITS_RAVEN", &colorTable[CT_ICON_BLUE]); if ( cg_skippingcin.integer ) {//Were skipping a cinematic and it's over now gi.cvar_set("timescale", "1"); gi.cvar_set("skippingCinematic", "0"); } } if (cg.creditsStart) { if ( !CG_Credits_Running() ) { cgi_Cvar_Set( "cg_endcredits", "0" ); cgi_EndGame(); } } } //draw the health bar based on current "health" and maxhealth void CG_DrawHealthBar(centity_t *cent, float chX, float chY, float chW, float chH) { vec4_t aColor; vec4_t bColor; vec4_t cColor; float x = chX-(chW/2); float y = chY-chH; float percent = 0.0f; if ( !cent || !cent->gent ) { return; } percent = ((float)cent->gent->health/(float)cent->gent->max_health); if (percent <= 0) { return; } //color of the bar //hostile aColor[0] = 1.0f; aColor[1] = 0.0f; aColor[2] = 0.0f; aColor[3] = 0.4f; //color of the border bColor[0] = 0.0f; bColor[1] = 0.0f; bColor[2] = 0.0f; bColor[3] = 0.3f; //color of greyed out "missing health" cColor[0] = 0.5f; cColor[1] = 0.5f; cColor[2] = 0.5f; cColor[3] = 0.4f; //draw the background (black) CG_DrawRect(x, y, chW, chH, 1.0f, colorTable[CT_BLACK]); //now draw the part to show how much health there is in the color specified CG_FillRect(x+1.0f, y+1.0f, (percent*chW)-1.0f, chH-1.0f, aColor); //then draw the other part greyed out CG_FillRect(x+(percent*chW), y+1.0f, chW-(percent*chW)-1.0f, chH-1.0f, cColor); } #define MAX_HEALTH_BAR_ENTS 32 int cg_numHealthBarEnts = 0; int cg_healthBarEnts[MAX_HEALTH_BAR_ENTS]; #define HEALTH_BAR_WIDTH 50 #define HEALTH_BAR_HEIGHT 5 void CG_DrawHealthBars( void ) { float chX=0, chY=0; centity_t *cent; vec3_t pos; for ( int i = 0; i < cg_numHealthBarEnts; i++ ) { cent = &cg_entities[cg_healthBarEnts[i]]; if ( cent && cent->gent ) { VectorCopy( cent->lerpOrigin, pos ); pos[2] += cent->gent->maxs[2]+HEALTH_BAR_HEIGHT+8; if ( CG_WorldCoordToScreenCoordFloat( pos, &chX, &chY ) ) {//on screen CG_DrawHealthBar( cent, chX, chY, HEALTH_BAR_WIDTH, HEALTH_BAR_HEIGHT ); } } } } #define HEALTHBARRANGE 422 void CG_AddHealthBarEnt( int entNum ) { if ( cg_numHealthBarEnts >= MAX_HEALTH_BAR_ENTS ) {//FIXME: Debug error message? return; } if (DistanceSquared( cg_entities[entNum].lerpOrigin, g_entities[0].client->renderInfo.eyePoint ) < (HEALTHBARRANGE*HEALTHBARRANGE) ) { cg_healthBarEnts[cg_numHealthBarEnts++] = entNum; } } void CG_ClearHealthBarEnts( void ) { if ( cg_numHealthBarEnts ) { cg_numHealthBarEnts = 0; memset( &cg_healthBarEnts, 0, MAX_HEALTH_BAR_ENTS ); } } /* ================================================================================ CROSSHAIR ================================================================================ */ /* ================= CG_DrawCrosshair ================= */ #ifdef AUTOAIM short cg_crossHairStatus = 0; #endif static void CG_DrawCrosshair( vec3_t worldPoint ) { float w, h; qhandle_t hShader; qboolean corona = qfalse; vec4_t ecolor; float f; float x, y; if ( !cg_drawCrosshair.integer ) { return; } if ( cg.zoomMode > 0 && cg.zoomMode < 3 ) { //not while scoped return; } #ifdef AUTOAIM cg_crossHairStatus = 0; #endif //set color based on what kind of ent is under crosshair if ( g_crosshairEntNum >= ENTITYNUM_WORLD ) { ecolor[0] = ecolor[1] = ecolor[2] = 1.0f; } else if ( cg_forceCrosshair && cg_crosshairForceHint.integer ) { ecolor[0] = 0.2f; ecolor[1] = 0.5f; ecolor[2] = 1.0f; corona = qtrue; } else if ( cg_crosshairIdentifyTarget.integer ) { gentity_t *crossEnt = &g_entities[g_crosshairEntNum]; if ( crossEnt->client ) { if ( crossEnt->client->ps.powerups[PW_CLOAKED] ) {//cloaked don't show up ecolor[0] = 1.0f;//R ecolor[1] = 1.0f;//G ecolor[2] = 1.0f;//B } else if ( g_entities[0].client && g_entities[0].client->playerTeam == TEAM_FREE ) {//evil player: everyone is red #ifdef AUTOAIM cg_crossHairStatus = 1; #endif //Enemies are red ecolor[0] = 1.0f;//R ecolor[1] = 0.1f;//G ecolor[2] = 0.1f;//B } else if ( crossEnt->client->playerTeam == TEAM_PLAYER ) { //Allies are green ecolor[0] = 0.0f;//R ecolor[1] = 1.0f;//G ecolor[2] = 0.0f;//B } else if ( crossEnt->client->playerTeam == TEAM_NEUTRAL ) { // NOTE: was yellow, but making it white unless they really decide they want to see colors ecolor[0] = 1.0f;//R ecolor[1] = 1.0f;//G ecolor[2] = 1.0f;//B } else { #ifdef AUTOAIM cg_crossHairStatus = 1; #endif //Enemies are red ecolor[0] = 1.0f;//R ecolor[1] = 0.1f;//G ecolor[2] = 0.1f;//B } } else if ( crossEnt->s.weapon == WP_TURRET && (crossEnt->svFlags&SVF_NONNPC_ENEMY) ) { // a turret if ( crossEnt->noDamageTeam == TEAM_PLAYER ) { // mine are green ecolor[0] = 0.0;//R ecolor[1] = 1.0;//G ecolor[2] = 0.0;//B } else { // hostile ones are red #ifdef AUTOAIM cg_crossHairStatus = 1; #endif ecolor[0] = 1.0;//R ecolor[1] = 0.0;//G ecolor[2] = 0.0;//B } } else if ( crossEnt->s.weapon == WP_TRIP_MINE ) { // tripmines are red #ifdef AUTOAIM cg_crossHairStatus = 1; #endif ecolor[0] = 1.0;//R ecolor[1] = 0.0;//G ecolor[2] = 0.0;//B } else if ( (crossEnt->flags&FL_RED_CROSSHAIR) ) {//special case flagged to turn crosshair red #ifdef AUTOAIM cg_crossHairStatus = 1; #endif ecolor[0] = 1.0;//R ecolor[1] = 0.0;//G ecolor[2] = 0.0;//B } else { VectorCopy( crossEnt->startRGBA, ecolor ); if ( !ecolor[0] && !ecolor[1] && !ecolor[2] ) { // We don't want a black crosshair, so use white since it will show up better ecolor[0] = 1.0f;//R ecolor[1] = 1.0f;//G ecolor[2] = 1.0f;//B } } } else // cg_crosshairIdentifyTarget is not on, so make it white { ecolor[0] = ecolor[1] = ecolor[2] = 1.0f; } ecolor[3] = 1.0; cgi_R_SetColor( ecolor ); if ( cg.forceCrosshairStartTime ) { // both of these calcs will fade the corona in one direction if ( cg.forceCrosshairEndTime ) { ecolor[3] = (cg.time - cg.forceCrosshairEndTime) / 500.0f; } else { ecolor[3] = (cg.time - cg.forceCrosshairStartTime) / 300.0f; } // clamp if ( ecolor[3] < 0 ) { ecolor[3] = 0; } else if ( ecolor[3] > 1.0f ) { ecolor[3] = 1.0f; } if ( !cg.forceCrosshairEndTime ) { // but for the other direction, we'll need to reverse it ecolor[3] = 1.0f - ecolor[3]; } } if ( corona ) // we are pointing at a crosshair item { if ( !cg.forceCrosshairStartTime ) { // must have just happened because we are not fading in yet...start it now cg.forceCrosshairStartTime = cg.time; cg.forceCrosshairEndTime = 0; } if ( cg.forceCrosshairEndTime ) { // must have just gone over a force thing again...and we were in the process of fading out. Set fade in level to the level where the fade left off cg.forceCrosshairStartTime = cg.time - ( 1.0f - ecolor[3] ) * 300.0f; cg.forceCrosshairEndTime = 0; } } else // not pointing at a crosshair item { if ( cg.forceCrosshairStartTime && !cg.forceCrosshairEndTime ) // were currently fading in { // must fade back out, but we will have to set the fadeout time to be equal to the current level of faded-in-edness cg.forceCrosshairEndTime = cg.time - ecolor[3] * 500.0f; } if ( cg.forceCrosshairEndTime && cg.time - cg.forceCrosshairEndTime > 500.0f ) // not pointing at anything and fade out is totally done { // reset everything cg.forceCrosshairStartTime = 0; cg.forceCrosshairEndTime = 0; } } w = h = cg_crosshairSize.value; // pulse the size of the crosshair when picking up items f = cg.time - cg.itemPickupBlendTime; if ( f > 0 && f < ITEM_BLOB_TIME ) { f /= ITEM_BLOB_TIME; w *= ( 1 + f ); h *= ( 1 + f ); } if ( worldPoint && VectorLength( worldPoint ) ) { if ( !CG_WorldCoordToScreenCoordFloat( worldPoint, &x, &y ) ) {//off screen, don't draw it return; } x -= 320;//???? y -= 240;//???? } else { x = cg_crosshairX.integer; y = cg_crosshairY.integer; } if ( cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD ) { if ( !Q_stricmp( "misc_panel_turret", g_entities[cg.snap->ps.viewEntity].classname )) { // draws a custom crosshair that is twice as large as normal cgi_R_DrawStretchPic( x + cg.refdef.x + 320 - w, y + cg.refdef.y + 240 - h, w * 2, h * 2, 0, 0, 1, 1, cgs.media.turretCrossHairShader ); } } else { hShader = cgs.media.crosshairShader[ cg_drawCrosshair.integer % NUM_CROSSHAIRS ]; cgi_R_DrawStretchPic( x + cg.refdef.x + 0.5 * (640 - w), y + cg.refdef.y + 0.5 * (480 - h), w, h, 0, 0, 1, 1, hShader ); } if ( cg.forceCrosshairStartTime && cg_crosshairForceHint.integer ) // drawing extra bits { ecolor[0] = ecolor[1] = ecolor[2] = (1 - ecolor[3]) * ( sinf( cg.time * 0.001f ) * 0.08f + 0.35f ); // don't draw full color ecolor[3] = 1.0f; cgi_R_SetColor( ecolor ); w *= 2.0f; h *= 2.0f; cgi_R_DrawStretchPic( x + cg.refdef.x + 0.5f * ( 640 - w ), y + cg.refdef.y + 0.5f * ( 480 - h ), w, h, 0, 0, 1, 1, cgs.media.forceCoronaShader ); } } /* qboolean CG_WorldCoordToScreenCoord(vec3_t worldCoord, int *x, int *y) Take any world coord and convert it to a 2D virtual 640x480 screen coord */ qboolean CG_WorldCoordToScreenCoordFloat(vec3_t worldCoord, float *x, float *y) { float xcenter, ycenter; vec3_t local, transformed; // xcenter = cg.refdef.width / 2;//gives screen coords adjusted for resolution // ycenter = cg.refdef.height / 2;//gives screen coords adjusted for resolution //NOTE: did it this way because most draw functions expect virtual 640x480 coords // and adjust them for current resolution xcenter = 640.0f / 2.0f;//gives screen coords in virtual 640x480, to be adjusted when drawn ycenter = 480.0f / 2.0f;//gives screen coords in virtual 640x480, to be adjusted when drawn VectorSubtract (worldCoord, cg.refdef.vieworg, local); transformed[0] = DotProduct(local,vright); transformed[1] = DotProduct(local,vup); transformed[2] = DotProduct(local,vfwd); // Make sure Z is not negative. if(transformed[2] < 0.01f) { return qfalse; } // Simple convert to screen coords. float xzi = xcenter / transformed[2] * (100.0f/cg.refdef.fov_x); float yzi = ycenter / transformed[2] * (100.0f/cg.refdef.fov_y); *x = xcenter + xzi * transformed[0]; *y = ycenter - yzi * transformed[1]; return qtrue; } qboolean CG_WorldCoordToScreenCoord( vec3_t worldCoord, int *x, int *y ) { float xF, yF; qboolean retVal = CG_WorldCoordToScreenCoordFloat( worldCoord, &xF, &yF ); *x = (int)xF; *y = (int)yF; return retVal; } // I'm keeping the rocket tracking code separate for now since I may want to do different logic...but it still uses trace info from scanCrosshairEnt //----------------------------------------- static void CG_ScanForRocketLock( void ) //----------------------------------------- { gentity_t *traceEnt; static qboolean tempLock = qfalse; // this will break if anything else uses this locking code ( other than the player ) traceEnt = &g_entities[g_crosshairEntNum]; if ( !traceEnt || g_crosshairEntNum <= 0 || g_crosshairEntNum >= ENTITYNUM_WORLD || (!traceEnt->client && traceEnt->s.weapon != WP_TURRET ) || !traceEnt->health || ( traceEnt && traceEnt->client && traceEnt->client->ps.powerups[PW_CLOAKED] )) { // see how much locking we have int dif = ( cg.time - g_rocketLockTime ) / ( 1200.0f / 8.0f ); // 8 is full locking....also if we just traced onto the world, // give them 1/2 second of slop before dropping the lock if ( dif < 8 && g_rocketSlackTime + 500 < cg.time ) { // didn't have a full lock and not in grace period, so drop the lock g_rocketLockTime = 0; g_rocketSlackTime = 0; tempLock = qfalse; } if ( g_rocketSlackTime + 500 >= cg.time && g_rocketLockEntNum < ENTITYNUM_WORLD ) { // were locked onto an ent, aren't right now.....but still within the slop grace period // keep the current lock amount g_rocketLockTime += cg.frametime; } if ( !tempLock && g_rocketLockEntNum < ENTITYNUM_WORLD && dif >= 8 ) { tempLock = qtrue; if ( g_rocketLockTime + 1200 < cg.time ) { g_rocketLockTime = cg.time - 1200; // doh, hacking the time so the targetting still gets drawn full } } // keep locking to this thing for one second after it gets out of view if ( g_rocketLockTime + 2000.0f < cg.time ) // since time was hacked above, I'm compensating so that 2000ms is really only 1000ms { // too bad, you had your chance g_rocketLockEntNum = ENTITYNUM_NONE; g_rocketSlackTime = 0; g_rocketLockTime = 0; } } else { tempLock = qfalse; if ( g_rocketLockEntNum >= ENTITYNUM_WORLD ) { if ( g_rocketSlackTime + 500 < cg.time ) { // we just locked onto something, start the lock at the current time g_rocketLockEntNum = g_crosshairEntNum; g_rocketLockTime = cg.time; g_rocketSlackTime = cg.time; } } else { if ( g_rocketLockEntNum != g_crosshairEntNum ) { g_rocketLockTime = cg.time; } // may as well always set this when we can potentially lock to something g_rocketSlackTime = cg.time; g_rocketLockEntNum = g_crosshairEntNum; } } } /* ================= CG_ScanForCrosshairEntity ================= */ extern Vehicle_t *G_IsRidingVehicle( gentity_t *ent ); extern float forcePushPullRadius[]; static void CG_ScanForCrosshairEntity( qboolean scanAll ) { trace_t trace; gentity_t *traceEnt = NULL; vec3_t start, end; int content; int ignoreEnt = cg.snap->ps.clientNum; Vehicle_t *pVeh = NULL; //FIXME: debounce this to about 10fps? cg_forceCrosshair = qfalse; if ( cg_entities[0].gent && cg_entities[0].gent->client ) // <-Mike said it should always do this //if (cg_crosshairForceHint.integer && {//try to check for force-affectable stuff first vec3_t d_f, d_rt, d_up; // If you're riding a vehicle and not being drawn. if ( ( pVeh = G_IsRidingVehicle( cg_entities[0].gent ) ) != NULL && cg_entities[0].currentState.eFlags & EF_NODRAW ) { VectorCopy( cg_entities[pVeh->m_pParentEntity->s.number].lerpOrigin, start ); AngleVectors( cg_entities[pVeh->m_pParentEntity->s.number].lerpAngles, d_f, d_rt, d_up ); } else { VectorCopy( g_entities[0].client->renderInfo.eyePoint, start ); AngleVectors( cg_entities[0].lerpAngles, d_f, d_rt, d_up ); } VectorMA( start, 2048, d_f, end );//4028 is max for mind trick //YES! This is very very bad... but it works! James made me do it. Really, he did. Blame James. gi.trace( &trace, start, vec3_origin, vec3_origin, end, ignoreEnt, MASK_OPAQUE|CONTENTS_SHOTCLIP|CONTENTS_BODY|CONTENTS_ITEM|CONTENTS_TERRAIN, G2_NOCOLLIDE, 10 );// ); took out CONTENTS_SOLID| so you can target people through glass.... took out CONTENTS_CORPSE so disintegrated guys aren't shown, could just remove their body earlier too... if ( trace.entityNum < ENTITYNUM_WORLD ) {//hit something traceEnt = &g_entities[trace.entityNum]; if ( traceEnt ) { // Check for mind trickable-guys if ( traceEnt->client ) {//is a client if ( cg_entities[0].gent->client->ps.forcePowerLevel[FP_TELEPATHY] && traceEnt->health > 0 && VALIDSTRING(traceEnt->behaviorSet[BSET_MINDTRICK]) ) {//I have the ability to mind-trick and he is alive and he has a mind trick script //NOTE: no need to check range since it's always 2048 cg_forceCrosshair = qtrue; } } // No? Check for force-push/pullable doors and func_statics else if ( traceEnt->s.eType == ET_MOVER ) {//hit a mover if ( !Q_stricmp( "func_door", traceEnt->classname ) ) {//it's a func_door if ( traceEnt->spawnflags & 2/*MOVER_FORCE_ACTIVATE*/ ) {//it's force-usable if ( cg_entities[0].gent->client->ps.forcePowerLevel[FP_PULL] || cg_entities[0].gent->client->ps.forcePowerLevel[FP_PUSH] ) {//player has push or pull float maxRange; if ( cg_entities[0].gent->client->ps.forcePowerLevel[FP_PULL] > cg_entities[0].gent->client->ps.forcePowerLevel[FP_PUSH] ) {//use the better range maxRange = forcePushPullRadius[cg_entities[0].gent->client->ps.forcePowerLevel[FP_PULL]]; } else {//use the better range maxRange = forcePushPullRadius[cg_entities[0].gent->client->ps.forcePowerLevel[FP_PUSH]]; } if ( maxRange >= trace.fraction * 2048 ) {//actually close enough to use one of our force powers on it cg_forceCrosshair = qtrue; } } } } else if ( !Q_stricmp( "func_static", traceEnt->classname ) ) {//it's a func_static if ( (traceEnt->spawnflags & 1/*F_PUSH*/) && (traceEnt->spawnflags & 2/*F_PULL*/) ) {//push or pullable float maxRange; if ( cg_entities[0].gent->client->ps.forcePowerLevel[FP_PULL] > cg_entities[0].gent->client->ps.forcePowerLevel[FP_PUSH] ) {//use the better range maxRange = forcePushPullRadius[cg_entities[0].gent->client->ps.forcePowerLevel[FP_PULL]]; } else {//use the better range maxRange = forcePushPullRadius[cg_entities[0].gent->client->ps.forcePowerLevel[FP_PUSH]]; } if ( maxRange >= trace.fraction * 2048 ) {//actually close enough to use one of our force powers on it cg_forceCrosshair = qtrue; } } else if ( (traceEnt->spawnflags & 1/*F_PUSH*/) ) {//pushable only if ( forcePushPullRadius[cg_entities[0].gent->client->ps.forcePowerLevel[FP_PUSH]] >= trace.fraction * 2048 ) {//actually close enough to use force push on it cg_forceCrosshair = qtrue; } } else if ( (traceEnt->spawnflags & 2/*F_PULL*/) ) {//pullable only if ( forcePushPullRadius[cg_entities[0].gent->client->ps.forcePowerLevel[FP_PULL]] >= trace.fraction * 2048 ) {//actually close enough to use force pull on it cg_forceCrosshair = qtrue; } } } } } } } if ( !cg_forceCrosshair ) { if ( 1 ) //(cg_dynamicCrosshair.integer ) {//100% accurate vec3_t d_f, d_rt, d_up; // If you're riding a vehicle and not being drawn. if ( ( pVeh = G_IsRidingVehicle( cg_entities[0].gent ) ) != NULL && cg_entities[0].currentState.eFlags & EF_NODRAW ) { VectorCopy( cg_entities[pVeh->m_pParentEntity->s.number].lerpOrigin, start ); AngleVectors( cg_entities[pVeh->m_pParentEntity->s.number].lerpAngles, d_f, d_rt, d_up ); } else if ( cg.snap->ps.weapon == WP_NONE || cg.snap->ps.weapon == WP_SABER || cg.snap->ps.weapon == WP_STUN_BATON ) { if ( cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD ) {//in camera ent view ignoreEnt = cg.snap->ps.viewEntity; if ( g_entities[cg.snap->ps.viewEntity].client ) { VectorCopy( g_entities[cg.snap->ps.viewEntity].client->renderInfo.eyePoint, start ); } else { VectorCopy( cg_entities[cg.snap->ps.viewEntity].lerpOrigin, start ); } AngleVectors( cg_entities[cg.snap->ps.viewEntity].lerpAngles, d_f, d_rt, d_up ); } else { VectorCopy( g_entities[0].client->renderInfo.eyePoint, start ); AngleVectors( cg_entities[0].lerpAngles, d_f, d_rt, d_up ); } } else { extern void CalcMuzzlePoint( gentity_t *const ent, vec3_t forward, vec3_t right, vec3_t up, vec3_t muzzlePoint, float lead_in ); AngleVectors( cg_entities[0].lerpAngles, d_f, d_rt, d_up ); CalcMuzzlePoint( &g_entities[0], d_f, d_rt, d_up, start , 0 ); } //VectorCopy( g_entities[0].client->renderInfo.muzzlePoint, start ); //FIXME: increase this? Increase when zoom in? VectorMA( start, 4096, d_f, end );//was 8192 } else {//old way VectorCopy( cg.refdef.vieworg, start ); //FIXME: increase this? Increase when zoom in? VectorMA( start, 4096, cg.refdef.viewaxis[0], end );//was 8192 } //YES! This is very very bad... but it works! James made me do it. Really, he did. Blame James. gi.trace( &trace, start, vec3_origin, vec3_origin, end, ignoreEnt, MASK_OPAQUE|CONTENTS_TERRAIN|CONTENTS_SHOTCLIP|CONTENTS_BODY|CONTENTS_ITEM, G2_NOCOLLIDE, 10 );// ); took out CONTENTS_SOLID| so you can target people through glass.... took out CONTENTS_CORPSE so disintegrated guys aren't shown, could just remove their body earlier too... /* CG_Trace( &trace, start, vec3_origin, vec3_origin, end, cg.snap->ps.clientNum, MASK_PLAYERSOLID|CONTENTS_CORPSE|CONTENTS_ITEM ); */ //FIXME: pick up corpses if ( trace.startsolid || trace.allsolid ) { // trace should not be allowed to pick up anything if it started solid. I tried actually moving the trace start back, which also worked, // but the dynamic cursor drawing caused it to render around the clip of the gun when I pushed the blaster all the way into a wall. // It looked quite horrible...but, if this is bad for some reason that I don't know trace.entityNum = ENTITYNUM_NONE; } traceEnt = &g_entities[trace.entityNum]; } // if the object is "dead", don't show it /* if ( cg.crosshairClientNum && g_entities[cg.crosshairClientNum].health <= 0 ) { cg.crosshairClientNum = 0; return; } */ //CROSSHAIR is now always drawn from this trace so it's 100% accurate if ( 1 ) //(cg_dynamicCrosshair.integer ) {//draw crosshair at endpoint CG_DrawCrosshair( trace.endpos ); } g_crosshairEntNum = trace.entityNum; g_crosshairEntDist = 4096*trace.fraction; if ( !traceEnt ) { //not looking at anything g_crosshairSameEntTime = 0; g_crosshairEntTime = 0; } else {//looking at a valid ent //store the distance if ( trace.entityNum != g_crosshairEntNum ) {//new crosshair ent g_crosshairSameEntTime = 0; } else if ( g_crosshairEntDist < 256 ) {//close enough to start counting how long you've been looking g_crosshairSameEntTime += cg.frametime; } //remember the last time you looked at the person g_crosshairEntTime = cg.time; } if ( !traceEnt ) { if ( traceEnt && scanAll ) { } else { return; } } // if the player is in fog, don't show it content = cgi_CM_PointContents( trace.endpos, 0 ); if ( content & CONTENTS_FOG ) { return; } // if the player is cloaked, don't show it if ( cg_entities[ trace.entityNum ].currentState.powerups & ( 1 << PW_CLOAKED )) { return; } // update the fade timer if ( cg.crosshairClientNum != trace.entityNum ) { infoStringCount = 0; } cg.crosshairClientNum = trace.entityNum; cg.crosshairClientTime = cg.time; } /* ===================== CG_DrawCrosshairNames ===================== */ static void CG_DrawCrosshairNames( void ) { qboolean scanAll = qfalse; centity_t *player = &cg_entities[0]; if ( 1 ) //cg_dynamicCrosshair.integer ) { // still need to scan for dynamic crosshair CG_ScanForCrosshairEntity( scanAll ); return; } if ( !player->gent ) { return; } if ( !player->gent->client ) { return; } // scan the known entities to see if the crosshair is sighted on one // This is currently being called by the rocket tracking code, so we don't necessarily want to do duplicate traces :) CG_ScanForCrosshairEntity( scanAll ); } //-------------------------------------------------------------- static void CG_DrawActivePowers(void) //-------------------------------------------------------------- { int icon_size = 40; int startx = icon_size*2+16; int starty = SCREEN_HEIGHT - icon_size*2; int endx = icon_size; int endy = icon_size; if (cg.zoomMode) { //don't display over zoom mask return; } /* //draw icon for duration powers so we know what powers are active cuttently int i = 0; while (i < NUM_FORCE_POWERS) { if ((cg.snap->ps.forcePowersActive & (1 << forcePowerSorted[i])) && CG_IsDurationPower(forcePowerSorted[i])) { CG_DrawPic( startx, starty, endx, endy, cgs.media.forcePowerIcons[forcePowerSorted[i]]); startx += (icon_size+2); //+2 for spacing if ((startx+icon_size) >= SCREEN_WIDTH-80) { startx = icon_size*2+16; starty += (icon_size+2); } } i++; } */ //additionally, draw an icon force force rage recovery if (cg.snap->ps.forceRageRecoveryTime > cg.time) { CG_DrawPic( startx, starty, endx, endy, cgs.media.rageRecShader); } } //-------------------------------------------------------------- static void CG_DrawRocketLocking( int lockEntNum, int lockTime ) //-------------------------------------------------------------- { gentity_t *gent = &g_entities[lockEntNum]; if ( !gent ) { return; } int cx, cy; vec3_t org; static int oldDif = 0; VectorCopy( gent->currentOrigin, org ); org[2] += (gent->mins[2] + gent->maxs[2]) * 0.5f; if ( CG_WorldCoordToScreenCoord( org, &cx, &cy )) { // we care about distance from enemy to eye, so this is good enough float sz = Distance( gent->currentOrigin, cg.refdef.vieworg ) / 1024.0f; if ( cg.zoomMode > 0 ) { if ( cg.overrides.active & CG_OVERRIDE_FOV ) { sz -= ( cg.overrides.fov - cg_zoomFov ) / 80.0f; } else { sz -= ( cg_fov.value - cg_zoomFov ) / 80.0f; } } if ( sz > 1.0f ) { sz = 1.0f; } else if ( sz < 0.0f ) { sz = 0.0f; } sz = (1.0f - sz) * (1.0f - sz) * 32 + 6; vec4_t color={0.0f,0.0f,0.0f,0.0f}; cy += sz * 0.5f; // well now, take our current lock time and divide that by 8 wedge slices to get the current lock amount int dif = ( cg.time - g_rocketLockTime ) / ( 1200.0f / 8.0f ); if ( dif < 0 ) { oldDif = 0; return; } else if ( dif > 8 ) { dif = 8; } // do sounds if ( oldDif != dif ) { if ( dif == 8 ) { cgi_S_StartSound( org, 0, CHAN_AUTO, cgi_S_RegisterSound( "sound/weapons/rocket/lock.wav" )); } else { cgi_S_StartSound( org, 0, CHAN_AUTO, cgi_S_RegisterSound( "sound/weapons/rocket/tick.wav" )); } } oldDif = dif; for ( int i = 0; i < dif; i++ ) { color[0] = 1.0f; color[1] = 0.0f; color[2] = 0.0f; color[3] = 0.1f * i + 0.2f; cgi_R_SetColor( color ); // our slices are offset by about 45 degrees. CG_DrawRotatePic( cx - sz, cy - sz, sz, sz, i * 45.0f, cgi_R_RegisterShaderNoMip( "gfx/2d/wedge" )); } // we are locked and loaded baby if ( dif == 8 ) { color[0] = color[1] = color[2] = sinf( cg.time * 0.05f ) * 0.5f + 0.5f; color[3] = 1.0f; // this art is additive, so the alpha value does nothing cgi_R_SetColor( color ); CG_DrawPic( cx - sz, cy - sz * 2, sz * 2, sz * 2, cgi_R_RegisterShaderNoMip( "gfx/2d/lock" )); } } } //------------------------------------ static void CG_RunRocketLocking( void ) //------------------------------------ { centity_t *player = &cg_entities[0]; // Only bother with this when the player is holding down the alt-fire button of the rocket launcher if ( player->currentState.weapon == WP_ROCKET_LAUNCHER ) { if ( player->currentState.eFlags & EF_ALT_FIRING ) { CG_ScanForRocketLock(); if ( g_rocketLockEntNum > 0 && g_rocketLockEntNum < ENTITYNUM_WORLD && g_rocketLockTime > 0 ) { #ifdef _XBOX FFFX_START( fffx_StartConst ); #endif CG_DrawRocketLocking( g_rocketLockEntNum, g_rocketLockTime ); } #ifdef _XBOX else { FFFX_START( fffx_StopConst ); } #endif } else { // disengage any residual locking #ifdef _XBOX FFFX_START( fffx_StopConst ); #endif g_rocketLockEntNum = ENTITYNUM_WORLD; g_rocketLockTime = 0; } } } /* ================= CG_DrawIntermission ================= */ static void CG_DrawIntermission( void ) { CG_DrawScoreboard(); } /* ================== CG_DrawSnapshot ================== */ static float CG_DrawSnapshot( float y ) { char *s; int w; s = va( "time:%i snap:%i cmd:%i", cg.snap->serverTime, cg.latestSnapshotNum, cgs.serverCommandSequence ); w = cgi_R_Font_StrLenPixels(s, cgs.media.qhFontMedium, 1.0f); cgi_R_Font_DrawString(635 - w, y+2, s, colorTable[CT_LTGOLD1], cgs.media.qhFontMedium, -1, 1.0f); return y + BIGCHAR_HEIGHT + 10; } /* ================== CG_DrawFPS ================== */ #define FPS_FRAMES 16 static float CG_DrawFPS( float y ) { char *s; static unsigned short previousTimes[FPS_FRAMES]; static unsigned short index; static int previous, lastupdate; int t, i, fps, total; unsigned short frameTime; #ifdef _XBOX const int xOffset = 30; #else const int xOffset = 0; #endif // don't use serverTime, because that will be drifting to // correct for internet lag changes, timescales, timedemos, etc t = cgi_Milliseconds(); frameTime = t - previous; previous = t; if (t - lastupdate > 50) //don't sample faster than this { lastupdate = t; previousTimes[index % FPS_FRAMES] = frameTime; index++; } // average multiple frames together to smooth changes out a bit total = 0; for ( i = 0 ; i < FPS_FRAMES ; i++ ) { total += previousTimes[i]; } if ( !total ) { total = 1; } fps = 1000 * FPS_FRAMES / total; s = va( "%ifps", fps ); const int w = cgi_R_Font_StrLenPixels(s, cgs.media.qhFontMedium, 1.0f); cgi_R_Font_DrawString(635-xOffset - w, y+2, s, colorTable[CT_LTGOLD1], cgs.media.qhFontMedium, -1, 1.0f); return y + BIGCHAR_HEIGHT + 10; } /* ================= CG_DrawTimer ================= */ static float CG_DrawTimer( float y ) { char *s; int w; int mins, seconds, tens; seconds = cg.time / 1000; mins = seconds / 60; seconds -= mins * 60; tens = seconds / 10; seconds -= tens * 10; s = va( "%i:%i%i", mins, tens, seconds ); w = cgi_R_Font_StrLenPixels(s, cgs.media.qhFontMedium, 1.0f); cgi_R_Font_DrawString(635 - w, y+2, s, colorTable[CT_LTGOLD1], cgs.media.qhFontMedium, -1, 1.0f); return y + BIGCHAR_HEIGHT + 10; } /* ================= CG_DrawAmmoWarning ================= */ static void CG_DrawAmmoWarning( void ) { char text[1024]={0}; int w; if ( cg_drawAmmoWarning.integer == 0 ) { return; } if ( !cg.lowAmmoWarning ) { return; } if ( weaponData[cg.snap->ps.weapon].ammoIndex == AMMO_NONE ) {//doesn't use ammo, so no warning return; } if ( cg.lowAmmoWarning == 2 ) { cgi_SP_GetStringTextString( "SP_INGAME_INSUFFICIENTENERGY", text, sizeof(text) ); } else { return; //s = "LOW AMMO WARNING"; } w = cgi_R_Font_StrLenPixels(text, cgs.media.qhFontSmall, 1.0f); cgi_R_Font_DrawString(320 - w/2, 64, text, colorTable[CT_LTGOLD1], cgs.media.qhFontSmall, -1, 1.0f); } //--------------------------------------- static qboolean CG_RenderingFromMiscCamera() { //centity_t *cent; //cent = &cg_entities[cg.snap->ps.clientNum]; if ( cg.snap->ps.viewEntity > 0 && cg.snap->ps.viewEntity < ENTITYNUM_WORLD )// cent && cent->gent && cent->gent->client && cent->gent->client->ps.viewEntity) { // Only check viewEntities if ( !Q_stricmp( "misc_camera", g_entities[cg.snap->ps.viewEntity].classname )) { // Only doing a misc_camera, so check health. if ( g_entities[cg.snap->ps.viewEntity].health > 0 ) { CG_DrawPic( 0, 0, 640, 480, cgi_R_RegisterShader( "gfx/2d/workingCamera" )); } else { CG_DrawPic( 0, 0, 640, 480, cgi_R_RegisterShader( "gfx/2d/brokenCamera" )); } // don't render other 2d stuff return qtrue; } else if ( !Q_stricmp( "misc_panel_turret", g_entities[cg.snap->ps.viewEntity].classname )) { // could do a panel turret screen overlay...this is a cheesy placeholder CG_DrawPic( 30, 90, 128, 300, cgs.media.turretComputerOverlayShader ); CG_DrawPic( 610, 90, -128, 300, cgs.media.turretComputerOverlayShader ); } else { // FIXME: make sure that this assumption is correct...because I'm assuming that I must be a droid. CG_DrawPic( 0, 0, 640, 480, cgi_R_RegisterShader( "gfx/2d/droid_view" )); } } // not in misc_camera, render other stuff. return qfalse; } qboolean cg_usingInFrontOf = qfalse; qboolean CanUseInfrontOf(gentity_t*); static void CG_UseIcon() { cg_usingInFrontOf = CanUseInfrontOf(cg_entities[cg.snap->ps.clientNum].gent); if (cg_usingInFrontOf) { cgi_R_SetColor( NULL ); CG_DrawPic( 50, 285, 64, 64, cgs.media.useableHint ); } } static void CG_Draw2DScreenTints( void ) { float rageTime, rageRecTime, absorbTime, protectTime; vec4_t hcolor; //force effects if (cg.snap->ps.forcePowersActive & (1 << FP_RAGE)) { if (!cgRageTime) { cgRageTime = cg.time; } rageTime = (float)(cg.time - cgRageTime); rageTime /= 9000; if ( rageTime < 0 ) { rageTime = 0; } if ( rageTime > 0.15f ) { rageTime = 0.15f; } hcolor[3] = rageTime; hcolor[0] = 0.7f; hcolor[1] = 0; hcolor[2] = 0; if (!cg.renderingThirdPerson) { CG_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor ); } cgRageFadeTime = 0; cgRageFadeVal = 0; } else if (cgRageTime) { if (!cgRageFadeTime) { cgRageFadeTime = cg.time; cgRageFadeVal = 0.15f; } rageTime = cgRageFadeVal; cgRageFadeVal -= (cg.time - cgRageFadeTime)*0.000005; if (rageTime < 0) { rageTime = 0; } if ( rageTime > 0.15f ) { rageTime = 0.15f; } if ( cg.snap->ps.forceRageRecoveryTime > cg.time ) { float checkRageRecTime = rageTime; if ( checkRageRecTime < 0.15f ) { checkRageRecTime = 0.15f; } hcolor[3] = checkRageRecTime; hcolor[0] = rageTime*4; if ( hcolor[0] < 0.2f ) { hcolor[0] = 0.2f; } hcolor[1] = 0.2f; hcolor[2] = 0.2f; } else { hcolor[3] = rageTime; hcolor[0] = 0.7f; hcolor[1] = 0; hcolor[2] = 0; } if (!cg.renderingThirdPerson && rageTime) { CG_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor ); } else { if (cg.snap->ps.forceRageRecoveryTime > cg.time) { hcolor[3] = 0.15f; hcolor[0] = 0.2f; hcolor[1] = 0.2f; hcolor[2] = 0.2f; CG_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor ); } cgRageTime = 0; } } else if (cg.snap->ps.forceRageRecoveryTime > cg.time) { if (!cgRageRecTime) { cgRageRecTime = cg.time; } rageRecTime = (float)(cg.time - cgRageRecTime); rageRecTime /= 9000; if ( rageRecTime < 0.15f )//0) { rageRecTime = 0.15f;//0; } if ( rageRecTime > 0.15f ) { rageRecTime = 0.15f; } hcolor[3] = rageRecTime; hcolor[0] = 0.2f; hcolor[1] = 0.2f; hcolor[2] = 0.2f; if ( !cg.renderingThirdPerson ) { CG_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor ); } cgRageRecFadeTime = 0; cgRageRecFadeVal = 0; } else if (cgRageRecTime) { if (!cgRageRecFadeTime) { cgRageRecFadeTime = cg.time; cgRageRecFadeVal = 0.15f; } rageRecTime = cgRageRecFadeVal; cgRageRecFadeVal -= (cg.time - cgRageRecFadeTime)*0.000005; if (rageRecTime < 0) { rageRecTime = 0; } if ( rageRecTime > 0.15f ) { rageRecTime = 0.15f; } hcolor[3] = rageRecTime; hcolor[0] = 0.2f; hcolor[1] = 0.2f; hcolor[2] = 0.2f; if (!cg.renderingThirdPerson && rageRecTime) { CG_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor ); } else { cgRageRecTime = 0; } } if (cg.snap->ps.forcePowersActive & (1 << FP_ABSORB)) { if (!cgAbsorbTime) { cgAbsorbTime = cg.time; } absorbTime = (float)(cg.time - cgAbsorbTime); absorbTime /= 9000; if ( absorbTime < 0 ) { absorbTime = 0; } if ( absorbTime > 0.15f ) { absorbTime = 0.15f; } hcolor[3] = absorbTime/2; hcolor[0] = 0; hcolor[1] = 0; hcolor[2] = 0.7f; if ( !cg.renderingThirdPerson ) { CG_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor ); } cgAbsorbFadeTime = 0; cgAbsorbFadeVal = 0; } else if (cgAbsorbTime) { if (!cgAbsorbFadeTime) { cgAbsorbFadeTime = cg.time; cgAbsorbFadeVal = 0.15f; } absorbTime = cgAbsorbFadeVal; cgAbsorbFadeVal -= (cg.time - cgAbsorbFadeTime)*0.000005; if ( absorbTime < 0 ) { absorbTime = 0; } if ( absorbTime > 0.15f ) { absorbTime = 0.15f; } hcolor[3] = absorbTime/2; hcolor[0] = 0; hcolor[1] = 0; hcolor[2] = 0.7f; if ( !cg.renderingThirdPerson && absorbTime ) { CG_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor ); } else { cgAbsorbTime = 0; } } if (cg.snap->ps.forcePowersActive & (1 << FP_PROTECT)) { if (!cgProtectTime) { cgProtectTime = cg.time; } protectTime = (float)(cg.time - cgProtectTime); protectTime /= 9000; if (protectTime < 0) { protectTime = 0; } if ( protectTime > 0.15f ) { protectTime = 0.15f; } hcolor[3] = protectTime/2; hcolor[0] = 0; hcolor[1] = 0.7f; hcolor[2] = 0; if ( !cg.renderingThirdPerson ) { CG_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor ); } cgProtectFadeTime = 0; cgProtectFadeVal = 0; } else if ( cgProtectTime ) { if ( !cgProtectFadeTime ) { cgProtectFadeTime = cg.time; cgProtectFadeVal = 0.15f; } protectTime = cgProtectFadeVal; cgProtectFadeVal -= (cg.time - cgProtectFadeTime)*0.000005; if (protectTime < 0) { protectTime = 0; } if (protectTime > 0.15f) { protectTime = 0.15f; } hcolor[3] = protectTime/2; hcolor[0] = 0; hcolor[1] = 0.7f; hcolor[2] = 0; if ( !cg.renderingThirdPerson && protectTime ) { CG_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor ); } else { cgProtectTime = 0; } } if ( (cg.refdef.viewContents&CONTENTS_LAVA) ) {//tint screen red float phase = cg.time / 1000.0 * WAVE_FREQUENCY * M_PI * 2; hcolor[3] = 0.5 + (0.15f*sinf( phase )); hcolor[0] = 0.7f; hcolor[1] = 0; hcolor[2] = 0; CG_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor ); } else if ( (cg.refdef.viewContents&CONTENTS_SLIME) ) {//tint screen green float phase = cg.time / 1000.0 * WAVE_FREQUENCY * M_PI * 2; hcolor[3] = 0.4 + (0.1f*sinf( phase )); hcolor[0] = 0; hcolor[1] = 0.7f; hcolor[2] = 0; CG_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor ); } else if ( (cg.refdef.viewContents&CONTENTS_WATER) ) {//tint screen light blue -- FIXME: check to see if in fog? float phase = cg.time / 1000.0 * WAVE_FREQUENCY * M_PI * 2; hcolor[3] = 0.3 + (0.05f*sinf( phase )); hcolor[0] = 0; hcolor[1] = 0.2f; hcolor[2] = 0.8f; CG_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, hcolor ); } } /* ================= CG_Draw2D ================= */ extern void CG_SaberClashFlare( void ); static void CG_Draw2D( void ) { char text[1024]={0}; int w,y_pos; centity_t *cent = &cg_entities[cg.snap->ps.clientNum]; // if we are taking a levelshot for the menu, don't draw anything if ( cg.levelShot ) { return; } if ( cg_draw2D.integer == 0 ) { return; } if ( cg.snap->ps.pm_type == PM_INTERMISSION ) { CG_DrawIntermission(); return; } CG_Draw2DScreenTints(); //end credits if (cg_endcredits.integer) { if (!CG_Credits_Draw()) { CG_DrawCredits(); // will probably get rid of this soon } } CGCam_DrawWideScreen(); CG_DrawBatteryCharge(); if (cg.snap->ps.forcePowersActive || cg.snap->ps.forceRageRecoveryTime > cg.time) { CG_DrawActivePowers(); } // Draw this before the text so that any text won't get clipped off if ( !in_camera ) { CG_DrawZoomMask(); } CG_DrawScrollText(); CG_DrawCaptionText(); if ( in_camera ) {//still draw the saber clash flare, but nothing else CG_SaberClashFlare(); return; } if ( CG_RenderingFromMiscCamera()) { // purposely doing an early out when in a misc_camera, change it if needed. // allowing center print when in camera mode, probably just an alpha thing - dmv CG_DrawCenterString(); return; } if ( (cg.snap->ps.forcePowersActive&(1<<FP_SEE)) ) {//force sight is on //indicate this with sight cone thingy CG_DrawPic( 0, 0, 640, 480, cgi_R_RegisterShader( "gfx/2d/jsense" )); CG_DrawHealthBars(); } else if ( cg_debugHealthBars.integer ) { CG_DrawHealthBars(); } // don't draw any status if dead if ( cg.snap->ps.stats[STAT_HEALTH] > 0 ) { if ( !(cent->gent && cent->gent->s.eFlags & (EF_LOCKED_TO_WEAPON )))//|EF_IN_ATST { //CG_DrawIconBackground(); } CG_DrawWeaponSelect(); if ( cg.zoomMode == 0 ) { CG_DrawStats(); } CG_DrawAmmoWarning(); //CROSSHAIR is now done from the crosshair ent trace //if ( !cg.renderingThirdPerson && !cg_dynamicCrosshair.integer ) // disruptor draws it's own crosshair artwork; binocs draw nothing; third person draws its own crosshair //{ // CG_DrawCrosshair( NULL ); //} CG_DrawCrosshairNames(); CG_RunRocketLocking(); CG_DrawInventorySelect(); CG_DrawForceSelect(); CG_DrawPickupItem(); CG_UseIcon(); } CG_SaberClashFlare(); #ifdef _XBOX float y = 32; #else float y = 0; #endif if (cg_drawSnapshot.integer) { y=CG_DrawSnapshot(y); } if (cg_drawFPS.integer) { y=CG_DrawFPS(y); } if (cg_drawTimer.integer) { y=CG_DrawTimer(y); } // don't draw center string if scoreboard is up if ( !CG_DrawScoreboard() ) { CG_DrawCenterString(); } /* if (cg.showInformation) { // CG_DrawMissionInformation(); } else */ if (missionInfo_Updated) { if (cg.predicted_player_state.pm_type != PM_DEAD) { // Was a objective given? /* if ((cg_updatedDataPadForcePower.integer) || (cg_updatedDataPadObjective.integer)) { // How long has the game been running? If within 15 seconds of starting, throw up the datapad. if (cg.dataPadLevelStartTime>cg.time) { // Make it pop up if (!in_camera) { cgi_SendConsoleCommand( "datapad" ); cg.dataPadLevelStartTime=cg.time; //and don't do it again this level! } } } */ if (!cg.missionInfoFlashTime) { cg.missionInfoFlashTime = cg.time + cg_missionInfoFlashTime.integer; } if (cg.missionInfoFlashTime < cg.time) // Time's up. They didn't read it. { cg.missionInfoFlashTime = 0; missionInfo_Updated = qfalse; CG_ClearDataPadCvars(); } cgi_SP_GetStringTextString( "SP_INGAME_NEW_OBJECTIVE_INFO", text, sizeof(text) ); int x_pos = 0; y_pos = 20; w = cgi_R_Font_StrLenPixels(text,cgs.media.qhFontSmall, 1.0f); x_pos = (SCREEN_WIDTH/2)-(w/2); cgi_R_Font_DrawString(x_pos, y_pos, text, colorTable[CT_LTRED1], cgs.media.qhFontMedium, -1, 1.0f); } } if (cg.weaponPickupTextTime > cg.time ) { int x_pos = 0; y_pos = 5; gi.Cvar_VariableStringBuffer( "cg_WeaponPickupText", text, sizeof(text) ); w = cgi_R_Font_StrLenPixels(text,cgs.media.qhFontSmall, 0.8f); x_pos = (SCREEN_WIDTH/2)-(w/2); cgi_R_Font_DrawString(x_pos, y_pos, text, colorTable[CT_WHITE], cgs.media.qhFontMedium, -1, 0.8f); } } /* =================== CG_DrawIconBackground Choose the proper background for the icons, scale it depending on if your opening or closing the icon section of the HU =================== */ void CG_DrawIconBackground(void) { int backgroundXPos,backgroundYPos; int backgroundWidth,backgroundHeight; qhandle_t background; const float shutdownTime = 130.0f; // Are we in zoom mode or the HUD is turned off? if (( cg.zoomMode != 0 ) || !( cg_drawHUD.integer )) { return; } if ((cg.snap->ps.viewEntity>0 && cg.snap->ps.viewEntity<ENTITYNUM_WORLD)) { return; } // Get size and location of bakcround specified in the HUD.MENU file if (!cgi_UI_GetMenuInfo("iconbackground",&backgroundXPos,&backgroundYPos,&backgroundWidth,&backgroundHeight)) { return; } // Use inventory background? if (((cg.inventorySelectTime+WEAPON_SELECT_TIME)>cg.time) || (cgs.media.currentBackground == ICON_INVENTORY)) { background = cgs.media.inventoryIconBackground; } // Use weapon background? else if (((cg.weaponSelectTime+WEAPON_SELECT_TIME)>cg.time) || (cgs.media.currentBackground == ICON_WEAPONS)) { background = 0; //background = cgs.media.weaponIconBackground; } // Use force background? else { background = cgs.media.forceIconBackground; } // Time is up, shutdown the icon section of the HUD if ((cg.iconSelectTime+WEAPON_SELECT_TIME)<cg.time) { // Scale background down as it goes away if (background && cg.iconHUDActive) { cg.iconHUDPercent = (cg.time - (cg.iconSelectTime+WEAPON_SELECT_TIME))/ shutdownTime; cg.iconHUDPercent = 1.0f - cg.iconHUDPercent; if (cg.iconHUDPercent<0.0f) { cg.iconHUDActive = qfalse; cg.iconHUDPercent=0.f; } float holdFloat = (float) backgroundHeight; backgroundHeight = (int) (holdFloat*cg.iconHUDPercent); CG_DrawPic( backgroundXPos, backgroundYPos, backgroundWidth, -backgroundHeight, background); // Top half CG_DrawPic( backgroundXPos, backgroundYPos,backgroundWidth, backgroundHeight, background); // Bottom half } return; } // Scale background up as it comes up if (!cg.iconHUDActive) { cg.iconHUDPercent = (cg.time - cg.iconSelectTime)/ shutdownTime; // Calc how far into opening sequence we are if (cg.iconHUDPercent>1.0f) { cg.iconHUDActive = qtrue; cg.iconHUDPercent=1.0f; } else if (cg.iconHUDPercent<0.0f) { cg.iconHUDPercent=0.0f; } } else { cg.iconHUDPercent=1.0f; } // Print the background if (background) { cgi_R_SetColor( colorTable[CT_WHITE] ); float holdFloat = (float) backgroundHeight; backgroundHeight = (int) (holdFloat*cg.iconHUDPercent); CG_DrawPic( backgroundXPos, backgroundYPos, backgroundWidth, -backgroundHeight, background); // Top half CG_DrawPic( backgroundXPos, backgroundYPos,backgroundWidth, backgroundHeight, background); // Bottom half } if ((cg.inventorySelectTime+WEAPON_SELECT_TIME)>cg.time) { cgs.media.currentBackground = ICON_INVENTORY; } else if ((cg.weaponSelectTime+WEAPON_SELECT_TIME)>cg.time) { cgs.media.currentBackground = ICON_WEAPONS; } else { cgs.media.currentBackground = ICON_FORCE; } } /* ===================== CG_DrawActive Perform all drawing needed to completely fill the screen ===================== */ void CG_DrawActive( stereoFrame_t stereoView ) { float separation; vec3_t baseOrg; // optionally draw the info screen instead if ( !cg.snap ) { CG_DrawInformation(); return; } //FIXME: these globals done once at start of frame for various funcs AngleVectors (cg.refdefViewAngles, vfwd, vright, vup); VectorCopy( vfwd, vfwd_n ); VectorCopy( vright, vright_n ); VectorCopy( vup, vup_n ); VectorNormalize( vfwd_n ); VectorNormalize( vright_n ); VectorNormalize( vup_n ); switch ( stereoView ) { case STEREO_CENTER: separation = 0; break; case STEREO_LEFT: separation = -cg_stereoSeparation.value / 2; break; case STEREO_RIGHT: separation = cg_stereoSeparation.value / 2; break; default: separation = 0; CG_Error( "CG_DrawActive: Undefined stereoView" ); } // clear around the rendered view if sized down CG_TileClear(); // offset vieworg appropriately if we're doing stereo separation VectorCopy( cg.refdef.vieworg, baseOrg ); if ( separation != 0 ) { VectorMA( cg.refdef.vieworg, -separation, cg.refdef.viewaxis[1], cg.refdef.vieworg ); } if ( cg.zoomMode == 3 && cg.snap->ps.batteryCharge ) // doing the Light amp goggles thing { cgi_R_LAGoggles(); } if ( (cg.snap->ps.forcePowersActive&(1<<FP_SEE)) ) { cg.refdef.rdflags |= RDF_ForceSightOn; } cg.refdef.rdflags |= RDF_DRAWSKYBOX; // draw 3D view cgi_R_RenderScene( &cg.refdef ); // restore original viewpoint if running stereo if ( separation != 0 ) { VectorCopy( baseOrg, cg.refdef.vieworg ); } // draw status bar and other floating elements CG_Draw2D(); if (cg.zoomMode) { float scale = 20 - (20 * (cg_zoomFov / 80)); int scale_int = (int)scale; //LOGI("zoom scale %d",scale_int); cgi_ANDROID_SetLookScale(scale_int); } else cgi_ANDROID_SetLookScale(1); }
[ "emile.belanger@gmail.com" ]
emile.belanger@gmail.com
ece5c2d8e52d31b23c3f5c302c34ad1341e1ffba
72ca613537ffb197cf7048dadcac360b9a00b5e5
/rfid/RFID_ACCESS.ino
85815a79d14e2f56fa9d0c3ffe4aaa3b563366ff
[]
no_license
Mohamed-Trabelsi/Smart_Cinema-2A2-
346ac74783b5e4ad501ba96984daddaa9f0753da
03f24275d911696b68ac17bc925e55c3f6e54245
refs/heads/master
2023-02-14T01:42:22.476645
2021-01-08T11:29:08
2021-01-08T11:29:08
315,463,670
0
1
null
null
null
null
UTF-8
C++
false
false
3,807
ino
#include <SPI.h> #include <MFRC522.h> #include <Servo.h> #include <LCD.h> #include <LiquidCrystal_I2C.h> //Define variables #define I2C_ADDR 0x27 //Define I2C Address where the PCF8574A is #define BACKLIGHT_PIN 3 #define En_pin 2 #define Rw_pin 1 #define Rs_pin 0 #define D4_pin 4 #define D5_pin 5 #define D6_pin 6 #define D7_pin 7 //Initialise the LCD #define SS_PIN 10 #define RST_PIN 9 #define LED_G 5 //define green LED pin #define LED_R 4 //define red LED #define BUZZER 2 //buzzer pin MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance. Servo myServo; //define servo name LiquidCrystal_I2C lcd(I2C_ADDR, En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin); void setup() { lcd.begin (16,2); lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE); lcd.setBacklight(HIGH); Serial.begin(9600); // Initiate a serial communication SPI.begin(); // Initiate SPI bus mfrc522.PCD_Init(); // Initiate MFRC522 myServo.attach(3); //servo pin myServo.write(0); //servo start position pinMode(LED_G, OUTPUT); pinMode(LED_R, OUTPUT); pinMode(BUZZER, OUTPUT); noTone(BUZZER); } void loop() { char data ; lcd.setCursor(0,0); lcd.print("Put Card.."); if(Serial.available()) { data=Serial.read(); if(data=='3') { lcd.setCursor(0,0); lcd.print(" ADMIN ACTION"); lcd.setCursor(0,1); lcd.print(" Door Open "); myServo.write(90); delay(5000); lcd.setCursor(0,1); lcd.print(" "); lcd.setCursor(0,0); lcd.print(" "); } else if(data=='4') { lcd.setCursor(0,0); lcd.print(" ADMIN ACTION"); lcd.setCursor(0,1); lcd.print(" Door Close "); myServo.write(0); delay(5000); lcd.setCursor(0,1); lcd.print(" "); lcd.setCursor(0,0); lcd.print(" "); } } // Look for new cards if ( ! mfrc522.PICC_IsNewCardPresent()) { return; } // Select one of the cards if ( ! mfrc522.PICC_ReadCardSerial()) { return; } //Show UID on serial monitor lcd.setCursor(0,0); lcd.print(" "); //lcd.print("UID tag :"); String content= ""; byte letter; for (byte i = 0; i < mfrc522.uid.size; i++) { //lcd.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "); //lcd.print(mfrc522.uid.uidByte[i], HEX); content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ")); content.concat(String(mfrc522.uid.uidByte[i], HEX)); } lcd.setCursor(0,0); lcd.print("Message : "); content.toUpperCase(); if ((content.substring(1) == "EA 46 57 1A")) //change here the UID of the card/cards that you want to give access { Serial.print("1"); lcd.setCursor(0,1); lcd.print(" Welcome Yosri"); data=2; delay(500); digitalWrite(LED_G, HIGH); tone(BUZZER, 500); delay(300); digitalWrite(LED_G, LOW); noTone(BUZZER); myServo.write(90); delay(1000); myServo.write(0); digitalWrite(LED_G, LOW); } else { if ((content.substring(1) == "27 17 4C 34")) { Serial.print("2"); lcd.setCursor(0,1); lcd.print(" Welcome Mohamed"); data=1; digitalWrite(LED_R, HIGH); tone(BUZZER, 500); delay(300); digitalWrite(LED_R, LOW); noTone(BUZZER); myServo.write(90); delay(1000); myServo.write(0); delay(300); } else { lcd.setCursor(0,1); lcd.print(" Access Denied!"); digitalWrite(LED_R, HIGH); tone(BUZZER, 300); delay(1000); digitalWrite(LED_R, LOW); noTone(BUZZER); } } delay(100); lcd.setCursor(0,1); lcd.print(" "); lcd.setCursor(0,0); lcd.print(" "); }
[ "wiem.trifi@esprit.tn" ]
wiem.trifi@esprit.tn
87397ec3977948bfddc36171d974cc3ea12ac354
fd5178b83eb0cfc7ce205220c3d80b2d25bec656
/headers/FGTrain.h
869b1a645ecca2d1ab2f96ed4394d72f5123e515
[]
no_license
ficsit/community-resources
e2d916ed3709562318369c81f7e70645ce005326
974089a84046b524ed5e2d19de4c09e8230ac7bf
refs/heads/master
2021-01-04T15:50:29.879718
2020-03-11T17:02:14
2020-03-11T17:02:14
240,621,430
0
0
null
null
null
null
UTF-8
C++
false
false
17,549
h
// Copyright 2016-2019 Coffee Stain Studios. All Rights Reserved. #pragma once #include "GameFramework/Actor.h" #include "FGSaveInterface.h" #include "FGSignificanceInterface.h" #include "RailroadNavigation.h" #include "FGTrain.generated.h" class UFGRailroadTrackConnectionComponent; /** * Error codes for the self driving locomotives. */ UENUM( BlueprintType ) enum class ESelfDrivingLocomotiveError : uint8 { SDLE_NoError UMETA( DisplayName = "No Error" ), SDLE_NoPower UMETA( DisplayName = "No Power" ), SDLE_NoTimeTable UMETA( DisplayName = "No Time Table" ), SDLE_InvalidNextStop UMETA( DisplayName = "Invalid Next Stop" ), SDLE_InvalidLocomotivePlacement UMETA( DisplayName = "Invalid Locomotive Placement" ), SDLE_NoPath UMETA( DisplayName = "No Path" ) }; /** * Signal aspects used for signaling and ATC points. */ UENUM( BlueprintType ) enum class ERailroadSignalAspect : uint8 { RSA_None UMETA( DisplayName = "None" ), RSA_Clear UMETA( DisplayName = "Clear" ), RSA_ClearThenStop UMETA( DisplayName = "Clear Then Stop" ), RSA_Stop UMETA( DisplayName = "Stop" ), RSA_Dock UMETA( DisplayName = "Dock" ) }; /** * Docked state. */ UENUM( BlueprintType ) enum class ETrainDockingState : uint8 { TDS_None UMETA( DisplayName = "None" ), TDS_ReadyToDock UMETA( DisplayName = "Ready To Dock" ), TDS_Docked UMETA( DisplayName = "Docked" ) }; /** Global constants for trains. */ struct TrainConstants { // At which distance can a station start catching the train. [cm] static float CATCH_DISTANCE; // At which offset should a locomotive stop at a signal or station. [cm] static float STOP_OFFSET; // At which distance a locomotive can dock to a station. [cm] static float DOCK_DISTANCE; // At which speed is docking allowed. [cm/s] static float DOCK_SPEED; // This is the speed on a restricted section, e.g. before docking. [cm/s] static float RESTRICTED_SPEED; }; /** * Describes the static properties of a train consist. * I.e. the locomotives, railcars, length and tare weight. */ USTRUCT( BlueprintType ) struct FTrainConsist { GENERATED_BODY() public: /** The vehicles in this consist. */ UPROPERTY( BlueprintReadOnly ) TArray< TSubclassOf< AFGRailroadVehicle > > Vehicles; //@todotrains Orientations. //@todotrains Fill percentages. /** Length of the consist, [cm] */ UPROPERTY( BlueprintReadOnly ) float Length = 0.f; /** Mass of the consist, [kg] */ UPROPERTY( BlueprintReadOnly ) float Mass = 0.f; /** Maximum speed for the slowest vehicle in the consist. [cm/s] */ UPROPERTY( BlueprintReadOnly ) float MaxSpeed = 0.f; /** The sustained braking force the consist can apply in it's operational speed range. [N] [kg cm/s^2] */ float MaxAirBrakingEffort = 0.f; float HighSpeedDynamicBrakingEffort = 0.f; float LimitedSpeedDynamicBrakingEffort = 0.f; float MaxTractiveEffort = 0.f; }; USTRUCT( BlueprintType ) struct FTrainAtcPoint { GENERATED_BODY() public: /** The track connection. */ UPROPERTY() UFGRailroadTrackConnectionComponent* TrackConnection = nullptr; /** How far away is this point in whole segments. */ float LongDistance = 0.f; /** How far away is this point. */ float Distance = 0.f; /** How high up is this. */ float AverageGrade = 0.f; /** The speed the train should have when passing this point. No limit if 0. */ float SpeedLimit = 0.f; /** Signal output at this point. If any. */ ERailroadSignalAspect SignalAspect = ERailroadSignalAspect::RSA_None; }; /** * Data for the automatic train control system. * For the AI to make the correct decisions. * As a safety/guidance system for when the player is driving. */ USTRUCT( BlueprintType ) struct FTrainAtcData { GENERATED_BODY() public: /** Functions to help manage the path. */ bool SetPath( const FRailroadPathFindingResult& result ); void ClearPath(); bool HasPath() const; /** Update the target points ahead from the current connection. */ void UpdateTargetPoints( UFGRailroadTrackConnectionComponent* current ); /** Function to update which path segment we're on based on what our current connection is up ahead. */ bool UpdateCurrentPathSegment( UFGRailroadTrackConnectionComponent* current ); /** If a connection is relevant for controlling the train. */ static bool IsRelevantForATC( const UFGRailroadTrackConnectionComponent* connection ); public: /** The route this train should follow. */ FRailroadPathSharedPtr Path; /** Index of the next point along the route. */ int32 CurrentPathSegment = INDEX_NONE; /** The next connection up ahead. */ TWeakObjectPtr< UFGRailroadTrackConnectionComponent > CurrentConnection = nullptr; float CurrentConnectionDistance = 0.f; /** * Connection points ahead we'll pass on our way forward and the distance to them. * Does not contain a point that is only a pass-through (not relevant). * Index 0 may not be the same as NextConnection. */ TArray< FTrainAtcPoint > TargetPoints; /** Speed and distance indicators. */ float CurrentSpeed = 0.f; float TargetSpeed = 0.f; /** * Next upcoming signal. * A signal in this context is something that announces a change in speed, e.g. a station we should dock to. * This is not necessarily the first signal that appears in target points but rather the most restricting for our speed. */ TWeakObjectPtr< UFGRailroadTrackConnectionComponent > NextSignalConnection = nullptr; float NextSignalSpeed = 0.f; float NextSignalDistance = 0.f; float NextSignalGrade = 0.f; // [%] ERailroadSignalAspect NextSignalAspect = ERailroadSignalAspect::RSA_None; /** If >= 0 we want to be catched at that distance. */ float CatchAtSignalDistance = -1.f; }; /** * States for self driving locomotives. */ UENUM() enum class ESelfDrivingLocomotiveState : uint8 { SDLS_Idle, SDLS_FollowPath, SDLS_Docking, SDLS_DockingCompleted, }; /** * Realtime data for the ai. */ USTRUCT() struct FTrainSelfDrivingData { GENERATED_BODY() public: /** The state the ai is in, determines which functions to run. */ ESelfDrivingLocomotiveState State = ESelfDrivingLocomotiveState::SDLS_Idle; /** Next stop we're aiming for, also look at the current stop in the time table, this is updated from there. */ int32 NextStop = INDEX_NONE; // Enabled // Last error /** When did we find this path. */ float TimeOfLastFindPath = 0.0f; /** If the last speed was up or down or none. */ int8 LastSpeedControl = 0; }; /** * The physics simulation data for the trains. */ USTRUCT() struct FTrainSimulationData { GENERATED_BODY() public: /** Is this train simulating physics and not just moving along the track. */ bool IsSimulatingPhysics = false; /** Cached vehicles in the direction of travel. */ UPROPERTY() TArray< class AFGRailroadVehicle* > SimulatedVehicles; /** Cached movements in the same order as the vehicles. */ UPROPERTY() TArray< class UFGRailroadVehicleMovementComponent* > SimulatedMovements; /** If we're simulating the train front to back (1) or back to front (-1). */ float SimulationDirection = 0.f; /** Cached master locomotive. */ UPROPERTY() class UFGLocomotiveMovementComponent* MasterMovement = nullptr; // Real-time measurements from the simulation. float GravitationalForce = 0.f; float TractiveForce = 0.f; float GradientForce = 0.f; float ResistiveForce = 0.f; float BrakingForce = 0.f; // Velocity of this train [directional] [cm/s] UPROPERTY( SaveGame ) float Velocity = 0.f; }; // Delegates for blueprint DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam( FIsSelfDrivingDelegate, bool, enabled ); DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam( FDockingStateDelegate, ETrainDockingState, state ); /** * The AFGTrain class is concept of multiple rolling stock that is connected in series and move together as one unit. * It's responsible for functionality that does not apply to the individual locomotives or rail car. * This functionality includes but are not limited to: * * Time tables, there can only be one time table for the train. * Simulation, the physics simulation is per train, the cars are just following the first vehicle. * ATC, the automatic train control system */ UCLASS( NotBlueprintable, notplaceable ) class FACTORYGAME_API AFGTrain : public AActor, public IFGSaveInterface, public IFGSignificanceInterface { GENERATED_BODY() public: AFGTrain(); // Begin AActor Interface virtual void GetLifetimeReplicatedProps( TArray< FLifetimeProperty >& OutLifetimeProps ) const override; virtual void Tick( float DeltaSeconds ); virtual void BeginPlay() override; virtual void Destroyed() override; virtual void EndPlay( const EEndPlayReason::Type EndPlayReason ) override; virtual bool IsLevelBoundsRelevant() const override; // End AActor Interface // Begin IFGSaveInterface virtual void PreSaveGame_Implementation( int32 saveVersion, int32 gameVersion ) override; virtual void PostSaveGame_Implementation( int32 saveVersion, int32 gameVersion ) override; virtual void PreLoadGame_Implementation( int32 saveVersion, int32 gameVersion ) override; virtual void PostLoadGame_Implementation( int32 saveVersion, int32 gameVersion ) override; virtual void GatherDependencies_Implementation( TArray< UObject* >& out_dependentObjects ) override; virtual bool NeedTransform_Implementation() override; virtual bool ShouldSave_Implementation() const override; // End IFSaveInterface //@todotrains Put stat counters in these. void TickAtc( float dt ); void TickSelfDriving( float dt ); // Begin IFGSignificanceInterface virtual void GainedSignificance_Implementation() override; virtual void LostSignificance_Implementation() override; virtual void GainedSignificance_Native() override; virtual void LostSignificance_Native() override; virtual float GetSignificanceRange() override; // Significance helpers FORCEINLINE bool IsSignificant() const { return mIsSignificant; } FVector GetSignificanceLocation() const { return mSignificanceLocation; } float GetSignificanceRadius() const { return mSignificanceRadius; } // End IFGSignificanceInterface /** Get the name of this train. */ UFUNCTION( BlueprintPure, Category = "FactoryGame|Railroad|Train" ) FText GetTrainName() const { return mTrainName; } /** Get the name of this train, must be called on server. */ UFUNCTION( BlueprintCallable, Category = "FactoryGame|Railroad|Train" ) void SetTrainName( const FText& name ); /** Get the track for this train. */ UFUNCTION( BlueprintPure, Category = "FactoryGame|Railroad|Train" ) int32 GetTrackGraphID() const { return mTrackGraphID; } /** Is this train driven by a player. */ bool IsPlayerDriven() const; /** @return true if the train has the autopilot enabled. */ UFUNCTION( BlueprintPure, Category = "FactoryGame|Railroad|SelfDriving" ) bool IsSelfDrivingEnabled() const; /** Enable/disable the autopilot on a train, does nothing if enabled/disabled twice, must be called server. */ UFUNCTION( BlueprintCallable, Category = "FactoryGame|Railroad|SelfDriving" ) void SetSelfDrivingEnabled( bool isEnabled ); /** Get the self driving error for this locomotive. */ UFUNCTION( BlueprintPure, Category = "FactoryGame|Railroad|SelfDriving" ) ESelfDrivingLocomotiveError GetSelfDrivingError() const { return mSelfDrivingError; } /** @return The master locomotive in the train; nullptr if MU is disabled. */ class AFGLocomotive* GetMultipleUnitMaster() const; /** @return true if we can set the multiple unit master to be the given locomotive without forcing; false if we cannot. */ bool CanSetMultipleUnitMaster( const class AFGLocomotive* locomotive ) const; /** * Set the new master locomotive in the train. * @param trainID The trains ID, if invalid this function does nothing. * @param locomotive The new master or nullptr to disable MU. * @param if true the new master is forced; if false the new master will only be set if MU is disabled (current master is nullptr). * @return true a new master was set or forced; false if not set. */ bool SetMultipleUnitMaster( class AFGLocomotive* locomotive, bool force ); /** @return true if input is blocked, e.g. we're docked or self driving is enabled. */ UFUNCTION( BlueprintPure, Category = "FactoryGame|Railroad|SelfDriving" ) bool IsInputDisabled() const; /** Get the time table for this train. */ UFUNCTION( BlueprintCallable, BlueprintPure = false, Category = "FactoryGame|Railroad|Train" ) class AFGRailroadTimeTable* GetTimeTable() const; /** Create a new time table for this train. */ UFUNCTION( BlueprintCallable, Category = "FactoryGame|Railroad|Train" ) class AFGRailroadTimeTable* NewTimeTable(); /** If this train has a valid time table. */ UFUNCTION( BlueprintPure, Category = "FactoryGame|Railroad|Train" ) bool HasTimeTable() const; /** Get the first vehicle in the consist. */ UFUNCTION( BlueprintPure, Category = "FactoryGame|Railroad|Train" ) class AFGRailroadVehicle* GetFirstVehicle() const; /** Get the last vehicle in the consist. */ UFUNCTION( BlueprintPure, Category = "FactoryGame|Railroad|Train" ) class AFGRailroadVehicle* GetLastVehicle() const; /** Dock this train to the station we're at, must be called on the server. */ UFUNCTION( BlueprintCallable, Category = "FactoryGame|Railroad|Train" ) void Dock(); /** Get the current status on the docking. */ UFUNCTION( BlueprintPure, Category = "FactoryGame|Railroad|Train" ) ETrainDockingState GetDockingState() const { return mDockingState; } /** If this train has docked at a station. */ UFUNCTION( BlueprintPure, Category = "FactoryGame|Railroad|Train" ) bool IsDocked() const { return mDockingState == ETrainDockingState::TDS_Docked; } /** Callbacks from the station with regards to docking. */ void OnDocked( AFGBuildableRailroadStation* station ); void OnDockingComplete(); /** Called when the train consist changes so constants can be recalculated. */ void OnConsistChanged(); private: void ReportSelfDrivingError( ESelfDrivingLocomotiveError error ); void ClearSelfDrivingError(); /** Try to find a path for this train, in any direction. */ bool FindPath( class AFGBuildableRailroadStation* station ); /** Called to set the current docking state. */ void SetDockingState( ETrainDockingState state ); /** Called to toggle state for next tick. */ void GotoSelfDrivingState( ESelfDrivingLocomotiveState newState ); /** Self driving state handlers. */ void TickSelfDriving_Idle(); void TickSelfDriving_FollowPath(); void TickSelfDriving_Docking(); void TickSelfDriving_DockingCompleted(); /** Help functions for speed related calculations. */ float CalcBrakeDistance( float currentSpeed, float targetSpeed, float deceleration ) const; float CalcTargetSpeed( float targetSpeed, float distance, float deceleration ) const; float CalcTargetAcceleration( float currentSpeed, float targetSpeed, float distance ) const; float CalcTargetDeceleration( float currentSpeed, float targetSpeed, float distance ) const; /** On reps */ UFUNCTION() void OnRep_DockingState(); UFUNCTION() void OnRep_IsSelfDrivingEnabled(); public: /** Called when the self driving is turn on or off. */ UPROPERTY( BlueprintAssignable, Category = "FactoryGame|Railroad|Train" ) FIsSelfDrivingDelegate mOnSelfDrivingChanged; /** Called when the docking state changes. */ UPROPERTY( BlueprintAssignable, Category = "FactoryGame|Railroad|Train" ) FDockingStateDelegate mOnDockingStateChanged; public: /** Static information about the consist, it changes when rolling stock is added/removed or a container is loaded/unloaded. */ UPROPERTY() FTrainConsist mConsistData; /** Runtime data for the automatic train control. See struct for more info. */ UPROPERTY() FTrainAtcData mAtcData; //@todotrains This should be simulated on the client as well without the need for replication. /** Physics simulation for the train */ UPROPERTY( SaveGame ) FTrainSimulationData mSimulationData; /** Runtime data for the self driving AI. */ FTrainSelfDrivingData mSelfDrivingData; public: //@todotrains private /** The name of this train. */ UPROPERTY( SaveGame, Replicated ) FText mTrainName; /** The track this train is on. */ UPROPERTY( Replicated ) int32 mTrackGraphID; /** Train are a doubly linked list, use TTrainIterator to iterate over a train. */ UPROPERTY( SaveGame ) class AFGRailroadVehicle* FirstVehicle; UPROPERTY( SaveGame ) class AFGRailroadVehicle* LastVehicle; /** This is the master locomotives that sends its input (throttle/brake/etc) to all other locomotives in the train. */ UPROPERTY( Replicated ) class AFGLocomotive* mMultipleUnitMaster; /** This trains time table. */ UPROPERTY( SaveGame, Replicated ) class AFGRailroadTimeTable* TimeTable; /** Is this train self driving */ UPROPERTY( SaveGame, ReplicatedUsing = OnRep_IsSelfDrivingEnabled ) bool mIsSelfDrivingEnabled; /** Error reported by the AI. */ UPROPERTY( Replicated ) ESelfDrivingLocomotiveError mSelfDrivingError; /** The status for an ongoing dock, this is not saved, it's updated from the station we're docked to on load. */ UPROPERTY( ReplicatedUsing = OnRep_DockingState ) ETrainDockingState mDockingState; /** How much the brakes decelerate the train. [cm/s^2] */ float MaxAirBrakeDeceleration; private: /** Sound component controlling all the moving/idle sounds for the train */ UPROPERTY() class UFGRailroadVehicleSoundComponent* mSoundComponent; /** Significance data */ bool mIsSignificant; FVector mSignificanceLocation; float mSignificanceRadius; float mSignificanceRange; };
[ "ian@nevir.net" ]
ian@nevir.net
83128928acea7de0941491cd521b5ae5ea6d7506
57370e163d07ceee075decd8bc25c8925a1262a7
/test/repeat_test.cpp
cffbc06a972203e6030e05c1f0488ff96ae1d8b5
[]
no_license
Infinoid/halide-sar-app
e195834ca694758b8a45f7a58b398d2c80ef20f6
65eec21ba534d0e4a36b98e79d0ec3e4cc520e84
refs/heads/master
2023-04-11T12:42:05.128153
2021-01-29T16:16:24
2021-01-29T16:16:24
304,348,129
0
0
null
null
null
null
UTF-8
C++
false
false
969
cpp
#include <stdio.h> #include <Halide.h> #include "repeat1.h" #include "test.h" using namespace std; using Halide::Runtime::Buffer; #define INPUT_NUM 10 #define REPEAT 2.5 #define OUTPUT_NUM (size_t)(INPUT_NUM * REPEAT) static void reference(float *ref) { for (size_t i = 0; i < OUTPUT_NUM; i++) { ref[i] = i % INPUT_NUM; } } int main(int argc, char **argv) { float in[INPUT_NUM]; for (size_t i = 0; i < INPUT_NUM; i++) { in[i] = i; } Buffer<float, 1> in_buf(in, INPUT_NUM); float ref[OUTPUT_NUM] = { 0 }; Buffer<float, 1> out(OUTPUT_NUM); int rv = repeat1(in_buf, out); if (!rv) { print_1d(out); reference(ref); float *obuf = out.begin(); for (size_t i = 0; i < OUTPUT_NUM; i++) { if (abs(ref[i] - obuf[i]) >= 0.1f) { cerr << "Verification failed at index " << i << endl; return -1; } } } return rv; }
[ "cimes@isi.edu" ]
cimes@isi.edu
46231253d3cd6d337c64e9ae83f928498d848b5d
84642b969685d0a35578bc9dc8dbd964a3a177e4
/lf_stack.h
07b5cbbe502a15c89d777a13119db3a41b065004
[]
no_license
linfan255/tiny_stl
cde5519e4d5a2c300263d087bd72aff220a4f100
e6f4b326c1a90a1b5b5132d1aa23d9207ea53b94
refs/heads/master
2021-01-18T11:41:29.360064
2017-09-07T09:06:44
2017-09-07T09:06:44
100,361,184
0
0
null
null
null
null
UTF-8
C++
false
false
1,676
h
// // Created by van on 17-8-24. // #ifndef TINY_STL_LF_STACK_H #define TINY_STL_LF_STACK_H #include "allocator.h" #include "lf_deque.h" namespace lf { template <typename T, typename Container = deque<T> > class stack { public: typedef typename Container::value_type value_type; typedef typename Container::pointer pointer; typedef typename Container::reference reference; typedef typename Container::const_pointer const_pointer; typedef typename Container::const_reference const_reference; typedef typename Container::size_type size_type; typedef typename Container::difference_type difference_type; private: Container cc; public: stack() = default; stack(const stack& other); stack(size_type n, const value_type& val); ~stack() = default; stack& operator=(const stack& rhs); void push(const value_type& val) { cc.push_back(val); } void pop() { cc.pop_back(); } size_type size() const { return cc.size(); } bool empty() const { return cc.empty(); } reference top() { return cc.back(); } const_reference top() const { return cc.back(); } }; template <typename T, typename Container> stack<T,Container>::stack(size_type n, const value_type &val): cc(n, val) {} template <typename T, typename Container> stack<T,Container>::stack(const stack &other): cc(other.cc) {} template <typename T, typename Container> stack<T,Container>& stack<T,Container>::operator=(const stack& rhs) { cc = rhs.cc; } } #endif //TINY_STL_LF_STACK_H
[ "linfan255@163.com" ]
linfan255@163.com
0c73090def61de4dd6efdbcbe2b8adbb3654238d
f6607972b5a6f3eac63d350c2cee89ac87c2d45e
/Round.cpp
fe3ad22bb2589130ebca0e1464b0574e63c1b67f
[]
no_license
redwoudt/CrimeTime
c2adec108409b2eb74b0ffeb96b2a12673a5ecbd
cc6bab6b037d0e39d60872029261af46d02fda42
refs/heads/master
2021-01-10T05:05:23.899128
2015-09-25T09:10:02
2015-09-25T09:10:02
43,125,372
0
0
null
null
null
null
UTF-8
C++
false
false
179
cpp
// // Round.cpp // BytePlay // // Created by Redelinghuys, Ferdinand on 08/07/2015. // Copyright (c) 2015 Redelinghuys, Ferdinand. All rights reserved. // #include "Round.h"
[ "fcredelinghuys@gmail.com" ]
fcredelinghuys@gmail.com
7a0f5e48f44fa247195947ce6b6340cfeafab3c2
116894caf8dcccf6f70211e386b943c43485087f
/vendor/Qt5.14.2/msvc2017/include/QtCore/5.14.2/QtCore/private/qeventdispatcher_winrt_p.h
2672f11123642c060caca22f40851815f827beb4
[ "MIT" ]
permissive
kiseop91/Pomordor
04498276ea73daef37ad50b6f351a2ffd2ed7ab5
5bfbfaa9ceecdf147058ca49dc3c4fa8b442717c
refs/heads/develop
2023-03-25T22:15:59.964938
2021-03-20T07:59:37
2021-03-20T07:59:37
276,431,994
2
2
MIT
2020-12-21T04:31:02
2020-07-01T16:44:31
C++
UTF-8
C++
false
false
3,887
h
/**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtCore module of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Lesser General Public License Usage ** Alternatively, this file may be used under the terms of the GNU Lesser ** General Public License version 3 as published by the Free Software ** Foundation and appearing in the file LICENSE.LGPL3 included in the ** packaging of this file. Please review the following information to ** ensure the GNU Lesser General Public License version 3 requirements ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ** ** GNU General Public License Usage ** Alternatively, this file may be used under the terms of the GNU ** General Public License version 2.0 or (at your option) the GNU General ** Public license version 3 or any later version approved by the KDE Free ** Qt Foundation. The licenses are as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 ** included in the packaging of this file. Please review the following ** information to ensure the GNU General Public License requirements will ** be met: https://www.gnu.org/licenses/gpl-2.0.html and ** https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #ifndef QEVENTDISPATCHER_WINRT_P_H #define QEVENTDISPATCHER_WINRT_P_H // // W A R N I N G // ------------- // // This file is not part of the Qt API. It exists purely as an // implementation detail. This header file may change from version to // version without notice, or even be removed. // // We mean it. // #include <QtCore/private/qglobal_p.h> #include "QtCore/qabstracteventdispatcher.h" #include <qt_windows.h> #include <functional> QT_BEGIN_NAMESPACE quint64 qt_msectime(); class QEventDispatcherWinRTPrivate; class Q_CORE_EXPORT QEventDispatcherWinRT : public QAbstractEventDispatcher { Q_OBJECT Q_DECLARE_PRIVATE(QEventDispatcherWinRT) public: explicit QEventDispatcherWinRT(QObject *parent = 0); ~QEventDispatcherWinRT(); static HRESULT runOnXamlThread(const std::function<HRESULT()> &delegate, bool waitForRun = true); static HRESULT runOnMainThread(const std::function<HRESULT()> &delegate, int timeout = 100); bool processEvents(QEventLoop::ProcessEventsFlags flags); bool hasPendingEvents(); void registerSocketNotifier(QSocketNotifier *notifier); void unregisterSocketNotifier(QSocketNotifier *notifier); void registerTimer(int timerId, int interval, Qt::TimerType timerType, QObject *object); bool unregisterTimer(int timerId); bool unregisterTimers(QObject *object); QList<TimerInfo> registeredTimers(QObject *object) const; int remainingTime(int timerId); bool registerEventNotifier(QWinEventNotifier *notifier); void unregisterEventNotifier(QWinEventNotifier *notifier); void wakeUp(); void interrupt(); void flush(); void startingUp(); void closingDown(); protected: QEventDispatcherWinRT(QEventDispatcherWinRTPrivate &dd, QObject *parent = 0); virtual bool sendPostedEvents(QEventLoop::ProcessEventsFlags flags); bool event(QEvent *); int activateTimers(); }; QT_END_NAMESPACE #endif // QEVENTDISPATCHER_WINRT_P_H
[ "kiseop91@naver.com" ]
kiseop91@naver.com
8b4ce849f5c89f421530ae790381948e582e5df1
5740ea2c2d9d5fb5626ff5ad651f3789048ae86b
/Extensions/LightningShaders/LightningShaderIRTranslationPass.hpp
f9f9e222ecebd06b50846cf2078f0694be1c2f3e
[ "MIT" ]
permissive
donovan680/Plasma
4945b92b7c6e642a557f12e05c7d53819186de55
51d40ef0669b7a3015f95e3c84c6d639d5469b62
refs/heads/master
2022-04-15T02:42:26.469268
2020-02-26T22:32:12
2020-02-26T22:32:12
null
0
0
null
null
null
null
UTF-8
C++
false
false
2,213
hpp
/////////////////////////////////////////////////////////////////////////////// /// /// Authors: Joshua Davis /// Copyright 2018, DigiPen Institute of Technology /// /////////////////////////////////////////////////////////////////////////////// #pragma once struct spv_diagnostic_t; typedef spv_diagnostic_t* spv_diagnostic; struct spv_optimizer_options_t; typedef spv_optimizer_options_t* spv_optimizer_options; namespace Plasma { //-------------------------------------------------------------------ShaderTranslationPassResult class ShaderTranslationPassResult { public: String ToString() { return mByteStream.ToString(); } ShaderByteStream mByteStream; ShaderStageInterfaceReflection mReflectionData; LightningRefLink(ShaderTranslationPassResult); }; //-------------------------------------------------------------------LightningShaderIRTranslationPass class LightningShaderIRTranslationPass : public Lightning::EventHandler { public: virtual ~LightningShaderIRTranslationPass() {}; /// Runs a translation pass that transforms the input data into the output data. /// This pass could be something like a tool (e.g. the optimizer) or a backend. /// Reflection data will be filled out that describes what transformations took place on the /// input data to produce the output data. Most tools will not change the reflection mapping /// (other than removing bindings) but backends may have to do significant transformations. virtual bool RunTranslationPass(ShaderTranslationPassResult& inputData, ShaderTranslationPassResult& outputData) = 0; virtual String GetErrorLog() { return String(); } LightningRefLink(LightningShaderIRTranslationPass); protected: /// Internal helper that converts a spirv diagnostic object into a string. String SpirvDiagnosticToString(spv_diagnostic& diagnostic); }; //-------------------------------------------------------------------LightningShaderIRBackend class LightningShaderIRBackend : public LightningShaderIRTranslationPass { public: /// Return an extension for the given backend. Mostly used for unit /// testing so that a backend can be written to a file. virtual String GetExtension() = 0; }; }//namespace Plasma
[ "dragonCASTjosh@gmail.com" ]
dragonCASTjosh@gmail.com
2ae06808d0e23b7c9ddd91e550f0190293e9d93f
ba86279dd568979d29b7f3b92840dfb6bc1f3ba0
/TankWar1_9/TankMoveMsg.cpp
5d2a8131556119c07dcd902410c7819f3f4ab539
[]
no_license
ChenYilei2016/MyTankWar
5e690ea6e9defc3bc579b18c1b8c69dd816e51df
6ce8495bf8587fa74f4ab9d259e3e11297c14f0b
refs/heads/master
2020-03-27T05:23:01.420150
2019-01-01T05:14:34
2019-01-01T05:14:34
146,014,430
2
1
null
null
null
null
UTF-8
C++
false
false
1,360
cpp
#include "TankMoveMsg.h" #include <QList> TankMoveMsg::TankMoveMsg(int id, Direction dir, int x, int y) { this->id = id; this->x = x; this->y = y; this->dir = dir; } TankMoveMsg::TankMoveMsg(TankClient *tc, const QJsonObject &obj) { this->tc = tc; this->obj = obj; } void TankMoveMsg::sendMsg(NetClient *client, QString IP, int Port) { QJsonDocument doc; QJsonObject obj; obj.insert("msgtype",this->msgType); obj.insert("id",this->id); obj.insert("x",this->x); obj.insert("y",this->y); obj.insert("dir",this->dir); doc.setObject(obj); QByteArray buf = doc.toJson(QJsonDocument::Compact); client->sendMsg(buf,IP,Port); } void TankMoveMsg::parse() { int id = obj.value("id").toInt(); if( id == tc->mytank->getOneTankID()) { return ; } else { bool exist =false; for(int i= 0 ; i<tc->tanks.size();i++) { Tank * t = tc->tanks.at(i); if(id == t->getOneTankID() ) { Direction dir = (Direction)obj.value("dir").toInt(); int x = obj.value("x").toInt(); int y = obj.value("y").toInt(); t->setX(x); t->setY(y); t->setDir(dir); exist = true; break; } } } }
[ "705029004@qq.com" ]
705029004@qq.com
fbd831beee42d7770200615c8c326111f20bb76d
ec8d9b2487efa2b1d8f3a9ca48e85b931fae9c6f
/Arduino/lib/Collections/ArrayList.h
a38bf5ba8b727e6135edd583b1cf697d2d0903bc
[]
no_license
slavasemeniuk/Relays
d9e16b4b0d2ff1aa2a35a18cae37cec7aafd8682
08b60eac2d3205d9b29a34381fd76374cec1d379
refs/heads/master
2021-01-22T20:49:25.452300
2017-10-05T18:57:02
2017-10-05T18:57:02
85,363,979
0
0
null
null
null
null
UTF-8
C++
false
false
3,872
h
#ifndef ArrayList_h #define ArrayList_h #include "List.h" #include "MemoryFree.h"//TODO:@Deprecated template<typename T> class ArrayList : public List<T> { public: ArrayList(); ArrayList(uint16_t initialCapacity); ~ArrayList(); void add(T item); void add(uint16_t index, T item); T set(uint16_t index, T item); T get(uint16_t index); T remove(uint16_t index); void clear(); uint16_t size(); bool isEmpty(); void trimToSize(); //@Deprecated void print(); private: bool rangeCheck(uint16_t index); void ensureCapacity(uint16_t index); void grow(uint16_t minCapacity); uint16_t capacity; uint16_t valuesSize; T* values; static const uint8_t DEFAULT_CAPACITY = 1; }; template< typename T > ArrayList<T>::ArrayList() { values = new T[DEFAULT_CAPACITY]; capacity = DEFAULT_CAPACITY; valuesSize = 0; } template< typename T > ArrayList<T>::ArrayList(uint16_t initialCapacity) { values = new T[initialCapacity]; capacity = initialCapacity; valuesSize = 0; } template< typename T > ArrayList<T>::~ArrayList() { delete[] values; } template< typename T > void ArrayList<T>::add(T item) { ensureCapacity(valuesSize + 1); values[valuesSize++] = item; } template< typename T > void ArrayList<T>::add(uint16_t index, T item) { if (rangeCheck(index == valuesSize ? index - 1 : index)) { ensureCapacity(valuesSize + 1); memmove(&values[index + 1], &values[index], (valuesSize - index) * sizeof(T)); values[index] = item; valuesSize++; } } template< typename T > T ArrayList<T>::set(uint16_t index, T item) { if (rangeCheck(index)) { T oldValue = values[index]; values[index] = item; return oldValue; } else return (T) NULL; } template< typename T > T ArrayList<T>::get(uint16_t index) { if (rangeCheck(index)) { return values[index]; } else return (T) NULL; } template< typename T > T ArrayList<T>::remove(uint16_t index) {//TODO: check if (rangeCheck(index)) { T removed = values[index]; if (index < valuesSize - 1) { memmove(&values[index], &values[index + 1], (valuesSize - index - 1) * sizeof(T));//TODO: check } valuesSize--; return removed; } else return (T) NULL; } template< typename T > void ArrayList<T>::clear() { valuesSize = 0; } template< typename T > uint16_t ArrayList<T>::size() { return valuesSize; } template< typename T > bool ArrayList<T>::isEmpty() { return valuesSize == 0; } template< typename T > void ArrayList<T>::trimToSize() { if (capacity > valuesSize) { values = (T*) realloc(values, valuesSize * sizeof(T)); capacity = valuesSize; } } template< typename T > bool ArrayList<T>::rangeCheck(uint16_t index) { if (index < size()) { return true; } else { Serial.print(F("IndexOutOfBoundsException: Index: ")); Serial.print(index); Serial.print(F(", Size: ")); Serial.println(valuesSize); return false; } } template< typename T > void ArrayList<T>::ensureCapacity(uint16_t minCapacity) { if (capacity < minCapacity) grow(minCapacity); } template< typename T > void ArrayList<T>::grow(uint16_t minCapacity) { if (capacity < minCapacity) { capacity += (capacity >> 1); if (capacity < minCapacity) capacity = minCapacity; values = (T*) realloc(values, capacity * sizeof(T)); } } //@Deprecated template< typename T > void ArrayList<T>::print() { Serial.println(F("-------------------")); // Serial.print(F("RAM: ")); Serial.println(freeMemory()); Serial.print(F("Capacity: ")); Serial.print(capacity); Serial.print(F(" | size = ")); Serial.println(valuesSize); for (uint16_t i = 0; i < valuesSize; i++) { Serial.print(F("@")); Serial.print((uint16_t) &values[i]); //Serial.print(F(" = ")); Serial.print(values[i]); Serial.print(F(", ")); } Serial.println(F("\n-------------------")); } #endif
[ "slavasemeniuk@gmail.com" ]
slavasemeniuk@gmail.com
481b23ce530639bf61e8b383ef6e479aa291e08f
3714fc7d4748b915fa32cda77218d7d4328f0d43
/minimoscuadrados.cpp
a3cccb8a9f7e99fd00a695d5c14b625576e540dd
[]
no_license
cnpoe/M-todos-num-ricos
987a30a272c059f67af30da09c0ca2e190b5962a
9b5551c085e9af449f11b1dcade0c57fe4fad78f
refs/heads/master
2021-01-11T16:55:35.786563
2017-01-28T05:57:26
2017-01-28T05:57:26
79,696,507
0
0
null
null
null
null
UTF-8
C++
false
false
589
cpp
#include<iostream> using namespace std; double a0, a1; void minimosCuadrados(int n, double *x, double *y){ double Sx = 0.0, Sx2 = 0.0, Sy = 0.0, Sxy = 0.0; for(int i = 0; i < n; i++){ Sx += x[i]; Sx2 = Sx2 + x[i] * x[i]; Sy += y[i]; Sxy = Sxy + x[i] * y[i]; } a1 = (n * Sxy - Sx * Sy) / (n * Sx2 - Sx * Sx); a0 = (Sy - a1 * Sx) / n; cout << "a0 = " << a0 << " , a1 = " << a1 << endl; } int main(void){ double x[10] = {12, 6.4, 95, 159, 120, 40, 73, 98, 112, 200}; double y[10] = {3, 2, 15, 40, 32, 0.8, 12, 15, 30, 48}; minimosCuadrados(10, x, y); return 0; }
[ "cnpoek@gmail.com" ]
cnpoek@gmail.com
a461ad78fa8f1a1f90c52b49bc8dcfda9cc6c46a
0de652685d9926570b59a74b5bf403a0795644b5
/h/Activeman.h
a8a582658b0e886641166ca43900c179ca80dda1
[]
no_license
zayac/runningram
b49215378f3ecfee3d24cb64ab2bb56f0c6bfc24
01ffeca795602b97583a4a6e089b8830e702e5f0
refs/heads/master
2020-03-30T21:59:14.160199
2011-09-30T19:15:41
2011-09-30T19:15:41
32,114,091
0
0
null
2020-02-28T21:18:31
2015-03-13T01:16:28
C++
UTF-8
C++
false
false
773
h
/* * File: Activeman.h * Author: necto * * Created on January 12, 2010, 12:32 AM */ #ifndef _ACTIVEMAN_H #define _ACTIVEMAN_H #include <list> #include "Transmitted.h" using std::list; class Canvas; class Active; class Battlefield; class Activeman :public list <Active*>, public Transmitted { void kill(iterator start, iterator finish); public: Activeman(); // Activeman(const Activeman& orig); // virtual ~Activeman(); void activate (float dt); void draw (Canvas*); void collisBrd (const Battlefield* bf); void processCollisions(); bool deleteDeadalives();//returns true when one or more of Deadalives have found and deleted int exp (char* buffer, int size) const; int imp (char* buffer, int size); bool ok() const; }; #endif /* _ACTIVEMAN_H */
[ "necto.ne@0b8b07ca-f9fe-11de-aabd-2bfef65f77b5" ]
necto.ne@0b8b07ca-f9fe-11de-aabd-2bfef65f77b5
a8666ee9164e30040e9b8df8ce4ff91d2223961d
b3f3a5ac8c57d6fe96fc74df732143b36fa2479b
/chapter12/12-23.cpp
df4f6e9d178e3773a6ad3b6b4a3296996fa79ae0
[]
no_license
wangzhengyang/MyC-PrimerAnswer
19ef7064b7e48f63e86e896e914dd8c92300d49e
c86ceea1667d3bb9078c22a55ec806c098773f46
refs/heads/master
2022-12-09T14:58:47.218957
2020-09-01T09:49:15
2020-09-01T09:49:15
261,182,915
0
0
null
null
null
null
UTF-8
C++
false
false
810
cpp
#include <iostream> #include <string> #include <cstdlib> #include <cstring> using namespace std; int main() { /* char *pc1 = "hello"; char *pc2 = "world"; size_t len = strlen(pc1) + strlen(pc2) + 1; char src[len] = {}; char *p = strcat(src, pc1); printf("%s\r\n", src); strcat(p, pc2); printf("%s\r\n", src); cout << "len:" << len << endl; char *pc = new char[len](); for(size_t i = 0; i < len; i++){ pc[i] = src[i]; cout << pc[i]; } cout << endl; delete[] p; */ string s1 = "hello"; string s2 = "world"; string s = s1 + s2; size_t len = s.size(); char *p = new char[len]; for(size_t i = 0; i < len; ++i){ p[i] = s[i]; cout << p[i]; } cout << endl; delete[] p; return 0; }
[ "1484413135@qq.com" ]
1484413135@qq.com
f9e4520fe27d561f95128f61759c894e290a8d4c
c03615f53093643e3c1e323b83cbe77970966575
/PRT/3rdParty/cgal/cgal/include/CGAL/RS/rs3_k_refiner_1.h
c9a47446539b19570f2d973ba676372382f636b3
[]
no_license
fangguanya/PRT
0925b28671e756a6e9431fd57149cf2eebc94818
77c1b8e5f3a7a149825ad0cc3ef6002816222622
refs/heads/master
2021-06-08T20:54:22.954395
2016-11-24T07:38:11
2016-11-24T07:38:11
null
0
0
null
null
null
null
UTF-8
C++
false
false
6,123
h
// Copyright (c) 2006-2013 INRIA Nancy-Grand Est (France). All rights reserved. // // This file is part of CGAL (www.cgal.org); 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 3 of the License, // or (at your option) any later version. // See the file LICENSE.LGPL distributed with CGAL. // // Licensees holding a valid commercial license may use this file in // accordance with the commercial license agreement provided with the software. // // This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE // WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. // // $URL$ // $Id$ // // Author: Luis Peñaranda <luis.penaranda@gmx.com> #ifndef CGAL_RS_RS3_K_REFINER_1_H #define CGAL_RS_RS3_K_REFINER_1_H #include <CGAL/Polynomial_traits_d.h> #include "rs2_calls.h" #include <rs3_fncts.h> #include "Gmpfr_make_unique.h" namespace CGAL{ namespace RS3{ template <class Polynomial_,class Bound_> struct RS3_k_refiner_1{ void operator()(const Polynomial_&,Bound_&,Bound_&,int); }; // class RS3_k_refiner_1 template <class Polynomial_,class Bound_> void RS3_k_refiner_1<Polynomial_,Bound_>:: operator()(const Polynomial_&,Bound_&,Bound_&,int){ CGAL_error_msg("RS3 k-refiner not implemented for these types"); return; } template<> void RS3_k_refiner_1<Polynomial<Gmpz>,Gmpfr>:: operator() (const Polynomial<Gmpz> &pol,Gmpfr &left,Gmpfr &right,int prec){ typedef Polynomial<Gmpz> Polynomial; typedef Polynomial_traits_d<Polynomial> Ptraits; typedef Ptraits::Degree Degree; CGAL_precondition(left<=right); // TODO: add precondition to check whether the interval is a point // or the evaluations on its endpoints have different signs //std::cout<<"refining ["<<left<<","<<right<<"]"<<std::endl; int deg=Degree()(pol); mpz_t* coefficients=(mpz_t*)malloc((deg+1)*sizeof(mpz_t)); __mpfi_struct interval; CGAL_RS_GMPFR_MAKE_UNIQUE(left,temp_left); CGAL_RS_GMPFR_MAKE_UNIQUE(right,temp_right); interval.left=*(left.fr()); interval.right=*(right.fr()); for(int i=0;i<=deg;++i) coefficients[i][0]=*(pol[i].mpz()); RS2::RS2_calls::init_solver(); rs3_refine_u_root(&interval, coefficients, deg, prec+CGAL::max(left.get_precision(), right.get_precision()), 1, 1); free(coefficients); mpfr_clear(left.fr()); mpfr_clear(right.fr()); mpfr_custom_init_set(left.fr(), mpfr_custom_get_kind(&interval.left), mpfr_custom_get_exp(&interval.left), mpfr_get_prec(&interval.left), mpfr_custom_get_mantissa(&interval.left)); mpfr_custom_init_set(right.fr(), mpfr_custom_get_kind(&interval.right), mpfr_custom_get_exp(&interval.right), mpfr_get_prec(&interval.right), mpfr_custom_get_mantissa(&interval.right)); CGAL_postcondition(left<=right); //std::cout<<"ref root is ["<<left<<","<<right<<"]"<<std::endl; return; } template<> void RS3_k_refiner_1<Polynomial<Gmpq>,Gmpfr>:: operator() (const Polynomial<Gmpq> &qpol,Gmpfr &left,Gmpfr &right,int prec){ typedef Polynomial<Gmpz> ZPolynomial; typedef Polynomial_traits_d<ZPolynomial> ZPtraits; typedef ZPtraits::Degree ZDegree; CGAL_precondition(left<=right); // TODO: add precondition to check whether the interval is a point // or the evaluations on its endpoints have different signs //std::cout<<"refining ["<<left<<","<<right<<"]"<<std::endl; Polynomial<Gmpz> zpol=CGAL::RS_AK1::Polynomial_converter_1< CGAL::Polynomial<Gmpq>, CGAL::Polynomial<Gmpz> >()(qpol); int deg=ZDegree()(zpol); mpz_t* coefficients=(mpz_t*)malloc((deg+1)*sizeof(mpz_t)); __mpfi_struct interval; CGAL_RS_GMPFR_MAKE_UNIQUE(left,temp_left); CGAL_RS_GMPFR_MAKE_UNIQUE(right,temp_right); interval.left=*(left.fr()); interval.right=*(right.fr()); for(int i=0;i<=deg;++i) coefficients[i][0]=*(zpol[i].mpz()); RS2::RS2_calls::init_solver(); rs3_refine_u_root(&interval, coefficients, deg, prec+CGAL::max(left.get_precision(), right.get_precision()), 1, 1); free(coefficients); mpfr_clear(left.fr()); mpfr_clear(right.fr()); mpfr_custom_init_set(left.fr(), mpfr_custom_get_kind(&interval.left), mpfr_custom_get_exp(&interval.left), mpfr_get_prec(&interval.left), mpfr_custom_get_mantissa(&interval.left)); mpfr_custom_init_set(right.fr(), mpfr_custom_get_kind(&interval.right), mpfr_custom_get_exp(&interval.right), mpfr_get_prec(&interval.right), mpfr_custom_get_mantissa(&interval.right)); CGAL_postcondition(left<=right); //std::cout<<"ref root is ["<<left<<","<<right<<"]"<<std::endl; return; } } // namespace RS3 } // namespace CGAL #endif // CGAL_RS_RS3_K_REFINER_1_H
[ "succeed.2009@163.com" ]
succeed.2009@163.com
689a29cabd9c80aeb6a6d095e1029760b0d7323a
504665f830424caf004e4782a50cb8cab2356f9e
/src/data/example_parser.h
88d1857dc9e40d0e6fb3a3e3575aa9774b28195c
[ "Apache-2.0" ]
permissive
ChenglongChen/parameter_server
4d5a402a4d0e34e8269641fb754786ca8dfc4553
ba358357ba33a94a2af5798e49428a8d15bb12a8
refs/heads/master
2020-04-29T18:08:35.827133
2014-10-19T22:41:23
2014-10-19T22:41:23
null
0
0
null
null
null
null
UTF-8
C++
false
false
693
h
#pragma once #include "util/common.h" #include "proto/example.pb.h" #include "proto/config.pb.h" namespace PS { static const int kSlotIDmax = 4096; class ExampleParser { public: typedef DataConfig::TextFormat TextFormat; void init(TextFormat format, bool ignore_fea_slot = false); void clear(); bool toProto(char*, Example*); ExampleInfo info(); int maxSlotID() { return ignore_fea_slot_ ? 2 : kSlotIDmax; } private: bool parseLibsvm(char*, Example*); bool parseAdfea(char*, Example*); ExampleInfo info_; SlotInfo slot_info_[kSlotIDmax]; bool ignore_fea_slot_; size_t num_ex_ = 0; TextFormat format_; std::function<bool(char*, Example*)> parser_; }; }
[ "muli@cs.cmu.edu" ]
muli@cs.cmu.edu
379310db1822d85f36ab4942501aaf1783bccdfd
054ba082469edd7e25c0c52abaebe5ce1f1eec06
/hhcards/Classes/PokerStateInitial.h
1ba9010fa84ba192ca936359d9bb44d33a155070
[ "MIT" ]
permissive
duhone/HeadstoneHarryCards
3d5ddf8f865a81c3b85eaad187cfc60226bebc14
1a08d671835c659e543faca238a5661b4b59262f
refs/heads/master
2020-12-29T12:56:28.444477
2020-02-06T13:43:18
2020-02-06T13:43:18
238,614,611
1
0
null
null
null
null
UTF-8
C++
false
false
1,295
h
/* * PokerStateInitial.h * hhcards * * Created by Eric Duhon on 3/7/10. * Copyright 2010 Apple Inc. All rights reserved. * */ #pragma once #include "PokerHand.h" #include "Graphics.h" #include "PokerState.h" namespace CR { namespace HHCards { template<typename DeckType> class PokerStateInitial : public PokerState { public: PokerStateInitial(CR::Cards::PokerHand<DeckType> &_hand,std::vector<CR::Graphics::Sprite*> &_sprites); virtual void Deal() {m_goNext = true;} virtual int Process(); private: virtual bool Begin(); CR::Cards::PokerHand<DeckType> &m_hand; std::vector<CR::Graphics::Sprite*> &m_sprites; bool m_goNext; }; template<typename DeckType> PokerStateInitial<DeckType>::PokerStateInitial(CR::Cards::PokerHand<DeckType> &_hand,std::vector<CR::Graphics::Sprite*> &_sprites) : m_hand(_hand), m_sprites(_sprites) { } template<typename DeckType> bool PokerStateInitial<DeckType>::Begin() { m_hand.Reset(); for(int i = 0;i < m_sprites.size(); ++i) { m_sprites[i]->Visible(false); } m_goNext = false; return true; } template<typename DeckType> int PokerStateInitial<DeckType>::Process() { if(m_goNext) return NEXT; else return UNCHANGED; } } }
[ "duhone@outlook.com" ]
duhone@outlook.com
6253092fbc5f00e5d06dacbc94b3a85d6578df46
756fce0e51a4888fd6190b925262d88d49e17c84
/BSGenLib/Include/Common/BSUtil.h
0fe09d242ff7634b20d9037d8020df80c99a9231
[ "Apache-2.0" ]
permissive
kivzcu/BSGenLib
15d32495e9985ed91896bfcd322eec9fce53b2f4
1aeb245eb873f8f23d4a03cd31d5534fa3f4500d
refs/heads/master
2021-07-13T12:11:13.689415
2020-06-12T09:15:03
2020-06-12T09:15:03
124,209,186
0
1
null
null
null
null
UTF-8
C++
false
false
195
h
#pragma once class CBSUtil { public: //formats time given in milliseconds static CString FormatTime(double time); //formats time given is bytes static CString FormatSize(DWORD dwBytes); };
[ "besoft@kiv.zcu.cz" ]
besoft@kiv.zcu.cz
cd624ac9c9ed132f40e8be8ed38914e3d3ec2728
401d9120db1750d65312479e5e99ff7ab1a867b3
/poj-3150-循环矩阵快速幂.cpp
5ffeb89b5ef410b9b8804052af1b60140c3de779
[ "MIT" ]
permissive
ZxMYS/Xiaos-ACM-Solution-Set
ff14348149bae56a7689a87ef5796533fff70aed
cfd7fc34deac27f4e0267a4eb3cc396c0a8dbe8f
refs/heads/master
2021-01-01T15:54:39.868855
2013-02-01T11:32:41
2013-02-01T11:32:41
null
0
0
null
null
null
null
UTF-8
C++
false
false
1,390
cpp
#include<stdio.h> #include<stdlib.h> #include<time.h> #include<string.h> #include<math.h> #include<assert.h> #include<iostream> #include<algorithm> #include<numeric> #include<vector> #include<map> #include<queue> #include<list> #include<sstream> using namespace std; #define LOOP(x,y,z) for((x)=(y);(x)<=(z);(x)++) #define LOOPB(x,y,z) for((x)=(y);(x)<(z);(x)++) #define RLOOP(x,y,z) for((x)=(y);(x)>=(z);(x)--) #define RLOOPB(x,y,z) for((x)=(y);(x)>(z);(x)--) #define MAX(x,y) ((x)>(y)?(x):(y)) #define MIN(x,y) ((x)<(y)?(x):(y)) #define PI 3.1415926535898 template<class T> string i2s(T x){ostringstream o; o<<x;return o.str();} int i,j,k,a,d,m,n,s,t,l,tt; unsigned long long int matrix[500],matrix3[500],matrix4[500]; inline void mul(unsigned long long int a[],unsigned long long int b[]){ int i,j; LOOPB(i,0,n){ matrix4[i]=0; LOOPB(j,0,n) matrix4[i]+=a[j]*b[i>=j?i-j:n+i-j]; } LOOPB(i,0,n) b[i]=matrix4[i]%m; } int main() { #ifndef ONLINE_JUDGE freopen("in.txt","r",stdin); freopen("out","w",stdout); #endif scanf("%d%d%d%d",&n,&m,&d,&k); LOOPB(i,0,n)scanf("%llu",&matrix[i]); LOOP(i,0,d)matrix3[i]=1; LOOP(i,d+1,n-d)matrix3[i]=0; LOOPB(i,n-d,n)matrix3[i]=1; while(k){ if(k&1) mul(matrix3,matrix); mul(matrix3,matrix3); k>>=1; } printf("%llu",matrix[0]); LOOPB(i,1,n)printf(" %llu",matrix[i]); printf("\n"); }
[ "manyoushen@gmail.com" ]
manyoushen@gmail.com
eaf622101605305179c545e5166a23cb56b43f41
75ee9d3ea8560eacada7049107b88d126ed85c23
/devel/include/gazebo_msgs/SetJointTrajectoryRequest.h
51ded98c5ea8a2adf868b7a577d25479c2fe42eb
[]
no_license
LordBismaya/FrenchVanilla
f1cf9047127884733bfdd53d5a4a2e5723f61a93
fe6f0cd608373814558281878b90da41ae8ed32b
refs/heads/master
2021-05-04T10:09:09.957348
2016-04-06T08:49:09
2016-04-06T08:49:09
55,325,248
0
2
null
2018-11-28T16:21:21
2016-04-03T02:05:36
C++
UTF-8
C++
false
false
9,540
h
// Generated by gencpp from file gazebo_msgs/SetJointTrajectoryRequest.msg // DO NOT EDIT! #ifndef GAZEBO_MSGS_MESSAGE_SETJOINTTRAJECTORYREQUEST_H #define GAZEBO_MSGS_MESSAGE_SETJOINTTRAJECTORYREQUEST_H #include <string> #include <vector> #include <map> #include <ros/types.h> #include <ros/serialization.h> #include <ros/builtin_message_traits.h> #include <ros/message_operations.h> #include <trajectory_msgs/JointTrajectory.h> #include <geometry_msgs/Pose.h> namespace gazebo_msgs { template <class ContainerAllocator> struct SetJointTrajectoryRequest_ { typedef SetJointTrajectoryRequest_<ContainerAllocator> Type; SetJointTrajectoryRequest_() : model_name() , joint_trajectory() , model_pose() , set_model_pose(false) , disable_physics_updates(false) { } SetJointTrajectoryRequest_(const ContainerAllocator& _alloc) : model_name(_alloc) , joint_trajectory(_alloc) , model_pose(_alloc) , set_model_pose(false) , disable_physics_updates(false) { } typedef std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > _model_name_type; _model_name_type model_name; typedef ::trajectory_msgs::JointTrajectory_<ContainerAllocator> _joint_trajectory_type; _joint_trajectory_type joint_trajectory; typedef ::geometry_msgs::Pose_<ContainerAllocator> _model_pose_type; _model_pose_type model_pose; typedef uint8_t _set_model_pose_type; _set_model_pose_type set_model_pose; typedef uint8_t _disable_physics_updates_type; _disable_physics_updates_type disable_physics_updates; typedef boost::shared_ptr< ::gazebo_msgs::SetJointTrajectoryRequest_<ContainerAllocator> > Ptr; typedef boost::shared_ptr< ::gazebo_msgs::SetJointTrajectoryRequest_<ContainerAllocator> const> ConstPtr; }; // struct SetJointTrajectoryRequest_ typedef ::gazebo_msgs::SetJointTrajectoryRequest_<std::allocator<void> > SetJointTrajectoryRequest; typedef boost::shared_ptr< ::gazebo_msgs::SetJointTrajectoryRequest > SetJointTrajectoryRequestPtr; typedef boost::shared_ptr< ::gazebo_msgs::SetJointTrajectoryRequest const> SetJointTrajectoryRequestConstPtr; // constants requiring out of line definition template<typename ContainerAllocator> std::ostream& operator<<(std::ostream& s, const ::gazebo_msgs::SetJointTrajectoryRequest_<ContainerAllocator> & v) { ros::message_operations::Printer< ::gazebo_msgs::SetJointTrajectoryRequest_<ContainerAllocator> >::stream(s, "", v); return s; } } // namespace gazebo_msgs namespace ros { namespace message_traits { // BOOLTRAITS {'IsFixedSize': False, 'IsMessage': True, 'HasHeader': False} // {'sensor_msgs': ['/opt/ros/indigo/share/sensor_msgs/cmake/../msg'], 'std_msgs': ['/opt/ros/indigo/share/std_msgs/cmake/../msg'], 'trajectory_msgs': ['/opt/ros/indigo/share/trajectory_msgs/cmake/../msg'], 'gazebo_msgs': ['/home/bismaya/catkin_ws/src/gazebo_ros_pkgs/gazebo_msgs/msg'], 'geometry_msgs': ['/opt/ros/indigo/share/geometry_msgs/cmake/../msg']} // !!!!!!!!!!! ['__class__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_parsed_fields', 'constants', 'fields', 'full_name', 'has_header', 'header_present', 'names', 'package', 'parsed_fields', 'short_name', 'text', 'types'] template <class ContainerAllocator> struct IsFixedSize< ::gazebo_msgs::SetJointTrajectoryRequest_<ContainerAllocator> > : FalseType { }; template <class ContainerAllocator> struct IsFixedSize< ::gazebo_msgs::SetJointTrajectoryRequest_<ContainerAllocator> const> : FalseType { }; template <class ContainerAllocator> struct IsMessage< ::gazebo_msgs::SetJointTrajectoryRequest_<ContainerAllocator> > : TrueType { }; template <class ContainerAllocator> struct IsMessage< ::gazebo_msgs::SetJointTrajectoryRequest_<ContainerAllocator> const> : TrueType { }; template <class ContainerAllocator> struct HasHeader< ::gazebo_msgs::SetJointTrajectoryRequest_<ContainerAllocator> > : FalseType { }; template <class ContainerAllocator> struct HasHeader< ::gazebo_msgs::SetJointTrajectoryRequest_<ContainerAllocator> const> : FalseType { }; template<class ContainerAllocator> struct MD5Sum< ::gazebo_msgs::SetJointTrajectoryRequest_<ContainerAllocator> > { static const char* value() { return "649dd2eba5ffd358069238825f9f85ab"; } static const char* value(const ::gazebo_msgs::SetJointTrajectoryRequest_<ContainerAllocator>&) { return value(); } static const uint64_t static_value1 = 0x649dd2eba5ffd358ULL; static const uint64_t static_value2 = 0x069238825f9f85abULL; }; template<class ContainerAllocator> struct DataType< ::gazebo_msgs::SetJointTrajectoryRequest_<ContainerAllocator> > { static const char* value() { return "gazebo_msgs/SetJointTrajectoryRequest"; } static const char* value(const ::gazebo_msgs::SetJointTrajectoryRequest_<ContainerAllocator>&) { return value(); } }; template<class ContainerAllocator> struct Definition< ::gazebo_msgs::SetJointTrajectoryRequest_<ContainerAllocator> > { static const char* value() { return "string model_name\n\ trajectory_msgs/JointTrajectory joint_trajectory\n\ geometry_msgs/Pose model_pose\n\ bool set_model_pose\n\ bool disable_physics_updates\n\ \n\ ================================================================================\n\ MSG: trajectory_msgs/JointTrajectory\n\ Header header\n\ string[] joint_names\n\ JointTrajectoryPoint[] points\n\ ================================================================================\n\ MSG: std_msgs/Header\n\ # Standard metadata for higher-level stamped data types.\n\ # This is generally used to communicate timestamped data \n\ # in a particular coordinate frame.\n\ # \n\ # sequence ID: consecutively increasing ID \n\ uint32 seq\n\ #Two-integer timestamp that is expressed as:\n\ # * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n\ # * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n\ # time-handling sugar is provided by the client library\n\ time stamp\n\ #Frame this data is associated with\n\ # 0: no frame\n\ # 1: global frame\n\ string frame_id\n\ \n\ ================================================================================\n\ MSG: trajectory_msgs/JointTrajectoryPoint\n\ # Each trajectory point specifies either positions[, velocities[, accelerations]]\n\ # or positions[, effort] for the trajectory to be executed.\n\ # All specified values are in the same order as the joint names in JointTrajectory.msg\n\ \n\ float64[] positions\n\ float64[] velocities\n\ float64[] accelerations\n\ float64[] effort\n\ duration time_from_start\n\ \n\ ================================================================================\n\ MSG: geometry_msgs/Pose\n\ # A representation of pose in free space, composed of postion and orientation. \n\ Point position\n\ Quaternion orientation\n\ \n\ ================================================================================\n\ MSG: geometry_msgs/Point\n\ # This contains the position of a point in free space\n\ float64 x\n\ float64 y\n\ float64 z\n\ \n\ ================================================================================\n\ MSG: geometry_msgs/Quaternion\n\ # This represents an orientation in free space in quaternion form.\n\ \n\ float64 x\n\ float64 y\n\ float64 z\n\ float64 w\n\ "; } static const char* value(const ::gazebo_msgs::SetJointTrajectoryRequest_<ContainerAllocator>&) { return value(); } }; } // namespace message_traits } // namespace ros namespace ros { namespace serialization { template<class ContainerAllocator> struct Serializer< ::gazebo_msgs::SetJointTrajectoryRequest_<ContainerAllocator> > { template<typename Stream, typename T> inline static void allInOne(Stream& stream, T m) { stream.next(m.model_name); stream.next(m.joint_trajectory); stream.next(m.model_pose); stream.next(m.set_model_pose); stream.next(m.disable_physics_updates); } ROS_DECLARE_ALLINONE_SERIALIZER; }; // struct SetJointTrajectoryRequest_ } // namespace serialization } // namespace ros namespace ros { namespace message_operations { template<class ContainerAllocator> struct Printer< ::gazebo_msgs::SetJointTrajectoryRequest_<ContainerAllocator> > { template<typename Stream> static void stream(Stream& s, const std::string& indent, const ::gazebo_msgs::SetJointTrajectoryRequest_<ContainerAllocator>& v) { s << indent << "model_name: "; Printer<std::basic_string<char, std::char_traits<char>, typename ContainerAllocator::template rebind<char>::other > >::stream(s, indent + " ", v.model_name); s << indent << "joint_trajectory: "; s << std::endl; Printer< ::trajectory_msgs::JointTrajectory_<ContainerAllocator> >::stream(s, indent + " ", v.joint_trajectory); s << indent << "model_pose: "; s << std::endl; Printer< ::geometry_msgs::Pose_<ContainerAllocator> >::stream(s, indent + " ", v.model_pose); s << indent << "set_model_pose: "; Printer<uint8_t>::stream(s, indent + " ", v.set_model_pose); s << indent << "disable_physics_updates: "; Printer<uint8_t>::stream(s, indent + " ", v.disable_physics_updates); } }; } // namespace message_operations } // namespace ros #endif // GAZEBO_MSGS_MESSAGE_SETJOINTTRAJECTORYREQUEST_H
[ "bsahoo@uwaterloo.ca" ]
bsahoo@uwaterloo.ca
1261141cbf8dab5ac05af792568f606cef3b34d3
6b5d6690678f05a71837b85016db3da52359a2f6
/src/net/base/network_delegate.h
81d81902412f89f952976e569132b9949d08e1fb
[ "BSD-3-Clause", "MIT" ]
permissive
bopopescu/MQUIC
eda5477bacc68f30656488e3cef243af6f7460e6
703e944ec981366cfd2528943b1def2c72b7e49d
refs/heads/master
2022-11-22T07:41:11.374401
2016-04-08T22:27:32
2016-04-08T22:27:32
282,352,335
0
0
MIT
2020-07-25T02:05:49
2020-07-25T02:05:49
null
UTF-8
C++
false
false
13,924
h
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef NET_BASE_NETWORK_DELEGATE_H_ #define NET_BASE_NETWORK_DELEGATE_H_ #include <stdint.h> #include <string> #include "base/callback.h" #include "base/strings/string16.h" #include "base/threading/non_thread_safe.h" #include "net/base/auth.h" #include "net/base/completion_callback.h" #include "net/cookies/canonical_cookie.h" class GURL; namespace base { class FilePath; } namespace net { // NOTE: Layering violations! // We decided to accept these violations (depending // on other net/ submodules from net/base/), because otherwise NetworkDelegate // would have to be broken up into too many smaller interfaces targeted to each // submodule. Also, since the lower levels in net/ may callback into higher // levels, we may encounter dangerous casting issues. // // NOTE: It is not okay to add any compile-time dependencies on symbols outside // of net/base here, because we have a net_base library. Forward declarations // are ok. class CookieOptions; class HttpRequestHeaders; class HttpResponseHeaders; class ProxyInfo; class URLRequest; class NET_EXPORT NetworkDelegate : public base::NonThreadSafe { public: // AuthRequiredResponse indicates how a NetworkDelegate handles an // OnAuthRequired call. It's placed in this file to prevent url_request.h // from having to include network_delegate.h. enum AuthRequiredResponse { AUTH_REQUIRED_RESPONSE_NO_ACTION, AUTH_REQUIRED_RESPONSE_SET_AUTH, AUTH_REQUIRED_RESPONSE_CANCEL_AUTH, AUTH_REQUIRED_RESPONSE_IO_PENDING, }; typedef base::Callback<void(AuthRequiredResponse)> AuthCallback; virtual ~NetworkDelegate() {} // Notification interface called by the network stack. Note that these // functions mostly forward to the private virtuals. They also add some sanity // checking on parameters. See the corresponding virtuals for explanations of // the methods and their arguments. int NotifyBeforeURLRequest(URLRequest* request, const CompletionCallback& callback, GURL* new_url); int NotifyBeforeSendHeaders(URLRequest* request, const CompletionCallback& callback, HttpRequestHeaders* headers); void NotifyBeforeSendProxyHeaders(URLRequest* request, const ProxyInfo& proxy_info, HttpRequestHeaders* headers); void NotifySendHeaders(URLRequest* request, const HttpRequestHeaders& headers); int NotifyHeadersReceived( URLRequest* request, const CompletionCallback& callback, const HttpResponseHeaders* original_response_headers, scoped_refptr<HttpResponseHeaders>* override_response_headers, GURL* allowed_unsafe_redirect_url); void NotifyBeforeRedirect(URLRequest* request, const GURL& new_location); void NotifyResponseStarted(URLRequest* request); void NotifyNetworkBytesReceived(URLRequest* request, int64_t bytes_received); void NotifyNetworkBytesSent(URLRequest* request, int64_t bytes_sent); void NotifyCompleted(URLRequest* request, bool started); void NotifyURLRequestDestroyed(URLRequest* request); void NotifyPACScriptError(int line_number, const base::string16& error); AuthRequiredResponse NotifyAuthRequired(URLRequest* request, const AuthChallengeInfo& auth_info, const AuthCallback& callback, AuthCredentials* credentials); bool CanGetCookies(const URLRequest& request, const CookieList& cookie_list); bool CanSetCookie(const URLRequest& request, const std::string& cookie_line, CookieOptions* options); bool CanAccessFile(const URLRequest& request, const base::FilePath& path) const; bool CanEnablePrivacyMode(const GURL& url, const GURL& first_party_for_cookies) const; bool AreExperimentalCookieFeaturesEnabled() const; // TODO(jww): Remove this once we ship strict secure cookies: // https://crbug.com/546820 bool AreStrictSecureCookiesEnabled() const; bool CancelURLRequestWithPolicyViolatingReferrerHeader( const URLRequest& request, const GURL& target_url, const GURL& referrer_url) const; private: // This is the interface for subclasses of NetworkDelegate to implement. These // member functions will be called by the respective public notification // member function, which will perform basic sanity checking. // Called before a request is sent. Allows the delegate to rewrite the URL // being fetched by modifying |new_url|. If set, the URL must be valid. The // reference fragment from the original URL is not automatically appended to // |new_url|; callers are responsible for copying the reference fragment if // desired. // |callback| and |new_url| are valid only until OnURLRequestDestroyed is // called for this request. Returns a net status code, generally either OK to // continue with the request or ERR_IO_PENDING if the result is not ready yet. // A status code other than OK and ERR_IO_PENDING will cancel the request and // report the status code as the reason. // // The default implementation returns OK (continue with request). virtual int OnBeforeURLRequest(URLRequest* request, const CompletionCallback& callback, GURL* new_url) = 0; // Called right before the HTTP headers are sent. Allows the delegate to // read/write |headers| before they get sent out. |callback| and |headers| are // valid only until OnCompleted or OnURLRequestDestroyed is called for this // request. // See OnBeforeURLRequest for return value description. Returns OK by default. virtual int OnBeforeSendHeaders(URLRequest* request, const CompletionCallback& callback, HttpRequestHeaders* headers) = 0; // Called after a proxy connection. Allows the delegate to read/write // |headers| before they get sent out. |headers| is valid only until // OnCompleted or OnURLRequestDestroyed is called for this request. virtual void OnBeforeSendProxyHeaders(URLRequest* request, const ProxyInfo& proxy_info, HttpRequestHeaders* headers) = 0; // Called right before the HTTP request(s) are being sent to the network. // |headers| is only valid until OnCompleted or OnURLRequestDestroyed is // called for this request. virtual void OnSendHeaders(URLRequest* request, const HttpRequestHeaders& headers) = 0; // Called for HTTP requests when the headers have been received. // |original_response_headers| contains the headers as received over the // network, these must not be modified. |override_response_headers| can be set // to new values, that should be considered as overriding // |original_response_headers|. // If the response is a redirect, and the Location response header value is // identical to |allowed_unsafe_redirect_url|, then the redirect is never // blocked and the reference fragment is not copied from the original URL // to the redirection target. // // |callback|, |original_response_headers|, and |override_response_headers| // are only valid until OnURLRequestDestroyed is called for this request. // See OnBeforeURLRequest for return value description. Returns OK by default. virtual int OnHeadersReceived( URLRequest* request, const CompletionCallback& callback, const HttpResponseHeaders* original_response_headers, scoped_refptr<HttpResponseHeaders>* override_response_headers, GURL* allowed_unsafe_redirect_url) = 0; // Called right after a redirect response code was received. // |new_location| is only valid until OnURLRequestDestroyed is called for this // request. virtual void OnBeforeRedirect(URLRequest* request, const GURL& new_location) = 0; // This corresponds to URLRequestDelegate::OnResponseStarted. virtual void OnResponseStarted(URLRequest* request) = 0; // Called when bytes are received from the network, such as after receiving // headers or reading raw response bytes. This includes localhost requests. // |bytes_received| is the number of bytes measured at the application layer // that have been received over the network for this request since the last // time OnNetworkBytesReceived was called. |bytes_received| will always be // greater than 0. // Currently, this is only implemented for HTTP transactions, and // |bytes_received| does not include TLS overhead or TCP retransmits. virtual void OnNetworkBytesReceived(URLRequest* request, int64_t bytes_received) = 0; // Called when bytes are sent over the network, such as when sending request // headers or uploading request body bytes. This includes localhost requests. // |bytes_sent| is the number of bytes measured at the application layer that // have been sent over the network for this request since the last time // OnNetworkBytesSent was called. |bytes_sent| will always be greater than 0. // Currently, this is only implemented for HTTP transactions, and |bytes_sent| // does not include TLS overhead or TCP retransmits. virtual void OnNetworkBytesSent(URLRequest* request, int64_t bytes_sent) = 0; // Indicates that the URL request has been completed or failed. // |started| indicates whether the request has been started. If false, // some information like the socket address is not available. virtual void OnCompleted(URLRequest* request, bool started) = 0; // Called when an URLRequest is being destroyed. Note that the request is // being deleted, so it's not safe to call any methods that may result in // a virtual method call. virtual void OnURLRequestDestroyed(URLRequest* request) = 0; // Corresponds to ProxyResolverJSBindings::OnError. virtual void OnPACScriptError(int line_number, const base::string16& error) = 0; // Called when a request receives an authentication challenge // specified by |auth_info|, and is unable to respond using cached // credentials. |callback| and |credentials| must be non-NULL, and must // be valid until OnURLRequestDestroyed is called for |request|. // // The following return values are allowed: // - AUTH_REQUIRED_RESPONSE_NO_ACTION: |auth_info| is observed, but // no action is being taken on it. // - AUTH_REQUIRED_RESPONSE_SET_AUTH: |credentials| is filled in with // a username and password, which should be used in a response to // |auth_info|. // - AUTH_REQUIRED_RESPONSE_CANCEL_AUTH: The authentication challenge // should not be attempted. // - AUTH_REQUIRED_RESPONSE_IO_PENDING: The action will be decided // asynchronously. |callback| will be invoked when the decision is made, // and one of the other AuthRequiredResponse values will be passed in with // the same semantics as described above. virtual AuthRequiredResponse OnAuthRequired( URLRequest* request, const AuthChallengeInfo& auth_info, const AuthCallback& callback, AuthCredentials* credentials) = 0; // Called when reading cookies to allow the network delegate to block access // to the cookie. This method will never be invoked when // LOAD_DO_NOT_SEND_COOKIES is specified. virtual bool OnCanGetCookies(const URLRequest& request, const CookieList& cookie_list) = 0; // Called when a cookie is set to allow the network delegate to block access // to the cookie. This method will never be invoked when // LOAD_DO_NOT_SAVE_COOKIES is specified. virtual bool OnCanSetCookie(const URLRequest& request, const std::string& cookie_line, CookieOptions* options) = 0; // Called when a file access is attempted to allow the network delegate to // allow or block access to the given file path. Returns true if access is // allowed. virtual bool OnCanAccessFile(const URLRequest& request, const base::FilePath& path) const = 0; // Returns true if the given |url| has to be requested over connection that // is not tracked by the server. Usually is false, unless user privacy // settings block cookies from being get or set. virtual bool OnCanEnablePrivacyMode( const GURL& url, const GURL& first_party_for_cookies) const = 0; // Returns true if the embedder has enabled the experimental features, and // false otherwise. virtual bool OnAreExperimentalCookieFeaturesEnabled() const = 0; // Returns true if the embedder has enabled experimental features or // specifically strict secure cookies, and false otherwise. // // TODO(jww): Remove this once we ship strict secure cookies: // https://crbug.com/546820. virtual bool OnAreStrictSecureCookiesEnabled() const = 0; // Called when the |referrer_url| for requesting |target_url| during handling // of the |request| is does not comply with the referrer policy (e.g. a // secure referrer for an insecure initial target). // Returns true if the request should be cancelled. Otherwise, the referrer // header is stripped from the request. virtual bool OnCancelURLRequestWithPolicyViolatingReferrerHeader( const URLRequest& request, const GURL& target_url, const GURL& referrer_url) const = 0; }; } // namespace net #endif // NET_BASE_NETWORK_DELEGATE_H_
[ "alyssar@google.com" ]
alyssar@google.com
193a989413c56a0b704462539d265b8d4251950a
5cdd9c1b6adb67fec94f6349ad6203ce2702fecb
/third_party/Windows-CalcEngine/src/SpectralAveraging/src/SpectralSample.cpp
8059abab1fd086bb4128fe977e9d40a0717347d3
[ "BSD-2-Clause", "BSD-3-Clause" ]
permissive
NREL/EnergyPlus
9d8fc6936b5a0c81d2469ab9cdabe55405ccb8f2
50b8a5511ce559e5175524b943c26cc5b99d712d
refs/heads/develop
2023-09-04T08:20:29.804559
2023-09-01T13:58:55
2023-09-01T13:58:55
14,620,185
1,013
406
NOASSERTION
2023-09-14T19:52:57
2013-11-22T14:47:34
C++
UTF-8
C++
false
false
12,527
cpp
#include <stdexcept> #include <cassert> #include "SpectralSample.hpp" #include "MeasuredSampleData.hpp" #include "WCECommon.hpp" using namespace FenestrationCommon; namespace SpectralAveraging { ////////////////////////////////////////////////////////////////////////////////////// //// CSample ////////////////////////////////////////////////////////////////////////////////////// CSample::CSample(const CSeries & t_SourceData, IntegrationType integrationType, double t_NormalizationCoefficient) : m_SourceData(t_SourceData), m_WavelengthSet(WavelengthSet::Data), m_IntegrationType(integrationType), m_NormalizationCoefficient(t_NormalizationCoefficient), m_StateCalculated(false) { CSample::reset(); } CSample::CSample() : m_WavelengthSet(WavelengthSet::Data), m_IntegrationType(IntegrationType::Trapezoidal), m_NormalizationCoefficient(1), m_StateCalculated(false) { CSample::reset(); } CSample & CSample::operator=(const CSample & t_Sample) { m_StateCalculated = t_Sample.m_StateCalculated; m_IntegrationType = t_Sample.m_IntegrationType; m_NormalizationCoefficient = t_Sample.m_NormalizationCoefficient; m_WavelengthSet = t_Sample.m_WavelengthSet; m_IncomingSource = t_Sample.m_IncomingSource; for(const auto & prop : EnumProperty()) { for(const auto & side : EnumSide()) { m_EnergySource[std::make_pair(prop, side)] = t_Sample.m_EnergySource.at(std::make_pair(prop, side)); } } return *this; } CSample::CSample(const CSample & t_Sample) { operator=(t_Sample); } CSeries & CSample::getSourceData() { calculateState(); // must interpolate data to same wavelengths return m_SourceData; } void CSample::setSourceData(CSeries & t_SourceData) { m_SourceData = t_SourceData; reset(); } void CSample::setDetectorData(const CSeries & t_DetectorData) { m_DetectorData = t_DetectorData; reset(); } FenestrationCommon::IntegrationType CSample::getIntegrator() const { return m_IntegrationType; } double CSample::getNormalizationCoeff() const { return m_NormalizationCoefficient; } void CSample::assignDetectorAndWavelengths(std::shared_ptr<CSample> const & t_Sample) { m_DetectorData = t_Sample->m_DetectorData; m_Wavelengths = t_Sample->m_Wavelengths; m_WavelengthSet = t_Sample->m_WavelengthSet; } void CSample::setWavelengths(WavelengthSet const t_WavelengthSet, const std::vector<double> & t_Wavelenghts) { m_WavelengthSet = t_WavelengthSet; switch(t_WavelengthSet) { case WavelengthSet::Custom: m_Wavelengths = t_Wavelenghts; break; case WavelengthSet::Source: if(m_SourceData.size() == 0) { throw std::runtime_error( "Cannot extract wavelenghts from source. Source is empty."); } m_Wavelengths = m_SourceData.getXArray(); break; case WavelengthSet::Data: m_Wavelengths = getWavelengthsFromSample(); break; default: throw std::runtime_error("Incorrect definition of wavelength set source."); break; } reset(); } double CSample::getEnergy(double const minLambda, double const maxLambda, Property const t_Property, Side const t_Side) { calculateState(); return m_EnergySource.at(std::make_pair(t_Property, t_Side)).sum(minLambda, maxLambda); } std::vector<double> CSample::getWavelengths() const { return m_Wavelengths; } double CSample::getProperty(double const minLambda, double const maxLambda, Property const t_Property, Side const t_Side) { calculateState(); auto Prop = 0.0; // Incoming energy can be calculated only if user has defined incoming source. // Otherwise just assume zero property. if(m_IncomingSource.size() > 0) { auto incomingEnergy = m_IncomingSource.sum(minLambda, maxLambda); double propertyEnergy = m_EnergySource.at(std::make_pair(t_Property, t_Side)).sum(minLambda, maxLambda); Prop = propertyEnergy / incomingEnergy; } return Prop; } CSeries & CSample::getEnergyProperties(const Property t_Property, const Side t_Side) { calculateState(); return m_EnergySource.at(std::make_pair(t_Property, t_Side)); } size_t CSample::getBandSize() const { return m_Wavelengths.size(); } void CSample::reset() { m_StateCalculated = false; m_IncomingSource = CSeries(); for(const auto & prop : EnumProperty()) { for(const auto & side : EnumSide()) { m_EnergySource[std::make_pair(prop, side)] = CSeries(); } } } void CSample::calculateState() { if(!m_StateCalculated) { if(m_WavelengthSet != WavelengthSet::Custom) { setWavelengths(m_WavelengthSet); } // In case source data are set then apply solar radiation to the calculations. // Otherwise, just use measured data. if(m_SourceData.size() > 0) { m_IncomingSource = m_SourceData.interpolate(m_Wavelengths); if(m_DetectorData.size() > 0) { const auto interpolatedDetector = m_DetectorData.interpolate(m_Wavelengths); m_IncomingSource = m_IncomingSource * interpolatedDetector; } calculateProperties(); m_IncomingSource = *m_IncomingSource.integrate(m_IntegrationType, m_NormalizationCoefficient); for(const auto & prop : EnumProperty()) { for(const auto & side : EnumSide()) { m_EnergySource[std::make_pair(prop, side)] = *m_EnergySource.at(std::make_pair(prop, side)) .integrate(m_IntegrationType, m_NormalizationCoefficient); } } m_StateCalculated = true; } } } ////////////////////////////////////////////////////////////////////////////////////// //// CSpectralSample ////////////////////////////////////////////////////////////////////////////////////// CSpectralSample::CSpectralSample(std::shared_ptr<CSpectralSampleData> const & t_SampleData, const CSeries & t_SourceData, FenestrationCommon::IntegrationType integrationType, double NormalizationCoefficient) : CSample(t_SourceData, integrationType, NormalizationCoefficient), m_SampleData(t_SampleData) { if(t_SampleData == nullptr) { throw std::runtime_error("Sample must have measured data."); } for(const auto & prop : EnumProperty()) { for(const auto & side : EnumSide()) { m_Property[std::make_pair(prop, side)] = CSeries(); } } } CSpectralSample::CSpectralSample(std::shared_ptr<CSpectralSampleData> const & t_SampleData) : CSample(), m_SampleData(t_SampleData) { if(t_SampleData == nullptr) { throw std::runtime_error("Sample must have measured data."); } for(const auto & prop : EnumProperty()) { for(const auto & side : EnumSide()) { m_Property[std::make_pair(prop, side)] = CSeries(); } } } std::shared_ptr<CSpectralSampleData> CSpectralSample::getMeasuredData() { calculateState(); // Interpolation is needed before returning the data return m_SampleData; } std::vector<double> CSpectralSample::getWavelengthsFromSample() const { return m_SampleData->getWavelengths(); } CSeries CSpectralSample::getWavelengthsProperty(const Property t_Property, const Side t_Side) { calculateState(); return m_Property.at(std::make_pair(t_Property, t_Side)); } void CSpectralSample::calculateProperties() { for(const auto & prop : EnumProperty()) { for(const auto & side : EnumSide()) { m_Property[std::make_pair(prop, side)] = m_SampleData->properties(prop, side); // No need to do interpolation if wavelength set is already from the data. if(m_WavelengthSet != WavelengthSet::Data) { m_Property[std::make_pair(prop, side)] = m_Property[std::make_pair(prop, side)].interpolate(m_Wavelengths); } } } // Calculation of energy balances for(const auto & prop : EnumProperty()) { for(const auto & side : EnumSide()) { m_EnergySource[std::make_pair(prop, side)] = m_Property.at(std::make_pair(prop, side)) * m_IncomingSource; } } } void CSpectralSample::calculateState() { CSample::calculateState(); if(m_SourceData.size() == 0) { for(const auto & prop : EnumProperty()) { for(const auto & side : EnumSide()) { m_Property[std::make_pair(prop, side)] = m_SampleData->properties(prop, side); } } m_StateCalculated = true; } } void CSpectralSample::cutExtraData(const double minLambda, const double maxLambda) { m_SampleData->cutExtraData(minLambda, maxLambda); } void CSpectralSample::Flipped(bool flipped) { m_SampleData->Filpped(flipped); } ///////////////////////////////////////////////////////////////////////////////////// /// CPhotovoltaicSample ///////////////////////////////////////////////////////////////////////////////////// CPhotovoltaicSample::CPhotovoltaicSample( const std::shared_ptr<PhotovoltaicSampleData> & t_PhotovoltaicData, const FenestrationCommon::CSeries & t_SourceData, FenestrationCommon::IntegrationType integrationType, double NormalizationCoefficient) : CSpectralSample( t_PhotovoltaicData, t_SourceData, integrationType, NormalizationCoefficient), m_JcsPrime{{Side::Front, CSeries()}, {Side::Back, CSeries()}} {} void CPhotovoltaicSample::calculateState() { CSpectralSample::calculateProperties(); for(const auto & side : EnumSide()) { const CSeries eqe{getSample()->eqe(side)}; const auto wl = getWavelengthsFromSample(); CSeries jscPrime; for(auto i = 0u; i < wl.size(); ++i) { const double pceVal = jscPrimeCalc(wl[i], eqe[i].value()); jscPrime.addProperty(wl[i], pceVal); } m_JcsPrime[side] = jscPrime; } } PhotovoltaicSampleData * CPhotovoltaicSample::getSample() const { return dynamic_cast<PhotovoltaicSampleData *>(m_SampleData.get()); } double CPhotovoltaicSample::jscPrimeCalc(double wavelength, double eqe) { double const microMeterToMeter{1e-6}; return eqe * wavelength * ConstantsData::ELECTRON_CHARGE * microMeterToMeter / (ConstantsData::SPEEDOFLIGHT * ConstantsData::PLANKCONSTANT); } FenestrationCommon::CSeries & CPhotovoltaicSample::jscPrime(const FenestrationCommon::Side side) { calculateState(); return m_JcsPrime.at(side); } } // namespace SpectralAveraging
[ "dvvidanovic@lbl.gov" ]
dvvidanovic@lbl.gov
034d241f110b11f3fa8acbfec92763b24270f9e1
a8e9dc87186626e726ebadfa490e4f7850a07d8e
/wpfib_essentials/fiberapp/fiber/webrtc/webrtc/modules/video_capture/windows/win_capture_feature_flags.h
83537477383e8453de916065e6b36cc9160d736a
[]
no_license
ymusiychuk-lohika/FreeSWITCH_test
25ca23bee1178c081abd002438888ea15a37187d
2ca7a992e1087442b6484699d24706085fc2851d
refs/heads/master
2021-01-12T10:51:55.561944
2016-12-12T11:57:27
2016-12-12T11:57:27
72,739,774
0
1
null
null
null
null
UTF-8
C++
false
false
2,227
h
#ifndef __WIN_CAPTURER_FEATURE_FLAGS_H_ #define __WIN_CAPTURER_FEATURE_FLAGS_H_ namespace BJN { // Feature type description, used by windows app capture process typedef enum _FeatureType { CaptureApp2UsingLatest = 1, // AppCapture2 with hooks and magnification CaptureScreenUsingDDBasic = 2, // primary & secondary (partial) monitor using dd CaptureScreenUsingDDComplete = 3, // all monitor support & smart presenter widget filtering CaptureAppUsingDDComplete = 4 // Capture application using dd }FeatureType; // Exit code for app capture process typedef enum _AppCaptureExitCode { ExitSuccess = 0, // App capture process exit successfully ExitFailureGeneric = -1, // App capture process exit with failure ExitFailureDDScreenShare = -2 // Problem with current DD screen capture mechanism request to fallback to existing mechanism }; class AppCaptureProcessParameters { public: typedef struct _ProcessData{ FeatureType requestedFeatureType; FeatureType deliveredFeatureType; bool bInfoBarEnabled; } ProcessData; // Create new app capture params AppCaptureProcessParameters(bool bCreate); // Open existing app capture params AppCaptureProcessParameters(LPCTSTR lpSharedDataId); ~AppCaptureProcessParameters(); bool IsValid() const { return _isValid; }; bool SetRequestedFeatureType(FeatureType requestedFeatureType); bool GetRequestedFeatureType(FeatureType& requestedFeatureType) const; bool SetDeliveredFeatureType(FeatureType deliveredFeatureType); bool GetDeliveredFeatureType(FeatureType& deliveredFeatureType) const; bool SetInfoBarEnabled(bool enabled); bool GetInfoBarEnabled(bool& enabled) const; bool GetSharedDataId(std::wstring& sharedDataId) const; private: bool _isValid; ProcessData* _pProcessData; std::wstring _sharedDataId; HANDLE _sharedMemory; }; bool GetGUID(std::wstring& sGuid); } // namespace BJN #endif //__WIN_CAPTURER_FEATURE_FLAGS_H_
[ "ymusiychuk@lohika.com" ]
ymusiychuk@lohika.com
fd4065d7ab4f3c7636ae84ed72086961b60ea838
4ee4b2d880fbd89bdf646570b6d2b3356488f143
/witisoPC/32cpp/贺利坚/查找与二叉搜索树与排序/归并排序.cpp
a851c4e2a16ea7bc72fa02b54ac971f856a6e94f
[]
no_license
wwuhn/wwuhn.github.io
8e5b3422c91f50c4ca989ed53b0d0e27131b574f
c63929f95557398b9f58319fe51a2ab00055afa4
refs/heads/master
2023-06-24T16:32:47.855733
2023-06-11T02:32:07
2023-06-11T02:32:07
211,744,777
3
3
null
null
null
null
GB18030
C++
false
false
2,387
cpp
// 归并排序 #include <stdio.h> #include <malloc.h> #define MaxSize 20 typedef int KeyType; //定义关键字类型 typedef char InfoType[10]; typedef struct //记录类型 { KeyType key; //关键字项 InfoType data; //其他数据项,类型为InfoType } RecType; //排序的记录类型定义 void Merge(RecType R[],int low,int mid,int high) { RecType *R1; int i=low,j=mid+1,k=0; //k是R1的下标,i、j分别为第1、2段的下标 R1=(RecType *)malloc((high-low+1)*sizeof(RecType)); //动态分配空间 while (i<=mid && j<=high) //在第1段和第2段均未扫描完时循环 if (R[i].key<=R[j].key) //将第1段中的记录放入R1中 { R1[k]=R[i]; i++; k++; } else //将第2段中的记录放入R1中 { R1[k]=R[j]; j++; k++; } while (i<=mid) //将第1段余下部分复制到R1 { R1[k]=R[i]; i++; k++; } while (j<=high) //将第2段余下部分复制到R1 { R1[k]=R[j]; j++; k++; } for (k=0,i=low; i<=high; k++,i++) //将R1复制回R中 R[i]=R1[k]; } void MergePass(RecType R[],int length,int n) //对整个数序进行一趟归并 { int i; for (i=0; i+2*length-1<n; i=i+2*length) //归并length长的两相邻子表 Merge(R,i,i+length-1,i+2*length-1); if (i+length-1<n) //余下两个子表,后者长度小于length Merge(R,i,i+length-1,n-1); //归并这两个子表 } void MergeSort(RecType R[],int n) //自底向上的二路归并算法 { int length; for (length=1; length<n; length=2*length) //进行log2n趟归并 MergePass(R,length,n); } int main() { int i,n=10; RecType R[MaxSize]; KeyType a[]= {9,8,7,6,5,4,3,2,1,0}; for (i=0; i<n; i++) R[i].key=a[i]; printf("排序前:"); for (i=0; i<n; i++) printf("%d ",R[i].key); printf("\n"); MergeSort(R,n); printf("排序后:"); for (i=0; i<n; i++) printf("%d ",R[i].key); printf("\n"); return 0; }
[ "noreply@github.com" ]
wwuhn.noreply@github.com
96a58bc8d4fd4762701890e6efd067f045b66fc1
ed6cc29968179d13bb30c73dbf2be2fb6469d495
/pizza/Pizzeria_86_Programma/OrderUI.cpp
6d4603d222fe3d81888e45865ea6988d804cd252
[]
no_license
sindri69/pizza420
e0880eea7eb0dbdeabae3dc675dba732a1778d90
a0f78b59b5830ff67e9b5456a6e6d229869628f5
refs/heads/master
2021-08-28T14:59:32.423484
2017-12-12T14:19:05
2017-12-12T14:19:05
112,332,570
0
0
null
null
null
null
UTF-8
C++
false
false
1,849
cpp
#include <iostream> #include <fstream> #include "MainUI.h" #include "OrderUI.h" #include "Pizza.h" using namespace std; OrderUI::OrderUI() { //ctor } OrderUI::~OrderUI() { //dtor } void OrderUI::start_orderUI() { char selection = '\0'; while (selection != 'q') { cout << "Pizzeria_86_Programma (Orders)" << endl; cout << "1: Add Order" << endl; cout << "2: See list of all Orders" << endl; cout << "3: Return to Main" << endl; cin >> selection; if (selection == '1') { int choice; cout << "How many pizzas do you wish to add to the list? "; cin >> choice; for (int i = 0; i < choice; i++) { Pizza pizza; pizza.setVerbose(true); cin >> pizza; ofstream fout; fout.open("pizza_list.txt", ios::app); pizza.setVerbose(false); fout << pizza; fout.close(); } } else if (selection == '2') { Pizza pizza; ifstream fin; fin.open("pizza_list.txt"); if (fin.is_open()) { int number_of_lines = 0; std::string line; std::ifstream myfile("pizza_list.txt"); while (std::getline(myfile, line)) ++number_of_lines; for (int i = 0; i < (number_of_lines / 2); i++) { pizza.setVerbose(false); fin >> pizza; pizza.setVerbose(true); cout << pizza; } } else { cout << "Could not find pizza list" << endl; } } else if (selection == '3') { selection = 'q'; } } }
[ "sindrii17@ru.ism" ]
sindrii17@ru.ism
23a70cc46fed2cd56bcfc379f4a6166b497bedae
a5f28e6f80a2e0ddf1fb2c8cdb2e74de2e4ff499
/src/image.h
9a7340566e25aea10335fc2e168334502f3e6230
[ "MIT" ]
permissive
fmdunlap/Art2Ascii
bdc3b1db0f7376305146dec6d7ca654b82a8e670
aab23cfba608c5e964c4c14126d4636dc96ebc37
refs/heads/master
2021-07-10T10:53:55.039243
2017-10-09T22:14:45
2017-10-09T22:14:45
105,313,402
0
0
null
null
null
null
UTF-8
C++
false
false
1,678
h
#include "../libs/CImg.h" #include <string> const int MAX_BRIGHTNESS = 255; const int DEFAULT_RESOLUTION = 6; enum PROCESS_TYPE{ standard, color, edge, transparency }; class image{ public: image(char* filename); image(char* filename, PROCESS_TYPE pt); ~image(); /*Computes the average brightness of a 'block' A block is a square of pixels that starts at a pixel(x,y) and extends to x+resolution, and y+resolution. */ int compute_block_average(int start_x, int start_y, int res); /* Computes the average distance from a given color in a block. */ int compute_block_color_distance(int start_x, int start_y, int res, int* color_values); /*Returns character in ascii_darkness_string that should be assosciated with the given brightness. NOTE: 0 <= BRIGHNTESS <= MAX_BRIGHTNESS NOTE: Automatically maps from 0-MAX_BRIGHTNESS into 'ascii_darkness_string' Function does not need to be updated if ascii_darkness_string is updated. */ char get_char_by_brightness(int brightness); //Prints current output_string to file at of_path void print_ascii_to_file(char* of_path); //If possible, updates the output ascii string to the current image & resolution. //Also returns the output string. std::string update_output_string(); //Getters & setters int get_resolution(); //NOTE: CAN BE A LONG RUNNING FUNCTION IN CHANGING RESOLUTION ON LARGE IMAGE. void set_resolution(int res); //Returns output_string std::string get_image_ascii(); private: int* base_color; int resolution; cimg_library::CImg<unsigned char>* raw_image; std::string ascii_darkness_string = "@#%*+=-:. "; std::string ascii_output_string; PROCESS_TYPE pType; };
[ "Fdunlap@usc.edu" ]
Fdunlap@usc.edu
190e39e9df0cbb5bb6cff08434721f2565aaf74e
364447971631437542a0240cfc1725eabecccc57
/Userland/Libraries/LibJS/Runtime/SymbolPrototype.h
7d0a92a5dbcda9726381994a237e98279e04b856
[ "BSD-2-Clause" ]
permissive
Jicgiebcden/serenity
aeb749fd18edb0191f5631b467ec7cd6a0e4eefb
f54a6d273e04f1739950c86dfcb026d746454f6a
refs/heads/master
2023-04-15T06:30:41.710696
2021-04-22T10:38:44
2021-04-22T11:05:30
null
0
0
null
null
null
null
UTF-8
C++
false
false
568
h
/* * Copyright (c) 2020, Matthew Olsson <matthewcolsson@gmail.com> * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include <LibJS/Runtime/Object.h> namespace JS { class SymbolPrototype final : public Object { JS_OBJECT(SymbolPrototype, Object); public: explicit SymbolPrototype(GlobalObject&); virtual void initialize(GlobalObject&) override; virtual ~SymbolPrototype() override; private: JS_DECLARE_NATIVE_GETTER(description_getter); JS_DECLARE_NATIVE_FUNCTION(to_string); JS_DECLARE_NATIVE_FUNCTION(value_of); }; }
[ "kling@serenityos.org" ]
kling@serenityos.org
de610465f2333b5a0df30cf321e9c26b5ac0e6ea
0c80aec0be5a600426006096a5c510c90b3ca949
/Leetcode/String/Ransom_Note.cpp
e0b441ab123c69b549f8808fcaead612822efa62
[]
no_license
skywithlight/Algorithms
7b8fd78874afffc8ae7c2775b53d2402cc165e65
06a13fbb73ea1404a7d0eaab56765ec2423f9e07
refs/heads/master
2020-03-23T21:20:04.814645
2018-10-16T03:59:42
2018-10-16T03:59:42
142,098,756
0
0
null
null
null
null
UTF-8
C++
false
false
726
cpp
class Solution { public: bool canConstruct(string ransomNote, string magazine) { int len, len2, i = 0, ans2 = 0, tem; len = ransomNote.length(); len2 = magazine.length(); bool ans = false; while (i < len){ tem = ans2; for (int j = 0; j < len2; j++){ if (ransomNote[i] == magazine[j]){ ans2++; magazine[j] = 0; j = len2; } } if (tem == ans2){ i = len; } i++; } if (ans2 == len){ ans = true; } return ans; } };
[ "noreply@github.com" ]
skywithlight.noreply@github.com
77210713f8502f747963a6832fc90417e0004e04
60619a8daa4603fb65f4f86f383a6ddde841e326
/2014-06-13/b.cpp
3682644ffc1f692ce807f1420d673c08b93b4f8b
[]
no_license
MYREarth/secret-weapon
f4b1d4b995951546b2fb1e40190707a805fb88b5
77f3ff1111aafaaae8f56893b78e3be9134437a9
refs/heads/master
2020-05-22T02:29:43.024017
2015-10-03T08:17:46
2015-10-03T08:17:46
186,199,326
3
0
null
2019-05-12T01:46:13
2019-05-12T01:46:13
null
UTF-8
C++
false
false
712
cpp
#include <cstdio> #include <cstring> bool vis[3010][3010]; double f[3010][3010]; int n,A,B,me; double dp(int a,int b) { if (vis[a][b]) return(f[a][b]); vis[a][b]=true; double &ret=f[a][b]; if (a+b==n) ret=0; else { int da=A-a,db=B-b; double tot=da*2.0+db+me; ret=me/tot; if (a<A) ret+=dp(a+1,b)*da*2/tot; if (b<B) ret+=dp(a,b+1)*db/tot; } return(ret); } int main() { freopen("bonus.in","r",stdin); freopen("bonus.out","w",stdout); scanf("%d%d%d",&n,&A,&B); me=2; printf("%.15f\n",dp(0,0)); memset(vis,0,sizeof(vis)); me=1; printf("%.15f\n",dp(0,0)); return(0); }
[ "ftiasch0@gmail.com" ]
ftiasch0@gmail.com
26e8f2ff90c0516841762f150b644e502fcd1ac0
80afdd987b0a8cf093d17ca3cd45a58cd0b97ead
/std-bind/copy-semantics/copy-semantics.cpp
6d273eb136ab5876d5fd20078dbeed67bf256d79
[]
no_license
dkambam/purer-interface
de6f739c8c1d8395a64b1a27420c4aae2846133e
b425a95ce8b5450183601d0c0d8fc32511986659
refs/heads/master
2021-01-19T11:15:39.379940
2015-03-17T00:14:50
2015-03-17T00:14:50
31,994,138
0
0
null
null
null
null
UTF-8
C++
false
false
477
cpp
#include <iostream> int sub(int a, int b); int main(){ int x = 10; std::function< int(void) > f; f = std::bind( sub, 29, x ); x = 20; f(); // o/p: (29 - 10) = 19 f = std::bind( sub, 29, std::ref(x) ); // std::ref avoids copy f(); // o/p: (29 - 20) = 9 return 0; } int sub(int a, int b){ int result = a - b; std::cout << "sub: " << "(" << a << " - " << b << ")" ; std::cout << " = " << result << std::endl; return result; }
[ "kdr.code@gmail.com" ]
kdr.code@gmail.com
edfd45a73fd6b8a60b59c00e225cbee75767aa25
1ea8698c8b7a447e172f146c3fa61a686c4862ef
/src/main.cpp
bacf0678f1a1b078e5efa02427626f32ed2a85de
[]
no_license
deniskorobicyn/dip-cpp
db1d44e62c8c07012746f8300d82b22171a4bf4b
9b421063d3e5416b51f21d97a400a1d7913f70ae
refs/heads/master
2020-05-23T10:22:45.129642
2017-09-07T19:38:47
2017-09-07T19:38:47
80,429,199
2
0
null
null
null
null
UTF-8
C++
false
false
506
cpp
#include <iostream> #include <stdio.h> /* defines FILENAME_MAX */ #include "yaml-cpp/yaml.h" #include "arguments.h" #include "dip.h" using namespace dip; int main(int argc, char **argv, char** envp) { Arguments args(argc, argv, envp); if (1 == args.parse()) { std::cout << args.error_message() << std::endl; return 1; } Dip dip(std::make_shared<Arguments>(args)); try { dip.execute(); } catch (YAML::BadFile e) { std::cout << "File dip.yml is not found" << std::endl; } return 0; }
[ "deniskorobitcin@gmail.com" ]
deniskorobitcin@gmail.com
d0b0dbd17425cb6797e716c509560ae5eaa9961e
1a2244c5b9879492227fec5ac86bf0b8ed8d19b1
/CS470.skel/hw4/HW_resize.cpp
f3f0a55fbb3980b8fbc41627dbcc044f5b5e41e8
[]
no_license
mhasan004/Image-Processing-Program
77b58cdb0a0abd5eac327a4759eb3b68a460ca87
e5b7ee6fc26447306de03fef21024b04e007a621
refs/heads/master
2022-03-17T23:53:19.718885
2019-12-12T06:00:36
2019-12-12T06:00:36
211,395,282
2
0
null
null
null
null
UTF-8
C++
false
false
7,302
cpp
#include "IP.h" using namespace IP; enum FILTERS { BOX, TRIANGLE, CUBIC_CONV, LANCZOS, HANN, HAMMING }; double boxFilter (double, double); double triFilter (double, double); double cubicConv (double, double); double lanczos (double, double); double hann (double, double); double hamming (double, double); // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // resize1D: // // Scale 1D scanline. float version. // Input consists of len elements in src. // Output consists of nlen elements in dst. // The inter-pixel distance in src and dst is offst: 1 for rows or row_width for columns // The resampling filter used is specified by mtd (BOX, TRIANGLE, CUBIC_CONV, LANCZOS, HANN, HAMMING) // void resize1D(ChannelPtr<uchar> src, int len, int nlen, int offst, int mtd, double param, ChannelPtr<uchar> dst) { // copy src to dst if no scale change if(len == nlen) { for(int i = 0; i<len; ++i) { *dst = *src; src += offst; dst += offst; } return; } // filter function and filter support (kernel half-width) declarations double (*filter)(double, double); // ptr to filter fct double filterSupport; // 1-sided filter length // default values for filter and its half-width support filter = triFilter; filterSupport = 1; // compute filterSupport: the half-width of the filter switch(mtd) { case FILTERS::BOX: filter = boxFilter; filterSupport = .5; break; case FILTERS::TRIANGLE: filter = triFilter; filterSupport = 1; break; case FILTERS::CUBIC_CONV: filter = cubicConv; filterSupport = 2; break; case FILTERS::LANCZOS: filter = lanczos; filterSupport = param; break; case FILTERS::HANN: filter = hann; filterSupport = param; break; case FILTERS::HAMMING: filter = hamming; filterSupport = param; break; default: fprintf(stderr, "resize1D: Bad filter choice %d\n", mtd); return; } // init filter amplitude (fscale) and width (fwidth), and scale change double fwidth = filterSupport; double fscale = 1.0; double scale = (double) nlen / len; // resampling scale factor // image minification: update fwidth and fscale; // else kernel remains intact for magnification if(scale < 1.0) { // minification: h(x) -> h(x*scale) * scale fwidth = filterSupport / scale; // broaden filter fscale = scale; // lower amplitude } // evaluate size of padding and buffer length int padlen = CEILING(fwidth); // buffer pad length int buflen = len + 2 * padlen; // buffer length // allocate buffer memory if necessary ImagePtr Ibuf; ChannelPtr<uchar> buf; int t=0; IP_getChannel(Ibuf, 0, buf, t); if(Ibuf->width() < buflen || t != UCHAR_TYPE) Ibuf->replaceChannel(0, buflen, 1, UCHAR_TYPE); // copy src into padded buffer buf = Ibuf[0]; // copy src into dst; save space for padding ChannelPtr<uchar> p1 = src; ChannelPtr<uchar> p2 = buf + padlen; for(int x=0; x<len; ++x,p1+=offst) p2[x] = *p1; // pad left and right columns int v1, v2; p1 = buf + padlen; p2 = p1 + len - 1; // replicate border v1 = p1[0]; v2 = p2[0]; for(int x=1; x<= padlen; ++x) { p1[-x] = v1; p2[ x] = v2; } // init srcp to point to first non-padded pixel in padded buffer ChannelPtr<uchar> srcp = buf + padlen; // compute all output pixels int left, right; // kernel extent in input double u; // input coordinate u double acc; // convolution accumulator double pixel; // fetched pixel value double weight; // filter kernel weight for(int x = 0; x<nlen; ++x) { // map output x to input u: inverse mapping u = x / scale; // left and right extent of kernel centered at u if(u - fwidth < 0) left = FLOOR (u - fwidth); else left = CEILING(u - fwidth); right = FLOOR(u + fwidth); // reset acc for collecting convolution products acc = 0; // weigh input pixels around u with kernel double sumWeight = 0; for(int i=left; i <= right; ++i) { // fetch pixel // padding replaces pixel = srcp[CLIP(i, 0, len-1)] to pixel = srcp[i] pixel = srcp[i]; // evaluate weight; multiply it with pixel and add it to accumulator weight = (*filter)((u-i) * fscale, param); sumWeight += weight; acc += (pixel * weight); } // assign weighted accumulator to dst *dst = (int) CLIP(ROUND(acc / sumWeight), 0, MaxGray); dst += offst; } } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // boxFilter: // // Box (nearest neighbor) filter. // double boxFilter(double t, double /*param*/) { if((t > -.5) && (t <= .5)) return(1.0); return(0.0); } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // triFilter: // // Triangle filter (used for linear interpolation). // double triFilter(double t, double /*param*/) { if(t < 0) t = -t; if(t < 1.0) return(1.0 - t); return(0.0); } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // cubicConv: // // Cubic convolution filter. // double cubicConv(double t, double param = -1) { float A; double t2, t3; if(t < 0) t = -t; t2 = t * t; t3 = t2 * t; A = param; if(t < 1.0) return((A + 2)*t3 - (A + 3)*t2 + 1); if(t < 2.0) return(A * (t3 - 5 * t2 + 8 * t - 4)); return(0.0); } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // sinc: // // Sinc function. // double sinc(double t) { t *= PI; if(t != 0) return(sin(t) / t); return(1.0); } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // lanczos: // // Lanczos filter. // double lanczos(double t, double param=3) { int N; N = (int) param; if(t < 0) t = -t; if(t < N) return(sinc(t) * sinc(t / N)); return(0.0); } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // hann: // // Hann windowed sinc function. // double hann(double t, double param=3) { int N; N = (int) param; if(t < 0) t = -t; if(t < N) return(sinc(t) * (.5 + .5*cos(PI*t / N))); return(0.0); } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // hamming: // // hamming windowed sinc function. // double hamming(double t, double param=3) { int N; N = (int) param; if(t < 0) t = -t; if(t < N) return(sinc(t) * (.54 + .46*cos(PI*t / N))); return(0.0); } // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // HW_resize: void HW_resize(ImagePtr I1, int ww, int hh, int kernelID, double param, ImagePtr I2) { int w = I1->width (); int h = I1->height(); // handle trivial case where dimensions remain unchanged if(ww == w && hh == h) { if(I1 != I2) IP_copyImage(I1, I2); return; } // init II ImagePtr II; if(I1 == I2) IP_copyImage(I1, II); else II = I1; // init I2 info IP_copyImageHeaderOnly(I1, I2); I2->setWidth (ww); I2->setHeight(hh); I2->initChannels(I1->channelTypes()); // create tmp image to hold horizontal pass ImagePtr I3; I3 = IP_allocImage(ww, h, UCHARCH_TYPE); // 2-pass scale algorithm int t; ChannelPtr<uchar> src, dst; for(int ch = 0; IP_getChannel(II, ch, src, t); ch++) { IP_getChannel(I2, ch, dst, t); // horizontal pass scales rows for(int y = 0; y<h; ++y) { // PUT YOUR CODE HERE } // vertical pass scales columns for(int x = 0; x<ww; ++x) { // PUT YOUR CODE HERE } } // free global buffer if(II != I1) II->freeImage(); I3->freeImage(); }
[ "mhasan0047@gmail.com" ]
mhasan0047@gmail.com
a5eb55138095c7e9d194d9c12146ea2ec880b807
2f87d0719a1e45bee3ab921682c6abd4d1edcff6
/11.5.1/Linux/Samples/CaptureStills/ImageWriterLinux.cpp
0c1bacae6e0117839f4c024384f15c062a6c2b7a
[]
no_license
LTNGlobal-opensource/bmsdk
28fdadb9db07916473d07f51ffd0bb3ef02dd883
8c7406c2dcd7e7383d69a61cf4c1506835b61570
refs/heads/master
2022-10-11T05:04:35.742445
2020-06-10T16:16:04
2020-06-10T16:16:04
116,147,880
0
2
null
2020-06-10T00:10:25
2018-01-03T14:46:11
C++
UTF-8
C++
false
false
4,206
cpp
/* -LICENSE-START- ** Copyright (c) 2018 Blackmagic Design ** ** Permission is hereby granted, free of charge, to any person or organization ** obtaining a copy of the software and accompanying documentation covered by ** this license (the "Software") to use, reproduce, display, distribute, ** execute, and transmit the Software, and to prepare derivative works of the ** Software, and to permit third-parties to whom the Software is furnished to ** do so, all subject to the following: ** ** The copyright notices in the Software and this entire statement, including ** the above license grant, this restriction and the following disclaimer, ** must be included in all copies of the Software, in whole or in part, and ** all derivative works of the Software, unless such copies or derivative ** works are solely in the form of machine-executable object code generated by ** a source language processor. ** ** 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, TITLE AND NON-INFRINGEMENT. IN NO EVENT ** SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE ** FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ** ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER ** DEALINGS IN THE SOFTWARE. ** -LICENSE-END- */ #include <png.h> #include <sys/stat.h> #include <iomanip> #include <sstream> #include "ImageWriter.h" static const uint32_t kPNGSignatureLength = 8; HRESULT ImageWriter::GetNextFilenameWithPrefix(const std::string& path, const std::string& filenamePrefix, std::string& nextFileName) { HRESULT result = E_FAIL; static int idx = 0; struct stat buf; while (idx < 10000) { std::stringstream pngFilenameStream; pngFilenameStream << path << '/' << filenamePrefix << std::setfill('0') << std::setw(4) << idx++ << ".png"; nextFileName = pngFilenameStream.str(); // If file does not exist, return S_OK if (stat(nextFileName.c_str(), &buf) != 0) { result = S_OK; break; } } return result; } HRESULT ImageWriter::WriteBgra32VideoFrameToPNG(IDeckLinkVideoFrame* bgra32VideoFrame, const std::string& pngFilename) { bool result = E_FAIL; png_structp pngDataPtr = nullptr; png_infop pngInfoPtr = nullptr; png_bytep deckLinkBuffer = nullptr; png_bytepp rowPtrs = nullptr; // Ensure video frame has expected pixel format if (bgra32VideoFrame->GetPixelFormat() != bmdFormat8BitBGRA) { fprintf(stderr, "Video frame is not in 8-Bit BGRA pixel format\n"); return E_FAIL; } FILE *pngFile = fopen(pngFilename.c_str(), "wb"); if (!pngFile) { fprintf(stderr, "Could not open PNG file %s for writing\n", pngFilename.c_str()); return false; } pngDataPtr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); if (!pngDataPtr) { fprintf(stderr, "Could not create PNG write struct\n"); goto bail; } pngInfoPtr = png_create_info_struct(pngDataPtr); if (!pngInfoPtr) { fprintf(stderr, "Could not create PNG info struct\n"); goto bail; } if (setjmp(png_jmpbuf(pngDataPtr))) { fprintf(stderr, "Failed PNG write initialization\n"); goto bail; } png_init_io(pngDataPtr, pngFile); png_set_IHDR(pngDataPtr, pngInfoPtr, bgra32VideoFrame->GetWidth(), bgra32VideoFrame->GetHeight(), 8, PNG_COLOR_TYPE_RGB_ALPHA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); png_write_info(pngDataPtr, pngInfoPtr); png_set_bgr(pngDataPtr); if (bgra32VideoFrame->GetBytes((void**)&deckLinkBuffer) != S_OK) { fprintf(stderr, "Could not get DeckLinkVideoFrame buffer pointer\n"); goto bail; } rowPtrs = (png_bytep*)malloc(sizeof(png_bytep) * bgra32VideoFrame->GetHeight()); // Set row pointers from the buffer for (uint32_t row = 0; row < bgra32VideoFrame->GetHeight(); ++row) rowPtrs[row] = &deckLinkBuffer[row * bgra32VideoFrame->GetRowBytes()]; png_write_image(pngDataPtr, rowPtrs); png_write_end(pngDataPtr, NULL); result = S_OK; bail: fclose(pngFile); png_destroy_write_struct(&pngDataPtr, &pngInfoPtr); free(rowPtrs); return result; }
[ "stoth@kernellabs.com" ]
stoth@kernellabs.com
b026619663bbbb230db32d0895194bcced2f02aa
c3ffa07567d3d29a7439e33a6885a5544e896644
/HSNU-OJ/399.cpp
1960ad86cb7470ba6d47101d39bac20599eb1123
[]
no_license
a00012025/Online_Judge_Code
398c90c046f402218bd14867a06ae301c0c67687
7084865a7050fc09ffb0e734f77996172a93d3ce
refs/heads/master
2018-01-08T11:33:26.352408
2015-10-10T23:20:35
2015-10-10T23:20:35
44,031,127
0
0
null
null
null
null
UTF-8
C++
false
false
1,083
cpp
#include<bits/stdc++.h> #define LL long long using namespace std; const int maxn=100000+10 ; int w[maxn] ; vector<int> v1[maxn],v2[maxn] ; bool vis1[maxn],vis2[maxn] ; LL dp[2][maxn] ; void dp1(int x) { if(vis1[x]) return ; vis1[x]=1 ; LL &ans=dp[0][x] ; ans=w[x] ; for(auto i : v1[x]) { dp1(i) ; ans=max(ans,w[x]+dp[0][i]) ; } } void dp2(int x) { if(vis2[x]) return ; vis2[x]=1 ; LL &ans=dp[1][x] ; ans=w[x] ; for(auto i : v2[x]) { dp2(i) ; ans=max(ans,w[x]+dp[1][i]) ; } } main() { int n,m ; scanf("%d%d",&n,&m) ; for(int i=1;i<=n;i++) scanf("%d",&w[i]) ; while(m--) { int x,y ; scanf("%d%d",&x,&y) ; v1[x].push_back(y) ; v2[y].push_back(x) ; } for(int i=1;i<=n;i++) dp1(i) ; for(int i=1;i<=n;i++) dp2(i) ; LL maxl=0LL ; for(int i=1;i<=n;i++) maxl=max(maxl,dp[0][i]) ; for(int i=1;i<=n;i++) { LL l=dp[0][i]+dp[1][i]-w[i] ; printf("%lld\n",maxl-l) ; } }
[ "a00012025@gmail.com" ]
a00012025@gmail.com
41f2a3a27ef5711184ab146abf95e64679788802
39b0b95dc24b1b881ae606a4614b541b3c0329e1
/BJ_11060/BJ_11060_LCH.cpp
5caf5b789946d381a9129eb03663b668269d2f85
[]
no_license
Algorithm-Study-Of-Gist/ProblemSource
46c9c1deafc23e64407e4787a1b240770c4f31ff
f55ed6fe6569e8b82e7a3c5fb944aac33e15a267
refs/heads/master
2022-07-24T08:29:04.177285
2020-05-21T14:45:26
2020-05-21T14:45:26
261,803,305
1
3
null
2020-05-21T14:28:38
2020-05-06T15:35:12
Java
UTF-8
C++
false
false
369
cpp
#include <cstdio> int main(){ int n, jump[2000], dp[2000] = {0}; scanf("%d", &n); for(int i=0; i<n; i++) scanf("%d", &jump[i]); for(int i=1; i<n; i++) dp[i] = 99999999; for(int i=0; i<n; i++){ for(int j=1; j<=jump[i]; j++){ dp[i+j] = dp[i+j] > dp[i]+1 ? dp[i]+1 : dp[i+j]; } } if(dp[n-1] == 99999999) printf("-1"); else printf("%d", dp[n-1]); }
[ "chayhyeon@naver.com" ]
chayhyeon@naver.com
062f9bd1ab767c2d251f3b74469264d5910c0550
67f2da456f3d395de4de6e27fa471df5bf0766f1
/Arduino_Matrix_GUI/include/statHandler.h
fc18feee8903908c78f6c966e52660efe19a93f2
[]
no_license
SjoerdJoosen/Pixl-Impact
eb78e127e77cae581b98b85186fc62e3f3fc93bd
0294bd6a01005280999e83c44bb6980087545789
refs/heads/main
2023-02-16T23:44:08.753548
2021-01-14T11:00:32
2021-01-14T11:00:32
317,810,649
0
0
null
null
null
null
UTF-8
C++
false
false
297
h
#ifndef STATHANDLER_H #define STATHANDLER_H #include <Arduino.h> class StatHandler{ private: int statValue; int oldStatValue; public: StatHandler(){}; StatHandler(int baseStat); int getStat(); void setStat(int valueToSetTo); bool checkForChange(); }; #endif
[ "74236811+reddog34@users.noreply.github.com" ]
74236811+reddog34@users.noreply.github.com
27808db647ac173bcfe276db4d40b88379c703fc
7a32cee45cdb5bc9357963eb69f458f53bfaffe4
/vol2_src_ref/Plugins/Molecule1/MoleculeUtils.cpp
8bc3eb53f3b3ecc1ec663611711f303dab5ceea7
[]
no_license
kingmax/mayaProgrammingB
464f36027672ed2d911dab7528b27f214f8231d9
13b09747f142b6654b6fcb43107e9d6d476eadf7
refs/heads/master
2021-10-24T02:30:36.708392
2019-03-21T06:13:00
2019-03-21T06:13:00
97,942,873
0
0
null
null
null
null
UTF-8
C++
false
false
3,755
cpp
// // This file accompanies the book "Complete Maya Programming (Volume 2)" // For further information visit http://www.davidgould.com // // Copyright (C) 2004 David Gould // All rights reserved. // #include "MoleculeUtils.h" #include <maya/MTypes.h> #include <maya/MGlobal.h> #include <maya/MVector.h> #include <math.h> int linearIndex( const int r, const int c, const int nRows, const int nCols ) { return ((r % nRows) * nCols) + (c % nCols); } MStatus genBall( const MPoint &centre, const double radius, const unsigned int nSegs, int &nPolys, MPointArray &verts, MIntArray &polyCounts, MIntArray &polyConnects ) { verts.clear(); polyCounts.clear(); polyConnects.clear(); int nAzimuthSegs = nSegs * 2; int nZenithSegs = nSegs; int nAzimuthPts = nAzimuthSegs; // Last point corresponds to the first int nZenithPts = nZenithSegs + 1; // Last point is at other pole double azimIncr = 2.0 * M_PI / nAzimuthSegs; double zenIncr = M_PI / nZenithSegs; MPoint p; double azimuth, zenith; double sinZenith; int azi, zeni; zenith = 0.0; for( zeni=0; zeni < nZenithPts; zeni++, zenith += zenIncr ) { azimuth = 0.0; for( azi=0; azi < nAzimuthPts; azi++, azimuth += azimIncr ) { sinZenith = sin(zenith); p.x = radius * sinZenith * cos(azimuth); p.y = radius * cos(zenith); p.z = radius * sinZenith * sin(azimuth); verts.append( p ); } } // Calculate the number of polygons nPolys = nAzimuthSegs * nZenithSegs; // Each face has four points polyCounts.setLength( nPolys ); int i; for( i=0; i < nPolys; i++ ) polyCounts[i] = 4; // Generate the faces for( zeni=0; zeni < nZenithSegs; zeni++ ) { for( azi=0; azi < nAzimuthSegs; azi++ ) { //MGlobal::displayInfo( MString( "\n" ) + azi + "," + zeni ); polyConnects.append( linearIndex( zeni, azi, nZenithPts, nAzimuthPts ) ); polyConnects.append( linearIndex( zeni, azi+1, nZenithPts, nAzimuthPts ) ); polyConnects.append( linearIndex( zeni+1, azi+1, nZenithPts, nAzimuthPts ) ); polyConnects.append( linearIndex( zeni+1, azi, nZenithPts, nAzimuthPts ) ); } } return MS::kSuccess; } MStatus genRod( const MPoint &p0, const MPoint &p1, const double radius, const unsigned int nSegs, int &nPolys, MPointArray &verts, MIntArray &polyCounts, MIntArray &polyConnects ) { verts.clear(); polyCounts.clear(); polyConnects.clear(); unsigned int nCirclePts = nSegs; unsigned int nVerts = 2 * nCirclePts; // Calculate the local axiis of the rod MVector vec( p1 - p0 ); MVector up( 0.0, 1.0, 0.0 ); MVector xAxis, yAxis, zAxis; yAxis = vec.normal(); if( up.isParallel( yAxis, 0.1 ) ) up = MVector( 1.0, 0.0, 0.0 ); xAxis = yAxis ^ up; zAxis = (xAxis ^ yAxis).normal(); xAxis = (yAxis ^ zAxis ).normal(); // Calculate the vertex positions verts.setLength( nVerts ); double angleIncr = 2.0 * M_PI / nSegs; double angle; MPoint p; double x, z; unsigned int i; for( i=0, angle=0; i < nCirclePts; i++, angle += angleIncr ) { // Calculate position in circle x = radius * cos( angle ); z = radius * sin( angle ); p = p0 + x * xAxis + z * zAxis; verts[ i ] = p; p += vec; verts[ i + nCirclePts ] = p; } nPolys = nSegs; // Generate polycounts polyCounts.setLength( nPolys ); for( i=0; i < polyCounts.length(); i++ ) polyCounts[i] = 4; // Generate polyconnects polyConnects.setLength( nPolys * 4 ); polyConnects.clear(); for( i=0; i < nSegs; i++ ) { polyConnects.append( linearIndex( 0, i, 2, nCirclePts ) ); polyConnects.append( linearIndex( 0, i+1, 2, nCirclePts ) ); polyConnects.append( linearIndex( 1, i+1, 2, nCirclePts ) ); polyConnects.append( linearIndex( 1, i, 2, nCirclePts ) ); } return MS::kSuccess; }
[ "kingmax_res@163.com" ]
kingmax_res@163.com
3f18d0ec33b37a07eda83e506ad8b9d23583af76
d0fb46aecc3b69983e7f6244331a81dff42d9595
/live/src/model/CreateMessageAppRequest.cc
51cf0038641ac83a7c7c8b4795991b463c695310
[ "Apache-2.0" ]
permissive
aliyun/aliyun-openapi-cpp-sdk
3d8d051d44ad00753a429817dd03957614c0c66a
e862bd03c844bcb7ccaa90571bceaa2802c7f135
refs/heads/master
2023-08-29T11:54:00.525102
2023-08-29T03:32:48
2023-08-29T03:32:48
115,379,460
104
82
NOASSERTION
2023-09-14T06:13:33
2017-12-26T02:53:27
C++
UTF-8
C++
false
false
1,955
cc
/* * Copyright 2009-2017 Alibaba Cloud All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <alibabacloud/live/model/CreateMessageAppRequest.h> using AlibabaCloud::Live::Model::CreateMessageAppRequest; CreateMessageAppRequest::CreateMessageAppRequest() : RpcServiceRequest("live", "2016-11-01", "CreateMessageApp") { setMethod(HttpRequest::Method::Post); } CreateMessageAppRequest::~CreateMessageAppRequest() {} std::map<std::string, std::string> CreateMessageAppRequest::getExtension() const { return extension_; } void CreateMessageAppRequest::setExtension(const std::map<std::string, std::string> &extension) { extension_ = extension; for(auto const &iter1 : extension) { setBodyParameter(std::string("Extension") + "." + iter1.first, iter1.second); } } std::map<std::string, std::string> CreateMessageAppRequest::getAppConfig() const { return appConfig_; } void CreateMessageAppRequest::setAppConfig(const std::map<std::string, std::string> &appConfig) { appConfig_ = appConfig; for(auto const &iter1 : appConfig) { setBodyParameter(std::string("AppConfig") + "." + iter1.first, iter1.second); } } std::string CreateMessageAppRequest::getAppName() const { return appName_; } void CreateMessageAppRequest::setAppName(const std::string &appName) { appName_ = appName; setBodyParameter(std::string("AppName"), appName); }
[ "sdk-team@alibabacloud.com" ]
sdk-team@alibabacloud.com
d90917b0c97a5053f752d85b996b6de6977b8f3b
cdd97aba68281f2a862d8441c9ec0456bf108163
/benchmarks/src/453.povray/src/objects.cpp
f53b5f219b325a8ccfd01040b89ac4874709f1a1
[]
no_license
elbrandt/CS752_Proj
894cf78096d8d8916c30acfbadda36729e69006a
546a5d0602211fcf8b93492e3cabf61dce6194c0
refs/heads/main
2023-02-02T07:33:15.191093
2020-12-16T02:44:18
2020-12-16T02:44:18
312,392,830
1
1
null
null
null
null
UTF-8
C++
false
false
17,197
cpp
/**************************************************************************** * objects.cpp * * This module implements the methods for objects and composite objects. * * from Persistence of Vision(tm) Ray Tracer version 3.6. * Copyright 1991-2003 Persistence of Vision Team * Copyright 2003-2004 Persistence of Vision Raytracer Pty. Ltd. *--------------------------------------------------------------------------- * NOTICE: This source code file is provided so that users may experiment * with enhancements to POV-Ray and to port the software to platforms other * than those supported by the POV-Ray developers. There are strict rules * regarding how you are permitted to use this file. These rules are contained * in the distribution and derivative versions licenses which should have been * provided with this file. * * These licences may be found online, linked from the end-user license * agreement that is located at http://www.povray.org/povlegal.html *--------------------------------------------------------------------------- * This program is based on the popular DKB raytracer version 2.12. * DKBTrace was originally written by David K. Buck. * DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins. *--------------------------------------------------------------------------- * $File: //depot/povray/3.5/source/objects.cpp $ * $Revision: #26 $ * $Change: 3010 $ * $DateTime: 2004/07/27 14:06:43 $ * $Author: thorsten $ * $Log$ *****************************************************************************/ #include "frame.h" #include "povray.h" #include "vector.h" #include "interior.h" #include "objects.h" #include "texture.h" #include "matrices.h" BEGIN_POV_NAMESPACE /***************************************************************************** * Local preprocessor defines ******************************************************************************/ /***************************************************************************** * Local typedefs ******************************************************************************/ /***************************************************************************** * Local variables ******************************************************************************/ unsigned int Number_of_istacks = 0; // GLOBAL VARIABLE unsigned int Max_Intersections = 64; // GLOBAL VARIABLE ISTACK *free_istack; // GLOBAL VARIABLE /***************************************************************************** * Static functions ******************************************************************************/ static OBJECT *Copy_Bound_Clip (OBJECT *Old); static void create_istack (void); /***************************************************************************** * * FUNCTION * * Intersection * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ bool Intersection (INTERSECTION *Ray_Intersection, OBJECT *Object, RAY *Ray) { ISTACK *Depth_Stack; INTERSECTION *Local; DBL Closest = HUGE_VAL; if (Object == NULL) { return (false); } if (!Ray_In_Bound (Ray,Object->Bound)) { return (false); } Depth_Stack = open_istack (); if (All_Intersections (Object, Ray, Depth_Stack)) { while ((Local = pop_entry(Depth_Stack)) != NULL) { if (Local->Depth < Closest) { *Ray_Intersection = *Local; Closest = Local->Depth; } } close_istack (Depth_Stack); return (true); } else { close_istack (Depth_Stack); return (false); } } /***************************************************************************** * * FUNCTION * * Inside_Object * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ bool Inside_Object (VECTOR IPoint, OBJECT *Object) { OBJECT *Sib; for (Sib = Object->Clip; Sib != NULL; Sib = Sib->Sibling) { if (!Inside_Object(IPoint, Sib)) { return(false); } } return (Inside(IPoint,Object)); } /***************************************************************************** * * FUNCTION * * Ray_In_Bound * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ bool Ray_In_Bound (RAY *Ray, OBJECT *Bounding_Object) { OBJECT *Bound; INTERSECTION Local; for (Bound = Bounding_Object; Bound != NULL; Bound = Bound->Sibling) { Increase_Counter(stats[Bounding_Region_Tests]); if (!Intersection (&Local, Bound, Ray)) { if (!Inside_Object(Ray->Initial, Bound)) { return (false); } } Increase_Counter(stats[Bounding_Region_Tests_Succeeded]); } return (true); } /***************************************************************************** * * FUNCTION * * Point_In_Clip * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ bool Point_In_Clip (VECTOR IPoint, OBJECT *Clip) { OBJECT *Local_Clip; for (Local_Clip = Clip; Local_Clip != NULL; Local_Clip = Local_Clip->Sibling) { Increase_Counter(stats[Clipping_Region_Tests]); if (!Inside_Object(IPoint, Local_Clip)) { return (false); } Increase_Counter(stats[Clipping_Region_Tests_Succeeded]); } return (true); } /***************************************************************************** * * FUNCTION * * Translate_Object * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ void Translate_Object (OBJECT *Object, VECTOR Vector, TRANSFORM *Trans) { OBJECT *Sib; if (Object == NULL) { return; } for (Sib = Object->Bound; Sib != NULL; Sib = Sib->Sibling) { Translate_Object(Sib, Vector, Trans); } if (Object->Clip != Object->Bound) { for (Sib = Object->Clip; Sib != NULL; Sib = Sib->Sibling) { Translate_Object(Sib, Vector, Trans); } } /* NK 1998 added if */ if (!Test_Flag(Object, UV_FLAG)) { Transform_Textures(Object->Texture, Trans); Transform_Textures(Object->Interior_Texture, Trans); } if (Object->UV_Trans == NULL) Object->UV_Trans = Create_Transform(); Compose_Transforms(Object->UV_Trans, Trans); Transform_Interior(Object->Interior, Trans); Translate(Object, Vector, Trans); } /***************************************************************************** * * FUNCTION * * Rotate_Object * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ void Rotate_Object (OBJECT *Object, VECTOR Vector, TRANSFORM *Trans) { OBJECT *Sib; if (Object == NULL) { return; } for (Sib = Object->Bound; Sib != NULL; Sib = Sib->Sibling) { Rotate_Object(Sib, Vector, Trans); } if (Object->Clip != Object->Bound) { for (Sib = Object->Clip; Sib != NULL; Sib = Sib->Sibling) { Rotate_Object(Sib, Vector, Trans); } } /* NK 1998 added if */ if (!Test_Flag(Object, UV_FLAG)) { Transform_Textures(Object->Texture, Trans); Transform_Textures(Object->Interior_Texture, Trans); } if (Object->UV_Trans == NULL) Object->UV_Trans = Create_Transform(); Compose_Transforms(Object->UV_Trans, Trans); Transform_Interior(Object->Interior, Trans); Rotate(Object, Vector, Trans); } /***************************************************************************** * * FUNCTION * * Scale_Object * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ void Scale_Object (OBJECT *Object, VECTOR Vector, TRANSFORM *Trans) { OBJECT *Sib; if (Object == NULL) { return; } for (Sib = Object->Bound; Sib != NULL; Sib = Sib->Sibling) { Scale_Object(Sib, Vector, Trans); } if (Object->Clip != Object->Bound) { for (Sib = Object->Clip; Sib != NULL; Sib = Sib->Sibling) { Scale_Object(Sib, Vector, Trans); } } /* NK 1998 added if */ if (!Test_Flag(Object, UV_FLAG)) { Transform_Textures(Object->Texture, Trans); Transform_Textures(Object->Interior_Texture, Trans); } if (Object->UV_Trans == NULL) Object->UV_Trans = Create_Transform(); Compose_Transforms(Object->UV_Trans, Trans); Transform_Interior(Object->Interior, Trans); Scale(Object, Vector, Trans); } /***************************************************************************** * * FUNCTION * * Transform_Object * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ void Transform_Object (OBJECT *Object, TRANSFORM *Trans) { OBJECT *Sib; if (Object == NULL) { return; } for (Sib = Object->Bound; Sib != NULL; Sib = Sib->Sibling) { Transform_Object(Sib, Trans); } if (Object->Clip != Object->Bound) { for (Sib = Object->Clip; Sib != NULL; Sib = Sib->Sibling) { Transform_Object(Sib, Trans); } } /* NK 1998 added if */ if (!Test_Flag(Object, UV_FLAG)) { Transform_Textures(Object->Texture, Trans); Transform_Textures(Object->Interior_Texture, Trans); } if (Object->UV_Trans == NULL) Object->UV_Trans = Create_Transform(); Compose_Transforms(Object->UV_Trans, Trans); Transform_Interior(Object->Interior, Trans); Transform(Object,Trans); } /***************************************************************************** * * FUNCTION * * Invert_Object * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ void Invert_Object (OBJECT *Object) { if (Object == NULL) { return; } Invert (Object); } /***************************************************************************** * * FUNCTION * * Copy_Bound_Clip * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ static OBJECT *Copy_Bound_Clip (OBJECT *Old) { OBJECT *Current, *New, *Prev, *First; First = Prev = NULL; for (Current = Old; Current != NULL; Current = Current->Sibling) { New = Copy_Object (Current); if (First == NULL) { First = New; } if (Prev != NULL) { Prev->Sibling = New; } Prev = New; } return (First); } /***************************************************************************** * * FUNCTION * * Copy_Object * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ OBJECT *Copy_Object (OBJECT *Old) { OBJECT *New; if (Old == NULL) { return (NULL); } New = (OBJECT *)Copy(Old); /* * The following copying of OBJECT_FIELDS is redundant if Copy * did *New = *Old but we cannot assume it did. It is safe for * Copy to do *New = *Old but it should not otherwise * touch OBJECT_FIELDS. */ New->Methods = Old->Methods; New->Type = Old->Type; New->Sibling = Old->Sibling; New->Texture = Old->Texture; New->Bound = Old->Bound; New->Clip = Old->Clip; New->BBox = Old->BBox; New->Flags = Old->Flags; New->LLights = NULL; /* Important */ New->Sibling = NULL; /* Important */ New->Texture = Copy_Textures (Old->Texture); New->Interior_Texture = Copy_Textures (Old->Interior_Texture); New->Bound = Copy_Bound_Clip (Old->Bound); New->Interior = Copy_Interior(Old->Interior); /* NK 1998 */ New->UV_Trans = Copy_Transform(Old->UV_Trans); /* NK ---- */ if (Old->Bound != Old->Clip) { New->Clip = Copy_Bound_Clip (Old->Clip); } else { New->Clip = New->Bound; } return (New); } /***************************************************************************** * * FUNCTION * * Destroy_Object * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ void Destroy_Single_Object (OBJECT **ObjectPtr) { OBJECT *Object; Object = *ObjectPtr; Destroy_Textures(Object->Texture); Destroy_Object(Object->Bound); Destroy_Interior((INTERIOR *)Object->Interior); /* NK 1998 */ Destroy_Transform(Object->UV_Trans); Destroy_Object (Object->Bound); Destroy_Interior((INTERIOR *)Object->Interior); if (Object->Bound != Object->Clip) { Destroy_Object(Object->Clip); } *ObjectPtr = Object->Sibling; Destroy(Object); } void Destroy_Object (OBJECT *Object) { OBJECT *Sib; while (Object != NULL) { Destroy_Textures(Object->Texture); Destroy_Textures(Object->Interior_Texture); Destroy_Object(Object->Bound); Destroy_Interior((INTERIOR *)Object->Interior); /* NK 1998 */ Destroy_Transform(Object->UV_Trans); if (Object->Bound != Object->Clip) { Destroy_Object(Object->Clip); } Sib = Object->Sibling; Destroy(Object); Object = Sib; } } /***************************************************************************** * * FUNCTION * * create_istack * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ static void create_istack() { ISTACK *New; int i; New = (ISTACK *)POV_MALLOC(sizeof (ISTACK), "istack"); New->next = free_istack; free_istack = New; New->istack = (INTERSECTION *)POV_MALLOC(Max_Intersections * sizeof (INTERSECTION), "istack entries"); New->max_entries = Max_Intersections; // make sure we have valid NULL pointers [trf] for(i = 0; i < New->max_entries; i++) New->istack[i].Object = NULL; Number_of_istacks++; } /***************************************************************************** * * FUNCTION * * Destroy_IStacks * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ void Destroy_IStacks() { ISTACK *istk, *temp; istk = free_istack; while (istk != NULL) { temp = istk; istk = istk->next; POV_FREE (temp->istack); POV_FREE (temp); } free_istack = NULL; } /***************************************************************************** * * FUNCTION * * open_sstack * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ ISTACK *open_istack() { ISTACK *istk; if (free_istack == NULL) { create_istack (); } istk = free_istack; free_istack = istk->next; istk->top_entry = 0; return (istk); } /***************************************************************************** * * FUNCTION * * close_istack * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ void close_istack (ISTACK *istk) { istk->next = free_istack; free_istack = istk; } /***************************************************************************** * * FUNCTION * * incstack * * INPUT * * OUTPUT * * RETURNS * * AUTHOR * * POV-Ray Team * * DESCRIPTION * * - * * CHANGES * * - * ******************************************************************************/ void incstack(ISTACK *istk) { if(++istk->top_entry >= istk->max_entries) { istk->top_entry--; Increase_Counter(stats[Istack_overflows]); } } /***************************************************************************** * * FUNCTION * * Default_UVCoord * * INPUT * * Object - Pointer to blob structure * Inter - Pointer to intersection * * OUTPUT * * * RETURNS * * AUTHOR * * Nathan Kopp * * DESCRIPTION * This is used as a default UVCoord function for objects where UVCoordinates * are not defined. It instead returns the XY coordinates of the intersection. * * CHANGES * * ******************************************************************************/ void Default_UVCoord(UV_VECT Result, OBJECT * /*Object*/, INTERSECTION *Inter) { Result[U] = Inter->IPoint[X]; Result[V] = Inter->IPoint[Y]; } END_POV_NAMESPACE
[ "eric.l.brandt@gmail.com" ]
eric.l.brandt@gmail.com
9cdce25dba60d2156d236058ead315132f55681f
20b85b68ceb95798832bfc6858ddecc06d86250b
/plugins/mdaAmbience.h
420e4b2c61ff72eb3a04affc13cf8298f64a3d65
[ "MIT" ]
permissive
elk-audio/mda-vst2
6ede7e9bf303e087fa2b123bba8fff32b7a827f5
8ea6ef97946a617d73e48d245777e57fb984357f
refs/heads/master
2020-11-28T11:27:08.490888
2019-12-23T17:42:00
2019-12-23T17:42:00
229,798,075
6
2
null
null
null
null
UTF-8
C++
false
false
1,260
h
#ifndef __mdaAmbience_H #define __mdaAmbience_H #include "audioeffectx.h" class mdaAmbience : public AudioEffectX { public: mdaAmbience(audioMasterCallback audioMaster); ~mdaAmbience(); virtual void process(float **inputs, float **outputs, VstInt32 sampleFrames); virtual void processReplacing(float **inputs, float **outputs, VstInt32 sampleFrames); virtual void setProgramName(char *name); virtual void getProgramName(char *name); virtual bool getProgramNameIndexed (VstInt32 category, VstInt32 index, char* name); virtual void setParameter(VstInt32 index, float value); virtual float getParameter(VstInt32 index); virtual void getParameterLabel(VstInt32 index, char *label); virtual void getParameterDisplay(VstInt32 index, char *text); virtual void getParameterName(VstInt32 index, char *text); virtual void suspend(); virtual bool getEffectName(char *name); virtual bool getVendorString(char *text); virtual bool getProductString(char *text); virtual VstInt32 getVendorVersion() { return 1000; } protected: float fParam0; float fParam1; float fParam2; float fParam3; float fParam4; float *buf1, *buf2, *buf3, *buf4; float fil, fbak, damp, wet, dry, size; VstInt32 pos, den, rdy; char programName[32]; }; #endif
[ "stefano@elk.audio" ]
stefano@elk.audio
a873fcce68083cc35007daa5adc2316f330c9df2
87b1736c19cd79903aaf7df9e8a7f52b0bbe355c
/lab8/cq1.cpp
9b12146d5ca6407f9eb25de9594a3fe10297b6f3
[]
no_license
imagine5am/cs699-pm9
85029a0ab8e41f90038ab86caf0e8db0edb6bee1
0c28d479c688387f66575317bcadf667d8abb78a
refs/heads/main
2023-04-06T15:37:19.828890
2021-04-29T18:27:31
2021-04-29T18:27:31
362,910,668
0
0
null
null
null
null
UTF-8
C++
false
false
2,148
cpp
#include <cstdlib> #include <cstring> #include <iostream> using namespace std; struct eArray{ private: // put data members here int *data_ptr; int nums = 0, heap_size = 0; static const int DEFAULT_SIZE = 32; public: // construct an array with 0 elements eArray(){ data_ptr = (int*) malloc(DEFAULT_SIZE * sizeof(int)); if (data_ptr == NULL){ printf("malloc: Memory not allocated.\n"); } else{ heap_size = DEFAULT_SIZE; } } // return a reference to the ith element of the array int &operator[](int i){ return data_ptr[i]; } // Append v to the current array // Use a simple implementation: allocate a new array to // accommodate the extra element v. Then copy the current // array into it. Copy v, and delete the current array. void push_back(int v){ int *temp_ptr; if (nums == heap_size) { temp_ptr = (int*) malloc(2 * heap_size * sizeof(int)); memcpy(temp_ptr, data_ptr, nums * sizeof(int)); if (temp_ptr == NULL){ printf("malloc: Memory not allocated.\n"); } else { free(data_ptr); data_ptr = temp_ptr; heap_size *= 2; } } data_ptr[nums++] = v; } // return the current size of the array // "const" says this function will not change the receiver int size() const { return nums; } // copy constructor eArray(const eArray &rhs){ data_ptr = (int*) malloc(rhs.heap_size * sizeof(int)); if (data_ptr == NULL){ printf("malloc: Memory not allocated.\n"); } else{ heap_size = rhs.heap_size; nums = rhs.nums; } memcpy(data_ptr, rhs.data_ptr, nums * sizeof(int)); } // destructor ~eArray(){ free(data_ptr); } // assignment operator eArray& operator=(const eArray &rhs){ nums = rhs.nums; heap_size = rhs.heap_size; free(data_ptr); data_ptr = (int*) malloc(rhs.heap_size * sizeof(int)); if (data_ptr == NULL){ printf("malloc: Memory not allocated.\n"); } else{ heap_size = rhs.heap_size * sizeof(int); } memcpy(data_ptr, rhs.data_ptr, nums * sizeof(int)); return *this; } };
[ "ssood@cse.iitb.ac.in" ]
ssood@cse.iitb.ac.in
2aa84d3a8a190662ec149cf8e5da3e27e09c996a
b20203514a73611acd5f226ba4c1668140959e8d
/ctraj/pp_util.cc
075abb0709f828a28dfd757eba50290ea23e86a9
[ "MIT" ]
permissive
Edroor/libmsci
978d748e2ec788bc5b28eadf311d4c497d95f705
872dc362292d93ce4966e554494bfa156594c9d9
refs/heads/master
2023-02-22T10:17:52.934272
2021-01-25T05:40:42
2021-01-25T05:40:42
null
0
0
null
null
null
null
UTF-8
C++
false
false
10,634
cc
#include <stdio.h> #include <stdint.h> #include <gsl/gsl_fft_complex.h> #include "peteys_tmpl_lib.h" #include "error_codes.h" #include "full_util.h" #include "time_class.h" #include "ctraj_defaults.h" #include "pp_util.h" #include "ctraj_3d_fields.h" using namespace libpetey; namespace ctraj { void swap_endian (int32_t *data, int n) { char *fourbyte; char swp; for (int i=0; i<n; i++) { fourbyte=(char *) (data+i); swp=fourbyte[0]; fourbyte[0]=fourbyte[3]; fourbyte[3]=swp; swp=fourbyte[1]; fourbyte[1]=fourbyte[2]; fourbyte[2]=swp; } } int pp_read_all(char *fname, int32_t **headers_all, float ***fields, int nmax) { FILE *fs; int32_t f77recsep; int32_t *header; float **data; int readcount; int nrec; fs=fopen(fname, "r"); if (fs==NULL) { fprintf(stderr, "Error: unable to open %s for input\n", fname); throw UNABLE_TO_OPEN_FILE_FOR_READING; } for (nrec=0; nrec<nmax; nrec++) { readcount=fread(&f77recsep, sizeof(f77recsep), 1, fs); //printf("%d %d\n", nrec, readcount); if (readcount==0) { break; } swap_endian(&f77recsep, 1); //should be 256: //printf("%d\n", f77recsep); if (f77recsep != PP_HEADLEN*4) { fprintf(stderr, "Error: error in record separator--wrong file type\n"); fprintf(stderr, " actual: %d; expected: %d\n", f77recsep, PP_HEADLEN*4); throw FILE_READ_ERROR; } header=new int32_t[PP_HEADLEN]; fread(header, sizeof(int32_t), PP_HEADLEN, fs); swap_endian(header, PP_HEADLEN); headers_all[nrec]=header; fread(&f77recsep, sizeof(f77recsep), 1, fs); fread(&f77recsep, sizeof(f77recsep), 1, fs); swap_endian(&f77recsep, 1); //should be 6912*4: //printf("%d\n", f77recsep); if (header[PP_HEADLOC_N]!=header[PP_HEADLOC_NLAT]*header[PP_HEADLOC_NLON]) { fprintf(stderr, "Error in record header: %d*%d != %d\n", header[PP_HEADLOC_NLAT], header[PP_HEADLOC_NLON], header[PP_HEADLOC_N]); throw FILE_READ_ERROR; } data=allocate_matrix<float, int32_t>(header[PP_HEADLOC_NLAT], header[PP_HEADLOC_NLON]); fread(data[0], sizeof(float), header[PP_HEADLOC_N], fs); swap_endian((int32_t *) data[0], header[PP_HEADLOC_N]); fields[nrec]=data; fread(&f77recsep, sizeof(f77recsep), 1, fs); } fclose(fs); return nrec; } int pp_read_field(FILE *fs, int32_t **headers, float ***fields, int nmax, int field_code, float *plev, int nlev, int toendflag) { int32_t f77recsep; int32_t *header; int nhead_check; //check number of elements read in float **data; int readcount; int nrec; int n, n1; //number of elements read in should match int nlon, nlat; float level; int lastcode=-1; int code=-1; do { readcount=fread(&f77recsep, sizeof(f77recsep), 1, fs); //printf("%d %d\n", nrec, readcount); if (readcount==0) { break; } swap_endian(&f77recsep, 1); //should be 256: //printf("%d\n", f77recsep); if (f77recsep != PP_HEADLEN*sizeof(int32_t)) { fprintf(stderr, "Error: error in record separator--wrong file type\n"); fprintf(stderr, " actual: %d; expected: %d\n", f77recsep, PP_HEADLEN*4); throw FILE_READ_ERROR; } header=new int32_t[PP_HEADLEN]; nhead_check=fread(header, sizeof(int32_t), PP_HEADLEN, fs); if (nhead_check!=PP_HEADLEN) { fprintf(stderr, "Not enough header records read in: %d vs. %d\n", nhead_check, PP_HEADLEN); if (nhead_check==0) break; else throw FILE_READ_ERROR; } swap_endian(header, PP_HEADLEN); headers[nrec]=header; fread(&f77recsep, sizeof(f77recsep), 1, fs); fread(&f77recsep, sizeof(f77recsep), 1, fs); swap_endian(&f77recsep, 1); //should be 6912*4: //printf("%d\n", f77recsep); n=header[PP_HEADLOC_N]; nlat=header[PP_HEADLOC_NLAT]; nlon=header[PP_HEADLOC_NLON]; lastcode=code; code=header[PP_HEADLOC_CODE]; level=*(float *)(header+PP_HEADLOC_LEV); if (n!=nlon*nlat) { fprintf(stderr, "Error in record header: %d*%d != %d\n", nlat, nlon, n); throw FILE_READ_ERROR; } if (n*sizeof(int32_t)!=f77recsep) { fprintf(stderr, "Error in record header: %d != %d\n", header[PP_HEADLOC_NLAT], f77recsep); throw FILE_READ_ERROR; } data=NULL; if (code == field_code) { if (plev!=NULL) { for (int i=0; i<nlev; i++) { if (plev[i]==level) { data=allocate_matrix<float, int32_t>(nlat, nlon); break; } } } else { data=allocate_matrix<float, int32_t>(nlat, nlon); } } if (data!=NULL) { n1=fread(data[0], sizeof(float), n, fs); if (n1!=n) { fprintf(stderr, "Not enough header records read in: %d vs. %d\n", nhead_check, PP_HEADLEN); throw FILE_READ_ERROR; } swap_endian((int32_t *) data[0], n); fields[nrec]=data; nrec++; fread(&f77recsep, sizeof(f77recsep), 1, fs); } else { fseek(fs, n*sizeof(int32_t)+1, SEEK_CUR); } } while (lastcode!=field_code || lastcode==code || toendflag); return nrec; } int pp_extract_uvwtz(float ***data, int32_t **header, int n, float ***&u, float ***&v, float ***&w, float ***&t, float ***&z) { int loc=0; if (header[loc][PP_HEADLOC_CODE] !=PP_U_CODE) goto fail; u=data+loc; for (loc=0; loc<n; loc++) { if (header[loc][PP_HEADLOC_CODE] != PP_U_CODE) break; } if (header[loc][PP_HEADLOC_CODE] !=PP_V_CODE || loc>=n) goto fail; v=data+loc; for ( ; loc<n; loc++) { if (header[loc][PP_HEADLOC_CODE] != PP_V_CODE) break; } if (header[loc][PP_HEADLOC_CODE] !=PP_Z_CODE || loc>=n) goto fail; z=data+loc; for ( ; loc<n; loc++) { if (header[loc][PP_HEADLOC_CODE] != PP_Z_CODE) break; } if (header[loc][PP_HEADLOC_CODE] !=PP_T_CODE || loc>=n) goto fail; t=data+loc; for ( ; loc<n; loc++) { if (header[loc][PP_HEADLOC_CODE] != PP_T_CODE) break; } if (header[loc][PP_HEADLOC_CODE] !=PP_W_CODE || loc>=n) goto fail; w=data+loc; return 0; fail: fprintf(stderr, "Error: formatting of field data; %d vs. %d\n", PP_V_CODE, header[loc][PP_HEADLOC_CODE]); throw FILE_READ_ERROR; } float * pp_extract_levels(int32_t **header, int n, int &nlev) { int32_t code; float *lev; nlev=0; code=header[0][PP_HEADLOC_CODE]; for (int i=1; i<n; i++) { if (code!=header[i][PP_HEADLOC_CODE]) { nlev=i; break; } } lev=new float[nlev]; for (int i=0; i<nlev; i++) { lev[i]=((float *) header[i])[PP_HEADLOC_LEV]; } for (int i=0; i<n; i++) { if (((float *) header[i])[PP_HEADLOC_LEV] != lev[i%nlev]) goto fail; } return lev; fail: fprintf(stderr, "Error: formatting of vertical levels\n"); throw FILE_READ_ERROR; } int pp_interpolate_uv(float ***u, float ***v, int nlev, int nlat, int nlon, float ***unew, float ***vnew) { int nfft=1 << int(log(nlon)/log(2)); double *Spolecirc; double *Npolecirc; float Nx=0, Ny=0; //North pole wind float Sx=0, Sy=0; //South pole wind float sinth, costh; //Spolecirc=new double[nfft*2]; //Npolecirc=new double[nfft*2]; for (int i=0; i<nlev; i++) { for (int j=1; j<nlat; j++) { for (int k=0; k<nlon; k++) { unew[i][j][k]=(u[i][j-1][k]+u[i][j][k])/2; vnew[i][j][k]=(v[i][j-1][k]+v[i][j][k])/2; } } } //do some shit for the poles: for (int i=0; i<nlev; i++) { for (int j=0; j<nlon; j++) { costh=cos(2*M_PI*j/nlon); sinth=sin(2*M_PI*j/nlon); //average to a single point at the pole by rotating to a common //coordinate system: Sx+=u[i][0][j]*costh-v[i][0][j]*sinth; Sy+=v[i][0][j]*sinth+u[i][0][j]*costh; Nx+=u[i][nlat-1][j]*costh-v[i][nlat-1][j]*sinth; Ny+=v[i][nlat-1][j]*sinth+u[i][nlat-1][j]*costh; } Sx/=nlon; Sy/=nlon; Nx/=nlon; Ny/=nlon; //printf("%g %g %g %g\n", Sx, Sy, Nx, Ny); for (int j=0; j<nlon; j++) { costh=cos(2*M_PI*j/nlon); sinth=sin(2*M_PI*j/nlon); //printf("%g %g\n", costh, sinth); //zonal and meridional winds are just this point in rotated //coordinates depeding on the longitude: unew[i][0][j]=Sx*costh+Sy*sinth; vnew[i][0][j]=Sx*sinth-Sy*costh; unew[i][nlat][j]=Nx*costh+Ny*sinth; vnew[i][nlat][j]=Nx*sinth-Ny*costh; //printf("(%g, %g) ", unew[i][0][j], vnew[i][0][j]); } //printf("\n"); } } //finds interpolation coefficients for a set of potential temperature levels float *** pp_interpolate_pt_levels(float *plev, float ***t, int nlev, int nlat, int nlon, float *ptlev, int npt, float pref) { float ***coef; float pt[nlev]; long sind[nlev]; long loc; long lastind=-1; coef=allocate_3D_field<float>(npt, nlat, nlon); for (int i=0; i<nlat; i++) { for (int j=0; j<nlon; j++) { for (int k=0; k<nlev; k++) { pt[k]=t[k][i][j]*pow(pref/plev[k], KAPPA); //printf("%g ", pt[k]); } //printf("\n"); heapsort(pt, sind, nlev); map_vector_inplace(pt, sind, nlev); for (int k=0; k<npt; k++) { loc=bin_search(pt, nlev, ptlev[k], lastind); if (sind[loc]>=nlev-1 || loc < 0) { fprintf(stderr, "Potential temperature level (%g) falls out of sky\n", ptlev[k]); throw PARAMETER_OUT_OF_RANGE; } coef[k][i][j]=sind[(int) loc]+(ptlev[k]-pt[loc])/(pt[loc+1]-pt[loc]); //printf("%g ", coef[k][i][j]); } } //printf("\n"); } return coef; } float *** pp_zinterpolate(float ***field, float ***coef, int nlev, int nlat, int nlon) { float *** fnew; fnew=new float**[nlev]; for (int i=0; i<nlev; i++) { fnew[i]=allocate_matrix<float, int32_t>(nlat, nlon); for (int j=0; j<nlat; j++) { for (int k=0; k<nlon; k++) { int pind=(int) coef[i][j][k]; float frac=coef[i][j][k]-pind; fnew[i][j][k]=field[pind][j][k]*(1-frac) +field[pind+1][j][k]*frac; //printf("%g ", field[pind][j][k]); } //printf("\n"); } } return fnew; } } //end namespace ctraj
[ "peteymills@hotmail.com" ]
peteymills@hotmail.com
9074a55bb5784d4e4ebf3a1c35e5d17e79c7a6c5
64892882b204aa9930b5b247a7695e9e466c0ab7
/MKA/Lab2_v4/Lab2_v4/main.cpp
3696ff10c09fe65e803c2f709a081d469c453bac
[]
no_license
zhekaso/ms-homework
13672346007954c518c758775ad39df0f284a7af
5518a18736d43faf7a112d9b08f70e35bb24ea86
refs/heads/master
2020-03-28T07:28:05.084024
2018-09-27T15:31:35
2018-09-27T15:31:35
147,903,240
0
0
null
null
null
null
WINDOWS-1251
C++
false
false
2,563
cpp
#include "mesh.h" void main() { setlocale(LC_ALL, "Russian"); MESH disk; disk.input(); int user_choise; bool end = false; while (!end) { printf("\t1) По номеру КЭ получить номер его базисых функций;\n\t2) По двум узлам получить номер ребра;\n"); printf("\t3) По номеру ребра узнать номера вершин, составляющих ребро;\n"); printf("\t4) По номеру ребра узнать каким КЭ данное ребро принадлежит;\n\t5) Выход;\n"); printf("Ваш выбор : "); scanf("%d\n", &user_choise); switch (user_choise) { case 1: { int fe_id; printf("Введите номер КЭ : "); scanf("%d\n", &fe_id); vector <int> base_id; base_id = disk.returnTheBasicFuncOfFE(fe_id); printf("В %d - й КЭ входят базисные функции с номерами : \n\t\t", fe_id); for(int i =0;i<base_id.size();i++) printf("%d ",base_id[i]); } break; case 2: { printf("\tВведите номер первой вершины : "); int A_id, B_id; scanf("%d\n", &A_id); printf("\tВведите номер второй вершины : "); scanf("%d\n", &B_id); int edge_id; if(disk.returnTheNumberOfEdge(A_id,B_id,&edge_id)) printf("\tДанные вершины образуют ребро с номером %d\n",edge_id); else printf("\tДанная пара вершин не образуют ребро\n"); } break; case 3: { printf("\tВведите номер ребра : "); int edge_id,A_id, B_id; scanf("%d\n", &edge_id); if (disk.returnPointsFormingAnEdge(&A_id, &B_id, edge_id)) printf("\tРебро %d обрауют вершины с номерами %d и %d\n", edge_id, A_id,B_id); else printf("\tНе существует ребра с таким номером.\n"); } break; case 4: { printf("\tВведите номер ребра : "); int edge_id; vector <int> FE; scanf("%d\n", &edge_id); disk.returnNumberFEIncludingEdge(edge_id); printf("Ребро с номером %d входит в КЭ с номерами: \n\t\t", edge_id); for (int i = 0; i < FE.size(); i++) printf("%d ", FE[i]); } break; case 5: end =! end ; break; default: printf("Ваш выбор не выходит в множество возможных действий! Введите цифру от 1 до 5"); break; } } }
[ "andrei.brenev@mail.ru" ]
andrei.brenev@mail.ru
800f99883a5ce0014adacf6741468451cd7bfb9f
cec302f1b0a1f4c41c3a0b5f9b90d4ab902005a6
/case-studies/h2o/src/H2oEnclave/h2omain/compress.cpp
ddbee838f6cbe3b6250c231af4810246bbbbb0b0
[ "Apache-2.0" ]
permissive
kripa432/Panoply
cf4ea0f63cd3c1216f7a97bc1cf77a14afa019af
6287e7feacc49c4bc6cc0229e793600b49545251
refs/heads/master
2022-09-11T15:06:22.609854
2020-06-03T04:51:59
2020-06-03T04:51:59
266,686,111
0
0
null
2020-05-25T04:53:14
2020-05-25T04:53:14
null
UTF-8
C++
false
false
6,533
cpp
/* * Copyright (c) 2015 DeNA Co., Ltd., Kazuho Oku * * 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 "h2o.h" #include "h2o/configurator.h" #define DEFAULT_GZIP_QUALITY 1 #define DEFAULT_BROTLI_QUALITY 1 struct compress_configurator_t { h2o_configurator_t super; h2o_compress_args_t *vars, _vars_stack[H2O_CONFIGURATOR_NUM_LEVELS + 1]; }; static const h2o_compress_args_t all_off = {{-1}, {-1}}, all_on = {{DEFAULT_GZIP_QUALITY}, {DEFAULT_BROTLI_QUALITY}}; static int on_config_gzip(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node) { printf("on_config_gzip \n"); struct compress_configurator_t *self = (void *)cmd->configurator; int mode; if ((mode = (int)h2o_configurator_get_one_of(cmd, node, "OFF,ON")) == -1) return -1; *self->vars = all_off; if (mode != 0) self->vars->gzip.quality = DEFAULT_GZIP_QUALITY; return 0; } static int obtain_quality(yoml_t *node, int min_quality, int max_quality, int default_quality, int *slot) { int tmp; if (node->type != YOML_TYPE_SCALAR) return -1; if (strcasecmp(node->data.scalar, "OFF") == 0) { *slot = -1; return 0; } if (strcasecmp(node->data.scalar, "ON") == 0) { *slot = default_quality; return 0; } if (sscanf(node->data.scalar, "%d", &tmp) == 1 && (min_quality <= tmp && tmp <= max_quality)) { *slot = tmp; return 0; } return -1; } static int on_config_compress(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node) { printf("on_config_compress \n"); struct compress_configurator_t *self = (void *)cmd->configurator; size_t i; switch (node->type) { case YOML_TYPE_SCALAR: if (strcasecmp(node->data.scalar, "OFF") == 0) { *self->vars = all_off; } else if (strcasecmp(node->data.scalar, "ON") == 0) { *self->vars = all_on; } else { h2o_configurator_errprintf(cmd, node, "scalar argument must be either of: `OFF`, `ON`"); return -1; } break; case YOML_TYPE_SEQUENCE: *self->vars = all_off; for (i = 0; i != node->data.sequence.size; ++i) { yoml_t *element = node->data.sequence.elements[i]; if (element->type == YOML_TYPE_SCALAR && strcasecmp(element->data.scalar, "gzip") == 0) { self->vars->gzip.quality = DEFAULT_GZIP_QUALITY; } else if (element->type == YOML_TYPE_SCALAR && strcasecmp(element->data.scalar, "br") == 0) { self->vars->brotli.quality = DEFAULT_BROTLI_QUALITY; } else { h2o_configurator_errprintf(cmd, element, "element of the sequence must be either of: `gzip`, `br`"); return -1; } } break; case YOML_TYPE_MAPPING: *self->vars = all_off; for (i = 0; i != node->data.mapping.size; ++i) { yoml_t *key = node->data.mapping.elements[i].key; yoml_t *value = node->data.mapping.elements[i].value; if (key->type == YOML_TYPE_SCALAR && strcasecmp(key->data.scalar, "gzip") == 0) { if (obtain_quality(node, 1, 9, DEFAULT_GZIP_QUALITY, &self->vars->gzip.quality) != 0) { h2o_configurator_errprintf( cmd, value, "value of gzip attribute must be either of `OFF`, `ON` or an integer value between 1 and 9"); return -1; } } else if (key->type == YOML_TYPE_SCALAR && strcasecmp(key->data.scalar, "br") == 0) { if (obtain_quality(node, 0, 11, DEFAULT_BROTLI_QUALITY, &self->vars->brotli.quality) != 0) { h2o_configurator_errprintf( cmd, value, "value of br attribute must be either of `OFF`, `ON` or an integer between 0 and 11"); return -1; } } else { h2o_configurator_errprintf(cmd, key, "key must be either of: `gzip`, `br`"); return -1; } } break; default: h2o_fatal("unexpected node type"); break; } return 0; } static int on_config_enter(h2o_configurator_t *configurator, h2o_configurator_context_t *ctx, yoml_t *node) { printf("on_config_enter compress.cpp \n"); struct compress_configurator_t *self = (void *)configurator; ++self->vars; self->vars[0] = self->vars[-1]; return 0; } static int on_config_exit(h2o_configurator_t *configurator, h2o_configurator_context_t *ctx, yoml_t *node) { struct compress_configurator_t *self = (void *)configurator; if (ctx->pathconf != NULL && (self->vars->gzip.quality != -1 || self->vars->brotli.quality != -1)) h2o_compress_register(ctx->pathconf, self->vars); --self->vars; return 0; } void h2o_compress_register_configurator(h2o_globalconf_t *conf) { struct compress_configurator_t *c = (void *)h2o_configurator_create(conf, sizeof(*c)); c->super.enter = on_config_enter; c->super.exit = on_config_exit; h2o_configurator_define_command(&c->super, "compress", H2O_CONFIGURATOR_FLAG_ALL_LEVELS, on_config_compress); h2o_configurator_define_command(&c->super, "gzip", H2O_CONFIGURATOR_FLAG_ALL_LEVELS | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR, on_config_gzip); c->vars = c->_vars_stack; c->vars->gzip.quality = -1; c->vars->brotli.quality = -1; }
[ "shwetasshinde24@gmail.com" ]
shwetasshinde24@gmail.com
228f42d80bb03af2317eac133e4f52b7060836a9
99387b630d7657c292dea99c7f1d6987925b667d
/src/snp_clustering.cpp
8035efa204047e26a516689dca54fe670b63de0b
[]
no_license
timdallman/snpaddress
8728b27d4074d2f82b904bb5fe19a0f8fcf0cf45
ee239617ec9ee8e882c055fe3e34412fddddce64
refs/heads/master
2020-04-15T00:06:19.999744
2015-08-04T12:13:14
2015-08-04T12:13:14
40,179,521
1
0
null
null
null
null
UTF-8
C++
false
false
10,758
cpp
#include <iostream> #include <string.h> #include <string> #include <sstream> #include <fstream> #include <iomanip> #include <vector> #include <cmath> #include <map> #include <vector> #include <algorithm> #include <stdio.h> #include <stdlib.h> using namespace std; ////////////////////////////////CLASSES////////////////////////////////// ///////////////////////////////FUNCTIONS///////////////////////////////// //convert string into int double cstr_double(string& str_double) { ostringstream osstr_double; osstr_double<<str_double<<endl; istringstream isstr_double(osstr_double.str()); double doublestr_double; isstr_double>>doublestr_double; return (doublestr_double); } //read matric file into multimap multimap <string, double> read_file(char *a) { //global variables multimap <string,double> mat; char split_char = '\t'; string line; string name1; string name2; double dist; ifstream infile (a); if (infile.is_open()) { while ( getline (infile,line)) { istringstream split(line); string each; int count = 0; while(std::getline(split, each, split_char)) { if(count == 0) { name1 = each; } if(count ==1) { name2 = each; } if(count ==2) { dist = cstr_double(each); } count++; } //Makes multimap of name1:name2 = snp_dist string pair = name1+":"+name2; mat.insert(make_pair(pair,dist)); string pair2 = name2+":"+name1; mat.insert(make_pair(pair2,dist)); } } return mat; } vector <vector <string> > make_links(multimap <string,double> mat, string each) { //global varaiables vector <vector <string> > links; vector <string> matches; string name1, name2; //set cutoff double co = cstr_double(each); multimap <string, double >::iterator it; char split_char = ':'; string old_name = ""; //vector for mathches //Loop through matrix multimap for (it=mat.begin(); it!=mat.end(); it++) { //get pair string pair = it->first; string splitter; istringstream split(pair); int count = 0; while(std::getline(split, splitter, split_char)) { if(count == 0) { name1 = splitter; } if(count == 1) { name2 = splitter; } count++; } //if a new strain if(name1 != old_name) { if(old_name != "") { links.push_back(matches); } //Create somewhere for the mathces matches.clear(); matches.push_back(name1); old_name = name1; } double dist = it->second; // if the distance less or equal to threshold and the strain to the matches if (dist <= co) { if(name1 != name2) { matches.push_back(name2); } } } // add final comparison links.push_back(matches); return links; } vector <vector <string> > define_clusters(vector <vector <string> > links) { //initial dedup sort(links.begin(), links.end()); vector <vector <string> >::iterator d_it; d_it = unique(links.begin(), links.end()); links.resize(distance(links.begin(),d_it)); //globals vector <vector <string> > clusters; clusters.resize(links.size()); //first pass to reduce the links //iterate over first cluster for (int i=0; i<links.size();i++) { vector <string> strains = links[i]; sort(strains.begin(), strains.end()); //iterate over the rest for (int j=i+1; j<links.size();j++) { vector <string> strains2 = links[j]; //sort clusters sort(strains2.begin(), strains2.end()); //check they have anything in common //initalise iterator vector <string>::iterator int_it; //result vector vector <string> int_check; int_check.resize(strains.size()+strains2.size()); int_it = set_intersection(strains.begin(), strains.end(), strains2.begin(), strains2.end(),int_check.begin()); //resize int_check.resize(int_it-int_check.begin()); if (int_check.size() > 0) { //they have a common strain so find the union //initalise iterator vector <string>::iterator union_it; //results vector vector <string> cluster; cluster.resize(strains.size()+strains2.size()); //find union union_it = set_union(strains.begin(), strains.end(), strains2.begin(), strains2.end(),cluster.begin()); //resize cluster.resize(union_it-cluster.begin()); sort(cluster.begin(), cluster.end()); links[j] = cluster; } } //return only unique vectors vector <vector <string> >::iterator d_it; d_it = unique(links.begin(), links.end()); links.resize(distance(links.begin(),d_it)); } //second pass on reduced links make clusters //iterate over first cluster for (int i=0; i<links.size();i++) { vector <string> strains = links[i]; sort(strains.begin(), strains.end()); clusters[i]= strains; //iterate over the rest for (int j=i+1; j<links.size();j++) { vector <string> strains2 = links[j]; //sort clusters sort(strains2.begin(), strains2.end()); //check they have anything in common //initalise iterator vector <string>::iterator int_it; //result vector vector <string> int_check; int_check.resize(strains.size()+strains2.size()); int_it = set_intersection(strains.begin(), strains.end(), strains2.begin(), strains2.end(),int_check.begin()); //resize int_check.resize(int_it-int_check.begin()); if (int_check.size() > 0) { //they have a common strain so find the union //initalise iterator vector <string>::iterator union_it; //results vector vector <string> cluster; cluster.resize(strains.size()+strains2.size()); //find union union_it = set_union(strains.begin(), strains.end(), strains2.begin(), strains2.end(),cluster.begin()); //resize cluster.resize(union_it-cluster.begin()); sort(cluster.begin(), cluster.end()); //can we merge with other clusters for(int k=0; k<clusters.size();k++) { //get strains from clusters vector <string> c_strains = clusters[k]; sort(c_strains.begin(), c_strains.end()); //check they have anything in common //initalise iterator vector <string>::iterator int_it; //result vector vector <string> int_check; int_check.resize(c_strains.size()+cluster.size()); int_it = set_intersection(c_strains.begin(), c_strains.end(), cluster.begin(), cluster.end(),int_check.begin()); //resize int_check.resize(int_it-int_check.begin()); if (int_check.size() > 0) { //initalise iterator vector <string>::iterator int_vector2; //results vector vector <string> cluster2; cluster2.resize(c_strains.size()+cluster.size()); //find union int_vector2 = set_union(c_strains.begin(), c_strains.end(), cluster.begin(), cluster.end(),cluster2.begin()); //resize cluster2.resize(int_vector2-cluster2.begin()); //update clusters clusters[i] = cluster2; clusters[k] = cluster2; } } } } } return clusters; } vector <vector <string> > remove_duplicate_clusters(vector <vector <string> > clusters) { sort(clusters.begin(), clusters.end()); //return only unique vectors vector <vector <string> >::iterator d_it; d_it = unique(clusters.begin(), clusters.end()); clusters.resize(distance(clusters.begin(),d_it)); return clusters; } void print_clusters(multimap <double, vector <vector <string> > > out_clusters, string co) { //globals multimap <double, vector <vector <string> > >::reverse_iterator it; multimap <string, vector <int> > strain_list; //print threshold header cout << "#\t" << co << "\n"; //loop through cutoffs for(it = out_clusters.rbegin(); it!=out_clusters.rend(); it++) { //create variables vector <vector <string> > clusters = it->second; double cutoff = it->first; //cout << cutoff; vector <vector <string> >::iterator c_it; //initialise cluster counter int i = 1; //loop through clusters for (c_it = clusters.begin(); c_it!=clusters.end(); c_it++) { //create variables vector <string>::iterator s_it; vector <string> strains = *c_it; if (strains.size() > 0) { //loop through strains for (s_it = strains.begin(); s_it!=strains.end(); s_it++) { //add to multimap multimap <string, vector <int> >::iterator st_it; //find strain_list for strain st_it = strain_list.find(*s_it); if(st_it != strain_list.end()) { //add cluster no st_it->second.push_back(i); } else { //create first instance vector<int> tmp; tmp.assign(1,i); strain_list.insert(make_pair(*s_it,tmp)); } } //iterate cluster counter i++; } } } //print clusters multimap <string, vector <int> >::iterator p_it; for(p_it = strain_list.begin();p_it!=strain_list.end(); p_it++) { //create variables string name = p_it->first; vector <int> clust = p_it->second; cout << name << "\t"; //iterator vector <int>::iterator v_it; string hier; for(v_it = clust.begin(); v_it!=clust.end();v_it++) { //convet to char and append to string std::stringstream ss; ss << *v_it; std::string str = ss.str(); hier.append(str); hier.append("."); } //remove last . hier.pop_back(); //print cout << hier; cout << "\n"; } } /////////////////////////////////Main//////////////////////////////////// int main(int argc, char *argv[]) { //IO if (argc <= 1) { cout << "Usage: " << argv[0] << "<snp matrix> <snp distances to use for clustering e.g 5:10:25:50>" << endl; exit(1); } //globals char * matrix = argv[1]; char * co = argv[2]; char split_char = ':'; multimap <string,double> mat; string each; istringstream split(co); multimap <double, vector <vector <string> > > out_clusters; //read matrix //cout << "reading matrix......\n"; mat = read_file(matrix); // for each threshold while(std::getline(split, each, split_char)) { //make initial links vector <vector <string> > links = make_links(mat, each); //make single linkage clusters vector <vector <string> > clusters = define_clusters(links); //remove duplicate clusters vector <vector <string> > dedup_clusters = remove_duplicate_clusters(clusters); //add to out_clusters multimap out_clusters.insert(make_pair(cstr_double(each),dedup_clusters)); } //print clusters print_clusters(out_clusters,co); return 0; }
[ "tim.dallman@phe.gov.uk" ]
tim.dallman@phe.gov.uk
9b442b0a14b3130b01b63610d8c4c5dc71954ae8
d92304badb95993099633c5989f6cd8af57f9b1f
/Codeforces/723-B.cpp
6063ccefff2dc690512e105e6bcbcd50437013b7
[]
no_license
tajirhas9/Problem-Solving-and-Programming-Practice
c5e2b77c7ac69982a53d5320cebe874a7adec750
00c298233a9cde21a1cdca1f4a2b6146d0107e73
refs/heads/master
2020-09-25T22:52:00.716014
2019-12-05T13:04:40
2019-12-05T13:04:40
226,103,342
0
0
null
null
null
null
UTF-8
C++
false
false
3,059
cpp
#include <bits/stdc++.h> using namespace std; #define MAX 1000000007 #define MOD 1000000007 #define rep(i,a,b) for(i=a;i<=b;i++) #define repR(i,a,b) for(i=a;i>=b;i--) #define mp(x,y) make_pair(x,y) #define pb(x) emplace_back(x) //#define pb(x) push_back(x) #define all(c) c.begin(),c.end() #define F first #define S second #define RESET(a,b) memset(a,b,sizeof(a)) #define gcd(a,b) __gcd(a,b) #define lcm(a,b) ((a*b)/gcd(a,b)) typedef long long ll; typedef string string; typedef pair<ll,ll> pii; typedef vector<ll> vl; typedef vector<string> vs; typedef set<ll> setl; typedef set<string> sets; typedef set<ll>::iterator setl_it; typedef set<string>::iterator sets_it; typedef vector<ll>::iterator vl_it; typedef vector<string>::iterator vs_it; inline bool isLeapYear(ll y) { return ((y%400==0) || (y%4==0 && y%100!=0)); } inline void optimize(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } inline bool isInside(pii p,ll n,ll m) { return (p.first>=0&&p.first<n&&p.second>=0&&p.second<m); }; inline bool isInside(pii p,ll n) { return (p.first>=0&&p.first<n&&p.second>=0&&p.second<n); }; inline bool isSquare(ll x) { ll s = sqrt(x); return (s*s==x); }; inline bool isFib(ll x) { return isSquare(5*x*x+4)|| isSquare(5*x*x-4); }; inline bool isPowerOfTwo(ll x) { return ((1LL<<(ll)log2(x))==x); }; ll primeMarked[MAX/64 + 2]; inline bool on(ll x) { return (primeMarked[x/64] & (1<<((x%64)/2))); }; inline void mark(ll x) { primeMarked[x/64] |= (1<<((x%64)/2)); }; inline ll bitOn(ll x,ll k) { return x |= 1<<k; } inline ll bitOff(ll x,ll k) { return x ^= 1<<k; } inline bool checkBit(ll x,ll k) { return x &= 1<<k; } const ll mod = 1e9+7; const double pi = acos(-1.0); struct func { //this is a sample overloading function for sorting stl bool operator()(pii const &a, pii const &b) { if(a.first==b.first) return (a.second<b.second); return (a.first>b.first); } };/* void sieve(ll n) { for (ll i=3; i*i<n;i+=2) { if (!on(i)) { for (ll j=i*i;j<=n;j+=i+i) { mark(j); } } } } inline bool isPrime(int num) { return num > 1 && (num == 2 || ((num & 1) && !on(num))); }*/ ll fx[] = {1,1,-1,-1}; ll fy[] = {1,-1,1,-1}; int main() { optimize(); ll i,l,m=0,cnt=0,word=0; string s; bool bracketIsOn,wordCount; bracketIsOn = wordCount = false; cin >> l; cin >> s; rep(i,0,l) { if(s[i]=='(') { m = max(m,cnt); cnt=0; bracketIsOn = true; } if(s[i]==')') { bracketIsOn = false; wordCount = false; } if(s[i]=='\0') { m = max(m,cnt); cnt = 0; } if(s[i]=='_') //RESET everything { if(bracketIsOn) { if(wordCount) { wordCount = false; } } else { //do something for outside bracket m = max(m,cnt); cnt = 0; } } if((s[i]>='a' && s[i]<='z') || (s[i]>='A' && s[i] <= 'Z')) { if(bracketIsOn) { if(!wordCount) { word++; wordCount = true; } } else { cnt++; } } } cout << m << " " << word << endl; return 0; } //?
[ "tajircuet@gmail.com" ]
tajircuet@gmail.com
2639eefe0aae88c9708c95373b259345bd726666
6c766846a9c07523369d3a5b55d77adb3808e5aa
/FinalPass/FinalPass.cpp
65b4029d0872156d4cd24dac597ccab9461d59e6
[]
no_license
danny30312/EECS-583-FinalProject
404133539826d341293d2abc7e3875316d8e0566
ba5d087f971d20687714dcd8a2451fc65537de44
refs/heads/main
2023-01-22T16:45:36.522007
2020-11-28T19:49:04
2020-11-28T19:49:04
316,807,908
0
0
null
null
null
null
UTF-8
C++
false
false
5,123
cpp
#include "llvm/Transforms/Scalar/LICM.h" #include "llvm/ADT/SetOperations.h" #include "llvm/ADT/Statistic.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/AliasSetTracker.h" #include "llvm/Analysis/BasicAliasAnalysis.h" #include "llvm/Analysis/CaptureTracking.h" #include "llvm/Analysis/ConstantFolding.h" #include "llvm/Analysis/GlobalsModRef.h" #include "llvm/Analysis/GuardUtils.h" #include "llvm/Analysis/Loads.h" #include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/LoopIterator.h" #include "llvm/Analysis/LoopPass.h" #include "llvm/Analysis/MemoryBuiltins.h" #include "llvm/Analysis/MemorySSA.h" #include "llvm/Analysis/MemorySSAUpdater.h" #include "llvm/Analysis/OptimizationRemarkEmitter.h" #include "llvm/Analysis/ScalarEvolution.h" #include "llvm/Analysis/ScalarEvolutionAliasAnalysis.h" #include "llvm/Analysis/TargetLibraryInfo.h" #include "llvm/Analysis/ValueTracking.h" #include "llvm/IR/CFG.h" #include "llvm/IR/Constants.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/DebugInfoMetadata.h" #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/Dominators.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/IntrinsicInst.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Metadata.h" #include "llvm/IR/PatternMatch.h" #include "llvm/IR/PredIteratorCache.h" #include "llvm/InitializePasses.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Scalar/LoopPassManager.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Transforms/Utils/Local.h" #include "llvm/Transforms/Utils/LoopUtils.h" #include "llvm/Transforms/Utils/SSAUpdater.h" #include <algorithm> #include <utility> #include "llvm/Analysis/BranchProbabilityInfo.h" #include "llvm/Analysis/BlockFrequencyInfo.h" using namespace llvm; namespace { struct Statics : public FunctionPass { static char ID; Statics() : FunctionPass(ID) {} void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired<BlockFrequencyInfoWrapperPass>(); // Analysis pass to load block execution count AU.addRequired<BranchProbabilityInfoWrapperPass>(); // Analysis pass to load branch probability } bool runOnFunction(Function &F) override { BranchProbabilityInfo &bpi = getAnalysis<BranchProbabilityInfoWrapperPass>().getBPI(); BlockFrequencyInfo &bfi = getAnalysis<BlockFrequencyInfoWrapperPass>().getBFI(); float DynOpCounts = 0; float IAlu = 0; float FAlu = 0; float Mem = 0; float BBranch = 0; float UBranch = 0; float Other = 0; for (Function::iterator b = F.begin(); b != F.end(); b++) { for (BasicBlock::iterator i = b->begin(); i != b->end(); i++) { uint64_t blockCount = bfi.getBlockProfileCount(&*b).getValue(); DynOpCounts += blockCount; int inst = i->getOpcode(); if (inst == Instruction::Add ||inst == Instruction::Sub ||inst == Instruction::Mul ||inst == Instruction::UDiv ||inst == Instruction::SDiv ||inst == Instruction::URem ||inst == Instruction::Shl ||inst == Instruction::LShr ||inst == Instruction::AShr ||inst == Instruction::And ||inst == Instruction::Or ||inst == Instruction::Xor ||inst == Instruction::ICmp ||inst == Instruction::SRem) {IAlu += blockCount;} else if (inst == Instruction::FAdd ||inst == Instruction::FSub ||inst == Instruction::FMul ||inst == Instruction::FDiv ||inst == Instruction::FRem ||inst == Instruction::FCmp) {FAlu += blockCount;} else if (inst == Instruction::Alloca ||inst == Instruction::Load ||inst == Instruction::Store ||inst == Instruction::GetElementPtr ||inst == Instruction::Fence ||inst == Instruction::AtomicCmpXchg ||inst == Instruction::AtomicRMW) {Mem += blockCount;} else if (inst == Instruction::Br ||inst == Instruction::Switch ||inst == Instruction::IndirectBr){ if (bpi.getHotSucc((BasicBlock*) &*b)){ BBranch += blockCount; } else { UBranch += blockCount; } } else{Other += blockCount;} } } errs() << F.getName() << ", "; errs() << int(DynOpCounts) << ", "; if (DynOpCounts == 0) { errs() << format("%f", 0.0f); } else { errs() << format("%f, ", (IAlu/DynOpCounts)); errs() << format("%f, ",(FAlu/DynOpCounts)); errs() << format("%f, ",(Mem/DynOpCounts)); errs() << format("%f, ",(BBranch/DynOpCounts)); errs() << format("%f, ",(UBranch/DynOpCounts)); errs() << format("%f",(Other/DynOpCounts)); } errs() << "\n"; return true; } }; } char Statics::ID = 0; static RegisterPass<Statics> X("statistics", "Operation Statistics Pass", false /* Only looks at CFG */, false /* Analysis Pass */);
[ "chchuang@eecs583a.eecs.umich.edu" ]
chchuang@eecs583a.eecs.umich.edu
165a81454f3fe79f9174a0cec1d1b961fdf8fc18
4be7a3f1465554edc9b31aacc2692daac51c46aa
/SEMPHY/lib/betaDistribution.cpp
9d62f7c53a857b9861cc277658a0cd406738bcb9
[]
no_license
kbavishi/MineBench
b90eaeb485b736cb80a4a5a7d09f966ef3eedf9d
74a8ef895a07f32164b20876798560f02f2b561e
refs/heads/master
2021-01-18T23:13:07.585731
2017-04-17T21:29:44
2017-04-17T21:29:44
87,095,090
2
0
null
null
null
null
UTF-8
C++
false
false
3,301
cpp
// $Id: betaDistribution.cpp 2399 2014-03-13 22:43:51Z wkliao $ #include "betaDistribution.h" #include "gammaUtilities.h" #include "betaUtilities.h" #include "errorMsg.h" #include "logFile.h" #include <cmath> betaDistribution::betaDistribution() { _alpha = 0.0; _beta = 0.0; _boundary.resize(0,0); _rates.resize(0,0); _ratesProb.resize(0,0); _globalRate = 1;//??? 0.5 or 1 } // note that the order of initalization makes a diffrence. betaDistribution::betaDistribution(const betaDistribution& other) : _boundary(other._boundary), _alpha(other._alpha), _beta(other._beta), _rates(other._rates), _ratesProb(other._ratesProb), _globalRate(other._globalRate) { } betaDistribution::betaDistribution(MDOUBLE alpha,MDOUBLE beta,int in_number_of_categories) :distribution(){ _globalRate=1.0; setBetaParameters(in_number_of_categories,alpha,beta); } betaDistribution::~betaDistribution() { _boundary.clear(); _rates.clear(); _ratesProb.clear(); } void betaDistribution::setAlpha(MDOUBLE in_alpha) { if (in_alpha == _alpha) return; setBetaParameters(categories(), in_alpha, _beta); } void betaDistribution::setBeta(MDOUBLE in_beta) { if (in_beta == _beta) return; setBetaParameters( categories(), _alpha, in_beta); } void betaDistribution::change_number_of_categories(int in_number_of_categories) { if (in_number_of_categories == categories()) return; setBetaParameters( in_number_of_categories, _alpha, _beta); } void betaDistribution::setBetaParameters(int in_number_of_categories, MDOUBLE in_alpha, MDOUBLE in_beta) { if ((in_alpha == _alpha) && (in_beta == _beta) && (in_number_of_categories == categories())) return; if (in_alpha < MINIMUM_ALPHA_PARAM) in_alpha = MINIMUM_ALPHA_PARAM;// when alpha is very small there are underflaw problems if (in_beta < MINIMUM_ALPHA_PARAM) in_beta = MINIMUM_ALPHA_PARAM;// when beta is very small there are underflaw problems _alpha = in_alpha; _beta = in_beta; _rates.clear(); _rates.resize(in_number_of_categories); _ratesProb.clear(); _ratesProb.resize(in_number_of_categories, 1.0/in_number_of_categories); _boundary.clear(); _boundary.resize(in_number_of_categories+1); if (in_number_of_categories==1) { _rates[0] = 1.0; return; } if (categories() > 1) { fill_mean(); return ; } } int betaDistribution::fill_mean() { fill_boundaries(); int i; //LOG(5,<<endl<<" alpha = "<<_alpha<<" beta = "<< _beta<<endl); //for (i=0; i<=categories(); ++i) cout<<endl<<_boundary[i]; //LOG(5,<<"\n====== the r categories are =====\n"); for (i=0; i<categories(); ++i) { _rates[i]=computeAverage_r(_boundary[i], _boundary[i+1], _alpha, _beta, categories()); //LOG(5,<<_rates[i]<<endl); } //LOG(5,<<endl<<_alpha<<endl); return 0; } int betaDistribution::fill_boundaries() { int i; //LOG(5,<<endl<<"========BOUNDARY============="<<endl); for (i=1; i<categories(); ++i) { _boundary[i]=inverseCDFBeta(_alpha, _beta,static_cast<MDOUBLE>(i)/categories()); //LOG(5,<<"_boundary[ "<<i<<"] ="<<_boundary[i]<<endl); } _boundary[0]=0; _boundary[i]=1; return 0; } const MDOUBLE betaDistribution::getCumulativeProb(const MDOUBLE x) const {// //since r~gamma(alpha, beta) then beta*r~ gamma(alpha,1)=gammp //here we assume alpha=beta return incompleteBeta(_alpha,_beta,x); }
[ "karan.bavishi90@gmail.com" ]
karan.bavishi90@gmail.com
d1289cf61b7c7e37a3e19d5c2595093e096350c0
8dc84558f0058d90dfc4955e905dab1b22d12c08
/ash/system/power/power_event_observer.cc
b232f6260595da5e0174a196226af9f0fce1a7c8
[ "LicenseRef-scancode-unknown-license-reference", "BSD-3-Clause" ]
permissive
meniossin/src
42a95cc6c4a9c71d43d62bc4311224ca1fd61e03
44f73f7e76119e5ab415d4593ac66485e65d700a
refs/heads/master
2022-12-16T20:17:03.747113
2020-09-03T10:43:12
2020-09-03T10:43:12
263,710,168
1
0
BSD-3-Clause
2020-05-13T18:20:09
2020-05-13T18:20:08
null
UTF-8
C++
false
false
14,555
cc
// Copyright 2013 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "ash/system/power/power_event_observer.h" #include <map> #include <utility> #include "ash/public/cpp/config.h" #include "ash/root_window_controller.h" #include "ash/session/session_controller.h" #include "ash/shell.h" #include "ash/system/model/clock_model.h" #include "ash/system/model/system_tray_model.h" #include "ash/wallpaper/wallpaper_widget_controller.h" #include "ash/wm/lock_state_controller.h" #include "ash/wm/lock_state_observer.h" #include "base/bind.h" #include "base/location.h" #include "base/scoped_observer.h" #include "base/threading/thread_task_runner_handle.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "ui/aura/window.h" #include "ui/aura/window_tree_host.h" #include "ui/base/user_activity/user_activity_detector.h" #include "ui/compositor/compositor.h" #include "ui/compositor/compositor_observer.h" #include "ui/display/manager/display_configurator.h" namespace ash { namespace { void OnSuspendDisplaysCompleted(base::OnceClosure suspend_callback, bool status) { std::move(suspend_callback).Run(); } // Returns whether the screen should be locked when device is suspended. bool ShouldLockOnSuspend() { SessionController* controller = ash::Shell::Get()->session_controller(); return controller->ShouldLockScreenAutomatically() && controller->CanLockScreen(); } // One-shot class that runs a callback after all compositors start and // complete two compositing cycles. This should ensure that buffer swap with the // current UI has happened. // After the first compositing cycle, the display compositor starts drawing the // UI changes, and schedules a buffer swap. Given that the display compositor // will not start drawing the next frame before the previous swap happens, when // the second compositing cycle ends, it should be safe to assume the required // buffer swap happened at that point. // Note that the compositor watcher will wait for any pending wallpaper // animation for a root window to finish before it starts observing compositor // cycles, to ensure it picks up wallpaper state from after the animation ends, // and avoids issues like https://crbug.com/820436. class CompositorWatcher : public ui::CompositorObserver { public: // |callback| - called when all visible root window compositors complete // required number of compositing cycles. It will not be called after // CompositorWatcher instance is deleted, nor from the CompositorWatcher // destructor. explicit CompositorWatcher(base::OnceClosure callback) : callback_(std::move(callback)), compositor_observer_(this), weak_ptr_factory_(this) { Start(); } ~CompositorWatcher() override = default; // ui::CompositorObserver: void OnCompositingDidCommit(ui::Compositor* compositor) override { if (!pending_compositing_.count(compositor) || pending_compositing_[compositor].state != CompositingState::kWaitingForCommit) { return; } pending_compositing_[compositor].state = CompositingState::kWaitingForStarted; } void OnCompositingStarted(ui::Compositor* compositor, base::TimeTicks start_time) override { if (!pending_compositing_.count(compositor) || pending_compositing_[compositor].state != CompositingState::kWaitingForStarted) { return; } pending_compositing_[compositor].state = CompositingState::kWaitingForEnded; } void OnCompositingEnded(ui::Compositor* compositor) override { if (!pending_compositing_.count(compositor)) return; CompositorInfo& compositor_info = pending_compositing_[compositor]; if (compositor_info.state != CompositingState::kWaitingForEnded) return; compositor_info.observed_cycles++; if (compositor_info.observed_cycles < kRequiredCompositingCycles) { compositor_info.state = CompositingState::kWaitingForCommit; compositor->ScheduleDraw(); return; } compositor_observer_.Remove(compositor); pending_compositing_.erase(compositor); RunCallbackIfAllCompositingEnded(); } void OnCompositingLockStateChanged(ui::Compositor* compositor) override {} void OnCompositingChildResizing(ui::Compositor* compositor) override {} void OnCompositingShuttingDown(ui::Compositor* compositor) override { compositor_observer_.Remove(compositor); pending_compositing_.erase(compositor); RunCallbackIfAllCompositingEnded(); } private: // CompositorWatcher observes compositors for compositing events, in order to // determine whether compositing cycles end for all root window compositors. // This enum is used to track this cycle. Compositing goes through the // following states: DidCommit -> CompositingStarted -> CompositingEnded. enum class CompositingState { kWaitingForWallpaperAnimation, kWaitingForCommit, kWaitingForStarted, kWaitingForEnded, }; struct CompositorInfo { // State of the current compositing cycle. CompositingState state = CompositingState::kWaitingForCommit; // Number of observed compositing cycles. int observed_cycles = 0; }; // Number of compositing cycles that have to complete for each compositor // in order for a CompositorWatcher to run the callback. static constexpr int kRequiredCompositingCycles = 2; // Starts observing all visible root window compositors. void Start() { for (aura::Window* window : Shell::GetAllRootWindows()) { ui::Compositor* compositor = window->GetHost()->compositor(); if (!compositor->IsVisible()) continue; DCHECK(!pending_compositing_.count(compositor)); compositor_observer_.Add(compositor); pending_compositing_[compositor].state = CompositingState::kWaitingForWallpaperAnimation; WallpaperWidgetController* wallpaper_widget_controller = RootWindowController::ForWindow(window) ->wallpaper_widget_controller(); if (wallpaper_widget_controller->IsAnimating()) { wallpaper_widget_controller->AddPendingAnimationEndCallback( base::BindOnce(&CompositorWatcher::StartObservingCompositing, weak_ptr_factory_.GetWeakPtr(), compositor)); } else { StartObservingCompositing(compositor); } } // Post task to make sure callback is not invoked synchronously as watcher // is started. base::ThreadTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::BindOnce(&CompositorWatcher::RunCallbackIfAllCompositingEnded, weak_ptr_factory_.GetWeakPtr())); } // Called when the wallpaper animations end for the root window associated // with the compositor. It starts observing the compositor's compositing // cycles. void StartObservingCompositing(ui::Compositor* compositor) { if (!pending_compositing_.count(compositor) || pending_compositing_[compositor].state != CompositingState::kWaitingForWallpaperAnimation) { return; } pending_compositing_[compositor].state = CompositingState::kWaitingForCommit; // Schedule a draw to force at least one more compositing cycle. compositor->ScheduleDraw(); } // If all observed root window compositors have gone through a compositing // cycle, runs |callback_|. void RunCallbackIfAllCompositingEnded() { if (pending_compositing_.empty() && callback_) std::move(callback_).Run(); } base::OnceClosure callback_; // Per-compositor compositing state tracked by |this|. The map will // not contain compositors that were not visible at the time the // CompositorWatcher was started - the main purpose of tracking compositing // state is to determine whether compositors can be safely stopped (i.e. their // visibility set to false), so there should be no need for tracking // compositors that were hidden to start with. std::map<ui::Compositor*, CompositorInfo> pending_compositing_; ScopedObserver<ui::Compositor, ui::CompositorObserver> compositor_observer_; base::WeakPtrFactory<CompositorWatcher> weak_ptr_factory_; DISALLOW_COPY_AND_ASSIGN(CompositorWatcher); }; } // namespace PowerEventObserver::PowerEventObserver() : lock_state_(Shell::Get()->session_controller()->IsScreenLocked() ? LockState::kLocked : LockState::kUnlocked), session_observer_(this) { chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver( this); } PowerEventObserver::~PowerEventObserver() { chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RemoveObserver( this); } void PowerEventObserver::OnLockAnimationsComplete() { VLOG(1) << "Screen locker animations have completed."; if (lock_state_ != LockState::kLocking) return; lock_state_ = LockState::kLockedCompositingPending; // If suspending, run pending animations to the end immediately, as there is // no point in waiting for them to finish given that the device is suspending. if (displays_suspended_callback_) EndPendingWallpaperAnimations(); // The |compositor_watcher_| is owned by this, and the callback passed to it // won't be called after |compositor_watcher_|'s destruction, so // base::Unretained is safe here. compositor_watcher_ = std::make_unique<CompositorWatcher>( base::BindOnce(&PowerEventObserver::OnCompositorsReadyForSuspend, base::Unretained(this))); } void PowerEventObserver::SuspendImminent( power_manager::SuspendImminent::Reason reason) { suspend_in_progress_ = true; displays_suspended_callback_ = chromeos::DBusThreadManager::Get() ->GetPowerManagerClient() ->GetSuspendReadinessCallback(FROM_HERE); // Stop compositing immediately if // * the screen lock flow has already completed // * screen is not locked, and should remain unlocked during suspend if (lock_state_ == LockState::kLocked || (lock_state_ == LockState::kUnlocked && !ShouldLockOnSuspend())) { StopCompositingAndSuspendDisplays(); } else { // If screen is getting locked during suspend, delay suspend until screen // lock finishes, and post-lock frames get picked up by display compositors. if (lock_state_ == LockState::kUnlocked) { VLOG(1) << "Requesting screen lock from PowerEventObserver"; lock_state_ = LockState::kLocking; Shell::Get()->lock_state_controller()->LockWithoutAnimation(); } else if (lock_state_ != LockState::kLocking) { // If the screen is still being locked (i.e. in kLocking state), // EndPendingWallpaperAnimations() will be called in // OnLockAnimationsComplete(). EndPendingWallpaperAnimations(); } } } void PowerEventObserver::SuspendDone(const base::TimeDelta& sleep_duration) { suspend_in_progress_ = false; // TODO(derat): After mus exposes a method for resuming displays, call it // here: http://crbug.com/692193 if (Shell::GetAshConfig() != Config::MASH) Shell::Get()->display_configurator()->ResumeDisplays(); Shell::Get()->system_tray_model()->clock()->NotifyRefreshClock(); // If the suspend request was being blocked while waiting for the lock // animation to complete, clear the blocker since the suspend has already // completed. This prevents rendering requests from being blocked after a // resume if the lock screen took too long to show. displays_suspended_callback_.Reset(); StartRootWindowCompositors(); } void PowerEventObserver::OnLockStateChanged(bool locked) { if (locked) { lock_state_ = LockState::kLocking; // The screen is now locked but the pending suspend, if any, will be blocked // until all the animations have completed. if (displays_suspended_callback_) { VLOG(1) << "Screen locked due to suspend"; } else { VLOG(1) << "Screen locked without suspend"; } } else { lock_state_ = LockState::kUnlocked; compositor_watcher_.reset(); if (suspend_in_progress_) { LOG(WARNING) << "Screen unlocked during suspend"; // If screen gets unlocked during suspend, which could theoretically // happen if the user initiated unlock just as device started unlocking // (though, it seems unlikely this would be encountered in practice), // relock the device if required. Otherwise, if suspend is blocked due to // screen locking, unblock it. if (ShouldLockOnSuspend()) { lock_state_ = LockState::kLocking; Shell::Get()->lock_state_controller()->LockWithoutAnimation(); } else if (displays_suspended_callback_) { StopCompositingAndSuspendDisplays(); } } } } void PowerEventObserver::StartRootWindowCompositors() { for (aura::Window* window : Shell::GetAllRootWindows()) { ui::Compositor* compositor = window->GetHost()->compositor(); if (!compositor->IsVisible()) compositor->SetVisible(true); } } void PowerEventObserver::StopCompositingAndSuspendDisplays() { DCHECK(displays_suspended_callback_); DCHECK(!compositor_watcher_.get()); for (aura::Window* window : Shell::GetAllRootWindows()) { ui::Compositor* compositor = window->GetHost()->compositor(); compositor->SetVisible(false); } ui::UserActivityDetector::Get()->OnDisplayPowerChanging(); // TODO(derat): After mus exposes a method for suspending displays, call it // here: http://crbug.com/692193 if (Shell::GetAshConfig() != Config::MASH) { Shell::Get()->display_configurator()->SuspendDisplays( base::Bind(&OnSuspendDisplaysCompleted, base::Passed(&displays_suspended_callback_))); } else { std::move(displays_suspended_callback_).Run(); } } void PowerEventObserver::EndPendingWallpaperAnimations() { for (aura::Window* window : Shell::GetAllRootWindows()) { WallpaperWidgetController* wallpaper_widget_controller = RootWindowController::ForWindow(window)->wallpaper_widget_controller(); if (wallpaper_widget_controller->IsAnimating()) wallpaper_widget_controller->EndPendingAnimation(); } } void PowerEventObserver::OnCompositorsReadyForSuspend() { compositor_watcher_.reset(); lock_state_ = LockState::kLocked; if (displays_suspended_callback_) StopCompositingAndSuspendDisplays(); } } // namespace ash
[ "arnaud@geometry.ee" ]
arnaud@geometry.ee
723f720dff4905239abc9d46da2a4c826c953c08
f065801a4839ac08672683b692524d9f604b65f3
/modules/ahci/ahci.h
11855688467597e42c2a5924a815014b2f180586
[ "BSD-3-Clause" ]
permissive
PoisonNinja/Pepper
4f48a06a401d6617496c69fe6550ff8e4dded5b3
ee5773006a02ab05459491c62eab0413994cfe80
refs/heads/master
2022-01-14T16:11:28.079999
2021-12-30T03:34:27
2021-12-30T03:34:27
91,926,989
2
1
null
null
null
null
UTF-8
C++
false
false
10,171
h
#pragma once #include <cpu/interrupt.h> #include <fs/block.h> #include <mm/dma.h> #include <types.h> using FIS_TYPE = enum { FIS_TYPE_REG_H2D = 0x27, // Register FIS - host to device FIS_TYPE_REG_D2H = 0x34, // Register FIS - device to host FIS_TYPE_DMA_ACT = 0x39, // DMA activate FIS - device to host FIS_TYPE_DMA_SETUP = 0x41, // DMA setup FIS - bidirectional FIS_TYPE_DATA = 0x46, // Data FIS - bidirectional FIS_TYPE_BIST = 0x58, // BIST activate FIS - bidirectional FIS_TYPE_PIO_SETUP = 0x5F, // PIO setup FIS - device to host FIS_TYPE_DEV_BITS = 0xA1, // Set device bits FIS - device to host }; #define ATA_STATUS_ERR (1 << 0) /* Error. */ #define ATA_STATUS_DRQ (1 << 3) /* Data Request. */ #define ATA_STATUS_DF (1 << 5) /* Device Fault. */ #define ATA_STATUS_DRDY (1 << 6) /* Device Ready. */ #define ATA_STATUS_BSY (1 << 7) /* Busy. */ /** ATA Commands. */ #define ATA_CMD_READ_DMA 0xC8 /**< READ DMA. */ #define ATA_CMD_READ_DMA_EXT 0x25 /**< READ DMA EXT. */ #define ATA_CMD_READ_SECTORS 0x20 /**< READ SECTORS. */ #define ATA_CMD_READ_SECTORS_EXT 0x24 /**< READ SECTORS EXT. */ #define ATA_CMD_WRITE_DMA 0xCA /**< WRITE DMA. */ #define ATA_CMD_WRITE_DMA_EXT 0x35 /**< WRITE DMA EXT. */ #define ATA_CMD_WRITE_SECTORS 0x30 /**< WRITE SECTORS. */ #define ATA_CMD_WRITE_SECTORS_EXT 0x34 /**< WRITE SECTORS EXT. */ #define ATA_CMD_PACKET 0xA0 /**< PACKET. */ #define ATA_CMD_IDENTIFY_PACKET 0xA1 /**< IDENTIFY PACKET DEVICE. */ #define ATA_CMD_FLUSH_CACHE 0xE7 /**< FLUSH CACHE. */ #define ATA_CMD_FLUSH_CACHE_EXT 0xEA /**< FLUSH CACHE EXT. */ #define ATA_CMD_IDENTIFY 0xEC /**< IDENTIFY DEVICE. */ /** Bits in the Port x Interrupt Enable register. */ #define PXIE_DHRE (1 << 0) /**< Device to Host Register Enable. */ #define PXIE_PSE (1 << 1) /**< PIO Setup FIS Enable. */ #define PXIE_DSE (1 << 2) /**< DMA Setup FIS Enable. */ #define PXIE_SDBE (1 << 3) /**< Set Device Bits Enable. */ #define PXIE_UFE (1 << 4) /**< Unknown FIS Enable. */ #define PXIE_DPE (1 << 5) /**< Descriptor Processed Enable. */ #define PXIE_PCE (1 << 6) /**< Port Connect Change Enable. */ #define PXIE_DMPE (1 << 7) /**< Device Mechanical Presence Enable. */ #define PXIE_PRCE (1 << 22) /**< PhyRdy Change Enable. */ #define PXIE_IPME (1 << 23) /**< Incorrect Port Multiplier Enable. */ #define PXIE_OFE (1 << 24) /**< Overflow Enable. */ #define PXIE_INFE (1 << 26) /**< Interface Non-Fatal Error Enable. */ #define PXIE_IFE (1 << 27) /**< Interface Fatal Error Enable. */ #define PXIE_HBDE (1 << 28) /**< Host Bus Data Error Enable. */ #define PXIE_HBFE (1 << 29) /**< Host Bus Fatal Error Enable. */ #define PXIE_TFEE (1 << 30) /**< Task File Error Enable. */ #define PXIE_CPDE (1 << 31) /**< Cold Port Detect Enable. */ #define PORT_INTR_ERROR \ (PXIE_UFE | PXIE_PCE | PXIE_PRCE | PXIE_IPME | PXIE_OFE | PXIE_INFE | \ PXIE_IFE | PXIE_HBDE | PXIE_HBFE | PXIE_TFEE) constexpr uint32_t PXCMD_ST = 1 << 0; /* 0x00000001 */ constexpr uint32_t PXCMD_SUD = 1 << 1; /* 0x00000002 */ constexpr uint32_t PXCMD_POD = 1 << 2; /* 0x00000004 */ constexpr uint32_t PXCMD_CLO = 1 << 3; /* 0x00000008 */ constexpr uint32_t PXCMD_FRE = 1 << 4; /* 0x00000010 */ constexpr uint32_t PXCMD_CSS(uint32_t val) { return (val >> 8) % 32; } constexpr uint32_t PXCMD_MPSS = 1 << 13; /* 0x00002000 */ constexpr uint32_t PXCMD_FR = 1 << 14; /* 0x00004000 */ constexpr uint32_t PXCMD_CR = 1 << 15; /* 0x00008000 */ constexpr uint32_t PXCMD_CPS = 1 << 16; /* 0x00010000 */ constexpr uint32_t PXCMD_PMA = 1 << 17; /* 0x00020000 */ constexpr uint32_t PXCMD_HPCP = 1 << 18; /* 0x00040000 */ constexpr uint32_t PXCMD_MPSP = 1 << 19; /* 0x00080000 */ constexpr uint32_t PXCMD_CPD = 1 << 20; /* 0x00100000 */ constexpr uint32_t PXCMD_ESP = 1 << 21; /* 0x00200000 */ constexpr uint32_t PXCMD_FBSCP = 1 << 22; /* 0x00400000 */ constexpr uint32_t PXCMD_APSTE = 1 << 23; /* 0x00800000 */ constexpr uint32_t PXCMD_ATAPI = 1 << 24; /* 0x01000000 */ constexpr uint32_t PXCMD_DLAE = 1 << 25; /* 0x02000000 */ constexpr uint32_t PXCMD_ALPE = 1 << 26; /* 0x04000000 */ constexpr uint32_t PXCMD_ASP = 1 << 27; /* 0x08000000 */ constexpr uint32_t PXCMD_ICC(uint32_t val) { return (val >> 28) % 16; } #define AHCI_TYPE_NULL 0x0 #define AHCI_TYPE_SATA 0x00000101 #define AHCI_TYPE_ATAPI 0xEB140101 #define AHCI_TYPE_SEMB 0xC33C0101 #define AHCI_TYPE_PM 0x96690101 #define AHCI_PRDT_MAX_MEMORY 0x1000 #define AHCI_BLOCK_SIZE 512 struct hba_port { uint32_t command_list_base_low; uint32_t command_list_base_high; uint32_t fis_base_low; uint32_t fis_base_high; uint32_t interrupt_status; uint32_t interrupt_enable; uint32_t command; uint32_t reserved_0; uint32_t task_file_data; uint32_t signature; uint32_t sata_status; uint32_t sata_control; uint32_t sata_error; uint32_t sata_active; uint32_t command_issue; uint32_t sata_notification; uint32_t fis_based_switch_control; uint32_t reserved_1[11]; uint32_t vendor[4]; } __attribute__((packed)); constexpr uint32_t GHC_AE = 1U << 31; constexpr uint32_t GHC_MRSM = 1U << 2; constexpr uint32_t GHC_IE = 1U << 1; constexpr uint32_t GHC_HR = 1U << 0; constexpr uint32_t CAP_S64A = 1U << 31; constexpr uint32_t capability_ncs(uint32_t capability) { return (capability & 0x1F00) >> 8; } struct hba_memory { uint32_t capability; uint32_t global_host_control; uint32_t interrupt_status; uint32_t port_implemented; uint32_t version; uint32_t ccc_control; uint32_t ccc_ports; uint32_t em_location; uint32_t em_control; uint32_t ext_capabilities; uint32_t bohc; uint8_t reserved[0xA0 - 0x2C]; uint8_t vendor[0x100 - 0xA0]; struct hba_port ports[32]; } __attribute__((packed)); struct hba_received_fis { uint8_t fis_ds[0x1C]; uint8_t pad_0[0x4]; uint8_t fis_ps[0x14]; uint8_t pad_1[0xC]; uint8_t fis_r[0x14]; uint8_t pad_2[0x4]; uint8_t fis_sdb[0x8]; uint8_t ufis[0x40]; uint8_t reserved[0x60]; } __attribute__((packed)); struct hba_command_header { uint8_t fis_length : 5; uint8_t atapi : 1; uint8_t write : 1; uint8_t prefetchable : 1; uint8_t reset : 1; uint8_t bist : 1; uint8_t clear_busy_upon_r_ok : 1; uint8_t reserved_0 : 1; uint8_t pmport : 4; uint16_t prdt_len; uint32_t prdb_count; uint32_t command_table_base_low; uint32_t command_table_base_high; uint32_t reserved_1[4]; } __attribute__((packed)); struct hba_prdt_entry { uint32_t data_base_low; uint32_t data_base_high; uint32_t reserved_0; uint32_t byte_count : 22; uint32_t reserved_1 : 9; uint32_t interrupt_on_complete : 1; } __attribute__((packed)); struct fis_h2d { uint8_t type; uint8_t pmport : 4; uint8_t reserved_0 : 3; uint8_t c : 1; uint8_t command; uint8_t feature_low; uint8_t lba0; uint8_t lba1; uint8_t lba2; uint8_t device; uint8_t lba3; uint8_t lba4; uint8_t lba5; uint8_t feature_high; uint8_t count_low; uint8_t count_high; uint8_t icc; uint8_t control; uint8_t reserved_1[0x4]; } __attribute__((packed)); struct hba_command_table { uint8_t command_fis[0x40]; uint8_t acmd[0x10]; uint8_t reserved[0x30]; struct hba_prdt_entry prdt[1]; } __attribute__((packed)); /* * ATA identify response data, per the ATA spec at * http://www.t13.org/Documents/UploadedDocuments/docs2009/d2015r1a-ATAATAPI_Command_Set_-_2_ACS-2.pdf * * TODO: Move this to generic ATA header */ enum class ahci_identify { ATA_GENERAL_CONFIGURATION = 0, ATA_SPECIFIC_CONFIGURATION = 2, ATA_SERIAL_NUMBER = 10, ATA_FIRMWARE_REVISION = 23, ATA_MODEL_NUMBER = 27, ATA_TRUSTED_COMPUTING = 48, ATA_CAPABILITY = 49, ATA_FIELD_VALID = 53, ATA_MULTIPLE_SECTOR = 59, ATA_LBA28_CAPACITY = 60, ATA_MULTIWORD_MODES = 63, ATA_PIO_MODES = 64, ATA_MAJOR_VERSION = 80, ATA_MINOR_VERSION = 81, ATA_COMMANDSET_1 = 82, ATA_COMMANDSET_2 = 83, ATA_COMMANDSET_EXTENDED = 84, ATA_CFS_ENABLE_1 = 85, ATA_CFS_ENABLE_2 = 86, ATA_CFS_DEFAULT = 87, ATA_UDMA_MODES = 88, ATA_HW_RESET = 93, ATA_ACOUSTIC = 94, ATA_LBA48_CAPACITY = 100, ATA_REMOVABLE = 127, ATA_SECURITY_STATUS = 128, ATA_CFA_POWER_MODE = 160, ATA_MEDIA_SERIAL_NUMBER = 176, ATA_INTEGRITY = 255, }; namespace pci { class device; } // namespace pci class ahci_controller; class ahci_port : public filesystem::block_device { public: ahci_port(ahci_controller* c, volatile struct hba_port* port); virtual ~ahci_port() override; virtual bool request(filesystem::block_request* request) override; virtual filesystem::sector_t sector_size() override; virtual size_t sg_max_size() override; virtual size_t sg_max_count() override; void handle(); private: int get_free_slot(); bool send_command(uint8_t command, size_t num_blocks, uint8_t write, uint64_t lba, libcxx::unique_ptr<memory::dma::sglist>& sglist); ahci_controller* controller; uint16_t* identify; volatile struct hba_port* port; memory::dma::region command_tables[32]; memory::dma::region fb; memory::dma::region clb; // Precache some geometry stuff to save lookups bool is_lba48; }; class ahci_controller { public: ahci_controller(pci::device* d, dev_t major); void init(); size_t get_ncs(); bool is_64bit(); private: void handler(int, void* data, struct interrupt_context* /* ctx */); dev_t major; ahci_port* ports[32]; volatile struct hba_memory* hba; pci::device* device; interrupt::handler handler_data; };
[ "syscallrax@gmail.com" ]
syscallrax@gmail.com
ae7c5e7701da36e38982aa3553911b0084aab8f7
4836ee9e77b6e1c23fbef4db492c147b88267a06
/Algorithm_Training/Blue/Lecture10/5/main.cpp
4da51eab1dc9a1485777da2d73e8dd81ba749ff5
[]
no_license
namnh97/CCode
33da753e575acabea37f69f8ab8a7c2e0d7458cf
bdf85622206b4a8a8ed46867ee15e000f020849b
refs/heads/master
2022-08-16T06:46:43.741051
2022-07-27T02:44:03
2022-07-27T02:44:03
165,805,230
0
0
null
null
null
null
UTF-8
C++
false
false
1,776
cpp
//https://open.kattis.com/problems/shortestpath3 #include<bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair #define pii pair<int, int> using namespace std; const int MAX = 1001; const int INF = 1e9; struct Edge { int from; int to; int weight; }; vector<Edge> graph; int m, n, q, s; int dist[MAX]; void Bellman(int src) { fill(dist, dist + MAX, INF); dist[src] = 0; for (int i = 0; i < n - 1; i++) { for (auto &edge : graph) { int u = edge.from; int v = edge.to; int w = edge.weight; if (dist[u] != INF && dist[v] > dist[u] + w) { dist[v] = dist[u] + w; } } } for (int i = 0; i < n - 1; i++) { for (auto &edge : graph) { int u = edge.from; int v = edge.to; int w = edge.weight; if (dist[u] != INF && dist[v] > dist[u] + w) { dist[v] = -INF; } } } } void solve() { while (cin >> n >> m >> q >> s && n >= 0 && m >= 0 && q >= 0 && s >= 0) { graph.clear(); for (int i = 0; i < m; i++) { int u, v, w; cin >> u >> v >> w; graph.pb(Edge{u, v, w}); } Bellman(s); for (int i = 0; i < q; i++) { int des; cin >> des; if (dist[des] == INF) { cout << "Impossible" << endl; } else if (dist[des] == -INF) { cout << "-Infinity" << endl; } else { cout << dist[des] << endl; } } cout << endl; } } int main(int argc, char** argv){ #ifndef ONLINE_JUDGE freopen(argv[1], "r", stdin); #endif solve(); return 0; }
[ "namnh997@gmail.com" ]
namnh997@gmail.com
4e2842c37ea1870cda63f375ea9344c09f2a24b2
1af5af91c0d692f7814f57441bee61a3b9ad1f1e
/70-climbing-stairs.cpp
3e505f96131019621398096e95bc9f2610768237
[]
no_license
raiseyang/leetcode
b064cd22fc09cfcf562a886e1e12d752ee2e7c37
4316dab854b17b3c26beb9c016539d4c2067f8e1
refs/heads/master
2022-02-21T19:12:52.990374
2019-09-07T08:23:52
2019-09-07T08:23:52
null
0
0
null
null
null
null
UTF-8
C++
false
false
290
cpp
class Solution { public: int climbStairs(int n) { int c1 = 1, c2 = 2; if (n < 3) return n; for (int i = 3; i <= n; ++i) { int tmp = c1 + c2; c1 = c2; c2 = tmp; } return c2; } };
[ "maxime.limy@gmail.com" ]
maxime.limy@gmail.com
f52f4957cce501086d0456cbd649fa19909bd5bc
c6b483cc2d7bc9eb6dc5c08ae92aa55ff9b3a994
/examples/adaptor/RawMap.cpp
74ac91e11f72383e5d23dc589d2af8fdb3b84111
[ "Apache-2.0" ]
permissive
oguzdemir/hazelcast-cpp-client
ebffc7137a3a14b9fc5d96e1a1b0eac8aac1e60f
95c4687634a8ac4886d0a9b9b4c17622225261f0
refs/heads/master
2021-01-21T02:53:05.197319
2016-08-24T21:08:14
2016-08-24T21:08:14
63,674,978
0
0
null
2016-07-19T08:16:24
2016-07-19T08:16:23
null
UTF-8
C++
false
false
4,278
cpp
/* * Copyright (c) 2008-2015, Hazelcast, Inc. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ // // Created by İhsan Demir on 21/12/15. // #include <hazelcast/client/HazelcastClient.h> #include <hazelcast/client/adaptor/RawPointerMap.h> #include <hazelcast/client/query/GreaterLessPredicate.h> #include <hazelcast/client/query/QueryConstants.h> class MyEntryListener : public hazelcast::client::EntryListener<std::string, std::string> { public: void entryAdded(const hazelcast::client::EntryEvent<std::string, std::string> &event) { std::cout << "[entryAdded] " << event << std::endl; } void entryRemoved(const hazelcast::client::EntryEvent<std::string, std::string> &event) { std::cout << "[entryRemoved] " << event << std::endl; } void entryUpdated(const hazelcast::client::EntryEvent<std::string, std::string> &event) { std::cout << "[entryAdded] " << event << std::endl; } void entryEvicted(const hazelcast::client::EntryEvent<std::string, std::string> &event) { std::cout << "[entryUpdated] " << event << std::endl; } void entryExpired(const hazelcast::client::EntryEvent<std::string, std::string> &event) { std::cout << "[entryExpired] " << event << std::endl; } void entryMerged(const hazelcast::client::EntryEvent<std::string, std::string> &event) { std::cout << "[entryMerged] " << event << std::endl; } void mapEvicted(const hazelcast::client::MapEvent &event) { std::cout << "[mapEvicted] " << event << std::endl; } void mapCleared(const hazelcast::client::MapEvent &event) { std::cout << "[mapCleared] " << event << std::endl; } }; int main() { hazelcast::client::ClientConfig config; hazelcast::client::HazelcastClient hz(config); hazelcast::client::IMap<std::string, std::string> m = hz.getMap<std::string, std::string>("map"); hazelcast::client::adaptor::RawPointerMap<std::string, std::string> map(m); map.put("1", "Tokyo"); map.put("2", "Paris"); map.put("3", "New York"); std::cout << "Finished loading map" << std::endl; std::auto_ptr<hazelcast::client::DataArray<std::string> > vals = map.values(); std::auto_ptr<hazelcast::client::EntryArray<std::string, std::string> > entries = map.entrySet(); std::cout << "There are " << vals->size() << " values in the map" << std::endl; std::cout << "There are " << entries->size() << " entries in the map" << std::endl; for (size_t i = 0; i < entries->size(); ++i) { const std::string * key = entries->getKey(i); if ((std::string *) NULL == key) { std::cout << "The key at index " << i << " is NULL" << std::endl; } else { std::auto_ptr<std::string> val = entries->releaseValue(i); std::cout << "(Key, Value) for index " << i << " is: (" << *key << ", " << (val.get() == NULL ? "NULL" : *val) << ")" << std::endl; } } MyEntryListener listener; std::string listenerId = map.addEntryListener(listener, true); std::cout << "EntryListener registered" << std::endl; // wait for modifymap executable to run hazelcast::util::sleep(10); map.removeEntryListener(listenerId); // Continuous Query example // Register listener with predicate // Only listen events for entries with key >= 7 listenerId = map.addEntryListener(listener, hazelcast::client::query::GreaterLessPredicate<int>( hazelcast::client::query::QueryConstants::getKeyAttributeName(), 7, true, false), true); // wait for modifymap executable to run hazelcast::util::sleep(10); map.removeEntryListener(listenerId); std::cout << "Finished" << std::endl; return 0; }
[ "ihsan@hazelcast.com" ]
ihsan@hazelcast.com
e4730fd370186636548afde99a9e63ee80d88c32
9b26f6ade6215662db0c706661f86f1a5a8713b7
/FrozenFlame/Game/Source/Objects/WizardEnemy.h
012ba7a9b7697a25031b7a16d803e1c387242e8a
[]
no_license
mbirky/FrozenFlame
d310c753f73bf092bd0e2fa9427b125c30bce568
4264bc86ee66a0c010642ecabf512c920a8082e3
refs/heads/main
2023-04-13T20:22:40.245502
2018-07-06T07:35:16
2018-07-06T07:35:16
361,937,727
0
0
null
null
null
null
UTF-8
C++
false
false
6,274
h
/*********************************************** * Filename: WizardEnemy.h * Date: 10/30/2012 * Mod. Date: 10/30/2012 * Mod. Initials: CM * Author: Charles Meade * Purpose: Function declarations for the wizard enemy object ************************************************/ #ifndef WIZARD_ENEMY_H #define WIZARD_ENEMY_H class CWorldManager; class CLevel; class CWizardSpawner; class CSpawner; #include "enemy.h" #include "../Renderer/Emitter.h" #include "CIceTrap.h" #include "CFireTrap.h" #include "SceneryObject.h" #include "IceEnemy.h" #include "FireEnemy.h" //#include "../Core/CWorldManager.h" enum WizardAnimations {RENEMY_IDLE = 3, RENEMY_WALK, RENEMY_ATTACK, RENEMY_DEATH}; enum WizardSubTypes {FIRST_STAGE,SECOND_STAGE,THIRD_STAGE,FOURTH_STAGE,FINAL_BOSS}; class CWizardEnemy : public CEnemy { private: int m_nNumTrapWavesCreated; int m_nWizardForm; int m_nWizardSubType; bool m_bIsAlive; bool m_bExhausted; float m_fTrapSpawnTimer; bool m_bEscaped; bool m_bDefeated; float m_fTotalHealth; float m_fFinalDeathTimer; float m_fDeathTimeLimit; bool m_bDeathCharging; bool m_bDeathExloding; bool m_bDeathExploded; TImage m_tShadow; int m_nShadowRenderID; CSceneryObject * m_pcBubble; CEmitter* m_pcFireEmitter; CEmitter* m_pcIceEmitter; vec3f m_tInitialPosition; vector<CIceTrap*> m_vIceTraps; vector<CFireTrap*> m_vFireTraps; CPlayerObject* m_pPlayer; CTimer m_tWizTimer; int m_nShapeID; // For Health // stuff for spawning enemies CLevel * m_pcCurrLevel; CIceEnemy * m_pcIceSpawned; CFireEnemy * m_pcFireSpawned; // crystals in final battle vector<CSpawner*> m_vpcWizardSpawners; // Emitters CEmitter * m_pcBubbleBurstEmitter; CEmitter * m_pcBubbleSheenEmitter; CEmitter * m_pcCrashEmitter; CEmitter * m_pcDeathBurstEmitter; CEmitter * m_pcDeathFlowEmitter; CEmitter * m_pcSmokeEmitter; CEmitter * m_pcTakeoffEmitter; CEmitter * m_pcSpawnEmitter; public: /***************************************************************** * CWizardEnemy(): Default constructor for the wizard enemy object * * * Ins: void * * Outs: void * * Returns: n/a * * Mod. Date: 10/30/2012 * Mod. Initials: CM *****************************************************************/ CWizardEnemy(void); /***************************************************************** * ~CWizardEnemy(): Default destructor for the wizard enemy object * * * Ins: void * * Outs: void * * Returns: n/a * * Mod. Date: 10/30/2012 * Mod. Initials: CM *****************************************************************/ ~CWizardEnemy(void); /***************************************************************** * Initialize(): The default funciton that sets all starting values for * this instance of the class * * Ins: void * * Outs: void * * Returns: void * * Mod. Date: 10/30/2012 * Mod. Initials: CM *****************************************************************/ void Initialize(void); /***************************************************************** * Reinitialize(): The default funciton that resets all starting values for * this instance of the class * * Ins: void * * Outs: void * * Returns: void * * Mod. Date: 10/30/2012 * Mod. Initials: CM *****************************************************************/ void Reinitialize(); /***************************************************************** * Update(): Updates all data for the class based off of time * * Ins: fElapsedTime * * Outs: void * * Returns: void * * Mod. Date: 10/30/2012 * Mod. Initials: CM *****************************************************************/ void Update(float fElapsedTime); /***************************************************************** * Uninitialize(): returns the object to the starting state * * Ins: void * * Outs: void * * Returns: void * * Mod. Date: 11/03/2012 * Mod. Initials: CM *****************************************************************/ void Uninitialize(); /***************************************************************** * OnAttack(): runs any logic when this object gets attacked by something * * Ins: void * * Outs: nDamage nElementType * * Returns: void * * Mod. Date: 02/04/2013 * Mod. Initials: BRG *****************************************************************/ void OnAttack(int nDamage,int nElementType); bool GetIsAlive(void) {return m_bIsAlive;} int GetWizardForm() {return m_nWizardForm;} void SetWizardForm(int _nWizardForm) {m_nWizardForm = _nWizardForm;} vec3f GetInitialPosition() {return m_tInitialPosition;} void SetInitialPosition(vec3f _tInitialPosition) {m_tInitialPosition = _tInitialPosition;} bool GetExhausted() {return m_bExhausted;} void SetExhausted(bool _bExhausted) {m_bExhausted = _bExhausted;} void SetWizardSubtype(int nSubType) {m_nWizardSubType = nSubType;}; int GetWizardSubtype() {return m_nWizardSubType;} bool GetEscaped(void) {return m_bEscaped;} void SetEscaped(bool _bEscaped) {m_bEscaped = _bEscaped;} bool GetIsDefeated(void) {return m_bDefeated;} void SetIsDefeated(bool _bDefeated) {m_bDefeated = _bDefeated;} CSceneryObject * GetBubble() {return m_pcBubble;} void HideBubble() { CView::SetIsVisible(GetBubble()->GetRenderID(),false);} void ShowBubble() { CView::SetIsVisible(GetBubble()->GetRenderID(),true);} float GetWizardTime() {return m_tWizTimer.GetElapsedTime();} void SpawnEnemies(); void CrystalDisabled(); void ReactivateCrystals(); void IncrementPhase(); void PushBackWizardSpawner(CSpawner * pcSpawner); void ClearWizardSpawners(); void SetTotalHealth(float fHealth) {m_fTotalHealth = fHealth; }; float GetTotalHealth() {return m_fTotalHealth;}; void SetBubbleBurstEmitterActive(bool bActive); void SetBubbleSheenEmitterActive(bool bActive); void SetCrashEmitterActive(bool bActive); void SetDeathBurstEmitterActive(bool bActive); void SetDeathFlowEmitterActive(bool bActive); void SetSmokeEmitterActive(bool bActive); void SetTakeoffEmitterActive(bool bActive); void SetSpawnEmitterActive(bool bActive); }; #endif
[ "danielmlima@fullsail.edu" ]
danielmlima@fullsail.edu
df982ddf40d60bf5dfb998563a278ce5d4c72d32
7810b13f010d84cbe7f40586ecb3a5d60399b821
/google/protobuf/unittest_well_known_types.pb.h
bb5f1160221ee79d69c28cfda47a02a4932e3569
[]
no_license
chrak/MyTestServer
091d9be4d0d9653abc3750ab2b5213b716afc983
189146e3b4d8aeefc93eae6efb14459e25cd3994
refs/heads/master
2022-05-02T13:45:21.738700
2022-04-11T06:35:26
2022-04-11T06:35:26
144,518,444
5
4
null
null
null
null
UTF-8
C++
false
true
180,639
h
// Generated by the protocol buffer compiler. DO NOT EDIT! // source: google/protobuf/unittest_well_known_types.proto #ifndef PROTOBUF_google_2fprotobuf_2funittest_5fwell_5fknown_5ftypes_2eproto__INCLUDED #define PROTOBUF_google_2fprotobuf_2funittest_5fwell_5fknown_5ftypes_2eproto__INCLUDED #include <string> #include <google/protobuf/stubs/common.h> #if GOOGLE_PROTOBUF_VERSION < 3001000 #error This file was generated by a newer version of protoc which is #error incompatible with your Protocol Buffer headers. Please update #error your headers. #endif #if 3001000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION #error This file was generated by an older version of protoc which is #error incompatible with your Protocol Buffer headers. Please #error regenerate this file with a newer version of protoc. #endif #include <google/protobuf/arena.h> #include <google/protobuf/arenastring.h> #include <google/protobuf/generated_message_util.h> #include <google/protobuf/metadata.h> #include <google/protobuf/message.h> #include <google/protobuf/repeated_field.h> // IWYU pragma: export #include <google/protobuf/extension_set.h> // IWYU pragma: export #include <google/protobuf/map.h> #include <google/protobuf/map_field_inl.h> #include <google/protobuf/unknown_field_set.h> #include <google/protobuf/any.pb.h> #include <google/protobuf/api.pb.h> #include <google/protobuf/duration.pb.h> #include <google/protobuf/empty.pb.h> #include <google/protobuf/field_mask.pb.h> #include <google/protobuf/source_context.pb.h> #include <google/protobuf/struct.pb.h> #include <google/protobuf/timestamp.pb.h> #include <google/protobuf/type.pb.h> #include <google/protobuf/wrappers.pb.h> // @@protoc_insertion_point(includes) namespace google { namespace protobuf { class Any; class AnyDefaultTypeInternal; extern AnyDefaultTypeInternal _Any_default_instance_; class Api; class ApiDefaultTypeInternal; extern ApiDefaultTypeInternal _Api_default_instance_; class BoolValue; class BoolValueDefaultTypeInternal; extern BoolValueDefaultTypeInternal _BoolValue_default_instance_; class BytesValue; class BytesValueDefaultTypeInternal; extern BytesValueDefaultTypeInternal _BytesValue_default_instance_; class DoubleValue; class DoubleValueDefaultTypeInternal; extern DoubleValueDefaultTypeInternal _DoubleValue_default_instance_; class Duration; class DurationDefaultTypeInternal; extern DurationDefaultTypeInternal _Duration_default_instance_; class Empty; class EmptyDefaultTypeInternal; extern EmptyDefaultTypeInternal _Empty_default_instance_; class Enum; class EnumDefaultTypeInternal; extern EnumDefaultTypeInternal _Enum_default_instance_; class EnumValue; class EnumValueDefaultTypeInternal; extern EnumValueDefaultTypeInternal _EnumValue_default_instance_; class Field; class FieldDefaultTypeInternal; extern FieldDefaultTypeInternal _Field_default_instance_; class FieldMask; class FieldMaskDefaultTypeInternal; extern FieldMaskDefaultTypeInternal _FieldMask_default_instance_; class FloatValue; class FloatValueDefaultTypeInternal; extern FloatValueDefaultTypeInternal _FloatValue_default_instance_; class Int32Value; class Int32ValueDefaultTypeInternal; extern Int32ValueDefaultTypeInternal _Int32Value_default_instance_; class Int64Value; class Int64ValueDefaultTypeInternal; extern Int64ValueDefaultTypeInternal _Int64Value_default_instance_; class ListValue; class ListValueDefaultTypeInternal; extern ListValueDefaultTypeInternal _ListValue_default_instance_; class Method; class MethodDefaultTypeInternal; extern MethodDefaultTypeInternal _Method_default_instance_; class Mixin; class MixinDefaultTypeInternal; extern MixinDefaultTypeInternal _Mixin_default_instance_; class Option; class OptionDefaultTypeInternal; extern OptionDefaultTypeInternal _Option_default_instance_; class SourceContext; class SourceContextDefaultTypeInternal; extern SourceContextDefaultTypeInternal _SourceContext_default_instance_; class StringValue; class StringValueDefaultTypeInternal; extern StringValueDefaultTypeInternal _StringValue_default_instance_; class Struct; class StructDefaultTypeInternal; extern StructDefaultTypeInternal _Struct_default_instance_; class Timestamp; class TimestampDefaultTypeInternal; extern TimestampDefaultTypeInternal _Timestamp_default_instance_; class Type; class TypeDefaultTypeInternal; extern TypeDefaultTypeInternal _Type_default_instance_; class UInt32Value; class UInt32ValueDefaultTypeInternal; extern UInt32ValueDefaultTypeInternal _UInt32Value_default_instance_; class UInt64Value; class UInt64ValueDefaultTypeInternal; extern UInt64ValueDefaultTypeInternal _UInt64Value_default_instance_; class Value; class ValueDefaultTypeInternal; extern ValueDefaultTypeInternal _Value_default_instance_; } // namespace protobuf } // namespace google namespace protobuf_unittest { class MapWellKnownTypes; class MapWellKnownTypesDefaultTypeInternal; extern MapWellKnownTypesDefaultTypeInternal _MapWellKnownTypes_default_instance_; class OneofWellKnownTypes; class OneofWellKnownTypesDefaultTypeInternal; extern OneofWellKnownTypesDefaultTypeInternal _OneofWellKnownTypes_default_instance_; class RepeatedWellKnownTypes; class RepeatedWellKnownTypesDefaultTypeInternal; extern RepeatedWellKnownTypesDefaultTypeInternal _RepeatedWellKnownTypes_default_instance_; class TestWellKnownTypes; class TestWellKnownTypesDefaultTypeInternal; extern TestWellKnownTypesDefaultTypeInternal _TestWellKnownTypes_default_instance_; } // namespace protobuf_unittest namespace protobuf_unittest { // Internal implementation detail -- do not call these. void protobuf_AddDesc_google_2fprotobuf_2funittest_5fwell_5fknown_5ftypes_2eproto(); void protobuf_InitDefaults_google_2fprotobuf_2funittest_5fwell_5fknown_5ftypes_2eproto(); // =================================================================== class TestWellKnownTypes : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:protobuf_unittest.TestWellKnownTypes) */ { public: TestWellKnownTypes(); virtual ~TestWellKnownTypes(); TestWellKnownTypes(const TestWellKnownTypes& from); inline TestWellKnownTypes& operator=(const TestWellKnownTypes& from) { CopyFrom(from); return *this; } static const ::google::protobuf::Descriptor* descriptor(); static const TestWellKnownTypes& default_instance(); static inline const TestWellKnownTypes* internal_default_instance() { return reinterpret_cast<const TestWellKnownTypes*>( &_TestWellKnownTypes_default_instance_); } void Swap(TestWellKnownTypes* other); // implements Message ---------------------------------------------- inline TestWellKnownTypes* New() const PROTOBUF_FINAL { return New(NULL); } TestWellKnownTypes* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const TestWellKnownTypes& from); void MergeFrom(const TestWellKnownTypes& from); void Clear() PROTOBUF_FINAL; bool IsInitialized() const PROTOBUF_FINAL; size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(TestWellKnownTypes* other); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return NULL; } inline void* MaybeArenaPtr() const { return NULL; } public: ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // .google.protobuf.Any any_field = 1; bool has_any_field() const; void clear_any_field(); static const int kAnyFieldFieldNumber = 1; const ::google::protobuf::Any& any_field() const; ::google::protobuf::Any* mutable_any_field(); ::google::protobuf::Any* release_any_field(); void set_allocated_any_field(::google::protobuf::Any* any_field); // .google.protobuf.Api api_field = 2; bool has_api_field() const; void clear_api_field(); static const int kApiFieldFieldNumber = 2; const ::google::protobuf::Api& api_field() const; ::google::protobuf::Api* mutable_api_field(); ::google::protobuf::Api* release_api_field(); void set_allocated_api_field(::google::protobuf::Api* api_field); // .google.protobuf.Duration duration_field = 3; bool has_duration_field() const; void clear_duration_field(); static const int kDurationFieldFieldNumber = 3; const ::google::protobuf::Duration& duration_field() const; ::google::protobuf::Duration* mutable_duration_field(); ::google::protobuf::Duration* release_duration_field(); void set_allocated_duration_field(::google::protobuf::Duration* duration_field); // .google.protobuf.Empty empty_field = 4; bool has_empty_field() const; void clear_empty_field(); static const int kEmptyFieldFieldNumber = 4; const ::google::protobuf::Empty& empty_field() const; ::google::protobuf::Empty* mutable_empty_field(); ::google::protobuf::Empty* release_empty_field(); void set_allocated_empty_field(::google::protobuf::Empty* empty_field); // .google.protobuf.FieldMask field_mask_field = 5; bool has_field_mask_field() const; void clear_field_mask_field(); static const int kFieldMaskFieldFieldNumber = 5; const ::google::protobuf::FieldMask& field_mask_field() const; ::google::protobuf::FieldMask* mutable_field_mask_field(); ::google::protobuf::FieldMask* release_field_mask_field(); void set_allocated_field_mask_field(::google::protobuf::FieldMask* field_mask_field); // .google.protobuf.SourceContext source_context_field = 6; bool has_source_context_field() const; void clear_source_context_field(); static const int kSourceContextFieldFieldNumber = 6; const ::google::protobuf::SourceContext& source_context_field() const; ::google::protobuf::SourceContext* mutable_source_context_field(); ::google::protobuf::SourceContext* release_source_context_field(); void set_allocated_source_context_field(::google::protobuf::SourceContext* source_context_field); // .google.protobuf.Struct struct_field = 7; bool has_struct_field() const; void clear_struct_field(); static const int kStructFieldFieldNumber = 7; const ::google::protobuf::Struct& struct_field() const; ::google::protobuf::Struct* mutable_struct_field(); ::google::protobuf::Struct* release_struct_field(); void set_allocated_struct_field(::google::protobuf::Struct* struct_field); // .google.protobuf.Timestamp timestamp_field = 8; bool has_timestamp_field() const; void clear_timestamp_field(); static const int kTimestampFieldFieldNumber = 8; const ::google::protobuf::Timestamp& timestamp_field() const; ::google::protobuf::Timestamp* mutable_timestamp_field(); ::google::protobuf::Timestamp* release_timestamp_field(); void set_allocated_timestamp_field(::google::protobuf::Timestamp* timestamp_field); // .google.protobuf.Type type_field = 9; bool has_type_field() const; void clear_type_field(); static const int kTypeFieldFieldNumber = 9; const ::google::protobuf::Type& type_field() const; ::google::protobuf::Type* mutable_type_field(); ::google::protobuf::Type* release_type_field(); void set_allocated_type_field(::google::protobuf::Type* type_field); // .google.protobuf.DoubleValue double_field = 10; bool has_double_field() const; void clear_double_field(); static const int kDoubleFieldFieldNumber = 10; const ::google::protobuf::DoubleValue& double_field() const; ::google::protobuf::DoubleValue* mutable_double_field(); ::google::protobuf::DoubleValue* release_double_field(); void set_allocated_double_field(::google::protobuf::DoubleValue* double_field); // .google.protobuf.FloatValue float_field = 11; bool has_float_field() const; void clear_float_field(); static const int kFloatFieldFieldNumber = 11; const ::google::protobuf::FloatValue& float_field() const; ::google::protobuf::FloatValue* mutable_float_field(); ::google::protobuf::FloatValue* release_float_field(); void set_allocated_float_field(::google::protobuf::FloatValue* float_field); // .google.protobuf.Int64Value int64_field = 12; bool has_int64_field() const; void clear_int64_field(); static const int kInt64FieldFieldNumber = 12; const ::google::protobuf::Int64Value& int64_field() const; ::google::protobuf::Int64Value* mutable_int64_field(); ::google::protobuf::Int64Value* release_int64_field(); void set_allocated_int64_field(::google::protobuf::Int64Value* int64_field); // .google.protobuf.UInt64Value uint64_field = 13; bool has_uint64_field() const; void clear_uint64_field(); static const int kUint64FieldFieldNumber = 13; const ::google::protobuf::UInt64Value& uint64_field() const; ::google::protobuf::UInt64Value* mutable_uint64_field(); ::google::protobuf::UInt64Value* release_uint64_field(); void set_allocated_uint64_field(::google::protobuf::UInt64Value* uint64_field); // .google.protobuf.Int32Value int32_field = 14; bool has_int32_field() const; void clear_int32_field(); static const int kInt32FieldFieldNumber = 14; const ::google::protobuf::Int32Value& int32_field() const; ::google::protobuf::Int32Value* mutable_int32_field(); ::google::protobuf::Int32Value* release_int32_field(); void set_allocated_int32_field(::google::protobuf::Int32Value* int32_field); // .google.protobuf.UInt32Value uint32_field = 15; bool has_uint32_field() const; void clear_uint32_field(); static const int kUint32FieldFieldNumber = 15; const ::google::protobuf::UInt32Value& uint32_field() const; ::google::protobuf::UInt32Value* mutable_uint32_field(); ::google::protobuf::UInt32Value* release_uint32_field(); void set_allocated_uint32_field(::google::protobuf::UInt32Value* uint32_field); // .google.protobuf.BoolValue bool_field = 16; bool has_bool_field() const; void clear_bool_field(); static const int kBoolFieldFieldNumber = 16; const ::google::protobuf::BoolValue& bool_field() const; ::google::protobuf::BoolValue* mutable_bool_field(); ::google::protobuf::BoolValue* release_bool_field(); void set_allocated_bool_field(::google::protobuf::BoolValue* bool_field); // .google.protobuf.StringValue string_field = 17; bool has_string_field() const; void clear_string_field(); static const int kStringFieldFieldNumber = 17; const ::google::protobuf::StringValue& string_field() const; ::google::protobuf::StringValue* mutable_string_field(); ::google::protobuf::StringValue* release_string_field(); void set_allocated_string_field(::google::protobuf::StringValue* string_field); // .google.protobuf.BytesValue bytes_field = 18; bool has_bytes_field() const; void clear_bytes_field(); static const int kBytesFieldFieldNumber = 18; const ::google::protobuf::BytesValue& bytes_field() const; ::google::protobuf::BytesValue* mutable_bytes_field(); ::google::protobuf::BytesValue* release_bytes_field(); void set_allocated_bytes_field(::google::protobuf::BytesValue* bytes_field); // .google.protobuf.Value value_field = 19; bool has_value_field() const; void clear_value_field(); static const int kValueFieldFieldNumber = 19; const ::google::protobuf::Value& value_field() const; ::google::protobuf::Value* mutable_value_field(); ::google::protobuf::Value* release_value_field(); void set_allocated_value_field(::google::protobuf::Value* value_field); // @@protoc_insertion_point(class_scope:protobuf_unittest.TestWellKnownTypes) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::Any* any_field_; ::google::protobuf::Api* api_field_; ::google::protobuf::Duration* duration_field_; ::google::protobuf::Empty* empty_field_; ::google::protobuf::FieldMask* field_mask_field_; ::google::protobuf::SourceContext* source_context_field_; ::google::protobuf::Struct* struct_field_; ::google::protobuf::Timestamp* timestamp_field_; ::google::protobuf::Type* type_field_; ::google::protobuf::DoubleValue* double_field_; ::google::protobuf::FloatValue* float_field_; ::google::protobuf::Int64Value* int64_field_; ::google::protobuf::UInt64Value* uint64_field_; ::google::protobuf::Int32Value* int32_field_; ::google::protobuf::UInt32Value* uint32_field_; ::google::protobuf::BoolValue* bool_field_; ::google::protobuf::StringValue* string_field_; ::google::protobuf::BytesValue* bytes_field_; ::google::protobuf::Value* value_field_; mutable int _cached_size_; friend void protobuf_InitDefaults_google_2fprotobuf_2funittest_5fwell_5fknown_5ftypes_2eproto_impl(); friend void protobuf_AddDesc_google_2fprotobuf_2funittest_5fwell_5fknown_5ftypes_2eproto_impl(); friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2funittest_5fwell_5fknown_5ftypes_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2funittest_5fwell_5fknown_5ftypes_2eproto(); }; // ------------------------------------------------------------------- class RepeatedWellKnownTypes : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:protobuf_unittest.RepeatedWellKnownTypes) */ { public: RepeatedWellKnownTypes(); virtual ~RepeatedWellKnownTypes(); RepeatedWellKnownTypes(const RepeatedWellKnownTypes& from); inline RepeatedWellKnownTypes& operator=(const RepeatedWellKnownTypes& from) { CopyFrom(from); return *this; } static const ::google::protobuf::Descriptor* descriptor(); static const RepeatedWellKnownTypes& default_instance(); static inline const RepeatedWellKnownTypes* internal_default_instance() { return reinterpret_cast<const RepeatedWellKnownTypes*>( &_RepeatedWellKnownTypes_default_instance_); } void Swap(RepeatedWellKnownTypes* other); // implements Message ---------------------------------------------- inline RepeatedWellKnownTypes* New() const PROTOBUF_FINAL { return New(NULL); } RepeatedWellKnownTypes* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const RepeatedWellKnownTypes& from); void MergeFrom(const RepeatedWellKnownTypes& from); void Clear() PROTOBUF_FINAL; bool IsInitialized() const PROTOBUF_FINAL; size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(RepeatedWellKnownTypes* other); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return NULL; } inline void* MaybeArenaPtr() const { return NULL; } public: ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // repeated .google.protobuf.Any any_field = 1; int any_field_size() const; void clear_any_field(); static const int kAnyFieldFieldNumber = 1; const ::google::protobuf::Any& any_field(int index) const; ::google::protobuf::Any* mutable_any_field(int index); ::google::protobuf::Any* add_any_field(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::Any >* mutable_any_field(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Any >& any_field() const; // repeated .google.protobuf.Api api_field = 2; int api_field_size() const; void clear_api_field(); static const int kApiFieldFieldNumber = 2; const ::google::protobuf::Api& api_field(int index) const; ::google::protobuf::Api* mutable_api_field(int index); ::google::protobuf::Api* add_api_field(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::Api >* mutable_api_field(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Api >& api_field() const; // repeated .google.protobuf.Duration duration_field = 3; int duration_field_size() const; void clear_duration_field(); static const int kDurationFieldFieldNumber = 3; const ::google::protobuf::Duration& duration_field(int index) const; ::google::protobuf::Duration* mutable_duration_field(int index); ::google::protobuf::Duration* add_duration_field(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::Duration >* mutable_duration_field(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Duration >& duration_field() const; // repeated .google.protobuf.Empty empty_field = 4; int empty_field_size() const; void clear_empty_field(); static const int kEmptyFieldFieldNumber = 4; const ::google::protobuf::Empty& empty_field(int index) const; ::google::protobuf::Empty* mutable_empty_field(int index); ::google::protobuf::Empty* add_empty_field(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::Empty >* mutable_empty_field(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Empty >& empty_field() const; // repeated .google.protobuf.FieldMask field_mask_field = 5; int field_mask_field_size() const; void clear_field_mask_field(); static const int kFieldMaskFieldFieldNumber = 5; const ::google::protobuf::FieldMask& field_mask_field(int index) const; ::google::protobuf::FieldMask* mutable_field_mask_field(int index); ::google::protobuf::FieldMask* add_field_mask_field(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldMask >* mutable_field_mask_field(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldMask >& field_mask_field() const; // repeated .google.protobuf.SourceContext source_context_field = 6; int source_context_field_size() const; void clear_source_context_field(); static const int kSourceContextFieldFieldNumber = 6; const ::google::protobuf::SourceContext& source_context_field(int index) const; ::google::protobuf::SourceContext* mutable_source_context_field(int index); ::google::protobuf::SourceContext* add_source_context_field(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceContext >* mutable_source_context_field(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceContext >& source_context_field() const; // repeated .google.protobuf.Struct struct_field = 7; int struct_field_size() const; void clear_struct_field(); static const int kStructFieldFieldNumber = 7; const ::google::protobuf::Struct& struct_field(int index) const; ::google::protobuf::Struct* mutable_struct_field(int index); ::google::protobuf::Struct* add_struct_field(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::Struct >* mutable_struct_field(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Struct >& struct_field() const; // repeated .google.protobuf.Timestamp timestamp_field = 8; int timestamp_field_size() const; void clear_timestamp_field(); static const int kTimestampFieldFieldNumber = 8; const ::google::protobuf::Timestamp& timestamp_field(int index) const; ::google::protobuf::Timestamp* mutable_timestamp_field(int index); ::google::protobuf::Timestamp* add_timestamp_field(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::Timestamp >* mutable_timestamp_field(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Timestamp >& timestamp_field() const; // repeated .google.protobuf.Type type_field = 9; int type_field_size() const; void clear_type_field(); static const int kTypeFieldFieldNumber = 9; const ::google::protobuf::Type& type_field(int index) const; ::google::protobuf::Type* mutable_type_field(int index); ::google::protobuf::Type* add_type_field(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::Type >* mutable_type_field(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Type >& type_field() const; // repeated .google.protobuf.DoubleValue double_field = 10; int double_field_size() const; void clear_double_field(); static const int kDoubleFieldFieldNumber = 10; const ::google::protobuf::DoubleValue& double_field(int index) const; ::google::protobuf::DoubleValue* mutable_double_field(int index); ::google::protobuf::DoubleValue* add_double_field(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::DoubleValue >* mutable_double_field(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DoubleValue >& double_field() const; // repeated .google.protobuf.FloatValue float_field = 11; int float_field_size() const; void clear_float_field(); static const int kFloatFieldFieldNumber = 11; const ::google::protobuf::FloatValue& float_field(int index) const; ::google::protobuf::FloatValue* mutable_float_field(int index); ::google::protobuf::FloatValue* add_float_field(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::FloatValue >* mutable_float_field(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FloatValue >& float_field() const; // repeated .google.protobuf.Int64Value int64_field = 12; int int64_field_size() const; void clear_int64_field(); static const int kInt64FieldFieldNumber = 12; const ::google::protobuf::Int64Value& int64_field(int index) const; ::google::protobuf::Int64Value* mutable_int64_field(int index); ::google::protobuf::Int64Value* add_int64_field(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::Int64Value >* mutable_int64_field(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Int64Value >& int64_field() const; // repeated .google.protobuf.UInt64Value uint64_field = 13; int uint64_field_size() const; void clear_uint64_field(); static const int kUint64FieldFieldNumber = 13; const ::google::protobuf::UInt64Value& uint64_field(int index) const; ::google::protobuf::UInt64Value* mutable_uint64_field(int index); ::google::protobuf::UInt64Value* add_uint64_field(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::UInt64Value >* mutable_uint64_field(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UInt64Value >& uint64_field() const; // repeated .google.protobuf.Int32Value int32_field = 14; int int32_field_size() const; void clear_int32_field(); static const int kInt32FieldFieldNumber = 14; const ::google::protobuf::Int32Value& int32_field(int index) const; ::google::protobuf::Int32Value* mutable_int32_field(int index); ::google::protobuf::Int32Value* add_int32_field(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::Int32Value >* mutable_int32_field(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Int32Value >& int32_field() const; // repeated .google.protobuf.UInt32Value uint32_field = 15; int uint32_field_size() const; void clear_uint32_field(); static const int kUint32FieldFieldNumber = 15; const ::google::protobuf::UInt32Value& uint32_field(int index) const; ::google::protobuf::UInt32Value* mutable_uint32_field(int index); ::google::protobuf::UInt32Value* add_uint32_field(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::UInt32Value >* mutable_uint32_field(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UInt32Value >& uint32_field() const; // repeated .google.protobuf.BoolValue bool_field = 16; int bool_field_size() const; void clear_bool_field(); static const int kBoolFieldFieldNumber = 16; const ::google::protobuf::BoolValue& bool_field(int index) const; ::google::protobuf::BoolValue* mutable_bool_field(int index); ::google::protobuf::BoolValue* add_bool_field(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::BoolValue >* mutable_bool_field(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::BoolValue >& bool_field() const; // repeated .google.protobuf.StringValue string_field = 17; int string_field_size() const; void clear_string_field(); static const int kStringFieldFieldNumber = 17; const ::google::protobuf::StringValue& string_field(int index) const; ::google::protobuf::StringValue* mutable_string_field(int index); ::google::protobuf::StringValue* add_string_field(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::StringValue >* mutable_string_field(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::StringValue >& string_field() const; // repeated .google.protobuf.BytesValue bytes_field = 18; int bytes_field_size() const; void clear_bytes_field(); static const int kBytesFieldFieldNumber = 18; const ::google::protobuf::BytesValue& bytes_field(int index) const; ::google::protobuf::BytesValue* mutable_bytes_field(int index); ::google::protobuf::BytesValue* add_bytes_field(); ::google::protobuf::RepeatedPtrField< ::google::protobuf::BytesValue >* mutable_bytes_field(); const ::google::protobuf::RepeatedPtrField< ::google::protobuf::BytesValue >& bytes_field() const; // @@protoc_insertion_point(class_scope:protobuf_unittest.RepeatedWellKnownTypes) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::Any > any_field_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::Api > api_field_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::Duration > duration_field_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::Empty > empty_field_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldMask > field_mask_field_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceContext > source_context_field_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::Struct > struct_field_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::Timestamp > timestamp_field_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::Type > type_field_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::DoubleValue > double_field_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::FloatValue > float_field_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::Int64Value > int64_field_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UInt64Value > uint64_field_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::Int32Value > int32_field_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::UInt32Value > uint32_field_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::BoolValue > bool_field_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::StringValue > string_field_; ::google::protobuf::RepeatedPtrField< ::google::protobuf::BytesValue > bytes_field_; mutable int _cached_size_; friend void protobuf_InitDefaults_google_2fprotobuf_2funittest_5fwell_5fknown_5ftypes_2eproto_impl(); friend void protobuf_AddDesc_google_2fprotobuf_2funittest_5fwell_5fknown_5ftypes_2eproto_impl(); friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2funittest_5fwell_5fknown_5ftypes_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2funittest_5fwell_5fknown_5ftypes_2eproto(); }; // ------------------------------------------------------------------- class OneofWellKnownTypes : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:protobuf_unittest.OneofWellKnownTypes) */ { public: OneofWellKnownTypes(); virtual ~OneofWellKnownTypes(); OneofWellKnownTypes(const OneofWellKnownTypes& from); inline OneofWellKnownTypes& operator=(const OneofWellKnownTypes& from) { CopyFrom(from); return *this; } static const ::google::protobuf::Descriptor* descriptor(); static const OneofWellKnownTypes& default_instance(); enum OneofFieldCase { kAnyField = 1, kApiField = 2, kDurationField = 3, kEmptyField = 4, kFieldMaskField = 5, kSourceContextField = 6, kStructField = 7, kTimestampField = 8, kTypeField = 9, kDoubleField = 10, kFloatField = 11, kInt64Field = 12, kUint64Field = 13, kInt32Field = 14, kUint32Field = 15, kBoolField = 16, kStringField = 17, kBytesField = 18, ONEOF_FIELD_NOT_SET = 0, }; static inline const OneofWellKnownTypes* internal_default_instance() { return reinterpret_cast<const OneofWellKnownTypes*>( &_OneofWellKnownTypes_default_instance_); } void Swap(OneofWellKnownTypes* other); // implements Message ---------------------------------------------- inline OneofWellKnownTypes* New() const PROTOBUF_FINAL { return New(NULL); } OneofWellKnownTypes* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const OneofWellKnownTypes& from); void MergeFrom(const OneofWellKnownTypes& from); void Clear() PROTOBUF_FINAL; bool IsInitialized() const PROTOBUF_FINAL; size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(OneofWellKnownTypes* other); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return NULL; } inline void* MaybeArenaPtr() const { return NULL; } public: ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // .google.protobuf.Any any_field = 1; bool has_any_field() const; void clear_any_field(); static const int kAnyFieldFieldNumber = 1; const ::google::protobuf::Any& any_field() const; ::google::protobuf::Any* mutable_any_field(); ::google::protobuf::Any* release_any_field(); void set_allocated_any_field(::google::protobuf::Any* any_field); // .google.protobuf.Api api_field = 2; bool has_api_field() const; void clear_api_field(); static const int kApiFieldFieldNumber = 2; const ::google::protobuf::Api& api_field() const; ::google::protobuf::Api* mutable_api_field(); ::google::protobuf::Api* release_api_field(); void set_allocated_api_field(::google::protobuf::Api* api_field); // .google.protobuf.Duration duration_field = 3; bool has_duration_field() const; void clear_duration_field(); static const int kDurationFieldFieldNumber = 3; const ::google::protobuf::Duration& duration_field() const; ::google::protobuf::Duration* mutable_duration_field(); ::google::protobuf::Duration* release_duration_field(); void set_allocated_duration_field(::google::protobuf::Duration* duration_field); // .google.protobuf.Empty empty_field = 4; bool has_empty_field() const; void clear_empty_field(); static const int kEmptyFieldFieldNumber = 4; const ::google::protobuf::Empty& empty_field() const; ::google::protobuf::Empty* mutable_empty_field(); ::google::protobuf::Empty* release_empty_field(); void set_allocated_empty_field(::google::protobuf::Empty* empty_field); // .google.protobuf.FieldMask field_mask_field = 5; bool has_field_mask_field() const; void clear_field_mask_field(); static const int kFieldMaskFieldFieldNumber = 5; const ::google::protobuf::FieldMask& field_mask_field() const; ::google::protobuf::FieldMask* mutable_field_mask_field(); ::google::protobuf::FieldMask* release_field_mask_field(); void set_allocated_field_mask_field(::google::protobuf::FieldMask* field_mask_field); // .google.protobuf.SourceContext source_context_field = 6; bool has_source_context_field() const; void clear_source_context_field(); static const int kSourceContextFieldFieldNumber = 6; const ::google::protobuf::SourceContext& source_context_field() const; ::google::protobuf::SourceContext* mutable_source_context_field(); ::google::protobuf::SourceContext* release_source_context_field(); void set_allocated_source_context_field(::google::protobuf::SourceContext* source_context_field); // .google.protobuf.Struct struct_field = 7; bool has_struct_field() const; void clear_struct_field(); static const int kStructFieldFieldNumber = 7; const ::google::protobuf::Struct& struct_field() const; ::google::protobuf::Struct* mutable_struct_field(); ::google::protobuf::Struct* release_struct_field(); void set_allocated_struct_field(::google::protobuf::Struct* struct_field); // .google.protobuf.Timestamp timestamp_field = 8; bool has_timestamp_field() const; void clear_timestamp_field(); static const int kTimestampFieldFieldNumber = 8; const ::google::protobuf::Timestamp& timestamp_field() const; ::google::protobuf::Timestamp* mutable_timestamp_field(); ::google::protobuf::Timestamp* release_timestamp_field(); void set_allocated_timestamp_field(::google::protobuf::Timestamp* timestamp_field); // .google.protobuf.Type type_field = 9; bool has_type_field() const; void clear_type_field(); static const int kTypeFieldFieldNumber = 9; const ::google::protobuf::Type& type_field() const; ::google::protobuf::Type* mutable_type_field(); ::google::protobuf::Type* release_type_field(); void set_allocated_type_field(::google::protobuf::Type* type_field); // .google.protobuf.DoubleValue double_field = 10; bool has_double_field() const; void clear_double_field(); static const int kDoubleFieldFieldNumber = 10; const ::google::protobuf::DoubleValue& double_field() const; ::google::protobuf::DoubleValue* mutable_double_field(); ::google::protobuf::DoubleValue* release_double_field(); void set_allocated_double_field(::google::protobuf::DoubleValue* double_field); // .google.protobuf.FloatValue float_field = 11; bool has_float_field() const; void clear_float_field(); static const int kFloatFieldFieldNumber = 11; const ::google::protobuf::FloatValue& float_field() const; ::google::protobuf::FloatValue* mutable_float_field(); ::google::protobuf::FloatValue* release_float_field(); void set_allocated_float_field(::google::protobuf::FloatValue* float_field); // .google.protobuf.Int64Value int64_field = 12; bool has_int64_field() const; void clear_int64_field(); static const int kInt64FieldFieldNumber = 12; const ::google::protobuf::Int64Value& int64_field() const; ::google::protobuf::Int64Value* mutable_int64_field(); ::google::protobuf::Int64Value* release_int64_field(); void set_allocated_int64_field(::google::protobuf::Int64Value* int64_field); // .google.protobuf.UInt64Value uint64_field = 13; bool has_uint64_field() const; void clear_uint64_field(); static const int kUint64FieldFieldNumber = 13; const ::google::protobuf::UInt64Value& uint64_field() const; ::google::protobuf::UInt64Value* mutable_uint64_field(); ::google::protobuf::UInt64Value* release_uint64_field(); void set_allocated_uint64_field(::google::protobuf::UInt64Value* uint64_field); // .google.protobuf.Int32Value int32_field = 14; bool has_int32_field() const; void clear_int32_field(); static const int kInt32FieldFieldNumber = 14; const ::google::protobuf::Int32Value& int32_field() const; ::google::protobuf::Int32Value* mutable_int32_field(); ::google::protobuf::Int32Value* release_int32_field(); void set_allocated_int32_field(::google::protobuf::Int32Value* int32_field); // .google.protobuf.UInt32Value uint32_field = 15; bool has_uint32_field() const; void clear_uint32_field(); static const int kUint32FieldFieldNumber = 15; const ::google::protobuf::UInt32Value& uint32_field() const; ::google::protobuf::UInt32Value* mutable_uint32_field(); ::google::protobuf::UInt32Value* release_uint32_field(); void set_allocated_uint32_field(::google::protobuf::UInt32Value* uint32_field); // .google.protobuf.BoolValue bool_field = 16; bool has_bool_field() const; void clear_bool_field(); static const int kBoolFieldFieldNumber = 16; const ::google::protobuf::BoolValue& bool_field() const; ::google::protobuf::BoolValue* mutable_bool_field(); ::google::protobuf::BoolValue* release_bool_field(); void set_allocated_bool_field(::google::protobuf::BoolValue* bool_field); // .google.protobuf.StringValue string_field = 17; bool has_string_field() const; void clear_string_field(); static const int kStringFieldFieldNumber = 17; const ::google::protobuf::StringValue& string_field() const; ::google::protobuf::StringValue* mutable_string_field(); ::google::protobuf::StringValue* release_string_field(); void set_allocated_string_field(::google::protobuf::StringValue* string_field); // .google.protobuf.BytesValue bytes_field = 18; bool has_bytes_field() const; void clear_bytes_field(); static const int kBytesFieldFieldNumber = 18; const ::google::protobuf::BytesValue& bytes_field() const; ::google::protobuf::BytesValue* mutable_bytes_field(); ::google::protobuf::BytesValue* release_bytes_field(); void set_allocated_bytes_field(::google::protobuf::BytesValue* bytes_field); OneofFieldCase oneof_field_case() const; // @@protoc_insertion_point(class_scope:protobuf_unittest.OneofWellKnownTypes) private: void set_has_any_field(); void set_has_api_field(); void set_has_duration_field(); void set_has_empty_field(); void set_has_field_mask_field(); void set_has_source_context_field(); void set_has_struct_field(); void set_has_timestamp_field(); void set_has_type_field(); void set_has_double_field(); void set_has_float_field(); void set_has_int64_field(); void set_has_uint64_field(); void set_has_int32_field(); void set_has_uint32_field(); void set_has_bool_field(); void set_has_string_field(); void set_has_bytes_field(); inline bool has_oneof_field() const; void clear_oneof_field(); inline void clear_has_oneof_field(); ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; union OneofFieldUnion { OneofFieldUnion() {} ::google::protobuf::Any* any_field_; ::google::protobuf::Api* api_field_; ::google::protobuf::Duration* duration_field_; ::google::protobuf::Empty* empty_field_; ::google::protobuf::FieldMask* field_mask_field_; ::google::protobuf::SourceContext* source_context_field_; ::google::protobuf::Struct* struct_field_; ::google::protobuf::Timestamp* timestamp_field_; ::google::protobuf::Type* type_field_; ::google::protobuf::DoubleValue* double_field_; ::google::protobuf::FloatValue* float_field_; ::google::protobuf::Int64Value* int64_field_; ::google::protobuf::UInt64Value* uint64_field_; ::google::protobuf::Int32Value* int32_field_; ::google::protobuf::UInt32Value* uint32_field_; ::google::protobuf::BoolValue* bool_field_; ::google::protobuf::StringValue* string_field_; ::google::protobuf::BytesValue* bytes_field_; } oneof_field_; mutable int _cached_size_; ::google::protobuf::uint32 _oneof_case_[1]; friend void protobuf_InitDefaults_google_2fprotobuf_2funittest_5fwell_5fknown_5ftypes_2eproto_impl(); friend void protobuf_AddDesc_google_2fprotobuf_2funittest_5fwell_5fknown_5ftypes_2eproto_impl(); friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2funittest_5fwell_5fknown_5ftypes_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2funittest_5fwell_5fknown_5ftypes_2eproto(); }; // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- class MapWellKnownTypes : public ::google::protobuf::Message /* @@protoc_insertion_point(class_definition:protobuf_unittest.MapWellKnownTypes) */ { public: MapWellKnownTypes(); virtual ~MapWellKnownTypes(); MapWellKnownTypes(const MapWellKnownTypes& from); inline MapWellKnownTypes& operator=(const MapWellKnownTypes& from) { CopyFrom(from); return *this; } static const ::google::protobuf::Descriptor* descriptor(); static const MapWellKnownTypes& default_instance(); static inline const MapWellKnownTypes* internal_default_instance() { return reinterpret_cast<const MapWellKnownTypes*>( &_MapWellKnownTypes_default_instance_); } void Swap(MapWellKnownTypes* other); // implements Message ---------------------------------------------- inline MapWellKnownTypes* New() const PROTOBUF_FINAL { return New(NULL); } MapWellKnownTypes* New(::google::protobuf::Arena* arena) const PROTOBUF_FINAL; void CopyFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void MergeFrom(const ::google::protobuf::Message& from) PROTOBUF_FINAL; void CopyFrom(const MapWellKnownTypes& from); void MergeFrom(const MapWellKnownTypes& from); void Clear() PROTOBUF_FINAL; bool IsInitialized() const PROTOBUF_FINAL; size_t ByteSizeLong() const PROTOBUF_FINAL; bool MergePartialFromCodedStream( ::google::protobuf::io::CodedInputStream* input) PROTOBUF_FINAL; void SerializeWithCachedSizes( ::google::protobuf::io::CodedOutputStream* output) const PROTOBUF_FINAL; ::google::protobuf::uint8* InternalSerializeWithCachedSizesToArray( bool deterministic, ::google::protobuf::uint8* target) const PROTOBUF_FINAL; ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const PROTOBUF_FINAL { return InternalSerializeWithCachedSizesToArray(false, output); } int GetCachedSize() const PROTOBUF_FINAL { return _cached_size_; } private: void SharedCtor(); void SharedDtor(); void SetCachedSize(int size) const PROTOBUF_FINAL; void InternalSwap(MapWellKnownTypes* other); private: inline ::google::protobuf::Arena* GetArenaNoVirtual() const { return NULL; } inline void* MaybeArenaPtr() const { return NULL; } public: ::google::protobuf::Metadata GetMetadata() const PROTOBUF_FINAL; // nested types ---------------------------------------------------- // accessors ------------------------------------------------------- // map<int32, .google.protobuf.Any> any_field = 1; int any_field_size() const; void clear_any_field(); static const int kAnyFieldFieldNumber = 1; const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Any >& any_field() const; ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Any >* mutable_any_field(); // map<int32, .google.protobuf.Api> api_field = 2; int api_field_size() const; void clear_api_field(); static const int kApiFieldFieldNumber = 2; const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Api >& api_field() const; ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Api >* mutable_api_field(); // map<int32, .google.protobuf.Duration> duration_field = 3; int duration_field_size() const; void clear_duration_field(); static const int kDurationFieldFieldNumber = 3; const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Duration >& duration_field() const; ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Duration >* mutable_duration_field(); // map<int32, .google.protobuf.Empty> empty_field = 4; int empty_field_size() const; void clear_empty_field(); static const int kEmptyFieldFieldNumber = 4; const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Empty >& empty_field() const; ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Empty >* mutable_empty_field(); // map<int32, .google.protobuf.FieldMask> field_mask_field = 5; int field_mask_field_size() const; void clear_field_mask_field(); static const int kFieldMaskFieldFieldNumber = 5; const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::FieldMask >& field_mask_field() const; ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::FieldMask >* mutable_field_mask_field(); // map<int32, .google.protobuf.SourceContext> source_context_field = 6; int source_context_field_size() const; void clear_source_context_field(); static const int kSourceContextFieldFieldNumber = 6; const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::SourceContext >& source_context_field() const; ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::SourceContext >* mutable_source_context_field(); // map<int32, .google.protobuf.Struct> struct_field = 7; int struct_field_size() const; void clear_struct_field(); static const int kStructFieldFieldNumber = 7; const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Struct >& struct_field() const; ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Struct >* mutable_struct_field(); // map<int32, .google.protobuf.Timestamp> timestamp_field = 8; int timestamp_field_size() const; void clear_timestamp_field(); static const int kTimestampFieldFieldNumber = 8; const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Timestamp >& timestamp_field() const; ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Timestamp >* mutable_timestamp_field(); // map<int32, .google.protobuf.Type> type_field = 9; int type_field_size() const; void clear_type_field(); static const int kTypeFieldFieldNumber = 9; const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Type >& type_field() const; ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Type >* mutable_type_field(); // map<int32, .google.protobuf.DoubleValue> double_field = 10; int double_field_size() const; void clear_double_field(); static const int kDoubleFieldFieldNumber = 10; const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::DoubleValue >& double_field() const; ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::DoubleValue >* mutable_double_field(); // map<int32, .google.protobuf.FloatValue> float_field = 11; int float_field_size() const; void clear_float_field(); static const int kFloatFieldFieldNumber = 11; const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::FloatValue >& float_field() const; ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::FloatValue >* mutable_float_field(); // map<int32, .google.protobuf.Int64Value> int64_field = 12; int int64_field_size() const; void clear_int64_field(); static const int kInt64FieldFieldNumber = 12; const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Int64Value >& int64_field() const; ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Int64Value >* mutable_int64_field(); // map<int32, .google.protobuf.UInt64Value> uint64_field = 13; int uint64_field_size() const; void clear_uint64_field(); static const int kUint64FieldFieldNumber = 13; const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::UInt64Value >& uint64_field() const; ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::UInt64Value >* mutable_uint64_field(); // map<int32, .google.protobuf.Int32Value> int32_field = 14; int int32_field_size() const; void clear_int32_field(); static const int kInt32FieldFieldNumber = 14; const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Int32Value >& int32_field() const; ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Int32Value >* mutable_int32_field(); // map<int32, .google.protobuf.UInt32Value> uint32_field = 15; int uint32_field_size() const; void clear_uint32_field(); static const int kUint32FieldFieldNumber = 15; const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::UInt32Value >& uint32_field() const; ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::UInt32Value >* mutable_uint32_field(); // map<int32, .google.protobuf.BoolValue> bool_field = 16; int bool_field_size() const; void clear_bool_field(); static const int kBoolFieldFieldNumber = 16; const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::BoolValue >& bool_field() const; ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::BoolValue >* mutable_bool_field(); // map<int32, .google.protobuf.StringValue> string_field = 17; int string_field_size() const; void clear_string_field(); static const int kStringFieldFieldNumber = 17; const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::StringValue >& string_field() const; ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::StringValue >* mutable_string_field(); // map<int32, .google.protobuf.BytesValue> bytes_field = 18; int bytes_field_size() const; void clear_bytes_field(); static const int kBytesFieldFieldNumber = 18; const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::BytesValue >& bytes_field() const; ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::BytesValue >* mutable_bytes_field(); // @@protoc_insertion_point(class_scope:protobuf_unittest.MapWellKnownTypes) private: ::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_; typedef ::google::protobuf::internal::MapEntryLite< ::google::protobuf::int32, ::google::protobuf::Any, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > MapWellKnownTypes_AnyFieldEntry; ::google::protobuf::internal::MapField< ::google::protobuf::int32, ::google::protobuf::Any, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > any_field_; typedef ::google::protobuf::internal::MapEntryLite< ::google::protobuf::int32, ::google::protobuf::Api, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > MapWellKnownTypes_ApiFieldEntry; ::google::protobuf::internal::MapField< ::google::protobuf::int32, ::google::protobuf::Api, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > api_field_; typedef ::google::protobuf::internal::MapEntryLite< ::google::protobuf::int32, ::google::protobuf::Duration, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > MapWellKnownTypes_DurationFieldEntry; ::google::protobuf::internal::MapField< ::google::protobuf::int32, ::google::protobuf::Duration, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > duration_field_; typedef ::google::protobuf::internal::MapEntryLite< ::google::protobuf::int32, ::google::protobuf::Empty, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > MapWellKnownTypes_EmptyFieldEntry; ::google::protobuf::internal::MapField< ::google::protobuf::int32, ::google::protobuf::Empty, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > empty_field_; typedef ::google::protobuf::internal::MapEntryLite< ::google::protobuf::int32, ::google::protobuf::FieldMask, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > MapWellKnownTypes_FieldMaskFieldEntry; ::google::protobuf::internal::MapField< ::google::protobuf::int32, ::google::protobuf::FieldMask, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > field_mask_field_; typedef ::google::protobuf::internal::MapEntryLite< ::google::protobuf::int32, ::google::protobuf::SourceContext, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > MapWellKnownTypes_SourceContextFieldEntry; ::google::protobuf::internal::MapField< ::google::protobuf::int32, ::google::protobuf::SourceContext, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > source_context_field_; typedef ::google::protobuf::internal::MapEntryLite< ::google::protobuf::int32, ::google::protobuf::Struct, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > MapWellKnownTypes_StructFieldEntry; ::google::protobuf::internal::MapField< ::google::protobuf::int32, ::google::protobuf::Struct, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > struct_field_; typedef ::google::protobuf::internal::MapEntryLite< ::google::protobuf::int32, ::google::protobuf::Timestamp, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > MapWellKnownTypes_TimestampFieldEntry; ::google::protobuf::internal::MapField< ::google::protobuf::int32, ::google::protobuf::Timestamp, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > timestamp_field_; typedef ::google::protobuf::internal::MapEntryLite< ::google::protobuf::int32, ::google::protobuf::Type, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > MapWellKnownTypes_TypeFieldEntry; ::google::protobuf::internal::MapField< ::google::protobuf::int32, ::google::protobuf::Type, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > type_field_; typedef ::google::protobuf::internal::MapEntryLite< ::google::protobuf::int32, ::google::protobuf::DoubleValue, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > MapWellKnownTypes_DoubleFieldEntry; ::google::protobuf::internal::MapField< ::google::protobuf::int32, ::google::protobuf::DoubleValue, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > double_field_; typedef ::google::protobuf::internal::MapEntryLite< ::google::protobuf::int32, ::google::protobuf::FloatValue, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > MapWellKnownTypes_FloatFieldEntry; ::google::protobuf::internal::MapField< ::google::protobuf::int32, ::google::protobuf::FloatValue, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > float_field_; typedef ::google::protobuf::internal::MapEntryLite< ::google::protobuf::int32, ::google::protobuf::Int64Value, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > MapWellKnownTypes_Int64FieldEntry; ::google::protobuf::internal::MapField< ::google::protobuf::int32, ::google::protobuf::Int64Value, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > int64_field_; typedef ::google::protobuf::internal::MapEntryLite< ::google::protobuf::int32, ::google::protobuf::UInt64Value, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > MapWellKnownTypes_Uint64FieldEntry; ::google::protobuf::internal::MapField< ::google::protobuf::int32, ::google::protobuf::UInt64Value, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > uint64_field_; typedef ::google::protobuf::internal::MapEntryLite< ::google::protobuf::int32, ::google::protobuf::Int32Value, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > MapWellKnownTypes_Int32FieldEntry; ::google::protobuf::internal::MapField< ::google::protobuf::int32, ::google::protobuf::Int32Value, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > int32_field_; typedef ::google::protobuf::internal::MapEntryLite< ::google::protobuf::int32, ::google::protobuf::UInt32Value, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > MapWellKnownTypes_Uint32FieldEntry; ::google::protobuf::internal::MapField< ::google::protobuf::int32, ::google::protobuf::UInt32Value, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > uint32_field_; typedef ::google::protobuf::internal::MapEntryLite< ::google::protobuf::int32, ::google::protobuf::BoolValue, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > MapWellKnownTypes_BoolFieldEntry; ::google::protobuf::internal::MapField< ::google::protobuf::int32, ::google::protobuf::BoolValue, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > bool_field_; typedef ::google::protobuf::internal::MapEntryLite< ::google::protobuf::int32, ::google::protobuf::StringValue, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > MapWellKnownTypes_StringFieldEntry; ::google::protobuf::internal::MapField< ::google::protobuf::int32, ::google::protobuf::StringValue, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > string_field_; typedef ::google::protobuf::internal::MapEntryLite< ::google::protobuf::int32, ::google::protobuf::BytesValue, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > MapWellKnownTypes_BytesFieldEntry; ::google::protobuf::internal::MapField< ::google::protobuf::int32, ::google::protobuf::BytesValue, ::google::protobuf::internal::WireFormatLite::TYPE_INT32, ::google::protobuf::internal::WireFormatLite::TYPE_MESSAGE, 0 > bytes_field_; mutable int _cached_size_; friend void protobuf_InitDefaults_google_2fprotobuf_2funittest_5fwell_5fknown_5ftypes_2eproto_impl(); friend void protobuf_AddDesc_google_2fprotobuf_2funittest_5fwell_5fknown_5ftypes_2eproto_impl(); friend const ::google::protobuf::uint32* protobuf_Offsets_google_2fprotobuf_2funittest_5fwell_5fknown_5ftypes_2eproto(); friend void protobuf_ShutdownFile_google_2fprotobuf_2funittest_5fwell_5fknown_5ftypes_2eproto(); }; // =================================================================== // =================================================================== #if !PROTOBUF_INLINE_NOT_IN_HEADERS // TestWellKnownTypes // .google.protobuf.Any any_field = 1; inline bool TestWellKnownTypes::has_any_field() const { return this != internal_default_instance() && any_field_ != NULL; } inline void TestWellKnownTypes::clear_any_field() { if (GetArenaNoVirtual() == NULL && any_field_ != NULL) delete any_field_; any_field_ = NULL; } inline const ::google::protobuf::Any& TestWellKnownTypes::any_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.TestWellKnownTypes.any_field) return any_field_ != NULL ? *any_field_ : *::google::protobuf::Any::internal_default_instance(); } inline ::google::protobuf::Any* TestWellKnownTypes::mutable_any_field() { if (any_field_ == NULL) { any_field_ = new ::google::protobuf::Any; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.TestWellKnownTypes.any_field) return any_field_; } inline ::google::protobuf::Any* TestWellKnownTypes::release_any_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.TestWellKnownTypes.any_field) ::google::protobuf::Any* temp = any_field_; any_field_ = NULL; return temp; } inline void TestWellKnownTypes::set_allocated_any_field(::google::protobuf::Any* any_field) { delete any_field_; any_field_ = any_field; if (any_field) { } else { } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestWellKnownTypes.any_field) } // .google.protobuf.Api api_field = 2; inline bool TestWellKnownTypes::has_api_field() const { return this != internal_default_instance() && api_field_ != NULL; } inline void TestWellKnownTypes::clear_api_field() { if (GetArenaNoVirtual() == NULL && api_field_ != NULL) delete api_field_; api_field_ = NULL; } inline const ::google::protobuf::Api& TestWellKnownTypes::api_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.TestWellKnownTypes.api_field) return api_field_ != NULL ? *api_field_ : *::google::protobuf::Api::internal_default_instance(); } inline ::google::protobuf::Api* TestWellKnownTypes::mutable_api_field() { if (api_field_ == NULL) { api_field_ = new ::google::protobuf::Api; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.TestWellKnownTypes.api_field) return api_field_; } inline ::google::protobuf::Api* TestWellKnownTypes::release_api_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.TestWellKnownTypes.api_field) ::google::protobuf::Api* temp = api_field_; api_field_ = NULL; return temp; } inline void TestWellKnownTypes::set_allocated_api_field(::google::protobuf::Api* api_field) { delete api_field_; api_field_ = api_field; if (api_field) { } else { } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestWellKnownTypes.api_field) } // .google.protobuf.Duration duration_field = 3; inline bool TestWellKnownTypes::has_duration_field() const { return this != internal_default_instance() && duration_field_ != NULL; } inline void TestWellKnownTypes::clear_duration_field() { if (GetArenaNoVirtual() == NULL && duration_field_ != NULL) delete duration_field_; duration_field_ = NULL; } inline const ::google::protobuf::Duration& TestWellKnownTypes::duration_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.TestWellKnownTypes.duration_field) return duration_field_ != NULL ? *duration_field_ : *::google::protobuf::Duration::internal_default_instance(); } inline ::google::protobuf::Duration* TestWellKnownTypes::mutable_duration_field() { if (duration_field_ == NULL) { duration_field_ = new ::google::protobuf::Duration; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.TestWellKnownTypes.duration_field) return duration_field_; } inline ::google::protobuf::Duration* TestWellKnownTypes::release_duration_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.TestWellKnownTypes.duration_field) ::google::protobuf::Duration* temp = duration_field_; duration_field_ = NULL; return temp; } inline void TestWellKnownTypes::set_allocated_duration_field(::google::protobuf::Duration* duration_field) { delete duration_field_; if (duration_field != NULL && duration_field->GetArena() != NULL) { ::google::protobuf::Duration* new_duration_field = new ::google::protobuf::Duration; new_duration_field->CopyFrom(*duration_field); duration_field = new_duration_field; } duration_field_ = duration_field; if (duration_field) { } else { } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestWellKnownTypes.duration_field) } // .google.protobuf.Empty empty_field = 4; inline bool TestWellKnownTypes::has_empty_field() const { return this != internal_default_instance() && empty_field_ != NULL; } inline void TestWellKnownTypes::clear_empty_field() { if (GetArenaNoVirtual() == NULL && empty_field_ != NULL) delete empty_field_; empty_field_ = NULL; } inline const ::google::protobuf::Empty& TestWellKnownTypes::empty_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.TestWellKnownTypes.empty_field) return empty_field_ != NULL ? *empty_field_ : *::google::protobuf::Empty::internal_default_instance(); } inline ::google::protobuf::Empty* TestWellKnownTypes::mutable_empty_field() { if (empty_field_ == NULL) { empty_field_ = new ::google::protobuf::Empty; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.TestWellKnownTypes.empty_field) return empty_field_; } inline ::google::protobuf::Empty* TestWellKnownTypes::release_empty_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.TestWellKnownTypes.empty_field) ::google::protobuf::Empty* temp = empty_field_; empty_field_ = NULL; return temp; } inline void TestWellKnownTypes::set_allocated_empty_field(::google::protobuf::Empty* empty_field) { delete empty_field_; if (empty_field != NULL && empty_field->GetArena() != NULL) { ::google::protobuf::Empty* new_empty_field = new ::google::protobuf::Empty; new_empty_field->CopyFrom(*empty_field); empty_field = new_empty_field; } empty_field_ = empty_field; if (empty_field) { } else { } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestWellKnownTypes.empty_field) } // .google.protobuf.FieldMask field_mask_field = 5; inline bool TestWellKnownTypes::has_field_mask_field() const { return this != internal_default_instance() && field_mask_field_ != NULL; } inline void TestWellKnownTypes::clear_field_mask_field() { if (GetArenaNoVirtual() == NULL && field_mask_field_ != NULL) delete field_mask_field_; field_mask_field_ = NULL; } inline const ::google::protobuf::FieldMask& TestWellKnownTypes::field_mask_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.TestWellKnownTypes.field_mask_field) return field_mask_field_ != NULL ? *field_mask_field_ : *::google::protobuf::FieldMask::internal_default_instance(); } inline ::google::protobuf::FieldMask* TestWellKnownTypes::mutable_field_mask_field() { if (field_mask_field_ == NULL) { field_mask_field_ = new ::google::protobuf::FieldMask; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.TestWellKnownTypes.field_mask_field) return field_mask_field_; } inline ::google::protobuf::FieldMask* TestWellKnownTypes::release_field_mask_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.TestWellKnownTypes.field_mask_field) ::google::protobuf::FieldMask* temp = field_mask_field_; field_mask_field_ = NULL; return temp; } inline void TestWellKnownTypes::set_allocated_field_mask_field(::google::protobuf::FieldMask* field_mask_field) { delete field_mask_field_; field_mask_field_ = field_mask_field; if (field_mask_field) { } else { } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestWellKnownTypes.field_mask_field) } // .google.protobuf.SourceContext source_context_field = 6; inline bool TestWellKnownTypes::has_source_context_field() const { return this != internal_default_instance() && source_context_field_ != NULL; } inline void TestWellKnownTypes::clear_source_context_field() { if (GetArenaNoVirtual() == NULL && source_context_field_ != NULL) delete source_context_field_; source_context_field_ = NULL; } inline const ::google::protobuf::SourceContext& TestWellKnownTypes::source_context_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.TestWellKnownTypes.source_context_field) return source_context_field_ != NULL ? *source_context_field_ : *::google::protobuf::SourceContext::internal_default_instance(); } inline ::google::protobuf::SourceContext* TestWellKnownTypes::mutable_source_context_field() { if (source_context_field_ == NULL) { source_context_field_ = new ::google::protobuf::SourceContext; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.TestWellKnownTypes.source_context_field) return source_context_field_; } inline ::google::protobuf::SourceContext* TestWellKnownTypes::release_source_context_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.TestWellKnownTypes.source_context_field) ::google::protobuf::SourceContext* temp = source_context_field_; source_context_field_ = NULL; return temp; } inline void TestWellKnownTypes::set_allocated_source_context_field(::google::protobuf::SourceContext* source_context_field) { delete source_context_field_; source_context_field_ = source_context_field; if (source_context_field) { } else { } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestWellKnownTypes.source_context_field) } // .google.protobuf.Struct struct_field = 7; inline bool TestWellKnownTypes::has_struct_field() const { return this != internal_default_instance() && struct_field_ != NULL; } inline void TestWellKnownTypes::clear_struct_field() { if (GetArenaNoVirtual() == NULL && struct_field_ != NULL) delete struct_field_; struct_field_ = NULL; } inline const ::google::protobuf::Struct& TestWellKnownTypes::struct_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.TestWellKnownTypes.struct_field) return struct_field_ != NULL ? *struct_field_ : *::google::protobuf::Struct::internal_default_instance(); } inline ::google::protobuf::Struct* TestWellKnownTypes::mutable_struct_field() { if (struct_field_ == NULL) { struct_field_ = new ::google::protobuf::Struct; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.TestWellKnownTypes.struct_field) return struct_field_; } inline ::google::protobuf::Struct* TestWellKnownTypes::release_struct_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.TestWellKnownTypes.struct_field) ::google::protobuf::Struct* temp = struct_field_; struct_field_ = NULL; return temp; } inline void TestWellKnownTypes::set_allocated_struct_field(::google::protobuf::Struct* struct_field) { delete struct_field_; if (struct_field != NULL && struct_field->GetArena() != NULL) { ::google::protobuf::Struct* new_struct_field = new ::google::protobuf::Struct; new_struct_field->CopyFrom(*struct_field); struct_field = new_struct_field; } struct_field_ = struct_field; if (struct_field) { } else { } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestWellKnownTypes.struct_field) } // .google.protobuf.Timestamp timestamp_field = 8; inline bool TestWellKnownTypes::has_timestamp_field() const { return this != internal_default_instance() && timestamp_field_ != NULL; } inline void TestWellKnownTypes::clear_timestamp_field() { if (GetArenaNoVirtual() == NULL && timestamp_field_ != NULL) delete timestamp_field_; timestamp_field_ = NULL; } inline const ::google::protobuf::Timestamp& TestWellKnownTypes::timestamp_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.TestWellKnownTypes.timestamp_field) return timestamp_field_ != NULL ? *timestamp_field_ : *::google::protobuf::Timestamp::internal_default_instance(); } inline ::google::protobuf::Timestamp* TestWellKnownTypes::mutable_timestamp_field() { if (timestamp_field_ == NULL) { timestamp_field_ = new ::google::protobuf::Timestamp; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.TestWellKnownTypes.timestamp_field) return timestamp_field_; } inline ::google::protobuf::Timestamp* TestWellKnownTypes::release_timestamp_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.TestWellKnownTypes.timestamp_field) ::google::protobuf::Timestamp* temp = timestamp_field_; timestamp_field_ = NULL; return temp; } inline void TestWellKnownTypes::set_allocated_timestamp_field(::google::protobuf::Timestamp* timestamp_field) { delete timestamp_field_; if (timestamp_field != NULL && timestamp_field->GetArena() != NULL) { ::google::protobuf::Timestamp* new_timestamp_field = new ::google::protobuf::Timestamp; new_timestamp_field->CopyFrom(*timestamp_field); timestamp_field = new_timestamp_field; } timestamp_field_ = timestamp_field; if (timestamp_field) { } else { } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestWellKnownTypes.timestamp_field) } // .google.protobuf.Type type_field = 9; inline bool TestWellKnownTypes::has_type_field() const { return this != internal_default_instance() && type_field_ != NULL; } inline void TestWellKnownTypes::clear_type_field() { if (GetArenaNoVirtual() == NULL && type_field_ != NULL) delete type_field_; type_field_ = NULL; } inline const ::google::protobuf::Type& TestWellKnownTypes::type_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.TestWellKnownTypes.type_field) return type_field_ != NULL ? *type_field_ : *::google::protobuf::Type::internal_default_instance(); } inline ::google::protobuf::Type* TestWellKnownTypes::mutable_type_field() { if (type_field_ == NULL) { type_field_ = new ::google::protobuf::Type; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.TestWellKnownTypes.type_field) return type_field_; } inline ::google::protobuf::Type* TestWellKnownTypes::release_type_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.TestWellKnownTypes.type_field) ::google::protobuf::Type* temp = type_field_; type_field_ = NULL; return temp; } inline void TestWellKnownTypes::set_allocated_type_field(::google::protobuf::Type* type_field) { delete type_field_; if (type_field != NULL && type_field->GetArena() != NULL) { ::google::protobuf::Type* new_type_field = new ::google::protobuf::Type; new_type_field->CopyFrom(*type_field); type_field = new_type_field; } type_field_ = type_field; if (type_field) { } else { } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestWellKnownTypes.type_field) } // .google.protobuf.DoubleValue double_field = 10; inline bool TestWellKnownTypes::has_double_field() const { return this != internal_default_instance() && double_field_ != NULL; } inline void TestWellKnownTypes::clear_double_field() { if (GetArenaNoVirtual() == NULL && double_field_ != NULL) delete double_field_; double_field_ = NULL; } inline const ::google::protobuf::DoubleValue& TestWellKnownTypes::double_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.TestWellKnownTypes.double_field) return double_field_ != NULL ? *double_field_ : *::google::protobuf::DoubleValue::internal_default_instance(); } inline ::google::protobuf::DoubleValue* TestWellKnownTypes::mutable_double_field() { if (double_field_ == NULL) { double_field_ = new ::google::protobuf::DoubleValue; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.TestWellKnownTypes.double_field) return double_field_; } inline ::google::protobuf::DoubleValue* TestWellKnownTypes::release_double_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.TestWellKnownTypes.double_field) ::google::protobuf::DoubleValue* temp = double_field_; double_field_ = NULL; return temp; } inline void TestWellKnownTypes::set_allocated_double_field(::google::protobuf::DoubleValue* double_field) { delete double_field_; if (double_field != NULL && double_field->GetArena() != NULL) { ::google::protobuf::DoubleValue* new_double_field = new ::google::protobuf::DoubleValue; new_double_field->CopyFrom(*double_field); double_field = new_double_field; } double_field_ = double_field; if (double_field) { } else { } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestWellKnownTypes.double_field) } // .google.protobuf.FloatValue float_field = 11; inline bool TestWellKnownTypes::has_float_field() const { return this != internal_default_instance() && float_field_ != NULL; } inline void TestWellKnownTypes::clear_float_field() { if (GetArenaNoVirtual() == NULL && float_field_ != NULL) delete float_field_; float_field_ = NULL; } inline const ::google::protobuf::FloatValue& TestWellKnownTypes::float_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.TestWellKnownTypes.float_field) return float_field_ != NULL ? *float_field_ : *::google::protobuf::FloatValue::internal_default_instance(); } inline ::google::protobuf::FloatValue* TestWellKnownTypes::mutable_float_field() { if (float_field_ == NULL) { float_field_ = new ::google::protobuf::FloatValue; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.TestWellKnownTypes.float_field) return float_field_; } inline ::google::protobuf::FloatValue* TestWellKnownTypes::release_float_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.TestWellKnownTypes.float_field) ::google::protobuf::FloatValue* temp = float_field_; float_field_ = NULL; return temp; } inline void TestWellKnownTypes::set_allocated_float_field(::google::protobuf::FloatValue* float_field) { delete float_field_; if (float_field != NULL && float_field->GetArena() != NULL) { ::google::protobuf::FloatValue* new_float_field = new ::google::protobuf::FloatValue; new_float_field->CopyFrom(*float_field); float_field = new_float_field; } float_field_ = float_field; if (float_field) { } else { } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestWellKnownTypes.float_field) } // .google.protobuf.Int64Value int64_field = 12; inline bool TestWellKnownTypes::has_int64_field() const { return this != internal_default_instance() && int64_field_ != NULL; } inline void TestWellKnownTypes::clear_int64_field() { if (GetArenaNoVirtual() == NULL && int64_field_ != NULL) delete int64_field_; int64_field_ = NULL; } inline const ::google::protobuf::Int64Value& TestWellKnownTypes::int64_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.TestWellKnownTypes.int64_field) return int64_field_ != NULL ? *int64_field_ : *::google::protobuf::Int64Value::internal_default_instance(); } inline ::google::protobuf::Int64Value* TestWellKnownTypes::mutable_int64_field() { if (int64_field_ == NULL) { int64_field_ = new ::google::protobuf::Int64Value; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.TestWellKnownTypes.int64_field) return int64_field_; } inline ::google::protobuf::Int64Value* TestWellKnownTypes::release_int64_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.TestWellKnownTypes.int64_field) ::google::protobuf::Int64Value* temp = int64_field_; int64_field_ = NULL; return temp; } inline void TestWellKnownTypes::set_allocated_int64_field(::google::protobuf::Int64Value* int64_field) { delete int64_field_; if (int64_field != NULL && int64_field->GetArena() != NULL) { ::google::protobuf::Int64Value* new_int64_field = new ::google::protobuf::Int64Value; new_int64_field->CopyFrom(*int64_field); int64_field = new_int64_field; } int64_field_ = int64_field; if (int64_field) { } else { } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestWellKnownTypes.int64_field) } // .google.protobuf.UInt64Value uint64_field = 13; inline bool TestWellKnownTypes::has_uint64_field() const { return this != internal_default_instance() && uint64_field_ != NULL; } inline void TestWellKnownTypes::clear_uint64_field() { if (GetArenaNoVirtual() == NULL && uint64_field_ != NULL) delete uint64_field_; uint64_field_ = NULL; } inline const ::google::protobuf::UInt64Value& TestWellKnownTypes::uint64_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.TestWellKnownTypes.uint64_field) return uint64_field_ != NULL ? *uint64_field_ : *::google::protobuf::UInt64Value::internal_default_instance(); } inline ::google::protobuf::UInt64Value* TestWellKnownTypes::mutable_uint64_field() { if (uint64_field_ == NULL) { uint64_field_ = new ::google::protobuf::UInt64Value; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.TestWellKnownTypes.uint64_field) return uint64_field_; } inline ::google::protobuf::UInt64Value* TestWellKnownTypes::release_uint64_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.TestWellKnownTypes.uint64_field) ::google::protobuf::UInt64Value* temp = uint64_field_; uint64_field_ = NULL; return temp; } inline void TestWellKnownTypes::set_allocated_uint64_field(::google::protobuf::UInt64Value* uint64_field) { delete uint64_field_; if (uint64_field != NULL && uint64_field->GetArena() != NULL) { ::google::protobuf::UInt64Value* new_uint64_field = new ::google::protobuf::UInt64Value; new_uint64_field->CopyFrom(*uint64_field); uint64_field = new_uint64_field; } uint64_field_ = uint64_field; if (uint64_field) { } else { } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestWellKnownTypes.uint64_field) } // .google.protobuf.Int32Value int32_field = 14; inline bool TestWellKnownTypes::has_int32_field() const { return this != internal_default_instance() && int32_field_ != NULL; } inline void TestWellKnownTypes::clear_int32_field() { if (GetArenaNoVirtual() == NULL && int32_field_ != NULL) delete int32_field_; int32_field_ = NULL; } inline const ::google::protobuf::Int32Value& TestWellKnownTypes::int32_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.TestWellKnownTypes.int32_field) return int32_field_ != NULL ? *int32_field_ : *::google::protobuf::Int32Value::internal_default_instance(); } inline ::google::protobuf::Int32Value* TestWellKnownTypes::mutable_int32_field() { if (int32_field_ == NULL) { int32_field_ = new ::google::protobuf::Int32Value; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.TestWellKnownTypes.int32_field) return int32_field_; } inline ::google::protobuf::Int32Value* TestWellKnownTypes::release_int32_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.TestWellKnownTypes.int32_field) ::google::protobuf::Int32Value* temp = int32_field_; int32_field_ = NULL; return temp; } inline void TestWellKnownTypes::set_allocated_int32_field(::google::protobuf::Int32Value* int32_field) { delete int32_field_; if (int32_field != NULL && int32_field->GetArena() != NULL) { ::google::protobuf::Int32Value* new_int32_field = new ::google::protobuf::Int32Value; new_int32_field->CopyFrom(*int32_field); int32_field = new_int32_field; } int32_field_ = int32_field; if (int32_field) { } else { } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestWellKnownTypes.int32_field) } // .google.protobuf.UInt32Value uint32_field = 15; inline bool TestWellKnownTypes::has_uint32_field() const { return this != internal_default_instance() && uint32_field_ != NULL; } inline void TestWellKnownTypes::clear_uint32_field() { if (GetArenaNoVirtual() == NULL && uint32_field_ != NULL) delete uint32_field_; uint32_field_ = NULL; } inline const ::google::protobuf::UInt32Value& TestWellKnownTypes::uint32_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.TestWellKnownTypes.uint32_field) return uint32_field_ != NULL ? *uint32_field_ : *::google::protobuf::UInt32Value::internal_default_instance(); } inline ::google::protobuf::UInt32Value* TestWellKnownTypes::mutable_uint32_field() { if (uint32_field_ == NULL) { uint32_field_ = new ::google::protobuf::UInt32Value; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.TestWellKnownTypes.uint32_field) return uint32_field_; } inline ::google::protobuf::UInt32Value* TestWellKnownTypes::release_uint32_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.TestWellKnownTypes.uint32_field) ::google::protobuf::UInt32Value* temp = uint32_field_; uint32_field_ = NULL; return temp; } inline void TestWellKnownTypes::set_allocated_uint32_field(::google::protobuf::UInt32Value* uint32_field) { delete uint32_field_; if (uint32_field != NULL && uint32_field->GetArena() != NULL) { ::google::protobuf::UInt32Value* new_uint32_field = new ::google::protobuf::UInt32Value; new_uint32_field->CopyFrom(*uint32_field); uint32_field = new_uint32_field; } uint32_field_ = uint32_field; if (uint32_field) { } else { } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestWellKnownTypes.uint32_field) } // .google.protobuf.BoolValue bool_field = 16; inline bool TestWellKnownTypes::has_bool_field() const { return this != internal_default_instance() && bool_field_ != NULL; } inline void TestWellKnownTypes::clear_bool_field() { if (GetArenaNoVirtual() == NULL && bool_field_ != NULL) delete bool_field_; bool_field_ = NULL; } inline const ::google::protobuf::BoolValue& TestWellKnownTypes::bool_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.TestWellKnownTypes.bool_field) return bool_field_ != NULL ? *bool_field_ : *::google::protobuf::BoolValue::internal_default_instance(); } inline ::google::protobuf::BoolValue* TestWellKnownTypes::mutable_bool_field() { if (bool_field_ == NULL) { bool_field_ = new ::google::protobuf::BoolValue; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.TestWellKnownTypes.bool_field) return bool_field_; } inline ::google::protobuf::BoolValue* TestWellKnownTypes::release_bool_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.TestWellKnownTypes.bool_field) ::google::protobuf::BoolValue* temp = bool_field_; bool_field_ = NULL; return temp; } inline void TestWellKnownTypes::set_allocated_bool_field(::google::protobuf::BoolValue* bool_field) { delete bool_field_; if (bool_field != NULL && bool_field->GetArena() != NULL) { ::google::protobuf::BoolValue* new_bool_field = new ::google::protobuf::BoolValue; new_bool_field->CopyFrom(*bool_field); bool_field = new_bool_field; } bool_field_ = bool_field; if (bool_field) { } else { } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestWellKnownTypes.bool_field) } // .google.protobuf.StringValue string_field = 17; inline bool TestWellKnownTypes::has_string_field() const { return this != internal_default_instance() && string_field_ != NULL; } inline void TestWellKnownTypes::clear_string_field() { if (GetArenaNoVirtual() == NULL && string_field_ != NULL) delete string_field_; string_field_ = NULL; } inline const ::google::protobuf::StringValue& TestWellKnownTypes::string_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.TestWellKnownTypes.string_field) return string_field_ != NULL ? *string_field_ : *::google::protobuf::StringValue::internal_default_instance(); } inline ::google::protobuf::StringValue* TestWellKnownTypes::mutable_string_field() { if (string_field_ == NULL) { string_field_ = new ::google::protobuf::StringValue; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.TestWellKnownTypes.string_field) return string_field_; } inline ::google::protobuf::StringValue* TestWellKnownTypes::release_string_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.TestWellKnownTypes.string_field) ::google::protobuf::StringValue* temp = string_field_; string_field_ = NULL; return temp; } inline void TestWellKnownTypes::set_allocated_string_field(::google::protobuf::StringValue* string_field) { delete string_field_; if (string_field != NULL && string_field->GetArena() != NULL) { ::google::protobuf::StringValue* new_string_field = new ::google::protobuf::StringValue; new_string_field->CopyFrom(*string_field); string_field = new_string_field; } string_field_ = string_field; if (string_field) { } else { } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestWellKnownTypes.string_field) } // .google.protobuf.BytesValue bytes_field = 18; inline bool TestWellKnownTypes::has_bytes_field() const { return this != internal_default_instance() && bytes_field_ != NULL; } inline void TestWellKnownTypes::clear_bytes_field() { if (GetArenaNoVirtual() == NULL && bytes_field_ != NULL) delete bytes_field_; bytes_field_ = NULL; } inline const ::google::protobuf::BytesValue& TestWellKnownTypes::bytes_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.TestWellKnownTypes.bytes_field) return bytes_field_ != NULL ? *bytes_field_ : *::google::protobuf::BytesValue::internal_default_instance(); } inline ::google::protobuf::BytesValue* TestWellKnownTypes::mutable_bytes_field() { if (bytes_field_ == NULL) { bytes_field_ = new ::google::protobuf::BytesValue; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.TestWellKnownTypes.bytes_field) return bytes_field_; } inline ::google::protobuf::BytesValue* TestWellKnownTypes::release_bytes_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.TestWellKnownTypes.bytes_field) ::google::protobuf::BytesValue* temp = bytes_field_; bytes_field_ = NULL; return temp; } inline void TestWellKnownTypes::set_allocated_bytes_field(::google::protobuf::BytesValue* bytes_field) { delete bytes_field_; if (bytes_field != NULL && bytes_field->GetArena() != NULL) { ::google::protobuf::BytesValue* new_bytes_field = new ::google::protobuf::BytesValue; new_bytes_field->CopyFrom(*bytes_field); bytes_field = new_bytes_field; } bytes_field_ = bytes_field; if (bytes_field) { } else { } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestWellKnownTypes.bytes_field) } // .google.protobuf.Value value_field = 19; inline bool TestWellKnownTypes::has_value_field() const { return this != internal_default_instance() && value_field_ != NULL; } inline void TestWellKnownTypes::clear_value_field() { if (GetArenaNoVirtual() == NULL && value_field_ != NULL) delete value_field_; value_field_ = NULL; } inline const ::google::protobuf::Value& TestWellKnownTypes::value_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.TestWellKnownTypes.value_field) return value_field_ != NULL ? *value_field_ : *::google::protobuf::Value::internal_default_instance(); } inline ::google::protobuf::Value* TestWellKnownTypes::mutable_value_field() { if (value_field_ == NULL) { value_field_ = new ::google::protobuf::Value; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.TestWellKnownTypes.value_field) return value_field_; } inline ::google::protobuf::Value* TestWellKnownTypes::release_value_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.TestWellKnownTypes.value_field) ::google::protobuf::Value* temp = value_field_; value_field_ = NULL; return temp; } inline void TestWellKnownTypes::set_allocated_value_field(::google::protobuf::Value* value_field) { delete value_field_; if (value_field != NULL && value_field->GetArena() != NULL) { ::google::protobuf::Value* new_value_field = new ::google::protobuf::Value; new_value_field->CopyFrom(*value_field); value_field = new_value_field; } value_field_ = value_field; if (value_field) { } else { } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.TestWellKnownTypes.value_field) } // ------------------------------------------------------------------- // RepeatedWellKnownTypes // repeated .google.protobuf.Any any_field = 1; inline int RepeatedWellKnownTypes::any_field_size() const { return any_field_.size(); } inline void RepeatedWellKnownTypes::clear_any_field() { any_field_.Clear(); } inline const ::google::protobuf::Any& RepeatedWellKnownTypes::any_field(int index) const { // @@protoc_insertion_point(field_get:protobuf_unittest.RepeatedWellKnownTypes.any_field) return any_field_.Get(index); } inline ::google::protobuf::Any* RepeatedWellKnownTypes::mutable_any_field(int index) { // @@protoc_insertion_point(field_mutable:protobuf_unittest.RepeatedWellKnownTypes.any_field) return any_field_.Mutable(index); } inline ::google::protobuf::Any* RepeatedWellKnownTypes::add_any_field() { // @@protoc_insertion_point(field_add:protobuf_unittest.RepeatedWellKnownTypes.any_field) return any_field_.Add(); } inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Any >* RepeatedWellKnownTypes::mutable_any_field() { // @@protoc_insertion_point(field_mutable_list:protobuf_unittest.RepeatedWellKnownTypes.any_field) return &any_field_; } inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Any >& RepeatedWellKnownTypes::any_field() const { // @@protoc_insertion_point(field_list:protobuf_unittest.RepeatedWellKnownTypes.any_field) return any_field_; } // repeated .google.protobuf.Api api_field = 2; inline int RepeatedWellKnownTypes::api_field_size() const { return api_field_.size(); } inline void RepeatedWellKnownTypes::clear_api_field() { api_field_.Clear(); } inline const ::google::protobuf::Api& RepeatedWellKnownTypes::api_field(int index) const { // @@protoc_insertion_point(field_get:protobuf_unittest.RepeatedWellKnownTypes.api_field) return api_field_.Get(index); } inline ::google::protobuf::Api* RepeatedWellKnownTypes::mutable_api_field(int index) { // @@protoc_insertion_point(field_mutable:protobuf_unittest.RepeatedWellKnownTypes.api_field) return api_field_.Mutable(index); } inline ::google::protobuf::Api* RepeatedWellKnownTypes::add_api_field() { // @@protoc_insertion_point(field_add:protobuf_unittest.RepeatedWellKnownTypes.api_field) return api_field_.Add(); } inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Api >* RepeatedWellKnownTypes::mutable_api_field() { // @@protoc_insertion_point(field_mutable_list:protobuf_unittest.RepeatedWellKnownTypes.api_field) return &api_field_; } inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Api >& RepeatedWellKnownTypes::api_field() const { // @@protoc_insertion_point(field_list:protobuf_unittest.RepeatedWellKnownTypes.api_field) return api_field_; } // repeated .google.protobuf.Duration duration_field = 3; inline int RepeatedWellKnownTypes::duration_field_size() const { return duration_field_.size(); } inline void RepeatedWellKnownTypes::clear_duration_field() { duration_field_.Clear(); } inline const ::google::protobuf::Duration& RepeatedWellKnownTypes::duration_field(int index) const { // @@protoc_insertion_point(field_get:protobuf_unittest.RepeatedWellKnownTypes.duration_field) return duration_field_.Get(index); } inline ::google::protobuf::Duration* RepeatedWellKnownTypes::mutable_duration_field(int index) { // @@protoc_insertion_point(field_mutable:protobuf_unittest.RepeatedWellKnownTypes.duration_field) return duration_field_.Mutable(index); } inline ::google::protobuf::Duration* RepeatedWellKnownTypes::add_duration_field() { // @@protoc_insertion_point(field_add:protobuf_unittest.RepeatedWellKnownTypes.duration_field) return duration_field_.Add(); } inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Duration >* RepeatedWellKnownTypes::mutable_duration_field() { // @@protoc_insertion_point(field_mutable_list:protobuf_unittest.RepeatedWellKnownTypes.duration_field) return &duration_field_; } inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Duration >& RepeatedWellKnownTypes::duration_field() const { // @@protoc_insertion_point(field_list:protobuf_unittest.RepeatedWellKnownTypes.duration_field) return duration_field_; } // repeated .google.protobuf.Empty empty_field = 4; inline int RepeatedWellKnownTypes::empty_field_size() const { return empty_field_.size(); } inline void RepeatedWellKnownTypes::clear_empty_field() { empty_field_.Clear(); } inline const ::google::protobuf::Empty& RepeatedWellKnownTypes::empty_field(int index) const { // @@protoc_insertion_point(field_get:protobuf_unittest.RepeatedWellKnownTypes.empty_field) return empty_field_.Get(index); } inline ::google::protobuf::Empty* RepeatedWellKnownTypes::mutable_empty_field(int index) { // @@protoc_insertion_point(field_mutable:protobuf_unittest.RepeatedWellKnownTypes.empty_field) return empty_field_.Mutable(index); } inline ::google::protobuf::Empty* RepeatedWellKnownTypes::add_empty_field() { // @@protoc_insertion_point(field_add:protobuf_unittest.RepeatedWellKnownTypes.empty_field) return empty_field_.Add(); } inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Empty >* RepeatedWellKnownTypes::mutable_empty_field() { // @@protoc_insertion_point(field_mutable_list:protobuf_unittest.RepeatedWellKnownTypes.empty_field) return &empty_field_; } inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Empty >& RepeatedWellKnownTypes::empty_field() const { // @@protoc_insertion_point(field_list:protobuf_unittest.RepeatedWellKnownTypes.empty_field) return empty_field_; } // repeated .google.protobuf.FieldMask field_mask_field = 5; inline int RepeatedWellKnownTypes::field_mask_field_size() const { return field_mask_field_.size(); } inline void RepeatedWellKnownTypes::clear_field_mask_field() { field_mask_field_.Clear(); } inline const ::google::protobuf::FieldMask& RepeatedWellKnownTypes::field_mask_field(int index) const { // @@protoc_insertion_point(field_get:protobuf_unittest.RepeatedWellKnownTypes.field_mask_field) return field_mask_field_.Get(index); } inline ::google::protobuf::FieldMask* RepeatedWellKnownTypes::mutable_field_mask_field(int index) { // @@protoc_insertion_point(field_mutable:protobuf_unittest.RepeatedWellKnownTypes.field_mask_field) return field_mask_field_.Mutable(index); } inline ::google::protobuf::FieldMask* RepeatedWellKnownTypes::add_field_mask_field() { // @@protoc_insertion_point(field_add:protobuf_unittest.RepeatedWellKnownTypes.field_mask_field) return field_mask_field_.Add(); } inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldMask >* RepeatedWellKnownTypes::mutable_field_mask_field() { // @@protoc_insertion_point(field_mutable_list:protobuf_unittest.RepeatedWellKnownTypes.field_mask_field) return &field_mask_field_; } inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FieldMask >& RepeatedWellKnownTypes::field_mask_field() const { // @@protoc_insertion_point(field_list:protobuf_unittest.RepeatedWellKnownTypes.field_mask_field) return field_mask_field_; } // repeated .google.protobuf.SourceContext source_context_field = 6; inline int RepeatedWellKnownTypes::source_context_field_size() const { return source_context_field_.size(); } inline void RepeatedWellKnownTypes::clear_source_context_field() { source_context_field_.Clear(); } inline const ::google::protobuf::SourceContext& RepeatedWellKnownTypes::source_context_field(int index) const { // @@protoc_insertion_point(field_get:protobuf_unittest.RepeatedWellKnownTypes.source_context_field) return source_context_field_.Get(index); } inline ::google::protobuf::SourceContext* RepeatedWellKnownTypes::mutable_source_context_field(int index) { // @@protoc_insertion_point(field_mutable:protobuf_unittest.RepeatedWellKnownTypes.source_context_field) return source_context_field_.Mutable(index); } inline ::google::protobuf::SourceContext* RepeatedWellKnownTypes::add_source_context_field() { // @@protoc_insertion_point(field_add:protobuf_unittest.RepeatedWellKnownTypes.source_context_field) return source_context_field_.Add(); } inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceContext >* RepeatedWellKnownTypes::mutable_source_context_field() { // @@protoc_insertion_point(field_mutable_list:protobuf_unittest.RepeatedWellKnownTypes.source_context_field) return &source_context_field_; } inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::SourceContext >& RepeatedWellKnownTypes::source_context_field() const { // @@protoc_insertion_point(field_list:protobuf_unittest.RepeatedWellKnownTypes.source_context_field) return source_context_field_; } // repeated .google.protobuf.Struct struct_field = 7; inline int RepeatedWellKnownTypes::struct_field_size() const { return struct_field_.size(); } inline void RepeatedWellKnownTypes::clear_struct_field() { struct_field_.Clear(); } inline const ::google::protobuf::Struct& RepeatedWellKnownTypes::struct_field(int index) const { // @@protoc_insertion_point(field_get:protobuf_unittest.RepeatedWellKnownTypes.struct_field) return struct_field_.Get(index); } inline ::google::protobuf::Struct* RepeatedWellKnownTypes::mutable_struct_field(int index) { // @@protoc_insertion_point(field_mutable:protobuf_unittest.RepeatedWellKnownTypes.struct_field) return struct_field_.Mutable(index); } inline ::google::protobuf::Struct* RepeatedWellKnownTypes::add_struct_field() { // @@protoc_insertion_point(field_add:protobuf_unittest.RepeatedWellKnownTypes.struct_field) return struct_field_.Add(); } inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Struct >* RepeatedWellKnownTypes::mutable_struct_field() { // @@protoc_insertion_point(field_mutable_list:protobuf_unittest.RepeatedWellKnownTypes.struct_field) return &struct_field_; } inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Struct >& RepeatedWellKnownTypes::struct_field() const { // @@protoc_insertion_point(field_list:protobuf_unittest.RepeatedWellKnownTypes.struct_field) return struct_field_; } // repeated .google.protobuf.Timestamp timestamp_field = 8; inline int RepeatedWellKnownTypes::timestamp_field_size() const { return timestamp_field_.size(); } inline void RepeatedWellKnownTypes::clear_timestamp_field() { timestamp_field_.Clear(); } inline const ::google::protobuf::Timestamp& RepeatedWellKnownTypes::timestamp_field(int index) const { // @@protoc_insertion_point(field_get:protobuf_unittest.RepeatedWellKnownTypes.timestamp_field) return timestamp_field_.Get(index); } inline ::google::protobuf::Timestamp* RepeatedWellKnownTypes::mutable_timestamp_field(int index) { // @@protoc_insertion_point(field_mutable:protobuf_unittest.RepeatedWellKnownTypes.timestamp_field) return timestamp_field_.Mutable(index); } inline ::google::protobuf::Timestamp* RepeatedWellKnownTypes::add_timestamp_field() { // @@protoc_insertion_point(field_add:protobuf_unittest.RepeatedWellKnownTypes.timestamp_field) return timestamp_field_.Add(); } inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Timestamp >* RepeatedWellKnownTypes::mutable_timestamp_field() { // @@protoc_insertion_point(field_mutable_list:protobuf_unittest.RepeatedWellKnownTypes.timestamp_field) return &timestamp_field_; } inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Timestamp >& RepeatedWellKnownTypes::timestamp_field() const { // @@protoc_insertion_point(field_list:protobuf_unittest.RepeatedWellKnownTypes.timestamp_field) return timestamp_field_; } // repeated .google.protobuf.Type type_field = 9; inline int RepeatedWellKnownTypes::type_field_size() const { return type_field_.size(); } inline void RepeatedWellKnownTypes::clear_type_field() { type_field_.Clear(); } inline const ::google::protobuf::Type& RepeatedWellKnownTypes::type_field(int index) const { // @@protoc_insertion_point(field_get:protobuf_unittest.RepeatedWellKnownTypes.type_field) return type_field_.Get(index); } inline ::google::protobuf::Type* RepeatedWellKnownTypes::mutable_type_field(int index) { // @@protoc_insertion_point(field_mutable:protobuf_unittest.RepeatedWellKnownTypes.type_field) return type_field_.Mutable(index); } inline ::google::protobuf::Type* RepeatedWellKnownTypes::add_type_field() { // @@protoc_insertion_point(field_add:protobuf_unittest.RepeatedWellKnownTypes.type_field) return type_field_.Add(); } inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Type >* RepeatedWellKnownTypes::mutable_type_field() { // @@protoc_insertion_point(field_mutable_list:protobuf_unittest.RepeatedWellKnownTypes.type_field) return &type_field_; } inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Type >& RepeatedWellKnownTypes::type_field() const { // @@protoc_insertion_point(field_list:protobuf_unittest.RepeatedWellKnownTypes.type_field) return type_field_; } // repeated .google.protobuf.DoubleValue double_field = 10; inline int RepeatedWellKnownTypes::double_field_size() const { return double_field_.size(); } inline void RepeatedWellKnownTypes::clear_double_field() { double_field_.Clear(); } inline const ::google::protobuf::DoubleValue& RepeatedWellKnownTypes::double_field(int index) const { // @@protoc_insertion_point(field_get:protobuf_unittest.RepeatedWellKnownTypes.double_field) return double_field_.Get(index); } inline ::google::protobuf::DoubleValue* RepeatedWellKnownTypes::mutable_double_field(int index) { // @@protoc_insertion_point(field_mutable:protobuf_unittest.RepeatedWellKnownTypes.double_field) return double_field_.Mutable(index); } inline ::google::protobuf::DoubleValue* RepeatedWellKnownTypes::add_double_field() { // @@protoc_insertion_point(field_add:protobuf_unittest.RepeatedWellKnownTypes.double_field) return double_field_.Add(); } inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::DoubleValue >* RepeatedWellKnownTypes::mutable_double_field() { // @@protoc_insertion_point(field_mutable_list:protobuf_unittest.RepeatedWellKnownTypes.double_field) return &double_field_; } inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::DoubleValue >& RepeatedWellKnownTypes::double_field() const { // @@protoc_insertion_point(field_list:protobuf_unittest.RepeatedWellKnownTypes.double_field) return double_field_; } // repeated .google.protobuf.FloatValue float_field = 11; inline int RepeatedWellKnownTypes::float_field_size() const { return float_field_.size(); } inline void RepeatedWellKnownTypes::clear_float_field() { float_field_.Clear(); } inline const ::google::protobuf::FloatValue& RepeatedWellKnownTypes::float_field(int index) const { // @@protoc_insertion_point(field_get:protobuf_unittest.RepeatedWellKnownTypes.float_field) return float_field_.Get(index); } inline ::google::protobuf::FloatValue* RepeatedWellKnownTypes::mutable_float_field(int index) { // @@protoc_insertion_point(field_mutable:protobuf_unittest.RepeatedWellKnownTypes.float_field) return float_field_.Mutable(index); } inline ::google::protobuf::FloatValue* RepeatedWellKnownTypes::add_float_field() { // @@protoc_insertion_point(field_add:protobuf_unittest.RepeatedWellKnownTypes.float_field) return float_field_.Add(); } inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::FloatValue >* RepeatedWellKnownTypes::mutable_float_field() { // @@protoc_insertion_point(field_mutable_list:protobuf_unittest.RepeatedWellKnownTypes.float_field) return &float_field_; } inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::FloatValue >& RepeatedWellKnownTypes::float_field() const { // @@protoc_insertion_point(field_list:protobuf_unittest.RepeatedWellKnownTypes.float_field) return float_field_; } // repeated .google.protobuf.Int64Value int64_field = 12; inline int RepeatedWellKnownTypes::int64_field_size() const { return int64_field_.size(); } inline void RepeatedWellKnownTypes::clear_int64_field() { int64_field_.Clear(); } inline const ::google::protobuf::Int64Value& RepeatedWellKnownTypes::int64_field(int index) const { // @@protoc_insertion_point(field_get:protobuf_unittest.RepeatedWellKnownTypes.int64_field) return int64_field_.Get(index); } inline ::google::protobuf::Int64Value* RepeatedWellKnownTypes::mutable_int64_field(int index) { // @@protoc_insertion_point(field_mutable:protobuf_unittest.RepeatedWellKnownTypes.int64_field) return int64_field_.Mutable(index); } inline ::google::protobuf::Int64Value* RepeatedWellKnownTypes::add_int64_field() { // @@protoc_insertion_point(field_add:protobuf_unittest.RepeatedWellKnownTypes.int64_field) return int64_field_.Add(); } inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Int64Value >* RepeatedWellKnownTypes::mutable_int64_field() { // @@protoc_insertion_point(field_mutable_list:protobuf_unittest.RepeatedWellKnownTypes.int64_field) return &int64_field_; } inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Int64Value >& RepeatedWellKnownTypes::int64_field() const { // @@protoc_insertion_point(field_list:protobuf_unittest.RepeatedWellKnownTypes.int64_field) return int64_field_; } // repeated .google.protobuf.UInt64Value uint64_field = 13; inline int RepeatedWellKnownTypes::uint64_field_size() const { return uint64_field_.size(); } inline void RepeatedWellKnownTypes::clear_uint64_field() { uint64_field_.Clear(); } inline const ::google::protobuf::UInt64Value& RepeatedWellKnownTypes::uint64_field(int index) const { // @@protoc_insertion_point(field_get:protobuf_unittest.RepeatedWellKnownTypes.uint64_field) return uint64_field_.Get(index); } inline ::google::protobuf::UInt64Value* RepeatedWellKnownTypes::mutable_uint64_field(int index) { // @@protoc_insertion_point(field_mutable:protobuf_unittest.RepeatedWellKnownTypes.uint64_field) return uint64_field_.Mutable(index); } inline ::google::protobuf::UInt64Value* RepeatedWellKnownTypes::add_uint64_field() { // @@protoc_insertion_point(field_add:protobuf_unittest.RepeatedWellKnownTypes.uint64_field) return uint64_field_.Add(); } inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UInt64Value >* RepeatedWellKnownTypes::mutable_uint64_field() { // @@protoc_insertion_point(field_mutable_list:protobuf_unittest.RepeatedWellKnownTypes.uint64_field) return &uint64_field_; } inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UInt64Value >& RepeatedWellKnownTypes::uint64_field() const { // @@protoc_insertion_point(field_list:protobuf_unittest.RepeatedWellKnownTypes.uint64_field) return uint64_field_; } // repeated .google.protobuf.Int32Value int32_field = 14; inline int RepeatedWellKnownTypes::int32_field_size() const { return int32_field_.size(); } inline void RepeatedWellKnownTypes::clear_int32_field() { int32_field_.Clear(); } inline const ::google::protobuf::Int32Value& RepeatedWellKnownTypes::int32_field(int index) const { // @@protoc_insertion_point(field_get:protobuf_unittest.RepeatedWellKnownTypes.int32_field) return int32_field_.Get(index); } inline ::google::protobuf::Int32Value* RepeatedWellKnownTypes::mutable_int32_field(int index) { // @@protoc_insertion_point(field_mutable:protobuf_unittest.RepeatedWellKnownTypes.int32_field) return int32_field_.Mutable(index); } inline ::google::protobuf::Int32Value* RepeatedWellKnownTypes::add_int32_field() { // @@protoc_insertion_point(field_add:protobuf_unittest.RepeatedWellKnownTypes.int32_field) return int32_field_.Add(); } inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::Int32Value >* RepeatedWellKnownTypes::mutable_int32_field() { // @@protoc_insertion_point(field_mutable_list:protobuf_unittest.RepeatedWellKnownTypes.int32_field) return &int32_field_; } inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::Int32Value >& RepeatedWellKnownTypes::int32_field() const { // @@protoc_insertion_point(field_list:protobuf_unittest.RepeatedWellKnownTypes.int32_field) return int32_field_; } // repeated .google.protobuf.UInt32Value uint32_field = 15; inline int RepeatedWellKnownTypes::uint32_field_size() const { return uint32_field_.size(); } inline void RepeatedWellKnownTypes::clear_uint32_field() { uint32_field_.Clear(); } inline const ::google::protobuf::UInt32Value& RepeatedWellKnownTypes::uint32_field(int index) const { // @@protoc_insertion_point(field_get:protobuf_unittest.RepeatedWellKnownTypes.uint32_field) return uint32_field_.Get(index); } inline ::google::protobuf::UInt32Value* RepeatedWellKnownTypes::mutable_uint32_field(int index) { // @@protoc_insertion_point(field_mutable:protobuf_unittest.RepeatedWellKnownTypes.uint32_field) return uint32_field_.Mutable(index); } inline ::google::protobuf::UInt32Value* RepeatedWellKnownTypes::add_uint32_field() { // @@protoc_insertion_point(field_add:protobuf_unittest.RepeatedWellKnownTypes.uint32_field) return uint32_field_.Add(); } inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::UInt32Value >* RepeatedWellKnownTypes::mutable_uint32_field() { // @@protoc_insertion_point(field_mutable_list:protobuf_unittest.RepeatedWellKnownTypes.uint32_field) return &uint32_field_; } inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::UInt32Value >& RepeatedWellKnownTypes::uint32_field() const { // @@protoc_insertion_point(field_list:protobuf_unittest.RepeatedWellKnownTypes.uint32_field) return uint32_field_; } // repeated .google.protobuf.BoolValue bool_field = 16; inline int RepeatedWellKnownTypes::bool_field_size() const { return bool_field_.size(); } inline void RepeatedWellKnownTypes::clear_bool_field() { bool_field_.Clear(); } inline const ::google::protobuf::BoolValue& RepeatedWellKnownTypes::bool_field(int index) const { // @@protoc_insertion_point(field_get:protobuf_unittest.RepeatedWellKnownTypes.bool_field) return bool_field_.Get(index); } inline ::google::protobuf::BoolValue* RepeatedWellKnownTypes::mutable_bool_field(int index) { // @@protoc_insertion_point(field_mutable:protobuf_unittest.RepeatedWellKnownTypes.bool_field) return bool_field_.Mutable(index); } inline ::google::protobuf::BoolValue* RepeatedWellKnownTypes::add_bool_field() { // @@protoc_insertion_point(field_add:protobuf_unittest.RepeatedWellKnownTypes.bool_field) return bool_field_.Add(); } inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::BoolValue >* RepeatedWellKnownTypes::mutable_bool_field() { // @@protoc_insertion_point(field_mutable_list:protobuf_unittest.RepeatedWellKnownTypes.bool_field) return &bool_field_; } inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::BoolValue >& RepeatedWellKnownTypes::bool_field() const { // @@protoc_insertion_point(field_list:protobuf_unittest.RepeatedWellKnownTypes.bool_field) return bool_field_; } // repeated .google.protobuf.StringValue string_field = 17; inline int RepeatedWellKnownTypes::string_field_size() const { return string_field_.size(); } inline void RepeatedWellKnownTypes::clear_string_field() { string_field_.Clear(); } inline const ::google::protobuf::StringValue& RepeatedWellKnownTypes::string_field(int index) const { // @@protoc_insertion_point(field_get:protobuf_unittest.RepeatedWellKnownTypes.string_field) return string_field_.Get(index); } inline ::google::protobuf::StringValue* RepeatedWellKnownTypes::mutable_string_field(int index) { // @@protoc_insertion_point(field_mutable:protobuf_unittest.RepeatedWellKnownTypes.string_field) return string_field_.Mutable(index); } inline ::google::protobuf::StringValue* RepeatedWellKnownTypes::add_string_field() { // @@protoc_insertion_point(field_add:protobuf_unittest.RepeatedWellKnownTypes.string_field) return string_field_.Add(); } inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::StringValue >* RepeatedWellKnownTypes::mutable_string_field() { // @@protoc_insertion_point(field_mutable_list:protobuf_unittest.RepeatedWellKnownTypes.string_field) return &string_field_; } inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::StringValue >& RepeatedWellKnownTypes::string_field() const { // @@protoc_insertion_point(field_list:protobuf_unittest.RepeatedWellKnownTypes.string_field) return string_field_; } // repeated .google.protobuf.BytesValue bytes_field = 18; inline int RepeatedWellKnownTypes::bytes_field_size() const { return bytes_field_.size(); } inline void RepeatedWellKnownTypes::clear_bytes_field() { bytes_field_.Clear(); } inline const ::google::protobuf::BytesValue& RepeatedWellKnownTypes::bytes_field(int index) const { // @@protoc_insertion_point(field_get:protobuf_unittest.RepeatedWellKnownTypes.bytes_field) return bytes_field_.Get(index); } inline ::google::protobuf::BytesValue* RepeatedWellKnownTypes::mutable_bytes_field(int index) { // @@protoc_insertion_point(field_mutable:protobuf_unittest.RepeatedWellKnownTypes.bytes_field) return bytes_field_.Mutable(index); } inline ::google::protobuf::BytesValue* RepeatedWellKnownTypes::add_bytes_field() { // @@protoc_insertion_point(field_add:protobuf_unittest.RepeatedWellKnownTypes.bytes_field) return bytes_field_.Add(); } inline ::google::protobuf::RepeatedPtrField< ::google::protobuf::BytesValue >* RepeatedWellKnownTypes::mutable_bytes_field() { // @@protoc_insertion_point(field_mutable_list:protobuf_unittest.RepeatedWellKnownTypes.bytes_field) return &bytes_field_; } inline const ::google::protobuf::RepeatedPtrField< ::google::protobuf::BytesValue >& RepeatedWellKnownTypes::bytes_field() const { // @@protoc_insertion_point(field_list:protobuf_unittest.RepeatedWellKnownTypes.bytes_field) return bytes_field_; } // ------------------------------------------------------------------- // OneofWellKnownTypes // .google.protobuf.Any any_field = 1; inline bool OneofWellKnownTypes::has_any_field() const { return oneof_field_case() == kAnyField; } inline void OneofWellKnownTypes::set_has_any_field() { _oneof_case_[0] = kAnyField; } inline void OneofWellKnownTypes::clear_any_field() { if (has_any_field()) { delete oneof_field_.any_field_; clear_has_oneof_field(); } } inline const ::google::protobuf::Any& OneofWellKnownTypes::any_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.OneofWellKnownTypes.any_field) return has_any_field() ? *oneof_field_.any_field_ : ::google::protobuf::Any::default_instance(); } inline ::google::protobuf::Any* OneofWellKnownTypes::mutable_any_field() { if (!has_any_field()) { clear_oneof_field(); set_has_any_field(); oneof_field_.any_field_ = new ::google::protobuf::Any; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.OneofWellKnownTypes.any_field) return oneof_field_.any_field_; } inline ::google::protobuf::Any* OneofWellKnownTypes::release_any_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.OneofWellKnownTypes.any_field) if (has_any_field()) { clear_has_oneof_field(); ::google::protobuf::Any* temp = oneof_field_.any_field_; oneof_field_.any_field_ = NULL; return temp; } else { return NULL; } } inline void OneofWellKnownTypes::set_allocated_any_field(::google::protobuf::Any* any_field) { clear_oneof_field(); if (any_field) { set_has_any_field(); oneof_field_.any_field_ = any_field; } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.OneofWellKnownTypes.any_field) } // .google.protobuf.Api api_field = 2; inline bool OneofWellKnownTypes::has_api_field() const { return oneof_field_case() == kApiField; } inline void OneofWellKnownTypes::set_has_api_field() { _oneof_case_[0] = kApiField; } inline void OneofWellKnownTypes::clear_api_field() { if (has_api_field()) { delete oneof_field_.api_field_; clear_has_oneof_field(); } } inline const ::google::protobuf::Api& OneofWellKnownTypes::api_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.OneofWellKnownTypes.api_field) return has_api_field() ? *oneof_field_.api_field_ : ::google::protobuf::Api::default_instance(); } inline ::google::protobuf::Api* OneofWellKnownTypes::mutable_api_field() { if (!has_api_field()) { clear_oneof_field(); set_has_api_field(); oneof_field_.api_field_ = new ::google::protobuf::Api; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.OneofWellKnownTypes.api_field) return oneof_field_.api_field_; } inline ::google::protobuf::Api* OneofWellKnownTypes::release_api_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.OneofWellKnownTypes.api_field) if (has_api_field()) { clear_has_oneof_field(); ::google::protobuf::Api* temp = oneof_field_.api_field_; oneof_field_.api_field_ = NULL; return temp; } else { return NULL; } } inline void OneofWellKnownTypes::set_allocated_api_field(::google::protobuf::Api* api_field) { clear_oneof_field(); if (api_field) { set_has_api_field(); oneof_field_.api_field_ = api_field; } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.OneofWellKnownTypes.api_field) } // .google.protobuf.Duration duration_field = 3; inline bool OneofWellKnownTypes::has_duration_field() const { return oneof_field_case() == kDurationField; } inline void OneofWellKnownTypes::set_has_duration_field() { _oneof_case_[0] = kDurationField; } inline void OneofWellKnownTypes::clear_duration_field() { if (has_duration_field()) { delete oneof_field_.duration_field_; clear_has_oneof_field(); } } inline const ::google::protobuf::Duration& OneofWellKnownTypes::duration_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.OneofWellKnownTypes.duration_field) return has_duration_field() ? *oneof_field_.duration_field_ : ::google::protobuf::Duration::default_instance(); } inline ::google::protobuf::Duration* OneofWellKnownTypes::mutable_duration_field() { if (!has_duration_field()) { clear_oneof_field(); set_has_duration_field(); oneof_field_.duration_field_ = new ::google::protobuf::Duration; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.OneofWellKnownTypes.duration_field) return oneof_field_.duration_field_; } inline ::google::protobuf::Duration* OneofWellKnownTypes::release_duration_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.OneofWellKnownTypes.duration_field) if (has_duration_field()) { clear_has_oneof_field(); ::google::protobuf::Duration* temp = oneof_field_.duration_field_; oneof_field_.duration_field_ = NULL; return temp; } else { return NULL; } } inline void OneofWellKnownTypes::set_allocated_duration_field(::google::protobuf::Duration* duration_field) { clear_oneof_field(); if (duration_field) { if (static_cast< ::google::protobuf::Duration*>(duration_field)->GetArena() != NULL) { ::google::protobuf::Duration* new_duration_field = new ::google::protobuf::Duration; new_duration_field->CopyFrom(*duration_field); duration_field = new_duration_field; } set_has_duration_field(); oneof_field_.duration_field_ = duration_field; } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.OneofWellKnownTypes.duration_field) } // .google.protobuf.Empty empty_field = 4; inline bool OneofWellKnownTypes::has_empty_field() const { return oneof_field_case() == kEmptyField; } inline void OneofWellKnownTypes::set_has_empty_field() { _oneof_case_[0] = kEmptyField; } inline void OneofWellKnownTypes::clear_empty_field() { if (has_empty_field()) { delete oneof_field_.empty_field_; clear_has_oneof_field(); } } inline const ::google::protobuf::Empty& OneofWellKnownTypes::empty_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.OneofWellKnownTypes.empty_field) return has_empty_field() ? *oneof_field_.empty_field_ : ::google::protobuf::Empty::default_instance(); } inline ::google::protobuf::Empty* OneofWellKnownTypes::mutable_empty_field() { if (!has_empty_field()) { clear_oneof_field(); set_has_empty_field(); oneof_field_.empty_field_ = new ::google::protobuf::Empty; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.OneofWellKnownTypes.empty_field) return oneof_field_.empty_field_; } inline ::google::protobuf::Empty* OneofWellKnownTypes::release_empty_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.OneofWellKnownTypes.empty_field) if (has_empty_field()) { clear_has_oneof_field(); ::google::protobuf::Empty* temp = oneof_field_.empty_field_; oneof_field_.empty_field_ = NULL; return temp; } else { return NULL; } } inline void OneofWellKnownTypes::set_allocated_empty_field(::google::protobuf::Empty* empty_field) { clear_oneof_field(); if (empty_field) { if (static_cast< ::google::protobuf::Empty*>(empty_field)->GetArena() != NULL) { ::google::protobuf::Empty* new_empty_field = new ::google::protobuf::Empty; new_empty_field->CopyFrom(*empty_field); empty_field = new_empty_field; } set_has_empty_field(); oneof_field_.empty_field_ = empty_field; } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.OneofWellKnownTypes.empty_field) } // .google.protobuf.FieldMask field_mask_field = 5; inline bool OneofWellKnownTypes::has_field_mask_field() const { return oneof_field_case() == kFieldMaskField; } inline void OneofWellKnownTypes::set_has_field_mask_field() { _oneof_case_[0] = kFieldMaskField; } inline void OneofWellKnownTypes::clear_field_mask_field() { if (has_field_mask_field()) { delete oneof_field_.field_mask_field_; clear_has_oneof_field(); } } inline const ::google::protobuf::FieldMask& OneofWellKnownTypes::field_mask_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.OneofWellKnownTypes.field_mask_field) return has_field_mask_field() ? *oneof_field_.field_mask_field_ : ::google::protobuf::FieldMask::default_instance(); } inline ::google::protobuf::FieldMask* OneofWellKnownTypes::mutable_field_mask_field() { if (!has_field_mask_field()) { clear_oneof_field(); set_has_field_mask_field(); oneof_field_.field_mask_field_ = new ::google::protobuf::FieldMask; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.OneofWellKnownTypes.field_mask_field) return oneof_field_.field_mask_field_; } inline ::google::protobuf::FieldMask* OneofWellKnownTypes::release_field_mask_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.OneofWellKnownTypes.field_mask_field) if (has_field_mask_field()) { clear_has_oneof_field(); ::google::protobuf::FieldMask* temp = oneof_field_.field_mask_field_; oneof_field_.field_mask_field_ = NULL; return temp; } else { return NULL; } } inline void OneofWellKnownTypes::set_allocated_field_mask_field(::google::protobuf::FieldMask* field_mask_field) { clear_oneof_field(); if (field_mask_field) { set_has_field_mask_field(); oneof_field_.field_mask_field_ = field_mask_field; } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.OneofWellKnownTypes.field_mask_field) } // .google.protobuf.SourceContext source_context_field = 6; inline bool OneofWellKnownTypes::has_source_context_field() const { return oneof_field_case() == kSourceContextField; } inline void OneofWellKnownTypes::set_has_source_context_field() { _oneof_case_[0] = kSourceContextField; } inline void OneofWellKnownTypes::clear_source_context_field() { if (has_source_context_field()) { delete oneof_field_.source_context_field_; clear_has_oneof_field(); } } inline const ::google::protobuf::SourceContext& OneofWellKnownTypes::source_context_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.OneofWellKnownTypes.source_context_field) return has_source_context_field() ? *oneof_field_.source_context_field_ : ::google::protobuf::SourceContext::default_instance(); } inline ::google::protobuf::SourceContext* OneofWellKnownTypes::mutable_source_context_field() { if (!has_source_context_field()) { clear_oneof_field(); set_has_source_context_field(); oneof_field_.source_context_field_ = new ::google::protobuf::SourceContext; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.OneofWellKnownTypes.source_context_field) return oneof_field_.source_context_field_; } inline ::google::protobuf::SourceContext* OneofWellKnownTypes::release_source_context_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.OneofWellKnownTypes.source_context_field) if (has_source_context_field()) { clear_has_oneof_field(); ::google::protobuf::SourceContext* temp = oneof_field_.source_context_field_; oneof_field_.source_context_field_ = NULL; return temp; } else { return NULL; } } inline void OneofWellKnownTypes::set_allocated_source_context_field(::google::protobuf::SourceContext* source_context_field) { clear_oneof_field(); if (source_context_field) { set_has_source_context_field(); oneof_field_.source_context_field_ = source_context_field; } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.OneofWellKnownTypes.source_context_field) } // .google.protobuf.Struct struct_field = 7; inline bool OneofWellKnownTypes::has_struct_field() const { return oneof_field_case() == kStructField; } inline void OneofWellKnownTypes::set_has_struct_field() { _oneof_case_[0] = kStructField; } inline void OneofWellKnownTypes::clear_struct_field() { if (has_struct_field()) { delete oneof_field_.struct_field_; clear_has_oneof_field(); } } inline const ::google::protobuf::Struct& OneofWellKnownTypes::struct_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.OneofWellKnownTypes.struct_field) return has_struct_field() ? *oneof_field_.struct_field_ : ::google::protobuf::Struct::default_instance(); } inline ::google::protobuf::Struct* OneofWellKnownTypes::mutable_struct_field() { if (!has_struct_field()) { clear_oneof_field(); set_has_struct_field(); oneof_field_.struct_field_ = new ::google::protobuf::Struct; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.OneofWellKnownTypes.struct_field) return oneof_field_.struct_field_; } inline ::google::protobuf::Struct* OneofWellKnownTypes::release_struct_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.OneofWellKnownTypes.struct_field) if (has_struct_field()) { clear_has_oneof_field(); ::google::protobuf::Struct* temp = oneof_field_.struct_field_; oneof_field_.struct_field_ = NULL; return temp; } else { return NULL; } } inline void OneofWellKnownTypes::set_allocated_struct_field(::google::protobuf::Struct* struct_field) { clear_oneof_field(); if (struct_field) { if (static_cast< ::google::protobuf::Struct*>(struct_field)->GetArena() != NULL) { ::google::protobuf::Struct* new_struct_field = new ::google::protobuf::Struct; new_struct_field->CopyFrom(*struct_field); struct_field = new_struct_field; } set_has_struct_field(); oneof_field_.struct_field_ = struct_field; } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.OneofWellKnownTypes.struct_field) } // .google.protobuf.Timestamp timestamp_field = 8; inline bool OneofWellKnownTypes::has_timestamp_field() const { return oneof_field_case() == kTimestampField; } inline void OneofWellKnownTypes::set_has_timestamp_field() { _oneof_case_[0] = kTimestampField; } inline void OneofWellKnownTypes::clear_timestamp_field() { if (has_timestamp_field()) { delete oneof_field_.timestamp_field_; clear_has_oneof_field(); } } inline const ::google::protobuf::Timestamp& OneofWellKnownTypes::timestamp_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.OneofWellKnownTypes.timestamp_field) return has_timestamp_field() ? *oneof_field_.timestamp_field_ : ::google::protobuf::Timestamp::default_instance(); } inline ::google::protobuf::Timestamp* OneofWellKnownTypes::mutable_timestamp_field() { if (!has_timestamp_field()) { clear_oneof_field(); set_has_timestamp_field(); oneof_field_.timestamp_field_ = new ::google::protobuf::Timestamp; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.OneofWellKnownTypes.timestamp_field) return oneof_field_.timestamp_field_; } inline ::google::protobuf::Timestamp* OneofWellKnownTypes::release_timestamp_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.OneofWellKnownTypes.timestamp_field) if (has_timestamp_field()) { clear_has_oneof_field(); ::google::protobuf::Timestamp* temp = oneof_field_.timestamp_field_; oneof_field_.timestamp_field_ = NULL; return temp; } else { return NULL; } } inline void OneofWellKnownTypes::set_allocated_timestamp_field(::google::protobuf::Timestamp* timestamp_field) { clear_oneof_field(); if (timestamp_field) { if (static_cast< ::google::protobuf::Timestamp*>(timestamp_field)->GetArena() != NULL) { ::google::protobuf::Timestamp* new_timestamp_field = new ::google::protobuf::Timestamp; new_timestamp_field->CopyFrom(*timestamp_field); timestamp_field = new_timestamp_field; } set_has_timestamp_field(); oneof_field_.timestamp_field_ = timestamp_field; } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.OneofWellKnownTypes.timestamp_field) } // .google.protobuf.Type type_field = 9; inline bool OneofWellKnownTypes::has_type_field() const { return oneof_field_case() == kTypeField; } inline void OneofWellKnownTypes::set_has_type_field() { _oneof_case_[0] = kTypeField; } inline void OneofWellKnownTypes::clear_type_field() { if (has_type_field()) { delete oneof_field_.type_field_; clear_has_oneof_field(); } } inline const ::google::protobuf::Type& OneofWellKnownTypes::type_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.OneofWellKnownTypes.type_field) return has_type_field() ? *oneof_field_.type_field_ : ::google::protobuf::Type::default_instance(); } inline ::google::protobuf::Type* OneofWellKnownTypes::mutable_type_field() { if (!has_type_field()) { clear_oneof_field(); set_has_type_field(); oneof_field_.type_field_ = new ::google::protobuf::Type; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.OneofWellKnownTypes.type_field) return oneof_field_.type_field_; } inline ::google::protobuf::Type* OneofWellKnownTypes::release_type_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.OneofWellKnownTypes.type_field) if (has_type_field()) { clear_has_oneof_field(); ::google::protobuf::Type* temp = oneof_field_.type_field_; oneof_field_.type_field_ = NULL; return temp; } else { return NULL; } } inline void OneofWellKnownTypes::set_allocated_type_field(::google::protobuf::Type* type_field) { clear_oneof_field(); if (type_field) { if (static_cast< ::google::protobuf::Type*>(type_field)->GetArena() != NULL) { ::google::protobuf::Type* new_type_field = new ::google::protobuf::Type; new_type_field->CopyFrom(*type_field); type_field = new_type_field; } set_has_type_field(); oneof_field_.type_field_ = type_field; } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.OneofWellKnownTypes.type_field) } // .google.protobuf.DoubleValue double_field = 10; inline bool OneofWellKnownTypes::has_double_field() const { return oneof_field_case() == kDoubleField; } inline void OneofWellKnownTypes::set_has_double_field() { _oneof_case_[0] = kDoubleField; } inline void OneofWellKnownTypes::clear_double_field() { if (has_double_field()) { delete oneof_field_.double_field_; clear_has_oneof_field(); } } inline const ::google::protobuf::DoubleValue& OneofWellKnownTypes::double_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.OneofWellKnownTypes.double_field) return has_double_field() ? *oneof_field_.double_field_ : ::google::protobuf::DoubleValue::default_instance(); } inline ::google::protobuf::DoubleValue* OneofWellKnownTypes::mutable_double_field() { if (!has_double_field()) { clear_oneof_field(); set_has_double_field(); oneof_field_.double_field_ = new ::google::protobuf::DoubleValue; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.OneofWellKnownTypes.double_field) return oneof_field_.double_field_; } inline ::google::protobuf::DoubleValue* OneofWellKnownTypes::release_double_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.OneofWellKnownTypes.double_field) if (has_double_field()) { clear_has_oneof_field(); ::google::protobuf::DoubleValue* temp = oneof_field_.double_field_; oneof_field_.double_field_ = NULL; return temp; } else { return NULL; } } inline void OneofWellKnownTypes::set_allocated_double_field(::google::protobuf::DoubleValue* double_field) { clear_oneof_field(); if (double_field) { if (static_cast< ::google::protobuf::DoubleValue*>(double_field)->GetArena() != NULL) { ::google::protobuf::DoubleValue* new_double_field = new ::google::protobuf::DoubleValue; new_double_field->CopyFrom(*double_field); double_field = new_double_field; } set_has_double_field(); oneof_field_.double_field_ = double_field; } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.OneofWellKnownTypes.double_field) } // .google.protobuf.FloatValue float_field = 11; inline bool OneofWellKnownTypes::has_float_field() const { return oneof_field_case() == kFloatField; } inline void OneofWellKnownTypes::set_has_float_field() { _oneof_case_[0] = kFloatField; } inline void OneofWellKnownTypes::clear_float_field() { if (has_float_field()) { delete oneof_field_.float_field_; clear_has_oneof_field(); } } inline const ::google::protobuf::FloatValue& OneofWellKnownTypes::float_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.OneofWellKnownTypes.float_field) return has_float_field() ? *oneof_field_.float_field_ : ::google::protobuf::FloatValue::default_instance(); } inline ::google::protobuf::FloatValue* OneofWellKnownTypes::mutable_float_field() { if (!has_float_field()) { clear_oneof_field(); set_has_float_field(); oneof_field_.float_field_ = new ::google::protobuf::FloatValue; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.OneofWellKnownTypes.float_field) return oneof_field_.float_field_; } inline ::google::protobuf::FloatValue* OneofWellKnownTypes::release_float_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.OneofWellKnownTypes.float_field) if (has_float_field()) { clear_has_oneof_field(); ::google::protobuf::FloatValue* temp = oneof_field_.float_field_; oneof_field_.float_field_ = NULL; return temp; } else { return NULL; } } inline void OneofWellKnownTypes::set_allocated_float_field(::google::protobuf::FloatValue* float_field) { clear_oneof_field(); if (float_field) { if (static_cast< ::google::protobuf::FloatValue*>(float_field)->GetArena() != NULL) { ::google::protobuf::FloatValue* new_float_field = new ::google::protobuf::FloatValue; new_float_field->CopyFrom(*float_field); float_field = new_float_field; } set_has_float_field(); oneof_field_.float_field_ = float_field; } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.OneofWellKnownTypes.float_field) } // .google.protobuf.Int64Value int64_field = 12; inline bool OneofWellKnownTypes::has_int64_field() const { return oneof_field_case() == kInt64Field; } inline void OneofWellKnownTypes::set_has_int64_field() { _oneof_case_[0] = kInt64Field; } inline void OneofWellKnownTypes::clear_int64_field() { if (has_int64_field()) { delete oneof_field_.int64_field_; clear_has_oneof_field(); } } inline const ::google::protobuf::Int64Value& OneofWellKnownTypes::int64_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.OneofWellKnownTypes.int64_field) return has_int64_field() ? *oneof_field_.int64_field_ : ::google::protobuf::Int64Value::default_instance(); } inline ::google::protobuf::Int64Value* OneofWellKnownTypes::mutable_int64_field() { if (!has_int64_field()) { clear_oneof_field(); set_has_int64_field(); oneof_field_.int64_field_ = new ::google::protobuf::Int64Value; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.OneofWellKnownTypes.int64_field) return oneof_field_.int64_field_; } inline ::google::protobuf::Int64Value* OneofWellKnownTypes::release_int64_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.OneofWellKnownTypes.int64_field) if (has_int64_field()) { clear_has_oneof_field(); ::google::protobuf::Int64Value* temp = oneof_field_.int64_field_; oneof_field_.int64_field_ = NULL; return temp; } else { return NULL; } } inline void OneofWellKnownTypes::set_allocated_int64_field(::google::protobuf::Int64Value* int64_field) { clear_oneof_field(); if (int64_field) { if (static_cast< ::google::protobuf::Int64Value*>(int64_field)->GetArena() != NULL) { ::google::protobuf::Int64Value* new_int64_field = new ::google::protobuf::Int64Value; new_int64_field->CopyFrom(*int64_field); int64_field = new_int64_field; } set_has_int64_field(); oneof_field_.int64_field_ = int64_field; } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.OneofWellKnownTypes.int64_field) } // .google.protobuf.UInt64Value uint64_field = 13; inline bool OneofWellKnownTypes::has_uint64_field() const { return oneof_field_case() == kUint64Field; } inline void OneofWellKnownTypes::set_has_uint64_field() { _oneof_case_[0] = kUint64Field; } inline void OneofWellKnownTypes::clear_uint64_field() { if (has_uint64_field()) { delete oneof_field_.uint64_field_; clear_has_oneof_field(); } } inline const ::google::protobuf::UInt64Value& OneofWellKnownTypes::uint64_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.OneofWellKnownTypes.uint64_field) return has_uint64_field() ? *oneof_field_.uint64_field_ : ::google::protobuf::UInt64Value::default_instance(); } inline ::google::protobuf::UInt64Value* OneofWellKnownTypes::mutable_uint64_field() { if (!has_uint64_field()) { clear_oneof_field(); set_has_uint64_field(); oneof_field_.uint64_field_ = new ::google::protobuf::UInt64Value; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.OneofWellKnownTypes.uint64_field) return oneof_field_.uint64_field_; } inline ::google::protobuf::UInt64Value* OneofWellKnownTypes::release_uint64_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.OneofWellKnownTypes.uint64_field) if (has_uint64_field()) { clear_has_oneof_field(); ::google::protobuf::UInt64Value* temp = oneof_field_.uint64_field_; oneof_field_.uint64_field_ = NULL; return temp; } else { return NULL; } } inline void OneofWellKnownTypes::set_allocated_uint64_field(::google::protobuf::UInt64Value* uint64_field) { clear_oneof_field(); if (uint64_field) { if (static_cast< ::google::protobuf::UInt64Value*>(uint64_field)->GetArena() != NULL) { ::google::protobuf::UInt64Value* new_uint64_field = new ::google::protobuf::UInt64Value; new_uint64_field->CopyFrom(*uint64_field); uint64_field = new_uint64_field; } set_has_uint64_field(); oneof_field_.uint64_field_ = uint64_field; } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.OneofWellKnownTypes.uint64_field) } // .google.protobuf.Int32Value int32_field = 14; inline bool OneofWellKnownTypes::has_int32_field() const { return oneof_field_case() == kInt32Field; } inline void OneofWellKnownTypes::set_has_int32_field() { _oneof_case_[0] = kInt32Field; } inline void OneofWellKnownTypes::clear_int32_field() { if (has_int32_field()) { delete oneof_field_.int32_field_; clear_has_oneof_field(); } } inline const ::google::protobuf::Int32Value& OneofWellKnownTypes::int32_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.OneofWellKnownTypes.int32_field) return has_int32_field() ? *oneof_field_.int32_field_ : ::google::protobuf::Int32Value::default_instance(); } inline ::google::protobuf::Int32Value* OneofWellKnownTypes::mutable_int32_field() { if (!has_int32_field()) { clear_oneof_field(); set_has_int32_field(); oneof_field_.int32_field_ = new ::google::protobuf::Int32Value; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.OneofWellKnownTypes.int32_field) return oneof_field_.int32_field_; } inline ::google::protobuf::Int32Value* OneofWellKnownTypes::release_int32_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.OneofWellKnownTypes.int32_field) if (has_int32_field()) { clear_has_oneof_field(); ::google::protobuf::Int32Value* temp = oneof_field_.int32_field_; oneof_field_.int32_field_ = NULL; return temp; } else { return NULL; } } inline void OneofWellKnownTypes::set_allocated_int32_field(::google::protobuf::Int32Value* int32_field) { clear_oneof_field(); if (int32_field) { if (static_cast< ::google::protobuf::Int32Value*>(int32_field)->GetArena() != NULL) { ::google::protobuf::Int32Value* new_int32_field = new ::google::protobuf::Int32Value; new_int32_field->CopyFrom(*int32_field); int32_field = new_int32_field; } set_has_int32_field(); oneof_field_.int32_field_ = int32_field; } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.OneofWellKnownTypes.int32_field) } // .google.protobuf.UInt32Value uint32_field = 15; inline bool OneofWellKnownTypes::has_uint32_field() const { return oneof_field_case() == kUint32Field; } inline void OneofWellKnownTypes::set_has_uint32_field() { _oneof_case_[0] = kUint32Field; } inline void OneofWellKnownTypes::clear_uint32_field() { if (has_uint32_field()) { delete oneof_field_.uint32_field_; clear_has_oneof_field(); } } inline const ::google::protobuf::UInt32Value& OneofWellKnownTypes::uint32_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.OneofWellKnownTypes.uint32_field) return has_uint32_field() ? *oneof_field_.uint32_field_ : ::google::protobuf::UInt32Value::default_instance(); } inline ::google::protobuf::UInt32Value* OneofWellKnownTypes::mutable_uint32_field() { if (!has_uint32_field()) { clear_oneof_field(); set_has_uint32_field(); oneof_field_.uint32_field_ = new ::google::protobuf::UInt32Value; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.OneofWellKnownTypes.uint32_field) return oneof_field_.uint32_field_; } inline ::google::protobuf::UInt32Value* OneofWellKnownTypes::release_uint32_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.OneofWellKnownTypes.uint32_field) if (has_uint32_field()) { clear_has_oneof_field(); ::google::protobuf::UInt32Value* temp = oneof_field_.uint32_field_; oneof_field_.uint32_field_ = NULL; return temp; } else { return NULL; } } inline void OneofWellKnownTypes::set_allocated_uint32_field(::google::protobuf::UInt32Value* uint32_field) { clear_oneof_field(); if (uint32_field) { if (static_cast< ::google::protobuf::UInt32Value*>(uint32_field)->GetArena() != NULL) { ::google::protobuf::UInt32Value* new_uint32_field = new ::google::protobuf::UInt32Value; new_uint32_field->CopyFrom(*uint32_field); uint32_field = new_uint32_field; } set_has_uint32_field(); oneof_field_.uint32_field_ = uint32_field; } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.OneofWellKnownTypes.uint32_field) } // .google.protobuf.BoolValue bool_field = 16; inline bool OneofWellKnownTypes::has_bool_field() const { return oneof_field_case() == kBoolField; } inline void OneofWellKnownTypes::set_has_bool_field() { _oneof_case_[0] = kBoolField; } inline void OneofWellKnownTypes::clear_bool_field() { if (has_bool_field()) { delete oneof_field_.bool_field_; clear_has_oneof_field(); } } inline const ::google::protobuf::BoolValue& OneofWellKnownTypes::bool_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.OneofWellKnownTypes.bool_field) return has_bool_field() ? *oneof_field_.bool_field_ : ::google::protobuf::BoolValue::default_instance(); } inline ::google::protobuf::BoolValue* OneofWellKnownTypes::mutable_bool_field() { if (!has_bool_field()) { clear_oneof_field(); set_has_bool_field(); oneof_field_.bool_field_ = new ::google::protobuf::BoolValue; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.OneofWellKnownTypes.bool_field) return oneof_field_.bool_field_; } inline ::google::protobuf::BoolValue* OneofWellKnownTypes::release_bool_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.OneofWellKnownTypes.bool_field) if (has_bool_field()) { clear_has_oneof_field(); ::google::protobuf::BoolValue* temp = oneof_field_.bool_field_; oneof_field_.bool_field_ = NULL; return temp; } else { return NULL; } } inline void OneofWellKnownTypes::set_allocated_bool_field(::google::protobuf::BoolValue* bool_field) { clear_oneof_field(); if (bool_field) { if (static_cast< ::google::protobuf::BoolValue*>(bool_field)->GetArena() != NULL) { ::google::protobuf::BoolValue* new_bool_field = new ::google::protobuf::BoolValue; new_bool_field->CopyFrom(*bool_field); bool_field = new_bool_field; } set_has_bool_field(); oneof_field_.bool_field_ = bool_field; } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.OneofWellKnownTypes.bool_field) } // .google.protobuf.StringValue string_field = 17; inline bool OneofWellKnownTypes::has_string_field() const { return oneof_field_case() == kStringField; } inline void OneofWellKnownTypes::set_has_string_field() { _oneof_case_[0] = kStringField; } inline void OneofWellKnownTypes::clear_string_field() { if (has_string_field()) { delete oneof_field_.string_field_; clear_has_oneof_field(); } } inline const ::google::protobuf::StringValue& OneofWellKnownTypes::string_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.OneofWellKnownTypes.string_field) return has_string_field() ? *oneof_field_.string_field_ : ::google::protobuf::StringValue::default_instance(); } inline ::google::protobuf::StringValue* OneofWellKnownTypes::mutable_string_field() { if (!has_string_field()) { clear_oneof_field(); set_has_string_field(); oneof_field_.string_field_ = new ::google::protobuf::StringValue; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.OneofWellKnownTypes.string_field) return oneof_field_.string_field_; } inline ::google::protobuf::StringValue* OneofWellKnownTypes::release_string_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.OneofWellKnownTypes.string_field) if (has_string_field()) { clear_has_oneof_field(); ::google::protobuf::StringValue* temp = oneof_field_.string_field_; oneof_field_.string_field_ = NULL; return temp; } else { return NULL; } } inline void OneofWellKnownTypes::set_allocated_string_field(::google::protobuf::StringValue* string_field) { clear_oneof_field(); if (string_field) { if (static_cast< ::google::protobuf::StringValue*>(string_field)->GetArena() != NULL) { ::google::protobuf::StringValue* new_string_field = new ::google::protobuf::StringValue; new_string_field->CopyFrom(*string_field); string_field = new_string_field; } set_has_string_field(); oneof_field_.string_field_ = string_field; } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.OneofWellKnownTypes.string_field) } // .google.protobuf.BytesValue bytes_field = 18; inline bool OneofWellKnownTypes::has_bytes_field() const { return oneof_field_case() == kBytesField; } inline void OneofWellKnownTypes::set_has_bytes_field() { _oneof_case_[0] = kBytesField; } inline void OneofWellKnownTypes::clear_bytes_field() { if (has_bytes_field()) { delete oneof_field_.bytes_field_; clear_has_oneof_field(); } } inline const ::google::protobuf::BytesValue& OneofWellKnownTypes::bytes_field() const { // @@protoc_insertion_point(field_get:protobuf_unittest.OneofWellKnownTypes.bytes_field) return has_bytes_field() ? *oneof_field_.bytes_field_ : ::google::protobuf::BytesValue::default_instance(); } inline ::google::protobuf::BytesValue* OneofWellKnownTypes::mutable_bytes_field() { if (!has_bytes_field()) { clear_oneof_field(); set_has_bytes_field(); oneof_field_.bytes_field_ = new ::google::protobuf::BytesValue; } // @@protoc_insertion_point(field_mutable:protobuf_unittest.OneofWellKnownTypes.bytes_field) return oneof_field_.bytes_field_; } inline ::google::protobuf::BytesValue* OneofWellKnownTypes::release_bytes_field() { // @@protoc_insertion_point(field_release:protobuf_unittest.OneofWellKnownTypes.bytes_field) if (has_bytes_field()) { clear_has_oneof_field(); ::google::protobuf::BytesValue* temp = oneof_field_.bytes_field_; oneof_field_.bytes_field_ = NULL; return temp; } else { return NULL; } } inline void OneofWellKnownTypes::set_allocated_bytes_field(::google::protobuf::BytesValue* bytes_field) { clear_oneof_field(); if (bytes_field) { if (static_cast< ::google::protobuf::BytesValue*>(bytes_field)->GetArena() != NULL) { ::google::protobuf::BytesValue* new_bytes_field = new ::google::protobuf::BytesValue; new_bytes_field->CopyFrom(*bytes_field); bytes_field = new_bytes_field; } set_has_bytes_field(); oneof_field_.bytes_field_ = bytes_field; } // @@protoc_insertion_point(field_set_allocated:protobuf_unittest.OneofWellKnownTypes.bytes_field) } inline bool OneofWellKnownTypes::has_oneof_field() const { return oneof_field_case() != ONEOF_FIELD_NOT_SET; } inline void OneofWellKnownTypes::clear_has_oneof_field() { _oneof_case_[0] = ONEOF_FIELD_NOT_SET; } inline OneofWellKnownTypes::OneofFieldCase OneofWellKnownTypes::oneof_field_case() const { return OneofWellKnownTypes::OneofFieldCase(_oneof_case_[0]); } // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // MapWellKnownTypes // map<int32, .google.protobuf.Any> any_field = 1; inline int MapWellKnownTypes::any_field_size() const { return any_field_.size(); } inline void MapWellKnownTypes::clear_any_field() { any_field_.Clear(); } inline const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Any >& MapWellKnownTypes::any_field() const { // @@protoc_insertion_point(field_map:protobuf_unittest.MapWellKnownTypes.any_field) return any_field_.GetMap(); } inline ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Any >* MapWellKnownTypes::mutable_any_field() { // @@protoc_insertion_point(field_mutable_map:protobuf_unittest.MapWellKnownTypes.any_field) return any_field_.MutableMap(); } // map<int32, .google.protobuf.Api> api_field = 2; inline int MapWellKnownTypes::api_field_size() const { return api_field_.size(); } inline void MapWellKnownTypes::clear_api_field() { api_field_.Clear(); } inline const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Api >& MapWellKnownTypes::api_field() const { // @@protoc_insertion_point(field_map:protobuf_unittest.MapWellKnownTypes.api_field) return api_field_.GetMap(); } inline ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Api >* MapWellKnownTypes::mutable_api_field() { // @@protoc_insertion_point(field_mutable_map:protobuf_unittest.MapWellKnownTypes.api_field) return api_field_.MutableMap(); } // map<int32, .google.protobuf.Duration> duration_field = 3; inline int MapWellKnownTypes::duration_field_size() const { return duration_field_.size(); } inline void MapWellKnownTypes::clear_duration_field() { duration_field_.Clear(); } inline const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Duration >& MapWellKnownTypes::duration_field() const { // @@protoc_insertion_point(field_map:protobuf_unittest.MapWellKnownTypes.duration_field) return duration_field_.GetMap(); } inline ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Duration >* MapWellKnownTypes::mutable_duration_field() { // @@protoc_insertion_point(field_mutable_map:protobuf_unittest.MapWellKnownTypes.duration_field) return duration_field_.MutableMap(); } // map<int32, .google.protobuf.Empty> empty_field = 4; inline int MapWellKnownTypes::empty_field_size() const { return empty_field_.size(); } inline void MapWellKnownTypes::clear_empty_field() { empty_field_.Clear(); } inline const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Empty >& MapWellKnownTypes::empty_field() const { // @@protoc_insertion_point(field_map:protobuf_unittest.MapWellKnownTypes.empty_field) return empty_field_.GetMap(); } inline ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Empty >* MapWellKnownTypes::mutable_empty_field() { // @@protoc_insertion_point(field_mutable_map:protobuf_unittest.MapWellKnownTypes.empty_field) return empty_field_.MutableMap(); } // map<int32, .google.protobuf.FieldMask> field_mask_field = 5; inline int MapWellKnownTypes::field_mask_field_size() const { return field_mask_field_.size(); } inline void MapWellKnownTypes::clear_field_mask_field() { field_mask_field_.Clear(); } inline const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::FieldMask >& MapWellKnownTypes::field_mask_field() const { // @@protoc_insertion_point(field_map:protobuf_unittest.MapWellKnownTypes.field_mask_field) return field_mask_field_.GetMap(); } inline ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::FieldMask >* MapWellKnownTypes::mutable_field_mask_field() { // @@protoc_insertion_point(field_mutable_map:protobuf_unittest.MapWellKnownTypes.field_mask_field) return field_mask_field_.MutableMap(); } // map<int32, .google.protobuf.SourceContext> source_context_field = 6; inline int MapWellKnownTypes::source_context_field_size() const { return source_context_field_.size(); } inline void MapWellKnownTypes::clear_source_context_field() { source_context_field_.Clear(); } inline const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::SourceContext >& MapWellKnownTypes::source_context_field() const { // @@protoc_insertion_point(field_map:protobuf_unittest.MapWellKnownTypes.source_context_field) return source_context_field_.GetMap(); } inline ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::SourceContext >* MapWellKnownTypes::mutable_source_context_field() { // @@protoc_insertion_point(field_mutable_map:protobuf_unittest.MapWellKnownTypes.source_context_field) return source_context_field_.MutableMap(); } // map<int32, .google.protobuf.Struct> struct_field = 7; inline int MapWellKnownTypes::struct_field_size() const { return struct_field_.size(); } inline void MapWellKnownTypes::clear_struct_field() { struct_field_.Clear(); } inline const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Struct >& MapWellKnownTypes::struct_field() const { // @@protoc_insertion_point(field_map:protobuf_unittest.MapWellKnownTypes.struct_field) return struct_field_.GetMap(); } inline ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Struct >* MapWellKnownTypes::mutable_struct_field() { // @@protoc_insertion_point(field_mutable_map:protobuf_unittest.MapWellKnownTypes.struct_field) return struct_field_.MutableMap(); } // map<int32, .google.protobuf.Timestamp> timestamp_field = 8; inline int MapWellKnownTypes::timestamp_field_size() const { return timestamp_field_.size(); } inline void MapWellKnownTypes::clear_timestamp_field() { timestamp_field_.Clear(); } inline const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Timestamp >& MapWellKnownTypes::timestamp_field() const { // @@protoc_insertion_point(field_map:protobuf_unittest.MapWellKnownTypes.timestamp_field) return timestamp_field_.GetMap(); } inline ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Timestamp >* MapWellKnownTypes::mutable_timestamp_field() { // @@protoc_insertion_point(field_mutable_map:protobuf_unittest.MapWellKnownTypes.timestamp_field) return timestamp_field_.MutableMap(); } // map<int32, .google.protobuf.Type> type_field = 9; inline int MapWellKnownTypes::type_field_size() const { return type_field_.size(); } inline void MapWellKnownTypes::clear_type_field() { type_field_.Clear(); } inline const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Type >& MapWellKnownTypes::type_field() const { // @@protoc_insertion_point(field_map:protobuf_unittest.MapWellKnownTypes.type_field) return type_field_.GetMap(); } inline ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Type >* MapWellKnownTypes::mutable_type_field() { // @@protoc_insertion_point(field_mutable_map:protobuf_unittest.MapWellKnownTypes.type_field) return type_field_.MutableMap(); } // map<int32, .google.protobuf.DoubleValue> double_field = 10; inline int MapWellKnownTypes::double_field_size() const { return double_field_.size(); } inline void MapWellKnownTypes::clear_double_field() { double_field_.Clear(); } inline const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::DoubleValue >& MapWellKnownTypes::double_field() const { // @@protoc_insertion_point(field_map:protobuf_unittest.MapWellKnownTypes.double_field) return double_field_.GetMap(); } inline ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::DoubleValue >* MapWellKnownTypes::mutable_double_field() { // @@protoc_insertion_point(field_mutable_map:protobuf_unittest.MapWellKnownTypes.double_field) return double_field_.MutableMap(); } // map<int32, .google.protobuf.FloatValue> float_field = 11; inline int MapWellKnownTypes::float_field_size() const { return float_field_.size(); } inline void MapWellKnownTypes::clear_float_field() { float_field_.Clear(); } inline const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::FloatValue >& MapWellKnownTypes::float_field() const { // @@protoc_insertion_point(field_map:protobuf_unittest.MapWellKnownTypes.float_field) return float_field_.GetMap(); } inline ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::FloatValue >* MapWellKnownTypes::mutable_float_field() { // @@protoc_insertion_point(field_mutable_map:protobuf_unittest.MapWellKnownTypes.float_field) return float_field_.MutableMap(); } // map<int32, .google.protobuf.Int64Value> int64_field = 12; inline int MapWellKnownTypes::int64_field_size() const { return int64_field_.size(); } inline void MapWellKnownTypes::clear_int64_field() { int64_field_.Clear(); } inline const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Int64Value >& MapWellKnownTypes::int64_field() const { // @@protoc_insertion_point(field_map:protobuf_unittest.MapWellKnownTypes.int64_field) return int64_field_.GetMap(); } inline ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Int64Value >* MapWellKnownTypes::mutable_int64_field() { // @@protoc_insertion_point(field_mutable_map:protobuf_unittest.MapWellKnownTypes.int64_field) return int64_field_.MutableMap(); } // map<int32, .google.protobuf.UInt64Value> uint64_field = 13; inline int MapWellKnownTypes::uint64_field_size() const { return uint64_field_.size(); } inline void MapWellKnownTypes::clear_uint64_field() { uint64_field_.Clear(); } inline const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::UInt64Value >& MapWellKnownTypes::uint64_field() const { // @@protoc_insertion_point(field_map:protobuf_unittest.MapWellKnownTypes.uint64_field) return uint64_field_.GetMap(); } inline ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::UInt64Value >* MapWellKnownTypes::mutable_uint64_field() { // @@protoc_insertion_point(field_mutable_map:protobuf_unittest.MapWellKnownTypes.uint64_field) return uint64_field_.MutableMap(); } // map<int32, .google.protobuf.Int32Value> int32_field = 14; inline int MapWellKnownTypes::int32_field_size() const { return int32_field_.size(); } inline void MapWellKnownTypes::clear_int32_field() { int32_field_.Clear(); } inline const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Int32Value >& MapWellKnownTypes::int32_field() const { // @@protoc_insertion_point(field_map:protobuf_unittest.MapWellKnownTypes.int32_field) return int32_field_.GetMap(); } inline ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::Int32Value >* MapWellKnownTypes::mutable_int32_field() { // @@protoc_insertion_point(field_mutable_map:protobuf_unittest.MapWellKnownTypes.int32_field) return int32_field_.MutableMap(); } // map<int32, .google.protobuf.UInt32Value> uint32_field = 15; inline int MapWellKnownTypes::uint32_field_size() const { return uint32_field_.size(); } inline void MapWellKnownTypes::clear_uint32_field() { uint32_field_.Clear(); } inline const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::UInt32Value >& MapWellKnownTypes::uint32_field() const { // @@protoc_insertion_point(field_map:protobuf_unittest.MapWellKnownTypes.uint32_field) return uint32_field_.GetMap(); } inline ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::UInt32Value >* MapWellKnownTypes::mutable_uint32_field() { // @@protoc_insertion_point(field_mutable_map:protobuf_unittest.MapWellKnownTypes.uint32_field) return uint32_field_.MutableMap(); } // map<int32, .google.protobuf.BoolValue> bool_field = 16; inline int MapWellKnownTypes::bool_field_size() const { return bool_field_.size(); } inline void MapWellKnownTypes::clear_bool_field() { bool_field_.Clear(); } inline const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::BoolValue >& MapWellKnownTypes::bool_field() const { // @@protoc_insertion_point(field_map:protobuf_unittest.MapWellKnownTypes.bool_field) return bool_field_.GetMap(); } inline ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::BoolValue >* MapWellKnownTypes::mutable_bool_field() { // @@protoc_insertion_point(field_mutable_map:protobuf_unittest.MapWellKnownTypes.bool_field) return bool_field_.MutableMap(); } // map<int32, .google.protobuf.StringValue> string_field = 17; inline int MapWellKnownTypes::string_field_size() const { return string_field_.size(); } inline void MapWellKnownTypes::clear_string_field() { string_field_.Clear(); } inline const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::StringValue >& MapWellKnownTypes::string_field() const { // @@protoc_insertion_point(field_map:protobuf_unittest.MapWellKnownTypes.string_field) return string_field_.GetMap(); } inline ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::StringValue >* MapWellKnownTypes::mutable_string_field() { // @@protoc_insertion_point(field_mutable_map:protobuf_unittest.MapWellKnownTypes.string_field) return string_field_.MutableMap(); } // map<int32, .google.protobuf.BytesValue> bytes_field = 18; inline int MapWellKnownTypes::bytes_field_size() const { return bytes_field_.size(); } inline void MapWellKnownTypes::clear_bytes_field() { bytes_field_.Clear(); } inline const ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::BytesValue >& MapWellKnownTypes::bytes_field() const { // @@protoc_insertion_point(field_map:protobuf_unittest.MapWellKnownTypes.bytes_field) return bytes_field_.GetMap(); } inline ::google::protobuf::Map< ::google::protobuf::int32, ::google::protobuf::BytesValue >* MapWellKnownTypes::mutable_bytes_field() { // @@protoc_insertion_point(field_mutable_map:protobuf_unittest.MapWellKnownTypes.bytes_field) return bytes_field_.MutableMap(); } #endif // !PROTOBUF_INLINE_NOT_IN_HEADERS // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // ------------------------------------------------------------------- // @@protoc_insertion_point(namespace_scope) } // namespace protobuf_unittest // @@protoc_insertion_point(global_scope) #endif // PROTOBUF_google_2fprotobuf_2funittest_5fwell_5fknown_5ftypes_2eproto__INCLUDED
[ "chrak@com2us.com" ]
chrak@com2us.com
af81201a22708a93eab4e835cbffc31733d54346
8aae71a092645f62d6f835578accc1ceb6416283
/ebobekok adres.cpp
c40d97d4305c30484f3c852d929064d1c6a61795
[]
no_license
dogabaris/C_Ornekleri
9db3c55115bb62b98b7ca157a3aaf50e51a502d5
dc6b3201ccb7165106f2decdeabcf7025eac4f41
refs/heads/master
2021-01-02T08:33:24.874333
2015-03-07T14:27:33
2015-03-07T14:27:33
31,814,348
0
0
null
null
null
null
UTF-8
C++
false
false
600
cpp
#include <stdio.h> #include <conio.h> void kontrol(int *,int *,int *,int *); main() { int girilen,s1,s2,ebob=1,ekok; printf("1. sayiyi girin = "); scanf("%d",&s1); printf("2. sayiyi girin = "); scanf("%d",&s2); kontrol(&s1,&s2,&ebob,&ekok); printf("ebob = %d\n",ebob); printf("ekok = %d",ekok); } void kontrol(int *s1,int *s2,int *ebob,int *ekok) { int kucuk,i,sayi1,sayi2; sayi1=*s1; sayi2=*s2; if(*s1<=*s2) {kucuk=*s1;} if(*s1>*s2) {kucuk=*s2;} for(i=2;i<=kucuk;i++) if(*s1%i==0 && *s2%i==0) { *s1=*s1/i; *s2=*s2/i; *ebob=*ebob*i; } *ekok=(sayi1)*(sayi2)/(*ebob); }
[ "dogabarisozdemir@gmail.com" ]
dogabarisozdemir@gmail.com
c2ee8a956229bdac101a2d3adc4a4f73dfa4c1a3
0459ae96bae0b3b2c9858ce5050e60e3b01b000e
/Christian/PROG_II/Uebung_8/svgfile.h
4f2e8210964beaaa8b040fb163dd0ce6f81a8443
[]
no_license
DevCodeOne/WS_1617
f03f19f1317b93483be4133f768c031bdf2bd364
461c7119b0854bbd35f117f0c3f0ccd0b5a3a94c
refs/heads/master
2021-05-03T12:30:16.521386
2017-02-02T09:31:57
2017-02-02T09:31:57
62,337,029
0
0
null
null
null
null
UTF-8
C++
false
false
1,242
h
/* * ++C - C++ introduction * Copyright (C) 2013, 2014, 2015, 2016 Wilhelm Meier <wilhelm.meier@hs-kl.de> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ #pragma once #include <fstream> #include <string> class SVGFile { public: SVGFile(std::string filename); ~SVGFile(); void add(std::string svgElement); private: std::ofstream mFile; // <> nicht-statische Datenelemente (Objektvariablen) werden bei der Destruktion ebenfalls zerstört. static std::string header1; // <> statische Datenelemente (Klassenvariablen) static std::string header2; static std::string header3; static std::string footer1; };
[ "christian.r.dev@googlemail.com" ]
christian.r.dev@googlemail.com
bd1bc2af610a9046e5544ca08621c02386a71268
dfa6ddf5fb513d553d43a028add28cdf40b46249
/474. Ones and Zeroes.cpp
ebee96f01b36b6ab1efa0be6748626890771b2f2
[]
no_license
brucechin/Leetcode
c58eb6eedf3a940841a0ccae18d543fd88b76f65
798e6f1fa128982c7fd141a725b99805131361cb
refs/heads/master
2021-11-22T14:31:53.143147
2021-10-08T06:50:28
2021-10-08T06:50:28
109,366,643
4
0
null
null
null
null
UTF-8
C++
false
false
2,252
cpp
/* In the computer world, use restricted resource you have to generate maximum benefit is what we always want to pursue. For now, suppose you are a dominator of m 0s and n 1s respectively. On the other hand, there is an array with strings consisting of only 0s and 1s. Now your task is to find the maximum number of strings that you can form with given m 0s and n 1s. Each 0 and 1 can be used at most once. Note: The given numbers of 0s and 1s will both not exceed 100 The size of given string array won't exceed 600. Example 1: Input: Array = {"10", "0001", "111001", "1", "0"}, m = 5, n = 3 Output: 4 Explanation: This are totally 4 strings can be formed by the using of 5 0s and 3 1s, which are “10,”0001”,”1”,”0” Example 2: Input: Array = {"10", "0", "1"}, m = 1, n = 1 Output: 2 Explanation: You could form "10", but then you'd have nothing left. Better form "0" and "1". */ class Solution { public: int findMaxForm(vector<string> &strs, int m, int n) { vector<vector<int>> memo(m + 1, vector<int>(n + 1, 0)); int numZeroes, numOnes; for (auto &s : strs) { numZeroes = numOnes = 0; // count number of zeroes and ones in current string for (auto c : s) { if (c == '0') numZeroes++; else if (c == '1') numOnes++; } // memo[i][j] = the max number of strings that can be formed with i 0's and j 1's // from the first few strings up to the current string s // Catch: have to go from bottom right to top left // Why? If a cell in the memo is updated(because s is selected), // we should be adding 1 to memo[i][j] from the previous iteration (when we were not considering s) // If we go from top left to bottom right, we would be using results from this iteration => overcounting for (int i = m; i >= numZeroes; i--) { for (int j = n; j >= numOnes; j--) { memo[i][j] = max(memo[i][j], memo[i - numZeroes][j - numOnes] + 1); } } } return memo[m][n]; } };
[ "1026193951@sjtu.edu.cn" ]
1026193951@sjtu.edu.cn
f0853b9cbbafb3ac8f549a7830b9debf1f8dd44b
5e9fb4da7aed28bdb39f95d85bd6f6cb479e0bd2
/63.5/uniform/time
25e209ba4a1862f3c031fa8c852496d44779f585
[]
no_license
wxyhappy0201/pipeflow_snappyHexMesh
fe0d59852370ca5e276258bc9f7b3a21a9ff1a70
1d534dfb274b3a4db4d1ffa2971d34be985b77aa
refs/heads/master
2022-02-08T17:16:47.004690
2019-07-22T21:39:19
2019-07-22T21:39:19
null
0
0
null
null
null
null
UTF-8
C++
false
false
971
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: v1906 | | \\ / A nd | Web: www.OpenFOAM.com | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; location "63.5/uniform"; object time; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // value 63.5; name "63.5"; index 113; deltaT 1; deltaT0 1; // ************************************************************************* //
[ "tong011@e.ntu.edu.sg" ]
tong011@e.ntu.edu.sg
11f109901d9356efe211c6a7f2e9aa3b5241b213
0eff74b05b60098333ad66cf801bdd93becc9ea4
/second/download/curl/gumtree/curl_repos_function_1253_curl-7.35.0.cpp
28ffb7ead0f465ad2cb5c31abb1e6c50a44fdc92
[]
no_license
niuxu18/logTracker-old
97543445ea7e414ed40bdc681239365d33418975
f2b060f13a0295387fe02187543db124916eb446
refs/heads/master
2021-09-13T21:39:37.686481
2017-12-11T03:36:34
2017-12-11T03:36:34
null
0
0
null
null
null
null
UTF-8
C++
false
false
55,136
cpp
CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, va_list param) { char *argptr; CURLcode result = CURLE_OK; long arg; #ifndef CURL_DISABLE_HTTP curl_off_t bigsize; #endif switch(option) { case CURLOPT_DNS_CACHE_TIMEOUT: data->set.dns_cache_timeout = va_arg(param, long); break; case CURLOPT_DNS_USE_GLOBAL_CACHE: /* remember we want this enabled */ arg = va_arg(param, long); data->set.global_dns_cache = (0 != arg)?TRUE:FALSE; break; case CURLOPT_SSL_CIPHER_LIST: /* set a list of cipher we want to use in the SSL connection */ result = setstropt(&data->set.str[STRING_SSL_CIPHER_LIST], va_arg(param, char *)); break; case CURLOPT_RANDOM_FILE: /* * This is the path name to a file that contains random data to seed * the random SSL stuff with. The file is only used for reading. */ result = setstropt(&data->set.str[STRING_SSL_RANDOM_FILE], va_arg(param, char *)); break; case CURLOPT_EGDSOCKET: /* * The Entropy Gathering Daemon socket pathname */ result = setstropt(&data->set.str[STRING_SSL_EGDSOCKET], va_arg(param, char *)); break; case CURLOPT_MAXCONNECTS: /* * Set the absolute number of maximum simultaneous alive connection that * libcurl is allowed to have. */ data->set.maxconnects = va_arg(param, long); break; case CURLOPT_FORBID_REUSE: /* * When this transfer is done, it must not be left to be reused by a * subsequent transfer but shall be closed immediately. */ data->set.reuse_forbid = (0 != va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_FRESH_CONNECT: /* * This transfer shall not use a previously cached connection but * should be made with a fresh new connect! */ data->set.reuse_fresh = (0 != va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_VERBOSE: /* * Verbose means infof() calls that give a lot of information about * the connection and transfer procedures as well as internal choices. */ data->set.verbose = (0 != va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_HEADER: /* * Set to include the header in the general data output stream. */ data->set.include_header = (0 != va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_NOPROGRESS: /* * Shut off the internal supported progress meter */ data->set.hide_progress = (0 != va_arg(param, long))?TRUE:FALSE; if(data->set.hide_progress) data->progress.flags |= PGRS_HIDE; else data->progress.flags &= ~PGRS_HIDE; break; case CURLOPT_NOBODY: /* * Do not include the body part in the output data stream. */ data->set.opt_no_body = (0 != va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_FAILONERROR: /* * Don't output the >=300 error code HTML-page, but instead only * return error. */ data->set.http_fail_on_error = (0 != va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_UPLOAD: case CURLOPT_PUT: /* * We want to sent data to the remote host. If this is HTTP, that equals * using the PUT request. */ data->set.upload = (0 != va_arg(param, long))?TRUE:FALSE; if(data->set.upload) { /* If this is HTTP, PUT is what's needed to "upload" */ data->set.httpreq = HTTPREQ_PUT; data->set.opt_no_body = FALSE; /* this is implied */ } else /* In HTTP, the opposite of upload is GET (unless NOBODY is true as then this can be changed to HEAD later on) */ data->set.httpreq = HTTPREQ_GET; break; case CURLOPT_FILETIME: /* * Try to get the file time of the remote document. The time will * later (possibly) become available using curl_easy_getinfo(). */ data->set.get_filetime = (0 != va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_FTP_CREATE_MISSING_DIRS: /* * An FTP option that modifies an upload to create missing directories on * the server. */ switch(va_arg(param, long)) { case 0: data->set.ftp_create_missing_dirs = 0; break; case 1: data->set.ftp_create_missing_dirs = 1; break; case 2: data->set.ftp_create_missing_dirs = 2; break; default: /* reserve other values for future use */ result = CURLE_UNKNOWN_OPTION; break; } break; case CURLOPT_SERVER_RESPONSE_TIMEOUT: /* * Option that specifies how quickly an server response must be obtained * before it is considered failure. For pingpong protocols. */ data->set.server_response_timeout = va_arg( param , long ) * 1000; break; case CURLOPT_TFTP_BLKSIZE: /* * TFTP option that specifies the block size to use for data transmission */ data->set.tftp_blksize = va_arg(param, long); break; case CURLOPT_DIRLISTONLY: /* * An option that changes the command to one that asks for a list * only, no file info details. */ data->set.ftp_list_only = (0 != va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_APPEND: /* * We want to upload and append to an existing file. */ data->set.ftp_append = (0 != va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_FTP_FILEMETHOD: /* * How do access files over FTP. */ data->set.ftp_filemethod = (curl_ftpfile)va_arg(param, long); break; case CURLOPT_NETRC: /* * Parse the $HOME/.netrc file */ data->set.use_netrc = (enum CURL_NETRC_OPTION)va_arg(param, long); break; case CURLOPT_NETRC_FILE: /* * Use this file instead of the $HOME/.netrc file */ result = setstropt(&data->set.str[STRING_NETRC_FILE], va_arg(param, char *)); break; case CURLOPT_TRANSFERTEXT: /* * This option was previously named 'FTPASCII'. Renamed to work with * more protocols than merely FTP. * * Transfer using ASCII (instead of BINARY). */ data->set.prefer_ascii = (0 != va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_TIMECONDITION: /* * Set HTTP time condition. This must be one of the defines in the * curl/curl.h header file. */ data->set.timecondition = (curl_TimeCond)va_arg(param, long); break; case CURLOPT_TIMEVALUE: /* * This is the value to compare with the remote document with the * method set with CURLOPT_TIMECONDITION */ data->set.timevalue = (time_t)va_arg(param, long); break; case CURLOPT_SSLVERSION: /* * Set explicit SSL version to try to connect with, as some SSL * implementations are lame. */ data->set.ssl.version = va_arg(param, long); break; #ifndef CURL_DISABLE_HTTP case CURLOPT_AUTOREFERER: /* * Switch on automatic referer that gets set if curl follows locations. */ data->set.http_auto_referer = (0 != va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_ACCEPT_ENCODING: /* * String to use at the value of Accept-Encoding header. * * If the encoding is set to "" we use an Accept-Encoding header that * encompasses all the encodings we support. * If the encoding is set to NULL we don't send an Accept-Encoding header * and ignore an received Content-Encoding header. * */ argptr = va_arg(param, char *); result = setstropt(&data->set.str[STRING_ENCODING], (argptr && !*argptr)? (char *) ALL_CONTENT_ENCODINGS: argptr); break; case CURLOPT_TRANSFER_ENCODING: data->set.http_transfer_encoding = (0 != va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_FOLLOWLOCATION: /* * Follow Location: header hints on a HTTP-server. */ data->set.http_follow_location = (0 != va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_UNRESTRICTED_AUTH: /* * Send authentication (user+password) when following locations, even when * hostname changed. */ data->set.http_disable_hostname_check_before_authentication = (0 != va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_MAXREDIRS: /* * The maximum amount of hops you allow curl to follow Location: * headers. This should mostly be used to detect never-ending loops. */ data->set.maxredirs = va_arg(param, long); break; case CURLOPT_POSTREDIR: { /* * Set the behaviour of POST when redirecting * CURL_REDIR_GET_ALL - POST is changed to GET after 301 and 302 * CURL_REDIR_POST_301 - POST is kept as POST after 301 * CURL_REDIR_POST_302 - POST is kept as POST after 302 * CURL_REDIR_POST_303 - POST is kept as POST after 303 * CURL_REDIR_POST_ALL - POST is kept as POST after 301, 302 and 303 * other - POST is kept as POST after 301 and 302 */ int postRedir = curlx_sltosi(va_arg(param, long)); data->set.keep_post = postRedir & CURL_REDIR_POST_ALL; } break; case CURLOPT_POST: /* Does this option serve a purpose anymore? Yes it does, when CURLOPT_POSTFIELDS isn't used and the POST data is read off the callback! */ if(va_arg(param, long)) { data->set.httpreq = HTTPREQ_POST; data->set.opt_no_body = FALSE; /* this is implied */ } else data->set.httpreq = HTTPREQ_GET; break; case CURLOPT_COPYPOSTFIELDS: /* * A string with POST data. Makes curl HTTP POST. Even if it is NULL. * If needed, CURLOPT_POSTFIELDSIZE must have been set prior to * CURLOPT_COPYPOSTFIELDS and not altered later. */ argptr = va_arg(param, char *); if(!argptr || data->set.postfieldsize == -1) result = setstropt(&data->set.str[STRING_COPYPOSTFIELDS], argptr); else { /* * Check that requested length does not overflow the size_t type. */ if((data->set.postfieldsize < 0) || ((sizeof(curl_off_t) != sizeof(size_t)) && (data->set.postfieldsize > (curl_off_t)((size_t)-1)))) result = CURLE_OUT_OF_MEMORY; else { char * p; (void) setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL); /* Allocate even when size == 0. This satisfies the need of possible later address compare to detect the COPYPOSTFIELDS mode, and to mark that postfields is used rather than read function or form data. */ p = malloc((size_t)(data->set.postfieldsize? data->set.postfieldsize:1)); if(!p) result = CURLE_OUT_OF_MEMORY; else { if(data->set.postfieldsize) memcpy(p, argptr, (size_t)data->set.postfieldsize); data->set.str[STRING_COPYPOSTFIELDS] = p; } } } data->set.postfields = data->set.str[STRING_COPYPOSTFIELDS]; data->set.httpreq = HTTPREQ_POST; break; case CURLOPT_POSTFIELDS: /* * Like above, but use static data instead of copying it. */ data->set.postfields = va_arg(param, void *); /* Release old copied data. */ (void) setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL); data->set.httpreq = HTTPREQ_POST; break; case CURLOPT_POSTFIELDSIZE: /* * The size of the POSTFIELD data to prevent libcurl to do strlen() to * figure it out. Enables binary posts. */ bigsize = va_arg(param, long); if(data->set.postfieldsize < bigsize && data->set.postfields == data->set.str[STRING_COPYPOSTFIELDS]) { /* Previous CURLOPT_COPYPOSTFIELDS is no longer valid. */ (void) setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL); data->set.postfields = NULL; } data->set.postfieldsize = bigsize; break; case CURLOPT_POSTFIELDSIZE_LARGE: /* * The size of the POSTFIELD data to prevent libcurl to do strlen() to * figure it out. Enables binary posts. */ bigsize = va_arg(param, curl_off_t); if(data->set.postfieldsize < bigsize && data->set.postfields == data->set.str[STRING_COPYPOSTFIELDS]) { /* Previous CURLOPT_COPYPOSTFIELDS is no longer valid. */ (void) setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL); data->set.postfields = NULL; } data->set.postfieldsize = bigsize; break; case CURLOPT_HTTPPOST: /* * Set to make us do HTTP POST */ data->set.httppost = va_arg(param, struct curl_httppost *); data->set.httpreq = HTTPREQ_POST_FORM; data->set.opt_no_body = FALSE; /* this is implied */ break; case CURLOPT_REFERER: /* * String to set in the HTTP Referer: field. */ if(data->change.referer_alloc) { Curl_safefree(data->change.referer); data->change.referer_alloc = FALSE; } result = setstropt(&data->set.str[STRING_SET_REFERER], va_arg(param, char *)); data->change.referer = data->set.str[STRING_SET_REFERER]; break; case CURLOPT_USERAGENT: /* * String to use in the HTTP User-Agent field */ result = setstropt(&data->set.str[STRING_USERAGENT], va_arg(param, char *)); break; case CURLOPT_HTTPHEADER: /* * Set a list with HTTP headers to use (or replace internals with) */ data->set.headers = va_arg(param, struct curl_slist *); break; case CURLOPT_HTTP200ALIASES: /* * Set a list of aliases for HTTP 200 in response header */ data->set.http200aliases = va_arg(param, struct curl_slist *); break; #if !defined(CURL_DISABLE_COOKIES) case CURLOPT_COOKIE: /* * Cookie string to send to the remote server in the request. */ result = setstropt(&data->set.str[STRING_COOKIE], va_arg(param, char *)); break; case CURLOPT_COOKIEFILE: /* * Set cookie file to read and parse. Can be used multiple times. */ argptr = (char *)va_arg(param, void *); if(argptr) { struct curl_slist *cl; /* append the cookie file name to the list of file names, and deal with them later */ cl = curl_slist_append(data->change.cookielist, argptr); if(!cl) { curl_slist_free_all(data->change.cookielist); data->change.cookielist = NULL; return CURLE_OUT_OF_MEMORY; } data->change.cookielist = cl; /* store the list for later use */ } break; case CURLOPT_COOKIEJAR: /* * Set cookie file name to dump all cookies to when we're done. */ result = setstropt(&data->set.str[STRING_COOKIEJAR], va_arg(param, char *)); /* * Activate the cookie parser. This may or may not already * have been made. */ data->cookies = Curl_cookie_init(data, NULL, data->cookies, data->set.cookiesession); break; case CURLOPT_COOKIESESSION: /* * Set this option to TRUE to start a new "cookie session". It will * prevent the forthcoming read-cookies-from-file actions to accept * cookies that are marked as being session cookies, as they belong to a * previous session. * * In the original Netscape cookie spec, "session cookies" are cookies * with no expire date set. RFC2109 describes the same action if no * 'Max-Age' is set and RFC2965 includes the RFC2109 description and adds * a 'Discard' action that can enforce the discard even for cookies that * have a Max-Age. * * We run mostly with the original cookie spec, as hardly anyone implements * anything else. */ data->set.cookiesession = (0 != va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_COOKIELIST: argptr = va_arg(param, char *); if(argptr == NULL) break; Curl_share_lock(data, CURL_LOCK_DATA_COOKIE, CURL_LOCK_ACCESS_SINGLE); if(Curl_raw_equal(argptr, "ALL")) { /* clear all cookies */ Curl_cookie_clearall(data->cookies); } else if(Curl_raw_equal(argptr, "SESS")) { /* clear session cookies */ Curl_cookie_clearsess(data->cookies); } else if(Curl_raw_equal(argptr, "FLUSH")) { /* flush cookies to file */ Curl_flush_cookies(data, 0); } else { if(!data->cookies) /* if cookie engine was not running, activate it */ data->cookies = Curl_cookie_init(data, NULL, NULL, TRUE); argptr = strdup(argptr); if(!argptr) { result = CURLE_OUT_OF_MEMORY; } else { if(checkprefix("Set-Cookie:", argptr)) /* HTTP Header format line */ Curl_cookie_add(data, data->cookies, TRUE, argptr + 11, NULL, NULL); else /* Netscape format line */ Curl_cookie_add(data, data->cookies, FALSE, argptr, NULL, NULL); free(argptr); } } Curl_share_unlock(data, CURL_LOCK_DATA_COOKIE); break; #endif /* CURL_DISABLE_COOKIES */ case CURLOPT_HTTPGET: /* * Set to force us do HTTP GET */ if(va_arg(param, long)) { data->set.httpreq = HTTPREQ_GET; data->set.upload = FALSE; /* switch off upload */ data->set.opt_no_body = FALSE; /* this is implied */ } break; case CURLOPT_HTTP_VERSION: /* * This sets a requested HTTP version to be used. The value is one of * the listed enums in curl/curl.h. */ arg = va_arg(param, long); #ifndef USE_NGHTTP2 if(arg == CURL_HTTP_VERSION_2_0) return CURLE_UNSUPPORTED_PROTOCOL; #endif data->set.httpversion = arg; break; case CURLOPT_HTTPAUTH: /* * Set HTTP Authentication type BITMASK. */ { int bitcheck; bool authbits; unsigned long auth = va_arg(param, unsigned long); if(auth == CURLAUTH_NONE) { data->set.httpauth = auth; break; } /* the DIGEST_IE bit is only used to set a special marker, for all the rest we need to handle it as normal DIGEST */ data->state.authhost.iestyle = (auth & CURLAUTH_DIGEST_IE)?TRUE:FALSE; if(auth & CURLAUTH_DIGEST_IE) { auth |= CURLAUTH_DIGEST; /* set standard digest bit */ auth &= ~CURLAUTH_DIGEST_IE; /* unset ie digest bit */ } /* switch off bits we can't support */ #ifndef USE_NTLM auth &= ~CURLAUTH_NTLM; /* no NTLM support */ auth &= ~CURLAUTH_NTLM_WB; /* no NTLM_WB support */ #elif !defined(NTLM_WB_ENABLED) auth &= ~CURLAUTH_NTLM_WB; /* no NTLM_WB support */ #endif #ifndef USE_HTTP_NEGOTIATE auth &= ~CURLAUTH_GSSNEGOTIATE; /* no GSS-Negotiate without GSSAPI or WINDOWS_SSPI */ #endif /* check if any auth bit lower than CURLAUTH_ONLY is still set */ bitcheck = 0; authbits = FALSE; while(bitcheck < 31) { if(auth & (1UL << bitcheck++)) { authbits = TRUE; break; } } if(!authbits) return CURLE_NOT_BUILT_IN; /* no supported types left! */ data->set.httpauth = auth; } break; #endif /* CURL_DISABLE_HTTP */ case CURLOPT_CUSTOMREQUEST: /* * Set a custom string to use as request */ result = setstropt(&data->set.str[STRING_CUSTOMREQUEST], va_arg(param, char *)); /* we don't set data->set.httpreq = HTTPREQ_CUSTOM; here, we continue as if we were using the already set type and this just changes the actual request keyword */ break; #ifndef CURL_DISABLE_PROXY case CURLOPT_HTTPPROXYTUNNEL: /* * Tunnel operations through the proxy instead of normal proxy use */ data->set.tunnel_thru_httpproxy = (0 != va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_PROXYPORT: /* * Explicitly set HTTP proxy port number. */ data->set.proxyport = va_arg(param, long); break; case CURLOPT_PROXYAUTH: /* * Set HTTP Authentication type BITMASK. */ { int bitcheck; bool authbits; unsigned long auth = va_arg(param, unsigned long); if(auth == CURLAUTH_NONE) { data->set.proxyauth = auth; break; } /* the DIGEST_IE bit is only used to set a special marker, for all the rest we need to handle it as normal DIGEST */ data->state.authproxy.iestyle = (auth & CURLAUTH_DIGEST_IE)?TRUE:FALSE; if(auth & CURLAUTH_DIGEST_IE) { auth |= CURLAUTH_DIGEST; /* set standard digest bit */ auth &= ~CURLAUTH_DIGEST_IE; /* unset ie digest bit */ } /* switch off bits we can't support */ #ifndef USE_NTLM auth &= ~CURLAUTH_NTLM; /* no NTLM support */ auth &= ~CURLAUTH_NTLM_WB; /* no NTLM_WB support */ #elif !defined(NTLM_WB_ENABLED) auth &= ~CURLAUTH_NTLM_WB; /* no NTLM_WB support */ #endif #ifndef USE_HTTP_NEGOTIATE auth &= ~CURLAUTH_GSSNEGOTIATE; /* no GSS-Negotiate without GSSAPI or WINDOWS_SSPI */ #endif /* check if any auth bit lower than CURLAUTH_ONLY is still set */ bitcheck = 0; authbits = FALSE; while(bitcheck < 31) { if(auth & (1UL << bitcheck++)) { authbits = TRUE; break; } } if(!authbits) return CURLE_NOT_BUILT_IN; /* no supported types left! */ data->set.proxyauth = auth; } break; case CURLOPT_PROXY: /* * Set proxy server:port to use as HTTP proxy. * * If the proxy is set to "" we explicitly say that we don't want to use a * proxy (even though there might be environment variables saying so). * * Setting it to NULL, means no proxy but allows the environment variables * to decide for us. */ result = setstropt(&data->set.str[STRING_PROXY], va_arg(param, char *)); break; case CURLOPT_PROXYTYPE: /* * Set proxy type. HTTP/HTTP_1_0/SOCKS4/SOCKS4a/SOCKS5/SOCKS5_HOSTNAME */ data->set.proxytype = (curl_proxytype)va_arg(param, long); break; case CURLOPT_PROXY_TRANSFER_MODE: /* * set transfer mode (;type=<a|i>) when doing FTP via an HTTP proxy */ switch (va_arg(param, long)) { case 0: data->set.proxy_transfer_mode = FALSE; break; case 1: data->set.proxy_transfer_mode = TRUE; break; default: /* reserve other values for future use */ result = CURLE_UNKNOWN_OPTION; break; } break; #endif /* CURL_DISABLE_PROXY */ #if defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI) case CURLOPT_SOCKS5_GSSAPI_SERVICE: /* * Set gssapi service name */ result = setstropt(&data->set.str[STRING_SOCKS5_GSSAPI_SERVICE], va_arg(param, char *)); break; case CURLOPT_SOCKS5_GSSAPI_NEC: /* * set flag for nec socks5 support */ data->set.socks5_gssapi_nec = (0 != va_arg(param, long))?TRUE:FALSE; break; #endif case CURLOPT_WRITEHEADER: /* * Custom pointer to pass the header write callback function */ data->set.writeheader = (void *)va_arg(param, void *); break; case CURLOPT_ERRORBUFFER: /* * Error buffer provided by the caller to get the human readable * error string in. */ data->set.errorbuffer = va_arg(param, char *); break; case CURLOPT_FILE: /* * FILE pointer to write to. Or possibly * used as argument to the write callback. */ data->set.out = va_arg(param, void *); break; case CURLOPT_FTPPORT: /* * Use FTP PORT, this also specifies which IP address to use */ result = setstropt(&data->set.str[STRING_FTPPORT], va_arg(param, char *)); data->set.ftp_use_port = (NULL != data->set.str[STRING_FTPPORT]) ? TRUE:FALSE; break; case CURLOPT_FTP_USE_EPRT: data->set.ftp_use_eprt = (0 != va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_FTP_USE_EPSV: data->set.ftp_use_epsv = (0 != va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_FTP_USE_PRET: data->set.ftp_use_pret = (0 != va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_FTP_SSL_CCC: data->set.ftp_ccc = (curl_ftpccc)va_arg(param, long); break; case CURLOPT_FTP_SKIP_PASV_IP: /* * Enable or disable FTP_SKIP_PASV_IP, which will disable/enable the * bypass of the IP address in PASV responses. */ data->set.ftp_skip_ip = (0 != va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_INFILE: /* * FILE pointer to read the file to be uploaded from. Or possibly * used as argument to the read callback. */ data->set.in = va_arg(param, void *); break; case CURLOPT_INFILESIZE: /* * If known, this should inform curl about the file size of the * to-be-uploaded file. */ data->set.infilesize = va_arg(param, long); break; case CURLOPT_INFILESIZE_LARGE: /* * If known, this should inform curl about the file size of the * to-be-uploaded file. */ data->set.infilesize = va_arg(param, curl_off_t); break; case CURLOPT_LOW_SPEED_LIMIT: /* * The low speed limit that if transfers are below this for * CURLOPT_LOW_SPEED_TIME, the transfer is aborted. */ data->set.low_speed_limit=va_arg(param, long); break; case CURLOPT_MAX_SEND_SPEED_LARGE: /* * When transfer uploads are faster then CURLOPT_MAX_SEND_SPEED_LARGE * bytes per second the transfer is throttled.. */ data->set.max_send_speed=va_arg(param, curl_off_t); break; case CURLOPT_MAX_RECV_SPEED_LARGE: /* * When receiving data faster than CURLOPT_MAX_RECV_SPEED_LARGE bytes per * second the transfer is throttled.. */ data->set.max_recv_speed=va_arg(param, curl_off_t); break; case CURLOPT_LOW_SPEED_TIME: /* * The low speed time that if transfers are below the set * CURLOPT_LOW_SPEED_LIMIT during this time, the transfer is aborted. */ data->set.low_speed_time=va_arg(param, long); break; case CURLOPT_URL: /* * The URL to fetch. */ if(data->change.url_alloc) { /* the already set URL is allocated, free it first! */ Curl_safefree(data->change.url); data->change.url_alloc = FALSE; } result = setstropt(&data->set.str[STRING_SET_URL], va_arg(param, char *)); data->change.url = data->set.str[STRING_SET_URL]; break; case CURLOPT_PORT: /* * The port number to use when getting the URL */ data->set.use_port = va_arg(param, long); break; case CURLOPT_TIMEOUT: /* * The maximum time you allow curl to use for a single transfer * operation. */ data->set.timeout = va_arg(param, long) * 1000L; break; case CURLOPT_TIMEOUT_MS: data->set.timeout = va_arg(param, long); break; case CURLOPT_CONNECTTIMEOUT: /* * The maximum time you allow curl to use to connect. */ data->set.connecttimeout = va_arg(param, long) * 1000L; break; case CURLOPT_CONNECTTIMEOUT_MS: data->set.connecttimeout = va_arg(param, long); break; case CURLOPT_ACCEPTTIMEOUT_MS: /* * The maximum time you allow curl to wait for server connect */ data->set.accepttimeout = va_arg(param, long); break; case CURLOPT_USERPWD: /* * user:password to use in the operation */ result = setstropt_userpwd(va_arg(param, char *), &data->set.str[STRING_USERNAME], &data->set.str[STRING_PASSWORD]); break; case CURLOPT_USERNAME: /* * authentication user name to use in the operation */ result = setstropt(&data->set.str[STRING_USERNAME], va_arg(param, char *)); break; case CURLOPT_PASSWORD: /* * authentication password to use in the operation */ result = setstropt(&data->set.str[STRING_PASSWORD], va_arg(param, char *)); break; case CURLOPT_LOGIN_OPTIONS: /* * authentication options to use in the operation */ result = setstropt(&data->set.str[STRING_OPTIONS], va_arg(param, char *)); break; case CURLOPT_XOAUTH2_BEARER: /* * XOAUTH2 bearer token to use in the operation */ result = setstropt(&data->set.str[STRING_BEARER], va_arg(param, char *)); break; case CURLOPT_POSTQUOTE: /* * List of RAW FTP commands to use after a transfer */ data->set.postquote = va_arg(param, struct curl_slist *); break; case CURLOPT_PREQUOTE: /* * List of RAW FTP commands to use prior to RETR (Wesley Laxton) */ data->set.prequote = va_arg(param, struct curl_slist *); break; case CURLOPT_QUOTE: /* * List of RAW FTP commands to use before a transfer */ data->set.quote = va_arg(param, struct curl_slist *); break; case CURLOPT_RESOLVE: /* * List of NAME:[address] names to populate the DNS cache with * Prefix the NAME with dash (-) to _remove_ the name from the cache. * * Names added with this API will remain in the cache until explicitly * removed or the handle is cleaned up. * * This API can remove any name from the DNS cache, but only entries * that aren't actually in use right now will be pruned immediately. */ data->set.resolve = va_arg(param, struct curl_slist *); data->change.resolve = data->set.resolve; break; case CURLOPT_PROGRESSFUNCTION: /* * Progress callback function */ data->set.fprogress = va_arg(param, curl_progress_callback); if(data->set.fprogress) data->progress.callback = TRUE; /* no longer internal */ else data->progress.callback = FALSE; /* NULL enforces internal */ break; case CURLOPT_XFERINFOFUNCTION: /* * Transfer info callback function */ data->set.fxferinfo = va_arg(param, curl_xferinfo_callback); if(data->set.fxferinfo) data->progress.callback = TRUE; /* no longer internal */ else data->progress.callback = FALSE; /* NULL enforces internal */ break; case CURLOPT_PROGRESSDATA: /* * Custom client data to pass to the progress callback */ data->set.progress_client = va_arg(param, void *); break; #ifndef CURL_DISABLE_PROXY case CURLOPT_PROXYUSERPWD: /* * user:password needed to use the proxy */ result = setstropt_userpwd(va_arg(param, char *), &data->set.str[STRING_PROXYUSERNAME], &data->set.str[STRING_PROXYPASSWORD]); break; case CURLOPT_PROXYUSERNAME: /* * authentication user name to use in the operation */ result = setstropt(&data->set.str[STRING_PROXYUSERNAME], va_arg(param, char *)); break; case CURLOPT_PROXYPASSWORD: /* * authentication password to use in the operation */ result = setstropt(&data->set.str[STRING_PROXYPASSWORD], va_arg(param, char *)); break; case CURLOPT_NOPROXY: /* * proxy exception list */ result = setstropt(&data->set.str[STRING_NOPROXY], va_arg(param, char *)); break; #endif case CURLOPT_RANGE: /* * What range of the file you want to transfer */ result = setstropt(&data->set.str[STRING_SET_RANGE], va_arg(param, char *)); break; case CURLOPT_RESUME_FROM: /* * Resume transfer at the give file position */ data->set.set_resume_from = va_arg(param, long); break; case CURLOPT_RESUME_FROM_LARGE: /* * Resume transfer at the give file position */ data->set.set_resume_from = va_arg(param, curl_off_t); break; case CURLOPT_DEBUGFUNCTION: /* * stderr write callback. */ data->set.fdebug = va_arg(param, curl_debug_callback); /* * if the callback provided is NULL, it'll use the default callback */ break; case CURLOPT_DEBUGDATA: /* * Set to a void * that should receive all error writes. This * defaults to CURLOPT_STDERR for normal operations. */ data->set.debugdata = va_arg(param, void *); break; case CURLOPT_STDERR: /* * Set to a FILE * that should receive all error writes. This * defaults to stderr for normal operations. */ data->set.err = va_arg(param, FILE *); if(!data->set.err) data->set.err = stderr; break; case CURLOPT_HEADERFUNCTION: /* * Set header write callback */ data->set.fwrite_header = va_arg(param, curl_write_callback); break; case CURLOPT_WRITEFUNCTION: /* * Set data write callback */ data->set.fwrite_func = va_arg(param, curl_write_callback); if(!data->set.fwrite_func) { data->set.is_fwrite_set = 0; /* When set to NULL, reset to our internal default function */ data->set.fwrite_func = (curl_write_callback)fwrite; } else data->set.is_fwrite_set = 1; break; case CURLOPT_READFUNCTION: /* * Read data callback */ data->set.fread_func = va_arg(param, curl_read_callback); if(!data->set.fread_func) { data->set.is_fread_set = 0; /* When set to NULL, reset to our internal default function */ data->set.fread_func = (curl_read_callback)fread; } else data->set.is_fread_set = 1; break; case CURLOPT_SEEKFUNCTION: /* * Seek callback. Might be NULL. */ data->set.seek_func = va_arg(param, curl_seek_callback); break; case CURLOPT_SEEKDATA: /* * Seek control callback. Might be NULL. */ data->set.seek_client = va_arg(param, void *); break; case CURLOPT_CONV_FROM_NETWORK_FUNCTION: /* * "Convert from network encoding" callback */ data->set.convfromnetwork = va_arg(param, curl_conv_callback); break; case CURLOPT_CONV_TO_NETWORK_FUNCTION: /* * "Convert to network encoding" callback */ data->set.convtonetwork = va_arg(param, curl_conv_callback); break; case CURLOPT_CONV_FROM_UTF8_FUNCTION: /* * "Convert from UTF-8 encoding" callback */ data->set.convfromutf8 = va_arg(param, curl_conv_callback); break; case CURLOPT_IOCTLFUNCTION: /* * I/O control callback. Might be NULL. */ data->set.ioctl_func = va_arg(param, curl_ioctl_callback); break; case CURLOPT_IOCTLDATA: /* * I/O control data pointer. Might be NULL. */ data->set.ioctl_client = va_arg(param, void *); break; case CURLOPT_SSLCERT: /* * String that holds file name of the SSL certificate to use */ result = setstropt(&data->set.str[STRING_CERT], va_arg(param, char *)); break; case CURLOPT_SSLCERTTYPE: /* * String that holds file type of the SSL certificate to use */ result = setstropt(&data->set.str[STRING_CERT_TYPE], va_arg(param, char *)); break; case CURLOPT_SSLKEY: /* * String that holds file name of the SSL key to use */ result = setstropt(&data->set.str[STRING_KEY], va_arg(param, char *)); break; case CURLOPT_SSLKEYTYPE: /* * String that holds file type of the SSL key to use */ result = setstropt(&data->set.str[STRING_KEY_TYPE], va_arg(param, char *)); break; case CURLOPT_KEYPASSWD: /* * String that holds the SSL or SSH private key password. */ result = setstropt(&data->set.str[STRING_KEY_PASSWD], va_arg(param, char *)); break; case CURLOPT_SSLENGINE: /* * String that holds the SSL crypto engine. */ argptr = va_arg(param, char *); if(argptr && argptr[0]) result = Curl_ssl_set_engine(data, argptr); break; case CURLOPT_SSLENGINE_DEFAULT: /* * flag to set engine as default. */ result = Curl_ssl_set_engine_default(data); break; case CURLOPT_CRLF: /* * Kludgy option to enable CRLF conversions. Subject for removal. */ data->set.crlf = (0 != va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_INTERFACE: /* * Set what interface or address/hostname to bind the socket to when * performing an operation and thus what from-IP your connection will use. */ result = setstropt(&data->set.str[STRING_DEVICE], va_arg(param, char *)); break; case CURLOPT_LOCALPORT: /* * Set what local port to bind the socket to when performing an operation. */ data->set.localport = curlx_sltous(va_arg(param, long)); break; case CURLOPT_LOCALPORTRANGE: /* * Set number of local ports to try, starting with CURLOPT_LOCALPORT. */ data->set.localportrange = curlx_sltosi(va_arg(param, long)); break; case CURLOPT_KRBLEVEL: /* * A string that defines the kerberos security level. */ result = setstropt(&data->set.str[STRING_KRB_LEVEL], va_arg(param, char *)); data->set.krb = (NULL != data->set.str[STRING_KRB_LEVEL])?TRUE:FALSE; break; case CURLOPT_GSSAPI_DELEGATION: /* * GSSAPI credential delegation */ data->set.gssapi_delegation = va_arg(param, long); break; case CURLOPT_SSL_VERIFYPEER: /* * Enable peer SSL verifying. */ data->set.ssl.verifypeer = (0 != va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_SSL_VERIFYHOST: /* * Enable verification of the host name in the peer certificate */ arg = va_arg(param, long); /* Obviously people are not reading documentation and too many thought this argument took a boolean when it wasn't and misused it. We thus ban 1 as a sensible input and we warn about its use. Then we only have the 2 action internally stored as TRUE. */ if(1 == arg) { failf(data, "CURLOPT_SSL_VERIFYHOST no longer supports 1 as value!"); return CURLE_BAD_FUNCTION_ARGUMENT; } data->set.ssl.verifyhost = (0 != arg)?TRUE:FALSE; break; #ifdef USE_SSLEAY /* since these two options are only possible to use on an OpenSSL- powered libcurl we #ifdef them on this condition so that libcurls built against other SSL libs will return a proper error when trying to set this option! */ case CURLOPT_SSL_CTX_FUNCTION: /* * Set a SSL_CTX callback */ data->set.ssl.fsslctx = va_arg(param, curl_ssl_ctx_callback); break; case CURLOPT_SSL_CTX_DATA: /* * Set a SSL_CTX callback parameter pointer */ data->set.ssl.fsslctxp = va_arg(param, void *); break; #endif #if defined(USE_SSLEAY) || defined(USE_QSOSSL) || defined(USE_GSKIT) || \ defined(USE_NSS) case CURLOPT_CERTINFO: data->set.ssl.certinfo = (0 != va_arg(param, long))?TRUE:FALSE; break; #endif case CURLOPT_CAINFO: /* * Set CA info for SSL connection. Specify file name of the CA certificate */ result = setstropt(&data->set.str[STRING_SSL_CAFILE], va_arg(param, char *)); break; case CURLOPT_CAPATH: /* * Set CA path info for SSL connection. Specify directory name of the CA * certificates which have been prepared using openssl c_rehash utility. */ /* This does not work on windows. */ result = setstropt(&data->set.str[STRING_SSL_CAPATH], va_arg(param, char *)); break; case CURLOPT_CRLFILE: /* * Set CRL file info for SSL connection. Specify file name of the CRL * to check certificates revocation */ result = setstropt(&data->set.str[STRING_SSL_CRLFILE], va_arg(param, char *)); break; case CURLOPT_ISSUERCERT: /* * Set Issuer certificate file * to check certificates issuer */ result = setstropt(&data->set.str[STRING_SSL_ISSUERCERT], va_arg(param, char *)); break; case CURLOPT_TELNETOPTIONS: /* * Set a linked list of telnet options */ data->set.telnet_options = va_arg(param, struct curl_slist *); break; case CURLOPT_BUFFERSIZE: /* * The application kindly asks for a differently sized receive buffer. * If it seems reasonable, we'll use it. */ data->set.buffer_size = va_arg(param, long); if((data->set.buffer_size> (BUFSIZE -1 )) || (data->set.buffer_size < 1)) data->set.buffer_size = 0; /* huge internal default */ break; case CURLOPT_NOSIGNAL: /* * The application asks not to set any signal() or alarm() handlers, * even when using a timeout. */ data->set.no_signal = (0 != va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_SHARE: { struct Curl_share *set; set = va_arg(param, struct Curl_share *); /* disconnect from old share, if any */ if(data->share) { Curl_share_lock(data, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE); if(data->dns.hostcachetype == HCACHE_SHARED) { data->dns.hostcache = NULL; data->dns.hostcachetype = HCACHE_NONE; } #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES) if(data->share->cookies == data->cookies) data->cookies = NULL; #endif if(data->share->sslsession == data->state.session) data->state.session = NULL; data->share->dirty--; Curl_share_unlock(data, CURL_LOCK_DATA_SHARE); data->share = NULL; } /* use new share if it set */ data->share = set; if(data->share) { Curl_share_lock(data, CURL_LOCK_DATA_SHARE, CURL_LOCK_ACCESS_SINGLE); data->share->dirty++; if(data->share->hostcache) { /* use shared host cache */ data->dns.hostcache = data->share->hostcache; data->dns.hostcachetype = HCACHE_SHARED; } #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_COOKIES) if(data->share->cookies) { /* use shared cookie list, first free own one if any */ if(data->cookies) Curl_cookie_cleanup(data->cookies); /* enable cookies since we now use a share that uses cookies! */ data->cookies = data->share->cookies; } #endif /* CURL_DISABLE_HTTP */ if(data->share->sslsession) { data->set.ssl.max_ssl_sessions = data->share->max_ssl_sessions; data->state.session = data->share->sslsession; } Curl_share_unlock(data, CURL_LOCK_DATA_SHARE); } /* check for host cache not needed, * it will be done by curl_easy_perform */ } break; case CURLOPT_PRIVATE: /* * Set private data pointer. */ data->set.private_data = va_arg(param, void *); break; case CURLOPT_MAXFILESIZE: /* * Set the maximum size of a file to download. */ data->set.max_filesize = va_arg(param, long); break; #ifdef USE_SSL case CURLOPT_USE_SSL: /* * Make transfers attempt to use SSL/TLS. */ data->set.use_ssl = (curl_usessl)va_arg(param, long); break; case CURLOPT_SSL_OPTIONS: arg = va_arg(param, long); data->set.ssl_enable_beast = arg&CURLSSLOPT_ALLOW_BEAST?TRUE:FALSE; break; #endif case CURLOPT_FTPSSLAUTH: /* * Set a specific auth for FTP-SSL transfers. */ data->set.ftpsslauth = (curl_ftpauth)va_arg(param, long); break; case CURLOPT_IPRESOLVE: data->set.ipver = va_arg(param, long); break; case CURLOPT_MAXFILESIZE_LARGE: /* * Set the maximum size of a file to download. */ data->set.max_filesize = va_arg(param, curl_off_t); break; case CURLOPT_TCP_NODELAY: /* * Enable or disable TCP_NODELAY, which will disable/enable the Nagle * algorithm */ data->set.tcp_nodelay = (0 != va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_FTP_ACCOUNT: result = setstropt(&data->set.str[STRING_FTP_ACCOUNT], va_arg(param, char *)); break; case CURLOPT_IGNORE_CONTENT_LENGTH: data->set.ignorecl = (0 != va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_CONNECT_ONLY: /* * No data transfer, set up connection and let application use the socket */ data->set.connect_only = (0 != va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_FTP_ALTERNATIVE_TO_USER: result = setstropt(&data->set.str[STRING_FTP_ALTERNATIVE_TO_USER], va_arg(param, char *)); break; case CURLOPT_SOCKOPTFUNCTION: /* * socket callback function: called after socket() but before connect() */ data->set.fsockopt = va_arg(param, curl_sockopt_callback); break; case CURLOPT_SOCKOPTDATA: /* * socket callback data pointer. Might be NULL. */ data->set.sockopt_client = va_arg(param, void *); break; case CURLOPT_OPENSOCKETFUNCTION: /* * open/create socket callback function: called instead of socket(), * before connect() */ data->set.fopensocket = va_arg(param, curl_opensocket_callback); break; case CURLOPT_OPENSOCKETDATA: /* * socket callback data pointer. Might be NULL. */ data->set.opensocket_client = va_arg(param, void *); break; case CURLOPT_CLOSESOCKETFUNCTION: /* * close socket callback function: called instead of close() * when shutting down a connection */ data->set.fclosesocket = va_arg(param, curl_closesocket_callback); break; case CURLOPT_CLOSESOCKETDATA: /* * socket callback data pointer. Might be NULL. */ data->set.closesocket_client = va_arg(param, void *); break; case CURLOPT_SSL_SESSIONID_CACHE: data->set.ssl.sessionid = (0 != va_arg(param, long))?TRUE:FALSE; break; #ifdef USE_LIBSSH2 /* we only include SSH options if explicitly built to support SSH */ case CURLOPT_SSH_AUTH_TYPES: data->set.ssh_auth_types = va_arg(param, long); break; case CURLOPT_SSH_PUBLIC_KEYFILE: /* * Use this file instead of the $HOME/.ssh/id_dsa.pub file */ result = setstropt(&data->set.str[STRING_SSH_PUBLIC_KEY], va_arg(param, char *)); break; case CURLOPT_SSH_PRIVATE_KEYFILE: /* * Use this file instead of the $HOME/.ssh/id_dsa file */ result = setstropt(&data->set.str[STRING_SSH_PRIVATE_KEY], va_arg(param, char *)); break; case CURLOPT_SSH_HOST_PUBLIC_KEY_MD5: /* * Option to allow for the MD5 of the host public key to be checked * for validation purposes. */ result = setstropt(&data->set.str[STRING_SSH_HOST_PUBLIC_KEY_MD5], va_arg(param, char *)); break; #ifdef HAVE_LIBSSH2_KNOWNHOST_API case CURLOPT_SSH_KNOWNHOSTS: /* * Store the file name to read known hosts from. */ result = setstropt(&data->set.str[STRING_SSH_KNOWNHOSTS], va_arg(param, char *)); break; case CURLOPT_SSH_KEYFUNCTION: /* setting to NULL is fine since the ssh.c functions themselves will then rever to use the internal default */ data->set.ssh_keyfunc = va_arg(param, curl_sshkeycallback); break; case CURLOPT_SSH_KEYDATA: /* * Custom client data to pass to the SSH keyfunc callback */ data->set.ssh_keyfunc_userp = va_arg(param, void *); break; #endif /* HAVE_LIBSSH2_KNOWNHOST_API */ #endif /* USE_LIBSSH2 */ case CURLOPT_HTTP_TRANSFER_DECODING: /* * disable libcurl transfer encoding is used */ data->set.http_te_skip = (0 == va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_HTTP_CONTENT_DECODING: /* * raw data passed to the application when content encoding is used */ data->set.http_ce_skip = (0 == va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_NEW_FILE_PERMS: /* * Uses these permissions instead of 0644 */ data->set.new_file_perms = va_arg(param, long); break; case CURLOPT_NEW_DIRECTORY_PERMS: /* * Uses these permissions instead of 0755 */ data->set.new_directory_perms = va_arg(param, long); break; case CURLOPT_ADDRESS_SCOPE: /* * We always get longs when passed plain numericals, but for this value we * know that an unsigned int will always hold the value so we blindly * typecast to this type */ data->set.scope = curlx_sltoui(va_arg(param, long)); break; case CURLOPT_PROTOCOLS: /* set the bitmask for the protocols that are allowed to be used for the transfer, which thus helps the app which takes URLs from users or other external inputs and want to restrict what protocol(s) to deal with. Defaults to CURLPROTO_ALL. */ data->set.allowed_protocols = va_arg(param, long); break; case CURLOPT_REDIR_PROTOCOLS: /* set the bitmask for the protocols that libcurl is allowed to follow to, as a subset of the CURLOPT_PROTOCOLS ones. That means the protocol needs to be set in both bitmasks to be allowed to get redirected to. Defaults to all protocols except FILE and SCP. */ data->set.redir_protocols = va_arg(param, long); break; case CURLOPT_MAIL_FROM: /* Set the SMTP mail originator */ result = setstropt(&data->set.str[STRING_MAIL_FROM], va_arg(param, char *)); break; case CURLOPT_MAIL_AUTH: /* Set the SMTP auth originator */ result = setstropt(&data->set.str[STRING_MAIL_AUTH], va_arg(param, char *)); break; case CURLOPT_MAIL_RCPT: /* Set the list of mail recipients */ data->set.mail_rcpt = va_arg(param, struct curl_slist *); break; case CURLOPT_SASL_IR: /* Enable/disable SASL initial response */ data->set.sasl_ir = (0 != va_arg(param, long)) ? TRUE : FALSE; break; case CURLOPT_RTSP_REQUEST: { /* * Set the RTSP request method (OPTIONS, SETUP, PLAY, etc...) * Would this be better if the RTSPREQ_* were just moved into here? */ long curl_rtspreq = va_arg(param, long); Curl_RtspReq rtspreq = RTSPREQ_NONE; switch(curl_rtspreq) { case CURL_RTSPREQ_OPTIONS: rtspreq = RTSPREQ_OPTIONS; break; case CURL_RTSPREQ_DESCRIBE: rtspreq = RTSPREQ_DESCRIBE; break; case CURL_RTSPREQ_ANNOUNCE: rtspreq = RTSPREQ_ANNOUNCE; break; case CURL_RTSPREQ_SETUP: rtspreq = RTSPREQ_SETUP; break; case CURL_RTSPREQ_PLAY: rtspreq = RTSPREQ_PLAY; break; case CURL_RTSPREQ_PAUSE: rtspreq = RTSPREQ_PAUSE; break; case CURL_RTSPREQ_TEARDOWN: rtspreq = RTSPREQ_TEARDOWN; break; case CURL_RTSPREQ_GET_PARAMETER: rtspreq = RTSPREQ_GET_PARAMETER; break; case CURL_RTSPREQ_SET_PARAMETER: rtspreq = RTSPREQ_SET_PARAMETER; break; case CURL_RTSPREQ_RECORD: rtspreq = RTSPREQ_RECORD; break; case CURL_RTSPREQ_RECEIVE: rtspreq = RTSPREQ_RECEIVE; break; default: rtspreq = RTSPREQ_NONE; } data->set.rtspreq = rtspreq; break; } case CURLOPT_RTSP_SESSION_ID: /* * Set the RTSP Session ID manually. Useful if the application is * resuming a previously established RTSP session */ result = setstropt(&data->set.str[STRING_RTSP_SESSION_ID], va_arg(param, char *)); break; case CURLOPT_RTSP_STREAM_URI: /* * Set the Stream URI for the RTSP request. Unless the request is * for generic server options, the application will need to set this. */ result = setstropt(&data->set.str[STRING_RTSP_STREAM_URI], va_arg(param, char *)); break; case CURLOPT_RTSP_TRANSPORT: /* * The content of the Transport: header for the RTSP request */ result = setstropt(&data->set.str[STRING_RTSP_TRANSPORT], va_arg(param, char *)); break; case CURLOPT_RTSP_CLIENT_CSEQ: /* * Set the CSEQ number to issue for the next RTSP request. Useful if the * application is resuming a previously broken connection. The CSEQ * will increment from this new number henceforth. */ data->state.rtsp_next_client_CSeq = va_arg(param, long); break; case CURLOPT_RTSP_SERVER_CSEQ: /* Same as the above, but for server-initiated requests */ data->state.rtsp_next_client_CSeq = va_arg(param, long); break; case CURLOPT_INTERLEAVEDATA: data->set.rtp_out = va_arg(param, void *); break; case CURLOPT_INTERLEAVEFUNCTION: /* Set the user defined RTP write function */ data->set.fwrite_rtp = va_arg(param, curl_write_callback); break; case CURLOPT_WILDCARDMATCH: data->set.wildcardmatch = (0 != va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_CHUNK_BGN_FUNCTION: data->set.chunk_bgn = va_arg(param, curl_chunk_bgn_callback); break; case CURLOPT_CHUNK_END_FUNCTION: data->set.chunk_end = va_arg(param, curl_chunk_end_callback); break; case CURLOPT_FNMATCH_FUNCTION: data->set.fnmatch = va_arg(param, curl_fnmatch_callback); break; case CURLOPT_CHUNK_DATA: data->wildcard.customptr = va_arg(param, void *); break; case CURLOPT_FNMATCH_DATA: data->set.fnmatch_data = va_arg(param, void *); break; #ifdef USE_TLS_SRP case CURLOPT_TLSAUTH_USERNAME: result = setstropt(&data->set.str[STRING_TLSAUTH_USERNAME], va_arg(param, char *)); if(data->set.str[STRING_TLSAUTH_USERNAME] && !data->set.ssl.authtype) data->set.ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */ break; case CURLOPT_TLSAUTH_PASSWORD: result = setstropt(&data->set.str[STRING_TLSAUTH_PASSWORD], va_arg(param, char *)); if(data->set.str[STRING_TLSAUTH_USERNAME] && !data->set.ssl.authtype) data->set.ssl.authtype = CURL_TLSAUTH_SRP; /* default to SRP */ break; case CURLOPT_TLSAUTH_TYPE: if(strnequal((char *)va_arg(param, char *), "SRP", strlen("SRP"))) data->set.ssl.authtype = CURL_TLSAUTH_SRP; else data->set.ssl.authtype = CURL_TLSAUTH_NONE; break; #endif case CURLOPT_DNS_SERVERS: result = Curl_set_dns_servers(data, va_arg(param, char *)); break; case CURLOPT_DNS_INTERFACE: result = Curl_set_dns_interface(data, va_arg(param, char *)); break; case CURLOPT_DNS_LOCAL_IP4: result = Curl_set_dns_local_ip4(data, va_arg(param, char *)); break; case CURLOPT_DNS_LOCAL_IP6: result = Curl_set_dns_local_ip6(data, va_arg(param, char *)); break; case CURLOPT_TCP_KEEPALIVE: data->set.tcp_keepalive = (0 != va_arg(param, long))?TRUE:FALSE; break; case CURLOPT_TCP_KEEPIDLE: data->set.tcp_keepidle = va_arg(param, long); break; case CURLOPT_TCP_KEEPINTVL: data->set.tcp_keepintvl = va_arg(param, long); break; default: /* unknown tag and its companion, just ignore: */ result = CURLE_UNKNOWN_OPTION; break; } return result; }
[ "993273596@qq.com" ]
993273596@qq.com
d1e1e82c5c4258525bb75bc4beed0baa1606669c
b9d335b40359423a868f36bb50533e355f409b38
/Course C++ workshop/HW/part _2/Afeka/part _2/Airline/Airline/main.cpp
ab2afc829ef4492a83db4bb7a09d389eb437449b
[]
no_license
YigalOrn/Afeka
58c8426af091ab854f041781b301c146623f7641
cdf47b5a1241af8e00a1fe9e4912e6617e3fff6b
refs/heads/master
2020-03-14T06:17:22.846129
2019-02-07T10:11:34
2019-02-07T10:11:34
131,480,781
0
0
null
null
null
null
UTF-8
C++
false
false
3,922
cpp
#include "Airline.h" #include <iostream> using namespace std; void main() { //Create Airline Airline airline("EL-AL"); //Create Planes Plane p1(50), p2, p3(200); airline.addPlane(p1); airline.addPlane(p2); airline.addPlane(p3); //Create Staff Members Pilot** pilots = new Pilot*[3]; Attendant** attendants = new Attendant*[3]; pilots[0] = new Pilot(Person("Ross", 32), 5, 35000, 2); pilots[1] = new Pilot(Person("Joey", 41), 11, 42000, 3); pilots[2] = new Pilot(Person("Chandler", 55), 25, 70000, 5); attendants[0] = new Attendant(Person("Phoebe", 20), 1, 5000); attendants[1] = new Attendant(Person("Rachel", 22), 2, 5750); attendants[2] = new Attendant(Person("Monica", 28), 3, 7000); for (int i = 0; i < 3; i++) airline.addCrewMember(*pilots[i]); for (int i = 0; i < 3; i++) airline.addCrewMember(*attendants[i]); //Create Flights Flight f1(&p1, Date(1, 2, 2015), "London", pilots[0]); Flight f2(&p2, Date(11, 12, 2015), "Tomsk", pilots[1]); Flight f3(&p1, Date(4, 9, 2015), "Rome", pilots[2]); Flight f4(&p3, Date(1, 2, 2015), "Tel-Aviv", pilots[0]); airline.addFlight(f1); airline.addFlight(f2); airline.addFlight(f3); airline.addFlight(f4); //add crew members airline.addStaffMemberToFlight(*attendants[1], f1); airline.addStaffMemberToFlight(*attendants[0], f1); airline.addStaffMemberToFlight(*pilots[1], f1); airline.addStaffMemberToFlight(*attendants[1], f2); airline.addStaffMemberToFlight(*attendants[2], f2); airline.addStaffMemberToFlight(*attendants[0], f3); airline.addStaffMemberToFlight(*pilots[1], f3); airline.addStaffMemberToFlight(*pilots[2], f4); //remove crew members airline.removeStaffMemberFromFlight(*attendants[0], f1); airline.removeStaffMemberFromFlight(*attendants[0], f2); // should not work airline.removeStaffMemberFromFlight(*attendants[0], f3); //Create Customers Customer** customers = new Customer*[3]; customers[0] = new Customer(Person("Koko", 37)); customers[1] = new Customer(Person("Momo", 21)); customers[2] = new Customer(Person("Gogo", 45)); for (int i = 0; i < 3; i++) { airline.addCustomer(*customers[i]); } //Create Orders Order o1(Date(1, 1, 2015), customers[0]); o1 += airline.createTicketForFlight(f1); o1 += airline.createTicketForFlight(f1); o1 += airline.createTicketForFlight(f2); Order o2(Date(2, 1, 2015), customers[1]); o2 += airline.createTicketForFlight(f2); o2 += airline.createTicketForFlight(f3); Order o3(Date(11, 5, 2015), customers[2]); o3 += airline.createTicketForFlight(f2); o3 += airline.createTicketForFlight(f3); o3 += airline.createTicketForFlight(f4); Order o4(Date(5, 2, 2015), customers[2]); o4 += airline.createTicketForFlight(f2); // operator += o4 += airline.createTicketForFlight(f3); airline.addOrder(o1); airline.addOrder(o2); airline.addOrder(o3); //remove some tickets o3 -= *(o3.getTickets()[2]); // operator -= o1 -= *(o1.getTickets()[1]); //Cancel an order airline.cancelOrder(o4); cout << airline << endl; //Free the allocations for (int i = 0; i < 3; i++) delete pilots[i]; delete[]pilots; for (int i = 0; i < 3; i++) delete attendants[i]; delete[]attendants; for (int i = 0; i < 3; i++) delete customers[i]; delete[] customers; // Try some operators //operators +, () Date d(1, 1, 2015); cout << d << endl; d = d + 5; cout << d << endl; d = 2 + d; cout << d << endl; d(2, 2, 2016);//operator() cout << d << endl; // operator [] cout << "Find employee by name.. Enter a name : " << endl; char name[100]; cin.getline(name, 100); int size = airline.getFlightsAmount(); Flight*const* flights = airline.getFlights(); int flag = 0; for (int i = 0; i < size; i++) { const AirCrew* const ac = (*flights[i])[name]; if (ac != NULL) { flag = 1; cout << ac << endl; } }//for if (!flag) { cout << "Did not found any staff member by the name " << name << endl; } }//main
[ "yigalorn@gmail.com" ]
yigalorn@gmail.com
de461719b14ba64325d4a0bdc5181b3d63401ef9
62126238af2e3e85b9337f66293c2a29946aa2a1
/framework/Thread/ThreadIOS/Sources/SemaphoreIOS.cpp
94dca5fcd1729a164ed30b4f509b8c7a175fd0de
[ "MIT" ]
permissive
metalkin/kigs
b43aa0385bdd9a495c5e30625c33a170df410593
87d1757da56a5579faf1d511375eccd4503224c7
refs/heads/master
2021-02-28T10:29:30.443801
2020-03-06T13:39:38
2020-03-06T13:51:54
null
0
0
null
null
null
null
UTF-8
C++
false
false
588
cpp
#include "SemaphoreIOS.h" #include "Core.h" IMPLEMENT_CLASS_INFO(SemaphoreIOS) SemaphoreIOS::SemaphoreIOS(const kstl::string& name, CLASS_NAME_TREE_ARG) : Semaphore(name, PASS_CLASS_NAME_TREE_ARG) { pthread_mutex_init(&myMutexLock,0); } SemaphoreIOS::~SemaphoreIOS() { pthread_mutex_destroy(&myMutexLock); } bool SemaphoreIOS::addItem(CoreModifiable *item, ItemPosition pos) { pthread_mutex_lock(&myMutexLock); return true; } bool SemaphoreIOS::removeItem(CoreModifiable *item DECLARE_DEFAULT_LINK_NAME) { pthread_mutex_unlock(&myMutexLock); return true; }
[ "stephane.capo@assoria.com" ]
stephane.capo@assoria.com
8c9dc9e10025ecf20596a68190fb6848241e7869
2620e0834c1b58a532e9875c9ea040d664027d9d
/app/src/main/cpp/ClientSocketDataDealThread.cpp
01961c092e5d3a1d9db8f7e692174b09917479f2
[]
no_license
EastUp/AndroidJnitSocket
93fbd92911d1bbabc4a6bcc4b15f66091299b4b6
9aa2d33721a6dc0d305b21225f941fd409d25813
refs/heads/master
2023-03-18T02:25:59.210426
2021-03-09T06:05:47
2021-03-09T06:05:47
345,900,747
2
0
null
null
null
null
UTF-8
C++
false
false
4,660
cpp
// // Created by Administrator on 2017/3/3 0003. // #include <sys/socket.h> #include <jni.h> #include <malloc.h> #include <memory.h> #include "my_log.h" #include "ClientSocketDataDealThread.h" pthread_cond_t ClientSocketDataDealThread::cond = PTHREAD_COND_INITIALIZER; pthread_mutex_t ClientSocketDataDealThread::mutex = PTHREAD_MUTEX_INITIALIZER; int ClientSocketDataDealThread::socketFd = 0; char *ClientSocketDataDealThread::getBuffer = NULL; bool ClientSocketDataDealThread::isShoudExit = false; JNIEnv *ClientSocketDataDealThread::env = NULL; jobject ClientSocketDataDealThread::obj = NULL; JavaVM *ClientSocketDataDealThread::javavm = NULL; void *ClientSocketDataDealThread::clientThread(void *args) { javavm->AttachCurrentThread(&ClientSocketDataDealThread::env, NULL); LOGI("%s:ClientSocketDataDealThread is running", TAG); while (!ClientSocketDataDealThread::isShoudExit) { // pthread_mutex_lock(&ClientSocketDataDealThread::mutex); // pthread_cond_wait(&ClientSocketDataDealThread::cond,&ClientSocketDataDealThread::mutex); // pthread_mutex_unlock(&ClientSocketDataDealThread::mutex); LOGI("%s:clientThread wake ", TAG); _SP_SendToClintStream_INFO *myNode = (_SP_SendToClintStream_INFO *) malloc( sizeof(_SP_SendToClintStream_INFO)); int needRecv = sizeof(_SP_SendToClintStream_INFO); char *buffer = (char *) malloc(needRecv); int pos = 0; int len; while (pos < needRecv) { LOGI("%s:needRecv=%d", TAG,needRecv); len = recv(socketFd, buffer + pos,needRecv, 0); LOGI("%s:len = %d", TAG, len); if (len < 0) { LOGI("%s:Server Recieve Data Failed!", TAG); printf("Server Recieve Data Failed!\n"); // break; } pos += len; } // close(new_server_socket); memcpy(myNode, buffer, needRecv); LOGI("%s:recv over Width=%d Height=%d\n",TAG, myNode->_Width, myNode->_Height); // free(buffer); // free(myNode); // int len = recv(socketFd,getBuffer, sizeof(getBuffer),0); LOGI("%s:get data %s,len = %d", TAG, buffer, len); if (ClientSocketDataDealThread::env != NULL && ClientSocketDataDealThread::obj) { jclass cls = ClientSocketDataDealThread::env->GetObjectClass( ClientSocketDataDealThread::obj); // if(cls == NULL){ // LOGI("%s:find class error",TAG); // pthread_exit(NULL); // } jmethodID mid = ClientSocketDataDealThread::env->GetMethodID(cls, "setRecevieData", "([B)V"); ClientSocketDataDealThread::env->DeleteLocalRef(cls); if (mid == NULL) { LOGI("%s:find method1 error", TAG); pthread_exit(NULL); } jbyteArray jarray = ClientSocketDataDealThread::env->NewByteArray(len); ClientSocketDataDealThread::env->SetByteArrayRegion(jarray, 0, len, (jbyte *) buffer); ClientSocketDataDealThread::env->CallVoidMethod(obj, mid, jarray); ClientSocketDataDealThread::env->DeleteLocalRef(jarray); } } LOGI("%s:ClientSocketDataDealThread exit", TAG); return NULL; } ClientSocketDataDealThread::ClientSocketDataDealThread(int fd, jobject obj1) : threadId(0), sendLength(0) { pthread_mutex_init(&mutex, 0); pthread_cond_init(&cond, 0); socketFd = fd; ClientSocketDataDealThread::obj = obj1; getBuffer = new char[100]; sendBuffer = new char[100]; if (pthread_create(&threadId, NULL, ClientSocketDataDealThread::clientThread, NULL) != 0) { LOGI("%s:pthread_create error", TAG); } LOGI("%s:mSTh->getSocketThreadId():%lu", TAG, (long) threadId); } ClientSocketDataDealThread::~ClientSocketDataDealThread() { delete getBuffer; delete sendBuffer; } void ClientSocketDataDealThread::sendData(char *buff, int length) { LOGI("%s:send data %s,len = %d", TAG, buff, length); int len = send(socketFd, buff, length, 0); if (len < 0) { LOGI("%s:send data error,len = %d", TAG, len); } wakeUpThread(); } pthread_t ClientSocketDataDealThread::getSocketThreadId() { return threadId; } void ClientSocketDataDealThread::wakeUpThread() { pthread_mutex_lock(&ClientSocketDataDealThread::mutex); // 设置条件为真 pthread_cond_signal(&ClientSocketDataDealThread::cond); pthread_mutex_unlock(&ClientSocketDataDealThread::mutex); }
[ "eastrisewm@163.com" ]
eastrisewm@163.com
939f94896cd57620e881c45c0253826fabd2f230
04fa32e35971bcef99074b97fdf0a611005799c5
/VersionC++/vector2d.cpp
fe21f6840bd88bc536dc01a7912bb4b6751c0f7b
[]
no_license
AdrianWennberg/ATak
71cd56c2442b2f9c4c108e7c28a34ef525db7983
07aa97c24b47ec0f3194e04d0d84c15f93ff9444
refs/heads/master
2021-01-22T21:07:39.882646
2017-11-13T06:52:05
2017-11-13T06:52:05
85,395,233
0
0
null
null
null
null
UTF-8
C++
false
false
723
cpp
#include <vector> #include "vector2d.h" using namespace std; template<typename T> Vector2d<T>::Vector2d(int pRows, int pColumns) : mRows(pRows), mColumns(pColumns), mField(pRows * pColumns) { }; template<typename T> void Vector2d<T>::setPosition(int pRow, int pColumn, int value) { if(pRow < mRows && pColumn < mColumns) { mField[pRow * mColumns + pColumn] = value; } }; template<typename T> T *Vector2d<T>::getPositionPointer(int pRow, int pColumn) { return &(mField[pRow * mColumns + pColumn]); }; template<typename T> int Vector2d<T>::getFieldSize() { return mField.size(); }; template<typename T> SquareVector<T>::SquareVector(int size) : Vector2d<T>(size, size) { };
[ "saikoupanda@gmail.com" ]
saikoupanda@gmail.com
1ea6635bfa0287eb51c062178ecc9232e541b9c4
a3be167a074cc31f61bd5df831373d24d4ec008c
/gfg/mimimum_copy_paste.cpp
9611ef4ed5a237fffa7a7cc022faaf92d1899293
[]
no_license
Nimishkhurana/Data-Structures
5a20b0b7882b3e9d2c853433902caba0a4f8b596
579c3d26b89392f75864543db821af40cb07622f
refs/heads/master
2021-07-08T14:36:48.043616
2020-07-29T18:48:03
2020-07-29T18:48:03
160,632,175
2
2
null
2019-10-18T20:10:54
2018-12-06T06:52:10
C++
UTF-8
C++
false
false
305
cpp
#include<iostream> using namespace std; int main(){ int n; cin>>n; int count = 0; for(int i=2;i<n;i++){ while(n%i==0){ count+=i; n/=i; } if(n<=4 && n>1){ count+=n; break; } } cout<<count<<endl; }
[ "nimishkhurana9@gmail.com" ]
nimishkhurana9@gmail.com
827d7cd46fa797d9e1ef5fee87bc7fd5270f936f
3b2208eae66b7f565bce678674059f83043136f9
/16. 3Sum Closest.cpp
f33bd38ba32f41c970db4bb3ba3af17d68e99b9f
[]
no_license
ccw2010/lc
23b07e75c10df16a85d04a727d3fadc820bd4752
90dc55143999e4c2d032df582d1825c17998e51a
refs/heads/master
2021-08-07T14:05:58.998697
2018-10-05T18:38:15
2018-10-05T18:38:15
136,192,287
0
2
null
null
null
null
UTF-8
C++
false
false
1,802
cpp
/*16. 3Sum Closest Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input would have exactly one solution. Example: Given array nums = [-1, 2, 1, -4], and target = 1. The sum that is closest to the target is 2. (-1 + 2 + 1 = 2). */ /*这道题让我们求最接近给定值的三数之和,是在 15.3Sum 三数之和的基础上又增加了些许难度,那么这道题让我们返回这个 最接近于给定值的值,即我们要保证当前三数和跟给定值之间的差的绝对值最小,所以我们需要定义一个变量diff用来记录差的绝对值, 然后我们还是要先将数组排个序,然后开始遍历数组,思路跟那道三数之和很相似,都是先确定一个数,然后用两个指针left和right来 滑动寻找另外两个数,每确定两个数,我们求出此三数之和,然后算和给定值的差的绝对值存在newDiff中,然后和diff比较并更新diff 和结果closest即可*/ class Solution { public: int threeSumClosest(vector<int>& nums, int target) { int closest = nums[0] + nums[1] + nums[2]; int diff = abs(closest - target); sort(nums.begin(), nums.end()); int n = nums.size(); for (int k = 0; k < n - 2; k++) { int i = k + 1, j = n - 1; while (i < j) { int sum = nums[k] + nums[i] + nums[j]; int newDiff = abs(sum - target); if (newDiff < diff) { diff = newDiff; closest = sum; } if (sum < target) i++; else j--; } } return closest; } };
[ "noreply@github.com" ]
ccw2010.noreply@github.com
d7cf116cc9b22399798acdea65c4ba346afbbd88
539ba303916e1b2bddd364c44cd1a07125449963
/WebServer/settings.ino
f965ae6381d418f97e11a4ecb4e3dc2952d13413
[]
no_license
DanLoad/Web-interface-for-ESP32
bb75ae942cf0b895c4d5fc7a93e6cf55ddbc7226
84c836d7175e05e86ba7a7294d19c48a5a0687d9
refs/heads/master
2021-05-17T03:55:40.604843
2020-03-29T16:38:32
2020-03-29T16:38:32
250,610,565
0
0
null
null
null
null
UTF-8
C++
false
false
1,091
ino
void Settings_read() { settingsWifi = readFile("json/settings/Wifi.json", 4096); settingsNetwork = readFile("json/settings/Network.json", 4096); settingsMqtt = readFile("json/settings/Mqtt.json", 4096); settingsAP = readFile("json/settings/AP.json", 4096); Config = readFile("json/settings/Conf.json", 4096); Serial.print("Settings Read Done"); } void Settings_WiFi() { _ssid = jsonRead(settingsWifi, "ssid"); _password = jsonRead(settingsWifi, "password"); _ssidAP = jsonRead(settingsAP, "ssidAP"); _passwordAP = jsonRead(settingsAP, "passwordAP"); nameMod = jsonRead(Config, "module"); idMod = jsonRead(Config, "name"); host = jsonRead(Config, "host"); Serial.print("Settings WiFi Done >>>>>>"); } void Settings_Mqtt() { String s = ""; int n = 0; host = jsonRead(settingsWifi, "host"); mqttServer = jsonRead(settingsMqtt, "mqttServer"); mqttPort = jsonReadtoInt(settingsMqtt, "mqttPort"); mqttUser = jsonRead(settingsMqtt, "mqttUser"); mqttPassword = jsonRead(settingsMqtt, "mqttPassword"); }
[ "danmetalist@gmail.com" ]
danmetalist@gmail.com
57ef891de81f6fbbeff7fe3046e43ca6a8cb71f8
d9f2430ec0c61e5cb69d01f3abd5667ab4c924c6
/datalust/src/Physics/ContactResolver.cpp
977dc69a5d7779a5c44258ce58ef1cbf4f1efa99
[]
no_license
ProgrammingMoogle/Portfolio
d74aeff998386e6724ab133d8024b194688a6057
8e361dea4b9e523f57525fe2d049667618a6c24d
refs/heads/master
2020-03-27T04:03:17.361681
2018-08-23T22:30:11
2018-08-23T22:30:11
145,908,779
0
1
null
null
null
null
UTF-8
C++
false
false
8,729
cpp
#pragma once /******************************************************************************/ /*! \file ContactResolver.cpp \author Keonwoo Ryoo \par email: keonwoo.ryoo\@digipen.edu \par DigiPen login: keonwoo.ryoo \par Last Update: 9/8/2017 \date 9/8/2017 \brief All content © 2017 DigiPen (USA) Corporation, all rights reserved. */ /******************************************************************************/ #include "ContactResolver.hpp" #include "ForceRegistry.hpp" #include <GameObject/Component.h> #include <GameObject/GameObject.h> #include <Transform/Transform.hpp> #include <Messaging/Messaging.hpp> #include <Engine/Engine.h> /** * \brief */ namespace KPE { /** * \brief * \param contactList */ void ContactResolver::addContactList(ContactList* contactList) { contactLists_.push_back(contactList); } /** * \brief * \param registry * \param dt * \return */ int ContactResolver::resolveContacts(ForceRegistry& registry, float dt) { int numContacts = 0; Messaging::MessageHandler* mHandler = engine.Find<Messaging::MessageHandler>(); //Loop through the vector of ContactLists auto iterList = contactLists_.begin(); for (; iterList != contactLists_.end(); ++iterList) { RigidBody* body = (*iterList)->body; RigidBody* otherBody = (*iterList)->otherBody; //Loop through the list of contacts auto iterContact = (*iterList)->contacts_.begin(); for (; iterContact != (*iterList)->contacts_.end(); ++iterContact) { ++numContacts; //Check what type of contact it is if ((*iterContact)->bound_->getType() == BoundType::BoundBox) { ContactBB* tempContact = static_cast<ContactBB*>((*iterContact)); bool pass = true; //Possible semisolid interaction Messaging::Message msg; msg.id = Messaging::ID::Collision; msg.message.collision.hit_ = false; msg.message.collision.pass_ = &pass; msg.message.collision.body_ = body; msg.message.collision.otherBody_ = otherBody; msg.message.collision.normal_ = tempContact->contactNormal_; msg.message.collision.penetration_ = tempContact->penetration_; mHandler->Post(msg); if (pass) { //Resolve Velocity resolveVelocity(tempContact, body, otherBody, dt); //Resolve Interpenetration if (tempContact->penetration_ > 0.0f) resolvePenetration(tempContact, body, otherBody, dt); //positionalCorrection(tempContact, body, otherBody); } } else { ContactHB* tempContact = static_cast<ContactHB*>((*iterContact)); //Send to messaging Messaging::Message msg; msg.id = Messaging::ID::Collision; msg.message.collision.hit_ = true; //Order RigidBodies (Hitbox, Hurtbox) if (tempContact->bound_->getType() == BoundHitBox) { msg.message.collision.body_ = body; msg.message.collision.otherBody_ = otherBody; msg.message.collision.normal_ = tempContact->contactNormal_; msg.message.collision.penetration_ = tempContact->penetration_; } else if (tempContact->bound_->getType() == BoundHurtBox) { msg.message.collision.body_ = otherBody; msg.message.collision.otherBody_ = body; msg.message.collision.normal_ = -(tempContact->contactNormal_); msg.message.collision.penetration_ = tempContact->penetration_; } mHandler->Post(msg); } } //Delete ContactList } //Clear the list vector clear(); return numContacts; } /** * \brief * \param contact * \param body * \param otherBody * \param dt */ void ContactResolver::resolveVelocity(ContactBB* contact, RigidBody* body, RigidBody* otherBody, float dt) { glm::vec2 tempVel(0); //Temporary velocity vector //Get Total Separating Velocity float separatingVelocity = calculateSeparatingVelocity(contact, body, otherBody); //If no separating velocity, no need to resolve velocity //Separating velocity must be negative. Positive means they are separating, not colliding if (separatingVelocity > 0) return; //Apply restitution float newSepVel = -separatingVelocity * contact->restitution_; //Find velocity caused by acceleration glm::vec2 accCausedVel = body->getLastAcceleration(); if (otherBody) accCausedVel -= otherBody->getLastAcceleration(); float accCausedSepVel = dot(accCausedVel, contact->contactNormal_) * dt; //Apply acceleration velocity to separating velocity if (accCausedSepVel < 0) { newSepVel += -accCausedSepVel * contact->restitution_; if (newSepVel < 0) newSepVel = 0; } //Find the delta velocity float deltaVel = newSepVel - separatingVelocity; //Find total inverse mass of both bodies float totalInverseMass = body->getInverseMass(); if (otherBody) if (otherBody->hasFiniteMass()) totalInverseMass += otherBody->getInverseMass(); if (totalInverseMass <= 0) return; //Find impulse magnitude per inverse mass float impulse = deltaVel / totalInverseMass; //Find impulse per inverse mass glm::vec2 impulsePerInverseMass = contact->contactNormal_ * impulse; //Apply velocities tempVel = body->getVelocity(); tempVel += impulsePerInverseMass * body->getInverseMass(); body->setVelocity(tempVel); if (otherBody) { tempVel = otherBody->getVelocity(); tempVel -= impulsePerInverseMass * otherBody->getInverseMass(); otherBody->setVelocity(tempVel); } } /** * \brief * \param contact * \param body * \param otherBody * \param dt */ void ContactResolver::resolvePenetration(ContactBB* contact, RigidBody* body, RigidBody* otherBody, float dt) { Transform* trans = body->GetParent().Find<Transform>(); Transform* otherTrans = otherBody->GetParent().Find<Transform>(); if (!(otherBody->hasFiniteMass())) { trans->setPosition( trans->getPosition() + contact->penetration_ * contact->contactNormal_); return; } glm::vec2 tempVel(0); if (contact->penetration_ <= 0) return; if ((body->GetParent().GetName() == "Player1" && otherBody->GetParent().GetName() == "Player2") || (body->GetParent().GetName() == "Player2" && otherBody->GetParent().GetName() == "Player1")) { tempVel.x = 0; } //Neither are immovable. float totalInverseMass = body->getInverseMass(); if (otherBody) if (otherBody->hasFiniteMass()) totalInverseMass += otherBody->getInverseMass(); if (totalInverseMass <= 0) return; glm::vec2 pulsePerInverseMass = contact->contactNormal_ * (contact->penetration_ / totalInverseMass); glm::vec2 tempShift(0); tempShift = pulsePerInverseMass * body->getInverseMass(); tempShift += trans->getPosition(); trans->setPosition(tempShift); if (otherBody) { tempShift = -pulsePerInverseMass * otherBody->getInverseMass(); tempShift += otherTrans->getPosition(); otherTrans->setPosition(tempShift); } } /** * \brief * \param contact * \param body * \param otherBody * \return */ float ContactResolver::calculateSeparatingVelocity(ContactBB* contact, RigidBody* body, RigidBody* otherBody) const { glm::vec2 relativeVel = body->getVelocity(); if (otherBody) relativeVel -= otherBody->getVelocity(); return dot(relativeVel, contact->contactNormal_); } /** * \brief * \param contact * \param body * \param otherBody */ void ContactResolver::positionalCorrection( Contact* contact, RigidBody* body, RigidBody* otherBody) { Transform* trans = body->GetParent().Find<Transform>(); Transform* otherTrans = otherBody->GetParent().Find<Transform>(); float percentage = 0.2f; glm::vec2 correction = contact->penetration_ / (body->getInverseMass() + otherBody->getInverseMass()) * percentage * contact->contactNormal_; trans->setPosition( trans->getPosition() + correction * body->getInverseMass()); otherTrans->setPosition( otherTrans->getPosition() + correction * otherBody->getInverseMass()); } /** * \brief */ void ContactResolver::clear(void) { auto iter = contactLists_.begin(); for (; iter != contactLists_.end(); ++iter) { delete *iter; } contactLists_.clear(); } }
[ "42657613+ProgrammingMoogle@users.noreply.github.com" ]
42657613+ProgrammingMoogle@users.noreply.github.com
9d04ef85f15833ee0424927374eb3d396631da75
2dc9ab0ec71fd31900173fb15a6f2c85753180c4
/third_party/blink/renderer/core/display_lock/display_lock_document_state.h
d7f9ca8cace4b8c39e2fce5046c82ee9541172d8
[ "LGPL-2.0-or-later", "LicenseRef-scancode-warranty-disclaimer", "LGPL-2.1-only", "GPL-1.0-or-later", "GPL-2.0-only", "LGPL-2.0-only", "BSD-2-Clause", "LicenseRef-scancode-other-copyleft", "MIT", "Apache-2.0", "BSD-3-Clause" ]
permissive
Forilan/chromium
ec337c30d23c22d11fbdf814a40b9b4c26000d78
562b20b68672e7831054ec8f160d5f7ae940eae4
refs/heads/master
2023-02-28T02:43:17.744240
2020-05-12T02:23:44
2020-05-12T02:23:44
231,539,724
0
0
BSD-3-Clause
2020-05-12T02:23:45
2020-01-03T07:52:37
null
UTF-8
C++
false
false
6,029
h
// Copyright 2020 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef THIRD_PARTY_BLINK_RENDERER_CORE_DISPLAY_LOCK_DISPLAY_LOCK_DOCUMENT_STATE_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_DISPLAY_LOCK_DISPLAY_LOCK_DOCUMENT_STATE_H_ #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/display_lock/display_lock_utilities.h" #include "third_party/blink/renderer/platform/heap/heap.h" #include "third_party/blink/renderer/platform/heap/heap_allocator.h" #include "third_party/blink/renderer/platform/heap/member.h" namespace blink { class DisplayLockContext; class Document; class Element; class IntersectionObserver; class IntersectionObserverEntry; // This class is responsible for keeping document level state for the display // locking feature. class CORE_EXPORT DisplayLockDocumentState final : public GarbageCollected<DisplayLockDocumentState> { public: explicit DisplayLockDocumentState(Document* document); // GC. void Trace(Visitor*); // Registers a display lock context with the state. This is used to force all // activatable locks. void AddDisplayLockContext(DisplayLockContext*); void RemoveDisplayLockContext(DisplayLockContext*); int DisplayLockCount() const; // Bookkeeping: the count of all locked display locks. void AddLockedDisplayLock(); void RemoveLockedDisplayLock(); int LockedDisplayLockCount() const; // Bookkeeping: the count of all locked display locks which block all // activation (i.e. content-visibility: hidden locks). void IncrementDisplayLockBlockingAllActivation(); void DecrementDisplayLockBlockingAllActivation(); int DisplayLockBlockingAllActivationCount() const; // Register the given element for intersection observation. Used for detecting // viewport intersections for content-visibility: auto locks. void RegisterDisplayLockActivationObservation(Element*); void UnregisterDisplayLockActivationObservation(Element*); // Returns true if all activatable locks have been forced. bool ActivatableDisplayLocksForced() const; class ScopedForceActivatableDisplayLocks { STACK_ALLOCATED(); public: ScopedForceActivatableDisplayLocks(ScopedForceActivatableDisplayLocks&&); ~ScopedForceActivatableDisplayLocks(); ScopedForceActivatableDisplayLocks& operator=( ScopedForceActivatableDisplayLocks&&); private: friend DisplayLockDocumentState; explicit ScopedForceActivatableDisplayLocks(DisplayLockDocumentState*); DisplayLockDocumentState* state_; }; ScopedForceActivatableDisplayLocks GetScopedForceActivatableLocks(); // Notify the display locks that selection was removed. void NotifySelectionRemoved(); // This is called when the ScopedChainForcedUpdate is created or destroyed. // This is used to ensure that we can create new locks that are immediately // forced by the existing forced scope. // // Consider the situation A -> B -> C, where C is the child node which is the // target of the forced lock (the parameter passed here), and B is its parent // and A is its grandparent. Suppose that A and B have locks, but since style // was blocked by A, B's lock has not been created yet. When we force the // update from C we call `NotifyNodeForced()`, and A's lock is forced by the // given ScopedChainForcedUpdate. Then we process the style and while // processing B's style, we find that there is a new lock there. This lock // needs to be forced immediately, since it is in the ancestor chain of C. // This is done by calling `ForceLockIfNeeded()` below, which adds B's scope // to the chain. At the end of the scope, everything is un-forced and // `EndNodeForcedScope()` is called to clean up state. // // Note that there can only be one scope created at a time, so we don't keep // track of more than one of these scopes. This is enforced by private access // modifier + friends, as well as DCHECKs. void BeginNodeForcedScope( const Node* node, bool self_was_forced, DisplayLockUtilities::ScopedChainForcedUpdate* scope); void EndNodeForcedScope(DisplayLockUtilities::ScopedChainForcedUpdate* scope); // Forces the lock on the given element, if it isn't yet forced but appears on // the ancestor chain for the forced element (which was set via // `BeginNodeForcedScope()`). void ForceLockIfNeeded(Element*); private: struct ForcedNodeInfo { ForcedNodeInfo(const Node* node, bool self_forced, DisplayLockUtilities::ScopedChainForcedUpdate* scope) : node(node), self_forced(self_forced), scope(scope) {} // Since this is created via a Scoped stack-only object, we know that GC // won't run so this is safe to store as an untraced member. UntracedMember<const Node> node; bool self_forced; DisplayLockUtilities::ScopedChainForcedUpdate* scope; }; IntersectionObserver& EnsureIntersectionObserver(); void ProcessDisplayLockActivationObservation( const HeapVector<Member<IntersectionObserverEntry>>&); void ForceLockIfNeededForInfo(Element*, ForcedNodeInfo*); // Note that since this class is owned by the document, it is important not to // take a strong reference for the backpointer. WeakMember<Document> document_ = nullptr; Member<IntersectionObserver> intersection_observer_ = nullptr; HeapHashSet<WeakMember<DisplayLockContext>> display_lock_contexts_; int locked_display_lock_count_ = 0; int display_lock_blocking_all_activation_count_ = 0; // If greater than 0, then the activatable locks are forced. int activatable_display_locks_forced_ = 0; // Contains all of the currently forced node infos, each of which represents // the node that caused the scope to be created. Vector<ForcedNodeInfo> forced_node_info_; }; } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_CORE_DISPLAY_LOCK_DISPLAY_LOCK_DOCUMENT_STATE_H_
[ "commit-bot@chromium.org" ]
commit-bot@chromium.org
4c253911adb8759cd97753fe49fbdd27a4a7dea1
1218f0e55768af3c39e4f643ce4e0799c10f19da
/stones.cpp
7738e81f6c6665cbaa0560375958159a78322b57
[]
no_license
ravinderdevesh/codechef
a5c35ea185663506f5e263c05e8262e5106802d8
f3bec3e9691afb552bf3d70e9582947958b20243
refs/heads/master
2021-01-19T19:01:49.612685
2015-02-21T16:37:44
2015-02-21T16:37:44
null
0
0
null
null
null
null
UTF-8
C++
false
false
395
cpp
#include <iostream> #include <stdio.h> using namespace std ; int main () { int T ; scanf("%d" , &T) ; while(T--) { string J , S ; cin >> J ; cin >> S ; int count = 0 ; int lj = J.length() ; int ls = S.length() ; for(int i = 0 ; i < ls ; i++) { for(int j = 0 ; j < lj ; j++) { if(S[i] == J[j]) { count++ ; break ; } } } printf("%d\n" , count) ; } }
[ "amangoeliitb@gmail.com" ]
amangoeliitb@gmail.com
90fa7980ae7898edefd5f68f6445609a2a4f3464
34a6d88518edb4eedc3d6cbaae1bca5894be2c6b
/C++/Point.h
6c24352c229619739061262776e1d59d60273a70
[]
no_license
DivyanshRoy/CryptographyProject
60178bbf4fc778df12966f0360c660045840676f
511b7259975c425a1f03fa5aaa95a43e75e9b706
refs/heads/master
2021-06-21T23:30:29.031857
2020-04-26T22:16:55
2020-04-26T22:16:55
254,508,536
0
0
null
null
null
null
UTF-8
C++
false
false
792
h
#include<bits/stdc++.h> using namespace std; class Point{ long x,y; public: Point(){} /* Point: Initialise with x and y coordinates of Elliptic curve point */ Point(long x, long y){ this->x = x; this->y = y; } /* getX: Return x coordinate of Elliptic curve point */ long getX() { return x; } /* getY: Return y coordinate of Elliptic curve point */ long getY() { return y; } /* setX: Store x coordinate of Elliptic curve point */ void setX(long x) { this->x = x; } /* setY: Store y coordinate of Elliptic curve point */ void setY(long y) { this->y = y; } };
[ "noreply@github.com" ]
DivyanshRoy.noreply@github.com
e2a02bf56df5e0d7f9a40bf61fd226921128a591
90047daeb462598a924d76ddf4288e832e86417c
/chromeos/printing/ppd_provider.cc
aa62d8b35c737ca08ee08911e5d6f78b4f9c4d6c
[ "BSD-3-Clause" ]
permissive
massbrowser/android
99b8c21fa4552a13c06bbedd0f9c88dd4a4ad080
a9c4371682c9443d6e1d66005d4db61a24a9617c
refs/heads/master
2022-11-04T21:15:50.656802
2017-06-08T12:31:39
2017-06-08T12:31:39
93,747,579
2
2
BSD-3-Clause
2022-10-31T10:34:25
2017-06-08T12:36:07
null
UTF-8
C++
false
false
39,322
cc
// Copyright 2016 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 "chromeos/printing/ppd_provider.h" #include <algorithm> #include <deque> #include <set> #include <unordered_map> #include <utility> #include <vector> #include "base/base64.h" #include "base/bind_helpers.h" #include "base/files/file.h" #include "base/files/file_util.h" #include "base/json/json_parser.h" #include "base/memory/ptr_util.h" #include "base/strings/string_number_conversions.h" #include "base/strings/string_split.h" #include "base/strings/string_tokenizer.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/synchronization/lock.h" #include "base/task_runner_util.h" #include "base/threading/sequenced_task_runner_handle.h" #include "base/threading/thread_restrictions.h" #include "base/time/time.h" #include "base/values.h" #include "chromeos/printing/ppd_cache.h" #include "chromeos/printing/printing_constants.h" #include "net/base/load_flags.h" #include "net/http/http_status_code.h" #include "net/url_request/url_fetcher.h" #include "net/url_request/url_fetcher_delegate.h" #include "net/url_request/url_request_context_getter.h" #include "url/gurl.h" namespace chromeos { namespace printing { namespace { // Extract cupsFilter/cupsFilter2 filter names from the contents // of a ppd, pre-split into lines. // cupsFilter2 lines look like this: // // *cupsFilter2: "application/vnd.cups-raster application/vnd.foo 100 // rastertofoo" // // cupsFilter lines look like this: // // *cupsFilter: "application/vnd.cups-raster 100 rastertofoo" // // |field_name| is the starting token we look for (*cupsFilter: or // *cupsFilter2:). // // |num_value_tokens| is the number of tokens we expect to find in the // value string. The filter is always the last of these. // // This function looks at each line in ppd_lines for lines of this format, and, // for each one found, adds the name of the filter (rastertofoo in the examples // above) to the returned set. // // This would be simpler with re2, but re2 is not an allowed dependency in // this part of the tree. std::set<std::string> ExtractCupsFilters( const std::vector<std::string>& ppd_lines, const std::string& field_name, int num_value_tokens) { std::set<std::string> ret; std::string delims(" \n\t\r\""); for (const std::string& line : ppd_lines) { base::StringTokenizer line_tok(line, delims); if (!line_tok.GetNext()) { continue; } if (line_tok.token_piece() != field_name) { continue; } // Skip to the last of the value tokens. for (int i = 0; i < num_value_tokens; ++i) { if (!line_tok.GetNext()) { // Continue the outer loop. goto next_line; } } if (line_tok.token_piece() != "") { ret.insert(line_tok.token_piece().as_string()); } next_line : {} // Lint requires {} instead of ; for an empty statement. } return ret; } // The ppd spec explicitly disallows quotes inside quoted strings, and provides // no way for including escaped quotes in a quoted string. It also requires // that the string be a single line, and that everything in these fields be // 7-bit ASCII. The CUPS spec on these particular fields is not particularly // rigorous, but specifies no way of including escaped spaces in the tokens // themselves, and the cups *code* just parses out these lines with a sscanf // call that uses spaces as delimiters. // // Furthermore, cups (post 1.5) discards all cupsFilter lines if *any* // cupsFilter2 lines exist. // // All of this is a long way of saying the regular-expression based parsing // done here is, to the best of my knowledge, actually conformant to the specs // that exist, and not just a hack. std::vector<std::string> ExtractFiltersFromPpd( const std::string& ppd_contents) { std::vector<std::string> lines = base::SplitString( ppd_contents, "\n\r", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); std::set<std::string> filters = ExtractCupsFilters(lines, "*cupsFilter2:", 4); if (filters.empty()) { // No cupsFilter2 lines found, fall back to looking for cupsFilter lines. filters = ExtractCupsFilters(lines, "*cupsFilter:", 3); } return std::vector<std::string>(filters.begin(), filters.end()); } // Returns false if there are obvious errors in the reference that will prevent // resolution. bool PpdReferenceIsWellFormed(const Printer::PpdReference& reference) { int filled_fields = 0; if (!reference.user_supplied_ppd_url.empty()) { ++filled_fields; GURL tmp_url(reference.user_supplied_ppd_url); if (!tmp_url.is_valid() || !tmp_url.SchemeIs("file")) { LOG(ERROR) << "Invalid url for a user-supplied ppd: " << reference.user_supplied_ppd_url << " (must be a file:// URL)"; return false; } } if (!reference.effective_make_and_model.empty()) { ++filled_fields; } // Should have exactly one non-empty field. return filled_fields == 1; } std::string PpdReferenceToCacheKey(const Printer::PpdReference& reference) { DCHECK(PpdReferenceIsWellFormed(reference)); // The key prefixes here are arbitrary, but ensure we can't have an (unhashed) // collision between keys generated from different PpdReference fields. if (!reference.effective_make_and_model.empty()) { return std::string("em:") + reference.effective_make_and_model; } else { return std::string("up:") + reference.user_supplied_ppd_url; } } struct ManufacturerMetadata { // Key used to look up the printer list on the server. This is initially // populated. std::string reference; // Map from localized printer name to canonical-make-and-model string for // the given printer. Populated on demand. std::unique_ptr<std::unordered_map<std::string, std::string>> printers; }; // Data for an inflight USB metadata resolution. struct UsbDeviceId { int vendor_id; int device_id; }; // A queued request to download printer information for a manufacturer. struct PrinterResolutionQueueEntry { // Localized manufacturer name std::string manufacturer; // URL we are going to pull from. GURL url; // User callback on completion. PpdProvider::ResolvePrintersCallback cb; }; class PpdProviderImpl : public PpdProvider, public net::URLFetcherDelegate { public: // What kind of thing is the fetcher currently fetching? We use this to // determine what to do when the fetcher returns a result. enum FetcherTarget { FT_LOCALES, // Locales metadata. FT_MANUFACTURERS, // List of manufacturers metadata. FT_PRINTERS, // List of printers from a manufacturer. FT_PPD_INDEX, // Master ppd index. FT_PPD, // A Ppd file. FT_USB_DEVICES // USB device id to canonical name map. }; PpdProviderImpl( const std::string& browser_locale, scoped_refptr<net::URLRequestContextGetter> url_context_getter, scoped_refptr<PpdCache> ppd_cache, scoped_refptr<base::SequencedTaskRunner> disk_task_runner, const PpdProvider::Options& options) : browser_locale_(browser_locale), url_context_getter_(url_context_getter), ppd_cache_(ppd_cache), disk_task_runner_(disk_task_runner), options_(options), weak_factory_(this) {} // Resolving manufacturers requires a couple of steps, because of // localization. First we have to figure out what locale to use, which // involves grabbing a list of available locales from the server. Once we // have decided on a locale, we go out and fetch the manufacturers map in that // localization. // // This means when a request comes in, we either queue it and start background // fetches if necessary, or we satisfy it immediately from memory. void ResolveManufacturers(const ResolveManufacturersCallback& cb) override { CHECK(base::SequencedTaskRunnerHandle::IsSet()) << "ResolveManufacturers must be called from a SequencedTaskRunner" "context"; if (cached_metadata_.get() != nullptr) { // We already have this in memory. base::SequencedTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(cb, PpdProvider::SUCCESS, GetManufacturerList())); return; } manufacturers_resolution_queue_.push_back(cb); MaybeStartFetch(); } // If there is work outstanding that requires a URL fetch to complete, start // going on it. void MaybeStartFetch() { if (fetch_inflight_) { // We'll call this again when the outstanding fetch completes. return; } if (!usb_resolution_queue_.empty()) { StartFetch(GetUsbURL(usb_resolution_queue_.front().first.vendor_id), FT_USB_DEVICES); return; } if (!manufacturers_resolution_queue_.empty()) { if (locale_.empty()) { // Don't have a locale yet, figure that out first. StartFetch(GetLocalesURL(), FT_LOCALES); } else { // Get manufacturers based on the locale we have. StartFetch(GetManufacturersURL(locale_), FT_MANUFACTURERS); } return; } if (!printers_resolution_queue_.empty()) { StartFetch(printers_resolution_queue_.front().url, FT_PRINTERS); return; } while (!ppd_resolution_queue_.empty()) { const auto& next = ppd_resolution_queue_.front(); if (!next.first.user_supplied_ppd_url.empty()) { DCHECK(next.first.effective_make_and_model.empty()); GURL url(next.first.user_supplied_ppd_url); DCHECK(url.is_valid()); StartFetch(url, FT_PPD); return; } DCHECK(!next.first.effective_make_and_model.empty()); if (cached_ppd_index_.get() == nullptr) { // Have to have the ppd index before we can resolve by ppd server // key. StartFetch(GetPpdIndexURL(), FT_PPD_INDEX); return; } // Get the URL from the ppd index and start the fetch. auto it = cached_ppd_index_->find(next.first.effective_make_and_model); if (it != cached_ppd_index_->end()) { StartFetch(GetPpdURL(it->second), FT_PPD); return; } // This ppd reference isn't in the index. That's not good. Fail // out the current resolution and go try to start the next // thing if there is one. LOG(ERROR) << "PPD " << next.first.effective_make_and_model << " not found in server index"; FinishPpdResolution(next.second, PpdProvider::INTERNAL_ERROR, std::string()); ppd_resolution_queue_.pop_front(); } } void ResolvePrinters(const std::string& manufacturer, const ResolvePrintersCallback& cb) override { std::unordered_map<std::string, ManufacturerMetadata>::iterator it; if (cached_metadata_.get() == nullptr || (it = cached_metadata_->find(manufacturer)) == cached_metadata_->end()) { // User error. LOG(ERROR) << "Can't resolve printers for unknown manufacturer " << manufacturer; base::SequencedTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(cb, PpdProvider::INTERNAL_ERROR, std::vector<std::string>())); return; } if (it->second.printers.get() != nullptr) { // Satisfy from the cache. base::SequencedTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(cb, PpdProvider::SUCCESS, GetManufacturerPrinterList(it->second))); } else { // We haven't resolved this manufacturer yet. PrinterResolutionQueueEntry entry; entry.manufacturer = manufacturer; entry.url = GetPrintersURL(it->second.reference); entry.cb = cb; printers_resolution_queue_.push_back(entry); MaybeStartFetch(); } } void ResolveUsbIds(int vendor_id, int device_id, const ResolveUsbIdsCallback& cb) override { usb_resolution_queue_.push_back({{vendor_id, device_id}, cb}); MaybeStartFetch(); } bool GetPpdReference(const std::string& manufacturer, const std::string& printer, Printer::PpdReference* reference) const override { std::unordered_map<std::string, ManufacturerMetadata>::iterator top_it; if (cached_metadata_.get() == nullptr) { return false; } auto it = cached_metadata_->find(manufacturer); if (it == cached_metadata_->end() || it->second.printers.get() == nullptr) { return false; } const auto& printers_map = *it->second.printers; auto it2 = printers_map.find(printer); if (it2 == printers_map.end()) { return false; } *reference = Printer::PpdReference(); reference->effective_make_and_model = it2->second; return true; } void ResolvePpd(const Printer::PpdReference& reference, const ResolvePpdCallback& cb) override { // Do a sanity check here, so we can assumed |reference| is well-formed in // the rest of this class. if (!PpdReferenceIsWellFormed(reference)) { FinishPpdResolution(cb, PpdProvider::INTERNAL_ERROR, std::string()); return; } // First step, check the cache. If the cache lookup fails, we'll (try to) // consult the server. ppd_cache_->Find(PpdReferenceToCacheKey(reference), base::Bind(&PpdProviderImpl::ResolvePpdCacheLookupDone, weak_factory_.GetWeakPtr(), reference, cb)); } // Our only sources of long running ops are cache fetches and network fetches. bool Idle() const override { return ppd_cache_->Idle() && !fetch_inflight_; } // Common handler that gets called whenever a fetch completes. Note this // is used both for |fetcher_| fetches (i.e. http[s]) and file-based fetches; // |source| may be null in the latter case. void OnURLFetchComplete(const net::URLFetcher* source) override { switch (fetcher_target_) { case FT_LOCALES: OnLocalesFetchComplete(); break; case FT_MANUFACTURERS: OnManufacturersFetchComplete(); break; case FT_PRINTERS: OnPrintersFetchComplete(); break; case FT_PPD_INDEX: OnPpdIndexFetchComplete(); break; case FT_PPD: OnPpdFetchComplete(); break; case FT_USB_DEVICES: OnUsbFetchComplete(); break; default: LOG(DFATAL) << "Unknown fetch source"; } fetch_inflight_ = false; MaybeStartFetch(); } private: // Return the URL used to look up the supported locales list. GURL GetLocalesURL() { return GURL(options_.ppd_server_root + "/metadata/locales.json"); } GURL GetUsbURL(int vendor_id) { DCHECK_GT(vendor_id, 0); DCHECK_LE(vendor_id, 0xffff); return GURL(base::StringPrintf("%s/metadata/usb-%04x.json", options_.ppd_server_root.c_str(), vendor_id)); } // Return the URL used to get the index of ppd server key -> ppd. GURL GetPpdIndexURL() { return GURL(options_.ppd_server_root + "/metadata/index.json"); } // Return the URL to get a localized manufacturers map. GURL GetManufacturersURL(const std::string& locale) { return GURL(base::StringPrintf("%s/metadata/manufacturers-%s.json", options_.ppd_server_root.c_str(), locale.c_str())); } // Return the URL used to get a list of printers from the manufacturer |ref|. GURL GetPrintersURL(const std::string& ref) { return GURL(base::StringPrintf( "%s/metadata/%s", options_.ppd_server_root.c_str(), ref.c_str())); } // Return the URL used to get a ppd with the given filename. GURL GetPpdURL(const std::string& filename) { return GURL(base::StringPrintf( "%s/ppds/%s", options_.ppd_server_root.c_str(), filename.c_str())); } // Create and return a fetcher that has the usual (for this class) flags set // and calls back to OnURLFetchComplete in this class when it finishes. void StartFetch(const GURL& url, FetcherTarget target) { DCHECK(!fetch_inflight_); DCHECK_EQ(fetcher_.get(), nullptr); fetcher_target_ = target; fetch_inflight_ = true; if (url.SchemeIs("http") || url.SchemeIs("https")) { fetcher_ = net::URLFetcher::Create(url, net::URLFetcher::GET, this); fetcher_->SetRequestContext(url_context_getter_.get()); fetcher_->SetLoadFlags(net::LOAD_BYPASS_CACHE | net::LOAD_DISABLE_CACHE | net::LOAD_DO_NOT_SAVE_COOKIES | net::LOAD_DO_NOT_SEND_COOKIES | net::LOAD_DO_NOT_SEND_AUTH_DATA); fetcher_->Start(); } else if (url.SchemeIs("file")) { disk_task_runner_->PostTaskAndReply( FROM_HERE, base::Bind(&PpdProviderImpl::FetchFile, this, url), base::Bind(&PpdProviderImpl::OnURLFetchComplete, this, nullptr)); } } // Fetch the file pointed at by url and store it in |file_fetch_contents_|. // Use |file_fetch_success_| to indicate success or failure. void FetchFile(const GURL& url) { CHECK(url.is_valid()); CHECK(url.SchemeIs("file")); base::ThreadRestrictions::AssertIOAllowed(); file_fetch_success_ = base::ReadFileToString(base::FilePath(url.path()), &file_fetch_contents_); } void FinishPpdResolution(const ResolvePpdCallback& cb, PpdProvider::CallbackResultCode result_code, const std::string& ppd_contents) { if (result_code == PpdProvider::SUCCESS) { base::SequencedTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(cb, PpdProvider::SUCCESS, ppd_contents, ExtractFiltersFromPpd(ppd_contents))); } else { // Just post the failure. base::SequencedTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(cb, result_code, std::string(), std::vector<std::string>())); } } // Callback when the cache lookup for a ppd request finishes. If we hit in // the cache, satisfy the resolution, otherwise kick it over to the fetcher // queue to be grabbed from a server. void ResolvePpdCacheLookupDone(const Printer::PpdReference& reference, const ResolvePpdCallback& cb, const PpdCache::FindResult& result) { if (result.success) { // Cache hit. FinishPpdResolution(cb, PpdProvider::SUCCESS, result.contents); } else { // Cache miss. Queue it to be satisfied by the fetcher queue. ppd_resolution_queue_.push_back({reference, cb}); MaybeStartFetch(); } } // Handler for the completion of the locales fetch. This response should be a // list of strings, each of which is a locale in which we can answer queries // on the server. The server (should) guarantee that we get 'en' as an // absolute minimum. // // Combine this information with the browser locale to figure out the best // locale to use, and then start a fetch of the manufacturers map in that // locale. void OnLocalesFetchComplete() { std::string contents; if (ValidateAndGetResponseAsString(&contents) != PpdProvider::SUCCESS) { FailQueuedMetadataResolutions(PpdProvider::SERVER_ERROR); return; } auto top_list = base::ListValue::From(base::JSONReader::Read(contents)); if (top_list.get() == nullptr) { // We got something malformed back. FailQueuedMetadataResolutions(PpdProvider::INTERNAL_ERROR); return; } // This should just be a simple list of locale strings. std::vector<std::string> available_locales; bool found_en = false; for (const base::Value& entry : *top_list) { std::string tmp; // Locales should have at *least* a two-character country code. 100 is an // arbitrary upper bound for length to protect against extreme bogosity. if (!entry.GetAsString(&tmp) || tmp.size() < 2 || tmp.size() > 100) { FailQueuedMetadataResolutions(PpdProvider::INTERNAL_ERROR); return; } if (tmp == "en") { found_en = true; } available_locales.push_back(tmp); } if (available_locales.empty() || !found_en) { // We have no locales, or we didn't get an english locale (which is our // ultimate fallback) FailQueuedMetadataResolutions(PpdProvider::INTERNAL_ERROR); return; } // Everything checks out, set the locale, head back to fetch dispatch // to start the manufacturer fetch. locale_ = GetBestLocale(available_locales); } // Called when the |fetcher_| is expected have the results of a // manufacturer map (which maps localized manufacturer names to keys for // looking up printers from that manufacturer). Use this information to // populate manufacturer_map_, and resolve all queued ResolveManufacturers() // calls. void OnManufacturersFetchComplete() { DCHECK_EQ(nullptr, cached_metadata_.get()); std::vector<std::pair<std::string, std::string>> contents; PpdProvider::CallbackResultCode code = ValidateAndParseJSONResponse(&contents); if (code != PpdProvider::SUCCESS) { LOG(ERROR) << "Failed manufacturer parsing"; FailQueuedMetadataResolutions(code); return; } cached_metadata_ = base::MakeUnique< std::unordered_map<std::string, ManufacturerMetadata>>(); for (const auto& entry : contents) { ManufacturerMetadata value; value.reference = entry.second; (*cached_metadata_)[entry.first].reference = entry.second; } std::vector<std::string> manufacturer_list = GetManufacturerList(); // Complete any queued manufacturer resolutions. for (const auto& cb : manufacturers_resolution_queue_) { base::SequencedTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(cb, PpdProvider::SUCCESS, manufacturer_list)); } manufacturers_resolution_queue_.clear(); } // The outstanding fetch associated with the front of // |printers_resolution_queue_| finished, use the response to satisfy that // ResolvePrinters() call. void OnPrintersFetchComplete() { CHECK(cached_metadata_.get() != nullptr); DCHECK(!printers_resolution_queue_.empty()); std::vector<std::pair<std::string, std::string>> contents; PpdProvider::CallbackResultCode code = ValidateAndParseJSONResponse(&contents); if (code != PpdProvider::SUCCESS) { base::SequencedTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(printers_resolution_queue_.front().cb, code, std::vector<std::string>())); } else { // This should be a list of lists of 2-element strings, where the first // element is the localized name of the printer and the second element // is the canonical name of the printer. const std::string& manufacturer = printers_resolution_queue_.front().manufacturer; auto it = cached_metadata_->find(manufacturer); // If we kicked off a resolution, the entry better have already been // in the map. CHECK(it != cached_metadata_->end()); // Create the printer map in the cache, and populate it. auto& manufacturer_metadata = it->second; CHECK(manufacturer_metadata.printers.get() == nullptr); manufacturer_metadata.printers = base::MakeUnique<std::unordered_map<std::string, std::string>>(); for (const auto& entry : contents) { manufacturer_metadata.printers->insert({entry.first, entry.second}); } base::SequencedTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(printers_resolution_queue_.front().cb, PpdProvider::SUCCESS, GetManufacturerPrinterList(manufacturer_metadata))); } printers_resolution_queue_.pop_front(); } // Called when |fetcher_| should have just received the index mapping // ppd server keys to ppd filenames. Use this to populate // |cached_ppd_index_|. void OnPpdIndexFetchComplete() { std::vector<std::pair<std::string, std::string>> contents; PpdProvider::CallbackResultCode code = ValidateAndParseJSONResponse(&contents); if (code != PpdProvider::SUCCESS) { FailQueuedServerPpdResolutions(code); } else { cached_ppd_index_ = base::MakeUnique<std::unordered_map<std::string, std::string>>(); // This should be a list of lists of 2-element strings, where the first // element is the |effective_make_and_model| of the printer and the second // element is the filename of the ppd in the ppds/ directory on the // server. for (const auto& entry : contents) { cached_ppd_index_->insert(entry); } } } // This is called when |fetcher_| should have just downloaded a ppd. If we // downloaded something successfully, use it to satisfy the front of the ppd // resolution queue, otherwise fail out that resolution. void OnPpdFetchComplete() { DCHECK(!ppd_resolution_queue_.empty()); std::string contents; if ((ValidateAndGetResponseAsString(&contents) != PpdProvider::SUCCESS) || contents.size() > kMaxPpdSizeBytes) { FinishPpdResolution(ppd_resolution_queue_.front().second, PpdProvider::SERVER_ERROR, std::string()); } else { ppd_cache_->Store( PpdReferenceToCacheKey(ppd_resolution_queue_.front().first), contents, base::Callback<void()>()); FinishPpdResolution(ppd_resolution_queue_.front().second, PpdProvider::SUCCESS, contents); } ppd_resolution_queue_.pop_front(); } // Called when |fetcher_| should have just downloaded a usb device map // for the vendor at the head of the |usb_resolution_queue_|. void OnUsbFetchComplete() { DCHECK(!usb_resolution_queue_.empty()); std::string contents; std::string buffer; PpdProvider::CallbackResultCode result = ValidateAndGetResponseAsString(&buffer); int desired_device_id = usb_resolution_queue_.front().first.device_id; if (result == PpdProvider::SUCCESS) { // Parse the JSON response. This should be a list of the form // [ // [0x3141, "some canonical name"], // [0x5926, "some othercanonical name"] // ] // So we scan through the response looking for our desired device id. auto top_list = base::ListValue::From(base::JSONReader::Read(buffer)); if (top_list.get() == nullptr) { // We got something malformed back. LOG(ERROR) << "Malformed top list"; result = PpdProvider::INTERNAL_ERROR; } else { // We'll set result to SUCCESS if we do find the device. result = PpdProvider::NOT_FOUND; for (const auto& entry : *top_list) { int device_id; const base::ListValue* sub_list; // Each entry should be a size-2 list with an integer and a string. if (!entry.GetAsList(&sub_list) || sub_list->GetSize() != 2 || !sub_list->GetInteger(0, &device_id) || !sub_list->GetString(1, &contents) || device_id < 0 || device_id > 0xffff) { // Malformed data. LOG(ERROR) << "Malformed line in usb device list"; result = PpdProvider::INTERNAL_ERROR; break; } if (device_id == desired_device_id) { // Found it. result = PpdProvider::SUCCESS; break; } } } } if (result != PpdProvider::SUCCESS) { contents.clear(); } base::SequencedTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(usb_resolution_queue_.front().second, result, contents)); usb_resolution_queue_.pop_front(); } // Something went wrong during metadata fetches. Fail all queued metadata // resolutions with the given error code. void FailQueuedMetadataResolutions(PpdProvider::CallbackResultCode code) { for (const auto& cb : manufacturers_resolution_queue_) { base::SequencedTaskRunnerHandle::Get()->PostTask( FROM_HERE, base::Bind(cb, code, std::vector<std::string>())); } manufacturers_resolution_queue_.clear(); } // Fail all server-based ppd resolutions inflight, because we failed to grab // the necessary index data from the server. Note we leave any user-based ppd // resolutions intact, as they don't depend on the data we're missing. void FailQueuedServerPpdResolutions(PpdProvider::CallbackResultCode code) { std::deque<std::pair<Printer::PpdReference, ResolvePpdCallback>> filtered_queue; for (const auto& entry : ppd_resolution_queue_) { if (!entry.first.user_supplied_ppd_url.empty()) { filtered_queue.push_back(entry); } else { FinishPpdResolution(entry.second, code, std::string()); } } ppd_resolution_queue_ = std::move(filtered_queue); } // Given a list of possible locale strings (e.g. 'en-GB'), determine which of // them we should use to best serve results for the browser locale (which was // given to us at construction time). std::string GetBestLocale(const std::vector<std::string>& available_locales) { // First look for an exact match. If we find one, just use that. for (const std::string& available : available_locales) { if (available == browser_locale_) { return available; } } // Next, look for an available locale that is a parent of browser_locale_. // Return the most specific one. For example, if we want 'en-GB-foo' and we // don't have an exact match, but we do have 'en-GB' and 'en', we will // return 'en-GB' -- the most specific match which is a parent of the // requested locale. size_t best_len = 0; size_t best_idx = -1; for (size_t i = 0; i < available_locales.size(); ++i) { const std::string& available = available_locales[i]; if (base::StringPiece(browser_locale_).starts_with(available + "-") && available.size() > best_len) { best_len = available.size(); best_idx = i; } } if (best_idx != static_cast<size_t>(-1)) { return available_locales[best_idx]; } // Last chance for a match, look for the locale that matches the *most* // pieces of locale_, with ties broken by being least specific. So for // example, if we have 'es-GB', 'es-GB-foo' but no 'es' available, and we're // requesting something for 'es', we'll get back 'es-GB' -- the least // specific thing that matches some of the locale. std::vector<base::StringPiece> browser_locale_pieces = base::SplitStringPiece(browser_locale_, "-", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL); size_t best_match_size = 0; size_t best_match_specificity; best_idx = -1; for (size_t i = 0; i < available_locales.size(); ++i) { const std::string& available = available_locales[i]; std::vector<base::StringPiece> available_pieces = base::SplitStringPiece( available, "-", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL); size_t match_size = 0; for (; match_size < available_pieces.size() && match_size < browser_locale_pieces.size(); ++match_size) { if (available_pieces[match_size] != browser_locale_pieces[match_size]) { break; } } if (match_size > 0 && (best_idx == static_cast<size_t>(-1) || match_size > best_match_size || (match_size == best_match_size && available_pieces.size() < best_match_specificity))) { best_idx = i; best_match_size = match_size; best_match_specificity = available_pieces.size(); } } if (best_idx != static_cast<size_t>(-1)) { return available_locales[best_idx]; } // Everything else failed. Throw up our hands and default to english. return "en"; } // Get the results of a fetch. This is a little tricky, because a fetch // may have been done by |fetcher_|, or it may have been a file access, in // which case we want to look at |file_fetch_contents_|. We distinguish // between the cases based on whether or not |fetcher_| is null. // // We return NOT_FOUND for 404 or file not found, SERVER_ERROR for other // errors, SUCCESS if everything was good. CallbackResultCode ValidateAndGetResponseAsString(std::string* contents) { CallbackResultCode ret; if (fetcher_.get() != nullptr) { if (fetcher_->GetStatus().status() != net::URLRequestStatus::SUCCESS) { ret = PpdProvider::SERVER_ERROR; } else if (fetcher_->GetResponseCode() != net::HTTP_OK) { if (fetcher_->GetResponseCode() == net::HTTP_NOT_FOUND) { // A 404 means not found, everything else is a server error. ret = PpdProvider::NOT_FOUND; } else { ret = PpdProvider::SERVER_ERROR; } } else { fetcher_->GetResponseAsString(contents); ret = PpdProvider::SUCCESS; } fetcher_.reset(); } else { // It's a file load. if (file_fetch_success_) { *contents = file_fetch_contents_; } else { contents->clear(); } // A failure to load a file is always considered a NOT FOUND error (even // if the underlying causes is lack of access or similar, this seems to be // the best match for intent. ret = file_fetch_success_ ? PpdProvider::SUCCESS : PpdProvider::NOT_FOUND; file_fetch_contents_.clear(); } return ret; } // Many of our metadata fetches happens to be in the form of a JSON // list-of-lists-of-2-strings. So this just attempts to parse a JSON reply to // |fetcher| into the passed contents vector. A return code of SUCCESS means // the JSON was formatted as expected and we've parsed it into |contents|. On // error the contents of |contents| cleared. PpdProvider::CallbackResultCode ValidateAndParseJSONResponse( std::vector<std::pair<std::string, std::string>>* contents) { contents->clear(); std::string buffer; auto tmp = ValidateAndGetResponseAsString(&buffer); if (tmp != PpdProvider::SUCCESS) { return tmp; } auto top_list = base::ListValue::From(base::JSONReader::Read(buffer)); if (top_list.get() == nullptr) { // We got something malformed back. return PpdProvider::INTERNAL_ERROR; } for (const auto& entry : *top_list) { const base::ListValue* sub_list; contents->push_back({}); if (!entry.GetAsList(&sub_list) || sub_list->GetSize() != 2 || !sub_list->GetString(0, &contents->back().first) || !sub_list->GetString(1, &contents->back().second)) { contents->clear(); return PpdProvider::INTERNAL_ERROR; } } return PpdProvider::SUCCESS; } // Create the list of manufacturers from |cached_metadata_|. Requires that // the manufacturer list has already been resolved. std::vector<std::string> GetManufacturerList() const { CHECK(cached_metadata_.get() != nullptr); std::vector<std::string> ret; ret.reserve(cached_metadata_->size()); for (const auto& entry : *cached_metadata_) { ret.push_back(entry.first); } // TODO(justincarlson) -- this should be a localization-aware sort. sort(ret.begin(), ret.end()); return ret; } // Get the list of printers from a given manufacturer from |cached_metadata_|. // Requires that we have already resolved this from the server. std::vector<std::string> GetManufacturerPrinterList( const ManufacturerMetadata& meta) const { CHECK(meta.printers.get() != nullptr); std::vector<std::string> ret; ret.reserve(meta.printers->size()); for (const auto& entry : *meta.printers) { ret.push_back(entry.first); } // TODO(justincarlson) -- this should be a localization-aware sort. sort(ret.begin(), ret.end()); return ret; } // Map from (localized) manufacturer name to metadata for that manufacturer. // This is populated lazily. If we don't yet have a manufacturer list, the // top pointer will be null. When we create the top level map, then each // value will only contain a reference which can be used to resolve the // printer list from that manufacturer. On demand, we use these references to // resolve the actual printer lists. std::unique_ptr<std::unordered_map<std::string, ManufacturerMetadata>> cached_metadata_; // Cached contents of the server index, which maps a // PpdReference::effective_make_and_model to a url for the corresponding // ppd. // Null until we have fetched the index. std::unique_ptr<std::unordered_map<std::string, std::string>> cached_ppd_index_; // Queued ResolveManufacturers() calls. We will simultaneously resolve // all queued requests, so no need for a deque here. std::vector<ResolveManufacturersCallback> manufacturers_resolution_queue_; // Queued ResolvePrinters() calls. std::deque<PrinterResolutionQueueEntry> printers_resolution_queue_; // Queued ResolvePpd() requests. std::deque<std::pair<Printer::PpdReference, ResolvePpdCallback>> ppd_resolution_queue_; // Queued ResolveUsbIds() requests. std::deque<std::pair<UsbDeviceId, ResolveUsbIdsCallback>> usb_resolution_queue_; // Locale we're using for grabbing stuff from the server. Empty if we haven't // determined it yet. std::string locale_; // If the fetcher is active, what's it fetching? FetcherTarget fetcher_target_; // Fetcher used for all network fetches. This is explicitly reset() when // a fetch has been processed. std::unique_ptr<net::URLFetcher> fetcher_; bool fetch_inflight_ = false; // Locale of the browser, as returned by // BrowserContext::GetApplicationLocale(); const std::string browser_locale_; scoped_refptr<net::URLRequestContextGetter> url_context_getter_; // For file:// fetches, a staging buffer and result flag for loading the file. std::string file_fetch_contents_; bool file_fetch_success_; // Cache of ppd files. scoped_refptr<PpdCache> ppd_cache_; // Where to run disk operations. scoped_refptr<base::SequencedTaskRunner> disk_task_runner_; // Construction-time options, immutable. const PpdProvider::Options options_; base::WeakPtrFactory<PpdProviderImpl> weak_factory_; protected: ~PpdProviderImpl() override {} }; } // namespace // static scoped_refptr<PpdProvider> PpdProvider::Create( const std::string& browser_locale, scoped_refptr<net::URLRequestContextGetter> url_context_getter, scoped_refptr<PpdCache> ppd_cache, scoped_refptr<base::SequencedTaskRunner> disk_task_runner, const PpdProvider::Options& options) { return scoped_refptr<PpdProvider>( new PpdProviderImpl(browser_locale, url_context_getter, ppd_cache, disk_task_runner, options)); } } // namespace printing } // namespace chromeos
[ "xElvis89x@gmail.com" ]
xElvis89x@gmail.com